:root {
  color-scheme: light;
  --bg: #eef4f4;
  --panel: #ffffff;
  --ink: #122322;
  --muted: #647675;
  --line: #d9e6e4;
  --accent: #08736b;
  --accent-dark: #075e59;
  --accent-soft: #ddf3ef;
  --blue: #105cb6;
  --good: #058352;
  --bad: #c13b31;
  --warn: #a76005;
  --shadow: 0 14px 38px rgba(15, 59, 56, 0.1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 100% 0%, rgba(72, 193, 178, 0.15), transparent 34rem),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; }

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
}
.login-card {
  width: min(100%, 430px);
  min-width: 0;
  overflow: hidden;
  padding: 30px 24px 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  box-shadow: var(--shadow);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: 22px;
  border-radius: 17px;
  color: white;
  background: linear-gradient(145deg, #0f8e82, #075e59);
  box-shadow: 0 10px 24px rgba(8, 115, 107, 0.28);
  font-size: 28px;
  font-weight: 900;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
.login-card h1 { margin-bottom: 10px; font-size: 30px; letter-spacing: -.03em; }
.login-intro { margin-bottom: 26px; color: var(--muted); line-height: 1.7; }
.field-label { display: block; margin-bottom: 8px; color: #425553; font-size: 13px; font-weight: 700; }
#accessCode {
  width: 100%;
  min-width: 0;
  height: 54px;
  padding: 0 16px;
  border: 1px solid #c7d8d6;
  border-radius: 15px;
  outline: none;
  color: var(--ink);
  background: #f9fcfb;
  font-size: 19px;
  letter-spacing: .14em;
  text-align: center;
}
#accessCode:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(8,115,107,.11); }
.primary-button, .secondary-button {
  border: 0;
  border-radius: 14px;
  font-weight: 800;
}
.primary-button {
  width: 100%;
  min-height: 50px;
  margin-top: 12px;
  color: white;
  background: linear-gradient(135deg, #0a8177, #075e59);
  box-shadow: 0 9px 20px rgba(8,115,107,.2);
}
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button.compact { min-height: 42px; margin-top: 10px; }
.form-message { min-height: 22px; margin: 10px 0 0; color: var(--bad); font-size: 13px; text-align: center; }
.privacy-note { margin-top: 20px; padding: 14px; border-radius: 15px; background: var(--accent-soft); }
.privacy-note strong, .privacy-note span { display: block; }
.privacy-note strong { margin-bottom: 4px; color: var(--accent-dark); font-size: 13px; }
.privacy-note span { color: #52706d; font-size: 12px; line-height: 1.6; }

.mobile-shell { width: min(100%, 760px); margin: 0 auto; padding: 0 14px 104px; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 -14px;
  padding: max(15px, env(safe-area-inset-top)) 18px 13px;
  background: rgba(238, 244, 244, .92);
  border-bottom: 1px solid rgba(205, 222, 220, .82);
  backdrop-filter: blur(18px);
}
.app-header h1 { margin: 0; font-size: 22px; letter-spacing: -.03em; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.readonly-badge { padding: 6px 9px; border-radius: 999px; color: var(--accent-dark); background: var(--accent-soft); font-size: 11px; font-weight: 800; }
.icon-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--accent-dark);
  background: white;
  font-size: 22px;
}
.icon-button.is-loading { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.range-panel, .section-card, .device-card, .warning-box {
  margin-top: 14px;
  border: 1px solid rgba(211, 226, 224, .95);
  border-radius: 20px;
  background: var(--panel);
  box-shadow: 0 7px 22px rgba(28, 70, 66, .055);
}
.range-panel { padding: 15px 16px; }
.range-summary { display: flex; align-items: center; justify-content: space-between; }
.range-summary span, .section-title span { display: block; color: var(--muted); font-size: 11px; }
.range-summary strong { display: block; margin-top: 3px; font-size: 15px; }
.text-button { border: 0; color: var(--accent); background: transparent; font-weight: 800; }
.range-controls { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.preset-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.preset-row button { min-height: 36px; border: 1px solid var(--line); border-radius: 11px; color: #526563; background: #f7faf9; }
.preset-row button.is-active { color: white; border-color: var(--accent); background: var(--accent); }
.date-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.date-grid label { color: var(--muted); font-size: 11px; }
.date-grid input { width: 100%; height: 40px; margin-top: 5px; padding: 0 9px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: white; }

.loading-panel { display: grid; justify-items: center; gap: 7px; margin: 14px 0; padding: 44px 20px; border-radius: 22px; color: var(--muted); background: rgba(255,255,255,.75); }
.loading-panel strong { color: #3c504e; font-size: 14px; }
.loading-panel small { font-size: 11px; }
.spinner { width: 28px; height: 28px; margin-bottom: 3px; border: 3px solid #cee0de; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }

.hero-card {
  margin-top: 14px;
  padding: 22px 20px;
  overflow: hidden;
  border-radius: 23px;
  color: white;
  background:
    radial-gradient(circle at 90% 0%, rgba(132, 238, 217, .35), transparent 45%),
    linear-gradient(140deg, #0b746c, #074b48);
  box-shadow: 0 16px 34px rgba(7, 75, 72, .23);
}
.hero-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero-heading span { color: rgba(255,255,255,.72); font-size: 12px; }
.hero-heading strong { display: block; margin-top: 8px; font-size: clamp(30px, 10vw, 42px); line-height: 1; letter-spacing: -.05em; }
.margin-pill { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; color: white !important; background: rgba(255,255,255,.14); font-weight: 800; }
.margin-pill.is-negative { background: rgba(255, 142, 128, .22); }
.hero-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 23px; }
.hero-metrics div { padding: 12px; border: 1px solid rgba(255,255,255,.13); border-radius: 14px; background: rgba(255,255,255,.08); }
.hero-metrics span, .hero-metrics strong { display: block; }
.hero-metrics span { margin-bottom: 5px; color: rgba(255,255,255,.65); font-size: 10px; }
.hero-metrics strong { font-size: 15px; }
.data-status { margin: 14px 0 0; color: rgba(255,255,255,.62); font-size: 10px; line-height: 1.5; }

.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 11px; }
.metric-card { min-height: 91px; padding: 15px; border: 1px solid var(--line); border-radius: 18px; background: white; }
.metric-card span, .metric-card strong { display: block; }
.metric-card span { margin-bottom: 9px; color: var(--muted); font-size: 11px; }
.metric-card strong { font-size: 18px; letter-spacing: -.02em; }
.metric-card.warning strong { color: var(--warn); }

.section-card { padding: 18px 16px; }
.section-title { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 15px; }
.section-title h2 { margin: 3px 0 0; font-size: 18px; letter-spacing: -.025em; }
.section-title small { max-width: 48%; color: var(--muted); font-size: 10px; text-align: right; line-height: 1.45; }
.lifetime-card { background: linear-gradient(145deg, white, #f3fbf8); }
.split-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.split-metrics div { padding: 14px; border-radius: 14px; background: #f4f7f7; }
.split-metrics .positive { background: #e5f6ee; }
.split-metrics span, .split-metrics strong { display: block; }
.split-metrics span { margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.split-metrics strong { font-size: 20px; letter-spacing: -.03em; }
.split-metrics .positive strong { color: var(--good); }
.lifetime-card > p { margin: 12px 2px 0; color: var(--muted); font-size: 10px; line-height: 1.55; }

.fund-list { display: grid; gap: 10px; }
.fund-list > div { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 13px 14px; border-radius: 14px; background: #f5f8f8; }
.fund-list span { color: var(--muted); font-size: 11px; }
.fund-list strong { grid-row: span 2; align-self: center; font-size: 17px; }
.fund-list small { color: #71827f; font-size: 9px; }

.stack-list { display: grid; gap: 0; }
.stack-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px 12px; padding: 13px 2px; border-top: 1px solid #edf1f0; }
.stack-item:first-child { padding-top: 2px; border-top: 0; }
.stack-main { min-width: 0; }
.stack-main strong { display: -webkit-box; overflow: hidden; color: #243533; font-size: 13px; line-height: 1.42; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.stack-main small { display: block; margin-top: 4px; overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.stack-value { text-align: right; white-space: nowrap; }
.stack-value strong, .stack-value small { display: block; }
.stack-value strong { font-size: 14px; }
.stack-value small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.stack-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 5px; }
.chip { padding: 4px 7px; border-radius: 999px; color: #516461; background: #edf3f2; font-size: 9px; font-weight: 700; }
.chip.good { color: #076741; background: #e1f4ea; }
.chip.bad { color: #a52d26; background: #fde9e6; }
.chip.warn { color: #925400; background: #fff0d5; }
.amount-good { color: var(--good); }
.amount-bad { color: var(--bad); }
.empty-state { padding: 24px 8px; color: var(--muted); font-size: 12px; text-align: center; }

.warning-box { padding: 16px; color: #70440d; background: #fff8e8; border-color: #f0d7a9; }
.warning-box strong { font-size: 13px; }
.warning-box ul { margin: 9px 0 0; padding-left: 18px; font-size: 10px; line-height: 1.6; }
.device-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; }
.device-card strong, .device-card span { display: block; }
.device-card strong { font-size: 13px; }
.device-card span { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.55; }
.secondary-button { flex: 0 0 auto; min-height: 36px; padding: 0 13px; color: var(--accent); background: var(--accent-soft); }
.logout-button { width: 100%; min-height: 44px; margin-top: 16px; border: 0; border-radius: 14px; color: #7c5250; background: rgba(255,255,255,.7); }
.footer-note { margin: 15px 0 2px; color: #84918f; font-size: 9px; text-align: center; }

.bottom-nav {
  position: fixed;
  right: 12px;
  bottom: max(10px, env(safe-area-inset-bottom));
  left: 12px;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(calc(100% - 24px), 720px);
  min-height: 57px;
  margin: auto;
  padding: 6px;
  border: 1px solid rgba(210, 224, 222, .94);
  border-radius: 19px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 13px 34px rgba(29,62,59,.16);
  backdrop-filter: blur(18px);
}
.bottom-nav a { display: grid; place-items: center; border-radius: 13px; color: #677875; font-size: 11px; font-weight: 700; text-decoration: none; }
.bottom-nav a:active { color: var(--accent-dark); background: var(--accent-soft); }

@media (min-width: 640px) {
  .mobile-shell { padding-inline: 20px; }
  .app-header { margin-inline: -20px; padding-inline: 26px; }
  .metric-grid { grid-template-columns: repeat(4, 1fr); }
  .section-card { padding: 21px 22px; }
}

@media (max-width: 350px) {
  .hero-heading strong { font-size: 28px; }
  .date-grid, .split-metrics { grid-template-columns: 1fr; }
}

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