/* Wavi Finance: design tokens and the few rules every page shares.
   Tokens are the only place a colour value appears (email bodies, which cannot use
   CSS variables, are the one exception: services/mailer.py). Dark-only, so there is
   no second theme to keep in step; `color-scheme` makes native controls match. */
:root {
  --bg: #0B1420;  --panel: #132234;  --panel2: #1B2E45;
  --line: #24405F;  --line-strong: #56769A;
  --txt: #E6EBF0;  --muted: #8FA3B8;
  --accent: #2FA5AF;  --on-accent: var(--bg);  --focus: var(--accent);
  --pos: #34D27B;  --neg: #FF7B7B;  --neu: #E5B53B;  --info: #78AEFF;
  --pos-bg: color-mix(in srgb, var(--pos) 12%, transparent);
  --neg-bg: color-mix(in srgb, var(--neg) 12%, transparent);
  --neu-bg: color-mix(in srgb, var(--neu) 12%, transparent);
  --info-bg: color-mix(in srgb, var(--info) 12%, transparent);
  --pos-line: color-mix(in srgb, var(--pos) 40%, transparent);
  --neg-line: color-mix(in srgb, var(--neg) 40%, transparent);
  --neu-line: color-mix(in srgb, var(--neu) 40%, transparent);
  --danger: #D8323F;  --on-danger: #FFFFFF;
  --danger-hover: color-mix(in srgb, var(--danger) 85%, black);
  --r-md: 8px;  --r-lg: 12px;  --r-pill: 9999px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--txt); font: 15px/1.5 var(--font-ui);
  min-height: 100vh; }
a { color: var(--accent); }
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px;
  padding: 0 18px; border: 0; border-radius: var(--r-md); background: var(--accent);
  color: var(--on-accent); font: 600 15px var(--font-ui); cursor: pointer;
  text-decoration: none; }
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; color: var(--txt); border: 1px solid var(--line-strong); }
.btn.danger { background: var(--danger); color: var(--on-danger); }
.btn.danger:hover { background: var(--danger-hover); filter: none; }
.mini { min-height: 36px; padding: 0 12px; border-radius: var(--r-md); font: 600 13px var(--font-ui);
  cursor: pointer; background: transparent; color: var(--txt); border: 1px solid var(--line-strong); }
.mini.go { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.mini.warn { color: var(--neg); border-color: var(--neg-line); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.shell { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; }
.shell.top { align-items: flex-start; }
.box { width: 100%; max-width: 420px; }
.brand { font-size: 19px; font-weight: 650; line-height: 1.3; margin: 0 0 4px; }
.brand span { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 24px; margin-top: 16px; }
h2 { margin: 0 0 6px; font-size: 18px; font-weight: 650; }
p.sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
/* 16px, not 15: iOS Safari zooms the whole page into any smaller focused input. */
input[type=email], input[type=password], input[type=text], input[type=search] { width: 100%; padding: 11px 13px;
  font: 16px/1.3 var(--font-ui); border-radius: var(--r-md); color: var(--txt);
  border: 1px solid var(--line-strong); background: var(--panel2); }
input::placeholder { color: var(--muted); opacity: 1; }
input[readonly] { color: var(--muted); border-color: var(--line); }
form > .btn { width: 100%; margin-top: 20px; }
.alert { margin: 0 0 16px; padding: 11px 14px; border-radius: var(--r-md); font-size: 14px;
  background: var(--neg-bg); color: var(--neg); border: 1px solid var(--neg-line); }
.alert.ok { background: var(--pos-bg); color: var(--pos); border-color: var(--pos-line); }
.foot { color: var(--muted); font-size: 13px; margin: 16px 0 0; text-align: center; }
.foot a, a.link { display: inline-flex; align-items: center; min-height: 40px; text-decoration: none; }
.hint { color: var(--muted); font-size: 12px; margin-top: 8px; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.topbar > span { min-width: 0; overflow-wrap: anywhere; }

/* Banks page */
.bank { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; border-top: 1px solid var(--line); }
.bank:first-of-type { border-top: 0; }
.bank > div { min-width: 0; overflow-wrap: anywhere; }
.bank .meta { color: var(--muted); font-size: 12px; }
.bank .actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.bank summary { list-style: none; display: inline-flex; align-items: center; }
.bank details[open] { flex-basis: 100%; }
.bank details form > .btn { width: auto; margin-top: 8px; }

/* Money pages: nav, tiles, lines tables. Status is green (--pos) or red (--neg), nothing else. */
.nav { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 8px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line); }
.nav a { display: inline-flex; align-items: center; min-height: 40px; color: var(--muted);
  text-decoration: none; font-weight: 600; font-size: 14px; }
.nav a[aria-current="page"] { color: var(--txt); box-shadow: inset 0 -2px 0 var(--accent); }
.nav .who { margin-left: auto; align-self: center; color: var(--muted); font-size: 12px; min-width: 0;
  overflow-wrap: anywhere; }
.nav .signout { margin: 0; align-self: center; }
.head { margin-top: 8px; }
.note { color: var(--muted); font-size: 14px; margin: 8px 0; }
.card.acct, .card.payday { padding: 16px; }
.acct-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 12px; }
.acct-head h2 { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.amt { text-align: right; font-variant-numeric: tabular-nums; }
.asof { color: var(--muted); font-size: 12px; font-weight: 400; }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 2px; text-align: left; min-width: 0; min-height: 44px;
  padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line-strong);
  background: var(--panel2); color: var(--txt); font: inherit; cursor: pointer; overflow-wrap: anywhere; }
.tile.ok { border-color: var(--pos-line); background: var(--pos-bg); }
.tile.ok .tile-head { color: var(--pos); }
.tile.short { border-color: var(--neg-line); background: var(--neg-bg); }
.tile.short .tile-head { color: var(--neg); }
.tile[aria-expanded="true"] { outline: 2px solid var(--line-strong); }
.tile-label { color: var(--muted); font-size: 12px; }
.tile-head { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile-sub { color: var(--muted); font-size: 12px; }
table.lines { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
table.lines[hidden] { display: none; }
table.lines th, table.lines td { padding: 6px 8px; border-top: 1px solid var(--line); text-align: left;
  vertical-align: top; overflow-wrap: anywhere; }
table.lines th.amt, table.lines td.amt { text-align: right; white-space: nowrap; }
table.lines th { color: var(--muted); font-weight: 600; font-size: 12px; border-top: 0; }
table.lines caption, .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
table.lines tr.k-total td, table.lines tr.k-result td { font-weight: 650; }
.scroll { overflow-x: auto; }

/* Recurring: two-line rows, the month calendar, one bill's form, the Saved page */
.card.list { padding: 16px; }
ul.rows, ol.rows { list-style: none; margin: 8px 0 0; padding: 0; }
ul.rows > li, ol.rows > li { border-top: 1px solid var(--line); }
ul.rows > li:first-child, ol.rows > li:first-child { border-top: 0; }
ul.rows > li.hint, ol.rows > li.hint { padding: 10px 0; }
a.row, li.row { display: flex; flex-direction: column; gap: 2px; min-height: 44px; padding: 8px 0;
  color: var(--txt); text-decoration: none; min-width: 0; }
a.row:hover .row-name { text-decoration: underline; }
.row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.row-name { min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.row-top .amt { white-space: nowrap; }
.row-sub { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.row-with-actions { display: flex; align-items: center; gap: 12px; }
.row-with-actions > .row { flex: 1 1 auto; }
.row-with-actions form { margin: 0; }
.row-actions { display: flex; flex-direction: column; gap: 6px; }
.tag { white-space: nowrap; }
.tag::before { content: "· "; }
.tag.neg, .state.missed { color: var(--neg); }
.state.paid { color: var(--pos); }
.cal-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cal-head h2 { margin: 0; }
.cal-head .link { min-width: 44px; justify-content: center; }
table.cal { width: 100%; table-layout: fixed; border-collapse: collapse; margin: 8px 0 4px; }
table.cal th { color: var(--muted); font-size: 12px; font-weight: 600; padding: 2px 0; }
table.cal abbr { text-decoration: none; }
table.cal td { position: relative; height: 44px; min-width: 0; padding: 2px; vertical-align: top;
  border: 1px solid var(--line); overflow: hidden; }
table.cal td.out { border-color: transparent; }
.dnum { display: block; font-size: 12px; color: var(--muted); line-height: 1.2; }
.marks { display: block; font-size: 13px; line-height: 1.2; font-weight: 700; overflow-wrap: anywhere; }
.mark.paid { color: var(--pos); }
.mark.missed { color: var(--neg); }
.mark.upcoming { color: var(--txt); }
.more { color: var(--muted); font-size: 11px; font-weight: 400; }
.stream-form select, .stream-form input[type=text], .stream-form input[type=search] { width: 100%; }
.stream-form select { padding: 11px 13px; font: 16px/1.3 var(--font-ui); border-radius: var(--r-md);
  color: var(--txt); border: 1px solid var(--line-strong); background: var(--panel2); }
.stream-form .alert { margin: 12px 0 0; }
.field-text { margin: 14px 0 0; overflow-wrap: anywhere; }
.field-name { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
label.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin: 14px 0 0;
  font-size: 15px; color: var(--txt); }
label.check input { width: 20px; height: 20px; margin: 0; }
fieldset.move { border: 1px solid var(--line); border-radius: var(--r-md); margin: 18px 0 0; padding: 4px 14px 14px;
  min-width: 0; }
fieldset.move legend { color: var(--muted); font-size: 13px; padding: 0 6px; }
details > summary { list-style: none; display: inline-flex; align-items: center; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details form > .btn { width: auto; margin-top: 12px; }
ul.changes { margin: 8px 0 0; padding-left: 18px; }
ul.changes li { margin: 4px 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 12px 0 0; }
form.undo > .btn { width: auto; margin-top: 8px; }

/* Transactions, one transaction's panel, Rules, the lines form */
.strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 8px; }
.fig { display: flex; flex-direction: column; gap: 2px; margin: 0; min-width: 0; min-height: 44px; padding: 10px 12px;
  border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--panel2); color: var(--txt);
  text-decoration: none; overflow-wrap: anywhere; }
a.fig:hover .tile-label { text-decoration: underline; }
.fig-num { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.filter-grid > div { min-width: 0; }
.filter-more { margin-top: 14px; }
.filter-more > summary { margin-bottom: 2px; }
.filter-grid label { margin-top: 10px; }
.scopes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 16px; }
.scopes .btn { width: auto; }
.pager { align-items: center; justify-content: space-between; }
.own-rule { margin-top: 18px; }
li.rule { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; min-width: 0; }
li.rule .row-name { overflow-wrap: anywhere; }
.rule-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 6px; }
.rule-actions form { margin: 0; }
.rule-actions details[open] { flex-basis: 100%; }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) 5.5em; gap: 0 12px; }
.pair > div { min-width: 0; }
.line-edit { border-top: 1px solid var(--line); margin-top: 14px; }
.line-edit details { margin-top: 10px; }
ul.keys { margin: 8px 0 0; padding-left: 18px; font-size: 13px; overflow-wrap: anywhere; }
h3.group-h { font-size: 15px; font-weight: 650; margin: 18px 0 0; }

/* Budget: the month grid, its edit form. A Left figure is green at $0.00, red below zero, plain above. */
.bud .pos, .fig-num.pos { color: var(--pos); }
.bud .neg, .fig-num.neg { color: var(--neg); }
.strip.one { grid-template-columns: minmax(0, 16em); }
.bud-wrap { overflow-x: auto; margin-top: 8px; }
table.bud { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.bud th, table.bud td { padding: 6px 8px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
table.bud thead th { color: var(--muted); font-weight: 600; font-size: 12px; border-top: 0; white-space: nowrap; }
table.bud .amt { text-align: right; white-space: nowrap; }
table.bud .b-name { font-weight: 400; min-width: 9em; overflow-wrap: anywhere; }
table.bud .b-name .row-sub { display: block; }
table.bud tr.b-group > * { background: var(--panel2); font-weight: 650; }
table.bud tr.b-total > * { font-weight: 650; border-top: 2px solid var(--line-strong); }
table.bud .b-cell.empty, table.bud .b-left.empty { color: var(--muted); }
table.bud .due { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.plan-form .line-edit > .field-text:first-child { margin-top: 12px; }
.pair.wide { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.pair.duo { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.plan-form .duo select { padding-left: 10px; padding-right: 4px; }
.cells { display: flex; flex-wrap: wrap; gap: 0 10px; }
.cells .cell { flex: 1 1 7em; min-width: 0; max-width: 10em; }
details.fold { margin-top: 14px; }
details.fold > summary { margin-bottom: 2px; }
@media (max-width: 640px) {
  /* the grid as stacked blocks: the line's name and Left; Planned · Spent; the paycheck cells as chips */
  table.bud, table.bud tbody, table.bud tfoot { display: block; }
  table.bud thead { display: none; }
  table.bud tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 10px 0;
    border-top: 1px solid var(--line); }
  table.bud tr::before, table.bud tr::after { content: ""; flex-basis: 100%; height: 0; }
  table.bud tr::before { order: 3; }
  table.bud tr::after { order: 6; }
  table.bud th, table.bud td { display: block; padding: 0; border: 0; min-width: 0; }
  table.bud td:empty, table.bud .b-cell.empty, table.bud .b-left.empty { display: none; }
  table.bud .b-name { order: 1; flex: 1 1 0; min-width: 0; }
  table.bud .b-left { order: 2; font-weight: 650; }
  table.bud .b-plan { order: 4; }
  table.bud .b-spent { order: 5; }
  table.bud .b-plan, table.bud .b-spent { font-size: 13px; text-align: left; }
  table.bud .b-plan::before, table.bud .b-spent::before, table.bud .b-left::before {
    content: attr(data-label) " "; color: var(--muted); font-weight: 400; }
  table.bud .b-spent::before { content: "· " attr(data-label) " "; }
  table.bud .b-cell { order: 7; display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 5px;
    padding: 3px 9px; border: 1px solid var(--line-strong); border-radius: var(--r-pill); font-size: 13px; }
  table.bud .b-cell::before { content: attr(data-label); color: var(--muted); font-weight: 400; }
  table.bud .due { display: inline; font-size: 12px; }
  table.bud tr.b-group { padding: 8px 10px; margin-top: 12px; background: var(--panel2); border-radius: var(--r-md);
    border-top: 0; }
  table.bud tr.b-group > * { background: none; }
  table.bud tr.b-total { border-top: 2px solid var(--line-strong); }
  table.bud tr.b-total > * { border-top: 0; }
  table.bud tr.b-in.pay .b-cell { order: 2; padding: 0; border: 0; font-size: 14px; font-weight: 650; }
  table.bud tr.b-in.pay .b-cell::before { content: none; }
  .pair.wide:not(.duo) { grid-template-columns: 1fr; }
  .strip.one { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .tiles { grid-template-columns: 1fr; }
  .strip { grid-template-columns: 1fr; gap: 6px; }
  .strip .fig { flex-direction: row; justify-content: space-between; align-items: baseline; gap: 12px; }
  .filter-grid { grid-template-columns: 1fr; }
  .nav .who { display: none; }
  .nav .signout { margin-left: auto; }
}
td.when { white-space: nowrap; }
