/*
 * Aartha — the "Aangan, refined" look, carried from Ghar Kharcha. Ivory and white, one
 * terracotta accent, a quiet colour per member (slots 1–6), light-weight numbers, thin-line
 * icons. One 480px column, phone first.
 * No inline styles anywhere (CSP style-src 'self'): every state is a class, and a bar's
 * proportions are classes too (.w1–.w100, see the split bar).
 *
 * Component classes (build pages from these):
 *   Shell      body.app .has-tabs .has-dock .sheet-page | body.public (.front-page) | main.col
 *   App bar    header.appbar > a.lockup + (right side: details.switcher | .me)   (layout.php draws it; $headRight fills the right)
 *   Logo       a.lockup > span.logo-tile (svg) + .lockup-t > .lockup-name + .lockup-tag   (_icon.php: lockup(), logo_tile())
 *   Member     .m1 … .m6 (slot colours) | .mx (a former member, grey) — each sets --pc / --pcs for everything inside
 *              .dot | .pc (text in member colour) | .av (30px initial circle) | .me (38px initial circle) | .left ("(left)" tag)
 *   Type       h1 | h2 | .eyebrow | .note | .prose | .notice (.notice-warn) | .err | .ok | .muted | .empty | .sr (screen-reader only)
 *   Home head  .top > div > .top-m + h1, then .me
 *   Switcher   details.switcher > summary (.sw-k "Group" + b name + svg.i chev) + .sw-menu > a(.on)… + a.sw-new
 *   Balance    .card.bal > .bal-who (b.pc) + .big (> .rs) + .split + .legend + a.bal-link
 *   Split bar  .split(.empty) > i.mN.wK …  — one <i> per member, slot class m1–m6/mx, K = 1–100 its share of the bar
 *              (flex-grow, so they need not add to exactly 100); .legend > span (.dot + name b) …  (wraps for 3–6 people)
 *   Sections   .sec > .eyebrow + a
 *   Rows       .rows > .row(.pay)(.mN) > (.ic | .av) + .grow (> .t1 + .t2) + .amt ; a.row is tappable
 *   Buttons    .btn + .btn-dark | .btn-acc | .btn-quiet | .btn-del | .btn-link ; .btn-block (full width) ; .btn-sm ; .btn-pair (two side by side)
 *   Add dock   .dock > a.btn.btn-dark.btn-block   (fixed above the tab bar; layout.php draws it from $dock)
 *   Tab bar    nav.tabbar > a(.on) > svg.i + span   (layout.php: Home, Month, Statement, Group)
 *   Sheet      body.sheet-page > .col > .sheet > .grab + .shead (a, h1, span) + .hero (> .rs + input) + .hline … + .save-bar > button.save
 *   Switch     .seg > (input[type=radio] + label(.mN > .dot))…   (Equal / Custom %, Today / Yesterday / Pick, paid-by)
 *   Tiles      .tiles > label.tile > input[type=radio] + .tile-ic (svg.i) + .tile-n ; details.more > summary.tile + .more-body
 *   Fields     label.field > .field-label + input|select|textarea, then field_error() (p.err) ; .field-row (label left, b value right) ; .stack (form spacing)
 *   Date       details.when > summary.field-row (b > [data-when-label] + .chev) + .when-body (.seg + .dates > select×3) ; .dates.ym
 *   Line form  form.line-form(.archived) > label.field + button.btn.btn-sm…
 *   Toast      .toast > .toast-msg + form > button.toast-undo   (_flash.php)
 *   PIN pad    .signin > h1 + form.signin-form > .pin-dots(span.on) + .pin-hint + .pin-row (input.pin-input + button) + .not-you + .keypad(button, .del, .keypad-gap)
 *   Month      .mnav (a | span.off, h1) | .mt | .tbl > .tl(.end) (span, b) | .day (day headings)
 *   Num table  .tbl > table.nums > thead th + tbody tr(.mN) > th (.dot name) + td… ; tfoot tr = totals   (who paid and shares, settling up)
 *   Members    .card.members > .mrow(.mN)(.is-left) > .av + .grow (.t1 + .tag) + (.pct > input + span "%" | .amt | form.btn-sm)
 *   Shares     form[data-shares] .seg (Equal / Custom %) + .members .pct inputs + p.sum[data-sum] (.sum-ok | .sum-bad)   (aartha.js keeps the sum live)
 *   Invite     .card.invite > .eyebrow + .invite-link (input[readonly] id=…) + .btn-pair (a.btn-acc WhatsApp, button[data-copy="#id"]) + .note
 *   Settle     .card.settle > (a|div).pay(.mN) > .av + .grow (b … pays b …) + .amt (+ .rec "Record ›" on a link)
 *   Pair       .field-pair > label.field + .field-arrow + label.field (payment: who paid → who got it)
 *   Front      section.front > h1.front-h + p.front-p + .btn… + ul.feats > li.feat.mN > .dot + span > b + text
 *   Auth       section.auth > h1 + .note + form.stack … + p.auth-alt ; .hp (the sign-up honeypot, off-screen)
 *   Pages      .brand (public header) | .phead (a.back + h1) | .page-msg | .card | fieldset.card.person > legend | article.doc (Privacy, Terms) | footer.foot
 *   Spacing    .space-s (8px above) | .space (16px above) | .space-l (28px above)
 */

:root {
    --bg: #FAF8F5;
    --card: #FFFFFF;
    --ink: #1F1C19;
    --mut: #8C8279;
    --faint: #BDB4AB;
    --line: #ECE6DF;
    --acc: #A9512B;
    --accs: #F6ECE6;
    --ok: #2F6B66;
    /* member slots 1–6: teal, plum, ochre (spec), then slate blue, moss, indigo (builder's call); x = former member */
    --m1: #2F6B66; --m1s: #E7F0EF;
    --m2: #7B4767; --m2s: #F2E9EF;
    --m3: #8A6A2A; --m3s: #F4EEE2;
    --m4: #3E5F86; --m4s: #E8EEF5;
    --m5: #5D6E38; --m5s: #EEF1E5;
    --m6: #5E4F8C; --m6s: #EDEAF5;
    --mx: #A39A91; --mxs: #F1EDE8;
    --seg: #F1EDE8;
    --dim: #8F8780;
    --pc: var(--mut);
    --pcs: var(--seg);
    --gut: 20px;
    --tabh: 58px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
    --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ── base ─────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-feature-settings: "tnum" 1;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; }
h2 { font-size: 17px; font-weight: 600; }
a { color: var(--acc); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: .92em; background: var(--seg); padding: 1px 5px; border-radius: 5px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
::selection { background: var(--accs); }

/* the icon sprite: <svg class="i"><use href="icons.svg#cart"></use></svg> */
.i {
    width: 20px; height: 20px; flex: none;
    fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
    vertical-align: middle;
}

/* ── shell ────────────────────────────────────────────────────────────── */

.col {
    max-width: 480px;
    margin: 0 auto;
    padding: calc(var(--safe-t) + 14px) var(--gut) 32px;
}
body.has-tabs .col { padding-bottom: calc(var(--tabh) + var(--safe-b) + 28px); }
body.has-tabs.has-dock .col { padding-bottom: calc(var(--tabh) + var(--safe-b) + 96px); }
body.public .col { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

/* ── the logo lockup and the app bar ──────────────────────────────────── */

.lockup { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; min-height: 44px; }
.logo-tile {
    display: inline-flex; align-items: center; justify-content: center; flex: none;
    width: 32px; height: 32px; border-radius: 8px; background: var(--acc);
}
.logo-tile svg { display: block; }
.lockup-t { display: flex; flex-direction: column; line-height: 1.1; }
.lockup-name { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.lockup-tag { font-size: 9.5px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--mut); margin-top: 3px; }
.brand { padding-top: 6px; }
.appbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 48px; margin-bottom: 6px; }

/* ── member colours (slots 1–6, former members grey) ──────────────────── */

.m1 { --pc: var(--m1); --pcs: var(--m1s); }
.m2 { --pc: var(--m2); --pcs: var(--m2s); }
.m3 { --pc: var(--m3); --pcs: var(--m3s); }
.m4 { --pc: var(--m4); --pcs: var(--m4s); }
.m5 { --pc: var(--m5); --pcs: var(--m5s); }
.m6 { --pc: var(--m6); --pcs: var(--m6s); }
.mx { --pc: var(--mx); --pcs: var(--mxs); }
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--pc); margin-right: 6px; vertical-align: 1px; }
.pc { color: var(--pc); font-weight: 600; }
.me, .av {
    display: flex; align-items: center; justify-content: center; flex: none;
    border-radius: 50%; background: var(--pcs); color: var(--pc); font-weight: 600;
}
.me { width: 38px; height: 38px; font-size: 14px; text-decoration: none; }
.av { width: 30px; height: 30px; font-size: 12px; }
.left { font-size: 12px; font-weight: 400; color: var(--mx); }

/* ── type ─────────────────────────────────────────────────────────────── */

.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--mut); }
.muted { color: var(--mut); }
.note { font-size: 13.5px; color: var(--mut); }
.prose { font-size: 15px; color: var(--ink); max-width: 36em; }
.notice { background: var(--accs); border-radius: 14px; padding: 12px 14px; font-size: 14px; color: var(--ink); }
.notice-warn { border: 1px solid var(--acc); }
.err { color: var(--acc); font-size: 13px; font-weight: 500; margin-top: 6px; }
.ok { color: var(--ok); font-size: 13px; font-weight: 500; }
.empty { color: var(--mut); font-size: 14px; text-align: center; padding: 22px 0; }
.sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── Home header ──────────────────────────────────────────────────────── */

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 6px; }
.top-m { font-size: 13px; color: var(--mut); }
.top h1 { margin-top: 2px; }

/* ── the group switcher (a <details> menu, no script) ─────────────────── */

details.switcher { position: relative; min-width: 0; }
details.switcher > summary {
    list-style: none; cursor: pointer;
    display: flex; align-items: center; gap: 4px; min-height: 44px; max-width: 220px;
    font-size: 13px; color: var(--mut);
}
details.switcher > summary::-webkit-details-marker { display: none; }
details.switcher > summary b { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
details.switcher > summary .i { width: 16px; height: 16px; color: var(--mut); transition: transform .15s var(--ease); }
details.switcher[open] > summary .i { transform: rotate(180deg); }
.sw-k { flex: none; }
.sw-menu {
    position: absolute; z-index: 40; right: 0; top: calc(100% + 4px);
    min-width: 220px; max-width: calc(100vw - 2 * var(--gut));
    padding: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
    box-shadow: 0 10px 30px rgba(31, 28, 25, .12);
    animation: toast-in .18s var(--ease) both;
}
.sw-menu a {
    display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 12px; border-radius: 10px;
    color: var(--ink); text-decoration: none; font-size: 14.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sw-menu a.on { font-weight: 600; background: var(--seg); }
.sw-menu a:active { background: var(--seg); }
.sw-menu .sw-new { color: var(--acc); font-weight: 500; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; margin-top: 4px; }

/* ── cards and the balance card ───────────────────────────────────────── */

.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 18px; }
.card + .card { margin-top: 14px; }
.bal { margin-top: 20px; padding: 20px 20px 16px; }
.bal-who { font-size: 14px; color: var(--mut); }
.big { font-size: 40px; font-weight: 300; letter-spacing: -.02em; line-height: 1.15; margin: 4px 0 2px; }
.big .rs, .hero .rs { font-size: 17px; font-weight: 400; color: var(--mut); margin-right: 6px; vertical-align: .8em; letter-spacing: 0; }

/* who-paid split for 1–6 members: <div class="split" role="img" aria-label="…"><i class="m1 w52"></i><i class="m2 w28"></i>…</div>.
   Each <i> grows in proportion to its wK class, so rounding never breaks the bar. Nothing paid yet: .split.empty with no <i>. */
.split { display: flex; gap: 2px; height: 5px; margin: 16px 0 10px; border-radius: 3px; overflow: hidden; background: var(--line); }
.split.empty { gap: 0; }
.split > i { display: block; flex: 0 1 0; min-width: 2px; background: var(--pc); }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 4px 14px; font-size: 13px; color: var(--mut); }
.legend .sep { flex: 1; text-align: center; }
.legend b { color: var(--ink); font-weight: 500; }
.bal-link {
    display: flex; justify-content: space-between; align-items: center;
    margin: 14px -20px -16px; padding: 12px 20px 14px; min-height: 48px;
    border-top: 1px solid var(--line);
    font-size: 14px; font-weight: 600; color: var(--acc); text-decoration: none;
    border-radius: 0 0 20px 20px;
}
.bal-link:active { background: var(--accs); }

/* ── sections and rows ────────────────────────────────────────────────── */

.sec { display: flex; justify-content: space-between; align-items: baseline; margin: 26px 0 2px; }
.sec a { font-size: 13px; color: var(--mut); text-decoration: none; padding: 8px 0; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows > * + * { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; min-height: 62px; color: inherit; text-decoration: none; }
a.row:active { background: linear-gradient(90deg, transparent, var(--seg) 12%, var(--seg) 88%, transparent); }
.ic {
    display: flex; align-items: center; justify-content: center; flex: none;
    width: 38px; height: 38px; border-radius: 12px;
    background: var(--pcs); color: var(--pc);
}
.ic .i { width: 19px; height: 19px; }
.grow { flex: 1; min-width: 0; }
.t1, .t2 { display: block; }
.t1 { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t2 { font-size: 12.5px; color: var(--mut); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.amt { flex: none; font-size: 15px; font-weight: 500; }
.row.pay .t1 { color: var(--pc); }

/* ── buttons ──────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 50px; padding: 13px 20px;
    border: 0; border-radius: 16px;
    font-size: 15px; font-weight: 500; letter-spacing: .01em; line-height: 1.2;
    text-decoration: none; text-align: center;
    transition: transform .12s var(--ease), opacity .12s;
}
.btn:active { transform: scale(.985); }
.btn-block { display: flex; width: 100%; }
.btn-dark { background: var(--ink); color: #fff; }
.btn-acc { background: var(--acc); color: #fff; }
.btn-quiet { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn-del { background: var(--card); color: var(--acc); border: 1px solid var(--line); }
.btn-link { background: none; color: var(--mut); min-height: 44px; padding: 10px 4px; }
.btn[disabled] { opacity: .5; }
.btn-pair { display: flex; gap: 8px; }
.btn-pair > .btn { flex: 1; min-width: 0; min-height: 46px; padding: 11px 12px; font-size: 14px; }

/* the dark Add button, fixed above the tab bar inside the column */
.dock {
    position: fixed; z-index: 20; left: 0; right: 0;
    bottom: calc(var(--tabh) + var(--safe-b));
    max-width: 480px; margin: 0 auto;
    padding: 14px var(--gut) 10px;
    background: linear-gradient(rgba(250, 248, 245, 0), var(--bg) 45%);
}

/* ── tab bar ──────────────────────────────────────────────────────────── */

.tabbar {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    max-width: 480px; margin: 0 auto;
    display: flex;
    padding: 6px 0 calc(6px + var(--safe-b));
    background: rgba(250, 248, 245, .96);
    border-top: 1px solid var(--line);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 46px;
    font-size: 11px; font-weight: 500; color: var(--mut); text-decoration: none;
}
.tabbar .i { width: 22px; height: 22px; }
.tabbar a.on { color: var(--ink); }

/* ── the sheet (Add, Settle, Entry): a page drawn as a bottom sheet over a dimmed backdrop ── */

body.sheet-page { background: var(--dim); }
body.sheet-page .col { padding: calc(var(--safe-t) + 28px) 0 0; }
.sheet {
    display: flex; flex-direction: column;
    min-height: calc(100vh - 28px); min-height: calc(100dvh - 28px - var(--safe-t));
    padding: 10px var(--gut) 0;
    background: var(--bg);
    border-radius: 24px 24px 0 0;
    animation: sheet-up .34s var(--ease) both;
}
@keyframes sheet-up { from { transform: translateY(48px); opacity: 0; } to { transform: none; opacity: 1; } }
.grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 4px; }
.shead { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px; font-size: 14px; color: var(--mut); }
.shead a { justify-self: start; color: var(--mut); text-decoration: none; padding: 10px 0; }
.shead h1 { font-size: 15px; font-weight: 600; color: var(--ink); }
.shead > :last-child { justify-self: end; }
.hero { display: flex; justify-content: center; align-items: baseline; margin: 18px 0 0; }
.hero input {
    width: 5.5ch; min-width: 1ch; max-width: 100%;
    padding: 0; border: 0; border-radius: 0; background: transparent; outline: none;
    font-size: 48px; font-weight: 300; letter-spacing: -.03em; text-align: center; color: var(--ink);
}
.hero input::placeholder { color: var(--faint); }
.hero .rs { position: relative; top: -1.3em; }   /* raised beside the digits (vertical-align does nothing in flex) */
@supports (field-sizing: content) {
    .hero input { field-sizing: content; width: auto; }
}
.hline { width: 28px; height: 2px; border-radius: 1px; background: var(--acc); margin: 6px auto 20px; transition: width .2s var(--ease); }
.hero:focus-within + .hline { width: 56px; }
.save-bar {
    position: sticky; bottom: 0; z-index: 5;
    margin: auto calc(-1 * var(--gut)) 0;
    padding: 16px var(--gut) calc(16px + var(--safe-b));
    background: linear-gradient(rgba(250, 248, 245, 0), var(--bg) 35%);
}
.save { display: flex; width: 100%; background: var(--acc); color: #fff; }

/* ── segmented switch (radios) ────────────────────────────────────────── */

.seg { position: relative; display: flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--seg); }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.seg label {
    flex: 1; display: flex; align-items: center; justify-content: center;
    min-height: 42px; padding: 8px 6px; border-radius: 10px;
    font-size: 14px; font-weight: 500; color: var(--mut); cursor: pointer;
    transition: background .15s, color .15s, box-shadow .15s;
}
.seg input:checked + label { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
.seg input:focus-visible + label { outline: 2px solid var(--acc); outline-offset: 1px; }

/* ── category tiles (radios; tapping the chosen one clears it, see aartha.js) ── */

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 6px; margin-top: 18px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; font-size: 11.5px; color: var(--mut); text-align: center; cursor: pointer; }
.tile input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.tile-ic {
    display: flex; align-items: center; justify-content: center;
    width: 52px; height: 52px; border-radius: 16px;
    border: 1px solid var(--line); background: var(--card); color: var(--ink);
    transition: background .15s, border-color .15s, color .15s;
}
.tile-ic .i { width: 21px; height: 21px; stroke-width: 1.5; }
.tile-n { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile input:checked ~ .tile-ic { border-color: var(--acc); background: var(--accs); color: var(--acc); }
.tile input:checked ~ .tile-n { color: var(--acc); font-weight: 600; }
.tile input:focus-visible ~ .tile-ic { outline: 2px solid var(--acc); outline-offset: 2px; }
details.more > summary { list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
.tiles > details.more[open] { grid-column: 1 / -1; }
.tiles > details.more[open] > summary { width: 25%; }
.more-body { margin-top: 4px; }

/* ── fields ───────────────────────────────────────────────────────────── */

.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: block; padding: 10px 0 8px; border-bottom: 1px solid var(--line); transition: border-color .15s; }
.field:focus-within { border-bottom-color: var(--acc); }
.field-label { display: block; font-size: 12.5px; color: var(--mut); }
.field input, .field select, .field textarea {
    display: block; width: 100%;
    padding: 6px 0; border: 0; border-radius: 0; background: transparent; outline: none;
    font-size: 16px; color: var(--ink);
}
.field select { -webkit-appearance: none; appearance: none; }
.field input::placeholder, .field textarea::placeholder { color: var(--faint); }
.field-row {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    min-height: 50px; border-bottom: 1px solid var(--line);
    font-size: 14px; color: var(--mut); text-decoration: none;
}
.field-row b { color: var(--ink); font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.stack > .err { margin-top: -8px; }
.person legend { float: left; width: 100%; margin-bottom: 4px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--pc); }
.person legend + * { clear: both; }

/* the date row: "Today, 14 Mangsir ›" opens Today / Yesterday / Pick and the BS selects */
details.when > summary { list-style: none; cursor: pointer; }
details.when > summary::-webkit-details-marker { display: none; }
details.when > summary b { display: flex; align-items: center; gap: 6px; }
.chev { color: var(--faint); font-size: 18px; font-weight: 400; transition: transform .15s var(--ease); }
details.when[open] .chev { transform: rotate(90deg); }
.when-body { padding: 12px 0 14px; border-bottom: 1px solid var(--line); }
.dates { display: grid; grid-template-columns: 1fr 1.6fr 1.2fr; gap: 8px; margin-top: 10px; }
.dates select {
    min-height: 44px; padding: 8px 10px; min-width: 0;
    border: 1px solid var(--line); border-radius: 12px; background: var(--card);
    font-size: 16px; color: var(--ink); -webkit-appearance: none; appearance: none;
}
.dates select:focus { border-color: var(--acc); outline: none; }
.dates.ym { grid-template-columns: 1.6fr 1fr; margin-top: 6px; }   /* Statement: a month and a year */

/* a field with its buttons on one line (Me: name, email; Group: categories) */
.line-form { display: flex; align-items: flex-end; gap: 8px; }
.line-form .field { flex: 1; min-width: 0; }
.line-form + .line-form, .line-form + .err + .line-form { margin-top: 4px; }
.line-form.archived input { color: var(--mut); }
.btn-sm { flex: none; min-height: 44px; padding: 8px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 4px; }

/* inside the sheets */
.sheet-note { text-align: center; margin-top: 14px; }
.save-bar .btn-del { margin-top: 10px; }
.tile-none { font-size: 18px; color: var(--mut); }

/* an entry, read-only */
.card.view { padding-top: 6px; padding-bottom: 6px; }
.card.view .big { margin: 10px 0 8px; }
.card.view .field-row:last-child { border-bottom: 0; }

/* ── toast ────────────────────────────────────────────────────────────── */

.toast {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 48px; margin: 0 0 14px; padding: 8px 8px 8px 16px;
    border-radius: 14px; background: var(--ink); color: #fff; font-size: 14px;
    animation: toast-in .28s var(--ease) both;
}
.toast form { margin: 0; flex: none; }
.toast-undo { min-height: 40px; padding: 8px 12px; border: 0; border-radius: 10px; background: none; color: #F0C3AC; font-weight: 600; }
@keyframes toast-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
body.public .toast { margin-top: 14px; }

/* ── the PIN pad: six dots, the keypad ────────────────────────────────── */

.signin { flex: 1; display: flex; flex-direction: column; text-align: center; padding-top: clamp(24px, 8vh, 80px); }
.signin h1 { font-size: 22px; }
.signin-form { flex: 1; display: flex; flex-direction: column; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 34px 0 10px; }
.pin-dots span { width: 13px; height: 13px; border-radius: 50%; border: 1.5px solid var(--faint); transition: background .12s, border-color .12s; }
.pin-dots span.on { background: var(--ink); border-color: var(--ink); }
.pin-hint { font-size: 13px; color: var(--mut); margin-top: 6px; }
.signin .err { margin-top: 10px; }
.pin-row { display: flex; gap: 10px; margin-top: 18px; }
.pin-input {
    flex: 1; min-width: 0; min-height: 50px; padding: 10px 14px;
    border: 1px solid var(--line); border-radius: 14px; background: var(--card);
    font-size: 20px; letter-spacing: .4em; text-align: center;
}
.pin-input:focus { border-color: var(--acc); outline: none; }
.not-you { margin-top: 18px; font-size: 13.5px; color: var(--mut); }
.not-you a { display: inline-block; padding: 10px 2px; font-weight: 500; }
.keypad {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px;
    margin: auto 0 0; padding: 20px 10px calc(14px + var(--safe-b));
}
.keypad button {
    min-height: 62px; border: 0; border-radius: 18px; background: none;
    font-size: 27px; font-weight: 300; color: var(--ink);
    transition: background .1s;
}
.keypad button:active { background: var(--seg); }
.keypad .del { font-size: 15px; font-weight: 400; color: var(--mut); }

/* ── Month ────────────────────────────────────────────────────────────── */

.mnav { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.mnav h1 { font-size: 19px; }
.mnav a, .mnav .off {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 12px;
    font-size: 24px; color: var(--mut); text-decoration: none;
}
.mnav .off { color: var(--line); }
.mnav a:active { background: var(--seg); }
.mt { text-align: center; margin-top: 16px; }
.mt .t2 { white-space: normal; }
.tbl { margin-top: 16px; padding: 4px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.tl { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; font-size: 14px; color: var(--mut); border-bottom: 1px solid var(--line); }
.tl:last-child { border-bottom: 0; }
.tl b { color: var(--ink); font-weight: 500; text-align: right; }
.tl.end { color: var(--ink); font-weight: 600; }
.tl.end b { color: var(--acc); font-weight: 600; }
.day { margin: 24px 0 2px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--mut); }

/* the per-member number table: who paid, share and net (Month), settling up */
.tbl.scroll { overflow-x: auto; }
table.nums { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.nums th, table.nums td { padding: 10px 0 10px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.nums th:first-child, table.nums td:first-child { padding-left: 0; text-align: left; }
table.nums thead th { font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--mut); padding-top: 12px; }
table.nums tbody th { font-weight: 500; color: var(--ink); max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
table.nums td { color: var(--ink); }
table.nums tfoot th, table.nums tfoot td { border-bottom: 0; font-weight: 600; }
table.nums tr:last-child > * { border-bottom: 0; }
table.nums .neg { color: var(--acc); }

/* ── Group: members and shares, the invite box ────────────────────────── */

.members { padding: 4px 16px; }
.members .eyebrow { display: block; margin: 12px 0 4px; }
.mrow { display: flex; align-items: center; gap: 11px; min-height: 54px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.mrow:last-child { border-bottom: 0; }
.mrow .t1 { font-size: 14.5px; }
.mrow.is-left .t1 { color: var(--mut); }
.tag { font-size: 12px; font-weight: 400; color: var(--mut); }
.pct { display: flex; align-items: baseline; gap: 4px; flex: none; font-size: 14px; color: var(--mut); }
.pct input {
    width: 3.4em; padding: 6px 0; text-align: right;
    border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; outline: none;
    font-size: 16px; color: var(--ink);
}
.pct input:focus { border-bottom-color: var(--acc); }
.pct input:disabled { color: var(--mut); }
.mrow form { margin: 0; }
.sum { padding: 8px 0 12px; font-size: 13px; color: var(--mut); }
.sum.sum-ok { color: var(--ok); }
.sum.sum-bad { color: var(--acc); font-weight: 500; }

.invite .invite-link {
    display: block; width: 100%; margin: 10px 0;
    padding: 11px 12px; border: 0; border-radius: 10px; background: var(--seg);
    font-size: 13px; color: var(--ink); text-overflow: ellipsis;
}
.invite .invite-link:focus { outline: 2px solid var(--acc); outline-offset: 1px; }
.invite .note { margin-top: 10px; }
.copied { color: var(--ok); }

/* ── Settle up: fewest payments ───────────────────────────────────────── */

.settle { padding: 4px 16px; }
.settle .pay {
    display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 10px 0;
    border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px;
}
.settle .pay:last-child { border-bottom: 0; }
.settle .pay b { font-weight: 600; }
.settle a.pay:active { background: linear-gradient(90deg, transparent, var(--seg) 12%, var(--seg) 88%, transparent); }
.settle .amt { font-size: 14.5px; }

/* a Settle up line she is in: the whole line is a link, with "Record ›" at its end */
.settle .rec { flex: none; font-size: 12.5px; font-weight: 600; color: var(--acc); margin-left: 2px; }

/* the Group tab's cards: room for the switch, the button and the notes inside */
.members .seg { margin: 4px 0 6px; }
.members > .btn-block { margin: 4px 0 6px; }
.members > .err { margin-bottom: 4px; }
.mrow .btn-sm { margin-bottom: 0; }
.invite-new { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.invite-new .btn-link { padding-left: 0; padding-right: 0; color: var(--acc); font-size: 14px; }
.invite-new .note { margin: 0; }

/* the payment sheet: who paid → who got it */
.field-pair { display: flex; align-items: flex-end; gap: 10px; }
.field-pair .field { flex: 1; min-width: 0; }
.field-arrow { flex: none; padding-bottom: 14px; color: var(--mut); }

/* a button pair where one side is a form (Me: Change PIN / Remove PIN) */
.btn-pair > form { flex: 1; min-width: 0; display: flex; margin: 0; }
.btn-pair > form > .btn { flex: 1; min-width: 0; min-height: 46px; padding: 11px 12px; font-size: 14px; }

/* ── the front page ───────────────────────────────────────────────────── */

.front { padding-top: 6px; }
.front-h { font-size: 30px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; margin: 26px 0 12px; }
.front-p { font-size: 15px; color: var(--mut); margin-bottom: 22px; max-width: 30em; }
.front .btn-link.front-in { color: var(--ink); font-size: 14.5px; margin-top: 4px; }
.feats { list-style: none; margin: 18px 0 0; padding: 0; }
.feat { display: flex; align-items: flex-start; gap: 4px; margin: 14px 0; font-size: 14px; color: var(--mut); }
.feat .dot { margin-top: 6px; margin-right: 10px; }
.feat b { display: block; font-size: 14.5px; font-weight: 600; color: var(--ink); }

/* ── the account pages ────────────────────────────────────────────────── */

.auth { padding-top: clamp(20px, 6vh, 56px); }
.auth h1 { margin-bottom: 6px; }
.auth > .note { margin-bottom: 6px; }
.auth-alt { margin-top: 14px; text-align: center; font-size: 14px; color: var(--mut); }
.auth-alt a { display: inline-block; padding: 8px 2px; font-weight: 500; }
.auth-alt .btn-link { padding: 10px 16px; }
.auth > .notice { margin-top: 14px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Privacy and Terms */
.doc { padding-top: 20px; max-width: 36em; }
.doc h1 { margin-bottom: 6px; }
.doc h2 { margin: 24px 0 6px; font-size: 16px; }
.doc p, .doc li { font-size: 15px; color: var(--ink); }
.doc p + p { margin-top: 10px; }
.doc ul { margin: 0; padding-left: 20px; }
.doc li + li { margin-top: 6px; }

/* the footer of the public pages */
.foot { margin-top: auto; padding: 36px 0 calc(10px + var(--safe-b)); font-size: 12px; line-height: 2; color: var(--mut); text-align: center; }
.foot a { color: var(--mut); padding: 6px 0; }

/* ── other pages ──────────────────────────────────────────────────────── */

.phead { display: flex; align-items: center; gap: 4px; min-height: 44px; margin-bottom: 8px; }
.phead .back { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: -12px; color: var(--ink); }
.page-msg { padding-top: 40px; }
.page-msg h1 { margin-bottom: 10px; }
.page-msg .prose, .page-msg .note, .page-msg .notice { margin-bottom: 16px; }
.setup .note { margin-bottom: 12px; }
.setup .stack { padding-bottom: 24px; }
.signout { margin-top: 18px; text-align: center; }
.space-s { margin-top: 8px; }
.space { margin-top: 16px; }
.space-l { margin-top: 28px; }

/* ── motion ───────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}

/* ── split-bar proportions: .split > i.wK grows K parts (1–100) ──────── */
.split > .w1 { flex-grow: 1; } .split > .w2 { flex-grow: 2; } .split > .w3 { flex-grow: 3; } .split > .w4 { flex-grow: 4; } .split > .w5 { flex-grow: 5; }
.split > .w6 { flex-grow: 6; } .split > .w7 { flex-grow: 7; } .split > .w8 { flex-grow: 8; } .split > .w9 { flex-grow: 9; } .split > .w10 { flex-grow: 10; }
.split > .w11 { flex-grow: 11; } .split > .w12 { flex-grow: 12; } .split > .w13 { flex-grow: 13; } .split > .w14 { flex-grow: 14; } .split > .w15 { flex-grow: 15; }
.split > .w16 { flex-grow: 16; } .split > .w17 { flex-grow: 17; } .split > .w18 { flex-grow: 18; } .split > .w19 { flex-grow: 19; } .split > .w20 { flex-grow: 20; }
.split > .w21 { flex-grow: 21; } .split > .w22 { flex-grow: 22; } .split > .w23 { flex-grow: 23; } .split > .w24 { flex-grow: 24; } .split > .w25 { flex-grow: 25; }
.split > .w26 { flex-grow: 26; } .split > .w27 { flex-grow: 27; } .split > .w28 { flex-grow: 28; } .split > .w29 { flex-grow: 29; } .split > .w30 { flex-grow: 30; }
.split > .w31 { flex-grow: 31; } .split > .w32 { flex-grow: 32; } .split > .w33 { flex-grow: 33; } .split > .w34 { flex-grow: 34; } .split > .w35 { flex-grow: 35; }
.split > .w36 { flex-grow: 36; } .split > .w37 { flex-grow: 37; } .split > .w38 { flex-grow: 38; } .split > .w39 { flex-grow: 39; } .split > .w40 { flex-grow: 40; }
.split > .w41 { flex-grow: 41; } .split > .w42 { flex-grow: 42; } .split > .w43 { flex-grow: 43; } .split > .w44 { flex-grow: 44; } .split > .w45 { flex-grow: 45; }
.split > .w46 { flex-grow: 46; } .split > .w47 { flex-grow: 47; } .split > .w48 { flex-grow: 48; } .split > .w49 { flex-grow: 49; } .split > .w50 { flex-grow: 50; }
.split > .w51 { flex-grow: 51; } .split > .w52 { flex-grow: 52; } .split > .w53 { flex-grow: 53; } .split > .w54 { flex-grow: 54; } .split > .w55 { flex-grow: 55; }
.split > .w56 { flex-grow: 56; } .split > .w57 { flex-grow: 57; } .split > .w58 { flex-grow: 58; } .split > .w59 { flex-grow: 59; } .split > .w60 { flex-grow: 60; }
.split > .w61 { flex-grow: 61; } .split > .w62 { flex-grow: 62; } .split > .w63 { flex-grow: 63; } .split > .w64 { flex-grow: 64; } .split > .w65 { flex-grow: 65; }
.split > .w66 { flex-grow: 66; } .split > .w67 { flex-grow: 67; } .split > .w68 { flex-grow: 68; } .split > .w69 { flex-grow: 69; } .split > .w70 { flex-grow: 70; }
.split > .w71 { flex-grow: 71; } .split > .w72 { flex-grow: 72; } .split > .w73 { flex-grow: 73; } .split > .w74 { flex-grow: 74; } .split > .w75 { flex-grow: 75; }
.split > .w76 { flex-grow: 76; } .split > .w77 { flex-grow: 77; } .split > .w78 { flex-grow: 78; } .split > .w79 { flex-grow: 79; } .split > .w80 { flex-grow: 80; }
.split > .w81 { flex-grow: 81; } .split > .w82 { flex-grow: 82; } .split > .w83 { flex-grow: 83; } .split > .w84 { flex-grow: 84; } .split > .w85 { flex-grow: 85; }
.split > .w86 { flex-grow: 86; } .split > .w87 { flex-grow: 87; } .split > .w88 { flex-grow: 88; } .split > .w89 { flex-grow: 89; } .split > .w90 { flex-grow: 90; }
.split > .w91 { flex-grow: 91; } .split > .w92 { flex-grow: 92; } .split > .w93 { flex-grow: 93; } .split > .w94 { flex-grow: 94; } .split > .w95 { flex-grow: 95; }
.split > .w96 { flex-grow: 96; } .split > .w97 { flex-grow: 97; } .split > .w98 { flex-grow: 98; } .split > .w99 { flex-grow: 99; } .split > .w100 { flex-grow: 100; }

/* Admin counts */
table.plain { width: 100%; border-collapse: collapse; }
table.plain th, table.plain td { padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 400; }
table.plain td { text-align: right; font-variant-numeric: tabular-nums; }
table.plain tr:last-child th, table.plain tr:last-child td { border-bottom: 0; }
