:root {
  color-scheme: light;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --raised: #eef0f7;
  --line: #dde0ea;
  --text: #12141c;
  --text-2: #4d5163;
  --muted: #5f6478;
  --accent: #4b3cc4;
  --accent-ink: #ffffff;
  --up: #11713b;
  --down: #b42323;
  --hero-a: #5b47e0;
  --hero-b: #1f6fd1;
  --hero-ink: #ffffff;
  --hero-up: #c9ffd9;
  --hero-down: #ffd3d3;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --trend: #2a78d6;
  --shadow: 0 1px 2px rgb(20 24 40 / 6%), 0 6px 20px rgb(20 24 40 / 6%);
  --radius: 18px;
  --tabbar-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0e1120;
    --surface: #171b2e;
    --raised: #21263d;
    --line: #2c3250;
    --text: #f1f2f8;
    --text-2: #c3c7da;
    --muted: #9ba1bb;
    --accent: #9085e9;
    --accent-ink: #0e1120;
    --up: #5ee08f;
    --down: #ff8a8a;
    --hero-a: #4a36c9;
    --hero-b: #1a5cb3;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --trend: #5ea2f0;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1120;
  --surface: #171b2e;
  --raised: #21263d;
  --line: #2c3250;
  --text: #f1f2f8;
  --text-2: #c3c7da;
  --muted: #9ba1bb;
  --accent: #9085e9;
  --accent-ink: #0e1120;
  --up: #5ee08f;
  --down: #ff8a8a;
  --hero-a: #4a36c9;
  --hero-b: #1a5cb3;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --trend: #5ea2f0;
  --shadow: none;
}

/* Color themes (Settings > Color): each has a light and a dark version */
:root[data-color="ocean"] { --accent: #0b7285; --trend: #0f8fa8; --series-7: #0b7285; --bg: #f1f7f9; --surface: #ffffff; --raised: #e4f0f3; --line: #d3e3e8; }
:root[data-color="forest"] { --accent: #2d7a3e; --trend: #2f8f4a; --series-7: #2d7a3e; --bg: #f3f7f2; --surface: #ffffff; --raised: #e6efe5; --line: #d6e2d4; }
:root[data-color="sunset"] { --accent: #b93d0b; --trend: #e0632a; --series-7: #b93d0b; --bg: #fbf5f1; --surface: #ffffff; --raised: #f6e9e1; --line: #ecd9cd; }
:root[data-color="rose"] { --accent: #b0175a; --trend: #db2777; --series-7: #b0175a; --bg: #fbf3f6; --surface: #ffffff; --raised: #f5e5ec; --line: #ebd3de; }
:root[data-color="graphite"] { --accent: #374151; --trend: #4b5563; --series-7: #374151; --bg: #f5f5f5; --surface: #ffffff; --raised: #ebebeb; --line: #dcdcdc; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="ocean"] { --accent: #4fc3d9; --trend: #4fc3d9; --series-7: #4fc3d9; --bg: #0a1a20; --surface: #10252d; --raised: #17323b; --line: #21424d; } }
:root[data-theme="dark"][data-color="ocean"] { --accent: #4fc3d9; --trend: #4fc3d9; --series-7: #4fc3d9; --bg: #0a1a20; --surface: #10252d; --raised: #17323b; --line: #21424d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="forest"] { --accent: #6fd18a; --trend: #6fd18a; --series-7: #6fd18a; --bg: #0c1a12; --surface: #13261b; --raised: #1b3325; --line: #254432; } }
:root[data-theme="dark"][data-color="forest"] { --accent: #6fd18a; --trend: #6fd18a; --series-7: #6fd18a; --bg: #0c1a12; --surface: #13261b; --raised: #1b3325; --line: #254432; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="sunset"] { --accent: #ff9a62; --trend: #ff9a62; --series-7: #ff9a62; --bg: #1c120d; --surface: #281a13; --raised: #35231a; --line: #463024; } }
:root[data-theme="dark"][data-color="sunset"] { --accent: #ff9a62; --trend: #ff9a62; --series-7: #ff9a62; --bg: #1c120d; --surface: #281a13; --raised: #35231a; --line: #463024; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="rose"] { --accent: #f472b6; --trend: #f472b6; --series-7: #f472b6; --bg: #1c0f16; --surface: #29161f; --raised: #37202b; --line: #48293a; } }
:root[data-theme="dark"][data-color="rose"] { --accent: #f472b6; --trend: #f472b6; --series-7: #f472b6; --bg: #1c0f16; --surface: #29161f; --raised: #37202b; --line: #48293a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="graphite"] { --accent: #d1d5db; --trend: #cbd5e1; --series-7: #d1d5db; --bg: #111214; --surface: #1a1b1e; --raised: #24262a; --line: #313338; } }
:root[data-theme="dark"][data-color="graphite"] { --accent: #d1d5db; --trend: #cbd5e1; --series-7: #d1d5db; --bg: #111214; --surface: #1a1b1e; --raised: #24262a; --line: #313338; }
:root[data-color="jararch"] { --accent: #185ca8; --trend: #3b82f6; --series-7: #185ca8; --bg: #f3f6fa; --surface: #ffffff; --raised: #e6edf6; --line: #d4dfec; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="jararch"] { --accent: #60a5fa; --trend: #60a5fa; --series-7: #60a5fa; --bg: #10131a; --surface: #191e28; --raised: #202632; --line: #2a3343; } }
:root[data-theme="dark"][data-color="jararch"] { --accent: #60a5fa; --trend: #60a5fa; --series-7: #60a5fa; --bg: #10131a; --surface: #191e28; --raised: #202632; --line: #2a3343; }
:root[data-color="navy"] { --accent: #1e3a8a; --trend: #2f4fb0; --series-7: #1e3a8a; --bg: #f2f4f9; --surface: #ffffff; --raised: #e4e8f3; --line: #d2d8e8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="navy"] { --accent: #93b4ff; --trend: #93b4ff; --series-7: #93b4ff; --bg: #0a0f1f; --surface: #111a30; --raised: #18233f; --line: #22304f; } }
:root[data-theme="dark"][data-color="navy"] { --accent: #93b4ff; --trend: #93b4ff; --series-7: #93b4ff; --bg: #0a0f1f; --surface: #111a30; --raised: #18233f; --line: #22304f; }
:root[data-color="teal"] { --accent: #0f766e; --trend: #14998c; --series-7: #0f766e; --bg: #f0f7f6; --surface: #ffffff; --raised: #e1efed; --line: #cfe3e0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="teal"] { --accent: #5eead4; --trend: #5eead4; --series-7: #5eead4; --bg: #081a18; --surface: #0f2623; --raised: #16322e; --line: #204440; } }
:root[data-theme="dark"][data-color="teal"] { --accent: #5eead4; --trend: #5eead4; --series-7: #5eead4; --bg: #081a18; --surface: #0f2623; --raised: #16322e; --line: #204440; }
:root[data-color="mint"] { --accent: #047857; --trend: #10a374; --series-7: #047857; --bg: #f0f8f4; --surface: #ffffff; --raised: #e0f1e8; --line: #cde5d8; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="mint"] { --accent: #6ee7b7; --trend: #6ee7b7; --series-7: #6ee7b7; --bg: #08190f; --surface: #0f2519; --raised: #163222; --line: #1f432f; } }
:root[data-theme="dark"][data-color="mint"] { --accent: #6ee7b7; --trend: #6ee7b7; --series-7: #6ee7b7; --bg: #08190f; --surface: #0f2519; --raised: #163222; --line: #1f432f; }
:root[data-color="amber"] { --accent: #a35a00; --trend: #d97706; --series-7: #a35a00; --bg: #fbf7ef; --surface: #ffffff; --raised: #f5ecdb; --line: #eadcc2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="amber"] { --accent: #fbbf24; --trend: #fbbf24; --series-7: #fbbf24; --bg: #1a140a; --surface: #261d0f; --raised: #332716; --line: #45351f; } }
:root[data-theme="dark"][data-color="amber"] { --accent: #fbbf24; --trend: #fbbf24; --series-7: #fbbf24; --bg: #1a140a; --surface: #261d0f; --raised: #332716; --line: #45351f; }
:root[data-color="crimson"] { --accent: #b91c1c; --trend: #dc2626; --series-7: #b91c1c; --bg: #fbf3f3; --surface: #ffffff; --raised: #f5e4e4; --line: #ebd1d1; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="crimson"] { --accent: #f87171; --trend: #f87171; --series-7: #f87171; --bg: #1c0d0d; --surface: #291414; --raised: #371c1c; --line: #482626; } }
:root[data-theme="dark"][data-color="crimson"] { --accent: #f87171; --trend: #f87171; --series-7: #f87171; --bg: #1c0d0d; --surface: #291414; --raised: #371c1c; --line: #482626; }
:root[data-color="violet"] { --accent: #6d28d9; --trend: #8b5cf6; --series-7: #6d28d9; --bg: #f6f3fc; --surface: #ffffff; --raised: #ece6f8; --line: #ddd3f0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="violet"] { --accent: #c4b5fd; --trend: #c4b5fd; --series-7: #c4b5fd; --bg: #140f20; --surface: #1e172e; --raised: #28203c; --line: #35294e; } }
:root[data-theme="dark"][data-color="violet"] { --accent: #c4b5fd; --trend: #c4b5fd; --series-7: #c4b5fd; --bg: #140f20; --surface: #1e172e; --raised: #28203c; --line: #35294e; }
:root[data-color="mocha"] { --accent: #7c4a2d; --trend: #9a6340; --series-7: #7c4a2d; --bg: #f8f4f0; --surface: #ffffff; --raised: #efe6de; --line: #e2d5c9; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"])[data-color="mocha"] { --accent: #e0b48f; --trend: #e0b48f; --series-7: #e0b48f; --bg: #17110d; --surface: #221913; --raised: #2e221a; --line: #3d2e23; } }
:root[data-theme="dark"][data-color="mocha"] { --accent: #e0b48f; --trend: #e0b48f; --series-7: #e0b48f; --bg: #17110d; --surface: #221913; --raised: #2e221a; --line: #3d2e23; }
.color-choices { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; }
.color-choices button { display: grid; justify-items: center; gap: 4px; background: none; border: 0; padding: 4px; color: var(--text-2); font-size: .78rem; font-weight: 600; cursor: pointer; border-radius: 12px; }
.color-choices i { width: 32px; height: 32px; border-radius: 50%; background: var(--swatch); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.color-choices button[aria-pressed="true"] { color: var(--text); }
.color-choices button[aria-pressed="true"] i { box-shadow: 0 0 0 2px var(--text); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(env(safe-area-inset-bottom) + 32px);
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin: 18px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small-text { font-size: .875rem; }
.error { color: var(--down); font-weight: 600; margin: 8px 0 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 750; letter-spacing: -.01em; }
.brand svg { width: 26px; height: 26px; fill: none; stroke: var(--series-1); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.sync-state { font-size: .8rem; color: var(--muted); }
.sync-state.bad { color: var(--down); font-weight: 600; }

main { max-width: 640px; margin: 0 auto; padding: 4px 16px 0; }
.view { display: grid; gap: 14px; }
.version { position: fixed; left: 8px; bottom: calc(env(safe-area-inset-bottom) + 3px); z-index: 7; margin: 0; font-size: 10px; line-height: 1; color: var(--muted); opacity: .7; letter-spacing: .04em; pointer-events: none; }
.view-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card.empty { text-align: center; padding: 28px 18px; }
.card.empty h2 { margin-bottom: 8px; font-size: 1.2rem; }
#home-charts { display: grid; gap: 14px; }

.hero {
  border-radius: var(--radius); padding: 22px 20px 20px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.hero-label { font-size: .95rem; font-weight: 600; color: var(--text-2); }
.hero-number { font-size: clamp(2.3rem, 11vw, 3.2rem); font-weight: 800; letter-spacing: -.03em; margin: 2px 0 4px; font-variant-numeric: tabular-nums; }
.hero-change { margin: 0; font-weight: 650; font-size: .95rem; }
.hero-change.up { color: var(--up); }
.hero-change.down { color: var(--down); }

.hero-sub { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: .88rem; }
.hero-sub button { background: none; border: 0; padding: 0; color: inherit; font: inherit; opacity: .9; cursor: pointer; }
.hero-sub button:hover { opacity: 1; text-decoration: underline; }
.hero-sub b { font-weight: 700; font-variant-numeric: tabular-nums; margin-left: 4px; }

.segmented { display: inline-flex; background: var(--raised); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented.wide { display: flex; }
.segmented.wide button { flex: 1; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 999px; font-size: .85rem; font-weight: 650; color: var(--text-2); cursor: pointer; min-height: 32px; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / 18%); }

.chart { position: relative; min-width: 0; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart-empty { color: var(--muted); font-size: .9rem; text-align: center; padding: 30px 8px; margin: 0; }
.grid { stroke: var(--line); stroke-width: 1; }
.grid.zero { stroke: var(--muted); }
.axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.trend-line { fill: none; stroke: var(--trend); stroke-width: 2.5; stroke-linejoin: round; }
.trend-line.estimated { stroke-dasharray: 5 4; opacity: .75; }
.trend-area { fill: url(#trend-fill); }
.trend-stop-top { stop-color: var(--trend); stop-opacity: .32; }
.trend-stop-bottom { stop-color: var(--trend); stop-opacity: 0; }
.trend-dot { fill: var(--trend); stroke: var(--surface); stroke-width: 2; }
.trend-label { fill: var(--text); font-size: 11px; font-weight: 650; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; font-variant-numeric: tabular-nums; }
.crosshair { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 3 3; }
.tooltip {
  position: absolute; top: -6px; transform: translateX(-50%); pointer-events: none; z-index: 2;
  background: var(--text); color: var(--bg); border-radius: 10px; padding: 5px 10px; font-size: .8rem; white-space: nowrap;
  display: grid; text-align: center;
}
.donut .tooltip { left: 50%; top: auto; bottom: -8px; }
.tooltip span { opacity: .8; font-size: .75rem; }

.allocation { display: grid; grid-template-columns: 168px 1fr; align-items: center; gap: 16px; }
.donut svg { width: 168px; }
.donut-slice { cursor: pointer; }
.donut-gap { stroke: var(--surface); stroke-width: 2; }
.donut-empty { stroke: var(--raised); }
.donut-total { fill: var(--text); font-size: 20px; font-weight: 800; }
.donut-caption { fill: var(--muted); font-size: 11px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; font-size: .9rem; }
.legend li { display: grid; grid-template-columns: 12px 1fr auto 36px; align-items: center; gap: 8px; }
.legend-value { font-weight: 650; font-variant-numeric: tabular-nums; }
.legend-pct { color: var(--muted); text-align: right; font-size: .8rem; font-variant-numeric: tabular-nums; }
.legend-debt { border-top: 1px solid var(--line); padding-top: 7px; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; display: inline-block; }

.movers { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.mover { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 10px 2px; cursor: pointer; text-align: left; border-radius: 10px; }
.mover-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.up, .delta.up { color: var(--up); }
.down, .delta.down { color: var(--down); }

.group { padding: 6px 0 4px; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px 8px; }
.group-head h2 { flex: 1; }
.group-head strong { font-variant-numeric: tabular-nums; }
.neg { color: var(--down); }
.account-list { list-style: none; margin: 0; padding: 0; }
.account-row {
  width: 100%; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name value" "meta value";
  background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 16px; text-align: left; cursor: pointer; min-height: 56px;
}
.account-row:hover { background: var(--raised); }
.account-name { grid-area: name; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-meta { grid-area: meta; color: var(--muted); font-size: .8rem; }
.account-value { grid-area: value; align-self: center; font-weight: 700; font-variant-numeric: tabular-nums; padding-left: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid var(--line); background: var(--raised); color: var(--text); font-weight: 650; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.danger { color: var(--down); }
.btn.small { min-height: 38px; padding: 6px 14px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { background: none; border: 0; color: var(--accent); font-weight: 650; margin-top: 14px; cursor: pointer; padding: 8px; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; width: 40px; height: 40px; border-radius: 10px; font-size: 1rem; }
.icon-btn:hover { background: var(--raised); color: var(--text); }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; justify-content: center; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 10px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.sample-csv { background: var(--raised); border-radius: 12px; padding: 12px; overflow-x: auto; font-size: .8rem; margin: 0 0 12px; }
.paste { margin-top: 14px; }
.paste summary { cursor: pointer; color: var(--accent); font-weight: 650; padding: 6px 0; }
textarea { width: 100%; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 10px; font: .85rem ui-monospace, Menlo, monospace; margin: 8px 0; }
.summary-list { margin: 12px 0; padding-left: 20px; display: grid; gap: 4px; }
.summary-list .warn { color: var(--series-4); }
.new-accounts { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.new-accounts li { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.new-accounts li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-accounts li.guessed select { border-color: var(--series-4); }
.skipped { font-size: .85rem; color: var(--muted); }

select, input[type="date"], input:not([type]), input[inputmode] {
  width: 100%; min-height: 44px; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
}
.new-accounts select { width: auto; max-width: 55%; }
label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }

dialog {
  width: min(560px, 100%); max-height: 92vh; margin: auto auto 0; border: 0; padding: 0; border-radius: 24px 24px 0 0;
  background: var(--surface); color: var(--text); box-shadow: 0 -10px 40px rgb(0 0 0 / 35%);
}
@media (min-width: 600px) { dialog { margin: auto; border-radius: 24px; } }
dialog::backdrop { background: rgb(5 7 15 / 60%); }
dialog form, .detail { padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.detail { gap: 10px; }
.detail-head { display: flex; align-items: center; gap: 12px; }
.detail-head > div { flex: 1; min-width: 0; }
.detail-head h2 { font-size: 1.2rem; overflow-wrap: anywhere; }
.detail-head p { margin: 0; font-size: .85rem; }
.detail-value { font-size: 2rem; font-weight: 800; margin: 4px 0; font-variant-numeric: tabular-nums; }
.balance-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.balance-form .btn { grid-column: 1 / -1; }
.chart.small svg { max-height: 190px; }
.history { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.history li { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 4px 0 4px 2px; }
.history li span { flex: 1; color: var(--text-2); }
.history li strong { font-variant-numeric: tabular-nums; }

.signin { min-height: 70vh; place-items: center; }
.signin-card { text-align: center; max-width: 380px; padding: 24px 8px; }
.signin-card h1 { font-size: 2rem; margin: 12px 0; letter-spacing: -.02em; }
.signin-mark { width: 72px; height: 72px; fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 24px); z-index: 20;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 650; font-size: .9rem; box-shadow: 0 6px 24px rgb(0 0 0 / 30%);
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .2s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
}
.c-1 { background: var(--series-1); } .c-2 { background: var(--series-2); } .c-3 { background: var(--series-3); } .c-4 { background: var(--series-4); }
.c-5 { background: var(--series-5); } .c-6 { background: var(--series-6); } .c-7 { background: var(--series-7); } .c-8 { background: var(--series-8); }
.holdings { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.holdings li { display: flex; justify-content: space-between; gap: 12px; border-top: 1px solid var(--line); padding: 8px 2px; }
.holding-id, .holding-value { display: grid; min-width: 0; }
.holding-id span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.holding-value { text-align: right; font-variant-numeric: tabular-nums; }
.position-accounts { list-style: none; margin: 12px 0; padding: 0; }
.position-accounts li { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--line); padding: 10px 2px; }
.position-accounts li > div { display: grid; min-width: 0; }
.grow { flex: 1; min-width: 0; }
.include { display: flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 650; color: var(--text-2); flex: none; }
.include input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }
li.excluded > :not(.include) { opacity: .4; text-decoration: line-through; }
.ignored-list { list-style: none; margin: 0; padding: 0; }
.ignored-list li { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 8px 0; }

/* Retirement planner */
.retire-chart-card { padding-bottom: 10px; }
.chart-note { margin: 6px 0 0; }
.proj-legend { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .85rem; font-weight: 650; }
.proj-legend li { display: flex; align-items: center; gap: 6px; }
.proj-legend b { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.proj-legend i { width: 20px; height: 0; border-top: 3px solid; }
.proj-legend .high i { border-color: var(--series-3); }
.proj-legend .avg i { border-color: var(--series-1); }
.proj-legend .low i { border-color: var(--series-2); border-top-style: dashed; }
.proj-legend .today i { border-color: var(--series-4); border-top-style: dotted; }
.proj-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.proj-line.high { stroke: var(--series-3); }
.proj-line.avg { stroke: var(--series-1); stroke-width: 3; }
.proj-line.low { stroke: var(--series-2); stroke-dasharray: 6 4; }
.proj-line.today { stroke: var(--series-4); stroke-width: 3; stroke-dasharray: 0.5 5.5; }
.proj-dot.today { fill: var(--series-4); }
.proj-label.today { fill: var(--series-4); font-size: 12px; font-weight: 800; }
.proj-dot { stroke: var(--surface); stroke-width: 2; }
.proj-dot.high { fill: var(--series-3); }
.proj-dot.avg { fill: var(--series-1); }
.proj-dot.low { fill: var(--series-2); }
.proj-x { fill: none; stroke-width: 2.5; stroke-linecap: round; }
.proj-x.high { stroke: var(--series-3); }
.proj-x.avg { stroke: var(--series-1); }
.proj-x.low { stroke: var(--series-2); }
.proj-label { fill: var(--text); font-size: 11px; font-weight: 650; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; font-variant-numeric: tabular-nums; }
.milestone { stroke: var(--text-2); stroke-width: 1; stroke-dasharray: 2 3; }
.milestone-label { fill: var(--text-2); font-size: 11px; font-weight: 700; }
.proj-tip { text-align: left; gap: 1px; }
.tip-row::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.tip-row.high::before { background: var(--series-3); }
.tip-row.avg::before { background: var(--series-1); }
.tip-row.low::before { background: var(--series-2); }
.tip-row.today::before { background: var(--series-4); }
.scenario-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scenario { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; border-top: 4px solid; min-width: 0; }
.scenario.high { border-top-color: var(--series-3); }
.scenario.avg { border-top-color: var(--series-1); }
.scenario.low { border-top-color: var(--series-2); border-top-style: dashed; }
.scenario h3 { margin: 0 0 6px; font-size: .85rem; }
.scenario dl { margin: 0; display: grid; gap: 1px; font-size: .8rem; }
.scenario dt { color: var(--muted); margin-top: 4px; }
.scenario dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.scenario dd.up { color: var(--up); }
.scenario dd.down { color: var(--down); }
#retire-needed { margin: 0 4px; }
.retire-fields { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin: 12px 0 10px; }
input[type="number"] { width: 100%; min-height: 44px; background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
input:disabled { opacity: .65; }
label.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; }
label.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.sliders { display: grid; gap: 16px; margin-top: 12px; }
.slider { gap: 4px; }
.slider-head { display: flex; justify-content: space-between; gap: 10px; font-weight: 600; }
.slider-value { font-weight: 750; font-variant-numeric: tabular-nums; color: var(--accent); white-space: nowrap; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; margin: 0; }
.compare h2 { margin-bottom: 10px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare-col { display: grid; gap: 2px; background: var(--raised); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.compare-col span { font-size: .8rem; color: var(--text-2); font-weight: 600; }
.compare-col strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.compare-col strong.up { color: var(--up); }
.compare-col strong.down { color: var(--down); }
.compare-col .compare-spend { display: block; color: var(--text); font-size: .95rem; white-space: nowrap; }
.compare-col small { color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }
.retire-tile { display: block; color: inherit; text-decoration: none; }
.tile-link { color: var(--accent); font-weight: 650; font-size: .85rem; }
.retire-tile-verdict { font-weight: 650; font-size: .92rem; color: var(--text-2); }
.retire-tile .card-head .retire-tile-verdict { flex: 1; margin: 0; min-width: 0; }
.retire-tile-verdict.good { color: var(--up); }
.retire-tile-verdict.warn { color: var(--series-4); }
.retire-tile-verdict.bad { color: var(--down); }

/* Profile menu (top right) */
.topbar-right { position: relative; display: flex; align-items: center; gap: 10px; }
.profile-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--raised); padding: 0; display: grid; place-items: center; cursor: pointer; overflow: hidden; }
.profile-btn[aria-expanded="true"] { outline: 2px solid var(--accent); outline-offset: 2px; }
.profile-btn img { width: 100%; height: 100%; object-fit: cover; }
.profile-btn svg { width: 22px; height: 22px; fill: none; stroke: var(--text-2); stroke-width: 2; stroke-linecap: round; }
.profile-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 220px; display: grid; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 36px rgb(0 0 0 / 30%);
}
.menu-who { margin: 4px 10px 6px; font-size: .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-who:empty { display: none; }
.profile-menu a, .menu-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 600; background: none; border: 0; text-align: left; cursor: pointer; width: 100%; }
.profile-menu a:hover, .menu-item:hover { background: var(--raised); }
.profile-menu a[aria-current="page"] { color: var(--accent); background: var(--raised); }
.profile-menu svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.menu-item { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; margin-top: 4px; color: var(--text-2); }
.plan-accounts { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 2px; }
.plan-accounts label.check { align-items: center; padding: 8px 2px; border-top: 1px solid var(--line); font-size: .92rem; }
.plan-accounts .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-accounts .muted { font-variant-numeric: tabular-nums; }
.home-retire-chart { margin: 4px 0 12px; }

/* Retirement inputs, grouped */
.plan-group { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.plan-group h3 { margin: 0; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.retire-inputs > h2 { margin-bottom: 0; }
.plan-group .retire-fields { margin-top: 8px; }
.plan-accounts-box { margin-top: 10px; }
.plan-accounts-box summary { cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--accent); padding: 4px 0; }
.plan-accounts { display: grid; gap: 8px; margin-top: 6px; }
.plan-acct-group h4 { margin: 4px 0 2px; font-size: .8rem; color: var(--text-2); }
.plan-acct-group label.check { align-items: center; padding: 5px 2px; border-top: 1px solid var(--line); font-size: .88rem; }
.plan-acct-group label.check input { width: 18px; height: 18px; margin: 0; }

/* Desktop: wider page; on Retire the graphs sit on the left and a compact inputs panel on the right. */
@media (min-width: 900px) {
  main { max-width: 1040px; padding: 4px 24px 0; }
  .retire-view {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas: "head head" "compare inputs" "chart inputs" "scen kids" "needed needed";
    align-items: start; column-gap: 18px;
  }
  .retire-view > .view-head { grid-area: head; }
  .retire-view > .compare { grid-area: compare; padding: 12px 14px; }
  .retire-view > .retire-chart-card { grid-area: chart; position: static; }
  .retire-view > .retire-scenarios { grid-area: scen; align-self: stretch; }
  .retire-view > .retire-needed { grid-area: needed; margin: 0; }
  .retire-view > .inherit-card { grid-area: kids; align-self: stretch; }
  /* The chart grows to end level with Your plan (see drawProjection) */
  .retire-view > .retire-inputs { grid-area: inputs; padding: 12px 16px; font-size: .9rem; }
  .retire-inputs .sliders { gap: 2px; margin-top: 2px; }
  .retire-inputs .slider-head { font-weight: 550; font-size: .85rem; }
  .retire-inputs .retire-fields input { padding: 6px 10px; min-height: 36px; }
  .retire-inputs input[type="range"] { height: 20px; }
  .retire-inputs .slider { gap: 0; }
  .retire-inputs .plan-group { padding-top: 6px; margin-top: 6px; }
  .retire-inputs h2 { margin-bottom: 4px; }
  .retire-inputs .retire-fields { margin: 8px 0 6px; }
}

/* Wide screens: Home is one dashboard, with the full planner below the overview. */
@media (min-width: 1100px) {
  body.dash main { max-width: 1280px; }
  /* Top row: a slim net worth card, allocation, and the widest column for the trend.
     Every card in a row is the same height; biggest moves runs across underneath. */
  body.dash #view-home {
    grid-template-columns: minmax(230px, .55fr) minmax(0, 1fr) minmax(0, 1.25fr);
    grid-template-areas: "hero alloc trend" "movers movers movers";
    align-items: stretch;
  }
  body.dash #view-home:has(#trend-card[hidden]) { grid-template-areas: "hero alloc alloc" "movers movers movers"; }
  body.dash #home-charts { display: contents; }
  body.dash .hero { grid-area: hero; display: flex; flex-direction: column; justify-content: center; }
  body.dash #alloc-card { grid-area: alloc; display: flex; flex-direction: column; }
  body.dash #alloc-card .allocation { flex: 1; }
  body.dash #trend-card { grid-area: trend; }
  body.dash #movers-card { grid-area: movers; }
  body.dash .movers { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); column-gap: 28px; }
  /* The number scales with the card's width so large totals stay inside it */
  body.dash .hero { container-type: inline-size; }
  body.dash .hero-number { font-size: clamp(1.3rem, 14cqi, 2.2rem); white-space: nowrap; }
  body.dash .allocation { grid-template-columns: 120px 1fr; gap: 12px; }
  body.dash .donut svg { width: 120px; height: auto; }
  body.dash .legend { font-size: .82rem; gap: 3px; }
  /* One even gap between every card; no "Retirement" heading on the dashboard */
  body.dash #view-home { gap: 16px; }
  body.dash #view-retire { margin-top: 16px; gap: 16px; grid-template-rows: auto auto auto auto; grid-template-areas: "compare inputs" "chart inputs" "scen kids" "needed needed"; }
  body.dash #view-retire > .view-head { display: none; }
  body.dash .retire-tile { display: none; }
}
.hero[data-go], .allocation[data-go] { cursor: pointer; }

/* Phones: Home fits on one screen */
@media (max-width: 899px) {
  .topbar { padding-top: calc(4px + env(safe-area-inset-top)); padding-bottom: 4px; }
  body { padding-bottom: calc(env(safe-area-inset-bottom) + 14px); }
  #view-home, #home-charts { gap: 6px; }
  #view-home .card { padding: 8px 12px; }
  #view-home .card-head { margin-bottom: 4px; }
  #view-home h2 { font-size: .9rem; }
  #view-home .card-head { min-height: 0; }
  .hero { padding: 10px 14px 10px; }
  .hero-label { font-size: .8rem; }
  .hero-number { font-size: 1.75rem; margin: 0; }
  .hero-change { font-size: .8rem; }
  .hero-sub { margin-top: 2px; font-size: .8rem; }
  .allocation { grid-template-columns: 96px 1fr; gap: 12px; }
  .donut svg { width: 96px; height: auto; }
  .legend { gap: 0; font-size: .72rem; }
  .legend li { grid-template-columns: 9px 1fr auto 30px; gap: 6px; }
  .legend .dot { width: 9px; height: 9px; }
  .legend-pct { font-size: .72rem; }
  .legend-debt { padding-top: 2px; }
  .retire-tile-verdict { font-size: .8rem; margin: 0 0 2px; }
  .retire-tile .proj-legend { font-size: .72rem; gap: 2px 10px; margin-bottom: 0; }
  .retire-tile .proj-legend i { width: 14px; }
  .home-retire-chart { margin: 0 0 4px; }
  .retire-tile .compare-grid { gap: 6px; }
  .retire-tile .compare-col { padding: 4px 10px; gap: 0; }
  .retire-tile .compare-col span, .retire-tile .compare-col small { font-size: .7rem; }
  .retire-tile .compare-col strong { font-size: .9rem; }
  #view-home .segmented button { padding: 3px 10px; font-size: .78rem; }
  .mover { padding: 1px 2px; font-size: .82rem; }
  .hero { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 12px; }
  .hero-label, .hero-sub { grid-column: 1 / -1; }
  .hero-change { justify-self: end; text-align: right; }
  .verdict-more { display: none; }
  .retire-tile .proj-legend { display: none; }
  .movers li:nth-child(n+4) { display: none; }
  .retire-tile .compare-col small { display: none; }
  #view-home .segmented { padding: 2px; }
  #view-home .segmented button { min-height: 26px; padding: 2px 10px; }
  #view-home .legend { line-height: 1.25; }
  .movers .dot { width: 9px; height: 9px; }
}

/* Holdings */
.key-form { display: flex; gap: 8px; margin-top: 10px; }
.key-form input { flex: 1; min-width: 0; }
.price-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.price-actions .link-btn { margin-top: 0; }
.price-ready p { margin: 6px 0 10px; }
.return-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; }
.return-stat { display: grid; gap: 2px; background: var(--raised); border-radius: 12px; padding: 8px 6px; text-align: center; }
.return-stat span { font-size: .75rem; color: var(--text-2); font-weight: 650; }
.return-stat strong { font-size: 1rem; font-variant-numeric: tabular-nums; }
.return-stat .muted { color: var(--muted); }
.holdings-insight { margin: 10px 0 0; font-size: .9rem; color: var(--text-2); }
.holdings-list { list-style: none; margin: 8px 0 6px; padding: 0; display: grid; }
.holding { padding: 10px 0; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.holding:first-child { border-top: 0; }
.holding-main { display: grid; grid-template-columns: auto 1fr auto; align-items: baseline; gap: 8px; }
.holding-symbol { font-size: .95rem; }
.holding-name { color: var(--text-2); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.holding-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.holding-returns { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; font-size: .8rem; }
.chip { background: var(--raised); border-radius: 999px; padding: 2px 8px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chip small { color: var(--muted); font-weight: 650; }
.chip.muted { color: var(--muted); }
.past-form select { width: auto; flex: 0 0 auto; }
#trend-card .card-head { flex-wrap: wrap; row-gap: 6px; }
#trend-card .card-head h2 { margin-right: auto; }
#trend-card .segmented button { padding-inline: 9px; }
.custom-range { display: flex; gap: 10px; margin: -2px 0 8px; }
.custom-range label { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-2); flex: 1; min-width: 0; }
.custom-range input { flex: 1; min-width: 0; padding: 4px 8px; min-height: 32px; }
#adjust-estimate { margin-right: 10px; white-space: nowrap; }
[data-color-choice="indigo"] i { --swatch: #5b47e0; }
[data-color-choice="ocean"] i { --swatch: #0f8fa8; }
[data-color-choice="forest"] i { --swatch: #2f8f4a; }
[data-color-choice="sunset"] i { --swatch: #e0632a; }
[data-color-choice="rose"] i { --swatch: #db2777; }
[data-color-choice="graphite"] i { --swatch: #4b5563; }
[data-color-choice="jararch"] i { --swatch: #60a5fa; }
[data-color-choice="navy"] i { --swatch: #1e3a8a; }
[data-color-choice="teal"] i { --swatch: #14998c; }
[data-color-choice="mint"] i { --swatch: #34d399; }
[data-color-choice="amber"] i { --swatch: #f59e0b; }
[data-color-choice="crimson"] i { --swatch: #dc2626; }
[data-color-choice="violet"] i { --swatch: #8b5cf6; }
[data-color-choice="mocha"] i { --swatch: #9a6340; }

/* Equity investments color */
:root { --series-9: #0e9aa7; }
:root[data-theme="dark"] { --series-9: #22b8c4; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-9: #22b8c4; } }
.c-9 { background: var(--series-9); }

/* Account form extras */
.extra-fields { display: grid; gap: 10px; }

/* Left for your kids */
.retire-needed { display: grid; gap: 16px; align-content: start; }
.inherit-card { border-top-color: var(--up); }
.inherit-more { margin-top: 6px; font-size: .78rem; }
.inherit-more summary { color: var(--accent); cursor: pointer; font-weight: 600; }
.inherit-more p { margin: 6px 0 0; }
.inherit-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; }
.inherit-list li { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 3px; }
.inherit-list strong { font-variant-numeric: tabular-nums; }

/* Investments card */
.invest-card .card-head { flex-wrap: wrap; row-gap: 6px; }
.invest-card .card-head h2 { margin-right: auto; }
.invest-card .segmented button { padding-inline: 9px; }
.invest-summary { margin: 0 0 8px; font-size: .95rem; }
.invest-summary .up { color: var(--up); } .invest-summary .down { color: var(--down); }
.invest-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.invest-row, .invest-cols { display: grid; grid-template-columns: minmax(0, 1fr) 76px 86px auto; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); }
.invest-name, .invest-value { display: grid; min-width: 0; }
.invest-name small { color: var(--muted); font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.invest-value { text-align: right; }
.invest-value small { color: var(--muted); font-size: .75rem; }
.invest-track { position: relative; height: 10px; border-radius: 5px; background: var(--raised); }
.invest-track::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--line); }
.invest-bar { position: absolute; top: 0; bottom: 0; border-radius: 5px; }
.invest-bar.up { left: 50%; background: var(--up); }
.invest-bar.down { right: 50%; background: var(--down); }
.invest-ret { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .9rem; }
.invest-ret.up { color: var(--up); } .invest-ret.down { color: var(--down); }
@media (min-width: 1100px) {
  body.dash #view-retire { grid-template-rows: auto auto auto auto auto; grid-template-areas: "compare inputs" "chart inputs" "scen kids" "needed needed" "invest invest"; }
  body.dash #invest-card { grid-area: invest; }
  body.dash .invest-rows { grid-template-columns: 1fr; }
}
@media (min-width: 1100px) {
  /* Net worth centered in its card */
  body.dash .hero { align-items: center; text-align: center; }
  body.dash .hero-sub { justify-content: center; }
}
/* Assets in green, debts in red */
#total-assets { color: var(--up); }
#total-debts { color: var(--down); }
/* Equity investments card */
.eq-c1 { fill: var(--series-1); } .eq-dot-1 { background: var(--series-1); }
.eq-c2 { fill: var(--series-3); } .eq-dot-2 { background: var(--series-3); }
.eq-c3 { fill: var(--series-2); } .eq-dot-3 { background: var(--series-2); }
.eq-c4 { fill: var(--series-4); } .eq-dot-4 { background: var(--series-4); }
.eq-c5 { fill: var(--series-5); } .eq-dot-5 { background: var(--series-5); }
.eq-c6 { fill: var(--series-9); } .eq-dot-6 { background: var(--series-9); }
.eq-c7 { fill: var(--series-6); } .eq-dot-7 { background: var(--series-6); }
.eq-c8 { fill: var(--series-8); } .eq-dot-8 { background: var(--series-8); }
.eq-bar { opacity: .55; }
.eq-build { stroke-width: 2; stroke-dasharray: 3 3; }
.eq-build.eq-c1 { stroke: var(--series-1); }
.eq-build.eq-c2 { stroke: var(--series-3); }
.eq-build.eq-c3 { stroke: var(--series-2); }
.eq-build.eq-c4 { stroke: var(--series-4); }
.eq-build.eq-c5 { stroke: var(--series-5); }
.eq-build.eq-c6 { stroke: var(--series-9); }
.eq-build.eq-c7 { stroke: var(--series-6); }
.eq-build.eq-c8 { stroke: var(--series-8); }

.eq-dot { stroke: var(--surface); stroke-width: 2px; }
.eq-label { fill: var(--text-2); font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; font-variant-numeric: tabular-nums; }
.eq-label.strong { fill: var(--text); font-weight: 750; }
.eq-line { fill: none; stroke: var(--up); stroke-width: 2.5; stroke-linejoin: round; }
.eq-area { fill: var(--up); opacity: .12; }
.eq-invested { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 5 4; }
.equity-list { list-style: none; margin: 12px 0 4px; padding: 0; display: grid; gap: 10px; }
.equity-item { border-top: 1px solid var(--line); padding-top: 10px; }
.equity-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: .9rem; }
.equity-head .muted { font-size: .8rem; }
.equity-stats { margin: 6px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px 12px; font-size: .8rem; }
.equity-stats dt { color: var(--muted); }
.equity-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.equity-stats dd.up { color: var(--up); } .equity-stats dd.down { color: var(--down); }
@media (min-width: 1100px) {
  body.dash #view-retire { grid-template-rows: auto auto auto auto auto auto; grid-template-areas: "compare inputs" "chart inputs" "scen kids" "needed needed" "invest invest" "equity equity"; }
  body.dash #equity-card { grid-area: equity; }
}
.field-note { margin: -4px 0 0; }
.eq-net.eq-c1 { stroke: var(--series-1); } .eq-end.eq-c1 { fill: var(--series-1); }
.eq-net.eq-c2 { stroke: var(--series-3); } .eq-end.eq-c2 { fill: var(--series-3); }
.eq-net.eq-c3 { stroke: var(--series-2); } .eq-end.eq-c3 { fill: var(--series-2); }
.eq-net.eq-c4 { stroke: var(--series-4); } .eq-end.eq-c4 { fill: var(--series-4); }
.eq-net.eq-c5 { stroke: var(--series-5); } .eq-end.eq-c5 { fill: var(--series-5); }
.eq-net.eq-c6 { stroke: var(--series-9); } .eq-end.eq-c6 { fill: var(--series-9); }
.eq-net.eq-c7 { stroke: var(--series-6); } .eq-end.eq-c7 { fill: var(--series-6); }
.eq-net.eq-c8 { stroke: var(--series-8); } .eq-end.eq-c8 { fill: var(--series-8); }
.eq-net { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.eq-end { font-size: 11px; font-weight: 750; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; font-variant-numeric: tabular-nums; }
.equity-stats label { font: inherit; color: inherit; display: inline; }
.equity-stats .equity-amount { width: 100%; max-width: 130px; padding: 2px 8px; min-height: 28px; font-size: .85rem; border: 1px solid var(--line); border-radius: 8px; background: var(--raised); font-weight: 700; font-variant-numeric: tabular-nums; }
/* Equity investment form */
.field-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
.field-pair label { min-width: 0; }
.field-pair input { width: 100%; min-width: 0; box-sizing: border-box; }
.eq-years { display: grid; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.eq-years-head { margin: 0; display: grid; gap: 2px; }
.eq-year-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.eq-year-list li { display: grid; gap: 3px; }
.eq-year-list label { font-size: .78rem; color: var(--muted); }
.eq-year-list input { min-height: 36px; padding: 4px 10px; width: 100%; min-width: 0; box-sizing: border-box; }
input.calculated { background: var(--raised); color: var(--text-2); }
.equity-name { font: inherit; font-weight: 700; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
.invest-ret { display: grid; justify-items: end; line-height: 1.2; }
.invest-ret small { font-size: .68rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.invest-cols { padding: 0 0 4px; font-size: .72rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.invest-cols span:nth-child(n+2) { text-align: right; }
.invest-cols[hidden], .invest-stats[hidden] { display: none; }
.invest-stats { margin: 0 0 12px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.invest-stats > div { background: var(--raised); border-radius: 12px; padding: 8px 10px; display: grid; gap: 1px; min-width: 0; }
.invest-stats dt { font-size: .75rem; color: var(--muted); font-weight: 600; }
.invest-stats dd { margin: 0; font-size: 1.1rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.invest-stats dd.up { color: var(--up); } .invest-stats dd.down { color: var(--down); }
.invest-stats small { font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.invest-card .segmented { display: flex; width: 100%; }
.invest-card .segmented button { flex: 1; padding-inline: 2px; min-width: 0; }
.invest-card .segmented button { font-size: .76rem; }
.invest-stats dt { font-size: .7rem; }
.invest-stats small.up { color: var(--up); } .invest-stats small.down { color: var(--down); }
.invest-name strong { display: flex; align-items: center; gap: 6px; }
.invest-name .dot { width: 9px; height: 9px; flex: none; }
#invest-chart { margin: 4px 0 10px; }
#gains-stats { margin-top: -4px; }
.ret-line { fill: none; stroke-width: 2.25; stroke-linejoin: round; }
.ret-dot { stroke: var(--surface); stroke-width: 1.5px; }
.ret-label { font-size: 11px; font-weight: 750; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; font-variant-numeric: tabular-nums; }
.eq-rate.eq-c1 { stroke: var(--series-1); }
.eq-rate.eq-c2 { stroke: var(--series-3); }
.eq-rate.eq-c3 { stroke: var(--series-2); }
.eq-rate.eq-c4 { stroke: var(--series-4); }
.eq-rate.eq-c5 { stroke: var(--series-5); }
.eq-rate.eq-c6 { stroke: var(--series-9); }
.eq-rate.eq-c7 { stroke: var(--series-6); }
.eq-rate.eq-c8 { stroke: var(--series-8); }
.eq-rate { fill: none; stroke-width: 1.75; stroke-dasharray: 5 4; opacity: .9; }
.eq-rate-dot { stroke: var(--surface); stroke-width: 1.5px; }
/* Holding rows: compact text so the two percent columns are easy to compare */
.invest-row { gap: 8px; padding: 5px 0; }
.invest-name strong { font-size: .82rem; }
.invest-name small, .invest-value small { font-size: .66rem; }
.invest-ret { font-size: .8rem; }
.invest-ret small { font-size: .62rem; }
.invest-value strong { font-size: .82rem; }
.invest-row, .invest-cols { grid-template-columns: minmax(0, 1fr) 70px 80px auto; }
.invest-cols { font-size: .64rem; }

/* iPhone zooms into any box with text under 16px when you tap it, and doesn't always zoom back out.
   Phone-size screens and touch screens keep every box at 16px so tapping never zooms. */
@media (max-width: 899px), (pointer: coarse) {
  input:not([type="range"]):not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px !important; }
}
