/* RH Ledger — design direction per spec §17.
 *
 * A sibling to SSR Calc: same type scale, spacing rhythm and control shapes.
 * One deliberate divergence — the accent is oxidised copper / weathered patina,
 * so it reads as a different tool at a glance.
 *
 * Quality floor (§17): responsive to phone, visible keyboard focus, reduced
 * motion respected, and nothing may sit over a field being typed into — the
 * on-screen keypad must never cover it. That was a real SSR Calc beta bug.
 *
 * 2026-08-14 the nav moved to the bottom of the viewport, which is where a
 * thumb is and where every finance app on a phone puts it. That is the one
 * fixed element, and `body.typing` lifts it out of the way the moment a field
 * takes focus — the original rule was about keyboards, and it still holds.
 */

:root {
  --accent: #2f6f62;
  --accent-soft: #2f6f6222;
  --warm: #b06b3f;
  --warm-soft: #b06b3f22;

  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f2efea;
  --line: #ddd6cc;
  --text: #1e1b18;
  --muted: #6d655c;

  --radius: 10px;
  --gap: 16px;
  --tap: 44px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12100e;
    --surface: #1b1917;
    --surface-2: #232019;
    --line: #38332c;
    --text: #f0ece6;
    --muted: #9d948a;
    --accent: #4e9b8a;
    --accent-soft: #4e9b8a26;
    --warm: #d08b5c;
    --warm-soft: #d08b5c26;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--gap) 96px;
}

/* ── Header and nav ─────────────────────────────────────────────────────── */

.app-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 20px 0 12px;
}

/* The header band, and the first card lifted into it. */
.app-head {
  margin: 0 calc(var(--gap) * -1);
  padding: calc(20px + env(safe-area-inset-top, 0px)) var(--gap) 46px;
  background: linear-gradient(135deg, #2f6f62 0%, #35806f 55%, #47a08a 100%);
  color: #fff;
}
.dashboard { margin-top: -34px; }

/*
 * ...but only when there is nothing between it and the header.
 *
 * The lift exists to tuck the first card into the green band. With a banner
 * present it pulled the DASHBOARD up over the BANNER instead — measured at
 * 22px of overlap on a 375px screen, which read as the warning hiding behind
 * the header. The banner is the more urgent of the two, so it keeps its space
 * and the card sits below it.
 */
.banner-slot:not(:empty) + .content .dashboard { margin-top: 0; }
.banner-slot:not(:empty) { padding-top: 12px; }

.head-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  position: relative;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
}
.head-icon:active { background: rgba(255, 255, 255, 0.18); }

.head-middle { text-align: center; display: grid; gap: 2px; justify-items: center; }
.head-date { font-size: 0.82rem; color: rgba(255, 255, 255, 0.85); }

.bell-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--warm);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 18px;
}

.brand {
  font-weight: 650;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}

.mark {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: inset 0 0 0 2px var(--bg), 0 0 0 2px var(--accent);
}

.scope-label {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  padding: 1px 9px;
  white-space: nowrap;
}

/* Five tabs, at the bottom, where a thumb is. */
.nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  transition: transform 0.18s ease;
}

/* A focused field means a keyboard is coming. Get out of its way. */
body.typing .nav { transform: translateY(120%); }

.nav-item {
  flex: 1 1 0;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px;
  border: 0;
  border-top: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.nav-icon { position: relative; font-size: 1.1rem; line-height: 1; }
.nav-item.active { color: var(--accent); border-top-color: var(--accent); font-weight: 650; }
.nav-item.active .nav-label { font-weight: 650; }

/* ── Structure ──────────────────────────────────────────────────────────── */

.screen-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  margin: 8px 0 16px;
}

h1 { font-size: 1.5rem; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: 0.85rem; margin: 0; }

.group { margin-bottom: 28px; }

.group-title {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 10px;
}

.panel,
.account-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.account-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.row-actions { display: flex; gap: 12px; flex: 0 0 auto; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.badge {
  font-size: 0.75rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
}

.badge-profile { background: var(--accent-soft); border-color: var(--accent); color: var(--text); font-weight: 600; }
.badge-accent  { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.badge-warm    { background: var(--warm-soft); border-color: var(--warm); color: var(--text); }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono  { font-family: var(--mono); word-break: break-all; }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
}

.callout {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.92rem;
}

.callout-warm { border-left-color: var(--warm); background: var(--warm-soft); }

.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.preview {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 12px 0;
  font-size: 0.9rem;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.kv:last-child { border-bottom: 0; }
.kv-key { color: var(--muted); flex: 0 0 auto; }
.kv-value { text-align: right; }

.counts { margin: 0; padding-left: 20px; color: var(--muted); font-size: 0.88rem; }

/* ── Forms and controls ─────────────────────────────────────────────────── */

.field { display: block; margin-bottom: 14px; }

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 5px;
}

.field-hint {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 5px;
}

/* Every text-like input, not a list that quietly forgets one. A password field
   left off this list rendered as a bare browser default next to styled ones. */
input[type='text'],
input[type='password'],
input[type='email'],
input[type='number'],
input[type='search'],
input[type='tel'],
input[type='date'],
input[type='file'],
select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.locked-value {
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  font-size: 0.95rem;
}

.check input { width: 20px; height: 20px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

button {
  min-height: var(--tap);
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}

button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }

button.link {
  min-height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ── Toasts ─────────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: 12px;                 /* top, not bottom — never over a focused field */
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
  width: min(560px, calc(100vw - 32px));
}

.toast {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 0.9rem;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.14);
}

.toast-error { border-left-color: var(--warm); }

.boot { padding: 40px 0; }
.boot-error { margin-top: 40px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ── Review queue (§14) ─────────────────────────────────────────────────── */

.triage {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 16px 16px;
  text-align: center;
}

.triage-head {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.88rem;
}

.triage-amount {
  font-size: 2.4rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  margin: 18px 0 4px;
}

.triage-merchant { font-size: 1.05rem; font-weight: 600; }
.triage-date { font-size: 0.9rem; margin-bottom: 18px; }

/* Six thumb-sized targets, two across on a phone (§14). */
.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}

.category-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 64px;
  padding: 12px 14px;
  text-align: left;
  line-height: 1.25;
  background: var(--surface-2);
}

.category-line {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.progress-wrap { display: flex; align-items: center; gap: 12px; margin-top: 18px; }

.progress {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.progress-label { font-size: 0.82rem; color: var(--muted); white-space: nowrap; }

.empty.done { border-style: solid; border-color: var(--accent); }

.done-mark {
  font-size: 2.4rem;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
}

.nav-count {
  display: inline-block;
  min-width: 20px;
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
}

/* ── Import (§13.1) ─────────────────────────────────────────────────────── */

.rows { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }

.import-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border-left: 3px solid var(--line);
  font-size: 0.88rem;
}

.import-row .badge { align-self: flex-start; }
.import-new { border-left-color: var(--accent); }
.import-duplicate,
.import-unknown_account { border-left-color: var(--warm); }
.import-error { border-left-color: var(--warm); }

.kv.total { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; padding-top: 12px; }

@media (max-width: 360px) {
  .category-grid { grid-template-columns: 1fr; }
}

/* ── Setup ──────────────────────────────────────────────────────────────── */

.setup { margin-top: 8px; }

.choice-group { display: flex; flex-direction: column; gap: 8px; }

.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-height: 56px;
  padding: 12px 14px;
  text-align: left;
  line-height: 1.3;
  background: var(--surface-2);
  font-weight: 500;
}

.choice.chosen {
  background: var(--accent-soft);
  border-color: var(--accent);
  font-weight: 650;
}

.choice-label { font-weight: 650; }
.choice-desc { font-size: 0.82rem; color: var(--muted); font-weight: 400; }

textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  resize: vertical;
}

/* ── Numbered setup steps ───────────────────────────────────────────────── */

.steps {
  margin: 0 0 14px;
  padding-left: 22px;
  font-size: 0.92rem;
  line-height: 1.5;
}

.steps li { margin-bottom: 6px; }

a.external {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  /* A link is a tap target too — give it the same room as a button. */
  display: inline-block;
  padding: 4px 0;
}

.external-mark { margin-left: 4px; font-size: 0.85em; opacity: 0.75; }

/* ── Money (§12.6) ──────────────────────────────────────────────────────── */

.balance-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.balance-row:last-child { border-bottom: 0; }

.balance-figure { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.owed { color: var(--warm); }

/* One tap per card instead of a form per card. */
.confirm-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.confirm-row:last-child { border-bottom: 0; }

.confirm-choices { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }

.chip {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--surface-2);
}

.chip.chosen {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ── Bulk account setup ─────────────────────────────────────────────────── */

.selectable { display: flex; align-items: flex-start; gap: 10px; }
.selectable-body { flex: 1; min-width: 0; }

.select-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  margin-top: 14px;
}

.select-box input { width: 22px; height: 22px; }

.bulk { border-left: 3px solid var(--accent); }

.lead { font-size: 1rem; margin: 0 0 16px; }
.panel.quiet { background: transparent; border-style: dashed; }

/* The one warning allowed to shout. Reserved for "your data has no second
   copy" — if this styling spreads to anything else it stops working. */
.callout.danger {
  border: 2px solid var(--warm);
  border-left-width: 6px;
  background: var(--warm-soft);
}

.callout.danger strong { display: block; margin-bottom: 3px; }

.small-button { min-height: 38px; padding: 0 14px; font-size: 0.88rem; white-space: nowrap; }

/* Figures whose freshness cannot be vouched for. Deliberately muted: they are
   still information, but they must not read as a current reading. */
.panel.dated { border-style: dashed; }
.panel.dated .kv-value { color: var(--muted); }
.panel.dated .kv.total .kv-value { color: var(--text); }

/* ── Transactions ───────────────────────────────────────────────────────── */

.filters { display: flex; flex-direction: column; gap: 10px; }
.filter-row { display: flex; gap: 10px; }
.filter-row select { flex: 1; }
.count-line { margin-bottom: 10px; }

.txn {
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.txn:last-child { border-bottom: 0; }
.txn.unreviewed { border-left: 3px solid var(--accent); padding-left: 10px; margin-left: -13px; }

/* The row itself; the whole left side is the tap target. */
.txn-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.txn-main { min-width: 0; flex: 1; }

/*
 * Transaction names wrap; they never clip. "Internet Transfer To 9276" ends in
 * the only part that says which account it hit, so a title cut short here is
 * not cosmetic — it is the row losing its meaning.
 */
.txn-main strong {
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.txn-main .small { white-space: normal; overflow-wrap: anywhere; }

.txn-tap {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  /* A <button> will not wrap its own text by default. */
  white-space: normal;
  padding: 0;
  cursor: pointer;
}

.txn-detail {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  gap: 8px;
}
.txn-detail .mono { font-family: var(--mono); font-size: 0.78rem; overflow-wrap: anywhere; }
.txn-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.txn-rename { display: flex; gap: 8px; }
.txn-edit-row { display: flex; gap: 8px; }
.txn-edit-row .txn-edit-input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}
.txn-notes {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  resize: vertical;
}
.txn-name-input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  font: inherit;
}

.txn-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

.txn-amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.txn-amount.income { color: var(--accent); }

.inline-select {
  min-height: 34px;
  padding: 4px 8px;
  font-size: 0.82rem;
  max-width: 168px;
}

.quick-sort { margin: 8px 0 0; }

/* ── Dashboard headline ─────────────────────────────────────────────────── */

.hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 16px 14px;
  margin-bottom: 12px;
}

.hero.dated { border-left-color: var(--warm); border-style: dashed; }

.hero-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 650;
}

/* The figure sets its own size rather than inheriting, and wraps instead of
   running off the edge — the old total overflowed the screen on a phone. */
/*
 * One line, always. `overflow-wrap: anywhere` used to let "$1,352.77" break
 * across two lines on a phone, which reads as two different numbers at a
 * glance. It scales down instead: the clamp floor is small enough for seven
 * figures at 320px, and tabular digits keep it from jittering as it updates.
 */
.hero-figure {
  font-size: clamp(1.6rem, 8.5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 4px 0 8px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.hero-split {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.92rem;
  color: var(--muted);
}

.hero-sync {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.group-head h2 { margin: 0; }
.group-total { font-weight: 700; font-variant-numeric: tabular-nums; }

.balance-name { min-width: 0; flex: 1; }
.balance-name strong { overflow-wrap: anywhere; }

button[disabled] { opacity: 0.55; }

/* ── Safe area ──────────────────────────────────────────────────────────── */

/* black-translucent draws the page UNDER the iOS status bar, and nothing was
   reserving that space — the "Accounts" heading sat behind the clock. */
.app-head { padding-top: calc(20px + env(safe-area-inset-top, 0px)); }
.app { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

/* ── Account cards ──────────────────────────────────────────────────────── */

.account-title { min-width: 0; flex: 1; }
.account-title strong { overflow-wrap: anywhere; }

.account-card.unconfirmed { border-left: 3px solid var(--accent); }

.card-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.inline-select.wide { max-width: 60%; }

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

/* ── Dashboard, the Rocket Money shape (2026-08-14) ─────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: var(--gap);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

/* Swipe between headline cards. One scroll container, snapping. */
.deck {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  margin: 0 calc(var(--gap) * -1);
  padding: 0 var(--gap);
}
.deck::-webkit-scrollbar { display: none; }
.deck > .card {
  flex: 0 0 100%;
  scroll-snap-align: center;
  margin-bottom: 6px;
}

.dots { display: flex; justify-content: center; gap: 7px; margin-bottom: 18px; }
.dot { width: 7px; height: 7px; border-radius: 999px; background: var(--line); }
.dot.on { background: var(--muted); }

.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero-label { color: var(--muted); font-size: 0.92rem; }
.hero-card.dated .hero-figure { opacity: 0.55; }

.hero-change {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 46%;
  text-align: left;
  font-size: 0.86rem;
  color: var(--muted);
}
.change-arrow {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  font-size: 0.8rem;
}
.hero-change.up .change-arrow { color: var(--warm); }
.hero-change.down .change-arrow { color: var(--accent); }

.spark { width: 100%; height: 64px; margin-top: 12px; display: block; }
.spark-area { fill: var(--accent-soft); }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.spark-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }

.hero-foot,
.account-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 10px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.hero-foot { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 14px; }

.row-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
}
.row-label { flex: 1 1 auto; font-weight: 600; }
.row-hint { display: block; font-weight: 400; }
.row-figure { font-weight: 700; font-variant-numeric: tabular-nums; }
.row-figure.owed { color: var(--warm); }
.row-caret { color: var(--muted); flex: 0 0 auto; }
.row-caret.open { transform: rotate(180deg); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 4px 0 10px;
}
.section-head h2 { margin: 0; font-size: 0.82rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.account-card { padding: 0 18px; }
.account-group + .account-group,
.net-row,
.more-row + .more-row { border-top: 1px solid var(--line); }
.account-details { padding: 4px 0 12px 50px; }
.account-detail {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 6px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}
.account-detail:active { opacity: 0.6; }
.account-detail.open { font-weight: 600; }

.pending-leg {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.pending-leg:last-of-type { border-bottom: 0; }

.account-txns {
  display: grid;
  gap: 8px;
  margin: 2px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 0.88rem;
  /*
   * A full year of an active account is hundreds of rows. Scrolling them
   * inside the card keeps the rest of the dashboard reachable — without this,
   * opening one account buries Net worth and the sync button under a year of
   * groceries.
   */
  max-height: 60vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.account-txns-head {
  padding-bottom: 2px;
  border-bottom: 1px solid var(--line);
}

/* Sticks to the top of the scroll box, so the month is never in doubt. */
.account-txn-month {
  position: sticky;
  top: -10px;
  z-index: 1;
  margin: 6px 0 -2px;
  padding: 6px 0 4px;
  background: var(--surface-2);
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.account-txn { display: flex; justify-content: space-between; gap: 12px; }
.account-txn-name { min-width: 0; overflow-wrap: anywhere; }
.account-txn .income { color: var(--accent); }
.account-note { padding: 0 0 14px 50px; }
.net-row { cursor: default; }

.sync-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px 0 10px;
}

/* ── Sheets: the gear drawer and the bell ──────────────────────────────── */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.35);
}

.sheet {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 31;
  width: min(88vw, 380px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow-y: auto;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.sheet-left { left: 0; border-right: 1px solid var(--line); }
.sheet-right { right: 0; border-left: 1px solid var(--line); }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px 12px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; }
.sheet-head .head-icon { color: var(--muted); }
.sheet-body { padding: 8px 18px 18px; }
.sheet-foot { padding-top: 12px; border-top: 1px solid var(--line); margin-top: 12px; }

.feed-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.feed-item.unread .row-label::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--accent);
}

/* ── More, as tiles ────────────────────────────────────────────────────── */

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: var(--gap); }
.tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 104px;
  padding: 16px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
}
.tile-icon { font-size: 1.5rem; }
.tile-label { font-weight: 600; }
.tile-hint { color: var(--muted); font-size: 0.76rem; text-align: center; }

/* ── Money in: what each choice does to the return ─────────────────────── */

.credit-groups { display: grid; gap: 14px; margin: 16px 0; }
.credit-group { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }

.credit-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface-2);
}
.credit-group-label { font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.credit-group.earnings .credit-group-label { color: var(--warm); }
.credit-group.ignored .credit-group-label { color: var(--muted); }
.credit-group-effect { font-size: 0.76rem; color: var(--muted); text-align: right; }

.credit-button {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border: 0;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.credit-button:first-of-type { border-top: 0; }
.credit-button:active { background: var(--surface-2); }
.credit-label { display: block; font-weight: 600; }
.credit-effect { display: block; }

.reversal-picker {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.reversal-picker > .muted { padding: 8px 14px; background: var(--surface-2); }

.scope-label.hidden { display: none; }

/* A back arrow on the left, where a thumb reaches for it. */
.screen-head.with-back { justify-content: flex-start; gap: 10px; }

.back-button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  margin-left: -8px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: none;
  color: inherit;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}
.back-button:active { background: var(--surface-2); }

.pct-field { display: flex; align-items: center; gap: 8px; }
.pct-field input { flex: 1; min-width: 0; }
.pct-sign { color: var(--muted); font-size: 1.05rem; }

/* Import: a drop zone rather than a bare file button. */
.drop-zone {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 26px 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: var(--surface-2);
  text-align: center;
  cursor: pointer;
}
.drop-zone:active { border-color: var(--accent); }
.drop-zone input[type='file'] { display: none; }
.drop-icon { font-size: 1.6rem; color: var(--muted); }
.drop-title { font-weight: 600; overflow-wrap: anywhere; }

.import-row {
  display: grid;
  gap: 4px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.import-row:last-child { border-bottom: 0; }
.import-row .badge { justify-self: start; }
.import-duplicate { opacity: 0.7; }
.import-error .badge { background: var(--warm-soft); border-color: var(--warm); }

.advanced-toggle { display: block; width: 100%; text-align: left; padding: 4px 0; }
.advanced-body { margin-top: 12px; }

/* A choice with consequences. See dom.js `ask`. */
.dialog-wrap { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; }

.dialog {
  position: relative;
  z-index: 41;
  width: min(92vw, 420px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}
.dialog h2 { margin-bottom: 6px; }

.dialog-choices { display: grid; gap: 10px; margin: 16px 0 12px; }

.dialog-choice {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.dialog-choice-label { font-weight: 650; }
.dialog-choice.primary-choice { border-color: var(--accent); background: var(--accent-soft); }
.dialog-choice.danger { border-color: var(--warm); }
.dialog-choice.danger .dialog-choice-label { color: var(--warm); }
.dialog-choice:active { transform: scale(0.995); }

.recovery-codes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 0.04em;
}
.recovery-codes code {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  text-align: center;
}
