/* Large, high-contrast, simple. Base text 20px; one big number per screen. */
:root {
  --bg: #ffffff; --card: #f3f4f6; --text: #111111; --muted: #3b3b3b; --line: #c9cdd3;
  --accent: #0b3d91; --accent-text: #ffffff; --up: #0a5a2a; --down: #a10f0f;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101214; --card: #1c1f23; --text: #f5f5f5; --muted: #d0d0d0; --line: #3a3f45;
    --accent: #8fb4ff; --accent-text: #0b1220; --up: #6ee39a; --down: #ff9a8f;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { font-size: 20px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.45;
}
main { max-width: 40rem; margin: 0 auto; padding: 1rem 1rem 7rem; }
h1 { font-size: 1.6rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.5rem; }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: 0.4rem 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.label { font-weight: 600; }

.accounts { display: flex; gap: 0.5rem; overflow-x: auto; padding: 0.25rem 0 0.75rem; scrollbar-width: none; }
.pill {
  flex: none; min-height: 3rem; padding: 0.6rem 1.1rem; border: 2px solid var(--line); border-radius: 999px;
  color: var(--text); text-decoration: none; font-weight: 600; white-space: nowrap; display: flex; align-items: center;
}
.pill[aria-current="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.hero { text-align: center; padding: 1.5rem 0 1rem; }
.hero .label { font-size: 1.1rem; margin: 0; }
.big { font-size: clamp(2.4rem, 11vw, 3.4rem); font-weight: 800; margin: 0.2rem 0 1rem; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.big-ish { font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.row { font-size: 1.1rem; display: flex; justify-content: center; flex-wrap: wrap; gap: 0.5rem; }

.chg { font-weight: 700; font-variant-numeric: tabular-nums; }
.chg.up { color: var(--up); }
.chg.down { color: var(--down); }
.chg.flat { color: var(--muted); }

.card { background: var(--card); border-radius: 16px; padding: 1rem 1.1rem; margin: 0.75rem 0; }
.holding .top { display: flex; justify-content: space-between; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; }
.holding .value { font-size: 1.25rem; font-weight: 800; margin: 0; font-variant-numeric: tabular-nums; }
.symbol { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.result.ok .result-title { color: var(--up); font-weight: 800; font-size: 1.2rem; }
.result.bad .result-title { color: var(--down); font-weight: 800; font-size: 1.2rem; }

.button {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 3.6rem; margin: 1rem 0 0;
  padding: 0.8rem 1rem; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.button.secondary { background: transparent; color: var(--accent); border: 2px solid var(--accent); }
.choices { display: grid; gap: 0.75rem; }
.choice {
  min-height: 3.6rem; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); color: var(--text);
  font: inherit; font-weight: 700; text-align: left; padding: 0.8rem 1rem; cursor: pointer;
}
.choice[aria-pressed="true"] { border-color: var(--accent); outline: 3px solid var(--accent); }
.choice[aria-pressed="true"]::after { content: "  ✓"; color: var(--accent); }

input[type="password"], input[type="text"] {
  width: 100%; min-height: 3.4rem; font: inherit; font-size: 1.2rem; padding: 0.6rem 0.8rem; margin: 0.4rem 0;
  border: 2px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--text);
}
.error { color: var(--down); font-weight: 700; }
details summary { cursor: pointer; color: var(--muted); }

.busy { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 88%, transparent);
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem; font-weight: 700; }
.busy[hidden] { display: none; }

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--bg); border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.15rem;
  min-height: 4.2rem; color: var(--muted); text-decoration: none; font-size: 0.8rem; font-weight: 600;
}
.tabs svg { width: 1.6rem; height: 1.6rem; fill: currentColor; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 800; box-shadow: inset 0 4px 0 var(--accent); }
a:focus-visible, button:focus-visible, label:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Charts (app/charts.py). Main series = blue, comparison = gray (emphasis form). */
:root { --viz-main: #2a78d6; --viz-context: #898781; --viz-grid: #e1e0d9; --viz-surface: var(--bg); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --viz-main: #3987e5; --viz-context: #898781; --viz-grid: #2c2c2a; }
}
.chart-wrap { position: relative; margin: 0.5rem 0 0.25rem; }
.chart { width: 100%; height: auto; display: block; touch-action: pan-y; overflow: visible; }
.chart:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; border-radius: 6px; }
.chart .grid { stroke: var(--viz-grid); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.main { stroke: var(--viz-main); }
.chart .line.context { stroke: var(--viz-context); }
.chart .area { fill: var(--viz-main); opacity: 0.1; }
.chart .dot, .chart .hover-dot { stroke: var(--viz-surface); stroke-width: 2; }
.chart .dot.main, .chart .hover-dot.main { fill: var(--viz-main); }
.chart .dot.context, .chart .hover-dot.context { fill: var(--viz-context); }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.tooltip {
  position: absolute; top: -0.5rem; transform: translateY(-100%); pointer-events: none; z-index: 2;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.4rem 0.6rem;
  font-size: 0.85rem; box-shadow: 0 4px 14px rgba(0,0,0,0.12); white-space: nowrap;
}
.tip-date { color: var(--muted); }
.tip-row { display: flex; align-items: center; gap: 0.4rem; }
.key { display: inline-block; width: 14px; height: 0; border-top: 3px solid; border-radius: 2px; }
.key.main { border-color: var(--viz-main); }
.key.context { border-color: var(--viz-context); }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; margin: 0.5rem 0 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 0.45rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.chips.periods { flex-wrap: nowrap; }
.chips.periods .pill { flex: 1; justify-content: center; padding: 0.6rem 0.4rem; }
.chips .pill { min-height: 2.8rem; }
.headline { font-size: 1.1rem; margin: 0.75rem 0 0.25rem; }
.verdict { font-weight: 800; }
.note { font-size: 0.85rem; color: var(--muted); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
table.data th, table.data td { text-align: right; padding: 0.3rem 0.2rem; border-bottom: 1px solid var(--line); }
table.data th:first-child, table.data td:first-child { text-align: left; }
.topbar { display: flex; justify-content: flex-end; }
.topbar a { display: inline-flex; align-items: center; gap: 0.35rem; min-height: 2.6rem; padding: 0 0.25rem;
  color: var(--muted); font-weight: 600; text-decoration: none; }
.topbar svg { width: 1.3rem; height: 1.3rem; fill: currentColor; }
.section-title { font-size: 1.05rem; margin: 1.5rem 0 0; }

/* Part-to-whole bars (My stocks). Categorical slots in fixed order; colour follows the entity. */
:root { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767; }
}
.s1 { --c: var(--s1); } .s2 { --c: var(--s2); } .s3 { --c: var(--s3); } .s4 { --c: var(--s4); }
.s5 { --c: var(--s5); } .s6 { --c: var(--s6); } .s7 { --c: var(--s7); } .s8 { --c: var(--s8); }
.alloc { background: transparent; padding: 0; }
.alloc h2 { margin-top: 1rem; }
.stack { display: flex; gap: 2px; height: 1.5rem; margin: 0.5rem 0; }
.stack .seg { background: var(--c); min-width: 3px; }
.stack .seg:first-child { border-radius: 4px 0 0 4px; }
.stack .seg:last-child { border-radius: 0 4px 4px 0; }
.stack .seg:only-child { border-radius: 4px; }
.stack .seg:hover { filter: brightness(1.1); }
.stack-legend { flex-direction: column; gap: 0.3rem; }
.swatch { width: 14px; height: 14px; border-radius: 3px; background: var(--c); flex: none; }
.bars { list-style: none; margin: 0.5rem 0 0; padding: 0; display: grid; gap: 0.7rem; }
.bar-label { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.95rem; }
.bar-label > span:first-child { overflow-wrap: anywhere; }
.bar-label > span:last-child { white-space: nowrap; }
.bar-track { height: 14px; margin-top: 0.2rem; }
.bar { display: block; height: 100%; min-width: 3px; background: var(--s1); border-radius: 0 4px 4px 0; }
