/* BudgetBuddy — styles. System fonts only (no external requests). Brand: navy + wallet green. */
:root {
  /* brand */
  --navy: #0C2339;
  --navy-2: #143150;
  --green: #12A06E;
  --green-2: #3CCB8F;
  --teal: #0F706D;
  --nav-bg: #0C2339;
  --nav-text: #DCE7F2;
  --nav-active: linear-gradient(135deg, #10A36F, #0E8E73);
  --hero-bg: linear-gradient(140deg, #0C2339 0%, #0F3043 60%, #0F4A4A 100%);
  --hero-line: #3DDC97;
  /* ui */
  --ink: #0B7F5C;            /* accent for links, primary buttons (AA on white) */
  --ink-2: #096B4D;
  --on-ink: #FFFFFF;
  --paper: #F3F7F6;
  --surface: #FFFFFF;
  --surface-2: #EDF3F1;
  --line: #DCE5E2;
  --text: #0C2339;
  --muted: #566778;
  --in: #0F8A5C;
  --in-bg: #E1F4EA;
  --warn: #8F600C;
  --warn-strong: #C27F12;
  --warn-bg: #FCF1DC;
  --bad: #B83A3A;
  --bad-bg: #FBE6E4;
  --focus: #2F6FE4;
  /* categorical chart hues (validated: colour-blind safe, 3:1 on surface) */
  --c1: #2F6FE4; --c2: #C97A0A; --c3: #0B8FA6; --c4: #8B5CF6; --c5: #2E9E4F; --c-other: #94A3B8;
  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 18px;
  --shadow: 0 1px 2px rgba(12, 35, 57, .05), 0 6px 20px rgba(12, 35, 57, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-figures: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI Variable Display", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --nav-bg: #081626; --nav-text: #C9D6E3; --hero-bg: linear-gradient(140deg, #10263D 0%, #12324A 60%, #114747 100%);
    --ink: #3CCB8F; --ink-2: #6BDBA9; --on-ink: #08201A; --paper: #0A1828; --surface: #10233A; --surface-2: #173049;
    --line: #24405C; --text: #E6EEF6; --muted: #98AABD; --in: #4FD69B; --in-bg: #10342C;
    --warn: #F0BC5E; --warn-strong: #E5A93E; --warn-bg: #352A12; --bad: #F2867C; --bad-bg: #3A1E22; --focus: #7FAEFF;
    --c1: #4A84EC; --c2: #C98420; --c3: #169CB2; --c4: #8F6CF0; --c5: #32A25A; --c-other: #64788F;
    --shadow: 0 1px 2px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --nav-bg: #081626; --nav-text: #C9D6E3; --hero-bg: linear-gradient(140deg, #10263D 0%, #12324A 60%, #114747 100%);
  --ink: #3CCB8F; --ink-2: #6BDBA9; --on-ink: #08201A; --paper: #0A1828; --surface: #10233A; --surface-2: #173049;
  --line: #24405C; --text: #E6EEF6; --muted: #98AABD; --in: #4FD69B; --in-bg: #10342C;
  --warn: #F0BC5E; --warn-strong: #E5A93E; --warn-bg: #352A12; --bad: #F2867C; --bad-bg: #3A1E22; --focus: #7FAEFF;
  --c1: #4A84EC; --c2: #C98420; --c3: #169CB2; --c4: #8F6CF0; --c5: #32A25A; --c-other: #64788F;
  --shadow: 0 1px 2px rgba(0,0,0,.35); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--text); font: 16px/1.5 var(--font); font-variant-numeric: tabular-nums; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .5em; }
a { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.num { font-family: var(--font-figures); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--in); }
.neg { color: var(--bad); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--nav-bg); color: var(--nav-text); padding: 22px 14px 0; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; text-decoration: none; }
.brand .logo { width: 36px; height: 34px; flex: none; }
.wordmark { font-weight: 800; letter-spacing: -0.025em; line-height: 1; font-size: 1.3rem; white-space: nowrap; }
.wordmark .w1 { color: var(--navy); }
.wordmark .w2 { background: linear-gradient(90deg, #0E9466, #22B585); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sidebar .wordmark .w1 { color: #FFFFFF; }
.sidebar .wordmark .w2 { background: linear-gradient(90deg, #2CC98A, #5BDCA6); -webkit-background-clip: text; background-clip: text; }
:root[data-theme="dark"] .wordmark .w1 { color: #FFFFFF; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wordmark .w1 { color: #FFFFFF; } }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-m); color: inherit; text-decoration: none; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a[aria-current="page"] { background: var(--nav-active); color: #fff; font-weight: 600; box-shadow: 0 4px 14px rgba(16, 163, 111, .28); }
.nav svg { width: 20px; height: 20px; flex: none; }
.sidebar-foot { margin-top: auto; font-size: .8rem; padding: 10px 10px 0; line-height: 1.45; position: relative; z-index: 1; display: flex; gap: 8px; align-items: flex-start; color: var(--nav-text); }
.sidebar-foot svg { width: 16px; height: 16px; flex: none; margin-top: 2px; color: var(--green-2); }
.sidebar-waves { display: block; width: calc(100% + 28px); margin: 6px -14px 0; height: 90px; }

main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 5; }
.topbar h1 { flex: 1; font-size: 1.35rem; }
.page { padding: 24px 28px 64px; max-width: 1180px; }
.bottom-nav { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 1.15rem; }
  .page { padding: 16px 16px 96px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 10; padding-bottom: env(safe-area-inset-bottom); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 10px; font-size: .72rem; color: var(--muted); text-decoration: none; background: none; border: 0; min-height: 56px; }
  .bottom-nav [aria-current="page"] { color: var(--ink); font-weight: 600; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .hide-mobile { display: none !important; }
  .runway-pace div { text-align: left; }
}

/* ---------- Buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border-radius: var(--radius-m); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 550; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); box-shadow: 0 2px 8px rgba(11, 127, 92, .22); }
.btn-primary:hover { background: var(--ink-2); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink); padding: 6px 10px; min-height: 36px; }
.btn-quiet:hover { background: var(--surface-2); border-color: transparent; }
.btn-danger { color: var(--bad); }
.btn-sm { min-height: 32px; padding: 4px 10px; font-size: .875rem; }
.btn svg { width: 18px; height: 18px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

label { display: block; font-size: .875rem; font-weight: 550; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=search], select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.money-input { position: relative; }
.money-input span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.money-input input { padding-left: 26px; font-family: var(--font-figures); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 450; font-size: .95rem; }
.check input { width: 20px; height: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }
.segmented { display: flex; background: var(--surface-2); border-radius: var(--radius-m); padding: 3px; gap: 3px; margin-bottom: 16px; flex-wrap: wrap; }
.segmented label { flex: 1; margin: 0; text-align: center; }
.segmented input { position: absolute; opacity: 0; }
.segmented span { display: block; padding: 8px 6px; border-radius: 8px; cursor: pointer; font-weight: 550; font-size: .9rem; }
.segmented input:checked + span { background: var(--surface); box-shadow: var(--shadow); color: var(--ink); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); }

/* ---------- Surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head a, .panel-head .btn-quiet { font-size: .9rem; }
.layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.layout > div > .panel + .panel { margin-top: 16px; }
@media (max-width: 1060px) { .layout { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 16px; }

/* ---------- Runway hero ---------- */
.runway { background: var(--hero-bg); color: #EAF2F8; border-radius: var(--radius-l); padding: 24px 24px 12px; position: relative; overflow: hidden; box-shadow: 0 10px 30px rgba(12, 35, 57, .18); }
.runway::after { content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(61, 220, 151, .16), transparent 70%); pointer-events: none; }
.runway-top { display: flex; flex-wrap: wrap; gap: 16px 40px; align-items: flex-end; justify-content: space-between; }
.runway-label { font-size: .95rem; opacity: .85; }
.runway-figure { font-family: var(--font-figures); font-size: clamp(2.6rem, 7vw, 4.2rem); font-weight: 750; line-height: 1; letter-spacing: -0.02em; margin: 6px 0 8px; }
.runway-figure.is-neg { color: #FFB4AA; }
.runway-sub { font-size: .95rem; opacity: .9; }
.runway-pace { display: flex; gap: 28px; }
.runway-pace div { text-align: right; }
.runway-pace .num { font-size: 1.5rem; font-weight: 700; display: block; }
.runway-pace small { opacity: .8; }
.runway svg { display: block; width: 100%; height: 150px; margin-top: 10px; overflow: visible; }
.runway .r-line { fill: none; stroke: var(--hero-line); stroke-width: 2.5; stroke-linejoin: round; }
.runway .r-area { fill: rgba(61, 220, 151, .13); }
.runway .r-buffer { stroke: #F2C46B; stroke-width: 1.5; stroke-dasharray: 5 5; }
.runway .r-zero { stroke: rgba(255,255,255,.35); stroke-width: 1; }
.runway .r-text { fill: currentColor; font-size: 11px; opacity: .8; font-family: var(--font); }
.runway .r-dot { fill: var(--hero-line); }
.runway .r-pay { fill: #F2C46B; }
.runway details { margin-top: 6px; font-size: .9rem; }
.runway summary { cursor: pointer; opacity: .9; padding: 6px 0; }
.breakdown { width: 100%; max-width: 420px; border-collapse: collapse; margin: 6px 0 10px; }
.breakdown td { padding: 3px 0; }
.breakdown td:last-child { text-align: right; }
.breakdown tr.total td { border-top: 1px solid rgba(255,255,255,.35); font-weight: 700; padding-top: 6px; }
.estimate-note { font-size: .78rem; opacity: .75; }

/* ---------- Rows & lists ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row-main { min-width: 0; }
.row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-amt { text-align: right; font-family: var(--font-figures); font-weight: 600; }
.row-amt small { display: block; font-weight: 400; color: var(--muted); font-size: .78rem; font-family: var(--font); }
.row.clickable { cursor: pointer; }
.row.clickable:hover { background: var(--surface-2); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: var(--radius-s); }
.date-chip { width: 44px; text-align: center; line-height: 1.1; color: var(--muted); font-size: .75rem; }
.date-chip b { display: block; font-size: 1.1rem; color: var(--text); font-family: var(--font-figures); }
.kind { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 1rem; background: var(--surface-2); }
.kind svg { width: 18px; height: 18px; }
.k-income { background: var(--in-bg); color: var(--in); }
.k-spending { background: var(--surface-2); color: var(--text); }
.k-debt { background: var(--bad-bg); color: var(--bad); }
.k-savings { background: color-mix(in srgb, var(--c1) 14%, transparent); color: var(--c1); }
.k-adjustment, .k-transfer, .k-withdrawal { background: var(--surface-2); color: var(--muted); }
.day-head { font-size: .82rem; color: var(--muted); font-weight: 600; padding: 14px 0 2px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.after-bal { font-size: .78rem; color: var(--muted); }
.after-bal.low { color: var(--warn); font-weight: 600; }
.after-bal.neg { color: var(--bad); font-weight: 600; }

.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag-good { background: var(--in-bg); color: var(--in); }
.tag-warn { background: var(--warn-bg); color: var(--warn); }
.tag-bad { background: var(--bad-bg); color: var(--bad); }

/* ---------- Alerts ---------- */
.alerts { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-m); background: var(--surface-2); font-size: .93rem; border-left: 4px solid var(--line); }
.alert-bad { background: var(--bad-bg); border-left-color: var(--bad); }
.alert-warn { background: var(--warn-bg); border-left-color: var(--warn-strong); }
.alert-good { background: var(--in-bg); border-left-color: var(--in); }
.alert-info { border-left-color: var(--ink); }
.alert button { margin-left: auto; }

/* ---------- Progress ---------- */
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; position: relative; }
.meter > span { position: absolute; inset: 0 auto 0 0; background: var(--ink); border-radius: 99px; }
.meter.good > span { background: var(--in); }
.meter.warn > span { background: var(--warn-strong); }
.meter.bad > span { background: var(--bad); }
.plan-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.plan-line:last-child { border-bottom: 0; }
.plan-line .meter { grid-column: 1 / -1; }
.plan-line .status { grid-column: 1 / -1; font-size: .8rem; }
.plan-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 14px; margin-top: 4px; border-top: 2px solid var(--text); font-weight: 700; font-size: 1.1rem; }

/* ---------- Stats ---------- */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.figure { padding: 12px 14px; border-radius: var(--radius-m); background: var(--surface-2); }
.figure span { display: block; font-size: .82rem; color: var(--muted); }
.figure strong { font-family: var(--font-figures); font-size: 1.3rem; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .bar { fill: var(--ink); }
.chart .bar.low { fill: var(--warn-strong); }
.chart .bar.neg { fill: var(--bad); }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.chart .buffer { stroke: var(--warn-strong); stroke-dasharray: 4 4; }
.chart-table summary { font-size: .82rem; color: var(--muted); cursor: pointer; margin-top: 6px; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.data td.r, table.data th.r { text-align: right; font-family: var(--font-figures); }

/* ---------- Calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: .75rem; color: var(--muted); text-align: center; padding: 4px 0; font-weight: 600; }
.cal-day { min-height: 92px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); padding: 6px; text-align: left; cursor: pointer; display: flex; flex-direction: column; gap: 2px; font-size: .75rem; }
.cal-day:hover { border-color: var(--ink); }
.cal-day.out { opacity: .4; }
.cal-day.today { border: 2px solid var(--ink); }
.cal-day[aria-pressed="true"] { background: var(--surface-2); border-color: var(--ink); }
.cal-day .d { font-weight: 650; font-size: .85rem; }
.cal-day .amt { font-family: var(--font-figures); font-weight: 600; }
.cal-day .bal { margin-top: auto; color: var(--muted); }
.cal-day.low .bal { color: var(--warn); font-weight: 600; }
.cal-day.negbal .bal { color: var(--bad); font-weight: 600; }
@media (max-width: 640px) {
  .cal-day { min-height: 58px; padding: 4px; font-size: .68rem; }
  .cal-day .amt-detail, .cal-day .bal { display: none; }
}
.dots { display: flex; gap: 3px; flex-wrap: wrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.income { background: var(--in); } .dot.spending { background: var(--text); } .dot.debt { background: var(--bad); } .dot.savings { background: var(--c1); }

/* ---------- Month switcher ---------- */
.month-switch { display: inline-flex; align-items: center; gap: 4px; }
.month-switch strong { min-width: 150px; text-align: center; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar select, .toolbar input { width: auto; min-width: 140px; }

/* ---------- Modal ---------- */
dialog { border: 0; border-radius: var(--radius-l); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 26, 26, .5); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.modal-body { padding: 10px 20px; overflow: auto; max-height: calc(100vh - 180px); }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
.form-error { color: var(--bad); font-size: .9rem; margin: 0 0 10px; font-weight: 550; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--paper); padding: 10px 12px 10px 18px; border-radius: var(--radius-m); display: flex; align-items: center; gap: 12px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; max-width: calc(100vw - 24px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast button { background: transparent; border: 1px solid currentColor; color: inherit; border-radius: 8px; padding: 4px 10px; cursor: pointer; }
@media (max-width: 860px) { .toast { bottom: 84px; } }

/* ---------- Empty / welcome ---------- */
.welcome { max-width: 640px; }
.welcome h2 { font-size: 1.5rem; margin-bottom: 8px; }
.welcome ol { padding-left: 20px; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty .btn { margin-top: 10px; }
.privacy { display: flex; gap: 10px; align-items: center; font-size: .85rem; color: var(--muted); margin-top: 28px; }
.privacy svg { width: 18px; height: 18px; flex: none; }

.split { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.story p { font-size: 1rem; }
.cardlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.acct-group + .acct-group { margin-top: 24px; }
.acct-group > h2 { margin-bottom: 10px; display: flex; justify-content: space-between; }
dl.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 10px 0 0; font-size: .9rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; text-align: right; font-family: var(--font-figures); }
input[type=range] { width: 100%; accent-color: var(--ink); }
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-top: 12px; }
.compare > div { padding: 14px; border-radius: var(--radius-m); background: var(--surface-2); }
.compare h3 { font-size: .9rem; margin-bottom: 6px; }
.compare .big { font-family: var(--font-figures); font-size: 1.25rem; font-weight: 700; }
.reorder { display: inline-flex; gap: 2px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .sidebar, .bottom-nav, .topbar .btn, .toast { display: none !important; } .shell { display: block; } }
.layout > div { min-width: 0; }
.row .btn-quiet { white-space: normal; text-align: left; min-width: 0; }
.cardlist > .panel, .figures > .panel { margin-top: 0; }

/* UK date field with calendar button */
.date-input { position: relative; display: flex; gap: 6px; align-items: stretch; }
.date-input input[type=text] { flex: 1; font-family: var(--font-figures); }
.date-input .date-pick { border: 1px solid var(--line); background: var(--surface); padding: 0 10px; min-height: 42px; }
.date-input .date-native { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }

/* Month plan sum */
table.sum { width: 100%; border-collapse: collapse; }
table.sum th, table.sum td { padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 500; }
table.sum td { text-align: right; font-family: var(--font-figures); font-weight: 600; }
table.sum tfoot th, table.sum tfoot td { border-top: 2px solid var(--text); border-bottom: 0; font-weight: 700; font-size: 1.1rem; padding-top: 12px; }
.bank-line { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-m); background: var(--surface-2); }
.bank-line > div { flex: 1; }
.bank-line span, .bank-line strong { display: block; }
.bank-line strong { font-size: 1.25rem; }

/* ---------- Planner grid ---------- */
.planner-panel { padding: 0; overflow: hidden; }
.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.planner { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 760px; font-size: .92rem; }
table.planner th, table.planner td { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.planner .r { text-align: right; }
table.planner thead th { position: sticky; top: 0; background: var(--surface); font-size: .82rem; color: var(--muted); font-weight: 600; padding: 12px 6px 8px; }
table.planner thead th.cur { color: var(--ink); }
table.planner th[scope=row], table.planner thead th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; padding-left: 16px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
table.planner tr.sec th { background: var(--surface-2); color: var(--text); font-weight: 700; padding: 8px 12px 8px 16px; position: static; }
table.planner tr.sec th span { margin-right: 8px; }
table.planner tr.sec .btn { min-height: 28px; font-weight: 550; }
table.planner td.usual { color: var(--muted); font-family: var(--font-figures); line-height: 1.1; }
table.planner td.usual small, .cell-btn small, table.planner td small { display: block; font-size: .7rem; font-family: var(--font); color: var(--muted); }
table.planner td.none { color: var(--muted); opacity: .6; }
table.planner tr.subtotal th, table.planner tr.subtotal td { font-weight: 650; font-family: var(--font-figures); border-bottom-width: 2px; }
table.planner tr.subtotal th { font-family: var(--font); color: var(--muted); }
table.planner tfoot th, table.planner tfoot td { font-weight: 700; font-family: var(--font-figures); padding-top: 10px; padding-bottom: 10px; }
table.planner tfoot th { font-family: var(--font); }
table.planner tfoot tr.leftover td, table.planner tfoot tr.leftover th { border-top: 2px solid var(--text); }
table.planner tfoot td.low { color: var(--warn); }
table.planner tfoot td.low small { color: var(--warn); }
input.cell { width: 96px; min-height: 34px; padding: 4px 8px; text-align: right; font-family: var(--font-figures); border: 1px solid transparent; border-radius: var(--radius-s); background: transparent; }
input.cell:hover { border-color: var(--line); background: var(--surface); }
input.cell:focus { border-color: var(--focus); background: var(--surface); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.cell.changed { background: var(--warn-bg); font-weight: 700; color: var(--text); border-color: transparent; }
.cell.changed:hover { border-color: var(--warn-strong); }
.cell.est { color: var(--muted); font-style: italic; }
.cell.demo { display: inline-block; padding: 1px 6px; border-radius: 4px; font-family: var(--font-figures); }
.cell-btn { width: 96px; min-height: 34px; padding: 4px 8px; text-align: right; font: inherit; font-family: var(--font-figures); background: none; border: 1px solid transparent; border-radius: var(--radius-s); cursor: pointer; color: inherit; line-height: 1.1; }
.cell-btn:hover { border-color: var(--line); }
.cell-btn.done { color: var(--in); }
.cell-btn.skipped { color: var(--muted); font-family: var(--font); font-size: .8rem; }
.cell-btn.changed { background: var(--warn-bg); font-weight: 700; }
.link-btn { background: none; border: 0; padding: 4px 0; font: inherit; color: inherit; cursor: pointer; text-align: left; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.link-btn:hover { text-decoration: underline; }
.planner-panel .legend { padding: 12px 16px; margin: 0; }
@media (max-width: 700px) {
  table.planner .usual { display: none; }
  table.planner { min-width: 620px; }
  table.planner th[scope=row] { max-width: 130px; }
  .link-btn { max-width: 120px; }
  input.cell, .cell-btn { width: 80px; }
}


/* ================= BudgetBuddy brand pieces ================= */
.panel { box-shadow: var(--shadow); border-color: var(--line); }
.topbar { background: color-mix(in srgb, var(--paper) 88%, transparent); backdrop-filter: blur(8px); }
.topbar .top-brand { display: none; }
.icon-btn { width: 40px; height: 40px; padding: 0; min-height: 40px; }
.icon-btn svg { width: 20px; height: 20px; }
@media (max-width: 860px) {
  .topbar .top-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; }
  .topbar .top-brand .logo { width: 30px; height: 28px; }
  .topbar .top-brand .wordmark { font-size: 1.15rem; }
  .topbar h1 { display: none; }
  .topbar .spacer { flex: 1; }
}
@media (min-width: 861px) { .topbar .spacer { display: none; } }

/* Welcome */
.welcome-hero { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); box-shadow: var(--shadow); padding: 36px 36px 0; }
.welcome-hero .lockup { display: flex; align-items: center; gap: 18px; }
.welcome-hero .lockup .logo { width: 84px; height: 78px; }
.welcome-hero .lockup .wordmark { font-size: clamp(2.4rem, 7vw, 4rem); }
.welcome-hero .tagline { font-size: clamp(1.2rem, 3vw, 1.6rem); color: var(--muted); margin: 6px 0 0 2px; font-weight: 500; }
.welcome-hero h2 { font-size: 1.35rem; margin: 28px 0 6px; }
.welcome-hero .lede { color: var(--muted); max-width: 46ch; font-size: 1.05rem; }
.features { list-style: none; padding: 0; margin: 22px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 28px; max-width: 760px; }
.features li { display: grid; grid-template-columns: 52px 1fr; gap: 14px; align-items: start; }
.features .f-ic { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.features .f-ic svg { width: 24px; height: 24px; }
.features h3 { font-size: 1.02rem; margin: 2px 0 2px; }
.features p { color: var(--muted); font-size: .92rem; margin: 0; }
.f-green { background: linear-gradient(135deg, #2BB673, #12A06E); }
.f-blue { background: linear-gradient(135deg, #4C8DF6, #2F6FE4); }
.f-purple { background: linear-gradient(135deg, #9D74F7, #7C4FE8); }
.f-orange { background: linear-gradient(135deg, #FF9A6B, #F2694A); }
.welcome-hero .btn-row { margin-top: 28px; position: relative; z-index: 1; }
.welcome-waves { display: block; width: calc(100% + 72px); margin: 28px -36px 0; height: 120px; }
@media (max-width: 600px) { .welcome-hero { padding: 24px 20px 0; } .welcome-waves { width: calc(100% + 40px); margin: 20px -20px 0; height: 80px; } .welcome-hero .lockup .logo { width: 60px; height: 56px; } }

/* Donut */
.donut-wrap { display: grid; grid-template-columns: 170px 1fr; gap: 18px; align-items: center; }
@media (max-width: 420px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }
.donut { width: 170px; height: 170px; }
.donut circle.seg { fill: none; stroke-width: 18; transition: stroke-width .12s; }
.donut circle.seg:hover { stroke-width: 22; }
.donut .d-total { font-family: var(--font-figures); font-weight: 750; font-size: 15px; fill: var(--text); }
.donut .d-sub { font-size: 10px; fill: var(--muted); }
.legend-list { list-style: none; margin: 0; padding: 0; width: 100%; }
.legend-list li { display: grid; grid-template-columns: 12px 1fr auto 44px; gap: 10px; align-items: center; padding: 5px 0; font-size: .92rem; border-bottom: 1px solid var(--line); }
.legend-list li:last-child { border-bottom: 0; }
.legend-list .sw { width: 10px; height: 10px; border-radius: 50%; }
.legend-list .amt { font-family: var(--font-figures); font-weight: 600; text-align: right; }
.legend-list .pc { color: var(--muted); text-align: right; font-size: .85rem; }
.lockup-sm { display: flex; align-items: center; gap: 10px; }
.lockup-sm .logo { width: 40px; height: 38px; }
.lockup-sm .wordmark { font-size: 1.5rem; }
.donut-wrap { grid-template-columns: 132px minmax(0, 1fr); gap: 14px; }
.donut-wrap > * { min-width: 0; }
.donut { width: 132px; height: 132px; }
.legend-list li { grid-template-columns: 10px minmax(0, 1fr) auto 34px; gap: 8px; font-size: .88rem; }
.legend-list li > span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 861px) { .shell { background: linear-gradient(to right, var(--nav-bg) 232px, transparent 232px); } }
@media (max-width: 560px) { .runway .r-low { display: none; } }
dialog.wide { width: min(860px, calc(100vw - 24px)); }
table.csv-preview td { vertical-align: top; }
table.csv-preview tr.err td { background: color-mix(in srgb, var(--bad-bg) 60%, transparent); }
