/* ==========================================================================
   EveryPound — design tokens
   Light palette defined on bare :root so nothing depends on a media query;
   dark mode only redefines the same tokens.
   ========================================================================== */
:root {
  --teal-50:#f0fdfa; --teal-100:#ccfbf1; --teal-200:#99f6e4; --teal-500:#14b8a6;
  --teal-600:#0d9488; --teal-700:#0f766e; --teal-800:#115e59; --teal-900:#134e4a;

  --bg:#f4f6f7;
  --surface:#ffffff;
  --surface-2:#fafbfb;
  --surface-sunken:#eef1f2;
  --border:#e2e7e9;
  --border-strong:#cdd5d8;

  --text:#14211f;
  --text-muted:#5b6b6b;
  --text-faint:#8b9a9a;
  --text-invert:#ffffff;

  --accent:var(--teal-700);
  --accent-hover:var(--teal-800);
  --accent-soft:var(--teal-50);
  --accent-border:var(--teal-200);

  --positive:#15803d;
  --positive-soft:#f0fdf4;
  --negative:#b91c1c;
  --negative-soft:#fef2f2;
  --warning:#b45309;
  --warning-soft:#fffbeb;
  --info:#1d4ed8;

  --radius-sm:6px; --radius:10px; --radius-lg:14px; --radius-xl:20px;
  --shadow-sm:0 1px 2px rgba(15,35,35,.06);
  --shadow:0 1px 3px rgba(15,35,35,.08), 0 4px 12px rgba(15,35,35,.05);
  --shadow-lg:0 8px 30px rgba(15,35,35,.14);

  --sidebar-w:232px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#0c1413;
    --surface:#121d1c;
    --surface-2:#162322;
    --surface-sunken:#0e1817;
    --border:#243433;
    --border-strong:#314544;

    --text:#e6efee;
    --text-muted:#93a8a6;
    --text-faint:#6b807e;

    --accent:var(--teal-500);
    --accent-hover:var(--teal-200);
    --accent-soft:#0f2b28;
    --accent-border:#1c4a45;

    --positive:#4ade80;
    --positive-soft:#0d2318;
    --negative:#f87171;
    --negative-soft:#2a1416;
    --warning:#fbbf24;
    --warning-soft:#2a2012;
    --info:#93c5fd;

    --shadow-sm:0 1px 2px rgba(0,0,0,.4);
    --shadow:0 1px 3px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.35);
    --shadow-lg:0 8px 30px rgba(0,0,0,.6);

    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg:#0c1413;
  --surface:#121d1c;
  --surface-2:#162322;
  --surface-sunken:#0e1817;
  --border:#243433;
  --border-strong:#314544;
  --text:#e6efee;
  --text-muted:#93a8a6;
  --text-faint:#6b807e;
  --accent:var(--teal-500);
  --accent-hover:var(--teal-200);
  --accent-soft:#0f2b28;
  --accent-border:#1c4a45;
  --positive:#4ade80;
  --positive-soft:#0d2318;
  --negative:#f87171;
  --negative-soft:#2a1416;
  --warning:#fbbf24;
  --warning-soft:#2a2012;
  --info:#93c5fd;
  --shadow-sm:0 1px 2px rgba(0,0,0,.4);
  --shadow:0 1px 3px rgba(0,0,0,.5), 0 4px 12px rgba(0,0,0,.35);
  --shadow-lg:0 8px 30px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* ========================= base ========================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.tnum { font-variant-numeric: tabular-nums; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.money.neg { color: var(--negative); }
.money.pos { color: var(--positive); }
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.sr-only {
  position:absolute; width:1px; height:1px; padding:0; margin:-1px;
  overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0;
}

/* ========================= boot ========================= */
.app-loading { display: grid; place-items: center; min-height: 100dvh; }
.boot { text-align: center; color: var(--text-muted); }
.boot-mark {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-size: 28px; font-weight: 700;
}

/* ========================= shell ========================= */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100dvh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px; font-weight: 700; font-size: 16px; letter-spacing: -.02em;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; background: var(--accent);
  color: #fff; display: grid; place-items: center; font-size: 16px; font-weight: 700;
  flex: none;
}
.nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 8px;
  color: var(--text-muted); text-decoration: none; font-weight: 550;
}
.nav a:hover { background: var(--surface-sunken); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 17px; height: 17px; flex: none; }
.nav-badge {
  margin-left: auto; background: var(--warning); color: #fff;
  border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px;
}
.sidebar-foot {
  margin-top: auto; padding: 12px; border-top: 1px solid var(--border);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
  border: 1px solid var(--accent-border);
}
.user-chip-name { font-weight: 600; font-size: 13px; line-height: 1.2; }
.user-chip-sub { font-size: 11px; color: var(--text-faint); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 20;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
}
.topbar h1 { font-size: 19px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.content { padding: 22px 24px 60px; flex: 1; }
.content.wide { max-width: none; }

/* ========================= controls ========================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-sunken); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--negative); border-color: var(--negative); color: #fff; }
.btn-danger:hover { filter: brightness(.92); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-icon { padding: 7px; border-radius: 8px; }

.input, .select, textarea.input {
  width: 100%; padding: 8px 11px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-faint); }
.field { display: grid; gap: 5px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }
.field-hint { font-size: 11.5px; color: var(--text-faint); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); }

/* Date fields carry their own dd/mm/yyyy text, because a native date input renders in the
   browser's locale and would show a UK household US-ordered dates. */
.date-field { position: relative; display: block; }
.date-field .input { padding-right: 34px; font-variant-numeric: tabular-nums; }
.date-field .input.is-invalid { border-color: var(--negative); box-shadow: 0 0 0 3px var(--negative-soft); }
.date-pick {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 26px; height: 26px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text-faint);
  cursor: pointer; padding: 0;
}
.date-pick:hover { background: var(--surface-sunken); color: var(--accent); }
/* Present for the platform picker only; never shown, but must stay focusable for showPicker(). */
.date-native {
  position: absolute; right: 8px; bottom: 0; width: 1px; height: 1px;
  opacity: 0; pointer-events: none; border: 0; padding: 0;
}

.money-input { position: relative; }
.money-input .prefix {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); pointer-events: none;
}
.money-input .input { padding-left: 24px; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; }
.money-input.no-prefix .input { padding-left: 11px; }

/* ========================= cards / layout ========================= */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 14px; }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

.stat { padding: 15px 16px; }
.stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 650; }
.stat-value { font-size: 23px; font-weight: 680; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 650;
  background: var(--surface-sunken); color: var(--text-muted);
}
.pill-pos { background: var(--positive-soft); color: var(--positive); }
.pill-neg { background: var(--negative-soft); color: var(--negative); }
.pill-warn { background: var(--warning-soft); color: var(--warning); }
.pill-accent { background: var(--accent-soft); color: var(--accent); }

.empty { text-align: center; padding: 44px 20px; color: var(--text-muted); }
.empty-mark { font-size: 30px; margin-bottom: 8px; opacity: .55; }
.empty h3 { font-size: 15px; margin-bottom: 5px; color: var(--text); }

/* ========================= tables ========================= */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-faint); font-weight: 650; padding: 9px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.right, table.data th.right { text-align: right; }
table.data td.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.row-click { cursor: pointer; }

/* ========================= budget screen ========================= */
.budget-layout { display: grid; grid-template-columns: minmax(0,1fr) 340px; gap: 20px; align-items: start; }

.month-nav { display: flex; align-items: center; gap: 4px; }
.month-nav .month-label { min-width: 148px; text-align: center; font-weight: 650; }

.ltb {
  border-radius: var(--radius-lg); padding: 14px 18px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.ltb-amount { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ltb-label { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; color: var(--text-faint); }
.ltb.balanced { border-color: var(--positive); background: var(--positive-soft); }
.ltb.balanced .ltb-amount { color: var(--positive); }
.ltb.over { border-color: var(--negative); background: var(--negative-soft); }
.ltb.over .ltb-amount { color: var(--negative); }
.ltb.under .ltb-amount { color: var(--accent); }
.ltb-note { font-size: 12.5px; color: var(--text-muted); margin-left: auto; text-align: right; max-width: 280px; }

.bgroup { margin-bottom: 14px; }
.bgroup-head {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: var(--radius) var(--radius) 0 0;
  background: var(--surface-sunken); border: 1px solid var(--border); border-bottom: 0;
  cursor: pointer; user-select: none;
}
.bgroup-name { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.bgroup-cols { margin-left: auto; display: flex; gap: 0; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 650; }
.bgroup-cols span { width: 104px; text-align: right; }
.bgroup-body { border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); background: var(--surface); overflow: hidden; }
.bgroup.collapsed .bgroup-body { display: none; }
.bgroup.collapsed .bgroup-head { border-radius: var(--radius); border-bottom: 1px solid var(--border); }
.chev { transition: transform .15s; width: 13px; height: 13px; color: var(--text-faint); }
.bgroup.collapsed .chev { transform: rotate(-90deg); }

.bline {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px; border-bottom: 1px solid var(--border);
}
.bline:last-child { border-bottom: 0; }
.bline:hover { background: var(--surface-2); }
.bline-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 7px; }
.bline-name .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.bline-name .label:hover { color: var(--accent); }
.fund-tag {
  font-size: 10px; font-weight: 700; letter-spacing: .02em;
  background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 4px;
  flex: none; white-space: nowrap; font-variant-numeric: tabular-nums;
  border: 1px solid var(--accent-border);
}
.bline-cell { width: 104px; flex: none; min-width: 0; text-align: right; }
.bline-planned input {
  width: 100%; min-width: 0; text-align: right; padding: 5px 8px; border-radius: 6px;
  border: 1px solid transparent; background: transparent;
  font-variant-numeric: tabular-nums; font-weight: 600;
}
.bline-planned input:hover { border-color: var(--border-strong); background: var(--surface); }
.bline-planned input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.bline-spent { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.bline-spent.has { color: var(--text); font-weight: 550; }
.bline-remaining { font-variant-numeric: tabular-nums; font-weight: 600; }
.bline-add {
  padding: 8px 14px; display: flex; align-items: center; gap: 7px;
  color: var(--text-faint); cursor: pointer; font-size: 13px; font-weight: 550;
}
.bline-add:hover { color: var(--accent); background: var(--surface-2); }

.progress { height: 4px; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; margin-top: 4px; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.progress.over > span { background: var(--negative); }

/* right rail */
.rail { position: sticky; top: 88px; display: grid; gap: 16px; }
.donut-wrap { display: grid; place-items: center; padding: 6px 0 12px; }
.donut { position: relative; width: 190px; height: 190px; }
.donut-centre {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center;
}
.donut-centre .lab { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 650; }
.donut-centre .val { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.legend { display: grid; gap: 1px; }
.legend-row {
  display: grid; grid-template-columns: 10px 1fr auto auto; gap: 9px; align-items: center;
  padding: 6px 4px; border-radius: 6px; font-size: 13px;
}
.legend-row:hover { background: var(--surface-2); }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.legend-val { font-variant-numeric: tabular-nums; }
.legend-pct { font-variant-numeric: tabular-nums; color: var(--text-faint); font-size: 12px; width: 38px; text-align: right; }

/* ========================= transactions ========================= */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters .field { min-width: 140px; }
.filters .field.grow { flex: 1; min-width: 200px; }

.tx-cat {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 6px;
  background: var(--surface-sunken); font-size: 12px; font-weight: 600; color: var(--text-muted);
}
.tx-cat.none { background: var(--warning-soft); color: var(--warning); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.status-Uncleared { background: var(--border-strong); }
.status-Cleared { background: var(--info); }
.status-Reconciled { background: var(--positive); }

.pager { display: flex; align-items: center; gap: 10px; justify-content: center; padding: 14px; }

.bulkbar {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-top: 12px;
  background: var(--surface); border: 1px solid var(--accent-border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

/* ========================= import ========================= */
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 38px 20px; text-align: center; cursor: pointer; background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-mark { font-size: 30px; margin-bottom: 8px; }

.decision-New { color: var(--positive); }
.decision-Duplicate { color: var(--text-faint); }
.decision-MatchExisting { color: var(--info); }
.decision-Ignore { color: var(--text-faint); text-decoration: line-through; }
tr.row-skip td { opacity: .5; }

.banklist { display: flex; flex-wrap: wrap; gap: 6px; }
.banklist .pill { font-size: 12px; }

/* ========================= reconcile ========================= */
.recon-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; }
.recon-cell { background: var(--surface); padding: 13px 15px; }
.recon-cell.diff-zero { background: var(--positive-soft); }
.recon-cell.diff-nonzero { background: var(--warning-soft); }

/* ========================= reports ========================= */
.bar-row { display: grid; grid-template-columns: 150px 1fr 96px; gap: 12px; align-items: center; padding: 6px 0; }
.bar-track { height: 20px; background: var(--surface-sunken); border-radius: 5px; overflow: hidden; display: flex; }
.bar-fill { height: 100%; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }

/* ========================= auth ========================= */
.auth-page {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: linear-gradient(160deg, var(--teal-900) 0%, var(--teal-700) 45%, #0b3b38 100%);
}
.auth-card {
  width: 100%; max-width: 410px; background: var(--surface);
  border-radius: var(--radius-xl); padding: 30px; box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.auth-brand .brand-mark { width: 38px; height: 38px; border-radius: 11px; font-size: 20px; }
.auth-brand h1 { font-size: 21px; }
.auth-sub { color: var(--text-muted); margin: 0 0 22px; font-size: 13.5px; }
.auth-form { display: grid; gap: 14px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 13px; color: var(--text-muted); }
.auth-switch button { background: none; border: 0; color: var(--accent); font-weight: 650; cursor: pointer; padding: 0; }
.auth-error {
  background: var(--negative-soft); color: var(--negative); border: 1px solid currentColor;
  border-radius: 8px; padding: 9px 12px; font-size: 13px; font-weight: 550;
}

/* ========================= modal ========================= */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8,20,19,.5); backdrop-filter: blur(2px);
  display: grid; place-items: center; padding: 20px; z-index: 100;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px; max-height: 88dvh; display: flex; flex-direction: column;
}
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-head .btn-icon { margin-left: auto; }
.modal-body { padding: 18px; overflow-y: auto; display: grid; gap: 14px; }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }

.split-row { display: grid; grid-template-columns: 1fr 120px 32px; gap: 9px; align-items: center; }

/* ========================= toasts ========================= */
.toasts {
  position: fixed; z-index: 200; right: 16px; display: grid; gap: 8px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 11px 14px; box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 550; max-width: 340px;
  animation: toast-in .2s ease-out;
}
.toast.error { border-left-color: var(--negative); }
.toast.success { border-left-color: var(--positive); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--border-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: grid; place-items: center; padding: 50px; }

/* ========================= responsive ========================= */
@media (max-width: 1100px) {
  .budget-layout { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto;
    flex-direction: row; align-items: center; border-right: 0; border-top: 1px solid var(--border);
    z-index: 50; padding-top: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; padding: 6px 4px; }
  .nav a { flex-direction: column; gap: 3px; font-size: 10.5px; padding: 6px 4px; flex: 1 1 0; min-width: 0; text-align: center; }
  .nav a span.nav-text { font-size: 10px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .nav-badge { position: absolute; margin: 0; transform: translate(14px, -6px); }
  .main { padding-bottom: 66px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .bgroup-cols span { width: 78px; }
  .bline-cell { width: 78px; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .ltb-note { display: none; }
  /* Three money columns leave nothing for the category name on a phone. Planned and Left are
     what you act on; Spent is still a tap away on the transactions screen. */
  .col-spent { display: none; }
  .bgroup-cols span { width: 88px; }
  .bline-cell { width: 88px; }
}
