:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --text: #14211d;
  --muted: #6b7b75;
  --line: #dfe8e4;
  --accent: #0d8f6a;
  --accent-strong: #087456;
  --accent-soft: #e4f5ee;
  --danger: #b54545;
  --danger-soft: #fff0ef;
  --shadow: 0 22px 60px rgba(25, 54, 44, 0.09);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0c1210;
    --surface: rgba(20, 29, 25, 0.9);
    --surface-solid: #141d19;
    --text: #ecf5f1;
    --muted: #93a69d;
    --line: #27362f;
    --accent: #45d3a2;
    --accent-strong: #6ce4ba;
    --accent-soft: #173b2f;
    --danger: #ff8d86;
    --danger-soft: #3a2221;
    --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, rgba(13, 143, 106, 0.09), transparent 34rem),
    radial-gradient(circle at 92% 12%, rgba(76, 148, 196, 0.07), transparent 28rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.page-shell {
  width: min(100% - 32px, 920px);
  margin: 0 auto;
  padding: 28px 0 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 30px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  background: linear-gradient(145deg, #11a77b, #087456);
  box-shadow: 0 8px 22px rgba(13, 143, 106, 0.24);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font-size: 16px;
  letter-spacing: 0.14em;
}

.brand-copy span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.16em;
}

.mode-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  backdrop-filter: blur(12px);
}

.mode-dot,
.detail-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.balance-card {
  position: relative;
  overflow: hidden;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.card-glow {
  position: absolute;
  top: -140px;
  right: -100px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(13, 143, 106, 0.16), transparent 68%);
  pointer-events: none;
}

.balance-heading,
.action-row,
.progress-labels {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.18em;
}

h1 {
  margin: 0;
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 720;
  letter-spacing: -0.03em;
}

.account-badge {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.amount-line {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 92px;
  margin-top: 18px;
}

.currency-symbol {
  color: var(--muted);
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 600;
}

.amount-value {
  font-size: clamp(48px, 9vw, 76px);
  font-weight: 760;
  line-height: 1.08;
  letter-spacing: -0.065em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.balance-note {
  min-height: 22px;
  margin: 8px 0 28px;
  color: var(--muted);
  font-size: 14px;
}

.progress-block {
  position: relative;
  margin-bottom: 28px;
}

.progress-labels {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.progress-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: var(--accent-soft);
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0d8f6a, #39c496);
  transition: width 420ms ease;
}

.refresh-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 22px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, #0d9670, #087456);
  box-shadow: 0 10px 24px rgba(13, 143, 106, 0.22);
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.refresh-button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(13, 143, 106, 0.28);
}

.refresh-button:active:not(:disabled) {
  transform: translateY(0);
}

.refresh-button:focus-visible,
.dismiss-error:focus-visible,
.brand:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.refresh-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.refresh-button.is-loading .refresh-icon {
  animation: spin 800ms linear infinite;
}

.update-time {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.error-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 24%, transparent);
  border-radius: 12px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 13px;
  line-height: 1.5;
}

.error-banner[hidden] {
  display: none;
}

.dismiss-error {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  color: inherit;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.stat-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  backdrop-filter: blur(14px);
}

.stat-label {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat-value {
  margin: 0;
  font-size: clamp(20px, 3.5vw, 27px);
  font-weight: 720;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.stat-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.detail-strip {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.detail-strip > div {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.detail-dot {
  flex: 0 0 auto;
  margin-top: 7px;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 34px;
  padding: 18px 4px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.noscript {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  padding: 14px;
  border-radius: 12px;
  color: var(--danger);
  background: var(--danger-soft);
  text-align: center;
}

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

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 24px, 520px);
    padding-top: 18px;
  }

  .topbar {
    margin-bottom: 20px;
  }

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

  .amount-line {
    min-height: 74px;
    margin-top: 16px;
  }

  .amount-value {
    font-size: clamp(44px, 14vw, 64px);
  }

  .balance-note {
    margin-bottom: 24px;
  }

  .action-row {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .refresh-button {
    width: 100%;
  }

  .update-time {
    text-align: center;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 4px 14px;
    padding: 16px 18px;
  }

  .stat-label {
    margin: 0;
  }

  .stat-value {
    grid-row: span 2;
    grid-column: 2;
    font-size: 22px;
  }

  .stat-meta {
    margin: 0;
  }

  .footer {
    flex-direction: column;
    gap: 6px;
    margin-top: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
