/* The shared layout for every page and every theme.
   Colours, corners and shadows are variables; each theme file in
   static/themes/ sets them (and nothing else). Mobile first: one narrow column
   that also looks fine on a laptop. Every tap target is at least --tap tall. */

/* ---- defaults and the category palette ---- */
:root {
  --tap: 48px;
  --radius: 14px;
  --radius-small: 10px;
  --shadow: none;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* The category colours (app/categories.py PALETTE): 12 hues and their second
     shades, each in two versions:
     -dark is bright but not neon, for dark themes; -light is deeper, so it shows
     on white. A rainbow theme picks one set (--red: var(--red-dark), ...) and
     the text colour on it (--rainbow-ink). Checked for WCAG AA in the tests. */
  --red-dark: #ff6b6b;    --red-light: #c92a2a;
  --orange-dark: #ff9f43; --orange-light: #c2410c;
  --amber-dark: #ffc145;  --amber-light: #b45309;
  --yellow-dark: #f2e05a; --yellow-light: #a16207;
  --lime-dark: #b5e655;   --lime-light: #4d7c0f;
  --green-dark: #5fd38d;  --green-light: #15803d;
  --teal-dark: #3fd0c0;   --teal-light: #0f766e;
  --cyan-dark: #5cc8f0;   --cyan-light: #0e7490;
  --blue-dark: #6aa8ff;   --blue-light: #1d4ed8;
  --indigo-dark: #9a8cff; --indigo-light: #4338ca;
  --violet-dark: #c58bf2; --violet-light: #7e22ce;
  --pink-dark: #f487c0;   --pink-light: #be185d;
  /* Their second shades ("red-2"): paler on dark themes, darker on light ones. */
  --red-2-dark: #ffb4b4;  --red-2-light: #7f1d1d;
  --orange-2-dark: #ffcf9e;  --orange-2-light: #7c2d12;
  --amber-2-dark: #ffe0a1;  --amber-2-light: #78350f;
  --yellow-2-dark: #fff3b0;  --yellow-2-light: #713f12;
  --lime-2-dark: #dcf5a8;  --lime-2-light: #365314;
  --green-2-dark: #a9ecc3;  --green-2-light: #14532d;
  --teal-2-dark: #a3ece4;  --teal-2-light: #134e4a;
  --cyan-2-dark: #aee3f8;  --cyan-2-light: #164e63;
  --blue-2-dark: #b6d3ff;  --blue-2-light: #1e3a8a;
  --indigo-2-dark: #cdc6ff;  --indigo-2-light: #312e81;
  --violet-2-dark: #e2c3fa;  --violet-2-light: #581c87;
  --pink-2-dark: #fac3df;  --pink-2-light: #831843;
}

/* A category's colour: --c is its fill (chip, bar, chart line), --c-ink the
   text on it. Single-accent themes don't set --red etc., so --c falls back to
   their accent. --pick is the true hue, for the colour picker in Settings. */
.c-red    { --c: var(--red, var(--accent));    --pick: var(--red, var(--red-light)); }
.c-orange { --c: var(--orange, var(--accent)); --pick: var(--orange, var(--orange-light)); }
.c-amber  { --c: var(--amber, var(--accent));  --pick: var(--amber, var(--amber-light)); }
.c-yellow { --c: var(--yellow, var(--accent)); --pick: var(--yellow, var(--yellow-light)); }
.c-lime   { --c: var(--lime, var(--accent));   --pick: var(--lime, var(--lime-light)); }
.c-green  { --c: var(--green, var(--accent));  --pick: var(--green, var(--green-light)); }
.c-teal   { --c: var(--teal, var(--accent));   --pick: var(--teal, var(--teal-light)); }
.c-cyan   { --c: var(--cyan, var(--accent));   --pick: var(--cyan, var(--cyan-light)); }
.c-blue   { --c: var(--blue, var(--accent));   --pick: var(--blue, var(--blue-light)); }
.c-indigo { --c: var(--indigo, var(--accent)); --pick: var(--indigo, var(--indigo-light)); }
.c-violet { --c: var(--violet, var(--accent)); --pick: var(--violet, var(--violet-light)); }
.c-pink   { --c: var(--pink, var(--accent));   --pick: var(--pink, var(--pink-light)); }
.c-red-2 { --c: var(--red-2, var(--accent)); --pick: var(--red-2, var(--red-2-light)); }
.c-orange-2 { --c: var(--orange-2, var(--accent)); --pick: var(--orange-2, var(--orange-2-light)); }
.c-amber-2 { --c: var(--amber-2, var(--accent)); --pick: var(--amber-2, var(--amber-2-light)); }
.c-yellow-2 { --c: var(--yellow-2, var(--accent)); --pick: var(--yellow-2, var(--yellow-2-light)); }
.c-lime-2 { --c: var(--lime-2, var(--accent)); --pick: var(--lime-2, var(--lime-2-light)); }
.c-green-2 { --c: var(--green-2, var(--accent)); --pick: var(--green-2, var(--green-2-light)); }
.c-teal-2 { --c: var(--teal-2, var(--accent)); --pick: var(--teal-2, var(--teal-2-light)); }
.c-cyan-2 { --c: var(--cyan-2, var(--accent)); --pick: var(--cyan-2, var(--cyan-2-light)); }
.c-blue-2 { --c: var(--blue-2, var(--accent)); --pick: var(--blue-2, var(--blue-2-light)); }
.c-indigo-2 { --c: var(--indigo-2, var(--accent)); --pick: var(--indigo-2, var(--indigo-2-light)); }
.c-violet-2 { --c: var(--violet-2, var(--accent)); --pick: var(--violet-2, var(--violet-2-light)); }
.c-pink-2 { --c: var(--pink-2, var(--accent)); --pick: var(--pink-2, var(--pink-2-light)); }
/* Not categorised yet, and special categories (Owed by people): always grey. */
.c-none { --c: var(--grey); --c-ink: var(--grey-ink); --bar-fill: var(--grey); --pick: var(--grey); }

/* ---- page ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}
main { max-width: 36rem; margin: 0 auto; padding: 1rem 1rem 2.5rem; }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.15rem; margin-top: 1.75rem; }
h3 { font-size: 1rem; margin-top: 1.25rem; }
a { color: var(--link, var(--accent)); }
small, .muted { color: var(--muted); }
code { overflow-wrap: anywhere; }
.small-text { font-size: 0.85rem; margin: 0.3rem 0; }
.error { color: var(--danger-text, var(--danger)); }
.warning, .status-warning { color: var(--warn); }
.status-ok { color: var(--ok); }
.status-mismatch { color: var(--danger-text, var(--danger)); }
.status-undone { color: var(--muted); }

/* ---- header: name, Personal/Business switch, menu ---- */
header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.25rem 1rem;
  /* Stage B: from the home screen the page starts under the iPhone status bar
     (black-translucent); the safe-area insets keep the name and switch below
     it and clear of a notch. They are 0 in a normal browser tab. */
  padding: calc(0.5rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right))
           0.6rem calc(1rem + env(safe-area-inset-left));
  background-color: var(--header-bg, var(--surface));
  border-bottom: 1px solid var(--line);
  /* Rainbow themes draw a thin stripe along the bottom (--header-stripe). */
  background-image: var(--header-stripe, none);
  background-size: 100% 4px;
  background-repeat: no-repeat;
  background-position: bottom;
}
header form { margin: 0; }
header a.brand { color: var(--text); text-decoration: none; font-size: 1.15rem; gap: 0.55rem;
                 min-height: var(--tap); display: inline-flex; align-items: center; }
.brand-icon { width: 32px; height: 32px; border-radius: 8px; flex: none; }
.switch { display: flex; border: 1px solid var(--accent); border-radius: 999px; overflow: hidden; }
.switch button {
  min-height: var(--tap);
  padding: 0 0.9rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--accent-text, var(--accent));
  font-size: 0.95rem;
}
.switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ---- forms, fields and buttons ---- */
.stack { display: flex; flex-direction: column; gap: 1rem; }
label { display: flex; flex-direction: column; gap: 0.3rem; color: var(--muted); }
input, textarea, select {
  font: inherit;
  font-size: 1rem;             /* 16 px: phones don't zoom in on fields */
  min-height: var(--tap);
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--field-border, var(--muted));
  border-radius: var(--field-radius, var(--radius-small));
  background: var(--field-bg, var(--bg));
  color: var(--text);
  max-width: 100%;
}
/* v0.2-6: a placeholder is a quiet hint, never data: dimmer than any typed value on every
   theme, so an empty field reads as empty. */
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.55; }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 1.25rem; height: 1.25rem;
                                               accent-color: var(--accent); flex: none; }
input[type="file"] { padding: 0.6rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 1px; }
label.inline { flex-direction: row; align-items: center; gap: 0.6rem; min-height: var(--tap); color: var(--text); }

button {
  font: inherit;
  font-weight: 600;
  min-height: var(--tap);
  padding: 0 1.1rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-small);
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}
button:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 3px solid var(--text); outline-offset: 2px; }
button.secondary { background: transparent; color: var(--accent-text, var(--accent)); }
button.danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); margin: 1rem 0; }
button.warn { background: var(--warn); border-color: var(--warn); color: var(--on-warn, var(--bg)); }
button.small { font-size: 0.9rem; padding: 0 0.9rem; margin: 0; }
button.link { background: none; border: 0; color: var(--link, var(--accent)); padding: 0; font-weight: normal; }
.inline-form { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 0.5rem; }

/* Small "open/close" details inside a row (Edit, Show lines, Rename ...). */
details summary { color: var(--link, var(--accent)); cursor: pointer; min-height: var(--tap);
                  display: flex; align-items: center; }

/* ---- cards and rows ---- */
.card { background: var(--surface); border-radius: var(--radius); padding: 0.9rem 1rem;
        margin: 1rem 0; box-shadow: var(--shadow); border: var(--card-border, 0); }
.card h2 { margin-top: 0.25rem; font-size: 1.05rem; word-break: break-word; }
.rows { list-style: none; padding: 0; margin: 0; }
.rows li { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.rows li:last-child { border-bottom: 0; }
.rows small { display: block; }
.rows details { margin-top: 0.25rem; font-size: 0.95rem; }

.warnings { border-left: 4px solid var(--danger); padding: 0.25rem 0.75rem; margin: 1rem 0; }
.warnings h3 { margin: 0.25rem 0; color: var(--danger-text, var(--danger)); }
.warnings ul { padding-left: 1.1rem; margin: 0.25rem 0; }
/* C-44: a statement read by the universal reader: an amber edge, not an error. */
.universal-notice { border-left: 4px solid var(--warn); padding: 0.1rem 0.75rem; margin: 0.5rem 0; }
.universal-notice p { margin: 0.25rem 0; }

dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 1rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.35rem 0.45rem; border-bottom: 1px solid var(--line); }
td { font-variant-numeric: tabular-nums; }

/* ---- lists of lines (transactions, import check, review, receipts) ---- */
.lines { list-style: none; padding: 0; margin: 0; }
.lines li { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
/* v0.2-2: "Show all N rows" under a long Transactions list. */
.show-all { margin: 1rem 0; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.lines li:last-child { border-bottom: 0; }
.line-main { display: flex; gap: 0.6rem; align-items: baseline; }
.line-main .date { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.line-main .payee { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.line-main .raw { display: block; font-size: 0.75rem; }
.line-main .date-kind { display: block; font-size: 0.7rem; }
.line-main .amount, .amount { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.line-extra { display: flex; gap: 0.3rem 1rem; align-items: center; flex-wrap: wrap; font-size: 0.85rem; margin-top: 0.3rem; }
.category { color: var(--muted); }
.category.review { color: var(--warn); }
.tx .line-extra { justify-content: space-between; }
.tx .date { color: var(--muted); }
.tx details { margin-top: 0.3rem; font-size: 0.95rem; }
.just-saved { background: var(--highlight, var(--surface)); }
.note { display: block; color: var(--text); font-style: italic; overflow-wrap: anywhere; }
.note-marker { font-weight: 600; font-style: normal; color: var(--accent-text, var(--accent)); }
/* One link per line instead of its forms: a big enough tap. */
.change-link, .rename-link { display: inline-flex; align-items: center; min-height: var(--tap); }
.rename-link { margin-left: 0.9rem; }
form.undo { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
form.undo small { display: block; margin-top: 0.4rem; }

/* ---- category chips and bars ---- */
/* Rainbow themes: a filled pill in the category's colour. Single-accent themes
   set --chip-fill: transparent, so the chip is just its name. */
.chip {
  display: inline-block;
  max-width: 100%;
  padding: var(--chip-pad, 0.1rem 0.65rem);
  border-radius: 999px;
  background: var(--chip-fill, var(--c));
  color: var(--chip-ink, var(--c-ink, var(--rainbow-ink, var(--on-accent))));
  font-weight: 600;
  overflow-wrap: anywhere;
}
.category .chip { font-size: 0.85rem; }
.bar { height: 8px; margin-top: 0.4rem; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 999px; background: var(--bar-fill, var(--c)); }

/* ---- view tabs and period picker ---- */
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0 1rem; }
.tabs a {
  display: inline-flex; align-items: center; min-height: var(--tap);
  padding: 0 1rem; border: 1px solid var(--line); border-radius: 999px;
  text-decoration: none; white-space: nowrap; color: var(--text);
}
.tabs a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.period { margin: 0.5rem 0 1rem; }
.period-nav { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin: 0.5rem 0; }
.period-nav a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 0.5rem;
                white-space: nowrap; text-decoration: none; font-weight: 600; }
.period-form, .filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end; }
.period-form label, .filters label { flex: 1 1 8rem; min-width: 0; font-size: 0.85rem; }
.period-form input, .period-form select, .filters input, .filters select { width: 100%; }
.filters { margin-bottom: 1rem; }
/* Period / From / To (owner 2026-11-05): at 390px wide they wrap onto two rows
   and Show goes below them; nothing scrolls sideways. */
.date-controls label { flex: 1 1 6.2rem; }
.date-controls .period-choice { flex: 1 1 5.6rem; }
.date-controls .column-count { flex: 0 1 4.5rem; }
.date-controls > button { flex: 0 0 auto; }
/* From and To (owner 2026-11-05): a calendar icon inside the right end of the
   text field, with a real type="date" field laid exactly over it: the same
   44 x 44 box, on top, opacity 0 (never display:none, visibility:hidden or no
   size, or a tap wouldn't reach it). The tap lands on the date field, so the
   browser opens its own picker. Both show only when app.js runs (.js-dates). */
.date-controls .date-label { flex: 1 1 8.75rem; }
.date-field { position: relative; display: block; }
.date-pick, .date-field .date-native { display: none; }
.js-dates .date-field input:not(.date-native) { padding-right: 2.9rem; }
.js-dates .date-pick {
  display: inline-flex; align-items: center; justify-content: center;
  position: absolute; top: 50%; right: 2px; transform: translateY(-50%);
  width: 44px; height: 44px; pointer-events: none; color: var(--accent); z-index: 1;
}
.js-dates .date-field .date-native {
  display: block; position: absolute; top: 50%; right: 2px; transform: translateY(-50%);
  width: 44px; height: 44px; min-width: 0; min-height: 0; margin: 0; padding: 0;
  border: 0; border-radius: var(--radius-small); background: transparent; color: transparent;
  opacity: 0; z-index: 2; cursor: pointer;
  -webkit-appearance: none; appearance: none;
}
/* Desktop Chrome opens the picker only from its own little icon: stretch that
   icon over the whole box, so a click anywhere on it opens the picker too. */
.date-field .date-native::-webkit-calendar-picker-indicator {
  position: absolute; inset: 0; width: auto; height: auto; margin: 0; padding: 0; cursor: pointer; }
/* Keyboard focus on the (invisible) date field shows on the icon. */
.date-field .date-native:focus-visible + .date-pick { outline: 3px solid var(--text); outline-offset: -3px;
                                                       border-radius: var(--radius-small); }
.period-nav strong { text-align: center; min-width: 0; overflow-wrap: anywhere; }
/* Next › on Trends / % share when it would pass today's period. */
.period-nav .period-end { display: inline-flex; align-items: center; min-height: var(--tap);
                          padding: 0 0.5rem; white-space: nowrap; font-weight: 600; opacity: 0.5; }
/* The search box takes the whole row; the category filter and Show go below it. */
.search-form .search-box { flex: 1 1 100%; }
.result-line { overflow-wrap: anywhere; }

/* ---- Summary ---- */
.total-card { background: var(--total-bg, var(--surface)); border-radius: var(--radius);
              padding: var(--total-pad, 1.1rem 1.2rem); margin: 1rem 0; box-shadow: var(--shadow);
              border: var(--card-border, 0); }
.total-card p { margin: 0.2rem 0; }
.big { font-size: 2.6rem; line-height: 1.1; font-weight: 800; letter-spacing: -0.02em;
       font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--total-text, var(--text)); }
.figures { list-style: none; padding: 0; margin: 0; }
.figures li { padding: 0.65rem 0; border-bottom: 1px solid var(--line); }
.figures li:last-child { border-bottom: 0; }
.figures .line-main { align-items: center; }
.figures .line-extra { gap: 0.2rem 1rem; color: var(--muted); }
.figures li.sum { font-weight: 600; }

/* Wide tables scroll sideways inside their box, never the whole page. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0.5rem 0; }
.table-scroll table { width: auto; min-width: 100%; }
.table-scroll th, .table-scroll td { white-space: nowrap; }
.num { text-align: right; }
table.over-time tbody th, table.over-time tfoot th { font-weight: normal; position: sticky; left: 0; background: var(--bg); }
table.over-time tfoot th, table.over-time tfoot td { font-weight: 600; }

/* ---- trend chart (SVG drawn on the server) ---- */
.chart { margin: 0.5rem 0 1rem; }
.chart svg { width: 100%; height: 180px; display: block; border-bottom: 1px solid var(--line); }
.chart rect.bar-total { fill: var(--chart-bar); }
/* Lines: single-accent themes colour them by order (--series-0 ... 5);
   rainbow themes leave those unset, so each line is its category's colour. */
.series-0 { --line-colour: var(--series-0, var(--c)); }
.series-1 { --line-colour: var(--series-1, var(--c)); }
.series-2 { --line-colour: var(--series-2, var(--c)); }
.series-3 { --line-colour: var(--series-3, var(--c)); }
.series-4 { --line-colour: var(--series-4, var(--c)); }
.series-5 { --line-colour: var(--series-5, var(--c)); }
.chart polyline { stroke: var(--line-colour, var(--c)); }
.chart figcaption { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-top: 0.4rem; }
.swatch { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 3px; margin-right: 0.3rem;
          vertical-align: -0.1rem; background: var(--line-colour, var(--c)); }
.bar-swatch { background: var(--chart-bar); }
/* Labels under the chart: one equal cell per bar; they never widen the page. */
.chart-labels { display: grid; font-size: 0.7rem; color: var(--muted); text-align: center; margin-top: 0.15rem; }
.chart-labels span { min-width: 0; overflow: hidden; white-space: nowrap; }

/* ---- collapsible sections (design pass B) ---- */
/* <details class="section">: a full-width header with the name and count, and
   an arrow that points right when closed and down when open. No JavaScript. */
details.section { margin: 1rem 0; background: var(--surface); border-radius: var(--radius);
                  box-shadow: var(--shadow); border: var(--card-border, 0); }
a.section-row,
details.section > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--tap);
  padding: 0.6rem 1rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.05rem;
}
details.section > summary::-webkit-details-marker { display: none; }
a.section-row::after,
details.section > summary::after {
  content: "";
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  border-right: 2.5px solid var(--accent-text, var(--accent));
  border-bottom: 2.5px solid var(--accent-text, var(--accent));
  transform: rotate(-45deg);
  margin-right: 0.25rem;
}
details.section[open] > summary::after { transform: rotate(45deg); margin-top: -0.3rem; }
details.section[open] > summary { border-bottom: 1px solid var(--line); }
.section-body { padding: 0.25rem 1rem 1rem; }
.section-body > h2:first-child, .section-body > p:first-child { margin-top: 0.5rem; }
/* A section inside a section (Categories → Personal / Business). */
.section-body details.section { margin: 0.75rem 0 0; background: var(--bg); box-shadow: none; }
.section-body details.section > summary { font-size: 1rem; }
/* v0.2-4: a row inside a section that opens a page (Settings > More settings). It shares
   the section header's own rules above (height, weight, the accent arrow) and the card of
   a section inside a section; being a link, its arrow always points right. */
a.section-row { margin: 0.75rem 0 0; background: var(--bg); border-radius: var(--radius);
                border: var(--card-border, 0); font-size: 1rem; text-decoration: none; }
a.section-row > span { min-width: 0; overflow-wrap: anywhere; }
a.section-row small { display: block; font-weight: 400; }
/* v0.2-6: a link row at the top level of Settings (People) looks exactly like the
   collapsible sections around it: the same card, height, bold title and accent arrow. */
a.section-row.settings-row { margin: 1rem 0; background: var(--surface); box-shadow: var(--shadow);
                             border: var(--card-border, 0); font-size: 1.05rem; }
/* v0.2-6: the one sentence at the top of an opened section saying what it is for. */
.section-explain { margin: 0.6rem 0 0.4rem; }

/* ---- review list ---- */
.groups { list-style: none; padding: 0; margin: 0; }
.groups > li { padding: 0.9rem 0; border-bottom: 1px solid var(--line); }
.groups > li:last-child { border-bottom: 0; }
.group .line-main .payee { font-weight: 600; }
.group .line-main .raw { font-weight: normal; }
.group .amount { text-align: right; }
.group .amount .count { display: block; font-size: 0.75rem; font-weight: normal; }
.group .amount .date-range { white-space: nowrap; }
/* "Saved. Undo" after a Review save, and Recently saved (owner 2026-11-09). */
.saved-undo { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between;
              flex-wrap: wrap; margin: 0.5rem 0; }
.saved-undo > span { min-width: 0; overflow-wrap: anywhere; }
.rows.recent-saves .row-line small { display: block; }
.group .lines .payee { font-weight: normal; }
.rate-form { border-top: 1px solid var(--line); padding-top: 0.5rem; }
.rate-day { border-top: 1px solid var(--line); padding: 0.25rem 0; }
/* Rule fields appear only when "Also save as a rule" is ticked (pure CSS). */
.rule-box { display: grid; grid-template-columns: auto 1fr; gap: 0.5rem; align-items: center; }
.rule-box > label { color: var(--text); min-height: var(--tap); justify-content: center; }
.rule-fields { grid-column: 1 / -1; display: none; flex-direction: column; gap: 0.5rem; }
.rule-toggle:checked ~ .rule-fields { display: flex; }
.receipt-question { border-top: 1px solid var(--line); padding-top: 0.5rem; margin-top: 0.75rem; }
.receipt-question:first-of-type { border-top: 0; margin-top: 0; }
.receipt-question h3 { margin: 0.25rem 0; overflow-wrap: anywhere; }
fieldset.choices { border: 0; margin: 0; padding: 0; }
/* One choice per row; the whole row is the tap target. */
label.choice { flex-direction: row; align-items: flex-start; gap: 0.6rem; color: var(--text);
               padding: 0.75rem 0; min-height: var(--tap); border-bottom: 1px solid var(--line); cursor: pointer; }
label.choice input { margin-top: 0.15rem; }
label.choice span { min-width: 0; overflow-wrap: anywhere; }
label.choice small { display: block; }
.choice-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.choice-buttons .reason { flex-basis: 100%; }

/* ---- receipts ---- */
.receipt-photo { margin: 0 0 1rem; }
/* The photo never makes the page wider than the phone; tall receipts scroll. */
.receipt-photo img { display: block; max-width: 100%; max-height: 70vh; height: auto;
                     border: 1px solid var(--line); border-radius: var(--radius-small); }
.receipt-photo figcaption { margin-top: 0.35rem; overflow-wrap: anywhere; }
.line-forms .inline-form + .inline-form { margin-top: 0.75rem; border-top: 1px solid var(--line); padding-top: 0.75rem; }

/* ---- settings: theme and colour pickers ---- */
.picker { border: 0; margin: 0.5rem 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem;
          /* C-58: a wrapping flex box stretches its lines to fill a taller box (align-content's
             default); iOS Safari gave the fieldset the form's height after a save's reload, so
             each pill grew into a tall oval. Lines and pills keep their own height. */
          align-content: flex-start; align-items: center; }
.picker > label { flex: none; }
.inline-form > fieldset { flex: none; min-width: 0; }
.picker legend { color: var(--muted); margin-bottom: 0.3rem; padding: 0; }
.picker label { flex-direction: row; align-items: center; gap: 0.5rem; min-height: var(--tap);
                padding: 0 0.75rem; border: 1px solid var(--line); border-radius: 999px; color: var(--text); }
.picker label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.picker.themes { flex-direction: column; align-items: stretch; }
.picker.themes label { border-radius: var(--radius-small); }
.dot { display: inline-block; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--pick);
       box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.5); flex: none; }
/* The colour picker: one round 48 px swatch per colour; the name is there for
   screen readers. The radio itself is hidden but still takes the keyboard. */
.picker.swatches { gap: 0.35rem; }
.picker.swatches label { position: relative; width: var(--tap); padding: 0; justify-content: center; border-radius: 50%; }
.picker.swatches input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.picker.swatches .dot { width: 2rem; height: 2rem; }
.picker.swatches label:has(input:checked) { border: 3px solid var(--text); box-shadow: none; }
.picker.swatches label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* A very narrow phone (320 px): smaller total and tighter header. */
@media (max-width: 360px) {
  .big { font-size: 2.1rem; }
  .switch button { padding: 0 0.7rem; font-size: 0.9rem; }
}

/* Mercado Pago screenshots (Step C): the image next to its rows on wide
   screens, above them on a phone. */
.shot-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 900px) { .shot-grid { grid-template-columns: minmax(200px, 320px) 1fr; } }
.shot-image { width: 100%; max-height: 80vh; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; }
.shot-table input { min-width: 0; padding: 0.3rem; font-size: 0.9rem; }
.shot-table input[type="checkbox"] { width: auto; }
.row-problem td { background: var(--warning-bg, rgba(255, 170, 0, 0.15)); }

/* ---- Taking / choosing a photo (owner 2026-11-05) ---- */
/* Each button is a label wrapping its file input: the input is invisible but
   still there (not display:none), so a tap on the button opens it everywhere. */
.photo-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.photo-button {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  flex: 1 1 10rem; min-height: var(--tap); padding: 0 1.1rem;
  border: 1px solid var(--accent); border-radius: var(--radius-small);
  background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer;
}
.photo-button.secondary { background: transparent; color: var(--accent-text, var(--accent)); }
.photo-button span { text-align: center; }
.photo-button .photo-input { position: absolute; inset: 0; width: 100%; height: 100%;
                             opacity: 0; cursor: pointer; min-height: 0; padding: 0; border: 0; }
.photo-button:focus-within { outline: 3px solid var(--text); outline-offset: 2px; }
.photo-preview { display: block; max-width: 100%; max-height: 40vh; height: auto;
                 border-radius: var(--radius-small); }
.photo-preview[hidden] { display: none; }
.camera-hint[hidden] { display: none; }
/* "Reading receipt…" with a spinner while the photo is read. */
.reading-status { display: flex; align-items: center; gap: 0.6rem; font-weight: 600; margin: 0; }
.reading-status[hidden] { display: none; }
.spinner { width: 1.2rem; height: 1.2rem; border-radius: 50%; flex: 0 0 auto;
           border: 3px solid var(--line); border-top-color: var(--accent);
           animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
button[disabled] { opacity: 0.6; cursor: wait; }
/* Slow buttons (app.js, owner 2026-11-06): the status sits on its own line under
   the pressed button or its row, also inside a row of buttons. */
.busy-status, .busy-error { flex-basis: 100%; margin: 0.5rem 0 0; }
.busy-error[hidden] { display: none; }

/* Many statements at once: the check page (bulk_check.html, owner 2026-11-06).
   Made for a 390px phone: long file names wrap, each file is one card, the
   status is a small coloured label, the lines open on demand. */
.bulk-name { overflow-wrap: anywhere; }
.bulk-tick { display: flex; gap: 0.5rem; align-items: flex-start; }
.bulk-tick input { margin-top: 0.2rem; flex: none; }
.bulk-status { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px;
               border: 1px solid currentColor; font-size: 0.85rem; margin-right: 0.25rem; }
.bulk-status.bulk-ok { color: var(--ok); }
.bulk-status.bulk-warning { color: var(--warn); }
.bulk-status.bulk-skipped { color: var(--muted); }
.bulk-status.bulk-failed { color: var(--danger-text, var(--danger)); }
.bulk-file.bulk-skipped { opacity: 0.8; }
.bulk-lines li { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; font-size: 0.9rem; }
.bulk-lines .bulk-desc { flex: 1 1 10rem; overflow-wrap: anywhere; }
.bulk-lines .amount { margin-left: auto; white-space: nowrap; }
.bulk-actions { position: sticky; bottom: 0; display: flex; gap: 0.5rem; flex-wrap: wrap;
                padding: 0.75rem 0; background: var(--bg); }
.bulk-actions button { flex: 1 1 8rem; }

/* Many receipt photos at once (owner 2026-11-06): the camera's "Add another
   page" / "Save and add another", and the check page's cards (receipt_batch.html).
   Made for a 390px phone: thumbnails side by side, buttons wrap, 44px+ to tap. */
.camera-panel { border: 1px dashed var(--line); border-radius: var(--radius-small); padding: 0.6rem; }
.camera-panel[hidden] { display: none; }
.camera-panel button { flex: 1 1 10rem; min-height: var(--tap); }
[data-batch-errors] { margin: 0; padding-left: 1.2rem; }
[data-batch-errors][hidden] { display: none; }
.batch-pages { list-style: none; padding: 0; margin: 0;
               display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 0.75rem; }
.batch-page { border: 1px solid var(--line); border-radius: var(--radius-small); padding: 0.4rem; min-width: 0; }
/* C-03 item 8: each photo has a fixed box (the link is a block as wide as the
   card, the picture a set height), so the page doesn't grow as the lazy-loaded
   photos arrive. Before, a block picture inside an inline link was wider than
   its box and had no height until it loaded: the Save button moved after
   WebKit scrolled to it, and a tap landed where it had been (the timeout). */
.batch-page > a { display: block; min-width: 0; }
.batch-page img { display: block; width: 100%; height: 14rem; object-fit: contain; background: var(--bg); }
.batch-page p { margin: 0.3rem 0; overflow-wrap: anywhere; }
.batch-buttons { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: flex-end; margin: 0.35rem 0; }
.batch-buttons button, .batch-move button { min-height: var(--tap); }
.batch-move { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: flex-end; }
.batch-move label { flex: 1 1 6rem; min-width: 0; }
.batch-move select, .batch-buttons select { min-height: var(--tap); max-width: 100%; }

/* Accounts: a card with a peso side and a dollar side (owner 2026-11-06). */
.card-sides .sides { list-style: none; margin: 0.35rem 0 0; padding: 0 0 0 0.75rem;
                     border-left: 3px solid var(--line); }
.card-sides .sides li { padding: 0.15rem 0; }
.side-label { display: inline-block; min-width: 4.5rem; font-size: 0.85em; font-weight: 600; }
.preview-examples { margin: 0.2rem 0 0; padding-left: 1.1rem; overflow-wrap: anywhere; }

/* ==== Stage B (owner 2026-11-07): tabs, buttons, compact rows, wide screens ==== */

/* ---- the six tabs: a bar fixed to the bottom on phones, tabs on a desktop ---- */
.tabbar { display: flex; background: var(--header-bg, var(--surface)); }
.tabbar .tab {
  flex: 1 1 0; min-width: 0; min-height: var(--tap);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 0.72rem; font-weight: 600;
}
.tab-icon { position: relative; display: inline-flex; padding: 3px 14px; border-radius: 999px; }
.tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabbar .tab[aria-current="page"] { color: var(--accent-text, var(--accent)); }
.tabbar .tab[aria-current="page"] .tab-icon { background: var(--accent); color: var(--on-accent); }
.tabbar .tab:focus-visible { outline: 3px solid var(--text); outline-offset: -3px; }
/* The count on Review: how many things wait for a decision. */
.badge {
  position: absolute; top: -5px; right: 0; min-width: 1.2rem; height: 1.2rem; padding: 0 0.3rem;
  border-radius: 999px; background: var(--danger); color: var(--on-danger);
  font-size: 0.7rem; line-height: 1.2rem; font-weight: 700; text-align: center;
  box-shadow: 0 0 0 2px var(--header-bg, var(--surface));
}
@media (max-width: 767px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    border-top: 1px solid var(--line);
    /* Clear of the iPhone's home bar and of a notch in landscape. */
    padding: 4px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .tabbar .tab { min-height: 56px; }
  /* C-47: seven tabs (Zero on). Equal widths would leave about 55px each at 390px,
     too narrow for "Transactions". So each tab starts from its own width (its words or
     its pill) and the room left is shared out: "Add" and "Zero" give some to
     "Transactions", and every label stays whole on one line. A narrower pill and
     slightly smaller words; the six-tab bar keeps the sizes above. */
  .tabbar-seven .tab { flex: 1 1 auto; font-size: 0.68rem; }
  .tabbar-seven .tab-icon { padding: 3px 10px; }
  /* Room under the page, so the bar never covers its last lines or buttons. */
  .tabbar ~ main { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }
  .tabbar ~ main .bulk-actions { bottom: calc(64px + env(safe-area-inset-bottom)); }
}
@media (min-width: 768px) {
  .tabbar { justify-content: center; gap: 0.25rem; padding: 0 1rem; border-bottom: 1px solid var(--line); }
  .tabbar .tab { flex: 0 0 auto; flex-direction: row; gap: 0.5rem; padding: 0 1rem; min-height: 52px;
                 font-size: 0.95rem; border-bottom: 3px solid transparent; margin-bottom: -1px; }
  .tabbar .tab[aria-current="page"] { border-bottom-color: var(--accent); }
  .tab-icon { padding: 0; }
  .tabbar .tab[aria-current="page"] .tab-icon { background: none; color: inherit; }
  .badge { position: static; margin-left: 0.35rem; box-shadow: none; }
  /* Use the width: pages get wider; forms keep a readable width. */
  main { max-width: 72rem; padding-left: 2rem; padding-right: 2rem; }
  .stack, .inline-form { max-width: 40rem; }
  .cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 2rem; align-items: start; }
  .cols-wide-left { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}
main { padding-left: calc(1rem + env(safe-area-inset-left)); padding-right: calc(1rem + env(safe-area-inset-right)); }

/* ---- buttons: one style everywhere ----
   Primary: filled with the accent (a plain <button>). Secondary: outlined
   (.secondary). Small, for lists (.small). A link or a details summary that
   acts as a button gets .btn (with .secondary / .small as well). */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: var(--tap); padding: 0 1.1rem; border: 1px solid var(--accent);
  border-radius: var(--radius-small); background: var(--accent); color: var(--on-accent);
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn.secondary, details > summary.btn { background: transparent; color: var(--accent-text, var(--accent)); }
.btn.small, button.small { min-height: 40px; font-size: 0.9rem; padding: 0 0.85rem; }
details > summary.btn { list-style: none; }
details > summary.btn::-webkit-details-marker { display: none; }
details[open] > summary.btn { background: var(--accent); color: var(--on-accent); }
.button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0.75rem 0; }

/* ---- compact rows: the words on the left, the action on the right ----
   <li class="row-with-action"> … <details class="row-action"><summary class="btn small">Edit</summary>
   … the form opens under the row, the full width. */
.row-with-action { position: relative; padding-right: 5.5rem !important; min-height: calc(var(--tap) + 0.5rem); }
.row-with-action > .row-action > summary { position: absolute; top: 0.45rem; right: 0; min-height: 40px; }
.row-with-action > .row-action[open] { margin-right: -5.5rem; }
.row-with-action > .row-action > *:not(summary) { margin-top: 0.75rem; }
.row-with-action > .row-action { margin: 0; }
.row-line { display: flex; gap: 0.75rem; align-items: center; justify-content: space-between; }
.row-line > :first-child { min-width: 0; overflow-wrap: anywhere; }
.row-line > :last-child { flex: none; }

/* ---- charts (Stage B): bars in the accent, never grey ---- */
.chart rect.bar-total { fill: var(--accent); }

/* ---- small shared bits ---- */
.count-pill { display: inline-block; min-width: 1.5rem; padding: 0 0.45rem; border-radius: 999px;
              background: var(--accent); color: var(--on-accent); font-size: 0.8rem; font-weight: 700;
              text-align: center; line-height: 1.5rem; }
.compact li { padding: 0.35rem 0; }
.rows .row-line small { display: inline; }
.rule-row small { display: inline; }
.link-rows { padding: 0 1rem; }
.link-rows a { color: var(--text); text-decoration: none; min-height: var(--tap); }
.logout-form { margin: 1.5rem 0; }
.brand-icon.small { width: 24px; height: 24px; border-radius: 6px; vertical-align: middle; }
.about-name { display: flex; justify-content: flex-end; align-items: center; gap: 0.4rem; }
.filter-chip-row { margin: 0 0 0.75rem; }
.filter-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0 0 0 0.8rem;
               border: 1px solid var(--accent); border-radius: 999px; color: var(--accent-text, var(--accent)); }
.chip-close { display: inline-flex; align-items: center; justify-content: center; width: 40px; min-height: 40px;
              text-decoration: none; color: inherit; }
.subtabs { margin-top: 0; }
.view-tabs { gap: 0.4rem; flex-wrap: nowrap; }
.view-tabs a { flex: 1 1 0; justify-content: center; padding: 0 0.5rem; font-size: 0.9rem; min-width: 0; }
.tabs.chips a { min-height: 40px; font-size: 0.9rem; }

/* ---- Review: the list of what waits, and rows that need an action ---- */
.review-index { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1rem; }
.index-chip { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 40px; padding: 0 0.4rem 0 0.85rem;
              border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
              color: var(--text); text-decoration: none; font-size: 0.9rem; }
.attention-row { padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
.attention-row:last-child { border-bottom: 0; }
.card.inner { background: var(--bg); box-shadow: none; }
.all-done { font-weight: 600; }

/* ---- Add: drop zone and paste box ---- */
.add-card h2 { margin-top: 0.25rem; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 0.9rem;
            display: flex; flex-direction: column; gap: 0.6rem; }
.dropzone.dragging { border-color: var(--accent); background: var(--highlight, var(--surface)); }
.dropzone .photo-button { flex: 0 0 auto; }
.drop-hint { margin: 0; text-align: center; }
.paste-box { display: none; align-items: center; justify-content: center; min-height: var(--tap);
             border: 1px solid var(--line); border-radius: var(--radius-small); color: var(--muted);
             font-size: 0.9rem; cursor: text; }
.paste-box:focus { outline: 3px solid var(--accent); outline-offset: 1px; color: var(--text); }
@media (min-width: 768px) { .paste-box { display: flex; } }
.dropzone form.stack { max-width: none; }

/* ---- Accounts: cards like a bank app ---- */
.group-title { font-size: 1rem; color: var(--muted); margin: 1.5rem 0 0.5rem; }
.account-cards { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 768px) { .account-cards { grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); } }
.account-card { background: var(--surface); border-radius: var(--radius); padding: 0.85rem 0.9rem;
                box-shadow: var(--shadow); border: var(--card-border, 0); min-width: 0; }
.account-card.archived { opacity: 0.6; }
/* C-53: the whole card opens its statements. The name's link stretches over the card (no
   script needed); Edit and each currency box sit above it and keep their own links. */
.account-card { position: relative; }
.account-card .card-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; z-index: 0; }
.account-card .account-head .btn, .account-card .account-side { position: relative; z-index: 1; }
.account-card:has(.card-link:active) { filter: brightness(0.96); }
.card-open { flex: none; font-size: 0.8rem; white-space: nowrap; }
.account-head { display: flex; gap: 0.7rem; align-items: center; }
.bank-badge { flex: none; width: 2.6rem; height: 2.6rem; border-radius: 12px; display: inline-flex;
              align-items: center; justify-content: center; font-weight: 800; font-size: 1.15rem;
              background: var(--c); color: var(--c-ink, var(--rainbow-ink, var(--on-accent))); }
.account-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.account-name { color: var(--text); font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.account-title small { overflow-wrap: anywhere; }
.account-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.5rem; margin-top: 0.7rem; }
.account-side { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.55rem 0.7rem; min-height: var(--tap);
                border: 1px solid var(--line); border-radius: var(--radius-small); color: var(--text);
                text-decoration: none; min-width: 0; }
.currency-tag { align-self: flex-start; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em;
                padding: 0 0.45rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.side-balance .amount { display: block; font-size: 1.15rem; }
.side-to { color: var(--muted); }
.gap-warning { color: var(--warn); }

/* ---- period controls: one compact row of equal-height controls ---- */
.period { margin: 0.25rem 0 1rem; }
.period-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0.5rem 0; }
.period-row > * { min-height: 44px; }
.period-steps { display: flex; align-items: center; gap: 0.25rem; flex: 1 1 auto; min-width: 0; }
.period-label { flex: 1; text-align: center; min-width: 0; overflow-wrap: anywhere; font-size: 1.05rem; }
.step-button { display: inline-flex; align-items: center; justify-content: center; flex: none;
               width: 44px; height: 44px; border-radius: 999px; border: 1px solid var(--line);
               color: var(--accent-text, var(--accent)); text-decoration: none; font-size: 1.4rem; font-weight: 700;
               line-height: 1; background: var(--surface); }
.step-button.disabled { opacity: 0.35; }
.today-button { min-height: 44px; }
.period-chip select { min-height: 44px; border-radius: 999px; padding: 0 2rem 0 0.9rem; font-weight: 600;
                      border-color: var(--accent); color: var(--accent-text, var(--accent)); background-color: var(--surface); }
.stepper { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0 0.15rem;
           border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.stepper .step-button { width: 40px; height: 40px; border: 0; background: transparent; }
.stepper-value { font-size: 0.9rem; font-weight: 600; white-space: nowrap; }
.range-pill { flex: 1 1 13rem; min-width: 0; position: relative; }
.range-pill > summary { list-style: none; display: flex; align-items: center; justify-content: center; gap: 0.45rem;
                        min-height: 44px; padding: 0 0.9rem; border: 1px solid var(--line); border-radius: 999px;
                        background: var(--surface); color: var(--text); font-weight: 600; white-space: nowrap;
                        font-variant-numeric: tabular-nums; cursor: pointer; }
.range-pill > summary::-webkit-details-marker { display: none; }
.range-pill > summary svg { color: var(--accent-text, var(--accent)); flex: none; }
.range-pill[open] > summary { border-color: var(--accent); }
.range-fields { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 0 0.2rem; }
.range-fields .date-label { flex: 1 1 9rem; font-size: 0.85rem; }
.range-fields input { width: 100%; }
@media (min-width: 768px) {
  .period { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 0.75rem; }
  .period > .period-row:first-child { flex: 0 1 auto; }
  .period-steps { flex: 0 0 auto; }
  .period-label { min-width: 9rem; }
  .period > .date-controls { flex: 1 1 26rem; }
  .period > .error { flex-basis: 100%; }
}

/* ---- segmented choice (Trend: Total / By category) ---- */
.segmented { display: inline-flex; border: 1px solid var(--accent); border-radius: 999px; overflow: hidden; margin: 0 0 0.75rem; }
.segmented a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 1rem;
               text-decoration: none; color: var(--accent-text, var(--accent)); font-weight: 600; font-size: 0.9rem; }
.segmented a[aria-current="page"] { background: var(--accent); color: var(--on-accent); }

/* ---- charts: y axis, bars, average, tooltip ---- */
.chart { position: relative; }
.chart-area { display: grid; grid-template-columns: 3.1rem 1fr; }
.y-axis { position: relative; height: 220px; font-size: 0.7rem; color: var(--muted); }
.y-axis span { position: absolute; right: 0.4rem; transform: translateY(50%); white-space: nowrap;
               font-variant-numeric: tabular-nums; }
.plot { position: relative; height: 220px; min-width: 0; }
.bar-chart .plot svg { width: 100%; height: 100%; display: block; border: 0; overflow: visible; }
.gridline { stroke: var(--line); stroke-width: 1; }
.gridline.baseline { stroke: var(--muted); }
.bar-hit { fill: transparent; }
.chart rect.bar-total { fill: var(--accent); }
.bar-part { fill: var(--c); }
/* C-15: "Other" (categories left out, or past the biggest 7) is one plain grey. */
.bar-part.c-other, .share-part.c-other, .swatch.c-other, .donut-part.c-other {
  --c: color-mix(in srgb, var(--muted) 55%, var(--surface)); }
.bar-part[data-href], .share-part[data-href] { cursor: pointer; }
.bar-total-label { position: absolute; transform: translate(-50%, -3px); font-size: 0.62rem; font-weight: 700;
                   white-space: nowrap; color: var(--text); pointer-events: none; font-variant-numeric: tabular-nums; }
@media (max-width: 767px) { .bar-total-label.thin-phone { visibility: hidden; } }
@media (min-width: 768px) { .bar-total-label { font-size: 0.72rem; } .bar-total-label.thin-desk { visibility: hidden; } }
.chart-tip.interactive { pointer-events: auto; }
.chart-tip a { color: inherit; }
.bar-part.c-none, .share-part.c-none, .swatch.c-none, .donut-part.c-none {
  --c: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.bar.active rect.bar-total, .bar.active .bar-part { stroke: var(--text); stroke-width: 2; vector-effect: non-scaling-stroke; }
.bar:focus-visible { outline: none; }
.bar:focus-visible rect:not(.bar-hit) { stroke: var(--text); stroke-width: 3; vector-effect: non-scaling-stroke; }
.average-line { stroke: var(--text); stroke-width: 1.5; stroke-dasharray: 4 4; }
.average-key { display: flex; align-items: center; justify-content: flex-end; gap: 0.4rem; margin: 0 0 0.3rem;
               font-size: 0.75rem; font-weight: 600; color: var(--text); }
.average-swatch { width: 1.4rem; border-top: 2px dashed var(--text); }
.chart-labels-window { margin-left: 3.1rem; overflow: hidden; }
.chart-labels span { white-space: nowrap; overflow: hidden; }
@media (max-width: 767px) { .chart-labels .thin-phone { visibility: hidden; } }
@media (min-width: 768px) {
  .chart-labels .thin-desk { visibility: hidden; }
  .y-axis, .plot { height: 280px; }
}
.chart-tip { position: absolute; z-index: 20; min-width: 11rem; max-width: min(18rem, 90vw); padding: 0.6rem 0.75rem;
             border-radius: var(--radius-small); background: var(--surface); color: var(--text);
             border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); font-size: 0.85rem;
             /* The mouse passes through (owner 2026-11-08): a tall box over its own bar
                would otherwise count as leaving the bar, and close itself. */
             pointer-events: none; }
.chart-tip[hidden] { display: none; }
.chart-tip strong { display: block; }
.chart-tip .tip-total { font-size: 1.05rem; font-weight: 700; }
.chart-tip ul { list-style: none; margin: 0.35rem 0 0; padding: 0; }
.chart-tip li { display: flex; gap: 0.5rem; justify-content: space-between; align-items: baseline; }
.chart-tip li span:first-child { min-width: 0; overflow-wrap: anywhere; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; padding: 0; margin: 0.6rem 0; font-size: 0.85rem; }
.swatch { display: inline-block; width: 0.85rem; height: 0.85rem; border-radius: 3px; margin-right: 0.35rem;
          vertical-align: -0.1rem; background: var(--c); }

/* ---- % of spending: donut and 100% bars ---- */
.donut-chart { position: relative; max-width: 17rem; margin: 0.5rem auto 1rem; }
.donut-chart svg { width: 100%; height: auto; display: block; }
.donut-track { fill: none; stroke: var(--track); stroke-width: 16; }
.donut-part { fill: none; stroke: var(--c); stroke-width: 16; }
.donut-centre { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
                justify-content: center; text-align: center; pointer-events: none; }
.donut-centre strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.share-list { list-style: none; padding: 0; margin: 0; }
.share-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.share-bars { position: relative; }
.share-row { display: grid; grid-template-columns: 3.4rem 1fr; gap: 0.5rem; align-items: center; margin: 0.3rem 0; }
.share-label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.share-bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: var(--track); cursor: pointer; }
.share-bar.active { outline: 2px solid var(--text); outline-offset: 1px; }
.share-part { display: block; height: 100%; background: var(--c); }
.share-empty { font-size: 0.75rem; color: var(--muted); padding: 0 0.5rem; align-self: center; }

/* ---- the screenshot check page on a phone: each row a card of labelled fields ---- */
.shot-grid > * { min-width: 0; }
.shot-table-box { overflow-x: auto; }
@media (max-width: 767px) {
  .shot-table thead { display: none; }
  .shot-table, .shot-table tbody { display: block; }
  .shot-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem 0.5rem; padding: 0.6rem 0;
                   border-bottom: 1px solid var(--line); }
  .shot-table td { display: flex; flex-direction: column; gap: 0.15rem; padding: 0; border: 0; min-width: 0; }
  .shot-table td::before { content: attr(data-label); font-size: 0.72rem; color: var(--muted); }
  .shot-table td.shot-name, .shot-table td.shot-result, .shot-table td.shot-new { grid-column: 1 / -1; }
  .shot-table input:not([type="checkbox"]) { width: 100%; min-width: 0; }
}

/* Stage B: one look for every drop-down on every browser (the iPhone's own grey
   box is replaced): the theme's field colours and a small arrow drawn with two
   gradients (nothing loaded from outside). */
select {
  -webkit-appearance: none; appearance: none;
  padding-right: 2.2rem;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 1.15rem) 50%, calc(100% - 0.8rem) 50%;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
}
.nowrap { white-space: nowrap; }
.range-pill > summary { font-size: 0.92rem; padding: 0 0.7rem; }
@media (min-width: 768px) {
  .view-tabs a { flex: 0 0 auto; padding: 0 1.1rem; }
  .period-chip { flex: 0 0 auto; }
  .period-chip select { min-width: 8rem; }
  .range-pill { flex: 0 1 18rem; }
}
/* Compact lists (Add): a long file name keeps the row; its details go under it. */
.compact li.row-line { flex-wrap: wrap; gap: 0.1rem 0.75rem; }
.compact li.row-line > :first-child { flex: 1 1 14rem; }
.compact li.row-line > :last-child { flex: 0 1 auto; }

/* Settings > Accounts (owner 2026-11-09): name on the left, "Replaced by" and
   "Mark as closed" (or Undo) on the right, wrapping under it on a phone. */
.closable-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center;
                justify-content: space-between; }
.closable-row > form { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center;
                       justify-content: flex-end; margin: 0; }
/* On a phone: the picker fills the row, the button under it on the right. */
.closable-row > .close-form { flex: 1 1 100%; min-width: 0; }
.closable-row label.inline { display: flex; margin: 0; flex: 1 1 100%; min-width: 0; }
.closable-row select { flex: 1; min-width: 0; }
@media (min-width: 768px) {
  /* On a desktop: one line, picker and button on the right of the name. */
  .closable-row > .close-form { flex: 0 1 auto; flex-wrap: nowrap; }
  .closable-row label.inline { flex: 0 1 auto; }
  .closable-row select { width: 14rem; }
}
.account-closed-note { font-weight: 600; }

/* ---- Settings > Categories as a grid; category order; Back to top (owner 2026-11-09) ---- */
/* A small two-way switch, "A to Z" / "Recently used", like the header's view switch. */
.order-switch { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin: 0.25rem 0 0.75rem; }
.order-switch button { min-height: 36px; padding: 0 0.8rem; font-size: 0.85rem; font-weight: normal;
                       background: transparent; color: var(--accent-text, var(--accent)); border-radius: 999px; }
.order-switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
/* Names only: 2 columns on a phone, 3 on a desktop. An open name spans the row,
   so its edit options get the full width under it. */
.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin: 0.5rem 0 1.5rem; }
@media (min-width: 768px) { .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.cat-cell { min-width: 0; }
.cat-cell > summary { list-style: none; cursor: pointer; min-height: var(--tap); display: flex; align-items: center;
                      padding: 0.25rem; border-radius: var(--radius-small); border: 1px solid var(--line); }
.cat-cell > summary::-webkit-details-marker { display: none; }
/* Long names wrap (never cut off), so every name can be read. */
.cat-cell > summary .chip { white-space: normal; overflow-wrap: anywhere; line-height: 1.25; padding-top: 0.2rem; padding-bottom: 0.2rem; }
.cat-cell.muted > summary .chip { opacity: 0.6; }
.cat-cell[open] { grid-column: 1 / -1; }
.cat-cell[open] > summary { border-color: var(--accent); }
.cat-edit { padding: 0.5rem 0.25rem 0.75rem; }
/* Back to top: bottom right (bottom left where right would cover a button), above
   the phone's tab bar. app.js shows it after about one screen of scrolling. */
.back-to-top { position: fixed; right: calc(1rem + env(safe-area-inset-right)); bottom: 1.25rem; z-index: 40;
               min-height: 40px; padding: 0 0.9rem; font-size: 0.85rem; border-radius: 999px;
               box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); }
.back-to-top[hidden] { display: none; }
.back-to-top.at-left { right: auto; left: calc(1rem + env(safe-area-inset-left)); }
@media (max-width: 767px) {
  .tabbar ~ .back-to-top { bottom: calc(64px + 0.75rem + env(safe-area-inset-bottom)); }
}

/* Daily interest, one row per month on Transactions (owner 2026-11-09). */
.interest-group > details > summary { display: block; cursor: pointer; list-style: none; }
.interest-group > details > summary::-webkit-details-marker { display: none; }
.interest-group > details > summary .payee::before { content: "▸ "; color: var(--muted); }
.interest-group > details[open] > summary .payee::before { content: "▾ "; }
.lines.nested { margin: 0.5rem 0 0 1rem; border-left: 2px solid var(--line); padding-left: 0.75rem; }
.lines.nested li:last-child { padding-bottom: 0; }

/* "Which line paid this?" on Review (owner 2026-11-09). */
.choice-card { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.choice-card .inline-form { display: flex; gap: 0.6rem; align-items: center; justify-content: space-between; }
.choice-card .inline-form > span { min-width: 0; overflow-wrap: anywhere; }

/* Import progress (owner 2026-11-09), the trade journal's look: spinner, words,
   a thin rounded bar in the header's rainbow, failed files as notices. */
.progress-box { display: flex; gap: 0.85rem; align-items: flex-start; }
.progress-words { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.progress-words [hidden] { display: none; }
.progress-bar { height: 6px; border-radius: 999px; background: var(--track, var(--line));
  overflow: hidden; margin-top: 0.6rem; }
.progress-bar > div { height: 100%; border-radius: 999px; transition: width 0.3s;
  background: var(--header-stripe, var(--accent)); }
.progress-bar > div.indeterminate { width: 40% !important; animation: progress-slide 1.2s ease-in-out infinite; }
@keyframes progress-slide { from { margin-left: -40%; } to { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress-bar > div.indeterminate { animation-duration: 3s; } }
.progress-errors { margin-top: 1rem; }
.progress-errors[hidden] { display: none; }
.progress-errors ul { list-style: none; padding: 0; margin: 0.4rem 0 0; display: grid; gap: 0.5rem; }
.progress-errors .notice { padding: 0.6rem 0.75rem; border-radius: var(--radius-small, 10px);
  border: 1px solid var(--danger); overflow-wrap: anywhere; }
.progress-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1rem 0 0; }
.progress-actions [hidden] { display: none; }
.add-progress { margin-bottom: 1rem; }
.reading-status[data-batch-status] { flex-wrap: wrap; }
.reading-status[data-batch-status] .progress-bar { flex-basis: 100%; margin-top: 0.2rem; }

/* Delete in a category's edit panel (C-03 item 1). */
.cat-delete { margin-top: 0.75rem; padding-top: 0.5rem; border-top: 1px solid var(--line, rgba(127,127,127,0.25)); }
.cat-delete select { max-width: 100%; }

/* "+ New category…" form under a category list (C-03 item 3). Every part
   may shrink (min-width: 0), so it never makes the page wider than the phone. */
.new-category { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-end;
                margin: 0.5rem 0; padding: 0.6rem; min-width: 0; max-width: 100%;
                border: 1px dashed var(--accent); border-radius: 8px; box-sizing: border-box; }
.new-category label { display: flex; flex-direction: column; flex: 1 1 10rem; min-width: 0; }
.new-category input, .new-category select { width: 100%; min-width: 0; box-sizing: border-box; }
.new-category-buttons { display: flex; gap: 0.5rem; }
.new-category [data-new-note] { flex-basis: 100%; margin: 0; }

/* Review (C-03 items 4 and 5). */
.prepick-note { margin: 0.25rem 0; }
.account-split { list-style: none; margin: 0.25rem 0; padding: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.account-split li { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; min-width: 0; }
.account-split .account-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.account-of-line { display: block; }
.new-category [hidden] { display: none; }   /* the rules above would show hidden parts */

/* Part 11: lines that saved themselves, each with Undo on the right. */
.auto-lines li { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.auto-line-text { flex: 1 1 12rem; min-width: 0; display: flex; flex-direction: column; overflow-wrap: anywhere; }
.auto-lines .amount { white-space: nowrap; }
.auto-lines form { margin: 0; }

/* ---- C-15: the category picker on Trends and % share ---- */
.category-picker { margin: 0 0 0.75rem; }
.category-picker > summary { list-style: none; display: inline-flex; align-items: center; cursor: pointer; }
.category-picker > summary::-webkit-details-marker { display: none; }
.picker-form { margin-top: 0.5rem; padding: 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-small);
               background: var(--surface); }
.picker-list { list-style: none; padding: 0; margin: 0 0 0.5rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.15rem 1rem; }
@media (min-width: 768px) { .picker-list { grid-template-columns: repeat(3, 1fr); } }
.picker-list label, .switch-row { display: flex; flex-direction: row; align-items: center; justify-content: flex-start;
  gap: 0.4rem; min-height: 40px; min-width: 0; overflow-wrap: anywhere; color: var(--text); text-align: left; }
.picker-list .swatch { flex: none; margin-right: 0; }
.picker-list input, .switch-row input { width: 1.2rem; height: 1.2rem; flex: none; }
.figures a.chip { text-decoration: none; color: inherit; }
.legend a, .share-list a { color: inherit; }

/* ---- C-15: a category's lines, changed right in the list ---- */
.back-row { margin: 0 0 0.25rem; }
/* C-52: "← Back" at the top of every sub-page: a whole 44 px tap target, quiet. */
.page-back { margin: -0.25rem 0 0.25rem; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px;
             padding: 0 0.75rem 0 0; font-weight: 600; text-decoration: none;
             color: var(--link, var(--accent)); }
.back-link:active { opacity: 0.6; }
.category-figure { margin-bottom: 0.75rem; }
.quick-message { display: flex; flex-direction: column; gap: 0.4rem; }
.quick-message p { margin: 0; }
.quick-message .inline-form { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0; }
.quick-message .inline-form > span { min-width: 0; overflow-wrap: anywhere; }
/* C-18: the shared line picker: the category, "Show this payee as", two buttons side
   by side, then the rule's words and "How" (always shown). */
.line-picker { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; margin: 0.4rem 0; }
.line-picker label { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.line-picker select, .line-picker input[type=text], .line-picker input:not([type]) { max-width: 100%; min-height: 40px; }
.pick-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: stretch; }
.pick-buttons button { min-height: 44px; white-space: normal; text-align: center; }
@media (max-width: 600px) { .pick-buttons button { flex: 1 1 9rem; } }
.pick-none { margin: 0; }
.pick-rule { display: flex; flex-wrap: wrap; gap: 0.4rem 0.75rem; align-items: flex-end;
             border-left: 3px solid var(--line); padding-left: 0.6rem; }
.pick-rule > label:first-child { flex: 1 1 12rem; }
.pick-rule > p, .pick-rule > .pick-which { flex-basis: 100%; margin: 0; }
.like-lines li { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; justify-content: space-between; }
.like-lines li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.saved-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
             gap: 0.5rem; padding: 0.5rem 0.75rem; border-radius: 8px; color: var(--ok);
             border: 1px dashed var(--line); }
.saved-row > span { min-width: 0; overflow-wrap: anywhere; }
.saved-row .inline-form { margin: 0; }
/* C-18 Step 0: a list line's category as a button that opens the shared picker. */
.chip-button { background: none; border: 0; padding: 0; min-height: 40px; color: inherit; font: inherit;
               text-align: left; cursor: pointer; }
.chip-button[aria-expanded="true"] .chip { outline: 2px solid var(--accent); outline-offset: 1px; }
.quick-category { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; min-width: 0; margin: 0; }
.quick-category label { min-width: 0; max-width: 100%; }
.quick-category select { max-width: 100%; min-height: 40px; }

/* C-16: Settings > Share from iPhone. A long key or address in a field with a
   Copy button beside it; the field shrinks, never the page (390 px). */
.copy-row { display: flex; gap: 0.5rem; align-items: center; margin: 0.5rem 0; }
.copy-row .copy-value { flex: 1; min-width: 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.copy-row button { flex: none; }
.new-key { padding: 0.75rem; border-radius: 0.5rem; }
.new-key p { margin-top: 0; }
ol.steps { padding-left: 1.4rem; }
ol.steps li { margin: 0.45rem 0; overflow-wrap: anywhere; }
.show-anyway > summary { cursor: pointer; color: var(--accent); }

/* ---- C-19: the period bar and draggable charts ---- */
/* The chart's strip holds bars either side of the period; the plot shows only the
   period's own. Sideways it is clipped; upwards a bar's total may still show. A finger
   moving sideways drags the bars; moving up or down still scrolls the page. */
.bar-chart .plot { overflow-x: clip; overflow-y: visible; touch-action: pan-y; }
@supports not (overflow-x: clip) { .bar-chart .plot { overflow: hidden; } }
.bar-chart .strip { position: relative; height: 100%; will-change: transform; }
.bar-chart[data-drag] .plot { cursor: grab; user-select: none; -webkit-user-select: none; }
.bar-chart.dragging .plot { cursor: grabbing; }
.bar-chart.dragging .average-line, .bar-chart.dragging .chart-tip { visibility: hidden; }
.bar-around { pointer-events: none; }
html.period-moving .period-label, html.period-moving .bar-chart .plot { opacity: 0.75; transition: opacity 0.2s; }

.period-jump { flex: 1; min-width: 0; position: relative; }
.period-jump > summary { list-style: none; display: flex; align-items: center; justify-content: center; gap: 0.3rem;
  min-height: 44px; cursor: pointer; text-align: center; border-radius: var(--radius-small); }
.period-jump > summary::-webkit-details-marker { display: none; }
.period-jump > summary strong { overflow-wrap: anywhere; }
.jump-caret { font-size: 0.75rem; color: var(--muted); }
.jump-list { position: absolute; z-index: 30; left: 50%; transform: translateX(-50%); top: calc(100% + 4px);
  width: min(22rem, calc(100vw - 2rem)); max-height: 60vh; overflow-y: auto; padding: 0.6rem 0.75rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-small);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); }
.jump-heading { margin: 0.25rem 0; font-size: 0.75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.jump-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.4rem; }
.jump-chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 0.7rem; border-radius: 999px;
  border: 1px solid var(--line); text-decoration: none; color: var(--text); font-size: 0.85rem; }
.jump-chip:focus-visible { border-color: var(--accent); }
.centre-on { position: relative; display: none; flex: 0 0 44px; width: 44px; height: 44px; align-items: center;
  justify-content: center; border: 1px solid var(--line); border-radius: 999px; color: var(--accent-text, var(--accent)); }
.js-dates .centre-on { display: inline-flex; }
.centre-on .date-native { display: block; position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0;
  cursor: pointer; border: 0; padding: 0; }
.centre-on .date-native::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
/* C-28: waiting pictures one by one (thumbnail, summary, Save / Delete). */
.waiting-items { list-style: none; padding: 0; margin: 0; }
.waiting-item { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.waiting-item:first-child { border-top: 0; }
.waiting-thumb { flex: 0 0 64px; }
.waiting-thumb img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.waiting-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.2rem; }
.waiting-text .bulk-name, .waiting-text small { overflow-wrap: anywhere; }
.waiting-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.4rem; }
.waiting-actions .inline-form { flex-direction: row; flex-wrap: wrap; align-items: center; margin-top: 0; min-width: 0; max-width: 100%; }
.waiting-actions select { width: 100%; max-width: 100%; min-width: 0; text-overflow: ellipsis; }
#which-account select { width: 100%; max-width: 100%; min-width: 0; text-overflow: ellipsis; }
.waiting-full { display: block; max-width: 100%; height: auto; margin: 0.75rem 0; border-radius: 8px; border: 1px solid var(--line); }
/* C-28: Add's two choices first; the recent lists start closed. */
.add-choices .add-hint { margin-top: -0.4rem; }
.add-lists > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.business-empty { margin-bottom: 1rem; }

/* C-31: each screenshot stays in view beside its lines (desktop) or just above
   them (phone) while that screenshot's lines scroll; it leaves with its section. */
.shot-figure { position: sticky; top: 0.5rem; align-self: start; z-index: 1; display: block;
  background: var(--bg, #fff); }
.shot-total { font-weight: 600; margin: 0.25rem 0; }
.shot-batch-total { font-weight: 600; }
@media (max-width: 899px) {
  .shot-figure { top: 0; padding-bottom: 0.4rem; }
  .shot-figure .shot-image { max-height: 34vh; }
}
@media (min-width: 900px) {
  .shot-figure .shot-image { max-height: calc(100vh - 2rem); }
}

/* C-37: a tap shows at once. Any button looks pressed while the finger is on it; a save
   sent in place (app.js "In place") keeps its button pressed and its form dimmed, with a
   working cursor, until the page has updated. */
button:active, .btn:active, button.is-pressed { transform: scale(0.97); filter: brightness(0.92); }
form.is-working { opacity: 0.7; cursor: progress; transition: opacity 0.1s; }
form.is-working button.is-pressed[disabled] { opacity: 1; }
@media (prefers-reduced-motion: reduce) { button:active, .btn:active, button.is-pressed { transform: none; } }

/* v0.2-5: "Statements updated until" under the tabs of Summary, Transactions, Calendar and
   Trends: one quiet line, a link to Accounts (a thumb-high tap target). */
.statements-until { margin: .25rem 0 .5rem; }
.statements-until a { display: inline-block; min-height: 44px; line-height: 44px; color: var(--muted);
  text-decoration: none; }
.statements-until a:focus-visible { color: var(--text); text-decoration: underline; }

/* ---- v0.2-6: a photo over the page (receipts, screenshots) ---- */
/* Dark backdrop whatever the theme, the photo fitted to the screen, and a large
   high-contrast Close in the top corner, clear of the iPhone's notch and home bar. */
.lightbox { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center;
            justify-content: center; background: rgba(0, 0, 0, 0.92);
            padding: max(3.5rem, env(safe-area-inset-top)) 0.75rem max(1rem, env(safe-area-inset-bottom)); }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; background: #fff; }
.lightbox-close { position: absolute; top: max(0.6rem, env(safe-area-inset-top)); right: 0.6rem;
                  width: 2.9rem; height: 2.9rem; min-height: 0; padding: 0; margin: 0;
                  border-radius: 50%; border: 2px solid #000; background: #fff; color: #000;
                  font-size: 1.9rem; line-height: 1; font-weight: 700; cursor: pointer;
                  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35); }
.lightbox-close:focus-visible { outline: 3px solid #ffd54a; outline-offset: 2px; }
html.lightbox-open, html.lightbox-open body { overflow: hidden; }

/* ---- v0.2-6: Search / Timeline on a row (Transactions, Review) ---- */
/* Small, quiet links that do not compete with the amount; still a finger's width apart. */
/* C-58: the payee's name is the web search: it reads as the name, with a dotted line to say it opens. */
.payee-search { color: inherit; text-decoration: underline dotted; text-decoration-thickness: 1px;
                text-underline-offset: 3px; overflow-wrap: anywhere; }
.choice-why { margin: 0.2rem 0; }
.existing-note { display: block; margin-top: 0.25rem; }
.lookup-row { display: inline-flex; gap: 0.4rem; flex-wrap: wrap; margin-left: 0.25rem; vertical-align: middle; }
.lookup-row a { font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px;
               border: 1px solid var(--line); color: var(--accent-text, var(--accent)); text-decoration: none;
               white-space: nowrap; line-height: 1.4; }
.lookup-row a:focus-visible { border-color: var(--accent); }
.payee .lookup-row { display: flex; margin: 0.2rem 0 0; }

/* C-42: the forwarding code box on Update by email, there before any code arrives. */
.code-box { border: 2px dashed var(--field-border, var(--muted)); border-radius: 8px; padding: 0.6rem 0.8rem;
  min-height: 3rem; overflow-wrap: anywhere; }
.code-box .confirmation-code { font-size: 1.3rem; letter-spacing: 0.08em; }

/* C-52: saved statements and receipts: what it is on the left, View and Delete on the right
   (wrapping under it on a narrow phone). Delete is outlined red: clearly not the main button. */
.saved-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 0.75rem; }
.saved-what { display: flex; flex-direction: column; min-width: 0; flex: 1 1 12rem; overflow-wrap: anywhere; }
.row-actions { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-left: auto; }
.row-actions form { margin: 0; display: inline-flex; }
.lines .row-actions { display: flex; justify-content: flex-end; margin-top: 0.35rem; }
button.danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); margin: 0; }
.danger-zone { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.empty-note { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }


/* C-52: a saved statement's file. PDF pages as pictures, the width of the page; a
   spreadsheet's table scrolls inside its own box (never the page sideways at 390 px). */
.statement-file-name { overflow-wrap: anywhere; }
.statement-pages { display: flex; flex-direction: column; gap: 1rem; }
.statement-page { margin: 0; }
.statement-page img { display: block; width: 100%; max-width: 900px; height: auto; background: #fff;
                      border: 1px solid var(--line); border-radius: 6px; }
.table-scroll { max-width: 100%; overflow: auto; max-height: 70vh; border: 1px solid var(--line);
                border-radius: 6px; -webkit-overflow-scrolling: touch; }
.statement-table { border-collapse: collapse; font-size: 0.85rem; min-width: 100%; }
.statement-table td { padding: 0.35rem 0.6rem; border-bottom: 1px solid var(--line); white-space: nowrap;
                      vertical-align: top; }

/* C-52 UX pass (looks only): on a phone every stand-alone control is at least a finger's
   44 px tall (small buttons and chips were 40 px; desktop keeps 40 for a mouse). */
@media (max-width: 767px) {
  .btn.small, button.small, details > summary.btn.small, .chip-button, .tabs.chips a,
  .jump-chip, .index-chip, .chip-close { min-height: 44px; }
  .chip-close { min-width: 44px; }
  .source-statement { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ---- C-53: one toast for save, delete and Undo (templates/_toast.html) ----
   Fixed, so it never moves the page; above the phone's tab bar (and the iPhone's home
   indicator), bottom centre on a desktop; never wider than the screen. Above the page and
   Back to top, below the photo lightbox. */
.toast { position: fixed; left: 50%; transform: translateX(-50%); z-index: 45;
         bottom: calc(1rem + env(safe-area-inset-bottom));
         width: min(calc(100% - 2rem - env(safe-area-inset-left) - env(safe-area-inset-right)), 32rem);
         display: flex; align-items: flex-start; gap: 0.25rem; box-sizing: border-box;
         padding: 0.35rem 0.35rem 0.35rem 0.9rem; border-radius: var(--radius);
         background: var(--surface); color: var(--text); border-left: 5px solid var(--ok);
         box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28); transition: opacity 0.25s ease; }
.toast.toast-warn { border-left-color: var(--warn); }
.toast[hidden] { display: none; }
.toast.is-leaving { opacity: 0; }
.toast-body { flex: 1; min-width: 0; padding: 0.3rem 0; overflow-wrap: anywhere; }
.toast-body > * { margin: 0; }
.toast-body .status-ok { color: var(--text); }
.toast-body .saved-undo { margin: 0; }
.toast-body .quick-message p { margin: 0; }
.toast-close { flex: none; min-width: 40px; min-height: 40px; padding: 0; border: 0; background: transparent;
               color: var(--muted); font-size: 1.4rem; line-height: 1; box-shadow: none; }
@media (max-width: 767px) {
  .tabbar ~ main .toast { bottom: calc(64px + 0.75rem + env(safe-area-inset-bottom)); }
  .toast-close { min-width: 44px; min-height: 44px; }
  .toast-body button { min-height: 44px; }
}
/* Room at the page's end the size of the toast, so the line just changed can sit above it
   (app.js sets it once a toast shows, and never takes it back on that page). */
main::after { content: ""; display: block; height: var(--toast-room, 0px); }
/* Back to top moves up while a toast is showing (app.js sets the space). */
.back-to-top { margin-bottom: var(--toast-space, 0px); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
/* C-53: a Transactions line is one tap target on a phone (app.js); a pressed look while touched. */
@media (max-width: 767px) {
  [data-row-tap] li:has(> a.change-link) { cursor: pointer; -webkit-tap-highlight-color: transparent; }
  [data-row-tap] li.is-touched { background: var(--bg); }
}

/* ---- C-55: Add's one "Saved files" list; the Settings hub's short lines ----
   A row's type is a small tag before its name; the search field takes the width left and
   wraps under 390 px, so nothing scrolls sideways. */
.saved-files .anchor { display: block; height: 0; }
.saved-kinds { margin: 0.75rem 0 0.5rem; }
.saved-search { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0 0 0.5rem; }
.saved-search-field { flex: 1 1 12rem; min-width: 0; margin: 0; }
.saved-search-field input { width: 100%; min-height: var(--tap); box-sizing: border-box; }
.kind-tag { display: inline-block; padding: 0 0.45rem; border: 1px solid var(--line); border-radius: 999px;
            font-size: 0.75rem; font-weight: 600; line-height: 1.4rem;
            vertical-align: 0.1em; white-space: nowrap; }
.saved-what small { display: block; }
.statement-file-delete { margin: 0 0 1rem; }
a.section-row .hub-row-text { display: flex; flex-direction: column; min-width: 0; }
a.section-row .hub-hint { font-size: 0.85rem; margin-top: 0.1rem; overflow-wrap: anywhere; }

/* ---- C-57: the iPhone's top edge (ARCHITECTURE "C-57 design", 4) ----
   From the home screen the page runs under the status bar (black-translucent). The header
   already pads itself; these keep everything else clear of the Dynamic Island too: a strip
   of the header's colour as tall as the inset stays over the top edge (0 px tall in a
   browser tab), anything scrolled into view (an address with #..., an in-place update)
   stops below it, and sticky pieces keep that distance. One variable, so a test can give
   it the iPhone's 59 px. */
:root { --safe-top: env(safe-area-inset-top, 0px); }
html { scroll-padding-top: calc(var(--safe-top) + 0.5rem); }
header { padding-top: calc(0.5rem + var(--safe-top)); }
body::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: var(--safe-top); z-index: 60;
               background-color: var(--header-bg, var(--surface)); pointer-events: none; }
.shot-figure { top: calc(0.5rem + var(--safe-top)); }
.lightbox { padding-top: max(3.5rem, var(--safe-top)); }

/* ---- C-57: the EN / ES switch on the signed-out pages ---- */
.lang-switch { display: flex; gap: 0.25rem; }
.lang-switch a { min-height: var(--tap); min-width: var(--tap); display: inline-flex; align-items: center;
                 justify-content: center; border-radius: 999px; color: var(--text); text-decoration: none;
                 font-weight: 600; font-size: 0.9rem; }
.lang-switch a[aria-current="true"] { border: 1px solid var(--accent); }
.picker.languages label { display: flex; gap: 0.5rem; align-items: center; min-height: var(--tap);
                          height: auto; max-height: calc(var(--tap) * 1.5); align-self: center; }

/* ---- C-59: "Is this for a new account or an existing one?" on Check before saving ---- */
.account-ask { border: 1px solid var(--line); border-radius: var(--radius-small); margin: 0.5rem 0;
               padding: 0.5rem 0.75rem 0.75rem; display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.account-ask legend { font-weight: 600; padding: 0 0.25rem; }
.account-ask .ask-choice { flex-direction: row; align-items: center; gap: 0.6rem; min-height: var(--tap); }
.account-ask .ask-choice input { width: 1.25rem; height: 1.25rem; flex: none; margin: 0; }
.account-ask .ask-branch { padding-left: 1.85rem; display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; }
.account-ask .ask-branch select { max-width: 100%; }
/* Only the chosen branch shows; nothing chosen yet: neither (a browser without :has shows both). */
.account-ask:not(:has(input[value="existing"]:checked)) [data-when="existing"],
.account-ask:not(:has(input[value="new"]:checked)) [data-when="new"] { display: none; }

/* ---- C-59: the Privacy policy and the Terms (/privacy, /terms) ---- */
.legal { max-width: 46rem; overflow-wrap: anywhere; }
.legal h2 { font-size: 1.1rem; margin: 1.4rem 0 0.4rem; }
.legal p { line-height: 1.55; }
.legal-links a { display: inline-block; min-height: var(--tap); min-width: var(--tap); line-height: var(--tap);
                 text-align: center; }
