/* Family finance dashboard — palette values from the Anthropic dataviz reference. */
:root {
  color-scheme: light dark;
  --page:        #f9f9f7;
  --surface-1:   #fcfcfb;
  --surface-2:   #f4f3ef;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:        #e1e0d9;
  --baseline:    #c3c2b7;
  --border:      rgba(11,11,11,0.10);
  --series-1:    #2a78d6;  /* blue  */
  --series-1-track: #cde2fb;
  --series-2:    #1baf7a;  /* aqua  */
  --status-good:     #0ca30c;
  --status-good-text:#006300;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(11,11,11,0.04), 0 4px 16px rgba(11,11,11,0.05);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page:        #0d0d0d;
    --surface-1:   #1a1a19;
    --surface-2:   #232322;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:        #2c2c2a;
    --baseline:    #383835;
    --border:      rgba(255,255,255,0.10);
    --series-1:    #3987e5;
    --series-1-track: #184f95;
    --series-2:    #199e70;
    --status-good:     #0ca30c;
    --status-good-text:#0ca30c;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 6px 20px rgba(0,0,0,0.35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

/* ---------- Passphrase gate ---------- */
[hidden] { display: none !important; }
.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.gate-card h1 { font-size: 20px; margin: 0; font-weight: 600; }
.gate-sub { margin: 0; color: var(--text-secondary); font-size: 14px; }
.gate-card input[type="password"] {
  font-family: var(--font);
  font-size: 16px;
  padding: 11px 13px;
  border: 1px solid var(--baseline);
  border-radius: 10px;
  background: var(--page);
  color: var(--text-primary);
}
.gate-card input[type="password"]:focus { outline: 2px solid var(--series-1); border-color: transparent; }
.gate-remember { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); }
.gate-card button {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  padding: 11px;
  border: none;
  border-radius: 10px;
  background: var(--series-1);
  color: #fff;
  cursor: pointer;
}
.gate-card button:hover { filter: brightness(1.05); }
.gate-error { margin: 0; color: var(--status-critical); font-size: 13px; }

/* ---------- App shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 20px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; }
.brand-dot { width: 11px; height: 11px; border-radius: 3px; background: var(--series-1); }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs button {
  font-family: var(--font); font-size: 14px;
  padding: 7px 13px; border: none; border-radius: 9px;
  background: transparent; color: var(--text-secondary); cursor: pointer;
}
.tabs button:hover { background: var(--surface-2); }
.tabs button.active { background: var(--surface-1); color: var(--text-primary); box-shadow: var(--shadow); }
.lang-toggle {
  font-family: var(--font); font-size: 13px; font-weight: 600;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-1); color: var(--text-secondary); cursor: pointer;
}
.view { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
.foot { max-width: 1080px; margin: 0 auto; padding: 0 20px 40px; color: var(--text-muted); font-size: 12px; }

/* ---------- Cards & layout ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin: 30px 0 12px; }
.section-title:first-child { margin-top: 0; }

/* ---------- Hero ---------- */
.hero { display: flex; flex-direction: column; gap: 6px; }
.hero-label { font-size: 13px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.hero-figure { font-size: 54px; font-weight: 650; line-height: 1.05; letter-spacing: -0.02em; }
.hero-sub { font-size: 14px; color: var(--text-secondary); }

/* ---------- Thermometer / meter ---------- */
.meter { margin-top: 16px; }
.meter-track { height: 14px; border-radius: 8px; background: var(--series-1-track); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 8px; background: var(--series-1); transition: width .4s ease; }
.meter-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.meter-pct { font-weight: 600; font-size: 15px; }
.meter-cap { font-size: 12px; color: var(--text-muted); }

/* ---------- Stat tiles ---------- */
.tile { display: flex; flex-direction: column; gap: 5px; }
.tile-label { font-size: 13px; color: var(--text-secondary); }
.tile-value { font-size: 27px; font-weight: 620; letter-spacing: -0.01em; }
.tile-sub { font-size: 13px; color: var(--text-muted); }
.tile-value.crit { color: var(--status-critical); }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--grid); }
.list-row:last-child { border-bottom: none; }
.list-main { display: flex; flex-direction: column; gap: 2px; }
.list-name { font-weight: 550; font-size: 14px; }
.list-meta { font-size: 12px; color: var(--text-muted); }
.list-amt { text-align: right; font-variant-numeric: tabular-nums; }
.list-amt .usd { display: block; font-size: 12px; color: var(--text-muted); }

/* ---------- Chips ---------- */
.chip { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.chip.badge { background: var(--series-1); color: #fff; border: none; font-weight: 600; }

/* ---------- Debt cards ---------- */
.debt-card { display: flex; flex-direction: column; gap: 10px; }
.debt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.debt-name { font-weight: 600; font-size: 16px; }
.debt-bal { font-size: 23px; font-weight: 620; letter-spacing: -0.01em; }
.debt-bal .usd { font-size: 13px; color: var(--text-muted); font-weight: 400; margin-left: 6px; }
.debt-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-secondary); }
.debt-facts b { color: var(--text-primary); font-weight: 600; }
.util { margin-top: 4px; }
.util-track { height: 7px; border-radius: 5px; background: var(--series-1-track); overflow: hidden; }
.util-fill { height: 100%; border-radius: 5px; background: var(--series-1); }
.util-fill.hot { background: var(--status-critical); }
.util-cap { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ---------- Budget bars ---------- */
.bud-row { padding: 12px 0; border-bottom: 1px solid var(--grid); }
.bud-row:last-child { border-bottom: none; }
.bud-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; gap: 10px; }
.bud-name { font-size: 14px; font-weight: 550; }
.bud-vals { font-size: 13px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.bud-track { height: 10px; background: var(--surface-2); border-radius: 0; overflow: visible; position: relative; }
.bud-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; max-width: 100%; }
.bud-fill.over { background: var(--status-critical); }
.bud-over-tag { font-size: 12px; color: var(--status-critical); font-weight: 600; }

/* ---------- Tables ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-weight: 600; color: var(--text-secondary); padding: 9px 10px; border-bottom: 1px solid var(--baseline); white-space: nowrap; }
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
table.tbl td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.tbl td.num .usd { display: block; font-size: 11px; color: var(--text-muted); }
tr.transfer { color: var(--text-muted); }
tr.transfer td { opacity: 0.7; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: end; }
.filters .fld { display: flex; flex-direction: column; gap: 4px; }
.filters label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.filters select {
  font-family: var(--font); font-size: 14px; padding: 7px 10px;
  border: 1px solid var(--baseline); border-radius: 9px;
  background: var(--surface-1); color: var(--text-primary);
}
.seg { display: inline-flex; border: 1px solid var(--baseline); border-radius: 9px; overflow: hidden; }
.seg button { font-family: var(--font); font-size: 13px; padding: 7px 13px; border: none; background: var(--surface-1); color: var(--text-secondary); cursor: pointer; }
.seg button.active { background: var(--series-1); color: #fff; }

/* ---------- Charts ---------- */
.chart-wrap { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; gap: 18px; margin-bottom: 8px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-secondary); }
.legend-key { width: 16px; height: 3px; border-radius: 2px; }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border);
  box-shadow: var(--shadow); border-radius: 9px; padding: 8px 11px;
  font-size: 12px; color: var(--text-primary); max-width: 220px;
}
.tooltip .tt-title { font-weight: 600; margin-bottom: 3px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 7px; }
.tooltip .tt-key { width: 10px; height: 10px; border-radius: 3px; }
.tooltip .tt-val { font-variant-numeric: tabular-nums; margin-left: auto; }

.muted { color: var(--text-muted); }
.strategy-note { margin-top: 14px; font-size: 14px; color: var(--text-secondary); }
.strategy-note b { color: var(--text-primary); }

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .hero-figure { font-size: 42px; }
  .view { padding: 18px 14px 50px; }
  .tabs { order: 3; width: 100%; }
}
