:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-hover: #256abf;
  --accent-soft: #cde2fb;
  --tint: #e3eefb; --tint-ink: #1c5cab;   /* icon tiles */
  --bar: #2a78d6;
  --bar-hl: #1c5cab;
  --good: #006300;
  --critical: #d03b3b;
  --caution: #c98500;   /* budget nearly used */
  --warn-bg: #fff4dc;
  /* Card colours: fixed categorical order (card 1 = blue, card 2 = orange…); "No card" is neutral gray. */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --series-none: #c3c2b7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-hover: #5598e7;
    --accent-soft: #184f95;
    --tint: #16304f; --tint-ink: #86b6ef;
    --bar: #3987e5;
    --bar-hl: #86b6ef;
    --good: #0ca30c;
    --caution: #eda100;
    --warn-bg: #3a2f12;
    --shadow: none;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --series-none: #52514e;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #242422; --ink: #fff; --ink-2: #c3c2b7;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,.10); --accent: #3987e5; --accent-hover: #5598e7;
  --accent-soft: #184f95; --tint: #16304f; --tint-ink: #86b6ef; --bar: #3987e5; --bar-hl: #86b6ef; --good: #0ca30c; --caution: #eda100; --warn-bg: #3a2f12; --shadow: none;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --series-none: #52514e;
}

* { box-sizing: border-box; }
/* Icons (Phosphor, inline SVG): sized to the text around them and drawn in its colour. */
.i { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.tile-value .i { color: var(--tint-ink); }
.sync-badge .i { width: 16px; height: 16px; vertical-align: 0; }
.icon-btn .i { width: 18px; height: 18px; vertical-align: 0; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h3 { font-size: 15px; font-weight: 600; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pad { padding: 16px; }
.strong { font-weight: 600; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top)); background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; }
.nav { display: none; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 999px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); }

.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--ink-2); text-decoration: none; padding: 4px 6px; border-radius: 10px; min-width: 56px; }
.bottomnav a span { display: grid; place-items: center; height: 24px; }
.bottomnav a .i { width: 22px; height: 22px; }
.bottomnav a b { font-weight: inherit; white-space: nowrap; }   /* the label (a <b> so it can be translated) */
.bottomnav a[aria-current="page"] { color: var(--accent); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 16px; outline: none; }

/* FAB */
.fab { position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 11; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600; padding: 14px 18px; box-shadow: 0 6px 20px rgba(42, 120, 214, .35); cursor: pointer; }
.fab span:first-child { display: grid; place-items: center; }
.fab .i { width: 22px; height: 22px; }
.fab-text { display: none; }
.fab:hover { background: var(--accent-hover); }

@media (min-width: 820px) {
  body { padding-bottom: 32px; }
  .nav { display: flex; }
  .bottomnav { display: none; }
  .fab { bottom: 24px; right: 24px; }
  .fab-text { display: inline; }
  main { padding: 24px; }
}

/* Layout */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; flex-wrap: wrap; }
.view-title { font-size: 24px; font-weight: 700; }
.lead { color: var(--ink-2); margin: -6px 0 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card p { margin: 8px 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.hint { font-size: 12px; color: var(--muted); }
.grid2 { display: grid; gap: 14px; }
.grid2 .card { margin: 0; }
.grid2 { margin-bottom: 14px; }
@media (min-width: 820px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.row { display: flex; align-items: center; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.end { justify-content: flex-end; margin-top: 14px; }
.spacer { flex: 1; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (min-width: 820px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
@media (min-width: 820px) { .tiles.three { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tiles.small .tile { background: var(--surface-2); box-shadow: none; border: 0; }
.tile-label { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.tile-value { font-size: clamp(19px, 5vw, 26px); font-weight: 700; margin: 4px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-sub { font-size: 12px; color: var(--muted); }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 9px 16px; border-radius: 10px; font-weight: 500; cursor: pointer; min-height: 40px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.more { width: 100%; margin-top: 8px; }
.link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-decoration: underline; }
select, input[type="search"], input[type="number"], input[type="date"], .field input { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; min-height: 40px; max-width: 100%; }
.select-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type="search"] { flex: 1 1 220px; }
.filters select { flex: 1 1 120px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.summary { font-size: 14px; color: var(--ink-2); margin: 0 4px 10px; }

/* Charts */
.chart-box { width: 100%; min-height: 220px; }
.chart { display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis-base { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--bar); transition: fill .12s; }
.chart .bar-hl, .chart .bar-hover { fill: var(--bar-hl); }
.chart .hit { fill: transparent; outline: none; }
.chart .hit:focus-visible { stroke: var(--accent); stroke-width: 2; }
.chart-tip { position: absolute; z-index: 50; display: none; pointer-events: none; background: var(--ink); color: var(--surface); padding: 7px 10px; border-radius: 8px; font-size: 13px; line-height: 1.35; box-shadow: 0 4px 16px rgba(0,0,0,.2); white-space: nowrap; }

.rank { display: flex; flex-direction: column; gap: 2px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) 9.6em; align-items: center; gap: 10px; padding: 7px 6px; border: 0; background: none; border-radius: 8px; text-align: left; cursor: default; width: 100%; }
button.rank-row { cursor: pointer; }
button.rank-row:hover { background: var(--surface-2); }
.rank-label { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-icon { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 8px; border-radius: 7px; background: var(--tint); color: var(--tint-ink); vertical-align: middle; }
.rank-icon .i { width: 16px; height: 16px; vertical-align: 0; }
.rank-track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.rank-bar { display: block; height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; }
.rank-value { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.rank-value small { display: inline-block; min-width: 42px; margin-left: 6px; color: var(--muted); font-weight: 400; font-size: 12px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
thead th { color: var(--ink-2); font-weight: 600; font-size: 12px; }
tbody th { font-weight: 500; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.hl, th.hl { background: color-mix(in srgb, var(--accent) 9%, transparent); }
tfoot th, tfoot td { font-weight: 700; border-bottom: 0; }
table.files { margin-top: 12px; }

/* Lists */
.list { padding: 6px; }
.day { font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 10px 4px; text-transform: uppercase; letter-spacing: .03em; }
.tx { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border: 0; background: none; border-radius: 10px; text-align: left; cursor: pointer; }
.tx:hover { background: var(--surface-2); }
.tx-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; background: var(--tint); color: var(--tint-ink); border-radius: 10px; }
.tx-icon .i { width: 20px; height: 20px; vertical-align: 0; }
.tx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tx-merchant { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-amt.pos { color: var(--good); }

.merchant { display: flex; align-items: center; gap: 12px; padding: 10px; border-bottom: 1px solid var(--grid); flex-wrap: wrap; }
.merchant:last-child { border-bottom: 0; }
.m-main { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; }
.m-name { font-weight: 500; }
.m-meta { font-size: 12px; color: var(--muted); }
.merchant select { flex: 0 1 220px; }

.notice { background: var(--warn-bg); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.notice.ok { background: color-mix(in srgb, var(--good) 12%, transparent); }

/* Import */
.drop { display: flex; align-items: center; justify-content: center; border: 2px dashed var(--axis); border-radius: 12px; padding: 28px 16px; margin-top: 12px; cursor: pointer; text-align: center; }
.drop.over, .drop:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.issues { margin-top: 12px; font-size: 13px; }
.issues summary { cursor: pointer; font-weight: 500; }
.issues ul { max-height: 260px; overflow: auto; padding-left: 18px; }
.issues li.warn::marker { color: #c98500; }
.issues li.error { color: var(--critical); }

.empty { text-align: center; padding: 36px 20px; }
.empty .row { justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.danger h3 { color: var(--critical); }

/* Dialog */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(460px, calc(100vw - 24px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
dialog h2 { font-size: 19px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); font-weight: 500; flex: 1; min-width: 0; }
.field input, .field select { color: var(--ink); font-size: 16px; width: 100%; }
.field-row { display: flex; gap: 10px; }
.seg { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg label { flex: 1; text-align: center; padding: 7px; border-radius: 8px; cursor: pointer; font-weight: 500; font-size: 14px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--surface); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); }
[hidden] { display: none !important; }

/* Sync & privacy */
.top-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.install-btn { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.install-btn .badge-text { display: inline; }
.sync-badge { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.sync-badge.warn { background: var(--warn-bg); color: var(--ink); }
.sync-badge.icon-only { padding: 6px 9px; }
.sync-badge.icon-only .i { width: 18px; height: 18px; vertical-align: 0; }
.sync-badge.on { background: var(--tint); color: var(--tint-ink); border-color: transparent; }
/* "Hide amounts" eye button, next to the Overview title */
.title-row { display: flex; align-items: center; gap: 10px; }
.hide-btn { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink-2); cursor: pointer; padding: 0; }
.hide-btn:hover { background: var(--surface-2); }
.hide-btn .i { width: 20px; height: 20px; vertical-align: 0; }
.hide-btn.on { background: var(--tint); color: var(--tint-ink); border-color: transparent; }
.badge-text { white-space: nowrap; }
@media (max-width: 420px) { .badge-text { display: none; } }
.sync-msg { font-size: 14px; }
.sync-msg.warn { background: var(--warn-bg); padding: 8px 12px; border-radius: 10px; }
details.sub { margin-top: 14px; border-top: 1px solid var(--grid); padding-top: 10px; }
details.sub summary { cursor: pointer; color: var(--ink-2); font-size: 14px; }
.promises { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 12px; }
.promises li { display: flex; gap: 12px; align-items: flex-start; }
.promises li > span { flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--tint); color: var(--tint-ink); }
.promises li > span .i { width: 20px; height: 20px; vertical-align: 0; }
@media (min-width: 820px) { .promises { grid-template-columns: 1fr 1fr; } }
.prose h3 { margin-top: 18px; }
.prose h3:first-child { margin-top: 0; }
.prose ul { padding-left: 20px; }
/* Cards */
.toolbar-controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.toolbar-controls select { max-width: 200px; }
.card-list { display: flex; flex-direction: column; margin: 4px 0 12px; }
.card-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--grid); }
.card-row:last-child { border-bottom: 0; }
.card-chip { width: 36px; height: 36px; flex: none; display: grid; place-items: center; background: var(--surface-2); border-radius: 10px; font-size: 18px; }
.notice.assign .row { margin-top: 8px; }
.assign-wrap { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--grid); }
.assign-wrap h4 { margin: 0 0 8px; font-size: 14px; }
.assign-wrap .notice { margin: 0 0 8px; }
.assign-groups { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.assign-group { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.assign-group.sub { background: transparent; border: 1px solid var(--grid); margin-top: 8px; }
.assign-group .m-main { flex: 1 1 220px; }
.assign-group .m-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0 4px; }
.assign-group select { flex: 0 1 220px; }
.assign-groups details.sub { margin: -4px 0 4px 14px; border-top: 0; padding-top: 0; }
/* Card colour key: a swatch next to text in normal ink (identity is never colour alone). */
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; vertical-align: baseline; margin-right: 6px; }
.tx-meta .swatch { width: 8px; height: 8px; margin-right: 4px; }
.card-chip .swatch { width: 14px; height: 14px; margin: 0; border-radius: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 10px; padding: 0; list-style: none; font-size: 13px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; }
.legend b { color: var(--ink); font-weight: 600; margin-left: 6px; font-variant-numeric: tabular-nums; }
.chart .seg-bar { transition: opacity .12s; }
.chart .bar-hover-group .seg-bar { opacity: .8; }
.chart-tip .swatch { width: 8px; height: 8px; margin-right: 5px; }
.card-pick { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--grid); }
.card-pick .field { flex: 1 1 240px; }
/* Import review */
.file-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.file-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; padding: 12px; background: var(--surface-2); border-radius: 12px; }
.file-main { flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
.file-card { flex: 0 1 240px; }
.file-add { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
.small-btn { min-height: 32px; padding: 4px 10px; font-size: 13px; background: var(--surface); border-color: var(--border); }
details.review { margin-top: 12px; }
details.review summary { cursor: pointer; font-weight: 600; font-size: 14px; padding: 6px 0; }
.review-table td { vertical-align: top; white-space: normal; }
.review-table td.nowrap, .nowrap { white-space: nowrap; }
.review-table tr.excluded td { opacity: .45; }
.review-table td.pos { color: var(--good); }
.review-table input[type="checkbox"] { width: 18px; height: 18px; }
.kind { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); white-space: nowrap; }
.kind-refund { color: var(--good); }
.kind-payment, .kind-deposit { color: var(--muted); }
.ios-tip { display: flex; align-items: flex-start; gap: 8px; }
.ios-tip > div { flex: 1; }
.ios-tip .btn { min-height: 32px; padding: 4px 10px; }
.privacy-note { font-size: 13px; color: var(--ink-2); background: var(--surface-2); padding: 8px 12px; border-radius: 10px; }
.error-text { color: var(--critical); font-size: 13px; min-height: 1em; margin: 0; }
code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

.toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 820px) { .toast { bottom: 32px; } }

/* Welcome screen (first use): hide the app's menus until the terms are accepted */
body.needs-welcome .nav, body.needs-welcome .bottomnav, body.needs-welcome .fab, body.needs-welcome .top-right { display: none; }
body.needs-welcome { padding-bottom: 24px; }
.welcome { max-width: 640px; margin: 0 auto; }
.welcome > img { display: block; border-radius: 16px; margin-bottom: 12px; }
.welcome h2 { font-size: 22px; margin-bottom: 6px; }
.welcome h3 { margin-top: 16px; }
.welcome .prose ul { padding-left: 20px; }
.btn.big { width: 100%; justify-content: center; padding: 12px 18px; font-size: 16px; margin-top: 8px; }
.legal { max-width: 760px; }
.legal li { margin-bottom: 4px; }

/* App lock */
body.is-locked > header, body.is-locked > main, body.is-locked > nav, body.is-locked > .fab { visibility: hidden; }
.lock-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--page); padding: 24px 16px; }
.lock-box { width: min(340px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.lock-box img { border-radius: 14px; }
.lock-box input { width: 100%; font-size: 24px; letter-spacing: .4em; text-align: center; padding: 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 12px; min-height: 52px; }
.lock-box input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.lock-box .btn.primary, .lock-box [data-bio] { width: 100%; justify-content: center; }
.lock-box [data-bio] .i { width: 20px; height: 20px; }
.lock-forgot { text-align: left; background: var(--surface-2); border-radius: 12px; padding: 12px 14px; font-size: 14px; }
.lock-forgot p { margin: 0 0 8px; }
.bio-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 4px 0 6px; font-size: 14px; }
.bio-row span { flex: 1 1 220px; }
.field.inline { flex-direction: row; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.field.inline select { width: auto; flex: 1 1 200px; }

/* Receipt scanning (Add expense) */
.scan-box { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.scan-box p { margin: 6px 0 0; }
.scan-box .btn .i { width: 18px; height: 18px; }
.scan-status { margin-top: 8px; }
.scan-status p { margin: 4px 0 0; }
.scan-status.ok p .i { color: var(--good); }
.scan-status.warn { background: var(--warn-bg); border-radius: 10px; padding: 8px 10px; }
.scan-remember { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; color: var(--ink-2); cursor: pointer; }
.scan-remember input { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.scan-bar { height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.scan-bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
/* Working but no measure yet: a sliding bar, so it never looks frozen. */
.scan-status.busy .scan-bar span { width: 35%; transition: none; animation: scan-slide 1.1s ease-in-out infinite; }
@keyframes scan-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) { .scan-status.busy .scan-bar span { animation-duration: 3s; } }
/* While a receipt is being read, the fields below are dimmed and can't be edited. */
form.scanning .field, form.scanning button[type="submit"] { opacity: .45; pointer-events: none; transition: opacity .2s; }

/* Categories screen: tabs, the list, the icon picker */
.seg.tabs { margin-bottom: 14px; max-width: 420px; }
.cat-list { display: flex; flex-direction: column; margin-top: 10px; }
.cat-row { display: flex; align-items: center; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--grid); }
.cat-row:last-child { border-bottom: 0; }
.cat-row .btn .i { width: 16px; height: 16px; }
.icon-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.icon-field legend { padding: 0; margin-bottom: 4px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; max-height: 196px; overflow-y: auto; padding: 2px; }
.icon-choice { position: relative; display: grid; place-items: center; height: 40px; border-radius: 10px; color: var(--ink-2); cursor: pointer; border: 1px solid transparent; }
.icon-choice:hover { background: var(--surface-2); }
.icon-field .icon-choice input { position: absolute; inset: 0; width: 1px; height: 1px; min-height: 0; opacity: 0; pointer-events: none; }
.icon-choice .i { width: 22px; height: 22px; }
.icon-choice:has(input:checked) { background: var(--tint); color: var(--tint-ink); border-color: var(--tint-ink); }
.icon-choice:has(input:focus-visible) { outline: 2px solid var(--accent); }
.remove-box { background: color-mix(in srgb, var(--critical) 8%, transparent); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.remove-box p { margin: 0; }

/* Budgets */
.budget-list { display: flex; flex-direction: column; max-height: 55vh; overflow-y: auto; margin: 0 -4px; padding: 0 4px; }
.budget-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--grid); cursor: text; }
.budget-row:last-child { border-bottom: 0; }
.budget-row .m-main { flex: 1 1 auto; }
.budget-input { display: flex; align-items: center; gap: 4px; flex: none; color: var(--ink-2); font-size: 14px; }
.budget-input input { width: 96px; text-align: right; font-size: 16px; }
.budgets { display: flex; flex-direction: column; gap: 4px; }
.budget { display: flex; flex-direction: column; gap: 5px; width: 100%; padding: 8px 6px; border: 0; background: none; border-radius: 8px; text-align: left; cursor: pointer; }
.budget:hover { background: var(--surface-2); }
.budget-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; }
.budget-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget-name .i { color: var(--tint-ink); }
.budget-amt { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.budget-amt b { color: var(--ink); }
.budget-track { position: relative; display: block; height: 10px; background: var(--surface-2); border-radius: 5px; }
.budget-fill { display: block; height: 100%; border-radius: 5px; background: var(--bar); }
.budget.near .budget-fill { background: var(--caution); }
.budget.over .budget-fill { background: var(--critical); }
.budget-pace { position: absolute; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--ink-2); border-radius: 1px; }
.budget-sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.budget.over .budget-sub { color: var(--critical); font-weight: 600; }
.budget-key { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: 10px 0 0 !important; }
.budget-pace-key { display: inline-block; width: 2px; height: 14px; background: var(--ink-2); border-radius: 1px; }
.budget-tip { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px 10px 16px; }
.budget-tip > .i { color: var(--tint-ink); width: 20px; height: 20px; }
.budget-tip span { flex: 1 1 200px; font-size: 14px; color: var(--ink-2); }
/* Settings: one tappable row per section, opens to show its options */
.settings { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.settings .card.setting { margin: 0; padding: 0; }
.setting > summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; border-radius: var(--radius); }
.setting > summary::-webkit-details-marker { display: none; }
.setting > summary:hover { background: var(--surface-2); }
.setting > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.setting > summary .m-main { flex: 1 1 auto; }
.setting > summary .m-name { font-size: 15px; }
.setting-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.setting-status.warn { color: var(--critical); font-weight: 600; }
.setting .chev { display: grid; place-items: center; color: var(--muted); transition: transform .15s; }
.setting .chev .i { width: 18px; height: 18px; }
.setting[open] .chev { transform: rotate(180deg); }
.setting[open] > summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.setting-body { padding: 4px 16px 16px; border-top: 1px solid var(--grid); }
.setting-body > p:first-child, .setting-body > div > p:first-child { margin-top: 12px; }
.setting.danger > summary .m-name { color: var(--critical); }
.setting.danger .tx-icon { background: color-mix(in srgb, var(--critical) 12%, transparent); color: var(--critical); }
.app-version { text-align: center; margin: 4px 0 20px; }
@media (prefers-reduced-motion: reduce) { .setting .chev { transition: none; } }
/* Ranked lists on phones: name and amount on one line, the bar underneath, so names aren't cut to "Gr…". */
@media (max-width: 560px) {
  .rank-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label value" "track track"; row-gap: 5px; padding: 8px 6px; }
  .rank-label { grid-area: label; }
  .rank-value { grid-area: value; }
  .rank-track { grid-area: track; }
  .rank-row:has(.rank-icon) .rank-track { margin-left: 34px; }
}
/* Settings → Support SpendVault (tips) */
.notice.tip-note { display: flex; gap: 10px; align-items: flex-start; background: var(--tint); color: var(--ink); margin: 10px 0; }
.notice.tip-note > .i { color: var(--tint-ink); width: 20px; height: 20px; flex: none; margin-top: 1px; }
.tip-box { margin: 10px 0; }
.tip-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.tip-btn { flex: 1 1 90px; font-weight: 600; }
.tip-btn .i { color: var(--critical); width: 16px; height: 16px; }
.tip-thanks { margin: 10px 0 0 !important; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--good) 12%, transparent); font-size: 14px; }
.tip-thanks .i { color: var(--critical); }.assign-groups details.sub.done { margin: 4px 0 0; }
.assign-groups details.sub.done > .assign-groups { margin-top: 8px; }
.assign-groups details.sub.year { margin: 8px 0 0 4px; }
.assign-groups details.sub.year summary { font-size: 13px; }
