/* Colors meet WCAG AA: text (--text, --text-2, --muted, and --accent, --neg, --pos and --warn used as text) at least
   4.5:1 on --bg, --surface and --surface-2, and on its own -soft color; --control-border 3:1 against them. Anything
   filled with a color (a primary button, a count badge, an error message) takes it from its -fill token and its text
   from the matching --on- token: white on the darker light-theme colors, near-black on the lighter dark-theme ones. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --control-border: #858c99; /* the edge of a text box or menu, which is all that shows where it is */
  --text: #1b1f27;
  --text-2: #4b5363;
  --muted: #636b79;
  --accent: #2465d2;
  --accent-soft: #e6eefc;
  --accent-fill: #2465d2;
  --on-accent: #ffffff;
  --pos: #1c7c4a;
  --neg: #c2362f;
  --neg-fill: #c2362f;
  --on-neg: #ffffff;
  --warn: #9a6200;
  --warn-fill: #9a6200;
  --on-warn: #ffffff;
  --warn-soft: #fdf3dd;
  --neg-soft: #fbe9e7;
  --pos-soft: #e3f4ea;
  --grid: #eceef2;
  --series-1: #2a78d6; /* bank */
  --series-2: #eb6834; /* budgeted */
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}
/* Dark: what the system asks for, unless this device chose light; or always, if it chose dark (data-theme, set by
   the script in App.razor and by app.js from Accounts › Settings). The two blocks must stay the same. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12151b;
    --surface: #1a1e26;
    --surface-2: #222733;
    --border: #2d3340;
    --control-border: #6a7281;
    --text: #e8eaef;
    --text-2: #b4bac6;
    --muted: #8e96a3;
    --accent: #6b9bf0;
    --accent-soft: #1f2d48;
    --accent-fill: #6b9bf0;
    --on-accent: #0f1724;
    --pos: #4cc282;
    --neg: #f07a72;
    --neg-fill: #f07a72;
    --on-neg: #1a0e0d;
    --warn: #e0ac4a;
    --warn-fill: #e0ac4a;
    --on-warn: #1d1404;
    --warn-soft: #3a2f17;
    --neg-soft: #3d201e;
    --pos-soft: #183324;
    --grid: #262b36;
    --series-1: #3987e5;
    --series-2: #d95926;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12151b;
  --surface: #1a1e26;
  --surface-2: #222733;
  --border: #2d3340;
  --control-border: #6a7281;
  --text: #e8eaef;
  --text-2: #b4bac6;
  --muted: #8e96a3;
  --accent: #6b9bf0;
  --accent-soft: #1f2d48;
  --accent-fill: #6b9bf0;
  --on-accent: #0f1724;
  --pos: #4cc282;
  --neg: #f07a72;
  --neg-fill: #f07a72;
  --on-neg: #1a0e0d;
  --warn: #e0ac4a;
  --warn-fill: #e0ac4a;
  --on-warn: #1d1404;
  --warn-soft: #3a2f17;
  --neg-soft: #3d201e;
  --pos-soft: #183324;
  --grid: #262b36;
  --series-1: #3987e5;
  --series-2: #d95926;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 700; }
h1:focus { outline: none; }
a { color: var(--accent); }
p { margin: 0 0 8px; }
code { font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; border: 0 !important; }

/* ---------- layout ---------- */
/* The sidebar is .sidebar, not .nav: the account pages' own Manage menu is a .nav (see "account pages" below). */
/* minmax(0, …): a wide table scrolls inside its card instead of widening the page. */
.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; padding-top: max(18px, env(safe-area-inset-top)); display: flex; flex-direction: column; flex-wrap: nowrap; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
/* Which budget this is (NavMenu): a picker with several, the family group's name with one. */
.budget-switch { display: flex; flex-direction: column; gap: 2px; margin: -8px 10px 14px; font-size: 13px; }
.budget-switch > span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.budget-switch select { width: 100%; }
.sheet .budget-switch { margin: 8px 12px; }
/* "Lee added you to …" (MainLayout). */
.added-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 16px; }
.added-banner > span { flex: 1 1 240px; }
.sidebar a { color: var(--text-2); text-decoration: none; padding: 8px 10px; border-radius: 8px; display: flex; align-items: center; gap: 10px; }
.sidebar a:hover { background: var(--surface-2); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar a .count { margin-left: auto; }
.nav-spacer { flex: 1; }
.sidebar a.nav-user { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.nav-logout { margin: 0; padding: 0 4px; }
.icon { width: 18px; height: 18px; flex: none; }
.count { background: var(--neg-fill); color: var(--on-neg); font-size: 11px; border-radius: 10px; padding: 0 7px; font-weight: 600; }
/* Transactions still pending at the bank (NavMenu): quieter, beside the count to link. */
.count.pending { background: var(--surface); color: var(--text-2); border: 1px dashed currentColor; padding: 0 6px; font-weight: 500; }
.sidebar a .count + .count { margin-left: -4px; }
main { padding: 24px 28px 60px; max-width: 1200px; width: 100%; outline: none; padding-bottom: max(60px, env(safe-area-inset-bottom)); }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { margin: 0; }
/* Signed out (sign in, register, password reset): the page centred under the brand, on one card (see .acct). */
.auth-main { max-width: 480px; margin: 0 auto; padding: max(48px, env(safe-area-inset-top)) 16px 48px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; font-weight: 700; font-size: 22px; }
.auth-brand img { border-radius: 8px; }

/* Phone-only pieces (NavMenu.razor): the bottom tab bar, with the add button in its middle, and the More sheet. */
.tabbar { display: none; }
.sheet[popover] { position: fixed; inset: auto 0 0; width: 100%; max-width: none; margin: 0; padding: 8px 12px calc(12px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0; background: var(--surface); color: var(--text); box-shadow: 0 -8px 30px rgba(0, 0, 0, .25); }
.sheet::backdrop { background: rgba(10, 14, 22, .45); }
.sheet form { margin: 0; }
.sheet a, .sheet .sheet-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 48px; padding: 10px 12px; border: 0; border-radius: 10px;
  background: none; color: var(--text); font: inherit; font-size: 15px; text-align: left; text-decoration: none; white-space: normal; }
.sheet a:hover, .sheet .sheet-item:hover { background: var(--surface-2); }
.sheet a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sheet .icon { width: 22px; height: 22px; }
.sheet .sheet-close { width: 100%; margin-top: 6px; min-height: 44px; }
/* "You were adding a transaction…" (NavMenu.razor, after a reload): bottom left of the page, clear of the toasts. */
.draft-callout { position: fixed; z-index: 35; left: 226px; bottom: 16px; max-width: min(460px, calc(100vw - 242px)); display: flex; flex-wrap: wrap;
  align-items: center; gap: 6px 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, .18); }
.draft-callout > span:first-child { flex: 1 1 200px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  /* Room at the bottom for the tab bar. */
  main { padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: calc(80px + env(safe-area-inset-bottom)); }

  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; inset: auto 0 0; z-index: 30;
    padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; padding: 6px 2px;
    border: 0; border-radius: 0; background: none; color: var(--text-2); font: inherit; font-size: 11px; line-height: 1.2; text-decoration: none; white-space: nowrap; }
  .tabbar a > span:last-child, .tabbar button > span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tabbar a:hover, .tabbar button:hover { background: none; color: var(--text); }
  .tabbar .active, .tabbar .active:hover { color: var(--accent); font-weight: 600; }
  .tabbar .icon { width: 24px; height: 24px; }
  .tab-icon { position: relative; display: inline-flex; }
  .tab-icon .count { position: absolute; top: -5px; left: 15px; padding: 0 5px; font-size: 10px; line-height: 16px; }
  .tab-icon .count.pending { left: auto; right: 15px; padding: 0 4px; line-height: 14px; } /* the other side of the icon */

  /* The add button, in the middle of the bar: the two tabs before it share as much room as the three after it, so it's
     centred, and "Transactions" gets the width it needs. */
  .tabbar.with-add { grid-template-columns: 3fr 3fr 64px 2fr 2fr 2fr; }
  .tabbar a.tab-add { padding: 4px 0; }
  .tab-add-btn { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent-fill); color: var(--on-accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .22); }
  .tabbar .tab-add-btn .icon { width: 26px; height: 26px; stroke-width: 2.2; }
  .tabbar a.tab-add:hover .tab-add-btn { filter: brightness(1.08); }
  .tabbar a.tab-add:focus-visible { outline: none; }
  .tabbar a.tab-add:focus-visible .tab-add-btn { outline: 3px solid var(--text); outline-offset: 2px; }

  /* At the top on phones: the bottom, above the tab bar, is where messages show. */
  .draft-callout { left: 16px; right: 16px; top: max(12px, env(safe-area-inset-top)); bottom: auto; max-width: none; }
  .draft-callout button { min-height: 36px; }
}
/* Shown only where the layout needs them, e.g. a Sort menu standing in for hidden column headers. */
@media (min-width: 761px) { .phone-only { display: none !important; } }
/* And the other way round, e.g. buttons a phone has in a ⋯ menu or its tab bar instead. */
@media (max-width: 760px) { .wide-only { display: none !important; } }

/* ---------- building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.ell { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; margin: 2px 0; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
/* Phones: the summary tiles two by two, a little tighter, so they take half the first screen rather than all of it and
   the lists that need doing something come up. */
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .stats > .card.stat { padding: 10px 12px; }
  .stat .label { font-size: 11px; }
  .stat .value { font-size: 20px; }
}
/* A link that reads as the text around it (a name in a list, a total in a report), dotted underneath so it still shows. */
a.text-link { color: inherit; text-decoration: underline dotted color-mix(in srgb, currentColor 50%, transparent); text-underline-offset: 3px; }
a.text-link:hover { color: var(--accent); text-decoration-style: solid; text-decoration-color: currentColor; }

button, .btn-bc { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block; line-height: 1.45; }
button:hover, .btn-bc:hover { background: var(--surface-2); }
button.primary, .btn-bc.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
button.primary:hover, .btn-bc.primary:hover { filter: brightness(1.08); background: var(--accent-fill); }
button.danger { color: var(--neg); }
button.link { border: 0; background: none; color: var(--accent); padding: 2px 4px; }
button.sm { padding: 3px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
/* Touch screens: small controls get at least 40px of height to tap, without moving anything. An invisible ::after
   reaches above and below each one, centred on it. One that clips what overflows it (a long name cut short) would clip
   that too, so its padding grows instead, with an equal negative margin taking the room back. A mouse sees no change. */
@media (pointer: coarse) {
  :is(button.link, button.sm, button.sugg, .chip-x, .menu-btn, .toast-action, .toast-close, details.numbers > summary, .acct .btn-link) { position: relative; }
  :is(button.link, button.sm, button.sugg, .chip-x, .menu-btn, .toast-action, .toast-close, details.numbers > summary, .acct .btn-link)::after {
    content: ""; position: absolute; inset: 50% 0 auto; height: max(100%, 40px); transform: translateY(-50%);
  }
  .occ button.link.ell { padding-top: 12px; padding-bottom: 12px; margin-top: -12px; margin-bottom: -12px; }
  .txn-table td.t-sel label { padding: 12px; margin: -12px; }
  .bulk-bar > label { padding-top: 10px; padding-bottom: 10px; margin-top: -10px; margin-bottom: -10px; } /* Select all */
  /* What reaches past a table's last row mustn't let its box scroll up and down a few pixels. A budget's history
     scrolls up and down anyway, so its last line's buttons keep their size there. */
  .table-wrap { overflow-y: hidden; }
  .ledger :is(button.link, button.sm)::after { content: none; }
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.spacer { flex: 1; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--control-border); border-radius: 7px; padding: 6px 8px; min-width: 0; }
input[type=checkbox], input[type=radio] { padding: 0; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, .btn-bc:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: grid; gap: 4px; font-size: 12px; color: var(--text-2); }
label.field > span { font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin: 0; }
.warn-text { color: var(--warn); }
.field-block { display: grid; gap: 8px; }
button[aria-pressed=true] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* A list of checkbox rows to pick from (e.g. which bank accounts to add). */
fieldset.pick-list { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 6px; }
fieldset.pick-list legend { padding: 0; margin-bottom: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
label.pick { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
label.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
label.pick .pick-name { min-width: 0; overflow-wrap: anywhere; }
label.pick .pick-name > .small { display: block; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th.num { text-align: right; }
td { padding: 8px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
tr.clickable:has(:focus-visible) td { background: var(--surface-2); }

/* Transactions on phones: each row stacks into an entry instead of scrolling sideways.
     [x] Payee ........ amount
         (o) date · account  ⋯
         [linked-to chips] */
@media (max-width: 760px) {
  .txn-table, .txn-table tbody { display: block; }
  .txn-table thead { display: none; }
  .txn-table tr { display: grid; grid-template-columns: auto auto auto minmax(0, 1fr) auto;
    grid-template-areas: "sel payee payee payee amount" "sel origin date acct more" "sel link link link link";
    column-gap: 6px; row-gap: 2px; padding: 10px 8px; border-bottom: 1px solid var(--grid); border-radius: 8px; }
  .txn-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .txn-table tr.clickable:hover td, .txn-table tr.clickable:has(:focus-visible) td { background: none; }
  .txn-table tr.clickable:hover, .txn-table tr.clickable:has(:focus-visible) { background: var(--surface-2); }
  .txn-table .t-payee { grid-area: payee; font-weight: 600; overflow-wrap: anywhere; }
  .txn-table .t-payee .small { font-weight: 400; }
  .txn-table .t-amt { grid-area: amount; font-weight: 600; }
  .txn-table .t-date { grid-area: date; color: var(--muted); }
  .txn-table .t-acct { grid-area: acct; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .txn-table .t-acct::before { content: "· "; }
  .txn-table .t-link { grid-area: link; margin-top: 4px; }
  /* Its head: the title and its buttons on one line, without the intro (Auto-link and Rules are under ⋯). */
  .txn-head { align-items: center; margin-bottom: 12px; }
  .txn-head h1 { margin: 0; }
  .txn-head .page-intro { display: none; }
}
/* A page's ⋯ for its less-used buttons (MoreMenu.razor). */
.more-btn { min-width: 40px; }
.more-btn[aria-expanded=true] { background: var(--surface-2); }
/* What the list comes to for the budget or bill chosen in Linked to (Transactions.razor). */
.target-total { margin: -4px 0 10px; color: var(--text-2); }
/* The keyboard-reachable control in a clickable row (a link, or a button whose click bubbles up to the row's
   handler). It looks like the row's text; its focus ring and the row highlight show where the keyboard is. */
.row-link { color: inherit; text-decoration: none; border-radius: 3px; }
button.row-link { font: inherit; line-height: inherit; text-align: inherit; white-space: normal; display: inline; background: none; border: 0; padding: 0; }
button.row-link:hover { background: none; }
.table-wrap { overflow-x: auto; }

/* Sortable column headers (SortTh): the whole cell is the button. The arrow is faint until the column is sorted. */
th.sortable { padding: 0; }
.sort-btn { display: flex; align-items: center; gap: 4px; width: 100%; padding: 6px 8px; border: 0; border-radius: 4px; background: none; color: inherit; font: inherit; font-weight: 600; line-height: inherit; text-align: inherit; }
th.num .sort-btn { justify-content: flex-end; }
.sort-btn:hover { background: var(--surface-2); color: var(--text); }
.sort-ind { font-size: 11px; opacity: .35; }
th[aria-sort=ascending], th[aria-sort=descending] { color: var(--text-2); }
th[aria-sort=ascending] .sort-ind, th[aria-sort=descending] .sort-ind { opacity: 1; color: var(--accent); }
.ledger th.sortable .sort-btn { padding: 4px 6px; }
.ledger thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); }

/* The filter row above a list: search first (it takes the spare width), then menus, then the match count. */
.filters { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }

/* FilterBar: a Filter button opening the less-used filters (a dropdown under the row; a bottom sheet on phones),
   and chips under the row for the filters in use. */
.filter-btn { display: inline-flex; align-items: center; gap: 6px; }
.filter-btn.on { border-color: var(--accent); color: var(--accent); }
.filter-btn[aria-expanded=true] { background: var(--accent-soft); }
.filter-n { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent-fill); color: var(--on-accent); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; }
.filter-scrim { position: fixed; inset: 0; z-index: 20; }
.filter-panel { position: absolute; top: calc(100% + 6px); right: 0; z-index: 21; width: min(360px, 100%); display: grid; gap: 12px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); }
.filter-panel:focus { outline: none; }
.filter-panel h2 { margin: 0; font-size: 15px; }
.filter-fields { display: grid; gap: 12px; }
div.field { display: grid; gap: 4px; font-size: 12px; color: var(--text-2); } /* like label.field, for a group of controls */
div.field > span:first-child { font-weight: 600; }
.filter-fields select, .filter-fields input { width: 100%; }
.filter-fields .date-range { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
.filter-foot { display: flex; align-items: center; gap: 8px; }
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -2px 0 10px; }
.chip-x { display: inline-flex; align-items: center; gap: 6px; padding: 2px 6px 2px 10px; border: 1px solid transparent; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; line-height: 1.5; }
.chip-x:hover { border-color: var(--accent); background: var(--accent-soft); }
.chip-x span { font-size: 10px; opacity: .8; }
@media (max-width: 760px) {
  .filter-scrim { z-index: 41; background: rgba(10, 14, 22, .45); }
  .filter-panel { position: fixed; inset: auto 0 0; z-index: 42; width: 100%; max-height: 85vh; max-height: 85dvh; overflow-y: auto;
    padding: 16px 16px max(16px, env(safe-area-inset-bottom)); border-width: 1px 0 0; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .25); }
  .filter-panel h2 { font-size: 16px; }
  .filter-foot button { min-height: 40px; }
  .chip-x { padding: 4px 8px 4px 12px; font-size: 13px; } /* bigger targets for fingers */
}
@media (max-width: 760px) and (prefers-reduced-motion: no-preference) { .filter-panel { animation: sheet-up .22s ease-out; } }
.filters input[type=search] { flex: 1 1 220px; min-width: 160px; }
.date-range { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sort-picker { display: inline-flex; align-items: center; gap: 4px; }
.sort-picker button { min-width: 32px; }
.filter-count { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.ledger-filters { margin: 10px 0 0; }
input.compact, select.compact { padding: 3px 6px; font-size: 13px; }
.ledger-filters input[type=search] { flex-basis: 140px; }
.card-head > h2 { margin: 0; align-self: center; }
.card-head > input[type=search].compact { width: 140px; }

.chip { display: inline-flex; gap: 4px; align-items: center; border-radius: 999px; padding: 1px 9px; font-size: 12px; background: var(--surface-2); color: var(--text-2); margin: 1px 2px 1px 0; white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.neg { background: var(--neg-soft); color: var(--neg); }
.chip.pos { background: var(--pos-soft); color: var(--pos); }
/* Paid, or looks paid, by a payment still pending at the bank: dashed, as pending transactions are (.origin-pending). */
.chip.pending { background: none; border: 1px dashed currentColor; padding: 0 8px; }
button.sugg { border-style: dashed; color: var(--accent); font-size: 12px; padding: 2px 9px; border-radius: 999px; }

.bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: 8px 0 4px; }
.bar > div { height: 100%; background: var(--accent); border-radius: 4px; }
.bar.over > div { background: var(--neg); }
/* Spending pace (PaceBar.razor): a tick where today falls in the period; amber when spending is well past it. */
.bar { position: relative; }
.bar.ahead > div { background: var(--warn); }
.pace-mark { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--text); opacity: .55; }
.big { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
button.big-btn { display: block; border: 0; background: none; padding: 0 4px; margin-left: -4px; line-height: 1.3; color: var(--neg); text-decoration: underline dashed 2px; text-underline-offset: 6px; }
button.big-btn:hover { background: var(--neg-soft); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.rules { list-style: none; padding: 0; margin: 10px 0 0; border-top: 1px solid var(--grid); }
.rules li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.rules li.ended { color: var(--muted); }
.ledger { margin-top: 10px; max-height: 320px; overflow-y: auto; font-size: 13px; }
.ledger td { padding: 4px 6px; }
/* A budget card's spending, linking to the transactions behind it (Budgets.razor): as quiet as the line it's in, with
   a dotted underline to say it goes somewhere. */
a.spent-link { color: var(--text-2); text-decoration: underline dotted; text-underline-offset: 3px; }
a.spent-link:hover { color: var(--accent); text-decoration-style: solid; }
/* Deleted budgets, under the cards (Budgets.razor): a quiet toggle, then each one with Restore. */
.deleted-budgets { margin-top: 20px; }
.deleted-list { list-style: none; padding: 0; margin: 6px 0 0; max-width: 560px; border-top: 1px solid var(--grid); }
.deleted-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.deleted-list li > span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 760px) {
  a.spent-link { padding: 8px 0; } /* the line's text is small: padding widens what a finger can hit, without moving the text */
  .deleted-budgets button { min-height: 40px; }
}

.empty { text-align: center; padding: 48px 16px; }
.empty p { color: var(--text-2); max-width: 560px; margin: 8px auto 18px; }
/* The first-run checklist (SetupChecklist.razor): numbered steps that tick themselves off, under the welcome (EmptyApp)
   or in a card at the top of Overview. */
.setup-card { margin-bottom: 16px; }
.setup-card .card-head h2 { margin: 0; }
.setup-card .card-head p { margin: 2px 0 0; }
.setup-steps { list-style: none; display: grid; gap: 12px; margin: 4px 0 0; padding: 0; text-align: left; }
.empty .setup-steps { max-width: 520px; margin: 20px auto 22px; }
.setup-steps li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: start; }
.setup-mark { display: grid; place-items: center; width: 26px; height: 26px; border: 1.5px solid var(--control-border); border-radius: 50%; color: var(--text-2); font-size: 13px; font-weight: 650; }
.setup-steps li.done .setup-mark { border-color: transparent; color: var(--pos); }
.setup-mark .icon { width: 26px; height: 26px; }
.setup-text { display: grid; gap: 2px; min-width: 0; padding-top: 3px; }
.setup-text > a { font-weight: 600; }
.setup-steps li.done .setup-text > a { color: var(--text-2); font-weight: 400; }
/* Overview's Coming up: budgets as one line under the bills and income, since they hold money rather than fall due. */
.held-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px; border-top: 1px solid var(--border); }
.held-line .small { display: block; }
.error { color: var(--neg); font-size: 13px; margin: 0; }
.callout { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--text-2); }
.callout.warn { background: var(--warn-soft); }

/* ---------- dialogs ---------- */
.modal-backdrop-bc { position: fixed; inset: 0; z-index: 40; background: rgba(10, 14, 22, .45); display: grid; place-items: center; padding: 16px; }
.modal-bc { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); width: min(680px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
.modal-bc:focus { outline: none; } /* holds focus when no field does (touch screens, a click on its text): no ring */
.modal-bc form { display: flex; flex-direction: column; width: 100%; min-height: 0; }
.modal-bc header { padding: 16px 20px 0; }
.modal-bc header h2 { margin: 0; }
.modal-bc .body { padding: 14px 20px; overflow-y: auto; display: grid; gap: 14px; }
.modal-bc footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
/* Closing with changes unsaved: the buttons give way to "Throw away your changes?" (Modal.razor). */
.modal-bc footer.discard-bar { align-items: center; background: var(--neg-soft); border-radius: 0 0 11px 11px; font-weight: 600; }

/* Phones: dialogs rise from the bottom as sheets, full width, with the buttons in thumb reach above the home bar. */
@media (max-width: 760px) {
  .modal-backdrop-bc { place-items: end stretch; padding: max(24px, env(safe-area-inset-top)) 0 0; }
  .modal-bc { width: 100%; max-height: 92vh; max-height: 92dvh; border-width: 1px 0 0; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, .25); }
  .modal-bc header { padding: 16px 16px 0; }
  .modal-bc .body { padding: 14px 16px; }
  .modal-bc footer { padding: 10px 16px max(12px, env(safe-area-inset-bottom)); }
  .modal-bc footer.discard-bar { border-radius: 0; }
  .modal-bc footer button { min-height: 40px; }
}
@media (max-width: 760px) and (prefers-reduced-motion: no-preference) {
  .modal-bc, .sheet:popover-open { animation: sheet-up .22s ease-out; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } }
.alloc-row, .inc-row { display: grid; gap: 8px; align-items: end; padding: 10px; background: var(--surface-2); border-radius: 8px; }
.alloc-row { grid-template-columns: 1fr 120px auto; }
.inc-row { grid-template-columns: 100px 120px 70px 1fr 1fr auto; }
@media (max-width: 640px) { .inc-row { grid-template-columns: 1fr 1fr; } .form-grid { grid-template-columns: 1fr; } }
.cand-list { display: grid; gap: 6px; max-height: 340px; overflow-y: auto; }
.cand { display: grid; grid-template-columns: auto 52px minmax(0, 1.4fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; white-space: nowrap; }
.cand.checked { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- bills & income: collapsible single-line cards in one column ---------- */
.bill-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-items: start; }
.card.bill { padding: 0; }
.bill-head { display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; }
.bill-toggle { flex: 1; min-width: 0; display: grid; grid-template-columns: 12px minmax(0, 1.4fr) auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
  border: 0; background: none; color: var(--text); text-align: left; padding: 8px; border-radius: 8px; white-space: nowrap; }
.bill-toggle > span { overflow: hidden; text-overflow: ellipsis; }
/* Opened from a link (?bill=): scrolled to the top with some room, clear of a phone's status bar. */
.bill-toggle { scroll-margin-top: max(16px, env(safe-area-inset-top)); }
.bill-name { font-weight: 600; }
.bill-acct, .bill-due { color: var(--text-2); font-size: 13px; }
.bill-head.pastdue .bill-toggle, .bill-head.pastdue .bill-toggle span { color: var(--neg); font-weight: 700; }
.chev { color: var(--muted); font-size: 16px; line-height: 1; transition: transform .15s; }
.bill-toggle[aria-expanded="true"] .chev { transform: rotate(90deg); }
.occ-list { border-top: 1px solid var(--border); padding: 2px 14px 8px; }
/* An occurrence's line: date, status chip (room for "Paid · pending"), what paid it, amount, actions. */
.occ { display: grid; grid-template-columns: 70px 104px minmax(0, 1fr) auto 84px; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--grid); white-space: nowrap; font-size: 13px; }
.occ .chip { justify-self: start; }
.occ.skipped > :not(.occ-actions) { opacity: .55; }
.occ .link.ell { display: block; max-width: 100%; text-align: left; padding: 0; }
.occ-actions { display: flex; justify-content: flex-end; align-items: center; gap: 4px; }
.occ.named { grid-template-columns: minmax(0, 1.3fr) 104px minmax(0, 1fr) auto 84px; }
/* A partly paid line has Mark paid beside Link: every line in its list gets the wider actions column, so amounts still
   line up. (Phones put that line's buttons under it instead; see below.) */
@media (min-width: 561px) {
  .occ-list.has-mark-paid .occ { grid-template-columns: 70px 104px minmax(0, 1fr) auto 152px; }
  .occ-list.has-mark-paid .occ.named { grid-template-columns: minmax(0, 1.3fr) 104px minmax(0, 1fr) auto 152px; }
}
.occ-name { overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.occ-today { color: var(--accent); font-weight: 600; padding: 6px 0 2px; border-bottom: 1px solid var(--accent-soft); }
.menu { position: relative; display: inline-block; }
.menu-btn { border: 0; background: none; padding: 2px 8px; color: var(--text-2); }
.menu-btn[aria-expanded="true"] { background: var(--surface-2); }
.menu-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 160px; display: grid; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.menu-pop button { border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: 6px; }
.menu-pop button:hover { background: var(--surface-2); }
.menu-scrim { position: fixed; inset: 0; z-index: 15; }
.menu-pop button:disabled { color: var(--muted); cursor: default; }
.menu-pop button:disabled:hover { background: none; }
.menu-pop hr { border: 0; border-top: 1px solid var(--border); margin: 4px 2px; }
/* A transaction row's right-click menu: where it was opened, kept on screen (Transactions.razor sets left and top). */
.context-menu { position: fixed; right: auto; }

/* Transactions: each row's tick box, and the symbol for where it came from (OriginIcon). */
.txn-table .t-sel, .txn-table .t-origin { width: 1%; padding-right: 0; }
/* Each row's ⋯, opening its menu (for phones, and anyone without a right-click). */
.txn-table .t-more { width: 1%; padding-left: 0; text-align: right; }
.txn-table .t-sel label { display: grid; place-items: center; padding: 6px; margin: -6px; cursor: pointer; }
.txn-table tr.selected td { background: var(--accent-soft); }
.origin { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 999px; border: 1px solid transparent; vertical-align: middle; }
.origin .icon { width: 15px; height: 15px; }
.origin-bank { color: var(--accent); background: var(--accent-soft); }
.origin-pending { color: var(--accent); border-style: dashed; border-color: var(--accent); }
.origin-cleared { color: var(--pos); background: var(--pos-soft); }
.origin-entered { color: var(--text-2); background: var(--surface-2); border-color: var(--border); }
.origin-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 10px 0 0; }
.origin-legend > span { display: inline-flex; align-items: center; gap: 6px; }
/* Transactions still pending at the bank: a group above the rest, under its own heading, set off from them by a
   heavier line. What they're linked or matched to is dashed, like their bank symbol: it's final once they post. */
.txn-table .txn-group th { padding: 12px 8px 6px; font-size: 13px; color: var(--text); }
.txn-group-name { display: inline-flex; align-items: center; gap: 6px; margin-right: 8px; }
.txn-table .txn-group .hint { font-weight: 400; }
.txn-table tbody.txn-pending > tr:last-child > td { border-bottom: 2px solid var(--border); }
.txn-table .chip.pending { border: 1px dashed currentColor; padding: 0 8px; } /* the border takes the place of a pixel of padding */
/* Above the list: tick every row shown (or none), and act on the ticked ones. */
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 0 8px; }
.bulk-bar label { display: inline-flex; align-items: center; gap: 8px; margin-right: 4px; font-size: 13px; cursor: pointer; }
/* Phones (see the stacked rows above): after the rules just above, which it overrides. */
@media (max-width: 760px) {
  .txn-table .t-sel { grid-area: sel; align-self: start; width: auto; }
  .txn-table .t-origin { grid-area: origin; width: auto; }
  .txn-table .t-origin .origin { width: 18px; height: 18px; }
  .txn-table .t-origin .origin .icon { width: 12px; height: 12px; }
  .txn-table .t-more { grid-area: more; justify-self: end; width: auto; }
  /* Bigger to tap than it looks: the padding reaches past the row's line without moving it. */
  .txn-table .row-more { padding: 8px 12px; margin: -8px -8px -8px 0; }
  .txn-table tr.selected { background: var(--accent-soft); }
  .txn-table tr.selected td { background: none; }
  .txn-table tr.txn-group { display: block; padding: 12px 8px 6px; }
  .txn-table tr.txn-group th { display: block; padding: 0; border: 0; }
  .txn-table tbody.txn-pending > tr:last-child { border-bottom: 2px solid var(--border); }
  .txn-table tbody.txn-pending > tr:last-child > td { border-bottom: 0; }
}
/* A transaction that likely paid an open bill, with Link / Not it (LikelyPaid.razor). */
.likely { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; max-width: 100%; font-size: 12px; color: var(--text-2); }
.likely-text { min-width: 0; overflow-wrap: anywhere; }
.likely button.sm { padding: 1px 8px; }
.occ-likely { padding: 2px 0 6px 80px; border-bottom: 1px solid var(--grid); }
/* "Price changes" and "Looks recurring" on Bills & Income. */
.card.found { margin-bottom: 12px; }
.card.found .card-head { flex-wrap: wrap; align-items: baseline; }
.found-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--grid); }
.found-main { min-width: 0; }
.found-main > .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.found-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
/* "Show deleted (n)" at the foot of Bills & Income: quieter than the page's other links, opening a list to restore from. */
.deleted-bills { margin-top: 16px; }
.deleted-bills > button.link { color: var(--text-2); }
.deleted-list { list-style: none; margin: 6px 0 0; padding: 0; border-top: 1px solid var(--grid); }
.deleted-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.deleted-name { min-width: 0; overflow-wrap: anywhere; }
/* Transaction rules (RulesDialog.razor) and "Always do this" when linking (TxnDialog.razor). */
.rule-list { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--grid); }
.rule-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.rule-text { min-width: 0; }
.rule-editor { display: grid; gap: 10px; padding: 12px; background: var(--surface-2); border-radius: 8px; }
.rule-editor h3 { margin: 0; }
.notify-grid { display: grid; grid-template-columns: max-content minmax(0, max-content); gap: 8px 12px; align-items: center; }
@media (max-width: 560px) { .notify-grid { grid-template-columns: 1fr; gap: 4px; } .notify-grid > span:empty { display: none; } }
.make-rule { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }
.make-rule input:not([type=checkbox]) { flex: 1 1 140px; min-width: 0; }
/* The label wraps rather than overflow (a phone's sheet, a long budget name); the checkbox keeps its size. */
.make-rule > label { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.make-rule > label > input { flex: none; }
@media (max-width: 560px) {
  .occ-likely { padding-left: 0; }
  .found-row { grid-template-columns: minmax(0, 1fr) auto; }
  .found-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .found-main > .small { white-space: normal; }
}
@media (max-width: 560px) {
  .bill-toggle { grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 8px; }
  .bill-acct, .occ > .ell { display: none; }
  .occ { grid-template-columns: 62px 70px minmax(0, 1fr) 84px; }
  .occ.named { grid-template-columns: minmax(0, 1fr) 70px auto 84px; }
  /* Short of room: "about" and the header's "of $118.00" go, two-word chips ("Marked paid") take two lines, and a
     partly paid line's buttons go on a line of their own under it. */
  .bill-about, .bill-toggle .bill-left-of { display: none; }
  .occ .chip { white-space: normal; text-align: center; line-height: 1.25; }
  .occ.mark-paid { grid-template-columns: 62px 70px minmax(0, 1fr); }
  .occ.mark-paid.named { grid-template-columns: minmax(0, 1fr) 70px auto; }
  .occ.mark-paid > .occ-actions { grid-column: 1 / -1; }
}

/* ---------- loading placeholders (Skeleton.razor) and progress ---------- */
.skel-wrap { display: grid; gap: 10px; }
.skel-cards { grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 16px; }
.skel-stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 760px) { .skel-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } } /* like .stats */
.skel-card { display: grid; gap: 10px; }
.skel-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--grid); }
.skel { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--grid) 50%, var(--surface-2) 75%); background-size: 200% 100%; }
.skel-big { height: 26px; }
.skel-amt { width: 64px; flex: none; }
@media (prefers-reduced-motion: no-preference) { .skel { animation: skel-shine 1.4s ease-in-out infinite; } }
@keyframes skel-shine { from { background-position: 100% 0; } to { background-position: -100% 0; } }
/* A thin bar along the top of a card while it waits on the bank. */
.progress { height: 3px; margin: -16px -16px 13px; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; background: var(--accent-soft); }
.progress::after { content: ""; display: block; width: 35%; height: 100%; background: var(--accent); }
@media (prefers-reduced-motion: no-preference) { .progress::after { animation: progress-slide 1.1s ease-in-out infinite; } }
@keyframes progress-slide { from { transform: translateX(-100%); } to { transform: translateX(290%); } }

/* ---------- saved views (ViewMenu.razor) and the List / Calendar switch ---------- */
.views-btn { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; }
.views-btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.views-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-panel.start { left: 0; right: auto; }
.view-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.view-list li { display: flex; align-items: center; gap: 4px; border-radius: 8px; }
.view-list li.active { background: var(--accent-soft); }
.view-pick { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.view-list li.active .view-pick { color: var(--accent); font-weight: 600; }
.view-save { display: grid; gap: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.view-save input { width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 0; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed=true] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 760px) {
  .seg button span { display: none; } /* icons only */
  .views-btn { max-width: 160px; }
  .view-pick { min-height: 44px; }
}

/* ---------- Bills & Income calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.cal-head h2 { margin: 0; min-width: 150px; text-align: center; }
.cal-head .sm { display: inline-grid; place-items: center; padding: 3px 6px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; padding: 2px 0 4px; text-transform: uppercase; letter-spacing: .04em; }
.cal-day { display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-height: 96px; min-width: 0; padding: 6px; border: 1px solid var(--grid); border-radius: 8px;
  background: var(--surface); text-align: left; white-space: normal; font-size: 12px; line-height: 1.3; }
.cal-day:hover { background: var(--surface-2); }
.cal-day.out { opacity: .5; }
.cal-day.today .cal-num { background: var(--accent-fill); color: var(--on-accent); }
.cal-day.picked { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-num { align-self: flex-start; min-width: 22px; padding: 1px 6px; border-radius: 11px; font-weight: 600; text-align: center; }
.cal-items { display: grid; gap: 2px; min-width: 0; }
.cal-item { display: flex; justify-content: space-between; gap: 4px; min-width: 0; padding: 1px 4px; border-radius: 4px; background: var(--surface-2); }
.cal-item .cal-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item b { font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-item.income { color: var(--pos); background: var(--pos-soft); }
.cal-item.overdue { color: var(--neg); background: var(--neg-soft); font-weight: 600; }
.cal-item.paid { color: var(--muted); }
.cal-item.pending { color: var(--text-2); background: none; border: 1px dashed var(--muted); padding: 0 3px; }
.cal-item.skipped { color: var(--muted); }
.cal-item.skipped .cal-name { text-decoration: line-through; text-decoration-color: color-mix(in srgb, currentColor 50%, transparent); }
.cal-more { color: var(--muted); font-size: 11px; }
.cal-bal { margin-top: auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; text-align: right; }
.cal-day.low .cal-bal { color: var(--neg); font-weight: 600; }
.bal-short { display: none; }
.cal-legend { margin-top: 10px; }
.cal-key { display: inline-block; width: 10px; height: 10px; margin: 0 4px 0 8px; border-radius: 3px; vertical-align: -1px; background: var(--surface-2); border: 1px solid var(--border); }
.cal-key:first-child { margin-left: 0; }
.cal-key.income { background: var(--pos-soft); border-color: var(--pos); }
.cal-key.overdue { background: var(--neg-soft); border-color: var(--neg); }
.cal-key.paid { opacity: .5; }
.cal-key.pending { background: none; border-style: dashed; border-color: var(--muted); }
.cal-detail { margin-top: 12px; }
.cal-detail h3 { margin-bottom: 6px; }
/* Phones: each day shows its number, a dot per item and a short balance; picking a day lists the items below. */
@media (max-width: 760px) {
  .cal-grid { gap: 2px; }
  .cal-day { min-height: 62px; padding: 4px 3px; align-items: center; }
  .cal-num { align-self: center; padding: 0 4px; min-width: 20px; }
  .cal-items { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
  .cal-item { width: 7px; height: 7px; padding: 0; border-radius: 50%; background: var(--text-2); }
  .cal-item > * { display: none; }
  .cal-item.income { background: var(--pos); }
  .cal-item.overdue { background: var(--neg); }
  .cal-item.paid, .cal-item.skipped { background: var(--muted); opacity: .6; }
  .cal-item.pending { background: none; border: 1.5px solid var(--text-2); padding: 0; } /* a ring */
  .cal-more { display: none; }
  .cal-bal { text-align: center; font-size: 10px; }
  .bal-full { display: none; }
  .bal-short { display: inline; }
}

/* ---------- appearance: the light/dark button and compact tables (Accounts › Settings) ---------- */
/* data-theme-shown on <html> is the theme in effect (App.razor, app.js): show the words and icon for switching away from it. */
:root[data-theme-shown="dark"] .when-light, :root:not([data-theme-shown="dark"]) .when-dark { display: none !important; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 0 0 4px; }
.theme-toggle { display: inline-grid; place-items: center; padding: 4px 6px; border: 0; background: none; color: var(--text-2); }
.theme-toggle:hover { color: var(--text); }
.seg .icon { width: 16px; height: 16px; }
.field > .seg { justify-self: start; }
/* Compact: tighter rows in tables and lists on wider screens (phones keep their own spacing). */
@media (min-width: 761px) {
  :root[data-density="compact"] table { font-size: 13px; }
  :root[data-density="compact"] td { padding: 3px 8px; }
  :root[data-density="compact"] th:not(.sortable) { padding: 4px 8px; }
  :root[data-density="compact"] th.sortable .sort-btn { padding: 4px 8px; }
  :root[data-density="compact"] .ledger td { padding: 2px 6px; }
  :root[data-density="compact"] .chip { padding: 0 7px; line-height: 1.45; }
  :root[data-density="compact"] .sugg { padding-top: 0; padding-bottom: 0; }
  :root[data-density="compact"] .occ { padding: 2px 0; }
  :root[data-density="compact"] .bill-grid { gap: 6px; }
  :root[data-density="compact"] .bill-head { padding-top: 1px; padding-bottom: 1px; }
  :root[data-density="compact"] .cal-day { min-height: 76px; }
}

/* ---------- account pages (Components/Account, inside AccountLayout's .acct) ----------
   ASP.NET Identity's sign-in and account pages keep the Bootstrap-style class names they were generated with. Rather
   than load Bootstrap for them, these rules give those names the app's look. Everything is under .acct, so none of it
   reaches the rest of the app (whose .row, for one, means something else). */
.acct h1 { margin-bottom: 4px; }
.acct h2 { font-size: 15px; font-weight: 600; color: var(--text-2); margin: 0 0 10px; }
.acct h3 { font-size: 14px; margin: 0 0 8px; }
.acct h4 { font-size: 14px; margin: 16px 0 6px; }
.acct hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.acct section + section, .acct form + form { margin-top: 16px; }
.acct p { margin: 0 0 10px; }
.acct ol.list, .acct ul:not(.nav):not(.validation-errors):not(.text-danger) { padding-left: 20px; margin: 0 0 12px; }
.acct ol.list > li { margin-bottom: 12px; }
.acct .glyphicon { display: none; } /* an icon font that was never included */
/* Grid: columns stack; forms stay a comfortable width. The Manage area is a menu beside the page on wider screens. */
.acct .row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-items: start; }
.acct .row > [class*="col-"] { min-width: 0; max-width: 520px; }
.acct .row > .col-lg-9, .acct .row > .col-md-12 { max-width: none; }
@media (min-width: 992px) { .acct .row:has(> .col-lg-3) { grid-template-columns: 210px minmax(0, 1fr); } }
/* Fields: the label above the box, like label.field elsewhere (the markup puts it after, for Bootstrap's floating labels). */
.acct .form-floating, .acct .mb-3 { margin-bottom: 14px; }
.acct .form-floating { display: flex; flex-direction: column; gap: 4px; }
.acct .form-floating > label, .acct .form-label { order: -1; font-size: 12px; font-weight: 600; color: var(--text-2); }
.acct .form-control { width: 100%; padding: 8px 10px; font-size: 15px; }
.acct .form-control:disabled { background: var(--surface-2); color: var(--text-2); }
.acct .password-rules { margin: 0; } /* what a new password needs, under its box (PasswordRules.razor) */
.acct .form-floating > .btn-link { align-self: flex-start; }
.acct .checkbox .form-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 400; color: var(--text); }
.acct .form-check-input { width: 16px; height: 16px; margin: 0; }
.acct .input-group { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 6px; }
.acct .input-group > label { grid-column: 1 / -1; }
.acct .input-group-text { display: grid; place-items: center; height: 100%; padding: 0 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); }
.acct .text-danger, .acct .validation-message { color: var(--neg); font-size: 12px; }
.acct h1.text-danger, .acct p.text-danger { font-size: inherit; }
/* The error summary (ValidationSummary: its own class, or text-danger where a page passes that instead). */
.acct .validation-errors, .acct ul.text-danger { list-style: none; margin: 0 0 14px; padding: 10px 12px; border-radius: 8px; background: var(--neg-soft); color: var(--neg); font-size: 13px; }
.acct .text-success { color: var(--pos); }
.acct .text-secondary { color: var(--muted); }
.acct .text-info { color: var(--accent); }
/* Buttons and button-styled links: the app's. */
.acct .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; line-height: 1.45; text-decoration: none; cursor: pointer; white-space: nowrap; }
.acct .btn:hover { background: var(--surface-2); }
.acct .btn-primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
.acct .btn-primary:hover { background: var(--accent-fill); filter: brightness(1.08); }
.acct .btn-danger { color: var(--neg); }
.acct .btn-link { border-color: transparent; background: none; color: var(--accent); padding: 4px 6px; }
.acct .btn-link:hover { background: var(--accent-soft); }
.acct .btn-lg { padding: 10px 16px; font-size: 15px; font-weight: 600; }
.acct a.btn + a.btn, .acct button.btn + button.btn, .acct button.btn + a.btn { margin-left: 6px; }
.acct .w-100 { width: 100%; }
/* Messages: the app's callouts. */
.acct .alert { margin: 0 0 14px; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); color: var(--text-2); font-size: 13px; }
.acct .alert-success { background: var(--pos-soft); color: var(--pos); }
.acct .alert-danger { background: var(--neg-soft); color: var(--neg); }
.acct .alert-warning { background: var(--warn-soft); color: var(--warn); }
.acct .alert p:last-child { margin-bottom: 0; }
/* The Manage menu: like the sidebar's links; a row of tabs on narrower screens. */
.acct .nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.acct .nav-link { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text-2); text-decoration: none; }
.acct .nav-link:hover { background: var(--surface-2); }
.acct .nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 991px) {
  .acct .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .acct .nav-link { padding: 6px 10px; border: 1px solid var(--border); }
}
/* Odds and ends. */
.acct .recovery-code { display: inline-block; margin: 3px; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); font-size: 14px; letter-spacing: .04em; }
.acct kbd { font-size: 13px; }
.acct .d-flex { display: flex; }
.acct .flex-column { flex-direction: column; }
.acct .mx-auto { margin-left: auto; margin-right: auto; }
.acct .mt-2 { margin-top: 8px; }
.acct .p-3 { padding: 12px; }
.acct .border { border: 1px solid var(--border); }
.acct .rounded { border-radius: 8px; }
.acct .font-weight-bold { font-weight: 700; }
.acct .h-100 { height: 100%; }
/* Signed out, the whole page is one card under the brand. */
.auth-main > .acct { padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth-main > .acct > h1 { font-size: 20px; }
.auth-main .acct .row > [class*="col-"] { max-width: none; }
@media (max-width: 560px) { .auth-main > .acct { padding: 18px 16px; } }

/* ---------- command palette (CommandPalette.razor) ---------- */
kbd { display: inline-block; min-width: 18px; padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-2); font: 600 11px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; text-align: center; }
.palette-btn { display: flex; align-items: center; gap: 8px; width: 100%; margin: -6px 0 12px; padding: 6px 8px; color: var(--muted); text-align: left; }
.palette-btn span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.palette-backdrop { position: fixed; inset: 0; z-index: 45; display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; background: rgba(10, 14, 22, .45); }
.palette { display: flex; flex-direction: column; width: min(640px, 100%); max-height: 72vh; overflow: hidden; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 18px 50px rgba(0, 0, 0, .35); }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.palette-search .icon { color: var(--muted); }
.palette-search input { flex: 1; min-width: 0; padding: 6px 0; border: 0; background: none; font-size: 16px; }
.palette-search input:focus { outline: none; } /* the open palette is the focus indicator */
.palette-list { overflow-y: auto; padding: 4px 6px 8px; }
.palette-group { padding: 10px 10px 4px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.palette-opt { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.palette-opt .icon { color: var(--muted); }
.palette-opt[aria-selected=true] { background: var(--accent-soft); color: var(--accent); }
.palette-opt[aria-selected=true] .icon { color: var(--accent); }
.palette-label { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.palette-detail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; text-align: right; }
.palette-empty { padding: 18px 10px; text-align: center; }
.palette-foot { display: flex; flex-wrap: wrap; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }
@media (max-width: 760px) {
  .palette-backdrop { padding: max(10px, env(safe-area-inset-top)) 8px 8px; }
  .palette { max-height: 70vh; max-height: 70dvh; } /* room for the on-screen keyboard */
  .palette-search kbd, .palette-foot { display: none; }
  .palette-opt { min-height: 44px; }
}

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: max(16px, env(safe-area-inset-bottom)); right: 16px; left: auto; display: grid; gap: 8px; z-index: 50; }
.toast-bc { display: flex; align-items: center; gap: 12px; background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 4px 16px rgba(0, 0, 0, .2); }
.toast-bc > span { flex: 1; }
/* Undo and other toast actions: a text button in the toast's own colors. The ✕ that closes a toast is one too. */
.toast-action, .toast-close { flex: none; padding: 2px 6px; border: 0; border-radius: 4px; background: none; color: inherit; font-weight: 700; }
.toast-action { text-decoration: underline; text-underline-offset: 2px; }
.toast-close { display: inline-grid; place-items: center; min-width: 24px; margin: -2px -8px -2px -4px; font-size: 12px; line-height: 20px; }
.toast-action:hover, .toast-close:hover { background: color-mix(in srgb, currentColor 15%, transparent); }
.toast-action:focus-visible, .toast-close:focus-visible { outline: 2px solid currentColor; }
.toast-bc.error { background: var(--neg-fill); color: var(--on-neg); }
.toast-bc.warn { background: var(--warn-fill); color: var(--on-warn); }
/* Phones: just above the tab bar. */
@media (max-width: 760px) { .toasts { left: 16px; bottom: calc(68px + env(safe-area-inset-bottom)); } .toast-bc { max-width: none; } }

/* ---------- forecast chart ---------- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .line.bank { stroke: var(--series-1); }
.chart .line.budgeted { stroke: var(--series-2); }
.chart .band { fill: var(--series-2); opacity: .12; }
.chart .low { fill: var(--neg); stroke: var(--surface); stroke-width: 2; }
.chart .cross-line { stroke: var(--text-2); stroke-width: 1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .dot.bank { fill: var(--series-1); }
.chart .dot.budgeted { fill: var(--series-2); }
.chart .end-label { fill: var(--text-2); font-size: 12px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.swatch.s1 { background: var(--series-1); }
.swatch.s2 { background: var(--series-2); }
.swatch.band { background: color-mix(in srgb, var(--series-2) 25%, transparent); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--text-2); margin-bottom: 6px; }
.chart-tooltip { position: fixed; z-index: 60; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, .15); max-width: 280px; }
.chart-tooltip hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; opacity: 1; }
.chart-tooltip b { font-variant-numeric: tabular-nums; }
.tip-row { display: flex; justify-content: space-between; gap: 12px; white-space: nowrap; }
/* Monthly columns (MonthBars.razor) and ranked bars (Reports.razor). */
.chart .baseline { stroke: var(--muted); stroke-width: 1; }
.chart .col.s1, .hbar > span.s1 { fill: var(--series-1); background: var(--series-1); }
.chart .col.s2 { fill: var(--series-2); }
.chart .tip-hit { fill: transparent; }
/* Phones: keep the monthly chart's labels readable; it scrolls sideways inside its card instead of shrinking. */
@media (max-width: 760px) {
  .chart.months { overflow-x: auto; }
  .chart.months svg { min-width: 560px; }
}
.chart .month { outline: none; }
.chart .month:hover .col, .chart .month:focus-visible .col { opacity: .8; }
.chart .month:focus-visible .tip-hit { stroke: var(--accent); stroke-width: 2; }
.rank { display: grid; grid-template-columns: minmax(90px, 200px) minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; font-size: 13px; }
.rank .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar { height: 12px; display: flex; align-items: center; }
.hbar > span { display: block; height: 12px; min-width: 2px; border-radius: 0 4px 4px 0; }
.rank .num { font-variant-numeric: tabular-nums; }
.report-table td, .report-table th { white-space: nowrap; }
.report-table .group td { font-weight: 700; background: var(--surface-2); }
/* "Show the numbers": a chart's table, a click away, its toggle styled like the app's link buttons. */
details.numbers { margin-top: 10px; }
details.numbers > summary { width: fit-content; margin-left: -4px; padding: 2px 4px; border-radius: 4px; color: var(--accent); font-size: 13px; cursor: pointer; }
details.numbers > summary:hover { background: var(--accent-soft); }
details.numbers > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
details.numbers[open] > summary { margin-bottom: 8px; }

/* ---------- framework ---------- */
#blazor-error-ui { color-scheme: light only; background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); box-sizing: border-box; display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; color: #222; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }
.validation-message { color: var(--neg); }
