/* ═══════ 3 PIN REALTY — FINANCE ═══════

   The same system as the landing page: a warm paper ground, espresso ink, hairlines rather
   than boxes, Instrument Serif carrying the hierarchy and Instrument Sans doing the work,
   tabular numerals wherever a figure sits in a column.

   Colour is spent carefully. Primary actions are espresso. The brand orange is one accent per
   screen — the active tab, the hero figure, the Record button — never every button at once.
   Type does the rest: five sizes with real distance between them, so a heading, a label, a
   figure and a hint can never be mistaken for one another.

   Mobile first: this is used standing in a site office on a phone far more than at a desk. */

:root {
  color-scheme: light;

  /* Brand — one accent, three strengths */
  --brand: #F58A07;
  --brand-600: #DB7A05;
  --brand-200: #F9C88A;
  --brand-soft: #FDF1E3;

  /* Espresso — the primary surface and the primary button */
  --es: #191108;
  --es-2: #241809;
  --on-es: #FAF7F2;
  --on-es-2: #B5A896;

  /* Working surface */
  --bg: #FBFAF8;
  --card: #FFFFFF;
  --card-2: #F5F2ED;
  --line: #E7E1D7;
  /* The band on every other row — barely there on its own, decisive across a wide table. */
  --band: #FAF8F4;
  --line-2: #D3CABC;
  --ink: #17150F;
  --ink-2: #5A5348;
  --ink-3: #8A8174;

  --good: #1F7A4D;
  --good-soft: #EAF4EE;
  --bad: #B3261E;
  --bad-soft: #FBEDEB;
  --warn: #8A5A00;
  --warn-soft: #FBF3E4;
  /* Money going out is a direction, not a fault: rust, so red is left meaning "wrong". */
  --out: #9A4A2C;
  --out-soft: #F6ECE6;

  /* Aliases the views and inline styles already use */
  --brand-dark: var(--brand-600);
  --brand-line: var(--brand-200);
  --panel: var(--card);
  --sunk: var(--card-2);
  --muted: var(--ink-2);
  --faint: var(--ink-3);

  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Fraunces', 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --mono: 'IBM Plex Mono', 'SF Mono', Menlo, monospace;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  --r-sm: 8px;
  --r: 10px;
  --r-md: 12px;
  --r-lg: 18px;
  --ring: 0 0 0 3px rgba(245, 138, 7, .28);
  --shadow: 0 1px 2px rgba(23, 21, 15, .04), 0 12px 32px -12px rgba(23, 21, 15, .12);

  --nav-h: 60px;
  --tab-h: 62px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  font-variant-numeric: tabular-nums;
}

/* ═══════ TYPE SCALE ═══════
   32 / 22 / 15 / 13 / 11. The serif carries the first two; the tracked 11px label is the
   quietest voice on the page. */

h1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2rem;
  line-height: 1.12;
  letter-spacing: -.015em;
  margin: 0 0 var(--s2);
}
h2 {
  border-top: 1px solid var(--line);
  padding-top: var(--s5);
  font-family: var(--serif);
  font-weight: 400;
  font-size: 1.4rem;
  line-height: 1.2;
  letter-spacing: -.01em;
  margin: var(--s10) 0 var(--s3);
}
h1 + h2, .lead + h2, .actions + h2 { margin-top: var(--s6); }
h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.005em;
  margin: 0 0 var(--s2);
}
p { margin: 0 0 var(--s3); }
a { color: var(--brand-600); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.lead { color: var(--ink-2); font-size: 15.5px; line-height: 1.5; margin: 0 0 var(--s5); max-width: 64ch; }
.small { font-size: 13px; }
.muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
.n { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.spacer { flex: 1; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }

/* The tracked micro-label — table heads, stat labels, group names. */
.eh, th, .stat .l {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ═══════ ACCESSIBILITY ═══════ */

:focus-visible { outline: 0; box-shadow: var(--ring); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 200; background: var(--es); color: var(--on-es); padding: 10px 14px; border-radius: var(--r); transition: top .15s; }
.skip-link:focus { top: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ═══════ LOGIN ═══════ */

.login { position: fixed; inset: 0; z-index: 300; display: none; align-items: center; justify-content: center; background: var(--bg); padding: var(--s6); }
.login.open { display: flex; }
.login-card { width: 100%; max-width: 360px; }
.login-card .mark { width: 56px; height: 56px; border-radius: 14px; display: block; margin-bottom: var(--s6); object-fit: cover; border: 1px solid var(--line); }
.login-card h1 { font-size: 2.1rem; }
.login-err { display: none; background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: var(--r); font-size: 13px; margin-bottom: var(--s3); }
.login-err.show { display: block; }

/* ═══════ SHELL ═══════ */

.top {
  position: sticky; top: 0; z-index: 60;
  height: var(--nav-h);
  display: flex; align-items: center; gap: var(--s3);
  padding: 0 var(--s4);
  background: rgba(251, 250, 248, .9);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; font-family: var(--serif); font-size: 19px; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; display: block; border: 1px solid var(--line); }
.brand .small { font-family: var(--sans); font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-left: 2px; }
.top .btn { white-space: nowrap; }
.who { font-size: 12.5px; color: var(--ink-3); }

/* A reading aid, so it stays quiet: hairline, small caps, and only the active side inked. */
.cur-tog { display: inline-flex; border: 1px solid var(--line-2); border-radius: 999px; overflow: hidden; background: var(--card); flex: none; }
.cur-tog button {
  border: 0; background: none; cursor: pointer; font: inherit;
  font-size: 10.5px; font-weight: 600; letter-spacing: .08em;
  padding: 5px 9px; min-height: 28px; color: var(--ink-3); transition: background .15s, color .15s;
}
.cur-tog button + button { border-left: 1px solid var(--line); }
.cur-tog button:hover { color: var(--ink); }
.cur-tog button.on { background: var(--es); color: var(--on-es); }

.shell { display: block; }
.side { display: none; }

main { padding: var(--s6) var(--s4) calc(var(--tab-h) + var(--s8)); max-width: 1080px; margin: 0 auto; min-width: 0; width: 100%; }
/* go() focuses main for screen readers; the ring is for controls, not the page. */
main:focus, main:focus-visible { outline: 0; box-shadow: none; }
main > * { animation: rise .18s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ═══════ BOTTOM TABS (phone) ═══════ */

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  height: var(--tab-h);
  display: flex; align-items: stretch;
  background: rgba(251, 250, 248, .96);
  backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom button {
  flex: 1; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: inherit; font-size: 10.5px; letter-spacing: .02em; color: var(--ink-3);
  min-height: 44px; padding: 0; position: relative;
}
.bottom button .ic { font-size: 16px; line-height: 1; height: 18px; display: grid; place-items: center; }
.bottom button.on { color: var(--ink); font-weight: 600; }
.bottom button.on::after { content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; background: var(--brand); border-radius: 0 0 2px 2px; }
.bottom button.rec .ic {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 20px; margin-top: -2px;
  box-shadow: 0 6px 16px -6px rgba(245, 138, 7, .6);
}
.bottom button.rec { color: var(--ink); font-weight: 600; }
.bottom button.rec.on::after { display: none; }

.sheet { position: fixed; inset: 0; z-index: 90; display: none; background: rgba(25, 17, 8, .38); align-items: flex-end; }
.sheet.open { display: flex; }
.sheet-inner { width: 100%; background: var(--bg); border-radius: 18px 18px 0 0; padding: var(--s4) var(--s4) calc(var(--s5) + env(safe-area-inset-bottom)); max-height: 78vh; overflow: auto; }
.sheet-inner h3 { font-family: var(--serif); font-weight: 400; font-size: 1.25rem; margin-bottom: var(--s3); }
.sheet-grid { display: block; }
.sheet-grid button {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r-md);
  padding: 14px 8px; font: inherit; font-size: 12.5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 44px; color: var(--ink-2);
}
.sheet-grid button.on { border-color: var(--ink); color: var(--ink); font-weight: 600; }

/* ═══════ CARDS & STATS ═══════ */

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); margin-bottom: var(--s3); }
.card.pad0 { padding: 0; overflow: hidden; }

.grid { display: grid; gap: var(--s3); grid-template-columns: repeat(2, 1fr); margin-bottom: var(--s3); }
.grid.g1 { grid-template-columns: 1fr; }
.grid.g3 { grid-template-columns: repeat(2, 1fr); }

.stat { padding: 14px 16px 16px; }
.stat .l { margin-bottom: var(--s2); }
.stat .v { font-family: var(--sans); font-weight: 600; font-size: 1.7rem; line-height: 1.1; letter-spacing: -.03em; font-variant-numeric: tabular-nums lining-nums; color: var(--ink); }
.stat .s { font-size: 12.5px; color: var(--ink-3); margin-top: var(--s2); line-height: 1.4; }
.stat.hero { background: var(--card-2); border-color: var(--line); position: relative; overflow: hidden; }
.stat.hero::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--brand); }

/* ═══════ BUTTONS ═══════ */

.btn {
  appearance: none; border: 1px solid var(--line-2); background: var(--card); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 500; letter-spacing: -.005em;
  padding: 10px 16px; border-radius: var(--r); cursor: pointer;
  min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, border-color .15s, color .15s, transform .08s;
}
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--es); border-color: var(--es); color: var(--on-es); }
.btn.primary:hover:not(:disabled) { background: var(--es-2); border-color: var(--es-2); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover:not(:disabled) { background: var(--card-2); border-color: transparent; color: var(--ink); }
.btn.sm { padding: 6px 12px; font-size: 13px; min-height: 36px; }
.btn.danger { color: var(--bad); border-color: #EBC7C3; }
.btn.danger:hover:not(:disabled) { background: var(--bad-soft); border-color: var(--bad); }
.btn.block { width: 100%; }

.actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s4); }

/* Deal actions read as money in / bill it / money out rather than one undifferentiated row,
   so the thing you came to record is findable without reading every button. */
.actiongroup { margin-bottom: var(--s3); }
.actiongroup > .small { margin-bottom: var(--s1); }
.actiongroup > .actions { margin-bottom: 0; }

/* ═══════ FORMS ═══════ */

.field { margin-bottom: var(--s4); }
.field > label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.field .hint { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; line-height: 1.45; }
.ferr { font-size: 12.5px; margin-top: 6px; line-height: 1.4; font-weight: 500; padding: 6px 10px; border-radius: var(--r-sm); }
.ferr.err { color: var(--bad); background: var(--bad-soft); }
.ferr.warn { color: var(--warn); background: var(--warn-soft); }
.field.has-err input, .field.has-err select { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.field.has-warn input, .field.has-warn select { border-color: #D9A441; }
.warn-ink { color: var(--warn); }

/* Direction — green for money in, red for money out, slate for moving your own money, amber
   for corrections. On the chooser it is a left rule; on the form and the result it is the
   same rule, so the colour follows the entry from the first tap to the confirmation. */
.dir-in { --dir: var(--good); --dir-soft: var(--good-soft); }
.dir-out { --dir: var(--out); --dir-soft: var(--out-soft); }
.dir-move { --dir: #4A5B73; --dir-soft: #EDF1F6; }
.dir-fix { --dir: var(--warn); --dir-soft: var(--warn-soft); }
.dir-setup { --dir: var(--ink-3); --dir-soft: var(--card-2); }
.chooser-grid button[class*="dir-"] { border-left: 4px solid var(--dir); }
.chooser-grid button[class*="dir-"]:hover { background: var(--dir-soft); }
.result[class*="dir-"]::before { background: var(--dir); }
.dirtag { display: inline-block; vertical-align: middle; font-family: var(--sans); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; background: var(--dir-soft); color: var(--dir); margin-left: 8px; }
.btn.in, .btn.out { border-left: 3px solid var(--dir); color: var(--ink); }
.btn.in { --dir: var(--good); --dir-soft: var(--good-soft); }
.btn.out { --dir: var(--out); --dir-soft: var(--out-soft); }
.btn.in:hover:not(:disabled), .btn.out:hover:not(:disabled) { background: var(--dir-soft); }

/* Allocation table inside a form */
.alloc table { font-size: 13px; }
.alloc input { max-width: 130px; min-height: 36px; padding: 6px 8px; text-align: right; }
.alloc tfoot td { font-weight: 600; }

/* Documents under a party on the Owed lists */
.doclist { margin-top: 6px; display: grid; gap: 3px; }
.docrow { display: grid; grid-template-columns: minmax(0, 1.4fr) auto auto; gap: 8px; align-items: baseline; font-size: 12.5px; color: var(--ink-2); }
.docrow .n { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.docrow > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

input[type=text], input[type=number], input[type=date], input[type=month],
input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
  padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--card); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: none; box-shadow: var(--ring); }
input[type=number] { font-variant-numeric: tabular-nums; }
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
select { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }

.picker { position: relative; }
.picker-results { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); max-height: 240px; overflow: auto; }
.picker-results button { display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; padding: 11px 14px; cursor: pointer; min-height: 44px; border-bottom: 1px solid var(--line); color: var(--ink); }
.picker-results button:last-child { border-bottom: 0; }
.picker-results button:hover, .picker-results button:focus { background: var(--card-2); }
.picker-results .add { color: var(--brand-600); font-weight: 600; }
.chip-sel { display: inline-flex; align-items: center; gap: 8px; background: var(--card-2); border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 8px 6px 14px; font-size: 13.5px; font-weight: 500; }
.chip-sel button { border: 0; background: none; cursor: pointer; font: inherit; color: var(--ink-3); padding: 4px 6px; }

/* ═══════ RECORD SCREEN ═══════ */

.chooser-group { margin-bottom: var(--s6); }
.chooser-group .eh { margin: 0 0 var(--s2); padding-left: 2px; }
.chooser-grid { display: grid; gap: var(--s2); grid-template-columns: 1fr; }
.chooser-grid button {
  text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: var(--r-md);
  padding: 13px 16px; font: inherit; cursor: pointer; min-height: 44px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  transition: border-color .15s, background .15s;
}
.chooser-grid button:hover { border-color: var(--ink-3); background: var(--card-2); }
.chooser-grid b { font-weight: 500; font-size: 15px; letter-spacing: -.005em; }
.chooser-grid .sub { font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }

.preview { position: static; }
.preview .when { background: var(--card-2); border-radius: var(--r-md); padding: 12px 14px; font-size: 13.5px; margin-bottom: var(--s4); color: var(--ink-2); line-height: 1.5; }
.effects { list-style: none; margin: 0 0 var(--s3); padding: 0; }
.effects li { position: relative; padding: 0 0 0 20px; margin-bottom: 8px; font-size: 14px; line-height: 1.45; }
.effects li::before { content: '→'; position: absolute; left: 0; color: var(--brand); font-weight: 600; }
.balanced { font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.balanced.ok { color: var(--good); }
.balanced.no { color: var(--bad); }

details.journal { border-top: 1px solid var(--line); padding-top: var(--s2); }
details.journal summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 8px; min-height: 44px; }
details.journal summary::-webkit-details-marker { display: none; }
details.journal summary::before { content: '▸'; color: var(--ink-3); transition: transform .15s; }
details.journal[open] summary::before { transform: rotate(90deg); }

.desk-only { display: none; }

/* ═══════ TABLES ═══════ */

/* A table has to answer two questions at a glance: which row am I on, and which column is
   this. Hairlines alone answer neither once a table is wider than the screen. So: banded
   rows to track across, a ruled and shaded header that stays put while the body scrolls,
   faint column rules, and a shadow at the edge that admits there is more to the right. */
.tbl-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(to right, var(--card) 30%, rgba(255, 255, 255, 0)) left / 24px 100% no-repeat,
    linear-gradient(to left, var(--card) 30%, rgba(255, 255, 255, 0)) right / 24px 100% no-repeat,
    radial-gradient(farthest-side at 0 50%, rgba(23, 21, 15, .10), transparent) left / 12px 100% no-repeat,
    radial-gradient(farthest-side at 100% 50%, rgba(23, 21, 15, .10), transparent) right / 12px 100% no-repeat;
  background-attachment: local, local, scroll, scroll;
}
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th {
  text-align: left; padding: 11px 14px; white-space: nowrap;
  background: var(--card-2); border-bottom: 2px solid var(--line-2);
  position: sticky; top: 0; z-index: 2;
}
th.n { text-align: right; }
td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; line-height: 1.45; }
td.n { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
/* A faint rule between columns, so a figure cannot drift into its neighbour's column. */
th + th, td + td { border-left: 1px solid var(--line); }
tbody tr:nth-child(even) { background: var(--band); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; transition: background .12s; }
tbody tr.click:hover, tbody tr.click:focus-within { background: var(--brand-soft); }
tfoot td { font-weight: 600; border-top: 2px solid var(--line-2); border-bottom: 0; background: var(--card-2); }
.card.pad0 table thead th:first-child, .card.pad0 table td:first-child { padding-left: 18px; }
.card.pad0 table thead th:last-child, .card.pad0 table td:last-child { padding-right: 18px; }

.tag {
  display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em;
  padding: 3px 7px; border-radius: 5px; background: var(--card-2); color: var(--ink-2); border: 1px solid var(--line);
  vertical-align: middle; margin-left: 6px;
}
.tag.auto { background: var(--brand-soft); color: var(--brand-600); border-color: var(--brand-200); }
.tag.rev { background: var(--bad-soft); color: var(--bad); border-color: #EBC7C3; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: #EBD9B4; }
.tag.ok { background: var(--good-soft); color: var(--good); border-color: #C3DDCC; }

/* A reversed entry and its reversal: still on the record, visibly no longer counted. */
tr.undone td { color: var(--ink-3); }
tr.undone td.lead { text-decoration: line-through; text-decoration-color: var(--line-2); }
tr.undone td.lead .tag { text-decoration: none; }

/* ═══════ STATES ═══════ */

.empty { border: 1px dashed var(--line-2); border-radius: var(--r-lg); padding: var(--s8) var(--s5); text-align: center; color: var(--ink-2); font-size: 14.5px; line-height: 1.55; }
.empty b { color: var(--ink); }
.empty .btn { margin-top: var(--s3); }

.skel { background: linear-gradient(90deg, var(--card-2) 25%, #EEE9E1 37%, var(--card-2) 63%); background-size: 400% 100%; animation: sh 1.3s ease-in-out infinite; border-radius: 6px; }
@keyframes sh { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skel-line { height: 13px; margin-bottom: 9px; }
.skel-card { height: 74px; margin-bottom: var(--s3); border-radius: var(--r-lg); }

.note { background: var(--warn-soft); border: 1px solid #EBD9B4; color: var(--warn); border-radius: var(--r-md); padding: 12px 14px; font-size: 13.5px; line-height: 1.5; margin-bottom: var(--s4); }
.note.info { background: var(--card-2); border-color: var(--line); color: var(--ink-2); }

/* ═══════ MODAL & DRAWER ═══════ */

.ov { position: fixed; inset: 0; z-index: 100; display: none; background: rgba(25, 17, 8, .42); padding: 0; align-items: flex-end; justify-content: center; }
.ov.show { display: flex; }
.modal { background: var(--bg); width: 100%; max-width: 640px; border-radius: 18px 18px 0 0; max-height: 92vh; overflow: auto; padding-bottom: env(safe-area-inset-bottom); }
.modal-head { position: sticky; top: 0; background: var(--bg); z-index: 2; display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.3rem; letter-spacing: -.01em; }
.modal-body { padding: var(--s5); }
.modal-foot { position: sticky; bottom: 0; background: var(--bg); border-top: 1px solid var(--line); padding: var(--s3) var(--s5); display: flex; gap: var(--s2); align-items: center; }

/* ═══════ TOAST ═══════ */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--tab-h) + 16px); z-index: 200;
  background: var(--es); color: var(--on-es); padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; display: flex; align-items: center; gap: 14px; max-width: calc(100vw - 32px);
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast button { background: none; border: 0; color: var(--brand-200); font: inherit; font-weight: 600; cursor: pointer; padding: 2px 4px; }

/* ═══════ PROGRESS / LISTS ═══════ */

.bar { height: 6px; background: var(--card-2); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 999px; }

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.45; }
.checklist li:last-child { border-bottom: 0; }
.checklist .mark { flex: none; min-width: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.checklist .done .mark { color: var(--good); }
.checklist .todo .mark { color: var(--ink-3); }

.thumbs { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.thumb { position: relative; width: 64px; height: 64px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--card-2); display: grid; place-items: center; font-size: 11px; color: var(--ink-3); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(25, 17, 8, .7); color: #fff; cursor: pointer; font-size: 12px; display: grid; place-items: center; padding: 0; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); overflow: hidden; background: var(--card); }
.seg button { border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 500; padding: 9px 14px; cursor: pointer; min-height: 40px; border-right: 1px solid var(--line); color: var(--ink-2); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--es); color: var(--on-es); }

.filters { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s3); }
.filters select, .filters input { width: auto; min-width: 130px; flex: 1 1 130px; font-size: 14px; min-height: 40px; padding: 8px 12px; }

/* ═══════ SAVE RESULT ═══════ */

.result { border-radius: var(--r-lg); padding: var(--s5); margin-bottom: var(--s4); border: 1px solid var(--line); background: var(--card); position: relative; overflow: hidden; }
.result::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.result.ok::before { background: var(--good); }
.result.err::before { background: var(--bad); }
.result.warn::before { background: var(--brand); }
.result h3 { margin: 0 0 2px; font-family: var(--serif); font-weight: 400; font-size: 1.35rem; }
.result.ok h3 { color: var(--good); }
.result.err h3 { color: var(--bad); }
.result .big { font-family: var(--sans); font-weight: 600; font-size: 2.1rem; line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: var(--s2) 0 var(--s1); }
.result .actions { margin: var(--s4) 0 0; }
.result .btn { min-height: 44px; }

.eno { font-family: var(--mono); font-size: 12px; color: var(--ink-3); letter-spacing: .02em; }

/* ═══════ ATTACHMENTS ═══════ */

.stage { list-style: none; margin: var(--s3) 0 0; padding: 0; }
.stage li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.stage li:last-child { border-bottom: 0; }
.stage .pv { width: 46px; height: 46px; border-radius: 8px; flex: none; overflow: hidden; background: var(--card-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: 10px; font-weight: 600; color: var(--ink-3); }
.stage .pv img { width: 100%; height: 100%; object-fit: cover; }
.stage .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage .st { font-size: 12px; white-space: nowrap; }
.stage .st.ok { color: var(--good); font-weight: 600; }
.stage .st.err { color: var(--bad); font-weight: 600; }
.stage .st.busy { color: var(--ink-2); }
.stage .rm { border: 0; background: none; color: var(--ink-3); cursor: pointer; padding: 8px; font: inherit; min-width: 44px; min-height: 44px; }

.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--s3); }
.att { display: block; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--card-2); text-decoration: none; color: var(--ink); position: relative; }
.att .img { aspect-ratio: 4 / 3; display: grid; place-items: center; background: var(--card-2); overflow: hidden; font-weight: 600; color: var(--ink-3); font-size: 12px; }
.att .img img { width: 100%; height: 100%; object-fit: cover; }
.att .cap { font-size: 11.5px; padding: 6px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--card); }
.att .del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(25, 17, 8, .7); color: #fff; cursor: pointer; font-size: 13px; display: grid; place-items: center; padding: 0; }

/* ═══════ PHONE LAYOUT ═══════ */

@media (max-width: 859px) {
  .who { display: none; }
  .top { gap: var(--s2); padding: 0 var(--s3); }
  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.3rem; }
  .stat .v { font-size: 1.6rem; }
  .card { padding: var(--s4); }
  .save-bar {
    position: sticky; bottom: calc(var(--tab-h) + 8px); z-index: 30;
    background: rgba(251, 250, 248, .97); backdrop-filter: saturate(160%) blur(14px);
    border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
    padding: 10px 10px 10px 14px; margin: var(--s3) 0; display: flex; gap: var(--s2); align-items: center;
  }
  .save-bar .sum { flex: 1; min-width: 0; font-size: 12.5px; line-height: 1.3; color: var(--ink-2); }
  .save-bar .sum b { color: var(--ink); font-weight: 600; font-size: 16px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
  .row2 { grid-template-columns: 1fr; }
  td.n.nowrap { white-space: normal; }
  td .btn.sm { margin: 2px 4px 2px 0; }
  .filters select, .filters input { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .filters input[type=search] { flex-basis: 100%; }
  .modal-body { padding: var(--s4); }
  th, td { padding-left: 10px; padding-right: 10px; }
}

/* ═══════ DESKTOP ═══════ */

@media (min-width: 860px) {
  .shell { display: grid; grid-template-columns: 224px 1fr; max-width: 1280px; margin: 0 auto; }

  .side { display: block; position: sticky; top: var(--nav-h); align-self: start; height: calc(100vh - var(--nav-h)); overflow-y: auto; padding: var(--s4) var(--s3) var(--s6); border-right: 1px solid var(--line); }
  .side .eh { margin: var(--s5) 12px var(--s2); }
  .side .eh:first-child { margin-top: var(--s2); }
  .side button {
    display: flex; align-items: center; width: 100%; text-align: left;
    border: 0; background: none; font: inherit; font-size: 14.5px; color: var(--ink-2);
    padding: 8px 12px 8px 20px; border-radius: var(--r); cursor: pointer; margin-bottom: 1px; min-height: 38px;
    position: relative; transition: background .12s, color .12s;
  }
  .side button:hover { background: var(--card-2); color: var(--ink); }
  .side button.on { color: var(--ink); font-weight: 600; background: var(--card-2); }
  .side button.on::before { content: ''; position: absolute; left: 8px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--brand); }

  .bottom { display: none; }
  main { padding: var(--s8) var(--s8) var(--s12); max-width: none; margin: 0; width: 100%; min-width: 0; }
  .shell > * { min-width: 0; }

  .grid { grid-template-columns: repeat(3, 1fr); }
  .grid.g1 { grid-template-columns: 1fr; }
  .grid.g3 { grid-template-columns: repeat(4, 1fr); }

  .record-split { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s6); align-items: start; }
  .preview { position: sticky; top: calc(var(--nav-h) + var(--s5)); }

  .ov { align-items: center; padding: var(--s6); }
  .modal { border-radius: var(--r-lg); max-height: 86vh; box-shadow: var(--shadow); }
  .toast { bottom: var(--s6); }
}

@media (min-width: 1100px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

/* ═══════ PRINT ═══════ */

@media print {
  .top, .side, .bottom, .actions, .filters, .btn { display: none !important; }
  main { padding: 0; }
  .card { border: 0; padding: 0; }
  body { background: #fff; }
}

@media (max-width: 430px) {
  .brand .small { display: none; }
  .brand { font-size: 17px; }
}

/* Guide */
.guide-bar { display: flex; gap: var(--s3); flex-wrap: wrap; align-items: center; margin-bottom: var(--s5); }
/* Eight sections will not sit on one line of a phone. The bar wraps to as many rows as it
   needs and each tab keeps a full 44px target rather than shrinking to a sliver. */
.guide-bar .seg { margin: 0; flex-wrap: wrap; height: auto; }
.guide-bar .seg button { flex: 0 1 auto; min-height: 40px; white-space: nowrap; }
.guide-bar input { flex: 1 1 240px; max-width: 380px; }
.guide-screen { border-left: 4px solid var(--line-2); }
.guide-screen table { margin-top: 4px; }
.guide-scenario[class*="dir-"], .guide-action { border-left: 4px solid var(--dir, var(--line-2)); }
.guide-faq { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 12px 14px; margin-bottom: 8px; }
.guide-faq summary { font-weight: 600; color: var(--ink); font-size: 14.5px; }


/* ═══════ A TABLE THAT STACKS ═══════

   Below 640px a wide table stops being a grid and becomes one block per row: each cell on
   its own line with its column heading beside it. Nothing scrolls sideways, and no value is
   ever separated from the heading that explains it. */
@media (max-width: 640px) {
  table.stack { font-size: 14px; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack tbody tr {
    display: block; padding: var(--s3) var(--s4);
    border-bottom: 1px solid var(--line-2);
  }
  table.stack tbody tr:nth-child(even) { background: var(--band); }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack tbody td {
    display: flex; gap: var(--s3); align-items: baseline; justify-content: space-between;
    padding: 3px 0; border: 0; text-align: left; white-space: normal;
  }
  table.stack tbody td::before {
    content: attr(data-label);
    flex: none; font-size: 11px; font-weight: 600; letter-spacing: .09em;
    text-transform: uppercase; color: var(--ink-3);
  }
  table.stack tbody td:not([data-label])::before { content: none; }
  /* The first cell is the row's name, so it leads rather than sitting in a label pair. */
  table.stack tbody td.lead {
    display: block; font-size: 15px; font-weight: 600; color: var(--ink);
    padding-bottom: var(--s2); margin-bottom: var(--s2); border-bottom: 1px solid var(--line);
  }
  table.stack tbody td.lead::before { content: none; }
  /* The card's edge padding belongs to the row now, so the cells inside it start flush —
     otherwise the first cell sits 18px in and nothing lines up under it. */
  .card.pad0 table.stack tbody td:first-child,
  .card.pad0 table.stack tbody td:last-child,
  .card.pad0 table.stack tfoot td:first-child,
  .card.pad0 table.stack tfoot td:last-child { padding-left: 0; padding-right: 0; }
  table.stack tbody td.n { justify-content: space-between; }
  table.stack tbody td .btn.sm { margin: 4px 6px 0 0; }
  table.stack tfoot td { display: flex; justify-content: space-between; border: 0; }
  table.stack tfoot td[data-label]::before { content: attr(data-label); font-weight: 600; }
  table.stack tfoot td:first-child { display: block; font-weight: 600; padding-bottom: 4px; }
  .tbl-wrap { background: none; }
}


/* ═══════ RECORD — MONEY IN / MONEY OUT FIRST ═══════ */
.dir-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); margin-bottom: var(--s3); }
.dir-tiles .tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  border: 1.5px solid var(--line-2); border-left: 5px solid var(--dir); border-radius: var(--r-lg);
  background: var(--card); padding: var(--s4); cursor: pointer; font: inherit; min-height: 96px;
  transition: background .12s, border-color .12s;
}
.dir-tiles .tile i { color: var(--dir); font-size: 18px; }
.dir-tiles .tile b { font-size: 17px; letter-spacing: -.01em; color: var(--ink); }
.dir-tiles .tile span { font-size: 12.5px; color: var(--ink-3); line-height: 1.35; }
.dir-tiles .tile:hover, .dir-tiles .tile.on { background: var(--dir-soft); border-color: var(--dir); }
.dir-chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-bottom: var(--s4); }
.dir-chips .chip {
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--card); padding: 7px 14px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 36px;
}
.dir-chips .chip[class*="dir-"] { border-left: 4px solid var(--dir); }
.dir-chips .chip.on { background: var(--es); color: var(--on-es); border-color: var(--es); }

/* ═══════ POSTING STRIP ═══════ */
.posting { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; margin: 0 0 var(--s3); background: var(--card-2); font-size: 13.5px; }
.post-row { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 3px 0; }
.post-row + .post-row { border-top: 1px dashed var(--line); }
.post-lbl { flex: none; width: 46px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.post-acc { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: baseline; font-weight: 600; color: var(--ink); }
.post-acc .code { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--ink-3); background: var(--card); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

/* ═══════ PETTY-CASH SCOPE ═══════ */
.scope-tog { margin-right: 6px; }
.scope-tog .lbl { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 0 8px; align-self: center; }
.scope-tog.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.scope-banner {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--brand-soft); border: 1px solid var(--brand-200); border-radius: var(--r-md);
  padding: 10px 14px; margin: 0 0 var(--s4); font-size: 13.5px; color: var(--ink);
}
.scope-banner .btn { margin-left: auto; }
.budget-in { max-width: 130px; min-height: 36px; padding: 6px 8px; text-align: right; }
@media (max-width: 859px) {
  .scope-tog .lbl { display: none; }
  .dir-tiles .tile { min-height: 84px; padding: var(--s3); }
}

/* The Record switch — which of the two books you are reading: in the header on a desk, at
   the top of the page on a phone. */
.scope-inline { display: none; align-items: center; gap: 10px; margin: 0 0 var(--s3); }
.scope-inline .lbl { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.scope-inline .seg { margin: 0; }
@media (max-width: 859px) {
  #scopeTog { display: none; }
  .scope-inline { display: flex; }
}


/* Collapsible groups on This month and the Books registers: the summary is a row in its own
   right, with the amount pushed to the end, so the page reads as a list of totals until one
   is opened. */
details.bucket { margin: 10px 0; }
details.bucket > summary {
  cursor: pointer; padding: 12px 14px; display: flex; align-items: baseline; gap: 10px;
  min-height: 44px; list-style: none;
}
details.bucket > summary::-webkit-details-marker { display: none; }
details.bucket > summary::before { content: '▸'; color: var(--muted); font-size: 12px; }
details.bucket[open] > summary::before { content: '▾'; }
details.bucket > summary .n { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
details.bucket > summary:hover { background: var(--hover, rgba(0,0,0,.03)); }
details.bucket[open] > summary { border-bottom: 1px solid var(--line); }


/* ═══════ SIDE NAV MODULES ═══════
   Five modules instead of eighteen links. The header is a real button — bold and a size up
   from the links beneath it, so the eye lands on the module first and the page second. The
   module holding the current page cannot be collapsed shut; when every other module is
   closed, that one still shows where you are. */

.side .mod { margin-bottom: 2px; }
.side .mod-h {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: none; cursor: pointer; font: inherit;
  padding: 10px 10px 10px 12px; border-radius: var(--r);
  color: var(--ink); font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  text-align: left; min-height: 42px; transition: background .12s;
}
.side .mod-h:hover { background: var(--card-2); }
.side .mod-name { flex: 1; }
.side .mod-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); flex: none; }
.side .mod-chev {
  font-size: 11px; color: var(--ink-3); flex: none;
  transition: transform .16s ease;
}
.side .mod.open .mod-chev { transform: rotate(180deg); }
.side .mod-body { display: none; padding: 0 0 8px; }
.side .mod.open .mod-body { display: block; animation: modOpen .16s ease-out both; }
@keyframes modOpen { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
.side .mod-note {
  margin: 0 12px 6px 20px; font-size: 11.5px; line-height: 1.35; color: var(--ink-3);
}
.side .mod-body button { gap: 10px; font-size: 14px; padding-left: 20px; }
.side .mod-body button .ic { font-size: 12.5px; width: 16px; text-align: center; color: var(--ink-3); flex: none; }
.side .mod-body button.on .ic { color: var(--brand); }
.side .mod-body button.on::before { left: 6px; }

/* The phone sheet teaches the same map as the sidebar. */
.sheet-mod + .sheet-mod { margin-top: var(--s5); }
.sheet-mod { max-width: 100%; }
.sheet-mod-h {
  font-size: 15px; font-weight: 700; color: var(--ink); margin: 0 0 8px;
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.sheet-mod-h span { font-size: 11.5px; font-weight: 400; color: var(--ink-3); flex: 1 1 100%; }
.sheet-mod-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.sheet-mod-grid button {
  border: 1px solid var(--line); background: var(--card); border-radius: var(--r-md);
  padding: 12px 6px; font: inherit; font-size: 12px; line-height: 1.25; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 68px; color: var(--ink-2); text-align: center; overflow-wrap: anywhere;
}
.sheet-mod-grid button.on { border-color: var(--ink); color: var(--ink); font-weight: 600; }


/* Four steps of one story: stacked on a phone, side by side once there is room. Forcing four
   columns at 390px is what pushed the guide into horizontal scroll. */
.grid.four-up { grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid.four-up { grid-template-columns: repeat(4, 1fr); } }


/* The sheet is the whole navigation on a phone, so it gets the room it needs and never the
   width it does not: nothing inside it may push the sheet sideways. */
.sheet-inner { max-height: 86vh; }
.sheet-inner > * { max-width: 100%; }
.sheet-mod-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 359px) { .sheet-mod-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }


/* Density and contrast, once every module is open by default: eighteen links and five headers
   have to fit a laptop screen without scrolling, and a link you can barely read is not a link.
   The description under each module header lives in its tooltip and in the phone sheet. */
.side .mod-h { padding: 8px 10px 8px 12px; min-height: 38px; font-size: 14.5px; }
.side .mod-body { padding-bottom: 4px; }
.side .mod-body button { color: var(--ink-2); font-size: 14px; min-height: 34px; padding-top: 6px; padding-bottom: 6px; }
.side .mod-body button:hover { color: var(--ink); }
.side .mod-body button .ic { color: var(--ink-3); opacity: .85; }
.side .mod + .mod { margin-top: 2px; border-top: 1px solid var(--line); padding-top: 2px; }


/* ═══════ OPENABLE FIGURES ═══════
   A total you can click says so quietly: the chevron appears on hover or focus, the tile
   lifts, and the whole card is one 44px target. Nothing moves on the page when it is not
   being touched, so a wall of stats still reads as a wall of stats. */
.stat.drill { cursor: pointer; position: relative; transition: border-color .12s, transform .12s; }
.stat.drill:hover, .stat.drill:focus-visible { border-color: var(--line-2); transform: translateY(-1px); }
.stat.drill:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.stat .drill-mark {
  position: absolute; top: 12px; right: 12px; color: var(--ink-3); font-size: 15px; line-height: 1;
  opacity: 0; transition: opacity .12s;
}
.stat.drill:hover .drill-mark, .stat.drill:focus-visible .drill-mark { opacity: 1; }
tr.click[role="button"]:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.bar.drill { cursor: pointer; }
.bar.drill:hover i { filter: brightness(1.08); }


/* ═══════ RECORD v2 ═══════
   Search first, "your usual" second, groups with the everyday actions open and the rare ones
   folded by name. The form leads with the amount and stays quiet until touched; one save bar
   serves both widths; on a phone the preview is a sheet one tap from Save. */
:root {
  --ease: cubic-bezier(.2, .7, .2, 1);
  --d1: 120ms; --d2: 180ms; --d3: 280ms;
  --form-w: 560px;
  --amt-size: 28px;
}

.rec-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3) var(--s6); margin-bottom: var(--s3); }
.rec-head h1 { margin: 0; flex: 1 1 260px; }
.rec-find { position: relative; flex: 1 1 320px; max-width: 520px; }
.rec-find input[type=search] {
  font-size: 17px; min-height: 52px; padding: 12px 48px 12px 46px; border-radius: 999px;
  border-color: var(--line-2); background-color: var(--card);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238A8174' stroke-width='2' stroke-linecap='round'><circle cx='11' cy='11' r='7'/><path d='m20 20-3.5-3.5'/></svg>");
  background-repeat: no-repeat; background-position: 18px 50%;
}
.rec-find input[type=search]::-webkit-search-cancel-button { display: none; }
.rec-find .clr { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; border-radius: 50%; background: none; color: var(--ink-3); cursor: pointer; display: grid; place-items: center; font-size: 16px; }
.rec-find .clr:hover { background: var(--card-2); color: var(--ink); }
@media (max-width: 859px) {
  .rec-head { display: block; }
  .rec-head h1 { margin-bottom: var(--s3); }
  .rec-find { position: sticky; top: var(--nav-h); z-index: 20; max-width: none; padding: var(--s2) 0; margin: 0 0 var(--s1);
    background: linear-gradient(var(--bg) 82%, rgba(251, 250, 248, 0)); }
}

.rec-groups { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  margin: 0 calc(-1 * var(--s4)); padding: 2px var(--s4) var(--s3); scroll-snap-type: x proximity; }
.rec-groups::-webkit-scrollbar { display: none; }
.rec-groups .chip {
  flex: none; scroll-snap-align: start; display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--card);
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer;
  transition: background var(--d1), color var(--d1), border-color var(--d1);
}
.rec-groups .chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dir, var(--ink-3)); flex: none; }
.rec-groups .chip .cnt { font-weight: 500; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rec-groups .chip:hover { border-color: var(--ink-3); color: var(--ink); }
.rec-groups .chip[aria-pressed="true"] { background: var(--es); border-color: var(--es); color: var(--on-es); }
.rec-groups .chip[aria-pressed="true"] .cnt { color: var(--on-es-2); }
.rec-groups .chip[aria-pressed="true"] .dot { box-shadow: 0 0 0 2px var(--on-es); }
@media (min-width: 860px) { .rec-groups { margin: 0; padding-left: 0; padding-right: 0; flex-wrap: wrap; overflow: visible; } }

.rec-usual { margin: 0 0 var(--s6); }
.rec-usual .eh { margin: 0 0 var(--s2); }
.rec-usual-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
@media (min-width: 860px)  { .rec-usual-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .rec-usual-grid { grid-template-columns: repeat(6, 1fr); } }

/* An action: one card, one rule of colour, one line of type, one line of hint. */
.act {
  position: relative; display: flex; flex-direction: column; gap: 2px; text-align: left; width: 100%;
  min-height: 56px; padding: 11px 14px 11px 20px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--card); font: inherit; color: var(--ink); cursor: pointer;
  transition: border-color var(--d1), background var(--d1), transform var(--d1) var(--ease);
}
.act::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--dir, var(--line-2)); }
.act b { font-weight: 500; font-size: 15px; letter-spacing: -.005em; line-height: 1.3; }
.act[data-tier="daily"] b { font-weight: 600; }
.act .sub { font-size: 13px; color: var(--ink-3); line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.act .grp { position: absolute; right: 12px; top: 12px; font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.act mark { background: var(--brand-soft); color: inherit; border-radius: 2px; padding: 0 1px; }
.act:hover { border-color: var(--line-2); background: var(--card-2); }
.act:active { transform: scale(.985); }
.act.compact { min-height: 48px; padding-top: 10px; padding-bottom: 10px; justify-content: center; }
.act.compact .sub { display: none; }
@media (min-width: 860px) { .act .sub { -webkit-line-clamp: 2; } .rec-hits .act { padding-right: 130px; } }

.rec-group { margin: 0 0 var(--s6); }
.rec-group > .eh { display: flex; align-items: baseline; gap: 8px; margin: 0 0 var(--s2); padding-left: 2px; }
.rec-group > .eh .cnt { font-weight: 500; color: var(--ink-3); letter-spacing: 0; text-transform: none; }
.rec-list { display: grid; gap: var(--s2); grid-template-columns: 1fr; }
@media (min-width: 860px) { .rec-list { grid-template-columns: 1fr 1fr; } }
.rec-fold { display: contents; }
.rec-fold[hidden] { display: none; }
.rec-more { grid-column: 1 / -1; justify-content: flex-start; min-height: 44px; padding-left: 20px; color: var(--ink-2); font-weight: 500; }
.rec-more::before { content: '▸'; font-size: 11px; color: var(--ink-3); margin-right: 8px; transition: transform var(--d1) var(--ease); }
.rec-more[aria-expanded="true"]::before { transform: rotate(90deg); }
.rec-fold .act { animation: rise var(--d2) var(--ease) both; }

/* ── the form ── */
.rec-bar { position: sticky; top: var(--nav-h); z-index: 20; display: flex; align-items: center; gap: var(--s3); min-height: 48px;
  margin: 0 0 var(--s2); background: linear-gradient(var(--bg) 82%, rgba(251, 250, 248, 0)); }
.rec-bar .dirtag { margin-left: auto; }
.rec-title { margin: 0 0 var(--s4); font-size: 1.75rem; }
@media (min-width: 860px) { .rec-title { font-size: 2rem; } }
.form-col { max-width: var(--form-w); }

.field.amt { position: relative; }
.field.amt input { font-family: var(--mono); font-size: var(--amt-size); font-weight: 500; letter-spacing: -.02em;
  min-height: 64px; padding: 10px 16px 10px 44px; text-align: left; }
.field.amt .cur { position: absolute; left: 16px; top: 44px; font-family: var(--mono); font-size: 22px; color: var(--ink-3); pointer-events: none; }
.field.amt input:focus + .cur { color: var(--ink); }

details.more { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: var(--s2) 0 var(--s4); }
details.more > summary { list-style: none; cursor: pointer; min-height: 48px; display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--ink-2); }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '▸'; font-size: 11px; color: var(--ink-3); transition: transform var(--d1) var(--ease); }
details.more[open] > summary::before { transform: rotate(90deg); }
details.more > summary .lbl { flex: none; white-space: nowrap; }
details.more > summary .n { font-weight: 400; color: var(--ink-3); letter-spacing: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
details.more > summary .flag { margin-left: auto; color: var(--bad); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
details.more > .body { padding: var(--s3) 0 var(--s1); animation: rise var(--d2) var(--ease) both; }

/* Quiet errors: one red signal per field, text only; the bar carries the summary. */
.field.has-err input, .field.has-err select { border-color: var(--bad); box-shadow: none; }
.ferr.err { background: none; padding: 2px 0 0; font-weight: 500; }

.field.attach .row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.field.attach .stage { flex-basis: 100%; margin-top: var(--s1); }
.dup { margin: 0; }
.dup .note { margin: 0 0 var(--s3); }
#saveErr .result { margin-bottom: var(--s3); }

/* One save bar for both widths. On a desk it sticks to the bottom of the form column. */
.save-bar { position: sticky; bottom: calc(var(--tab-h) + var(--s2)); z-index: 30; display: flex; align-items: center; gap: var(--s2);
  padding: 10px 10px 10px 14px; margin: var(--s3) 0 0; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: rgba(251, 250, 248, .97); backdrop-filter: saturate(160%) blur(14px); box-shadow: var(--shadow); overflow: hidden; }
.save-bar::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--dir, transparent); }
.save-bar .sum { flex: 1; min-width: 0; font-size: 13px; line-height: 1.3; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.save-bar .sum b { display: block; font-size: 17px; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; font-weight: 600; }
.save-bar .sum .todo { color: var(--ink-2); }
.save-bar .sum .chip { display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); vertical-align: middle; }
.save-bar .btn.primary { min-width: 92px; }
.btn[aria-busy="true"] { color: transparent !important; position: relative; }
.btn[aria-busy="true"]::after { content: ''; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(250, 247, 242, .35); border-top-color: var(--on-es); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.save-bar .pv-open { display: none; }
@media (max-width: 859px) { .save-bar .pv-open { display: inline-flex; } }
@media (min-width: 860px) { .save-bar { bottom: var(--s4); } }
form[aria-busy="true"] { pointer-events: none; opacity: .6; }

/* ── the preview ── */
.preview .about .when { margin: var(--s2) 0 0; }
.pv-empty { margin: 0 0 var(--s2); }
@media (max-width: 859px) {
  .preview { display: none; }
  .pv-sheet .preview { display: block; }
  .pv-sheet .preview .card { border: 0; padding: 0; margin: 0; background: none; }
  .pv-sheet .preview .card > h3 { display: none; }
}
.sheet-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.sheet-head h3 { margin: 0; flex: 1; outline: 0; }
.sheet-head h3:focus, .sheet-head h3:focus-visible { box-shadow: none; outline: 0; }
.sheet-head .btn { min-width: 44px; }
.sheet-foot { display: flex; gap: var(--s2); align-items: center; position: sticky; bottom: 0; background: var(--bg); padding: var(--s3) 0 0; border-top: 1px solid var(--line); margin-top: var(--s4); }
.sheet-inner::before { content: ''; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 0 auto var(--s3); }
.sheet.open .sheet-inner { animation: sheetUp var(--d3) var(--ease) both; }
@keyframes sheetUp { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-signout { margin-top: var(--s4); }
@media (min-width: 860px) { .sheet-signout { display: none; } }
@media (max-width: 859px) { .top .btn.ghost.sm { display: none; } }

/* ── the result ── */
.result h3 .tick { vertical-align: -4px; margin-right: 4px; }
.result.ok h3 .tick path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: tick var(--d3) var(--ease) 100ms forwards; }
@keyframes tick { to { stroke-dashoffset: 0; } }
.big { font-family: var(--sans); font-weight: 600; font-size: 2.1rem; line-height: 1.05; letter-spacing: -.03em; font-variant-numeric: tabular-nums; margin: var(--s2) 0 var(--s1); }

/* ═══════ WHOLE-APP PASS ═══════ */

/* A two-column block that is one column on a phone. */
.grid.two-up { grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid.two-up { grid-template-columns: 1fr 1fr; } }

/* A heading with its one link, instead of a full-sentence button. */
.h2row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.h2row .more { font: 500 14px var(--sans); color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.h2row .more:hover { color: var(--ink); text-decoration: underline; }

/* One accent per screen: the hero tile is the one the page is about; the others are keyed. */
.stat.key { background: var(--card-2); }

/* The bottom tab indicator in ink, so the Record button is the only orange on the bar. */
.bottom button.on::after { background: var(--ink); }

/* The sidebar fits a 900px window: nineteen links and five headers. */
@media (min-width: 860px) {
  .side { padding-top: var(--s2); }
  .side .mod-h { min-height: 34px; padding-top: 6px; padding-bottom: 6px; }
  .side .mod-body button { min-height: 32px; padding-top: 5px; padding-bottom: 5px; }
  .side .mod + .mod { margin-top: 0; padding-top: 0; }
  /* A module animates only when it is opened, not on every repaint. */
  .side .mod .mod-body { animation: none; }
  .side .mod.just-opened .mod-body { animation: modOpen .18s ease-out both; }
}

/* Owed on a phone: the document row wraps instead of painting the date over the note. */
@media (max-width: 640px) {
  .docrow { display: flex; flex-wrap: wrap; gap: 2px 10px; }
  .docrow > span:first-child { flex: 1 1 100%; white-space: normal; }
  .docrow > div { flex-basis: 100%; }
}

/* Transactions on a phone: a two-line ledger row, not six labelled lines and a button. */
table.ledger .phone { display: none; }
@media (max-width: 640px) {
  table.ledger thead { position: absolute; clip: rect(0 0 0 0); }
  table.ledger .desk { display: none; }
  table.ledger .phone { display: block; }
  table.ledger tbody tr { display: grid; grid-template-columns: 1fr auto; gap: 0 var(--s3); padding: 12px var(--s4); border-bottom: 1px solid var(--line); }
  table.ledger td { display: block; padding: 0; border: 0; }
  table.ledger td.lead { grid-column: 1; grid-row: 1; font-size: 15px; font-weight: 500; }
  table.ledger td.amt { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
  table.ledger td.meta { grid-column: 1; grid-row: 2; font-size: 13px; color: var(--ink-3); }
  tr.undone td.amt { color: var(--ink-3); }
}

/* Allocation table on a phone: the figure gets the width. */
@media (max-width: 640px) {
  .alloc table { font-size: 13px; }
  .alloc input { max-width: none; width: 100%; min-height: 44px; }
}

/* Modal figures sit two by two. */
.modal .grid { grid-template-columns: 1fr 1fr; }

/* Transactions: the everyday filters stay out; the rest fold, and a fold with something on opens. */
.filters-more { margin: 0 0 var(--s3); border-top: 0; }
.filters-more > .body { padding-bottom: var(--s2); }


/* ═══════ RECORD — CATEGORIES FIRST ═══════
   Seven tiles, then the actions inside the one chosen. The tile is the biggest thing on the
   screen because it is the first decision; its rule carries the direction colour. */
.cat-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
@media (min-width: 860px) { .cat-tiles { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .cat-tiles { grid-template-columns: repeat(4, 1fr); } }
.cat {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left;
  min-height: 108px; padding: 16px 44px 14px 20px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--card); font: inherit; color: var(--ink); cursor: pointer;
  transition: border-color var(--d1), background var(--d1), transform var(--d1) var(--ease);
}
.cat::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 4px; border-radius: 0 4px 4px 0; background: var(--dir, var(--line-2)); }
.cat b { font-family: var(--serif); font-weight: 500; font-size: 20px; letter-spacing: -.01em; line-height: 1.15; }
.cat .sub { font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.cat .cnt { position: absolute; right: 14px; top: 14px; font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cat:hover { border-color: var(--line-2); background: var(--card-2); }
.cat:active { transform: scale(.985); }
@media (max-width: 859px) { .cat { min-height: 96px; padding: 14px 36px 12px 18px; } .cat b { font-size: 18px; } .cat .sub { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; } }
.cat-head { margin: 0 0 var(--s3); }

/* ═══════ OPENING THE BOOKS ═══════
   On screen until the books are in. The same shapes the overview takes, so nothing jumps when
   the figures arrive; one line of type says what is happening. */

.boot { animation: rise .25s ease both; }
.boot-head { display: flex; align-items: center; gap: 14px; margin: 2px 0 16px; }
.boot-ring { width: 34px; height: 34px; border-radius: 50%; flex: none; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .9s linear infinite; }
.boot-t { font-family: var(--serif); font-size: 1.4rem; font-weight: 500; letter-spacing: -.01em; color: var(--ink); line-height: 1.15; }
.boot-s { font-size: 13px; color: var(--ink-2); margin-top: 3px; font-variant-numeric: tabular-nums; }
.boot-bar { height: 4px; border-radius: 4px; background: var(--card-2); overflow: hidden; margin-bottom: var(--s5); }
.boot-bar i { display: block; height: 100%; width: 6%; border-radius: 4px; background: var(--brand); transition: width .35s ease; }
.boot-bar.idle i { width: 28%; animation: bootSlide 1.5s ease-in-out infinite; }
.boot.err .boot-ring { border-color: var(--bad-soft); border-top-color: var(--bad); animation: none; }
.boot-err { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: var(--bad-soft); color: var(--bad); border-radius: var(--r); padding: 12px 14px; font-size: 13.5px; margin-bottom: var(--s5); }
.boot-err .btn { margin-left: auto; }

.sk { position: relative; overflow: hidden; display: block; background: var(--card-2); border-radius: 6px; }
.sk::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .75), transparent); animation: shimmer 1.6s ease-in-out infinite; }
.sk-stat .sk.l { width: 42%; height: 11px; margin-bottom: 12px; }
.sk-stat .sk.v { width: 68%; height: 26px; margin-bottom: 10px; }
.sk-stat .sk.s { width: 54%; height: 10px; }
.sk-rows { padding: 4px 0; }
.sk-row { display: grid; grid-template-columns: 44px 1fr 88px; gap: 14px; align-items: center; padding: 13px var(--s5); border-top: 1px solid var(--line); }
.sk-row:first-child { border-top: 0; }
.sk-row .sk.d { height: 10px; }
.sk-row .sk.t { height: 12px; width: 62%; }
.sk-row .sk.a { height: 12px; justify-self: end; width: 100%; }
.sk-row:nth-child(2) .sk.t { width: 48%; }
.sk-row:nth-child(4) .sk.t { width: 70%; }
.sk-row:nth-child(5) .sk.t { width: 40%; }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes bootSlide { from { transform: translateX(-100%); } to { transform: translateX(400%); } }
