/* Layout: one phone-width column, sticky disclaimer on top, tab bar at the bottom; desktop centres the column. */
:root {
  --bg: #eef2f8;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --ink: #0f1b2d;
  --ink-2: #46546a;
  --muted: #6c788c;
  --line: #dde3ee;
  --accent: #1f55c9;
  --accent-ink: #ffffff;
  --accent-soft: #e5ecfa;
  --good: #0b7a4b; --good-soft: #e3f4ec;
  --warn: #a25a00; --warn-soft: #fdf0dc;
  --bad: #b42318; --bad-soft: #fde8e6;
  --banner-bg: #12203a; --banner-ink: #dfe7f6;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --font-text: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Manrope', 'Inter', system-ui, sans-serif;
  --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b111c; --surface: #131c2b; --surface-2: #182336; --ink: #e8edf5; --ink-2: #b0bccd; --muted: #8592a6;
    --line: #26324a; --accent: #7aa2ff; --accent-ink: #0b111c; --accent-soft: #1a2a4a;
    --good: #4fd19a; --good-soft: #10291f; --warn: #f0b050; --warn-soft: #2e2210; --bad: #ff8a7f; --bad-soft: #351614;
    --banner-bg: #1d2a44; --banner-ink: #dfe7f6; --s1: #3987e5; --s2: #d95926; --s3: #199e70; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b111c; --surface: #131c2b; --surface-2: #182336; --ink: #e8edf5; --ink-2: #b0bccd; --muted: #8592a6;
  --line: #26324a; --accent: #7aa2ff; --accent-ink: #0b111c; --accent-soft: #1a2a4a;
  --good: #4fd19a; --good-soft: #10291f; --warn: #f0b050; --warn-soft: #2e2210; --bad: #ff8a7f; --bad-soft: #351614;
  --banner-bg: #1d2a44; --banner-ink: #dfe7f6; --s1: #3987e5; --s2: #d95926; --s3: #199e70; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font-text); -webkit-font-smoothing: antialiased; }
.app { max-width: 440px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 520px) { .app { border-inline: 1px solid var(--line); } }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num, .amt, td, .big { font-variant-numeric: tabular-nums; }

.banner { position: sticky; top: 0; z-index: 5; background: var(--banner-bg); color: var(--banner-ink); font-size: 11px; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; padding: calc(6px + env(safe-area-inset-top, 0px)) 16px 6px; }
main { padding: 20px max(16px, env(safe-area-inset-left, 0px)) 24px max(16px, env(safe-area-inset-right, 0px)); display: flex; flex-direction: column; gap: 18px; outline: none; }
.loading { color: var(--muted); }

h1, h2, h3 { font-family: var(--font-display); margin: 0; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 24px; line-height: 1.2; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p { margin: 0; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sub { color: var(--ink-2); font-size: 14px; }
.small { font-size: 12.5px; color: var(--muted); }
.nowrap { white-space: nowrap; }
.head { display: flex; flex-direction: column; gap: 6px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.section { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.row > :first-child { min-width: 0; }

.big { font-family: var(--font-display); font-size: 34px; font-weight: 800; line-height: 1.05; letter-spacing: -.02em; }
.delta { font-size: 13px; font-weight: 600; }
.delta.up { color: var(--bad); } .delta.down { color: var(--good); }

.leak { background: var(--accent); color: var(--accent-ink); border: 0; }
.leak .eyebrow, .leak .small { color: inherit; opacity: .8; }
.leak .big { font-size: 38px; }
.leak ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.leak li strong { white-space: nowrap; }
.leak li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; border-top: 1px solid color-mix(in srgb, var(--accent-ink) 22%, transparent); padding-top: 8px; }

/* Bars */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: baseline; }
.bar-row .label { font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
.bar-row .amt { font-size: 14px; font-weight: 600; text-align: right; }
.bar-track { grid-column: 1 / -1; position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--accent); }
.bar-tick { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; opacity: .55; }
.bar-row .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

.stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--surface); }
.stack span { display: block; height: 100%; }
.legend { display: flex; flex-direction: column; gap: 8px; }
.legend .row { font-size: 14px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: 0; flex: none; }
.c0 { background: var(--s1); } .c1 { background: var(--s2); } .c2 { background: var(--s3); }

/* Card chip */
.cardname { display: inline-flex; align-items: center; gap: 0; font-weight: 600; }
.cardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cardhead .small { text-align: right; }

/* Progress */
.target { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.target:first-of-type { border-top: 0; padding-top: 0; }
.progress { position: relative; height: 10px; border-radius: 5px; background: var(--surface-2); overflow: visible; }
.progress .done { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 5px; }
.progress .proj { position: absolute; inset: 0 auto 0 0; border-radius: 5px; background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--accent) 35%, transparent) 0 4px, transparent 4px 8px); }
.target .remaining { font-family: var(--font-display); font-weight: 700; font-size: 18px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.neutral { background: var(--surface-2); color: var(--ink-2); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }

/* Picker */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: 500 13.5px var(--font-text); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; cursor: pointer; min-height: 34px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.amount-wrap { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; }
.amount-wrap:focus-within { border-color: var(--accent); }
.amount-wrap span { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--muted); }
.amount-wrap input { border: 0; background: transparent; color: var(--ink); font: 700 26px var(--font-display); padding: 8px 8px; width: 100%; min-width: 0; outline: none; font-variant-numeric: tabular-nums; }
select { font: 14px var(--font-text); color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; align-self: flex-start; }
.seg button { font: 500 13px var(--font-text); border: 0; background: var(--surface); color: var(--ink-2); padding: 8px 14px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.controls { display: grid; grid-template-columns: 1fr; gap: 12px; }
.amount-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.amount-row .seg { flex-direction: column; align-self: end; }
.amount-row .seg button { padding: 6px 12px; }
.label-row { display: flex; justify-content: space-between; gap: 8px; }

.result { display: flex; flex-direction: column; gap: 10px; }
.result.best { border: 2px solid var(--accent); }
.result .top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.result .val { text-align: right; }
.result .val .amt { font-family: var(--font-display); font-weight: 800; font-size: 26px; line-height: 1.1; display: block; }
.rank { font-family: var(--font-display); font-weight: 800; color: var(--muted); margin-right: 8px; }
.reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.reasons li { font-size: 13.5px; line-height: 1.4; padding-left: 18px; position: relative; color: var(--ink-2); }
.reasons li::before { content: ""; position: absolute; left: 2px; top: .45em; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.reasons li.good::before { background: var(--good); }
.reasons li.warn::before { background: var(--warn); }
.reasons li.bad::before { background: var(--bad); }
.reasons li.bad { color: var(--ink); }

/* Lists */
.list { display: flex; flex-direction: column; }
.item { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 0; }
.item:last-child { padding-bottom: 0; }
.item .l { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.item .r { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; flex: none; }
.item .title { font-weight: 600; }

/* Home */
.hero { display: flex; flex-direction: column; gap: 10px; }
.hero h1 { font-size: 27px; }
.persona { flex-direction: row; gap: 12px; align-items: center; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font: 800 16px var(--font-display); flex: none; }
.tiles { display: grid; grid-template-columns: 1fr; gap: 10px; }
.tile { text-decoration: none; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.tile:hover { border-color: var(--accent); }
.tile .t { font: 700 16px var(--font-display); }
.tile .teaser { grid-column: 1; font-size: 13.5px; color: var(--ink-2); }
.tile .go { grid-row: 1 / span 2; grid-column: 2; color: var(--accent); font-size: 20px; }
.tile.hero-tile { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tile.hero-tile .teaser, .tile.hero-tile .go { color: inherit; opacity: .9; }

.how { border-top: 1px dashed var(--line); padding-top: 12px; font-size: 12.5px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.how strong { color: var(--ink-2); font-weight: 600; }
.how a { color: inherit; }
.error { background: var(--bad-soft); color: var(--bad); border-radius: var(--r); padding: 14px; }

.tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 440px; z-index: 5; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding: 6px max(4px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px)); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500; padding: 4px 0; }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) { .bar-fill, .progress .done { transition: width .3s ease; } }
