/* Rationes. A ledger, kept calmly: warm paper, ledger-green ink, numbers in
   tabular figures lined up on the right, and red only for what's on the
   wrong side (SCREENS.md 3.1). Dense where the work is entry at a desk
   (registers, journal entries), roomy where it's keeping up on a phone. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --desk: #F3F1EA;
  --paper: #FFFFFF;
  --sunk: #F8F7F2;
  --ink: #1D2421;
  --muted: #5E6862;
  --rule: #DEDBD0;
  --rule-strong: #C3BFB0;
  --accent: #1F4D3A;
  --accent-ink: #FFFFFF;
  --accent-soft: #E1ECE5;
  --red: #B5462F;
  --red-soft: #F7E3DD;
  --amber: #8A5A00;
  --amber-soft: #FBEFCF;
  --ok: #1D7550;
  --focus: #2F6FEB;
  --shadow: 0 1px 2px rgba(29, 36, 33, 0.07), 0 6px 18px rgba(29, 36, 33, 0.07);
  --lift: 0 2px 4px rgba(29, 36, 33, 0.1), 0 18px 40px rgba(29, 36, 33, 0.14);

  --s-2: 0.75rem;
  --s-1: 0.875rem;
  --s0: 1rem;
  --s1: 1.25rem;
  --s2: 1.5rem;
  --tap: 44px;
  --gutter: 16px;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --side: 264px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --desk: #131716;
    --paper: #1C2120;
    --sunk: #171B1A;
    --ink: #E7ECE9;
    --muted: #A2ADA7;
    --rule: #2E3533;
    --rule-strong: #46504C;
    --accent: #8FCBAE;
    --accent-ink: #0F1A15;
    --accent-soft: #233A30;
    --red: #EE8C76;
    --red-soft: #3E2620;
    --amber: #E8BE6A;
    --amber-soft: #3A2F17;
    --ok: #7FD1A8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
    --lift: 0 2px 4px rgba(0, 0, 0, 0.35), 0 18px 40px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--desk); color: var(--ink);
  font: 400 var(--s0)/1.45 "Atkinson Hyperlegible", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--s2); line-height: 1.2; }
h2 { font-size: var(--s0); }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: var(--s-1); }
.negative, .amount.negative { color: var(--red); }
.num { text-align: right; white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.boot { padding: 40px; color: var(--muted); text-align: center; }

/* ------------------------------------------------------------ buttons and fields */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 6px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--rule-strong); background: var(--paper); color: var(--ink);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.small { min-height: 30px; padding: 3px 10px; font-size: var(--s-1); }
.btn:disabled { opacity: 0.45; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); border: 0; border-radius: var(--r-sm); background: none; color: inherit; cursor: pointer; }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn:hover { background: var(--accent-soft); }
.linkish { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; }
.icon { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

:where(input:not([type=checkbox]):not([type=radio]), select, textarea) {
  width: 100%; min-height: 38px; padding: 6px 10px; border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm); background: var(--paper);
}
:where(input, select):disabled { background: var(--sunk); color: var(--muted); }
input.amount-input { text-align: right; font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: var(--s-1); color: var(--muted); font-weight: 700; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline > span { white-space: nowrap; }
.field-error { color: var(--red); font-size: var(--s-1); }
.form-error { color: var(--red); background: var(--red-soft); padding: 8px 12px; border-radius: var(--r-sm); }
.note { background: var(--amber-soft); color: var(--amber); padding: 8px 12px; border-radius: var(--r-sm); }
.check { display: inline-flex; align-items: center; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.choices { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.choices legend { font-size: var(--s-1); color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--rule); border-radius: var(--r-sm); cursor: pointer; }
.choice > span { display: flex; flex-direction: column; }
.segmented { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--r-sm); overflow: hidden; }
.segmented button { border: 0; background: var(--paper); padding: 6px 16px; cursor: pointer; min-height: 36px; }
.segmented button + button { border-left: 1px solid var(--rule-strong); }
.segmented button[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); font-weight: 700; }

/* ------------------------------------------------------------ the shell (2.2) */

.app.wide { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100dvh; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.app.narrow .main-col { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.top {
  display: flex; align-items: center; gap: 8px; padding: 12px var(--gutter);
  position: sticky; top: 0; z-index: 10; background: var(--desk); border-bottom: 1px solid var(--rule);
}
.top .titles { flex: 1; min-width: 0; }
.top h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .kicker { font-size: var(--s-1); color: var(--muted); }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
main { padding: 16px var(--gutter) 32px; display: flex; flex-direction: column; gap: 16px; max-width: 1180px; width: 100%; }

.sync { font-size: var(--s-2); padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.sync[data-state=sending], .sync[data-state=connecting] { background: var(--amber-soft); color: var(--amber); }
.sync[data-state=offline] { background: var(--sunk); color: var(--muted); border: 1px solid var(--rule-strong); }
.sync[data-state=problem] { background: var(--red-soft); color: var(--red); }

.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto; background: var(--paper);
  border-right: 1px solid var(--rule); padding: 12px 10px 24px; display: flex; flex-direction: column; gap: 10px;
}
.side-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 0 4px; }
.books-switcher { display: flex; align-items: center; gap: 4px; border: 0; background: none; cursor: pointer; font-weight: 700; font-size: var(--s1); padding: 4px; border-radius: var(--r-sm); min-width: 0; }
.books-switcher .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.books-switcher:hover { background: var(--accent-soft); }
.sections { display: flex; flex-direction: column; gap: 1px; }
.sections h2 { font-size: var(--s-2); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 12px 8px 4px; }
.sections a { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-sm); color: var(--ink); text-decoration: none; min-height: 34px; }
.sections a:hover { background: var(--sunk); }
.sections a[aria-current=page] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.sections .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sections .badge, .tabbar .badge { font-size: var(--s-2); background: var(--accent-soft); color: var(--accent); padding: 0 7px; border-radius: 99px; font-weight: 700; }
.sections [data-nav=bills] .badge, .sections [data-nav=invoices] .badge { background: var(--amber-soft); color: var(--amber); }
.sections .side-account .amount { font-size: var(--s-1); }
.sections hr { border: 0; border-top: 1px solid var(--rule); margin: 8px 4px; }
.business-docs { margin-top: 10px; }
.business-docs summary { cursor: pointer; color: var(--muted); font-size: var(--s-1); padding: 6px 8px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--paper); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a, .tabbar button {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px;
  font-size: var(--s-2); color: var(--muted); text-decoration: none; border: 0; background: none; cursor: pointer;
}
.tabbar [aria-current=page] { color: var(--accent); font-weight: 700; }
.tabbar .badge { position: absolute; top: 4px; left: calc(50% + 8px); }
.tabbar [data-nav=new] { color: var(--accent); }

.banner { display: flex; gap: 12px; align-items: center; padding: 10px var(--gutter); background: var(--amber-soft); color: var(--amber); }

/* ------------------------------------------------------------ bars (3.5, 3.6) */

.bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 12px; border-radius: var(--r-sm); background: var(--sunk); border: 1px solid var(--rule); }
.bar > span { flex: 1; min-width: 200px; }
.bar-actions { display: flex; gap: 6px; }
.closed-bar, .reconciled-bar, .document-bar { background: var(--accent-soft); border-color: transparent; }
.concurrent-bar, .flag-bar { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.concurrent-bar.deleted, .deleted-bar { background: var(--red-soft); color: var(--red); }

/* ------------------------------------------------------------ sheets, menus, toasts */

.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(20, 26, 23, 0.42); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; display: flex; flex-direction: column; background: var(--paper); border-radius: 18px 18px 0 0; box-shadow: var(--lift); padding-bottom: env(safe-area-inset-bottom); animation: rise .2s ease-out; }
.sheet.wide { max-width: 760px; }
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--rule-strong); margin: 8px auto 0; flex: none; }
.sheet-content { display: flex; flex-direction: column; min-height: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 4px 20px; }
.sheet-head h2 { font-size: var(--s1); }
.sheet-main { padding: 6px 20px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.sheet-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 20px 16px; border-top: 1px solid var(--rule); flex-wrap: wrap; }
@media (min-width: 900px) {
  .scrim { align-items: center; }
  .sheet { border-radius: 18px; max-height: 86dvh; }
  .grabber { display: none; }
  .sheet-head { padding-top: 12px; }
}
.menu { position: fixed; z-index: 60; min-width: 190px; max-width: 320px; padding: 6px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); box-shadow: var(--lift); display: flex; flex-direction: column; }
.menu button { text-align: left; border: 0; background: none; padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer; min-height: 40px; }
.menu button:hover, .menu button:focus-visible { background: var(--accent-soft); outline: none; }
.menu button.danger { color: var(--red); }
.menu button:disabled { opacity: 0.4; cursor: default; background: none; }
.menu hr { border: 0; border-top: 1px solid var(--rule); margin: 4px 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 14px; max-width: calc(100% - 32px);
  padding: 12px 16px; border-radius: var(--r); background: var(--ink); color: var(--paper); box-shadow: var(--lift); animation: rise .2s ease-out;
}
.toast.error { background: var(--red); color: #fff; }
.toast button { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 4px; }
@media (min-width: 900px) { .toast { bottom: 24px; } }
.notice-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.notice { max-width: 440px; display: flex; flex-direction: column; gap: 14px; background: var(--paper); padding: 28px; border-radius: var(--r-lg); box-shadow: var(--shadow); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.picker-list {
  position: fixed; z-index: 80; max-height: 280px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--r-sm); box-shadow: var(--lift);
}
.picker-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 4px; cursor: pointer; }
.picker-list li[aria-selected=true] { background: var(--accent-soft); }
.picker-list .opt-sub { color: var(--muted); font-size: var(--s-2); }
.picker-list li.create { color: var(--accent); font-weight: 700; }

/* ------------------------------------------------------------ cards and lists */

.empty { padding: 32px 16px; text-align: center; color: var(--muted); display: flex; flex-direction: column; gap: 10px; align-items: center; }
section, .attention-card, .inbox-card, .home-accounts, .caught-up { background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); }
main > section { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 140px; }
.filters input[type=search] { flex: 1; min-width: 180px; max-width: 360px; }
.link-list { list-style: none; margin: 0; padding: 0; background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); }
.link-list li a { display: flex; justify-content: space-between; padding: 12px 16px; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--rule); }
.link-list li:last-child a { border-bottom: 0; }

/* Books list (4.28) */
.books-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.books-row { display: flex; align-items: center; gap: 8px; background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); padding: 4px 8px 4px 0; }
.books-row a { flex: 1; display: flex; flex-direction: column; padding: 12px 16px; text-decoration: none; color: var(--ink); }
.books-row strong { font-size: var(--s1); }
.books-row.lost { opacity: 0.75; }
.foot { text-align: center; }
.share-list { list-style: none; margin: 0; padding: 0; }
.share-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); }

/* Home (4.1) */
.inbox-head { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.inbox-head h2 { font-size: var(--s1); flex: 1; }
.inbox-card .count { font-size: var(--s2); font-weight: 700; color: var(--accent); }
.per-account { color: var(--muted); }
.attention-card h2, .home-accounts h2 { font-size: var(--s-2); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.attention, .home-accounts ul { list-style: none; margin: 0; padding: 0; }
.attention a, .home-accounts a { display: flex; align-items: center; gap: 10px; padding: 9px 0; text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--rule); }
.attention li:last-child a, .home-accounts li:last-child a { border-bottom: 0; }
.attention .mark { color: var(--amber); width: 1.4em; text-align: center; }
.attention .what { flex: 1; display: flex; flex-direction: column; }
.attention .detail { color: var(--muted); font-size: var(--s-1); }
.home-accounts .name { flex: 1; }
.caught-up { padding: 14px 16px; }
.quick-links { display: flex; flex-wrap: wrap; gap: 8px; }

/* Chart of accounts (4.4) */
.coa-list { list-style: none; margin: 0; padding: 0; }
.coa-row a { display: grid; grid-template-columns: 4.5em 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0 8px calc(var(--depth, 0) * 18px); text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--rule); }
.coa-row .number { color: var(--muted); font-size: var(--s-1); }
.coa-row.archived { opacity: 0.6; }
.kind-badge { font-size: var(--s-2); background: var(--sunk); border: 1px solid var(--rule); padding: 0 6px; border-radius: 4px; color: var(--muted); }
.flag { color: var(--amber); margin-left: 4px; }

/* ------------------------------------------------------------ registers (4.6) and grids */

.register-head { display: flex; flex-wrap: wrap; gap: 6px 24px; align-items: baseline; }
.register-head .big .amount { font-size: var(--s2); font-weight: 700; }
.register-head .label { color: var(--muted); font-size: var(--s-1); margin-right: 6px; }
.table-wrap { overflow-x: auto; background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: var(--s-2); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; }
th.num { text-align: right; }
td { padding: 6px 8px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
table.register tbody tr[data-line] { cursor: pointer; }
table.register tbody tr[data-line]:hover { background: var(--sunk); }
table.register td.account { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.register td.status { width: 1%; white-space: nowrap; color: var(--muted); }
table.register .mark { font-weight: 700; font-size: var(--s-1); }
table.register .mark.r { color: var(--accent); }
td.balance { text-align: right; white-space: nowrap; font-weight: 700; }
td.date { white-space: nowrap; }
table.register.narrow td.what .cell { display: flex; flex-direction: column; }
table.register.narrow td.what .date { font-size: var(--s-2); }
table.register.narrow td.amounts { text-align: right; white-space: nowrap; vertical-align: top; }
table.register.narrow td.amounts .cell { display: flex; flex-direction: column; align-items: flex-end; }
table.register.narrow td.amounts .balance { font-size: var(--s-1); }
.app.narrow .top { flex-wrap: wrap; }
.app.narrow .top .titles { flex: 1 1 auto; min-width: 55%; }
.books-title { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
tr.entry-row { background: var(--sunk); }
tr.entry-row td { padding: 4px; }
tr.entry-row input { min-height: 32px; padding: 4px 6px; }
.account-memo { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.entry-error { padding: 2px 4px; }

/* Transaction editor (4.7) */
.tx-editor { display: flex; flex-direction: column; gap: 14px; background: var(--paper); padding: 16px; border-radius: var(--r); box-shadow: var(--shadow); }
.simple-form { display: grid; grid-template-columns: 1fr; gap: 12px; max-width: 560px; }
.simple-form .segmented { justify-self: start; }
.je-head { display: grid; grid-template-columns: 10em 10em 1fr; gap: 10px; }
@media (max-width: 700px) { .je-head { grid-template-columns: 1fr 1fr; } .je-head .grow { grid-column: 1 / 3; } }
table.je td { padding: 3px 4px; }
table.je td.n { color: var(--muted); width: 2.5em; }
table.je input { min-height: 32px; padding: 4px 6px; }
.je-totals td, .je-totals th { border-bottom: 0; font-weight: 700; }
.je-totals .off { color: var(--red); }
.je-totals .ok { color: var(--ok); }
.editor-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.attachments { box-shadow: none; background: var(--sunk); padding: 10px 12px; }
.attachments h2 { display: flex; gap: 6px; align-items: center; font-size: var(--s-1); }
.attachments ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.attachments li { display: flex; align-items: center; gap: 2px; }
.history summary { cursor: pointer; color: var(--muted); }
.history-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--s-1); }
.history-list .outcome { color: var(--amber); }
table.theirs th { text-transform: none; letter-spacing: 0; }
table.theirs tr.changed td:first-of-type { background: var(--amber-soft); }
.stub p:first-child { font-size: var(--s1); color: var(--ink); }

@media (max-width: 899px) {
  .tx-editor { padding: 12px; }
  table.je { min-width: 720px; }
}
.app.narrow .top-actions { margin-left: auto; }

/* ---- screens: ledger (4.4–4.9, 4.22, 4.26) ---- */

/* A checkbox among filters keeps its own size. */
.filters label.check input[type=checkbox] { min-width: 0; width: auto; }

/* Chart of accounts (4.4) */
.coa-row { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--rule); }
.coa-row a { flex: 1; min-width: 0; border-bottom: 0; grid-template-columns: 4.5em 1fr auto auto; }
.coa-row .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coa-row .badges { display: inline-flex; gap: 4px; }
.coa-row .row-menu { flex: none; color: var(--muted); }
.coa-row[draggable=true] { cursor: grab; }
.coa-row.drop-target { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -2px; }
.coa-flagged { border-left: 4px solid var(--amber); }
.coa-flagged h2 { display: flex; gap: 6px; align-items: center; color: var(--amber); }
.coa-flagged .flag-sentence { color: var(--amber); font-weight: 700; margin-top: 4px; }
.coa-hint { text-align: center; }
.merge-summary { display: flex; flex-direction: column; gap: 8px; }
.sheet-actions.inline { padding: 8px 0 0; border-top: 0; }
.btn.danger-text { color: var(--red); }
.spacer { flex: 1; }
@media (max-width: 899px) {
  .coa-row a { grid-template-columns: 3.4em 1fr auto; }
  .coa-row .badges { display: none; }
}

/* Account editor (4.5) */
.account-form { display: flex; flex-direction: column; gap: 12px; }
.type-note { margin-top: 2px; }
.account-editor { max-width: 640px; }
.account-history { margin-top: 4px; }

/* Register (4.6) */
.date-range { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.date-range input { width: 8.5em; min-width: 0; }
table.register tbody tr[data-line]:focus { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--accent-soft); }

/* Transaction editor (4.7) */
.drag-handle { cursor: grab; color: var(--muted); margin-right: 2px; vertical-align: middle; }
.line-status { box-shadow: none; background: var(--sunk); padding: 10px 12px; }
.line-status h2 { font-size: var(--s-1); }
.line-status ul { list-style: none; margin: 0; padding: 0; font-size: var(--s-1); }
.line-status .mark { font-weight: 700; }
.line-status .mark.r { color: var(--accent); }
.refused-bar { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.attachments img.thumb, .qe-photo img.thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; border: 1px solid var(--rule); }
.attachments li.pending span { color: var(--muted); }
dl.version { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
dl.version dt { color: var(--muted); font-size: var(--s-1); }
dl.version dd { margin: 0; }
.history-list li .btn.small { margin-left: 6px; min-height: 24px; padding: 1px 8px; }

/* Quick entry and Snap receipt (4.8) */
.quick-entry { display: flex; flex-direction: column; gap: 12px; background: var(--paper); padding: 16px; border-radius: var(--r); box-shadow: var(--shadow); max-width: 560px; width: 100%; }
.quick-entry .segmented { align-self: flex-start; }
.quick-entry input.amount-input.big { font-size: var(--s2); min-height: 52px; font-weight: 700; }
.qe-photos { display: flex; flex-direction: column; gap: 6px; }
.qe-photo { display: flex; align-items: center; gap: 8px; }
.qe-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.app.narrow .qe-actions .btn { flex: 1; min-height: var(--tap); }
.snap { display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.snap .big-btn { min-height: 64px; font-size: var(--s1); }
.snap-head { display: flex; align-items: flex-end; gap: 12px; }
img.snap-photo { max-width: 60%; max-height: 260px; border-radius: var(--r); box-shadow: var(--shadow); object-fit: contain; background: var(--paper); }
.attach-to { list-style: none; margin: 0; padding: 0; background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); }
.attach-to li button { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--rule); background: none; text-align: left; cursor: pointer; min-height: var(--tap); }
.attach-to li:last-child button { border-bottom: 0; }
.attach-to .what { display: flex; flex-direction: column; min-width: 0; }
.attach-to li.none { padding: 12px 16px; }

/* Search (4.9) */
.search-bar { display: flex; align-items: center; gap: 8px; background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); padding: 4px 12px; }
.search-bar input { border: 0; font-size: var(--s1); min-height: 44px; background: none; }
.search-bar input:focus-visible { outline: none; }
.search-bar:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
select.chip, a.chip { width: auto; min-width: 0; border-radius: 99px; padding: 4px 12px; min-height: 32px; font-size: var(--s-1); }
select.chip.on, a.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
a.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--rule-strong); text-decoration: none; }
.search-results, .deleted-list, .refused-list { list-style: none; margin: 0; padding: 0; background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); }
.search-results .result { display: grid; grid-template-columns: 5.5em 1fr minmax(8em, 16em) 9em auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.search-results li:last-child .result { border-bottom: 0; }
.search-results .result:hover, .search-results .result:focus { background: var(--sunk); }
.search-results .what { display: flex; flex-direction: column; min-width: 0; }
.search-results .desc, .search-results .where { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-results .meta { font-size: var(--s-1); }
.search-results .amount { text-align: right; white-space: nowrap; font-weight: 700; }
.search-results .date { color: var(--muted); font-size: var(--s-1); white-space: nowrap; }
@media (max-width: 899px) {
  .search-results .result { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "what amount" "where date"; row-gap: 2px; }
  .search-results .what { grid-area: what; }
  .search-results .amount { grid-area: amount; }
  .search-results .date { grid-area: date; text-align: right; }
  .search-results .where { grid-area: where; font-size: var(--s-1); }
}

/* Refused changes (4.22) */
.refused-change { padding: 14px 16px; border-bottom: 1px solid var(--rule); display: flex; flex-direction: column; gap: 8px; }
.refused-change:last-child { border-bottom: 0; }
.refused-change.dismissed { opacity: 0.6; }
.refused-change .sentence { line-height: 1.5; }
.refused-change table.theirs { font-size: var(--s-1); }
.refused-change table.theirs th, .refused-change table.theirs td { padding: 4px 8px; }
.tried-wrap summary { cursor: pointer; color: var(--muted); font-size: var(--s-1); }

/* Deleted (4.26) */
.deleted-row { display: grid; grid-template-columns: 1fr minmax(6em, 12em) 8em minmax(8em, 14em) auto; gap: 10px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--rule); }
.deleted-row:last-child { border-bottom: 0; }
.deleted-row .what { display: flex; flex-direction: column; color: var(--ink); text-decoration: none; min-width: 0; }
.deleted-row .amount { text-align: right; white-space: nowrap; }
.deleted-row .who { font-size: var(--s-1); }
.deleted-row .field-error { grid-column: 1 / -1; }
@media (max-width: 899px) {
  .deleted-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "what btn" "contact amount" "who who" "err err"; row-gap: 4px; }
  .deleted-row .what { grid-area: what; }
  .deleted-row .btn { grid-area: btn; }
  .deleted-row .contact { grid-area: contact; }
  .deleted-row .amount { grid-area: amount; }
  .deleted-row .who { grid-area: who; }
  .deleted-row .field-error { grid-area: err; }
}
/* Room below the buttons, so a toast (which sits above the tab bar) never hides them. */
.app.narrow main.quick-page, .app.narrow main.snap-page { padding-bottom: 160px; }

/* ---- screens: documents (4.10–4.19, 4.24) ---- */

/* Lists (4.10, 4.12, 4.14, 4.15, 4.19) */
table.doc-list tbody tr[data-doc], table.doc-list tbody tr[data-adjustment], table.doc-list tbody tr[tabindex], table.items-table tbody tr { cursor: pointer; }
table.doc-list tbody tr:hover, table.items-table tbody tr:hover { background: var(--sunk); }
table.doc-list td.select { width: 1%; }
.status-word.overdue, .overdue { color: var(--amber); font-weight: 700; }
.status-word.overpaid, .overpaid { color: var(--red); }
.short-badge { display: inline-block; margin-left: 6px; font-size: var(--s-2); font-weight: 700; background: var(--amber-soft); color: var(--amber); padding: 0 7px; border-radius: 99px; white-space: nowrap; }
.doc-cards, .contact-list, .plain-list, .check-list { list-style: none; margin: 0; padding: 0; }
.doc-cards { background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); }
.doc-cards li { border-bottom: 1px solid var(--rule); }
.doc-cards li:last-child { border-bottom: 0; }
.doc-cards a { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; text-decoration: none; color: var(--ink); }
.doc-cards .line1 { display: flex; justify-content: space-between; gap: 10px; }
.doc-cards .line2 { font-size: var(--s-1); }
.doc-cards .flag-line { padding: 0 16px 10px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: var(--s-1); }
.contact-list { background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); }
.contact-row { border-bottom: 1px solid var(--rule); }
.contact-row:last-child { border-bottom: 0; }
.contact-row > a { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 10px 16px; text-decoration: none; color: var(--ink); }
.contact-row .who { display: flex; flex-direction: column; min-width: 0; }
.contact-row .who .muted { font-size: var(--s-1); }
.contact-row .open { display: flex; flex-direction: column; align-items: flex-end; font-size: var(--s-1); }
.contact-row .owe { color: var(--ink); }
.contact-row .unapplied { color: var(--amber); }
.contact-row.archived, .item-row.archived { opacity: 0.6; }
.flag-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--amber); font-size: var(--s-1); padding: 0 16px 10px; }
td .flag-line { padding: 4px 0 0; }
.items-total { text-align: right; color: var(--muted); }
.items-total strong { color: var(--ink); }

/* Contact and item detail (4.11, 4.13) */
.contact-summary { display: flex; flex-wrap: wrap; gap: 6px 20px; font-weight: 700; }
.contact-fields, .item-fields { display: flex; flex-direction: column; gap: 10px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.activity li a { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--rule); text-decoration: none; color: var(--ink); }
.activity li:last-child a { border-bottom: 0; }
.on-hand .figures { display: flex; flex-wrap: wrap; gap: 8px 32px; }
.on-hand .figure { display: flex; flex-direction: column; }
.on-hand .figure .label { color: var(--muted); font-size: var(--s-1); }
.on-hand .figure strong { font-size: var(--s1); }
.used-up summary, .consumption summary { cursor: pointer; }
.used-up summary { color: var(--muted); margin-top: 6px; }
.consumption { border-bottom: 1px solid var(--rule); padding: 6px 0; }
.consumption summary { display: grid; grid-template-columns: 5em minmax(7em, 1fr) minmax(6em, 1fr) 6em 7em 7em auto; gap: 8px; align-items: baseline; }
.consumption .draws { margin: 6px 0 4px 5em; color: var(--muted); font-size: var(--s-1); }
@media (max-width: 899px) {
  .consumption summary { grid-template-columns: 4.5em 1fr auto; }
  .consumption summary .who, .consumption summary .unit-cost { display: none; }
  .consumption .draws { margin-left: 0; }
}

/* Document editors (4.14, 4.16–4.19) */
.doc-editor { display: flex; flex-direction: column; gap: 14px; background: var(--paper); padding: 16px; border-radius: var(--r); box-shadow: var(--shadow); }
.doc-editor > section, .doc-editor .lines-section { box-shadow: none; padding: 0; background: none; border-radius: 0; }
.doc-editor .attachments { padding: 10px 12px; background: var(--sunk); }
.doc-head { display: grid; grid-template-columns: minmax(200px, 2fr) repeat(3, minmax(110px, 1fr)); gap: 10px; }
.payment-editor .doc-head { grid-template-columns: minmax(200px, 2fr) 1fr minmax(200px, 2fr) 1fr 1fr; }
.invoice-editor .doc-head { grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(100px, 1fr)); }
.adjustment-editor .doc-head { grid-template-columns: 10em minmax(200px, 1fr) minmax(200px, 2fr); }
@media (max-width: 899px) { .doc-head, .payment-editor .doc-head, .invoice-editor .doc-head, .adjustment-editor .doc-head { grid-template-columns: 1fr 1fr; } .doc-head > :first-child { grid-column: 1 / -1; } }
.doc-sub { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: baseline; }
details.payable summary { cursor: pointer; color: var(--muted); font-size: var(--s-1); }
details.payable summary span { color: var(--ink); }
details.payable[open] summary { margin-bottom: 6px; }
.lines-section h2 { font-size: var(--s-2); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 6px; }
.lines-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.lines-section .add-line, .add-lines { margin-top: 8px; }
.add-lines { display: flex; gap: 8px; flex-wrap: wrap; }
.add-lines .add-line { margin-top: 0; }
.doc-editor table td { padding: 3px 4px; }
.doc-editor table input, .doc-editor table select { min-height: 32px; padding: 4px 6px; }
.doc-editor input.qty-input { text-align: right; min-width: 4.5em; }
.doc-editor td.qty { width: 6em; }
.doc-editor td.item { min-width: 250px; }
.doc-editor select.kind-select { min-width: 7em; }
table.item-lines td.share, table.item-lines td.landed, table.item-lines td.landed-unit { color: var(--muted); font-variant-numeric: tabular-nums; }
table.item-lines td.landed { color: var(--ink); font-weight: 700; }
table.item-lines tfoot td { font-weight: 700; border-bottom: 0; }
tr.line-note td { border-bottom: 0; padding-top: 0; }
.over-receive, .missing-weight, .field-warning { color: var(--amber); font-size: var(--s-1); }
.missing-weight { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.field-warning { display: flex; gap: 4px; align-items: center; }
tr.cost-row td { border-bottom: 1px solid var(--rule); padding-top: 0; font-size: var(--s-1); }
.cost { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fifo-cost { color: var(--muted); font-size: var(--s-1); white-space: nowrap; }
.doc-totals { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.doc-totals .row { display: flex; gap: 16px; min-width: 240px; justify-content: space-between; }
.doc-totals .doc-total { font-size: var(--s1); }
.doc-payments a { font-size: var(--s-1); }
.unapplied-note, .match-status { font-size: var(--s-1); }
.misapplied { list-style: none; padding: 0; margin: 6px 0 0; color: var(--amber); font-size: var(--s-1); }
.misapplied li { display: flex; align-items: center; gap: 4px; }
table.apply-lines td .check { gap: 8px; }
.line-card { border: 1px solid var(--rule); border-radius: var(--r-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; background: var(--paper); }
.line-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.line-card-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.line-card-fields .field:first-child { grid-column: 1 / -1; }
.line-card .landed-line { color: var(--accent); font-weight: 700; font-size: var(--s-1); }
.line-card table td { border: 0; padding: 2px 0; }
.check-list li { padding: 6px 0; }
table.bill-from-po input.qty-input { width: 6em; }
@media (max-width: 899px) { .doc-editor { padding: 12px; } }
.doc-editor > .segmented { align-self: flex-start; }
.doc-editor td.num input.amount-input { min-width: 7.5em; }
.doc-editor td.num input.price-input { min-width: 6.5em; }
table.apply-lines input.amount-input { max-width: 11em; margin-left: auto; display: block; }
@media (min-width: 900px) { .contact-fields { display: grid; grid-template-columns: 1fr 1fr; } .contact-fields > p { grid-column: 1 / -1; order: 3; } }

/* ---- screens: bank (4.1, 4.2, 4.3, 4.25) ---- */

/* A file input inside a button-like label: hidden, still there for labels and tests. */
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
label.btn { position: relative; }

/* Inbox (4.2) */
.inbox-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.inbox-filters select { width: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--rule-strong); background: var(--paper); border-radius: 99px; padding: 4px 12px; cursor: pointer; min-height: 32px; }
.chip .n { color: var(--muted); font-weight: 700; }
.chip[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed=true] .n { color: inherit; }
.inbox-list { list-style: none; margin: 0; padding: 0; background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.inbox-line { border-bottom: 1px solid var(--rule); padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; background: var(--paper); }
.inbox-line:last-child { border-bottom: 0; }
.inbox-line .line-main { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.inbox-line .line-top { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; cursor: pointer; min-width: 0; }
.inbox-line .date { color: var(--muted); font-size: var(--s-1); width: 4.5em; flex: none; }
.inbox-line .desc { font-weight: 700; overflow-wrap: anywhere; }
.inbox-line .amount { white-space: nowrap; }
.inbox-line .acct { font-size: var(--s-1); }
.inbox-line .suggestion { grid-column: 1; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; color: var(--accent); font-size: var(--s-1); }
.inbox-line .suggestion .mark { width: 1.2em; text-align: center; font-weight: 700; }
.inbox-line .suggestion .source { margin-left: auto; color: var(--muted); font-size: var(--s-2); }
.inbox-line .line-buttons { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
.inbox-list.wide .inbox-line[aria-selected=true] { background: var(--sunk); box-shadow: inset 3px 0 0 var(--accent); }
.inbox-line.gone { opacity: 0.55; background: var(--sunk); animation: inbox-fade 4s ease-in forwards; }
.inbox-line .gone-text { font-size: var(--s-1); color: var(--muted); font-style: italic; }
@keyframes inbox-fade { 0% { opacity: 0.8; } 100% { opacity: 0.25; } }
.line-form { display: flex; flex-direction: column; gap: 10px; }
.line-form .line-inputs { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; align-items: start; }
.line-form .line-inputs.split-mode { grid-template-columns: 1fr 1fr; }
.line-form .line-inputs.split-mode .split { grid-column: 1 / -1; }
.line-form-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.line-form-actions .btn.primary { margin-left: auto; }
.line-form .split { display: flex; flex-direction: column; gap: 6px; }
.split-line { display: grid; grid-template-columns: 2fr 8em 1.5fr auto; gap: 6px; align-items: center; }
.split-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.split-foot .left.off { color: var(--red); font-weight: 700; }
.split-foot .left.ok { color: var(--ok); font-weight: 700; }
.inbox-list.narrow .inbox-line { touch-action: pan-y; cursor: pointer; transition: transform .15s ease-out; user-select: none; }
.inbox-list.narrow .inbox-line[data-swipe] { transition: none; }
.inbox-list.narrow .inbox-line[data-swipe=accept] { background: var(--accent-soft); }
.inbox-list.narrow .inbox-line[data-swipe=dismiss] { background: var(--red-soft); }
.inbox-list.narrow .line-main { grid-template-columns: 1fr; }
.inbox-list.narrow .line-top { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.inbox-list.narrow .line-top .desc { grid-area: 1 / 1; }
.inbox-list.narrow .line-top .amount { grid-area: 1 / 2; text-align: right; }
.inbox-list.narrow .line-top .date { grid-area: 2 / 1; width: auto; }
.inbox-list.narrow .line-top .acct { grid-area: 2 / 2; text-align: right; }
.bank-line { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
.sheet-suggestion { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--accent); }
.pick-list, .open-docs, .accept-payments ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pick-list .pick { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--paper); cursor: pointer; }
.pick-list .pick:hover { border-color: var(--accent); }
.open-doc { display: grid; grid-template-columns: 1fr 9em; gap: 8px; align-items: center; }
@media (max-width: 899px) {
  .line-form .line-inputs, .line-form .line-inputs.split-mode { grid-template-columns: 1fr; }
  .split-line { grid-template-columns: 1fr 7em auto; }
  .split-line input[aria-label$="memo"] { grid-column: 1 / 3; }
}

/* Import (4.3) */
.import-source { gap: 12px; }
.import-source select { width: auto; min-width: 220px; align-self: flex-start; }
.drop-zone { border: 2px dashed var(--rule-strong); border-radius: var(--r); padding: 22px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--muted); }
.drop-zone.over { border-color: var(--accent); background: var(--accent-soft); }
.file-pick { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.preview-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; align-items: baseline; }
table.preview-rows tr.existing td { color: var(--muted); }
.csv-map .table-wrap { box-shadow: none; border: 1px solid var(--rule); }
table.csv-columns th { text-transform: none; letter-spacing: 0; padding: 6px; }
table.csv-columns select { min-width: 8.5em; }
table.csv-columns td { white-space: nowrap; font-size: var(--s-1); }
table.csv-columns tr.header-row td { color: var(--muted); font-weight: 700; }
.csv-options { display: flex; flex-direction: column; gap: 10px; }
.csv-options select { width: auto; }
.csv-options .signs { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.import-result h2 { font-size: var(--s1); }
.recent-imports ul { list-style: none; margin: 0; padding: 0; }
.recent-imports li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.recent-imports li:last-child { border-bottom: 0; }
.recent-imports .import-what { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.recent-imports .counts { font-size: var(--s-1); }
.recent-imports li.removed .import-what { opacity: 0.6; }
.import-removed { display: flex; gap: 8px; align-items: center; }
.import-removed .badge { font-size: var(--s-2); background: var(--sunk); border: 1px solid var(--rule); padding: 0 7px; border-radius: 99px; color: var(--muted); font-weight: 700; }

/* Rules (4.25) */
.rules-list { list-style: none; margin: 0; padding: 0; background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); }
.rule-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--rule); background: var(--paper); }
.rule-row:last-child { border-bottom: 0; }
.rule-row.drop-target { box-shadow: inset 0 3px 0 var(--accent); }
.rule-row .grip { color: var(--muted); cursor: grab; display: grid; place-items: center; }
.rule-link { flex: 1; min-width: 0; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.rule-match { overflow-wrap: anywhere; }
.rule-sub { font-size: var(--s-1); }
.rule-count { font-size: var(--s-1); white-space: nowrap; }
.rule-editor { display: flex; flex-direction: column; gap: 14px; background: var(--paper); padding: 16px; border-radius: var(--r); box-shadow: var(--shadow); max-width: 760px; }
.rule-accounts .row-actions { gap: 8px 18px; }
.rule-match-row, .rule-amount-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rule-match-row select, .rule-amount-row select { width: auto; }
.rule-match-row input { flex: 1; min-width: 160px; }
.rule-amount-row .field.inline input { width: 8em; }
.rule-suggest { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rule-suggest .field-error { grid-column: 1 / -1; }
.rule-preview { box-shadow: none; background: var(--sunk); padding: 12px; }
.rule-preview h2 { font-size: var(--s-1); margin-bottom: 6px; }
.rule-preview-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--s-1); }
.rule-preview-lines li { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.rule-preview-lines .desc { font-weight: 700; flex: 1; min-width: 10em; }
@media (max-width: 899px) {
  .rule-suggest { grid-template-columns: 1fr; }
  .rule-row { flex-wrap: wrap; }
}

/* ---- screens: admin (4.20, 4.21, 4.23, 4.27) ---- */

/* Reconcile (4.20) */
.rec-accounts { list-style: none; margin: 0; padding: 0; background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); }
.rec-accounts li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--rule); }
.rec-accounts li:last-child { border-bottom: 0; }
.rec-account-name { display: flex; flex-direction: column; text-decoration: none; color: var(--ink); min-width: 0; }
.rec-account-name .in-progress { color: var(--amber); }
.rec-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--rule); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.rec-figure { background: var(--paper); padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.rec-figure .label { font-size: var(--s-2); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.rec-figure .amount { font-size: var(--s1); font-weight: 700; }
.rec-figure.difference.ok .amount { color: var(--ok); }
.rec-figure.difference.off .amount { color: var(--red); }
.rec-inbox-warning a.btn { color: inherit; }
.rec-columns.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.rec-columns.one { display: flex; flex-direction: column; gap: 12px; }
.rec-columns.one > .segmented { align-self: flex-start; }
.rec-column { padding: 0; overflow: hidden; }
.rec-column-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--rule-strong); }
.rec-column-head h2 { font-size: var(--s-2); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.rec-column > p { padding: 12px 14px; }
.rec-lines { list-style: none; margin: 0; padding: 0; }
.rec-line { display: grid; grid-template-columns: auto 4.6em 1fr auto 1.2em; gap: 8px; align-items: center; padding: 6px 14px; border-bottom: 1px solid var(--rule); }
.rec-line:last-child { border-bottom: 0; }
.rec-line.ticked { background: var(--sunk); }
.rec-line input[type=checkbox] { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); }
.rec-line .date { font-size: var(--s-1); white-space: nowrap; }
.rec-line .what { display: flex; flex-direction: column; min-width: 0; color: var(--ink); text-decoration: none; }
.rec-line .what .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-line .what:hover .name { text-decoration: underline; }
.rec-line .ticked-by { font-size: var(--s-2); color: var(--accent); }
.rec-line .mark.c { color: var(--muted); font-weight: 700; font-size: var(--s-1); }
.rec-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.rec-none { align-items: flex-start; }
.reconcile-page > .segmented { align-self: flex-start; }
.rec-past ul { list-style: none; margin: 0; padding: 0; }
.rec-past li { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.rec-past li:last-child { border-bottom: 0; }
.rec-past .what { display: flex; flex-direction: column; }
.rec-past .undo { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; max-width: 220px; text-align: right; }
@media (max-width: 899px) {
  .rec-summary { grid-template-columns: 1fr 1fr; }
  .rec-line { grid-template-columns: auto 1fr auto; padding: 8px 12px; }
  .rec-line .date { grid-column: 2; grid-row: 2; }
  .rec-line .what { grid-column: 2; grid-row: 1; }
  .rec-line .amount { grid-column: 3; grid-row: 1; }
  .rec-line .marks { grid-column: 3; grid-row: 2; text-align: right; }
  .rec-line input[type=checkbox] { grid-row: 1 / 3; width: 24px; height: 24px; }
  .rec-accounts li, .rec-past li { grid-template-columns: 1fr auto; }
  .rec-accounts li > .amount { display: none; }
}

/* Books settings (4.23) */
.settings { display: flex; flex-direction: column; gap: 16px; max-width: 720px; }
.settings > section { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.settings section h2 { display: flex; align-items: center; gap: 6px; }
.settings .field > .segmented, .setup .field > .segmented { align-self: flex-start; }
.settings select { max-width: 280px; }
.settings .inline-form .field { max-width: 420px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 160px; }
.inline-form .grow { flex: 2; }
.lock-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.lock-sentence { font-weight: 700; }
.defaults-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.default-account { display: flex; flex-direction: column; gap: 6px; }
.member-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.member-list li { background: var(--sunk); border: 1px solid var(--rule); border-radius: 99px; padding: 2px 10px; }
.link-list.plain { box-shadow: none; }
.link-list.plain li a { padding: 10px 0; align-items: center; }

/* Reports (4.21) */
.report-group ul.report-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }
.report-list li { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.report-list li a { font-weight: 700; text-decoration: none; }
.report-list li a:hover { text-decoration: underline; }
.report-options { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; }
.report-options .filters { flex: 1; }
.report-options .field.inline input { width: 9em; }
.report-options .period { font-size: var(--s-1); }
.report-buttons { display: flex; gap: 8px; }
.report { padding: 0; gap: 0; overflow: hidden; }
.report .print-title { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; padding: 10px 14px; border-bottom: 1px solid var(--rule); font-size: var(--s-1); }
.report .table-wrap { box-shadow: none; border-radius: 0; }
.report-table th.name { text-transform: none; letter-spacing: 0; font-size: var(--s0); font-weight: 400; color: var(--ink); white-space: nowrap; }
.report-table thead th.name { font-size: var(--s-2); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.report-table th.name a { color: inherit; text-decoration: none; }
.report-table th.name a:hover { text-decoration: underline; color: var(--accent); }
.report-table td.num { min-width: 7.5em; }
.report-table td.text { white-space: nowrap; max-width: 28em; overflow: hidden; text-overflow: ellipsis; }
.report-table td.text a { color: inherit; }
.report-table tr.section th.name { font-weight: 700; padding-top: 14px; }
.report-table tr.parent th.name { font-weight: 700; }
.report-table tr.subtotal th, .report-table tr.subtotal td { color: var(--muted); }
.report-table tr.total th, .report-table tr.total td { font-weight: 700; border-top: 1px solid var(--rule-strong); }
.report-table tr.total.strong th, .report-table tr.total.strong td { border-bottom: 3px double var(--rule-strong); }
.report-table tr.gl-account th { font-weight: 700; padding-top: 14px; }
.report-table tr.gl-closing th, .report-table tr.gl-closing td { font-weight: 700; color: var(--muted); }
.report-table .toggle { width: 22px; height: 22px; margin-right: 4px; vertical-align: middle; }
.report-table .toggle[aria-expanded=false] { color: var(--muted); }
/* The first column stays put while the rest scroll sideways (a phone, or many columns). */
.report-table tbody th, .report-table thead th.name { position: sticky; left: 0; z-index: 1; background: var(--paper); }
.tie-out { padding: 10px 14px; border-top: 1px solid var(--rule); font-weight: 700; }
.tie-out.off { color: var(--red); }
@media (max-width: 899px) {
  .report-table th.name { white-space: normal; min-width: 9em; max-width: 14em; }
}
@media print {
  body[data-screen=report] { background: #fff; color: #000; }
  body[data-screen=report] aside.sidebar, body[data-screen=report] nav.tabbar, body[data-screen=report] header.top,
  body[data-screen=report] .report-options, body[data-screen=report] #problem, body[data-screen=report] .toast { display: none !important; }
  body[data-screen=report] .app.wide { display: block; }
  body[data-screen=report] main { padding: 0; max-width: none; }
  body[data-screen=report] .report, body[data-screen=report] .report .table-wrap { box-shadow: none; overflow: visible; }
  body[data-screen=report] .report-table th, body[data-screen=report] .report-table td { position: static; padding: 3px 6px; }
  body[data-screen=report] .report-table .toggle { display: none; }
  body[data-screen=report] .report-table a { color: inherit; text-decoration: none; }
  body[data-screen=report] .print-title { font-size: 1rem; }
}

/* New books setup (4.27) */
.setup { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.setup-steps { list-style: none; margin: 0; padding: 8px; background: var(--paper); border-radius: var(--r); box-shadow: var(--shadow); counter-reset: step; position: sticky; top: 80px; }
.setup-steps li { counter-increment: step; }
.setup-steps button { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 8px; border-radius: var(--r-sm); cursor: pointer; color: var(--ink); }
.setup-steps button::before { content: counter(step); display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; border-radius: 50%; border: 1px solid var(--rule-strong); font-size: var(--s-2); color: var(--muted); }
.setup-steps li.done button::before { content: "✓"; background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.setup-steps li[aria-current=step] button { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.setup-steps li[aria-current=step] button::before { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.setup-step { padding: 16px; gap: 14px; min-width: 0; }
.setup-step .step-head h2 { font-size: var(--s1); }
.setup-step h3 { font-size: var(--s-1); text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 8px 0 4px; }
.setup-nav { display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--rule); padding-top: 12px; flex-wrap: wrap; }
.setup-nav .grow { flex: 1; }
.setup-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--red-soft); color: var(--red); }
.setup-accounts { list-style: none; margin: 0; padding: 0; }
.setup-accounts li { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--rule); }
.setup-accounts li.dropping .name { text-decoration: line-through; color: var(--muted); }
.setup-accounts input[type=checkbox] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.setup-accounts input.number { width: 5.5em; flex: none; min-height: 32px; padding: 4px 6px; }
.setup-accounts input.name { flex: 1; min-width: 0; min-height: 32px; padding: 4px 6px; }
.setup-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.setup-add input, .setup-add select { width: auto; flex: 1 1 140px; }
.setup-add input[aria-label="New account number"] { flex: 0 1 6em; }
.paste { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.paste .field { flex: 1 1 260px; }
.paste textarea { min-height: 64px; font-family: ui-monospace, monospace; font-size: var(--s-1); }
table.tb-grid td { padding: 3px 4px; }
table.tb-grid td.n { color: var(--muted); width: 2em; }
table.tb-grid input { min-height: 32px; padding: 4px 6px; }
table.tb-grid td.num { width: 9em; }
table.tb-grid tbody td:nth-child(2) { min-width: 16em; }
table.tb-grid td.hint { font-size: var(--s-1); max-width: 16em; }
table.tb-grid tr.from-next { background: var(--sunk); }
table.tb-grid tr.opening-row td { font-weight: 700; background: var(--accent-soft); }
table.tb-grid .unmatched { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--amber); }
table.tb-grid .unmatched select { width: auto; min-height: 30px; padding: 2px 6px; }
.tb-totals td, .tb-totals th { font-weight: 700; border-bottom: 0; }
.tb-totals .ok { color: var(--ok); }
.step-actions { display: flex; justify-content: flex-end; gap: 8px; }
.doc-grid { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.doc-grid + .doc-grid { border-top: 1px solid var(--rule); }
.doc-check { font-weight: 700; }
.doc-check.off { color: var(--red); }
.import-links ul { margin: 6px 0 0; padding-left: 20px; }
@media (max-width: 899px) {
  .setup { grid-template-columns: minmax(0, 1fr); }
  .setup-steps { position: static; display: flex; overflow-x: auto; gap: 2px; padding: 4px; }
  .setup-steps li { flex: none; }
  .setup-steps button { white-space: nowrap; padding: 6px 8px; font-size: var(--s-1); }
  table.tb-grid { min-width: 560px; }
}
