/* Books — Money's look (tokens, Lexend, light/dark; taken from Money's app.css 7 Nov 2026: base, header, lists,
   cards, buttons, chips, forms, notices, toast; Money's domain sections left out), laid out desktop-first: the
   shell and tables are the last section. Tokens: BOOKS_REFERENCE.md §12. */

/* ---------- font: Lexend variable (SIL OFL), vendored @fontsource-variable/lexend 5.3.0 ---------- */
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/static/fonts/lexend-latin-ext-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Lexend";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url(/static/fonts/lexend-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --fill: #E3E3E8;
  --text: #000000;
  --text-2: #6C6C70;
  --tab-inactive: #8A8A8E;
  --separator: rgba(60, 60, 67, 0.20);
  --tint: #2F5BDB;
  --tint-fill: #2F5BDB;
  --tint-soft: #EEF2FD;
  --negative: #C4001A;
  --positive: #1F7A3A;
  --tabbar: rgba(249, 249, 249, 0.94);
  --toast: #1C1C1E;
  --toast-action: #7AA7FF;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 1px rgba(0, 0, 0, 0.04);
  /* kind colours (white glyph on top); essential, lifestyle, income, unsorted darkened from the
     iOS system colours so the glyph reaches 3:1 (Hamid's choice, phase 2b) */
  --k-commitment: #5856D6;
  --k-essential: #2AA349;
  --k-lifestyle: #CE7D00;
  --k-family: #FF2D55;
  --k-giving: #AF52DE;
  --k-income: #2B9CB0;
  --k-business: #8E8E93;
  --k-adjustment: #8F8F94;
  --k-transfer: #8E8E93;
  /* account type tiles */
  --t-bank: #0A84FF;
  --t-cash: var(--k-essential);
  --t-card: #5856D6;
  --t-pay_later: var(--k-lifestyle);
  --t-savings: var(--k-income);
  --t-investment: #AF52DE;
  --t-other: #8E8E93;
  --t-loan: #8E8E93;
  /* Home rings (30 Oct 2026): ring / alert states and the Lifestyle ring's category hues */
  --ok: #24963F;
  --warn: #9A5B00;          /* amber text on white, 4.6:1 */
  --warn-fill: #D27A00;     /* amber arcs, bars and tiles (white glyph, 3:1) */
  --seg-0: #5856D6; --seg-1: #1E9BD7; --seg-2: #AF52DE; --seg-3: #0A6CFF;
  --seg-4: #A2845E; --seg-5: #2AA5B8; --seg-6: #64748B; --seg-other: #A1A1A6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --fill: #2C2C2E;
    --text: #FFFFFF;
    --text-2: #98989F;
    --tab-inactive: #8D8D93;
    --separator: rgba(84, 84, 88, 0.65);
    --tint: #7AA7FF;
    --tint-fill: #3563E3;
    --tint-soft: rgba(122, 167, 255, 0.16);
    --negative: #FF6961;
    --positive: #30D158;
    --tabbar: rgba(22, 22, 24, 0.94);
    --toast: #2C2C2E;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --k-commitment: #5E5CE6;
    --k-essential: #25A444;
    --k-lifestyle: #CE7D00;
    --k-family: #FF375F;
    --k-giving: #BF5AF2;
    --k-income: #1D9DB4;
    --k-business: #8E8E93;
    --k-adjustment: #636366;
    --k-transfer: #8E8E93;
    --ok: #30D158;
    --warn: #FFB340;
    --warn-fill: #F09A1A;
    --seg-0: #7D7AFF; --seg-1: #40B8F0; --seg-2: #C77DEB; --seg-3: #4D94FF;
    --seg-4: #B89C78; --seg-5: #40C8E0; --seg-6: #8A97AB; --seg-other: #6E6E73;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: Lexend, -apple-system, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.3;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  overflow-x: clip; /* clip, not hidden: body must not become a scroll container (sticky Save) */
}
body { min-height: 100vh; padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
a { color: var(--tint); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.icon { display: block; flex: none; }
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 16px 24px; }
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--positive); }
.neg { color: var(--negative); }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- motion ---------- */
@view-transition { navigation: auto; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet { animation: sheet-up 250ms ease-out; }
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- large-title header ---------- */
.lt-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 12px 0 8px; }
.lt-header .titles { min-width: 0; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-2); }
.eyebrow a { text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 400; display: inline-flex; align-items: center; min-height: 44px; }
.large-title { font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.lt-actions { display: flex; align-items: center; gap: 12px; padding-bottom: 4px; }
.gear { width: 36px; height: 36px; border-radius: 50%; background: var(--fill); color: var(--tint); display: inline-flex; align-items: center; justify-content: center; position: relative; }
.gear::after { content: ""; position: absolute; inset: -4px; }
.text-btn { background: none; border: 0; color: var(--tint); font-size: 17px; min-height: 44px; display: inline-flex; align-items: center; padding: 0 2px; }
.text-btn.strong { font-weight: 600; }
.text-btn.danger { color: var(--negative); }

/* ---------- sections & grouped lists ---------- */
.section-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 24px 16px 6px; font-size: 13px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-2); }
.section-h a { text-transform: none; letter-spacing: 0; font-size: 15px; }
.section-f { margin: 6px 16px 0; font-size: 13px; color: var(--text-2); }
.group { list-style: none; background: var(--card); border-radius: 12px; overflow: hidden; }
.row { position: relative; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 10px 16px; background: var(--card); color: var(--text); width: 100%; text-align: left; border: 0; }
/* hairline between items of a group, inset from the leading edge (after the icon) */
.group > * { position: relative; --inset: 16px; }
.group > .has-tile { --inset: 58px; }
.group > .has-round { --inset: 64px; }
.group > * + *::before, .txn-list > .row + .row::before {
  content: ""; position: absolute; top: 0; right: 0; left: var(--inset); height: 0.5px; background: var(--separator); z-index: 1;
}
a.row, button.row, label.row, summary.row { cursor: pointer; }
.row .main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.row .title { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .subtitle { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .subtitle.wrap { white-space: normal; overflow-wrap: anywhere; }
.row .label { flex: none; color: var(--text); }
.row .value { margin-left: auto; color: var(--text-2); text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .trailing { margin-left: auto; text-align: right; padding-left: 8px; }
.row .chev { color: #C4C4C7; flex: none; margin-right: -4px; }
@media (prefers-color-scheme: dark) { .row .chev { color: #5A5A5E; } }
.row.destructive { justify-content: center; color: var(--negative); font-size: 17px; }
.row.plain-action { justify-content: center; color: var(--tint); }
.row-wrap { display: block; }
.row-details > summary { list-style: none; }
.row-details > summary::-webkit-details-marker { display: none; }
.row-details[open] > summary .chev { transform: rotate(90deg); }
.row-panel { padding: 4px 16px 14px; background: var(--card); }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 10px; background: var(--tint-soft); color: var(--tint); }
.badge.plain { background: var(--fill); color: var(--text-2); }

/* icon tiles */
.tile { width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: #FFFFFF; flex: none; }
.tile.round { width: 36px; height: 36px; border-radius: 50%; }
.k-commitment { background: var(--k-commitment); }
.k-essential { background: var(--k-essential); }
.k-lifestyle { background: var(--k-lifestyle); }
.k-family { background: var(--k-family); }
.k-giving { background: var(--k-giving); }
.k-income { background: var(--k-income); }
.k-business { background: var(--k-business); }
.k-adjustment, .k-unsorted { background: var(--k-adjustment); }
.k-transfer { background: var(--k-transfer); }
.t-bank { background: var(--t-bank); }
.t-cash { background: var(--t-cash); }
.t-card { background: var(--t-card); }
.t-pay_later { background: var(--t-pay_later); }
.t-savings { background: var(--t-savings); }
.t-investment { background: var(--t-investment); }
.t-loan { background: var(--t-loan); }
.t-other { background: var(--t-other); }

/* ---------- cards, hero ---------- */
.card { background: var(--card); border-radius: 16px; padding: 16px; margin: 8px 0; }
.card-label { font-size: 15px; color: var(--text-2); }
.hero-amt { font-size: 40px; line-height: 44px; font-weight: 700; letter-spacing: -0.01em; margin: 2px 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-sub { font-size: 15px; color: var(--text-2); }
.hairline { height: 0.5px; background: var(--separator); margin: 14px 0; border: 0; }
.split { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.split > * { min-width: 0; }
.split .right { text-align: right; font-size: 15px; }
.mid-amt { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bar-track { height: 4px; border-radius: 2px; background: var(--fill); overflow: hidden; margin-top: 6px; }
.bar { display: block; height: 4px; border-radius: 2px; width: var(--w, 0%); }

/* ---------- buttons ---------- */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 50px; padding: 0 16px; border: 0; border-radius: 14px; background: var(--tint-fill); color: #FFFFFF; font-size: 17px; font-weight: 600; margin: 16px 0 0; }
.btn.secondary { background: var(--card); color: var(--tint); }
.btn.danger { background: var(--negative); }
.btn.inline { display: inline-flex; width: auto; min-height: 44px; margin: 0; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.actions .btn { flex: 1; }

/* ---------- chips ---------- */
.chip-row { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 4px 16px; scroll-padding: 16px; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.chip { position: relative; flex: none; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 18px; border: 0; background: var(--card); color: var(--text); font-size: 15px; white-space: nowrap; }
.chip::after { content: ""; position: absolute; inset: -4px 0; } /* 44px tap target */
.chip.on { background: var(--tint-fill); color: #FFFFFF; font-weight: 500; }
.chip.more { color: var(--tint); }
.chip .dot { width: 24px; height: 24px; border-radius: 50%; margin-left: -8px; display: inline-flex; align-items: center; justify-content: center; color: #FFFFFF; }
.chip.with-dot { padding-left: 14px; }
.on-fill .chip { background: var(--fill); }
.on-fill .chip.on { background: var(--tint-fill); }
select.chip { appearance: none; -webkit-appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: right 16px center, right 11px center; background-size: 5px 5px; background-repeat: no-repeat; }
select.chip.on { background-color: var(--tint-fill); }
.tag-chips .tchip { display: inline-flex; position: relative; }
.tchip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tchip span { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 18px; background: var(--fill); color: var(--text); font-size: 15px; cursor: pointer; }
.tchip span::after { content: ""; position: absolute; inset: -4px 0; }
.tchip input:checked + span { background: var(--tint-fill); color: #FFFFFF; }
.tchip input:focus-visible + span { outline: 2px solid var(--tint); outline-offset: 2px; }
.tag-group { margin: 6px 0; }
.tag-group .tag-type { display: block; font-size: 13px; color: var(--text-2); margin: 4px 0 6px; }

/* ---------- forms ---------- */
.row input[type=text], .row input[type=date], .row input[type=number], .row select, .row textarea {
  flex: 1; min-width: 0; min-height: 24px; border: 0; background: transparent; text-align: right; color: var(--text); font-size: 17px; outline: none; padding: 0;
}
.row select { appearance: none; -webkit-appearance: none; text-align-last: right; color: var(--text-2); cursor: pointer; }
.row input::placeholder, .row textarea::placeholder { color: var(--text-2); opacity: 0.8; }
.row input.left, .row textarea.left { text-align: left; }
.row textarea { min-height: 72px; resize: vertical; text-align: left; }
.field-col { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.field-col textarea, .field-col input, .field-col select { width: 100%; text-align: left; }
.search { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 8px; border-radius: 10px; background: var(--fill); color: var(--text-2); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 17px; color: var(--text); height: 36px; }
.search input::placeholder { color: var(--text-2); }
.switch { appearance: none; -webkit-appearance: none; position: relative; flex: none; width: 51px; height: 31px; border-radius: 16px; background: var(--fill); cursor: pointer; transition: background 150ms; border: 0; margin: 0; }
.switch::before { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: transform 150ms; }
.switch:checked { background: var(--tint-fill); }
.switch:checked::before { transform: translateX(20px); }
.switch:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }
.segmented { display: flex; padding: 2px; border-radius: 9px; background: var(--fill); margin: 8px 0; }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented span { display: flex; align-items: center; justify-content: center; min-height: 32px; border-radius: 7px; font-size: 15px; font-weight: 500; cursor: pointer; }
.segmented span::after { content: ""; position: absolute; inset: -6px 0; }
.segmented input:checked + span { background: var(--card); box-shadow: var(--shadow); font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--tint); }

/* ---------- notices ---------- */
.notice { border-radius: 12px; padding: 12px 16px; margin: 8px 0; background: var(--card); font-size: 15px; overflow-wrap: anywhere; }
.notice.ok { color: var(--text); }
.notice.error, .alert { color: var(--negative); }
.alert { display: flex; gap: 10px; align-items: flex-start; border-radius: 12px; padding: 12px 16px; margin: 8px 0; background: var(--card); font-size: 15px; }
.alert .icon { margin-top: 1px; }
.alert a { color: var(--tint); font-weight: 600; }

/* ---------- transaction rows / activity ---------- */
.txn-list { list-style: none; }
.txn-list > .day-h { display: flex; justify-content: space-between; gap: 8px; margin: 24px 16px 6px; font-size: 13px; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-2); }
.txn-list > .day-h:first-child { margin-top: 12px; }
.txn-list > .row { --inset: 64px; position: relative; }
.txn-list > .day-h + .row { border-top-left-radius: 12px; border-top-right-radius: 12px; }
.txn-list > .row:last-child, .txn-list > .row:has(+ .day-h), .txn-list > .row:has(+ #more) { border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }
.txn-row .row-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: inherit; }
.txn-row .amt { margin-left: auto; padding-left: 8px; }
.amt.income { color: var(--positive); }
.amt.transfer { color: var(--text-2); }
.check-circle { position: relative; flex: none; display: inline-flex; }
.check-circle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-circle span { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--tab-inactive); display: inline-block; }
.check-circle span::after { content: ""; position: absolute; inset: -10px; }
.check-circle input:checked + span { background: var(--tint-fill); border-color: var(--tint-fill); box-shadow: inset 0 0 0 4px var(--tint-fill), inset 0 0 0 12px #FFFFFF; }
.check-circle input:focus-visible + span { outline: 2px solid var(--tint); outline-offset: 2px; }
.filters-row { margin: 8px -16px 0; }
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 100; display: flex; align-items: center; gap: 4px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  background: var(--tabbar); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-top: 0.5px solid var(--separator); }
.actionbar .count { flex: 1; font-size: 15px; font-weight: 600; min-width: 0; }
.actionbar .text-btn { padding: 0 8px; }
dialog.sheet-dialog { margin: auto auto 0; width: 100%; max-width: 600px; border: 0; border-radius: 16px 16px 0 0; padding: 8px 16px calc(24px + env(safe-area-inset-bottom, 0px)); background: var(--bg); color: var(--text); }
dialog.sheet-dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
.load-more { margin-top: 12px; }

/* ---------- Add sheet ---------- */
.grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--fill); margin: 8px auto 4px; }
.sheet-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px; }
.sheet-nav .nav-title { font-size: 17px; font-weight: 600; }
.sheet-nav .right { justify-self: end; }
.sheet-nav .left { justify-self: start; }
.amount-box { display: flex; align-items: baseline; justify-content: center; gap: 4px; margin: 12px 0 8px; }
.amount-box .rupee { font-size: 30px; color: var(--text-2); font-weight: 600; }
.amount-box input { width: 2ch; min-width: 1ch; max-width: calc(100% - 40px); border: 0; background: transparent; outline: none; text-align: center; font-size: 60px; line-height: 1.1; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); padding: 0; }
.amount-box input::placeholder { color: var(--text-2); opacity: 0.5; }
.sugg { background: var(--tint-soft); }
.sugg .title b { font-weight: 700; }
.sugg .go { color: var(--tint); flex: none; }
.save-bar { position: sticky; bottom: env(safe-area-inset-bottom, 0px); z-index: 40; padding: 12px 0 4px; background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
.save-bar .btn { margin: 0; min-height: 52px; }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(196px + env(safe-area-inset-bottom, 0px)); max-width: 568px; margin: 0 auto; z-index: 120;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 6px 6px 18px; border-radius: 26px; background: var(--toast); color: #FFFFFF; font-size: 15px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3); }
.toast span { overflow-wrap: anywhere; }
.toast-undo { min-height: 40px; padding: 0 14px; border: 0; border-radius: 20px; background: transparent; color: var(--toast-action); font-weight: 600; font-size: 15px; }

.group.spaced { margin-top: 24px; }
.group > .txn-row { --inset: 64px; }
.sugg-list > .row { position: relative; --inset: 64px; }
.sugg-list > .row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: var(--inset); height: 0.5px; background: var(--separator); }
.sugg-list > .row:first-child::before { content: ""; position: absolute; top: 0; right: 0; left: 0; height: 0.5px; background: var(--separator); }
.row a.main { color: inherit; }
.switch-form { display: flex; flex: none; }
.btn.danger-text { color: var(--negative); }
.row-panel .group.on-fill { background: var(--bg); }
.row-panel .group.on-fill .row { background: var(--bg); }
.memo-box { min-height: 88px; border: 0; border-radius: 10px; background: var(--fill); padding: 10px 12px; font-size: 17px; color: var(--text); resize: vertical; outline: none; }
.row-panel .segmented { margin-top: 0; }
.row-panel #date-pick { margin-top: 8px; background: var(--bg); }
.row-panel #date-pick .row { background: var(--bg); }
.field-col .label { font-size: 17px; }
.field-col textarea { border: 0; background: transparent; resize: vertical; outline: none; min-height: 60px; font-size: 17px; color: var(--text); }
.section-f.split { display: flex; justify-content: space-between; margin-top: 16px; font-size: 15px; color: var(--text); }
.select-mode .txn-list > .row { --inset: 100px; }
.row .subtitle.neg { color: var(--negative); }

/* ---------- Books (phase 0b): sign-in, enrolment, company switcher, account, admin ---------- */
.row input[type=email], .row input[type=password] {
  flex: 1; min-width: 0; min-height: 24px; border: 0; background: transparent; text-align: right; color: var(--text); font-size: 17px; outline: none; padding: 0;
}
.row .label { white-space: nowrap; }
.row:focus-within { box-shadow: inset 0 0 0 2px var(--tint); border-radius: 12px; }
.center { text-align: center; }
.badge.warn { background: var(--fill); color: var(--warn); }
.badge.neg { background: var(--fill); color: var(--negative); }
.btn .icon { flex: none; }
.btn.secondary.danger-text { color: var(--negative); }
form + form .btn.secondary, form + form > .btn { margin-top: 12px; }

.auth { max-width: 440px; margin: 0 auto; }
.auth .large-title { margin-top: 8px; }
.auth-brand { display: flex; align-items: center; gap: 10px; max-width: 440px; margin: 0 auto; padding: 28px 0 4px; font-size: 20px; font-weight: 600; color: var(--text); }
.auth-tile { background: var(--tint-fill); }
.auth-lead { margin: 6px 0 16px; font-size: 15px; color: var(--text-2); }
.auth-foot { margin-top: 18px; text-align: center; font-size: 15px; }
.auth-foot a { display: inline-flex; align-items: center; min-height: 44px; }
.auth .group { margin-top: 8px; }
.auth .section-h { margin-left: 4px; }

.code-box { display: block; background: var(--card); border-radius: 12px; padding: 10px 16px; }
.code-box input { width: 100%; border: 0; background: transparent; outline: none; text-align: center; color: var(--text);
  font-size: 34px; line-height: 44px; font-weight: 600; letter-spacing: 0.25em; font-variant-numeric: tabular-nums; padding-left: 0.25em; }
.code-box input::placeholder { color: var(--text-2); opacity: 0.4; }
.code-box:focus-within { box-shadow: inset 0 0 0 2px var(--tint); }

.enrol-card { text-align: center; }
.qr { display: block; width: 216px; height: 216px; max-width: 100%; margin: 4px auto 12px; border-radius: 12px; image-rendering: pixelated; }
.secret { font-size: 16px; letter-spacing: 0.04em; word-spacing: 0.35em; overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; margin-top: 6px; }

.switcher { margin-top: 0; margin-bottom: 4px; }
.switcher .chip .icon { margin-left: -2px; }
.setup-card { display: flex; gap: 14px; align-items: flex-start; }
.setup-tile { background: var(--tint-fill); }
.setup-title { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.row .value .neg, .row .value.neg { color: var(--negative); }

/* ---------- Books (phase 1): partner cards, the check, statements, settings, starting balances ---------- */
.partner-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 0; }
@media (min-width: 520px) { .partner-grid { grid-template-columns: 1fr 1fr; } }
.partner-card { display: flex; flex-direction: column; gap: 2px; margin: 0; color: var(--text); min-width: 0; }
.partner-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.partner-card .chev { color: #C4C4C7; }
@media (prefers-color-scheme: dark) { .partner-card .chev { color: #5A5A5E; } }
.partner-card .mid-amt { overflow-wrap: anywhere; }
.check-card { padding-top: 12px; }
.check-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; font-size: 15px; }
.check-line .amt { text-align: right; }
.check-line.strong { font-weight: 600; font-size: 17px; }
.check-card .hairline { margin: 8px 0; }
.check-note { margin-top: 6px; }
.stmt-legend { margin-top: 6px; margin-bottom: 10px; }
.stmt-row { align-items: flex-start; }
.stmt-row .title { white-space: normal; overflow-wrap: anywhere; }
.stmt-amts { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.stmt-bal { font-size: 13px; color: var(--text-2); }
.stmt-opening .title { font-weight: 600; }
.stmt-opening .stmt-bal { font-size: 17px; color: var(--text); font-weight: 600; }
a.row.inactive .title { color: var(--text-2); }
.voided { text-decoration: line-through; color: var(--text-2); }
.row .unit { flex: none; color: var(--text-2); padding-left: 4px; }
.add-details { margin: 6px 0 4px; }
.add-details > summary { list-style: none; display: inline-flex; gap: 6px; padding-left: 16px; }
.add-details > summary::-webkit-details-marker { display: none; }
.add-details[open] > summary { margin-bottom: 4px; }
.add-details .btn { margin-top: 10px; }
.group.spaced-sm { margin-top: 10px; }
.row-panel form .btn { margin-top: 10px; }
.row .label { flex: none; }
.row select { max-width: 60%; }

/* ---------- Books (phase 3): In the bank, sheet rows, monthly income ---------- */
.bank-card .hero-amt { margin-top: 0; }
.bank-card .hero-sub { overflow-wrap: anywhere; }
.bank-formula { margin: 2px 0 8px; overflow-wrap: anywhere; }
.ok-line { color: var(--positive); font-size: 15px; font-weight: 500; }
.sheet-mark { display: inline-block; padding: 0 6px; border-radius: 8px; background: var(--fill); color: var(--text-2); font-size: 12px; line-height: 17px; }
.doubt-mark { display: inline-block; padding: 0 6px; border-radius: 8px; background: var(--fill); color: var(--warn); font-size: 12px; line-height: 17px; }
.notice.quiet { color: var(--text-2); font-size: 13px; padding: 10px 14px; }
.strong-title { font-weight: 600; }
.income-row { align-items: flex-start; }
.income-row .chev { align-self: center; }
.stmt-row .subtitle { white-space: normal; overflow-wrap: anywhere; }

/* ---------- Books (desktop layout, 7 Nov): the shell ----------
   ≥ 1024 px: a fixed 240 px sidebar and content up to 1280 px. Below: a top bar whose menu button opens the same
   nav as a sheet (books.js). No bottom tab bar. */
:root { --side-w: 240px; --topbar-h: 52px; --sticky-top: 0px; --hover: rgba(47, 91, 219, 0.06); }
@media (prefers-color-scheme: dark) { :root { --hover: rgba(122, 167, 255, 0.08); } }
:focus-visible { outline: 2px solid var(--tint); outline-offset: 2px; }
main:focus { outline: none; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 300; padding: 10px 14px; border-radius: 10px; background: var(--tint-fill); color: #FFFFFF; font-weight: 600; }
.skip:focus { top: 8px; }

.sidenav { display: flex; flex-direction: column; gap: 6px; padding: 14px 12px 16px; background: var(--card); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 8px; font-size: 18px; font-weight: 600; }
.brand .tile { width: 28px; height: 28px; }
.brand-name { flex: 1; }
.nav-close { display: none; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--fill); color: var(--text-2); align-items: center; justify-content: center; }
.co-switch { margin: 0 0 8px; border-radius: 10px; background: var(--fill); font-size: 15px; }
.co-switch summary { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 10px; list-style: none; cursor: pointer; font-weight: 600; border-radius: 10px; }
.co-switch summary::-webkit-details-marker { display: none; }
.co-switch summary .icon { color: var(--text-2); }
.co-switch.single { display: flex; align-items: center; min-height: 40px; padding: 6px 10px; font-weight: 600; }
.co-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-switch ul { list-style: none; padding: 0 4px 6px; }
.co-switch ul a { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 4px 8px; border-radius: 8px; color: var(--text); }
.co-switch ul a:hover { background: var(--card); }
.co-switch ul a[aria-current] { color: var(--tint); font-weight: 600; }
.nav-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nav-list a { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 6px 10px; border-radius: 8px; color: var(--text); font-size: 15px; }
.nav-list a .icon { color: var(--text-2); }
.nav-list a:hover { background: var(--fill); }
.nav-list a[aria-current="page"] { background: var(--tint-soft); color: var(--tint); font-weight: 600; }
.nav-list a[aria-current="page"] .icon { color: var(--tint); }
.nav-foot { margin-top: auto; padding-top: 12px; border-top: 0.5px solid var(--separator); }

@media (min-width: 1024px) {
  /* the sidebar's colour drawn on the body too, so it runs the full height of a long page */
  body.shell { padding-left: var(--side-w); background: linear-gradient(to right, var(--card) calc(var(--side-w) - 0.5px), var(--separator) calc(var(--side-w) - 0.5px), var(--separator) var(--side-w), var(--bg) var(--side-w)); }
  .toolbar .chip-row { flex-wrap: wrap; overflow: visible; }
  .sidenav { position: fixed; top: 0; bottom: 0; left: 0; width: var(--side-w); z-index: 50; border-right: 0.5px solid var(--separator); }
  .topbar, .nav-backdrop { display: none !important; }
  .container { padding: 8px 32px 40px; }
  .large-title { font-size: 28px; line-height: 34px; }
  .lt-header { padding: 16px 0 10px; }
  .eyebrow a { min-height: 28px; }
  .row { min-height: 40px; padding: 8px 14px; }
  .row .title, .row input[type=text], .row input[type=date], .row input[type=number], .row input[type=email],
  .row input[type=password], .row select, .row textarea, .text-btn { font-size: 15px; }
  .btn { min-height: 40px; font-size: 15px; border-radius: 10px; }
  .card { padding: 14px 16px; }
  .section-h { margin: 20px 4px 6px; }
  .section-f { margin: 6px 4px 0; }
}
@media (max-width: 1023.98px) {
  :root { --sticky-top: var(--topbar-h); }
  .topbar { position: sticky; top: 0; z-index: 90; display: flex; align-items: center; gap: 6px; height: var(--topbar-h); padding: 0 8px;
    background: var(--tabbar); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-bottom: 0.5px solid var(--separator); }
  .menu-btn { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--tint); display: inline-flex; align-items: center; justify-content: center; }
  .topbar-title { font-size: 17px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* closed: hidden (out of the Tab order) once it has slid out; open: visible at once, so focus can move in */
  .sidenav { position: fixed; top: 0; bottom: 0; left: 0; z-index: 120; width: min(300px, 86vw); visibility: hidden; transform: translateX(-100%);
    transition: transform 200ms ease-out, visibility 0s linear 200ms; box-shadow: 0 0 24px rgba(0, 0, 0, 0.25); padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  body.nav-open .sidenav { visibility: visible; transform: none; transition: transform 200ms ease-out, visibility 0s; }
  body.nav-open { overflow: hidden; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 110; background: rgba(0, 0, 0, 0.35); }
  .nav-close { display: inline-flex; }
}

/* bare pages (sign-in): a centred card */
body.bare .container { max-width: 520px; }
@media (min-width: 700px) { body.bare .container { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding-bottom: 64px; } }
.auth { background: var(--card); border-radius: 16px; padding: 20px 20px 24px; }
.auth .group, .auth .group .row, .auth .code-box, .auth .enrol-card { background: var(--bg); }
.auth-brand { padding-left: 4px; }

/* narrow content (forms and key-value pages) inside the wide area */
.page-narrow { max-width: 680px; }

/* ---------- tables ---------- */
.table-wrap { position: relative; margin: 8px 0; }   /* relative: .sr-only cells stay inside it */
table.data { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border-radius: 12px; font-size: 14px; line-height: 1.35; }
table.data caption { text-align: left; }
table.data th, table.data td { padding: 7px 12px; text-align: left; vertical-align: top; border-bottom: 0.5px solid var(--separator); }
table.data thead th { position: sticky; top: var(--sticky-top); z-index: 3; background: var(--card); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; color: var(--text-2); white-space: nowrap; }
table.data thead tr:first-child th:first-child { border-top-left-radius: 12px; }
table.data thead tr:first-child th:last-child { border-top-right-radius: 12px; }
table.data tbody th { font-weight: 400; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .nowrap, table.data .date { white-space: nowrap; }
table.data tbody tr:hover > * { background: var(--hover); }
table.data tbody tr.edit-row:hover > *, table.data tbody tr.detail-row:hover > * { background: var(--card); }
table.data tfoot th, table.data tfoot td { border-bottom: 0; font-weight: 600; }
table.data > :last-child > tr:last-child > * { border-bottom: 0; }
table.data .muted-cell { color: var(--text-2); }
table.data a { color: var(--tint); }
table.data .act { text-align: right; white-space: nowrap; width: 1%; }
table.data .act .text-btn { min-height: 0; padding: 0; font-size: 14px; line-height: 1.35; }
tr.link-row { cursor: pointer; }
tr.group-h > th { background: var(--bg); color: var(--text); font-size: 13px; font-weight: 600; padding-top: 14px; }
tr.group-h .muted { font-weight: 400; margin-left: 6px; }
tr.opening > *, tfoot tr.closing > * { font-weight: 600; }
.tag { display: inline-block; padding: 0 6px; border-radius: 8px; background: var(--fill); color: var(--text-2); font-size: 11px; line-height: 16px; margin-left: 4px; vertical-align: 1px; }
table.data .sheet-mark, table.data .doubt-mark { font-size: 11px; line-height: 16px; margin-left: 4px; vertical-align: 1px; }
@media (max-width: 719.98px) {
  .table-wrap { overflow-x: auto; margin-left: -16px; margin-right: -16px; padding: 0 16px; }
  .table-wrap.tall { max-height: calc(100vh - var(--topbar-h) - 24px); overflow: auto; }
  .table-wrap.tall table.data thead th { top: 0; }
  .table-wrap:not(.tall) table.data thead th { position: static; }
  table.data { font-size: 13px; }
  table.data th, table.data td { padding: 6px 8px; }
}

/* toolbars above a table */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 8px; }
.toolbar .chip-row { margin: 0; padding: 4px 0; flex: 1 1 360px; min-width: 0; }
.toolbar .chip { height: 32px; font-size: 14px; padding: 0 12px; }
.search-form { display: flex; align-items: center; gap: 8px; flex: 0 1 340px; min-width: 0; }
.search-form .search { flex: 1; min-width: 0; background: var(--card); }
.search-form .search input { font-size: 15px; }
.search-form .text-btn { font-size: 15px; min-height: 36px; }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 15px; border-radius: 10px; gap: 6px; }
.seg-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 6px; }
.seg-links a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border-radius: 17px; background: var(--card); color: var(--text); font-size: 15px; }
.seg-links a[aria-current] { background: var(--tint-fill); color: #FFFFFF; font-weight: 500; }
.result-note { margin: 0 4px 6px; }

/* ---------- Home ---------- */
.partner-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.home-cols { display: grid; grid-template-columns: 1fr; gap: 8px 24px; align-items: start; }
@media (min-width: 1180px) { .home-cols { grid-template-columns: minmax(300px, 360px) 1fr; } }
.home-cols .section-h { margin-top: 18px; }
.home-cols > *, .two-cols > *, .detail-grid > * { min-width: 0; }   /* grid items: never wider than their column */
.latest-table td.desc { overflow-wrap: anywhere; }
@media (max-width: 719.98px) { .latest-table td.desc { min-width: 160px; } }

/* statements */
.stmt-table td.desc { overflow-wrap: anywhere; }
@media (min-width: 1280px) { .stmt-table td.desc { min-width: 220px; } .stmt-table td.type { min-width: 120px; } }
/* below 1280 (1024 leaves 720 px of content): compact cells; Monthly income folds Stream under the month */
@media (max-width: 1279.98px) {
  table.data { font-size: 13px; }
  table.data th, table.data td { padding: 6px 8px; }
  .income-table .col-stream { display: none; }
}
@media (min-width: 1280px) { .income-table .stream-inline { display: none; } }
@media (max-width: 719.98px) {
  .stmt-table th:first-child, .stmt-table td:first-child { position: sticky; left: 0; z-index: 2; background: var(--card); }
  .stmt-table th:last-child, .stmt-table td:last-child { position: sticky; right: 0; z-index: 2; background: var(--card); box-shadow: -6px 0 6px -6px rgba(0, 0, 0, 0.25); }
  .stmt-table thead th:first-child, .stmt-table thead th:last-child { z-index: 4; }
  .large-title { font-size: 28px; line-height: 34px; }
  .stmt-table td.desc { min-width: 180px; }
}

/* monthly income */
.expander { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; color: var(--text); font-weight: 600; text-align: left; }
.expander .icon { color: var(--text-2); transition: transform 150ms; }
.expander[aria-expanded="true"] .icon { transform: rotate(90deg); }
.income-table tr.income-row { cursor: pointer; }
.income-table .sub { display: block; color: var(--text-2); font-size: 12px; padding-left: 18px; }
.note-icon { display: inline-flex; vertical-align: -2px; margin-left: 4px; color: var(--warn); cursor: help; border-radius: 50%; }
tr.detail-row > td { background: var(--card); padding: 4px 16px 14px 30px; }
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 8px 24px; }
@media (min-width: 900px) { .detail-grid { grid-template-columns: 1fr 1fr; } }
.detail-grid h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-2); margin: 8px 0 4px; }
.mini { list-style: none; font-size: 13px; }
.mini li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 0.5px solid var(--separator); }
.mini li:last-child { border-bottom: 0; }
.mini .who-h { font-weight: 600; justify-content: flex-start; }
.detail-notes { margin: 8px 0 0; color: var(--warn); font-size: 13px; }
.detail-link { display: inline-block; margin-top: 8px; font-size: 13px; }

/* settings: tables with an inline edit form per row */
.set-nav { margin-bottom: 4px; }
.set-section { scroll-margin-top: calc(var(--sticky-top) + 8px); }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 8px 0 4px; }
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); min-width: 0; flex: 1 1 160px; }
.fld.narrow { flex: 0 1 90px; }
.fld.wide { flex: 2 1 260px; }
.fld input[type=text], .fld input[type=number], .fld input[type=date], .fld input[type=email], .fld input[type=password], .fld select, .fld textarea {
  width: 100%; min-height: 36px; padding: 6px 10px; border: 0.5px solid var(--separator); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 15px; }
.fld textarea { min-height: 60px; resize: vertical; }
.fld.check { flex: 0 0 auto; flex-direction: row; align-items: center; gap: 8px; min-height: 36px; font-size: 14px; color: var(--text); }
.fld .unit-wrap { display: flex; align-items: center; gap: 6px; }
.form-btns { display: flex; gap: 8px; flex: 0 0 auto; }
.form-btns .btn { margin: 0; min-height: 36px; padding: 0 16px; font-size: 15px; border-radius: 10px; width: auto; }
.form-note { flex-basis: 100%; font-size: 12px; color: var(--text-2); }
tr.edit-row > td { background: var(--card); padding-top: 2px; }
tr.add-row td { padding-top: 4px; padding-bottom: 4px; }
.add-row .text-btn { display: inline-flex; gap: 6px; min-height: 32px; font-size: 15px; }
.form-card { background: var(--card); border-radius: 12px; padding: 4px 14px 12px; margin: 8px 0; }

/* key-value pages (account, admin user) */
.two-cols { display: grid; grid-template-columns: 1fr; gap: 0 24px; align-items: start; }
@media (min-width: 1180px) { .two-cols { grid-template-columns: 1fr 1fr; } }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions-row form { display: contents; }
.actions-row .btn { width: auto; margin: 0; }

/* ---------- entries (phase 2): the Add button, the side panel, the forms, the preview, the toast ----------
   The panel: 480 px over the page from the right on a desktop, the whole screen on a phone. */
.add-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; background: var(--tint-fill); color: #FFFFFF; font-weight: 600; font-size: 15px; }
.add-btn.side { min-height: 38px; margin: 0 0 8px; }
.add-btn.top { margin-left: auto; min-height: 36px; padding: 0 12px; }
.add-btn:hover { filter: brightness(1.06); }
.panel-backdrop { position: fixed; inset: 0; z-index: 190; background: rgba(0, 0, 0, 0.35); }
.panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 200; width: min(480px, 100vw); overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); box-shadow: -8px 0 32px rgba(0, 0, 0, 0.25); padding-bottom: env(safe-area-inset-bottom, 0px); }
.panel[hidden], .panel-backdrop[hidden] { display: none; }
body.panel-open { overflow: hidden; }
.panel-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px 10px; background: var(--bg); border-bottom: 0.5px solid var(--separator); }
.panel-title { font-size: 18px; font-weight: 600; }
.icon-btn { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: var(--fill); color: var(--text-2); }
.icon-btn:hover { color: var(--text); }
.type-seg { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px 2px; }
.type-seg a { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 16px; background: var(--card); color: var(--text); font-size: 14px; }
.type-seg a[aria-current="page"] { background: var(--tint-fill); color: #FFFFFF; font-weight: 600; }
.entry-form { display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 16px; }
.entry-form .notice { margin: 0; }
.entry-form > .fld, .entry-form > details > .fld, fieldset.costs .fld { flex: none; }   /* a column: no 160 px basis */
.fld-row { display: flex; flex-wrap: wrap; gap: 12px; }
.fld-row > .fld { flex: 1 1 150px; }
.fld.narrow-date { flex: 0 1 160px; }
.fld.big-amt input { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 44px; }
.entry-form .fld select, .entry-form .fld input { background: var(--card); }
fieldset.costs, fieldset.seg-fld { border: 0; min-width: 0; }
fieldset.costs legend, fieldset.seg-fld legend { font-size: 12px; color: var(--text-2); padding: 0; margin-bottom: 4px; }
fieldset.costs legend { font-size: 13px; font-weight: 600; color: var(--text); }
/* a cost line: what + amount + remove on one row, who paid it under them */
.cost-line { display: grid; grid-template-columns: minmax(0, 1fr) 128px 36px; grid-template-areas: "what amt rm" "paid paid rm";
  gap: 6px; align-items: center; padding: 8px; margin-bottom: 8px; border-radius: 10px; background: var(--card); }
.cost-line .c-what { grid-area: what; } .cost-line .c-amt { grid-area: amt; } .cost-line .c-paid { grid-area: paid; }
.cost-line .icon-btn { grid-area: rm; align-self: start; }
.entry-form .cost-line .fld input, .entry-form .cost-line .fld select { background: var(--bg); }
.add-cost { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; font-size: 15px; }
.seg-fld .segmented { margin: 0; }
details.more { background: var(--card); border-radius: 10px; padding: 8px 12px; }
details.more summary { cursor: pointer; font-size: 14px; color: var(--tint); }
details.more[open] summary { margin-bottom: 8px; }
details.more .fld { margin-top: 8px; }
.preview { background: var(--card); border-radius: 12px; padding: 10px 12px; }
.preview h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-2); margin-bottom: 6px; }
.preview h4 { font-size: 14px; margin: 8px 0 4px; }
.pv-line { font-size: 13px; color: var(--text-2); margin: 2px 0; }
.pv-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 6px 0; }
.pv-table caption { text-align: left; font-size: 12px; color: var(--text-2); padding-top: 6px; }
.pv-table th, .pv-table td { padding: 4px 0; border-bottom: 0.5px solid var(--separator); text-align: left; font-weight: 400; vertical-align: top; }
.pv-table tr:last-child th, .pv-table tr:last-child td { border-bottom: 0; }
.pv-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 8px; }
.pv-table .neg { color: var(--negative); }
.pv-table .sub { display: block; font-size: 12px; color: var(--text-2); }
.pv-table thead th { font-size: 11px; text-transform: uppercase; color: var(--text-2); }
.pv-bal .changed { font-weight: 600; }
.panel .save-bar, .entry-page .save-bar { display: flex; gap: 8px; position: sticky; bottom: 0; padding: 12px 0 4px; background: linear-gradient(to bottom, transparent, var(--bg) 30%); }
.panel .save-bar .btn, .entry-page .save-bar .btn { margin: 0; min-height: 44px; }
.panel .save-bar .btn.secondary, .entry-page .save-bar .btn.secondary { flex: 0 0 auto; width: auto; padding: 0 18px; }
.form-note.keys { text-align: center; }
.entry-page { background: var(--card); border-radius: 16px; margin-top: 16px; overflow: hidden; }
.entry-page .panel-head { background: var(--card); }
.entry-page .entry-form .fld select, .entry-page .entry-form .fld input { background: var(--bg); }
/* the toast: bottom right on a desktop, above the bottom edge on a phone */
.toast { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 210; }
.toast form { display: contents; }
@media (min-width: 1024px) { .toast { left: auto; right: 32px; max-width: 360px; } }
.desc a { color: inherit; }
.desc a:hover { color: var(--tint); text-decoration: underline; }
.muted-cell-inline { color: var(--text-2); font-size: 13px; }
.void-form { margin-top: 16px; }
.kv .check-line > span:last-child { text-align: right; overflow-wrap: anywhere; }
@media (max-width: 719.98px) {
  .panel { width: 100vw; }
  .cost-line { grid-template-columns: minmax(0, 1fr) 108px 36px; }
}

/* ---------- approvals and instant saves (8 Nov) ---------- */
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: auto; border-radius: 10px; background: var(--negative); color: #FFFFFF; font-size: 12px; font-weight: 700; }
.section-h .badge { margin-left: 6px; vertical-align: 1px; }
.approvals { margin: 4px 0 16px; }
.appr { margin: 8px 0; }
.appr.mine { background: var(--tint-soft); }
.appr-head { font-size: 14px; }
.appr-desc { font-size: 15px; font-weight: 600; margin-top: 4px; }
.appr .tag { font-size: 12px; padding: 1px 6px; border-radius: 6px; background: var(--fill); }
.appr-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.appr-actions form { display: flex; align-items: center; gap: 8px; }
.appr-actions .btn { width: auto; margin: 0; }
.reject-form { flex: 1 1 280px; }
.reject-form .fld { flex: 1; }
.sub-h { font-size: 13px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--text-2); margin: 14px 4px 4px; font-weight: 600; }
.is-busy { opacity: 0.45; pointer-events: none; }
tr.saving-row td { color: var(--text-2); font-style: italic; background: var(--tint-soft); }
tr.load-row td { text-align: center; padding: 10px; }
.toast.error { background: var(--negative); }
.toast.error .toast-undo { color: #FFFFFF; text-decoration: underline; }
.pv-need { font-size: 13px; font-weight: 600; color: var(--tint); margin: 2px 0 6px; }
.pv-need.warn, .approval-note.warn { color: var(--warn); }
.neg { color: var(--negative); }

/* ---------- documents: the file space (8 Nov) ---------- */
.docs-layout { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 1024px) { .docs-layout { grid-template-columns: 300px minmax(0, 1fr); } }
.doc-tree { padding: 8px 6px; font-size: 14px; max-height: calc(100vh - 140px); overflow: auto; position: sticky; top: 12px; }
.doc-tree ul { list-style: none; padding-left: 14px; }
.doc-tree > ul { padding-left: 0; }
.doc-tree a { display: flex; align-items: center; gap: 6px; padding: 4px 6px; border-radius: 6px; color: var(--text); min-height: 30px; }
.doc-tree a:hover { background: var(--fill); }
.doc-tree a[aria-current="page"] { background: var(--tint-soft); color: var(--tint); font-weight: 600; }
.doc-tree a .icon { color: var(--text-2); flex: none; }
.doc-tree summary { list-style: none; cursor: pointer; }
.doc-tree summary::-webkit-details-marker { display: none; }
.doc-tree .cnt { margin-left: auto; font-size: 12px; color: var(--text-2); }
.doc-tree .trash-link { margin-top: 8px; border-top: 0.5px solid var(--separator); padding-top: 6px; }
.doc-main .search-form { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.doc-main .search { flex: 1; }
.doc-path { font-size: 16px; font-weight: 600; margin: 4px 4px 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.doc-path .sep { color: var(--text-2); }
.doc-path a { color: var(--text); }
.doc-table .doc-name a { display: inline-flex; align-items: center; gap: 6px; }
.doc-table .sub { display: block; font-size: 12px; color: var(--text-2); font-weight: 400; }
.doc-table .act { white-space: nowrap; text-align: right; }
.doc-table .act form { display: inline; }
.thumb img { display: block; max-width: 140px; max-height: 90px; margin-top: 6px; border-radius: 6px; border: 0.5px solid var(--separator); object-fit: cover; }
.section-h a { font-size: 13px; text-transform: none; letter-spacing: 0; margin-left: 8px; display: inline-flex; gap: 4px; align-items: center; }

.docs-layout > * { min-width: 0; }
.file-btn { position: relative; cursor: pointer; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 2px solid var(--tint); outline-offset: 2px; }
.doc-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 6px; }
.doc-bar .doc-path { flex: 1; margin: 4px; }
.doc-bar form { display: inline; }
.doc-path a[aria-current="page"] { color: var(--tint); }
.new-folder { background: var(--card); border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; }
.edit-row .inline-form { gap: 8px 16px; }
.doc-main.over { outline: 2px dashed var(--tint); outline-offset: 6px; border-radius: 12px; }
.upload-box { position: fixed; right: 24px; bottom: 84px; z-index: 205; width: min(420px, calc(100vw - 32px)); max-height: 50vh; overflow: auto;
  background: var(--card); border-radius: 14px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25); padding: 10px 12px; font-size: 13px; }
.upload-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.upload-head .icon-btn { width: 28px; height: 28px; font-size: 18px; }
.upload-box ul { list-style: none; }
.up-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 0.5px solid var(--separator); }
.up-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-state { color: var(--text-2); white-space: nowrap; }
.up-item.done .up-state { color: var(--positive); }
.up-item.failed .up-state { color: var(--negative); white-space: normal; }
.zip-tree { list-style: none; font-size: 13px; background: var(--card); border-radius: 10px; padding: 8px 10px; max-height: 50vh; overflow: auto; }
.zip-tree li { padding: 2px 0; display: flex; align-items: center; gap: 4px; }
.zip-tree .d1 { padding-left: 16px; } .zip-tree .d2 { padding-left: 32px; } .zip-tree .d3 { padding-left: 48px; }
.zip-tree .d4 { padding-left: 64px; } .zip-tree .d5 { padding-left: 80px; } .zip-tree .d6 { padding-left: 96px; }
.zip-tree .d7 { padding-left: 112px; } .zip-tree .d8 { padding-left: 128px; }
.zip-tree .bad { color: var(--negative); }
@media (max-width: 719.98px) { .upload-box { right: 16px; bottom: 76px; } }
@media (max-width: 719.98px) { .lt-header { flex-wrap: wrap; } .lt-actions { flex-wrap: wrap; gap: 6px; } }
