:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --panel: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.78);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --muted-soft: #86868b;
  --line: rgba(0, 0, 0, 0.10);
  --line-soft: rgba(0, 0, 0, 0.06);
  --soft: #f5f5f7;
  --accent: #0071e3;
  --accent-dark: #0077ed;
  --danger: #b42318;
  --danger-bg: #fff1f0;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, #fbfbfd 0%, #f5f5f7 42%, #ffffff 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(980px, calc(100% - 40px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 12px 0 26px;
  text-align: center;
}

.brand-logo {
  width: min(200px, 54vw);
  height: auto;
  display: block;
  margin-bottom: 4px;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: 40px;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0;
}

p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0;
}

.query-panel {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 28px;
  background: var(--panel-soft);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.08);
  backdrop-filter: saturate(180%) blur(22px);
}

.search-form label {
  display: block;
  margin: 0 0 10px 4px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 104px;
  gap: 12px;
}

.search-field {
  position: relative;
}

input,
button {
  height: 52px;
  border-radius: 999px;
  font-size: 17px;
}

input {
  width: 100%;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.92);
  padding: 0 20px;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

input::placeholder {
  color: #a1a1a6;
}

input:focus {
  outline: 4px solid rgba(0, 113, 227, 0.14);
  border-color: rgba(0, 113, 227, 0.48);
  background: #fff;
}

button {
  border: 0;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 113, 227, 0.20);
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.12);
  backdrop-filter: saturate(180%) blur(18px);
}

.suggestion-item {
  width: 100%;
  height: auto;
  display: block;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: rgba(0, 113, 227, 0.08);
}

.suggestion-item:last-child {
  border-bottom: 0;
}

.suggestion-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.suggestion-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.suggestion-empty {
  padding: 14px 16px;
  color: var(--muted);
}

/* ---------- 常用店铺 / 最近搜索 ---------- */
.recent-searches {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 4px 6px;
  padding: 0;
}

.recent-searches[hidden] {
  display: none !important;
}

.recent-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-right: 4px;
}

.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  box-shadow: none;
  transition: all 0.15s ease;
}

.recent-chip:hover {
  background: rgba(0, 113, 227, 0.10);
  border-color: rgba(0, 113, 227, 0.20);
  color: var(--accent);
}

.recent-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.recent-chip-remove:hover {
  color: var(--danger);
}

.status {
  min-height: 24px;
  margin: 18px 4px 10px;
  color: var(--muted);
  font-size: 14px;
}

.status.error {
  color: var(--danger);
}

/* ---------- 查询中状态：骨架屏 + 按钮 loading ---------- */
.skeleton-card {
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  padding: 22px;
  background: #fff;
  animation: skeleton-pulse 1.2s ease-in-out infinite;
}

.skeleton-line {
  height: 14px;
  border-radius: 999px;
  background: #e9eaee;
}

.skeleton-title {
  width: 40%;
  height: 20px;
  margin-bottom: 16px;
}

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.skeleton-block {
  height: 84px;
  border-radius: 16px;
  background: #e9eaee;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

button.loading {
  position: relative;
  color: transparent !important;
}

button.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- 低余额卡片：红色顶部条带 ---------- */
.meter-card {
  position: relative;
  overflow: hidden;
}

.meter-card-low::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--danger);
}

/* ---------- 自动补全低余额 ---------- */
.suggestion-meta-low {
  color: var(--danger) !important;
}

/* ---------- 空态 / 错误态 ---------- */
.state-panel {
  padding: 36px 20px;
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  background: #fff;
  text-align: center;
}

.state-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
}

.state-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.state-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.retry-button {
  display: inline-block;
  margin-top: 18px;
  padding: 0 28px;
  height: 44px;
  border-radius: 999px;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 113, 227, 0.20);
}

.retry-button:hover {
  background: var(--accent-dark);
}

/* ---------- 页脚 & 充值指引触发 ---------- */
.page-footer {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.page-footer p {
  max-width: none;
  margin: 0 auto;
}

.guide-trigger-link {
  display: inline;
  height: auto;
  padding: 0 2px;
  margin-left: 6px;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: none;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.guide-trigger-link:hover {
  color: var(--accent-dark);
  background: transparent;
}

.footer-stats {
  margin: 6px auto 0 !important;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.2px;
}

.footer-stats strong {
  color: var(--text);
  font-weight: 600;
}

.footer-update {
  font-size: 12px;
  opacity: 0.8;
}

.results {
  display: grid;
  gap: 16px;
}

.result-card {
  border: 1px solid var(--line-soft);
  border-radius: 24px;
  padding: 22px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.06);
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.result-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.22;
}

.result-meta {
  color: var(--muted);
  margin-top: 5px;
  font-size: 14px;
}

/* ---------- 请款复制按钮 ---------- */
.copy-claim-btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  background: #fff1f0;
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.24);
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.copy-claim-btn:hover {
  background: #ffe3e1;
  color: #901b12;
  border-color: rgba(180, 35, 24, 0.4);
}

.copy-claim-btn.copied {
  background: #e6f7ec !important;
  color: #137333 !important;
  border-color: rgba(19, 115, 51, 0.3) !important;
}

.cycle-row {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.metric-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}

.metric-grid-primary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-grid-secondary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric {
  min-height: 116px;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  padding: 16px;
  background: var(--soft);
}

.metric label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.18;
  overflow-wrap: anywhere;
}

.metric-alert {
  border-color: rgba(180, 35, 24, 0.16);
  background: var(--danger-bg);
}

.low-balance {
  color: var(--danger) !important;
}

.metric-warning {
  margin-top: 8px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.meter-summary {
  color: var(--muted);
  font-size: 14px;
}

.meter-summary strong {
  color: var(--text);
  font-weight: 700;
}

.meter-cards {
  display: grid;
  gap: 14px;
}

.meter-card {
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  padding: 16px;
  background: var(--soft);
}

.meter-card-low {
  border-color: rgba(180, 35, 24, 0.16);
  background: var(--danger-bg);
}

.meter-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.meter-card-head .meter-address {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.meter-index {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.meter-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.meter-card-grid .metric {
  min-height: 108px;
  padding: 14px;
}

.meter-card-grid .metric strong {
  font-size: 20px;
}

@media (max-width: 640px) {
  .meter-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.recharge-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}

.recharge-section h2 {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}

.recharge-row,
.bill-row {
  padding: 13px 0;
  border-top: 1px solid var(--line-soft);
}

.recharge-row:first-of-type,
.bill-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.bill-main {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: start;
}

.bill-month,
.bill-usage,
.recharge-amount {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

.bill-numbers {
  display: grid;
  justify-items: end;
  gap: 4px;
  text-align: right;
}

.bill-detail-button {
  width: auto;
  height: 32px;
  margin-top: 5px;
  padding: 0 14px;
  border: 1px solid rgba(0, 113, 227, 0.18);
  border-radius: 999px;
  background: rgba(0, 113, 227, 0.08);
  color: var(--accent);
  box-shadow: none;
  font-size: 13px;
  font-weight: 700;
}

.bill-detail-button:hover {
  background: rgba(0, 113, 227, 0.12);
}

.bill-meters[hidden] {
  display: none;
}

.bill-meters {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 16px;
  background: var(--soft);
}

.bill-meter-card {
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.bill-meter-card:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.bill-meter-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.bill-meter-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bill-meter-usage {
  color: var(--text);
  white-space: nowrap;
}

.bill-tiers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.bill-tier {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: #fff;
}

.bill-tier span,
.recharge-meta,
.recharge-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.bill-tier strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.recharge-address {
  align-self: center;
}

/* ---------- 弹窗组件 (Modal) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  animation: modal-fade-in 0.2s ease-out;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-panel {
  width: min(520px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.16);
  padding: 24px;
  animation: modal-scale-in 0.2s ease-out;
}

@keyframes modal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-scale-in {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.06);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.12);
  color: var(--text);
}

.modal-body {
  display: grid;
  gap: 16px;
  padding: 18px 0;
}

.guide-item {
  display: grid;
  gap: 4px;
}

.guide-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.guide-text {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
}

.guide-text strong {
  color: var(--text);
}

.modal-foot {
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  text-align: right;
}

.modal-confirm-btn {
  height: 42px;
  padding: 0 24px;
  font-size: 15px;
  border-radius: 999px;
}

@media (max-width: 680px) {
  .page-shell {
    width: 100%;
    padding: 22px 14px 32px;
  }

  .hero {
    padding: 6px 0 18px;
    gap: 8px;
  }

  .brand-logo {
    width: min(170px, 58vw);
  }

  h1 {
    font-size: 30px;
    line-height: 1.12;
  }

  p {
    max-width: 320px;
    font-size: 15px;
  }

  .query-panel {
    padding: 16px;
    border-radius: 24px;
  }

  .search-row,
  .metric-grid,
  .meter-row,
  .recharge-row,
  .bill-main,
  .bill-meter-row {
    grid-template-columns: 1fr;
  }

  input,
  button {
    height: 50px;
    font-size: 16px;
  }

  .suggestions {
    max-height: 54vh;
    border-radius: 16px;
  }

  .suggestion-item {
    padding: 14px;
  }

  .result-card {
    padding: 16px;
    border-radius: 22px;
  }

  .result-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .copy-claim-btn {
    width: 100%;
    height: 38px;
  }

  .result-title {
    font-size: 21px;
  }

  .metric {
    min-height: 0;
  }

  .metric strong {
    font-size: 22px;
  }

  .meter-row {
    gap: 6px;
  }

  .meter-value {
    white-space: normal;
  }

  .bill-numbers,
  .bill-meter-usage {
    text-align: left;
  }

  .bill-numbers {
    justify-items: start;
  }

  .bill-tiers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .meter-card {
    padding: 14px;
    border-radius: 18px;
  }

  .meter-card-grid .metric {
    min-height: 96px;
    padding: 12px;
  }

  .meter-card-grid .metric strong {
    font-size: 17px;
  }

  .skeleton-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .state-panel {
    padding: 28px 16px;
  }

  .page-footer {
    font-size: 12px;
  }

  .modal-panel {
    padding: 20px;
  }
}

@media (max-width: 400px) {
  .meter-card-grid {
    grid-template-columns: 1fr;
  }
}
