/* Tokens ------------------------------------------------------------------- */

/* Dark is the default, and deliberately not `prefers-color-scheme`.
   A media query means the app is bright whenever the OS says so, with no way
   to say otherwise from inside it — which for anyone sensitive to light is not
   a preference being missed, it is the app hurting them. The theme is chosen
   explicitly and remembered; `auto` is available for anyone who wants the OS
   to decide.

   The dark palette is built rather than inverted:
   - the ground is warm near-black, never #000, because pure black under light
     text makes glyphs halate and smear
   - text sits around 11:1, not the 18:1 that glares — still well past WCAG AA
   - accents are desaturated, since saturated hues bloom on a dark ground
   - large figures are held BELOW body contrast (see .stat-value): a 2rem
     number at full brightness is the largest light source on the page, and
     this app is mostly large numbers. */

:root {
  --ink: #e0ddd7;
  --muted: #a09c94;
  --faint: #736f68;
  --line: #302e2a;
  --bg: #171614;
  --panel: #1e1d1a;
  --ok: #7fbf94;
  --attention: #d9a071;
  --danger: #d98b80;
  --accent: #8fb3dd;
  --bar: #6b93c4;
  --bar-track: #2b2925;
  /* Foreground for text sitting ON a filled accent or attention colour.
     Hardcoding #fff broke the moment the accent got light enough to read on
     a dark ground. */
  --on-accent: #171614;
  --on-attention: #171614;

  /* One type scale. These replace the fourteen ad-hoc rem values that used to
     be scattered through the file, none of which agreed with each other. */
  --t-xs: .75rem;
  --t-sm: .8125rem;
  --t-base: .9375rem;
  --t-md: 1.0625rem;
  --t-lg: 1.375rem;
  --t-xl: 2rem;
}

/* Dim: for a bad day. Everything steps down together, so nothing becomes the
   brightest thing on screen by accident. */
:root.theme-dim {
  --ink: #c9c5be;
  --muted: #8b8880;
  --faint: #625f59;
  --line: #262421;
  --bg: #131211;
  --panel: #191817;
  --ok: #6da37e;
  --attention: #bb8a62;
  --danger: #bb7f70;
  --accent: #7d9dc2;
  --bar: #5b7da8;
  --bar-track: #232120;
  --on-accent: #131211;
  --on-attention: #131211;
}

:root.theme-light,
:root.theme-auto {
  --ink: #1a1a1a;
  --muted: #6b6b6b;
  --faint: #9a9a9a;
  --line: #e4e2de;
  --bg: #fbfaf8;
  --panel: #ffffff;
  --ok: #2f7d4f;
  --attention: #a8531b;
  --danger: #a4342b;
  --accent: #1f4f8b;
  --bar: #4a7ab5;
  --bar-track: #eceae6;
  --on-accent: #ffffff;
  --on-attention: #ffffff;
}

/* `auto` is the only theme that asks the OS, and it is opt-in. */
@media (prefers-color-scheme: dark) {
  :root.theme-auto {
    --ink: #e0ddd7;
    --muted: #a09c94;
    --faint: #736f68;
    --line: #302e2a;
    --bg: #171614;
    --panel: #1e1d1a;
    --ok: #7fbf94;
    --attention: #d9a071;
    --danger: #d98b80;
    --accent: #8fb3dd;
    --bar: #6b93c4;
    --bar-track: #2b2925;
    --on-accent: #171614;
    --on-attention: #171614;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--t-base)/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main { max-width: 66rem; margin: 0 auto; padding: 2rem 1.25rem 5rem; }

h1 { font-size: var(--t-lg); margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: var(--t-base); margin: 0 0 1rem; font-weight: 600; }
h3 { font-size: var(--t-md); margin: 0 0 .6rem; }

a { color: var(--accent); }

/* Nav ---------------------------------------------------------------------- */

.topnav {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-inner {
  max-width: 66rem;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: .25rem;
}
.brand { font-weight: 600; margin-right: 1.25rem; letter-spacing: -.01em; }
.nav-spacer { flex: 1; }

.nav-link {
  padding: .9rem .7rem;
  color: var(--muted);
  text-decoration: none;
  font-size: var(--t-base);
  border-bottom: 2px solid transparent;
}
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }

/* The sign-out button sits in the nav and should not look like a button. */
.nav-form { margin: 0; display: flex; }
button.nav-link {
  font: inherit;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.badge {
  display: inline-block;
  min-width: 1.15rem;
  padding: 0 .3rem;
  border-radius: 1rem;
  background: var(--attention);
  color: var(--on-attention);
  font-weight: 600;
  font-size: var(--t-xs);
  line-height: 1.15rem;
  text-align: center;
}

/* Alerts and freshness ----------------------------------------------------- */

/* Above the page rather than inside it, because these are about whether what
   is below can be believed. */
.alerts { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1.25rem; }
.alerts .banner { margin-bottom: 0; }
.alerts .banner strong { display: block; margin-bottom: .15rem; }
.alerts .banner a { margin-left: .3rem; white-space: nowrap; }

/* Deliberately quiet, and shown even when nothing is wrong: seeing it normally
   is what makes an odd one legible later. */
.freshness {
  margin: 2.5rem 0 0;
  font-size: var(--t-xs);
  color: var(--faint);
  text-align: right;
}

/* Appearance switcher ------------------------------------------------------ */

/* In the nav rather than buried in settings: when the screen is hurting you,
   the fix should not be three clicks away. */
.theme-picker {
  display: flex;
  align-items: center;
  gap: .3rem;
  margin: 0 .3rem 0 0;
}
.theme-picker select {
  font-size: var(--t-xs);
  padding: .2rem 1.4rem .2rem .4rem;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
  cursor: pointer;
}
.theme-picker select:hover { color: var(--ink); border-color: var(--line); }
.theme-picker select:focus-visible { color: var(--ink); border-color: var(--line); }

/* The select submits itself, so this is only reached without JS. Hidden the
   accessible way — display:none would take it from keyboard users too. */
.theme-go {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.theme-go:focus {
  position: static;
  width: auto;
  height: auto;
  clip-path: none;
  font: inherit;
  font-size: var(--t-xs);
  padding: .2rem .5rem;
  border: 1px solid var(--line);
  border-radius: .35rem;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Page furniture ----------------------------------------------------------- */

.page-head { margin-bottom: 1.5rem; }
.sub { margin: 0; color: var(--muted); font-size: var(--t-base); }
.hint { color: var(--muted); font-size: var(--t-sm); }

.flash {
  padding: .6rem .85rem;
  border-radius: .4rem;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: var(--t-base);
  margin: 0 0 1.25rem;
}
.flash.problem { border-color: var(--danger); color: var(--danger); }

.banner.problem { border-color: var(--danger); }
.banner.problem strong { color: var(--danger); }

.banner {
  padding: .8rem 1rem;
  border-radius: .5rem;
  margin-bottom: 1.25rem;
  font-size: var(--t-base);
  border: 1px solid var(--attention);
  background: var(--panel);
}

.empty { padding: 1.5rem 0; color: var(--muted); }
.empty p { margin: 0 0 .3rem; }

/* Stats -------------------------------------------------------------------- */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .6rem;
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.stat-label { font-size: var(--t-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value {
  font-size: var(--t-xl);
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  /* Held under body contrast on purpose: the biggest glyphs on the page
     should not also be the brightest. */
  opacity: .92;
}
.stat-sub { font-size: var(--t-xs); color: var(--faint); }
.stat.good .stat-sub { color: var(--ok); }
.stat.bad .stat-sub { color: var(--danger); }
.stat.warn .stat-value { color: var(--attention); }

/* Panels and columns ------------------------------------------------------- */

.columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
  /* Panels size to their content instead of stretching to the tallest one. */
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .6rem;
  padding: 1.1rem 1.25rem;
}

/* Whose spending ----------------------------------------------------------- */

.who-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: .15rem;
  margin: -.4rem 0 1rem;
}
.who {
  padding: .25rem .55rem;
  border-radius: .3rem;
  font-size: var(--t-xs);
  text-decoration: none;
  color: var(--muted);
}
.who:hover { color: var(--ink); background: var(--bg); }
.who.current { color: var(--ink); background: var(--bg); font-weight: 500; }

/* Bars --------------------------------------------------------------------- */

.bars, .budget-list, .accounts, .review-list { list-style: none; margin: 0; padding: 0; }
.bars li, .budget { margin-bottom: .9rem; }

.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: var(--t-sm);
  margin-bottom: .3rem;
}
.bar-amount { color: var(--muted); font-variant-numeric: tabular-nums; }

.bar-track {
  position: relative;
  height: .5rem;
  background: var(--bar-track);
  border-radius: 1rem;
  overflow: hidden;
}
.bar-fill { height: 100%; background: var(--bar); border-radius: 1rem; }

/* The pace marker: where an even rate would have you by now. */
.bar-pace {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--ink);
  opacity: .45;
}

.budget.over .bar-fill { background: var(--attention); }
.budget.under .bar-fill { background: var(--ok); }
.budget-note { margin: .3rem 0 0; font-size: var(--t-xs); color: var(--muted); }
.budget-actions { margin: -.5rem 0 1rem; }

.group {
  display: flex;
  justify-content: space-between;
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 1rem 0 .4rem;
  font-weight: 600;
}
.group:first-child { margin-top: 0; }

.accounts li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .35rem 0;
  font-size: var(--t-base);
  font-variant-numeric: tabular-nums;
}
.mask { color: var(--faint); }

/* Tables ------------------------------------------------------------------- */

.txns { width: 100%; border-collapse: collapse; font-size: var(--t-base); }
.txns th {
  text-align: left;
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: .4rem .5rem;
  border-bottom: 1px solid var(--line);
}
.txns td { padding: .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.txns tbody tr:hover { background: var(--bg); }
.txns .date { color: var(--muted); white-space: nowrap; width: 4.5rem; }
.txns .amount, .txns .right { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txns .amount.credit { color: var(--ok); }
.txns .cat { width: 14rem; }
.txns.compact { table-layout: fixed; }
.txns.compact td { padding: .35rem .3rem; }
/* Fixed widths plus truncation: a long bank descriptor must not wrap a row
   into three lines in a narrow column. */
.txns.compact .merchant { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txns.compact .cat { width: 6.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.txns.compact .amount { width: 5.5rem; }
.txns .is-transfer { opacity: .6; }

.merchant .meta { display: block; color: var(--faint); font-size: var(--t-xs); }
.more { margin: .8rem 0 0; font-size: var(--t-sm); }

/* Recurring ---------------------------------------------------------------- */

.txns.recurring .cadence { color: var(--muted); font-size: var(--t-sm); white-space: nowrap; }
.txns.recurring .next { white-space: nowrap; font-size: var(--t-sm); }
.txns.recurring .annual { font-weight: 500; }

/* A price change is the thing people most want to be told and never are. */
.txns.recurring .rose { color: var(--attention); }
.txns.recurring .fell { color: var(--ok); }

/* Past due: either it was cancelled and this row is stale, or a charge was
   missed. Worth pointing at, not worth guessing between. */
.txns.recurring .next.overdue { color: var(--attention); }
.txns.recurring .next.overdue .meta { color: var(--attention); opacity: .8; }

.recurring-note { margin-top: 1rem; }

/* Forms -------------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .6rem;
  margin-bottom: 1.25rem;
  padding: .9rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .6rem;
}
.filters label { display: grid; gap: .2rem; font-size: var(--t-xs); color: var(--muted); }
.filters .grow { flex: 1; min-width: 12rem; }
.filters .check { flex-direction: row; align-items: center; gap: .4rem; display: flex; }

.budget-form { display: grid; gap: .85rem; max-width: 24rem; }
.budget-form label { display: grid; gap: .25rem; font-size: var(--t-sm); color: var(--muted); }
.budget-form .check { display: flex; align-items: center; gap: .45rem; }

input, select {
  font: inherit;
  font-size: var(--t-base);
  padding: .4rem .5rem;
  border: 1px solid var(--line);
  border-radius: .35rem;
  background: var(--bg);
  color: var(--ink);
  max-width: 100%;
}
input[type="checkbox"] { width: auto; padding: 0; }

form.inline { display: inline-flex; gap: .4rem; align-items: center; margin: 0; }

.button {
  font: inherit;
  font-size: var(--t-sm);
  font-weight: 500;
  padding: .45rem .9rem;
  border-radius: .35rem;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.button:disabled { opacity: .55; cursor: default; }
.button.small { padding: .3rem .7rem; font-size: var(--t-sm); }
.button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }

.link-button {
  font: inherit;
  font-size: var(--t-sm);
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
}
.link-button.danger { color: var(--danger); }

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.25rem;
  font-size: var(--t-sm);
}

/* Accounts ----------------------------------------------------------------- */

.account-editor {
  display: grid;
  grid-template-columns: 1fr 10rem auto auto;
  gap: .6rem 1rem;
  align-items: end;
  padding: .9rem 0;
  border-top: 1px solid var(--line);
}
.account-editor:first-of-type { border-top: none; }
.account-head { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 1rem; }
.account-head .account-name { font-weight: 500; }
.account-editor label { display: grid; gap: .2rem; font-size: var(--t-xs); color: var(--muted); }
.account-editor .check { display: flex; align-items: center; gap: .4rem; }
.add-person { margin-top: .8rem; }

/* Narrow screens ----------------------------------------------------------- */

/* The app is reached from a phone now, which is most of why it moved off a
   machine at home. Before this there was one media query in the whole file. */

/* Restore ------------------------------------------------------------------ */

.restore { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: 0; }
.restore input[type="file"] { flex: 1 1 16rem; font-size: var(--t-sm); }
.restore-result {
  flex: 1 1 100%;
  margin: 0;
  font-size: var(--t-sm);
  color: var(--muted);
}
.restore-result.good { color: var(--ok); }
.restore-result.bad { color: var(--danger); }

.panel h4 { margin: 1.2rem 0 .4rem; font-size: var(--t-base); }

/* Signing in with Discord --------------------------------------------------- */

.sign-in-with { margin: 0 0 1rem; }
.button.discord {
  display: block;
  text-align: center;
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}
.button.discord:hover { border-color: var(--accent); }
.or {
  margin: 0 0 1rem;
  text-align: center;
  color: var(--muted);
  font-size: var(--t-sm);
}

/* The way out of setup ------------------------------------------------------ */
/* The setup page renders without the nav, so without this there is no link
   back to the app at all -- you have to edit the address bar. */

.back { margin: 0 0 1rem; font-size: var(--t-sm); }
.back a { color: var(--muted); text-decoration: none; }
.back a:hover { color: var(--ink); }

/* Cards, in avalanche order ------------------------------------------------- */

.cards { list-style: none; margin: 0; padding: 0; }
.card-row {
  display: flex;
  gap: .8rem;
  align-items: baseline;
  justify-content: space-between;
  padding: .55rem 0;
  border-top: 1px solid var(--line);
}
.card-row:first-child { border-top: none; }
.card-name { font-weight: 500; }
.card-row .meta { display: block; color: var(--muted); font-size: var(--t-sm); }
.card-figures { display: flex; gap: .8rem; align-items: baseline; white-space: nowrap; }
.rate { font-variant-numeric: tabular-nums; }

/* Utilisation, and only these two states are coloured -- a card at 40% is
   simply a card, and colouring it would spend the reader's attention on
   nothing. */
.used.high { color: var(--attention); }
.used.over { color: var(--danger); font-weight: 500; }

/* Connected apps ----------------------------------------------------------- */

.grants-list { list-style: none; margin: 0; padding: 0; }
.grant {
  display: flex;
  gap: .8rem;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 0;
  border-top: 1px solid var(--line);
}
.grant:first-child { border-top: none; }
.grant-who { font-weight: 500; }
.grant .meta { display: block; color: var(--muted); font-size: var(--t-sm); }

/* Consent ------------------------------------------------------------------ */
/* The one screen where somebody decides what a model may see. Read in a hurry,
   in a popup, so it is built to survive skimming. */

.consent { max-width: 34rem; }
.consent .panel { margin-bottom: 1rem; }
.consent .panel.warn { border-color: var(--attention); }

.grants { margin: 0 0 .6rem; padding-left: 1.1rem; }
.grants li { margin: .25rem 0; font-size: var(--t-sm); }

.consent-form { display: block; margin: 0; }
.consent-actions {
  display: flex;
  gap: .6rem;
  align-items: center;
  margin-top: 1.2rem;
}

/* Notifications ------------------------------------------------------------ */
/* One row per person, because the alerts route per person. */

.notify-row {
  display: flex;
  gap: .6rem;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: .6rem 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
.notify-row:first-of-type { border-top: none; }
.notify-row label { flex: 1 1 14rem; margin: 0; }
.notify-result {
  flex: 1 1 100%;
  margin: 0;
  font-size: var(--t-sm);
  color: var(--muted);
  min-height: 1.2em;
}
.notify-result.good { color: var(--ok); }
.notify-result.bad { color: var(--danger); }

@media (max-width: 46rem) {
  /* A person's row stacks: a text field sharing a line with a button at 390px
     leaves neither usable. */
  .notify-row { align-items: stretch; }
  .notify-row label { flex-basis: 100%; }
  .notify-row .button { width: 100%; }

  .restore input[type="file"] { flex-basis: 100%; }
  .restore .button { width: 100%; }

  /* Allow and Cancel each get a full line: a mis-tap here grants access to a
     year of bank transactions, so they should not sit thumb-width apart. */
  .consent-actions { flex-direction: column; align-items: stretch; }
  .consent-actions .button { width: 100%; }

  /* The name and its Disconnect button stop fighting for one line. */
  .grant { flex-direction: column; align-items: stretch; gap: .4rem; }

  /* A card's name and its figures stack rather than squeezing the balance off
     the edge, which is the column you opened the page for. */
  .card-row { flex-direction: column; align-items: stretch; gap: .3rem; }
  .card-figures { justify-content: space-between; }

  main { padding: 1.25rem .875rem 4rem; }

  /* The nav scrolls sideways rather than wrapping to three rows or hiding
     behind a menu. Every destination stays one tap away and it needs no JS —
     which matters, because a menu button is exactly the sort of thing that
     breaks quietly. */
  .nav-inner {
    padding: 0 .875rem;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav-inner::-webkit-scrollbar { display: none; }
  .nav-link, .brand { white-space: nowrap; }
  .brand { margin-right: .75rem; }
  /* flex:1 would push Setup and Sign out past the end of a scrolling row. */
  .nav-spacer { flex: 0 0 .75rem; }

  h1 { font-size: var(--t-lg); }

  /* Two stat cards side by side leaves ~11rem each, and the figures are 2rem
     and tabular. They overflow. */
  .stat-row { grid-template-columns: 1fr; }
  .columns { grid-template-columns: 1fr; }

  .filters { padding: .75rem .8rem; }
  .filters .grow { min-width: 100%; }

  /* Comfortable targets. The desktop sizes are fine with a pointer and too
     small with a thumb. */
  .button { padding: .55rem 1rem; min-height: 2.75rem; }
  .button.small { padding: .45rem .8rem; min-height: 2.25rem; }
  input, select { padding: .5rem .55rem; min-height: 2.5rem; }
  .link-button { padding: .35rem 0; min-height: 2rem; }

  /* Tables become stacked rows.
     A four-column table at 390px is unreadable, and the alternative — sideways
     scrolling — hides the amount, which is the column you came for. The
     existing cell classes carry the layout, so no markup changes. */
  .txns { display: block; }
  .txns thead { display: none; }
  .txns tbody { display: block; }

  .txns tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .15rem .75rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--line);
  }
  .txns td {
    padding: 0;
    border: none;
    width: auto;
  }
  .txns tbody tr:hover { background: none; }

  .txns .merchant { grid-column: 1; grid-row: 1; font-size: var(--t-base); }
  .txns .amount, .txns .right {
    grid-column: 2;
    grid-row: 1;
    font-size: var(--t-base);
    font-weight: 500;
  }
  .txns .date { grid-column: 1; grid-row: 2; font-size: var(--t-xs); }

  /* On the dashboard the category is text and sits opposite the date. On the
     transactions page it is a select and a button, so it gets its own row. */
  .txns.compact .cat {
    grid-column: 2;
    grid-row: 2;
    text-align: right;
    font-size: var(--t-xs);
    color: var(--muted);
  }
  .txns:not(.compact) .cat {
    grid-column: 1 / -1;
    grid-row: 3;
    margin-top: .35rem;
  }
  .txns:not(.compact) .cat form { display: flex; width: 100%; gap: .5rem; }
  .txns:not(.compact) .cat select { flex: 1; min-width: 0; }

  /* Truncation was there to stop a long bank descriptor wrapping a narrow
     column into three lines. With a row per transaction there is width to
     wrap into, and the full name is worth more than one tidy line. */
  .txns.compact .merchant,
  .txns.compact .cat {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
  }

  /* Five columns where four already did not fit. Same stacked treatment: the
     merchant and the yearly cost lead, because the yearly cost is the number
     that makes someone cancel something. */
  .txns.recurring tr { grid-template-columns: 1fr auto; }
  .txns.recurring .merchant { grid-column: 1; grid-row: 1; }
  .txns.recurring .annual { grid-column: 2; grid-row: 1; }
  .txns.recurring .cadence { grid-column: 1; grid-row: 2; }
  .txns.recurring .next { grid-column: 2; grid-row: 2; text-align: right; }
  .txns.recurring .amount:not(.annual) {
    grid-column: 1 / -1;
    grid-row: 3;
    font-size: var(--t-xs);
    color: var(--muted);
    font-weight: 400;
  }
  .txns.recurring .amount:not(.annual) .meta { display: inline; margin-left: .3rem; }

  .account-editor { grid-template-columns: 1fr; align-items: stretch; }

  .pager { gap: .75rem; }
  .rule { flex-direction: column; align-items: flex-start; gap: .5rem; }

  /* The link wraps under the text rather than being pushed off the edge. */
  .alerts .banner a { display: inline-block; margin-left: 0; margin-top: .3rem; }
  .freshness { text-align: left; margin-top: 2rem; }

  /* Thumb-sized, since these are the smallest targets on the dashboard. */
  .who { padding: .45rem .7rem; }
}

/* Very narrow: the theme picker's label is the first thing that can go, since
   the control is self-explanatory once you use it once. */
@media (max-width: 26rem) {
  .stat-value { font-size: var(--t-lg); }
}

.budget-note.warn { color: var(--attention); }

/* Rules -------------------------------------------------------------------- */

.rule-form { display: grid; gap: .9rem; }
.rule-sentence {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  font-size: var(--t-base);
}
.rule-sentence input[type="text"] { min-width: 10rem; }
.rule-form .check { display: flex; align-items: center; gap: .45rem; font-size: var(--t-base); }

.rule-list { list-style: none; margin: 0; padding: 0; }
.rule {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .7rem 0;
  border-top: 1px solid var(--line);
  font-size: var(--t-base);
}
.rule:first-child { border-top: none; }
.rule.disabled { opacity: .5; }
/* Also the panels, where a secret's name is worth setting apart from prose. */
.rule code, .panel code {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: .25rem;
  padding: .05rem .35rem;
  font-size: .88em;
}
.rule-actions { display: flex; gap: .8rem; white-space: nowrap; }

/* Review ------------------------------------------------------------------- */

.review-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: .6rem;
  padding: 1rem 1.15rem;
  margin-bottom: .75rem;
}
.review-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; }
.review-head .merchant { font-weight: 500; }
.review-head .meta { color: var(--faint); font-size: var(--t-xs); margin-left: .5rem; }
.review-head .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.review-head .amount.credit { color: var(--ok); }
.suggestion { margin: .5rem 0 .9rem; font-size: var(--t-base); color: var(--muted); }
.review-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

/* Setup page --------------------------------------------------------------- */

.steps { list-style: none; margin: 0 0 2rem; padding: 0; }

.step { display: flex; gap: .85rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.step:last-child { border-bottom: 1px solid var(--line); }

.mark {
  flex: 0 0 1.5rem;
  height: 1.5rem;
  width: 1.5rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: var(--t-xs);
  border: 1px solid var(--line);
  color: var(--muted);
}
.step h2 { margin: 0; font-size: var(--t-md); }
.detail { margin: .15rem 0 0; color: var(--muted); font-size: var(--t-base); }

.step.complete .mark { border-color: var(--ok); color: var(--ok); }
.step.complete h2 { color: var(--muted); font-weight: 500; }
.step.action_needed .mark { border-color: var(--attention); color: var(--attention); }
.step.action_needed .detail { color: var(--attention); }
.step.pending { opacity: .55; }
.step.skipped { opacity: .7; }

.lede { margin: 0 0 .5rem; color: var(--muted); }
.env { margin: 0 0 2rem; color: var(--muted); font-size: var(--t-base); }
.remedy { margin: 0 0 1rem; }

.credentials { display: grid; gap: 1rem; max-width: 26rem; }
.credentials label { display: grid; gap: .3rem; }
.credentials label > span { font-size: var(--t-sm); font-weight: 500; }

fieldset { border: 1px solid var(--line); border-radius: .4rem; padding: .75rem .9rem; margin: 0; }
legend { font-size: var(--t-sm); font-weight: 500; padding: 0 .3rem; }

label.radio { display: flex; align-items: baseline; gap: .5rem; font-size: var(--t-base); }
label.radio + label.radio { margin-top: .35rem; }
label.radio input { width: auto; }

footer { margin-top: 2rem; font-size: var(--t-base); }

.warning { color: var(--attention); font-size: var(--t-sm); font-weight: 500; margin: 1rem 0 .5rem; }

.key-block {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: .4rem;
  padding: .8rem;
  overflow-x: auto;
  font-size: var(--t-xs);
  line-height: 1.45;
  margin: 0;
}

/* Setup renders standalone, without the app shell. */
body.setup { padding: 3rem 1.25rem 4rem; }
body.setup main { max-width: 40rem; padding: 0; }
