/* Gumleaf, tightened. Mobile-first, 390 px design width, no truncated text. */

@font-face { font-family: "Figtree"; src: url("/fonts/figtree.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #ffffff;
  --card: #ffffff;
  --fill: #f1f4f2;
  --press: #e6ebe7;
  --ink: #14231a;
  --muted: #526158;
  --line: #dce3dd;
  --euc: #24573d;
  --euc-soft: #e8efea;
  --wattle: #f3c443;
  --due: #7a5600;
  --over: #a0281c;
  --over-soft: #f9e6e3;
  --radius: 6px;
  --font: "Figtree", "Helvetica Neue", Arial, sans-serif;
  --font-brand: "Bricolage Grotesque", "Figtree", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus, :focus-visible { outline: none; }
html.kbd :focus-visible { outline: 2.5px solid var(--euc); outline-offset: 2px; border-radius: 6px; }
html { background: var(--bg); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

#app { min-height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; background: var(--bg); }
#screen { flex: 1; display: flex; flex-direction: column; overflow-x: clip; background: var(--bg); }
#screen > .page { flex: 1; display: flex; flex-direction: column; background: var(--bg); }

/* Top bar */
.top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; min-height: 56px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) max(10px, env(safe-area-inset-right, 0px)) 6px max(10px, env(safe-area-inset-left, 0px));
  background: var(--bg); transition: box-shadow .2s; }
html.scrolled .top { box-shadow: 0 1px 0 var(--line); }
.top h1 { margin: 0; font-size: 18px; font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.top .spacer { flex: 1; }
/* With a back button the title is centred, iOS style, clear of the button. */
.top:has(> .back) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto) minmax(0, 1fr); column-gap: 8px; }
.top:has(> .back) > .back { justify-self: start; }
.top:has(> .back) > h1 { grid-column: 2; text-align: center; font-size: 17px; }
.top:has(> .back) > :last-child:not(h1, .spacer, .back) { grid-column: 3; justify-self: end; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.wordmark { font-family: var(--font-brand); font-weight: 700; font-size: 20px; letter-spacing: -0.02em; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: var(--radius); display: grid; place-items: center; cursor: pointer; color: var(--ink); flex: none; text-decoration: none; }
.avatar { font-weight: 700; font-size: 13px; background: var(--euc-soft); color: var(--euc); }
.back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 8px 0 2px; color: var(--euc); font-weight: 600; text-decoration: none; }

/* Page body */
main { flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.has-tabs main { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
h2.q { margin: 0; font-size: 21px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; text-wrap: balance; }
.hint { margin: -6px 0 0; color: var(--muted); font-size: 14px; }
.small { font-size: 13px; color: var(--muted); }
.sec { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); margin: 4px 0 -6px; }
.amount { font-weight: 600; font-size: 26px; letter-spacing: -0.015em; line-height: 1.1; }
.banner { background: var(--fill); border-radius: 14px; padding: 12px 14px; font-size: 14px; }
.banner.warn { background: #fdf3d8; }
.banner.bad { background: var(--over-soft); }
.banner ul { margin: 6px 0 0; padding-left: 18px; }

/* Forms */
form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label, .field .lbl { font-size: 13px; font-weight: 600; }
.field .opt { font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; min-height: 48px; padding: 0 14px; background: var(--fill); border: 1.5px solid transparent; border-radius: 12px; font-size: 16px; -webkit-appearance: none; appearance: none; }
.field textarea { padding: 10px 12px; min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--euc); background: var(--card); }
.field input[aria-invalid="true"] { border-color: var(--over); }
.field .help { font-size: 12.5px; color: var(--muted); }
.field .err { font-size: 12.5px; color: var(--over); }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.pair.short-first { grid-template-columns: 120px minmax(0, 1fr); }
.static { min-height: 48px; display: flex; align-items: center; padding: 0 14px; border-radius: 12px; background: var(--fill); color: var(--muted); }
.seg { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 2px; padding: 3px; border-radius: 12px; background: var(--fill); }
.seg button { border: 0; border-radius: 9px; background: transparent; min-height: 42px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; transition: background .15s, color .15s; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(20, 35, 26, .14); }
.check { display: flex; align-items: flex-start; gap: 10px; background: var(--fill); border-radius: 14px; padding: 14px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--euc); flex: none; }
.check .s { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 18px; border: 0; border-radius: 99px; background: var(--euc); color: #ffffff; font-weight: 700; font-size: 15.5px; cursor: pointer; text-decoration: none; text-align: center; transition: transform .08s ease, opacity .15s; -webkit-tap-highlight-color: transparent; }
.btn:active { transform: scale(.985); }
.btn.secondary { background: var(--fill); color: var(--ink); }
.btn.danger { background: var(--fill); color: var(--over); }
.btn[disabled] { opacity: 0.5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--euc); font-weight: 600; cursor: pointer; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.actions-row { display: flex; flex-direction: column; gap: 6px; }
.foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 8px; }

/* Lists and rows */
.list { background: var(--fill); border-radius: 16px; overflow: hidden; }
.kv { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); flex: 0 1 auto; min-width: 0; overflow-wrap: anywhere; }
.kv > b { font-weight: 600; text-align: right; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.kv.total { background: var(--bg); }
.kv.total > span:first-child { color: var(--ink); font-weight: 600; }
.srow { display: flex; flex-direction: column; gap: 1px; padding: 9px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.srow:last-child { border-bottom: 0; }
.srow > span { font-size: 12px; color: var(--muted); }
.srow > b { font-weight: 600; overflow-wrap: anywhere; }
.srow > .sub { font-weight: 400; color: var(--muted); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; min-height: 44px; }
.row:last-child { border-bottom: 0; }
.row b { font-weight: 600; overflow-wrap: anywhere; }
.row .s { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.row .r { justify-self: end; text-align: right; font-weight: 600; }
.nav-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer; }
.nav-row:last-child { border-bottom: 0; }
.nav-row.danger { color: var(--over); }
.opt-row { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; min-height: 60px; cursor: pointer; }
.opt-row:last-child { border-bottom: 0; }
.opt-row b { display: block; font-weight: 600; }
.opt-row .s { font-size: 13px; color: var(--muted); }
.radio { width: 22px; height: 22px; border-radius: 999px; border: 1.5px solid #b9c4bc; background: var(--card); flex: none; }
.opt-row[aria-pressed="true"] .radio { border: 6px solid var(--euc); }
.doc-head { padding: 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.doc-head .meta { font-size: 12.5px; color: var(--muted); }
.title-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.empty { padding: 18px 14px; color: var(--muted); font-size: 14px; }
.report { border-bottom: 1px solid var(--line); }
.report:last-child { border-bottom: 0; }
.report .row { border-bottom: 0; }
.report-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; padding: 0 14px 12px; }
.pay { display: grid; grid-template-columns: 96px minmax(0, 1fr) 44px; align-items: center; padding-left: 14px; min-height: 46px; border-bottom: 1px solid var(--line); font-size: 14px; }
.pay:last-child { border-bottom: 0; }
.pay > span { color: var(--muted); }
.pay > b { font-weight: 600; overflow-wrap: anywhere; }

/* Status: coloured text with a small square marker, fixed line height */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; line-height: 20px; white-space: nowrap; color: var(--muted); }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 1px; background: currentColor; }
.status.due, .status.part_paid { color: var(--due); }
.status.paid { color: var(--euc); }
.status.overdue { color: var(--over); }
.status.reported { color: var(--ink); }

/* Bottom tabs */
.tabs { box-shadow: 0 -1px 0 var(--line); position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px; z-index: 6; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--bg); padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px; font-size: 11px; font-weight: 500; color: var(--muted); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--euc); font-weight: 600; }

.ic { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.centre { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.centre p { margin: 0; color: var(--muted); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: #ffffff; padding: 10px 16px; border-radius: 99px; font-size: 14px; max-width: calc(100% - 32px); z-index: 30; }
.progress-bar { height: 3px; background: var(--line); margin: -16px calc(-1 * max(16px, env(safe-area-inset-right, 0px))) 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px))); }
.progress-bar i { display: block; height: 100%; background: var(--euc); }
.row-actions { display: flex; gap: 14px; }
.danger-text { color: var(--over); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.link.center { justify-content: center; }
.done-mark { color: var(--euc); }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

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

/* Rows press like buttons; hairlines sit inset on the fill. */
.list > .row, .list > .nav-row, .list > .kv, .list > .srow, .list > .opt-row, .list > .pay { border-bottom-color: rgba(20, 35, 26, .08); }
a.row, .nav-row, .opt-row { -webkit-tap-highlight-color: transparent; transition: background .12s; }
a.row:active, .nav-row:active, .opt-row:active { background: var(--press); }
.kv.total { background: transparent; }
.doc-head { border-bottom-color: rgba(20, 35, 26, .08); }

/* Gestures (see gestures.js) */
.back-under { position: fixed; inset: 0; overflow: hidden; background: var(--bg); pointer-events: none; z-index: 3; }
.back-under > section { max-width: 560px; margin: 0 auto; }
.back-sheet { position: fixed; inset: 0; background: var(--bg); box-shadow: -10px 0 24px rgba(20, 35, 26, .16); pointer-events: none; z-index: 3; }
.back-shade { position: absolute; inset: 0; background: #000000; opacity: 0; }
#screen { position: relative; z-index: 4; }
.tab-peek { position: fixed; left: 0; right: 0; bottom: 0; overflow: hidden; z-index: 5; background: var(--bg); pointer-events: none; }
.tab-peek > section { max-width: 560px; margin: 0 auto; }
.tab-peek > section > .head { display: none; }
.ptr { position: fixed; left: 0; right: 0; height: 0; overflow: hidden; z-index: 21; pointer-events: none; display: flex; align-items: center; justify-content: center; transition: opacity .25s ease, scale .25s ease; }
.ptr.held { left: 50%; right: auto; width: 40px; height: 40px; margin-left: -20px; border-radius: 50%; background: var(--card); box-shadow: 0 4px 18px rgba(0, 0, 0, .14); }
.ptr.gone { opacity: 0; scale: .6; }
.ptr-spin { width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--euc-soft); border-top-color: var(--euc); flex: none; }
.ptr-spin.spinning { animation: ptr-turn .7s linear infinite; }
@keyframes ptr-turn { to { rotate: 1turn; } }

/* Sign-in: a green panel with the form in a white sheet below */
main:has(> .auth) { padding: 0; }
.auth { flex: 1; display: flex; flex-direction: column; background: var(--euc); }
.auth-panel { color: #ffffff; display: flex; flex-direction: column; gap: 18px;
  padding: calc(28px + env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) 28px max(24px, env(safe-area-inset-left, 0px)); }
.auth-panel.compact { padding-bottom: 22px; }
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand .wordmark { font-size: 26px; }
.auth-panel.compact .wordmark { font-size: 21px; }
.auth-title { margin: 0; font-size: 33px; line-height: 1.05; letter-spacing: -0.03em; font-weight: 700; text-wrap: balance; max-width: 13ch; }
.auth-sample { background: rgba(255, 255, 255, .1); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.auth-sample > div { display: flex; justify-content: space-between; gap: 12px; }
.auth-sample-sub { color: rgba(255, 255, 255, .78); font-size: 13px; }
.auth-sample-sub b { color: #ffffff; }
.auth-paid { color: var(--wattle); font-weight: 600; font-size: 13px; }
.auth-sheet { flex: 1; background: var(--bg); border-radius: 26px 26px 0 0; display: flex; flex-direction: column; gap: 14px;
  padding: 26px max(22px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(22px, env(safe-area-inset-left, 0px)); }
.auth-form { gap: 12px; }
.auth-form .hint { margin: 0; }
.auth-form .hint b { color: var(--ink); overflow-wrap: anywhere; }
.auth-form .small, .auth-tenant { margin: 0; }
.auth-tenant { margin-top: auto; padding-top: 16px; }
.auth-form .back { align-self: flex-start; padding-left: 0; margin: -10px 0 -4px; }
.auth-form .link { min-height: 0; }
.pill { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 6px 0 20px; border-radius: 99px; background: var(--fill); border: 1.5px solid transparent; }
.pill:focus-within { border-color: var(--euc); background: var(--card); }
.field .pill input { flex: 1; min-width: 0; min-height: 0; padding: 0; border: 0; background: transparent; border-radius: 0; font-size: 16.5px; outline: none; }
.field .pill input:focus { background: transparent; }
.pill-go { width: 44px; height: 44px; border: 0; border-radius: 99px; background: var(--euc); color: #ffffff; display: grid; place-items: center; flex: none; cursor: pointer; transition: transform .08s; }
.pill-go:active { transform: scale(.94); }
.pill-go[disabled] { opacity: .5; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
/* Code boxes: one transparent input over six cells */
.cells { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.cell { height: 58px; border-radius: 14px; background: var(--fill); display: grid; place-items: center; font-size: 25px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cell.on { background: var(--card); box-shadow: inset 0 0 0 2px var(--euc); }
.field .cells input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; border: 0; padding: 0; background: transparent; font-size: 16px; color: transparent; -webkit-text-fill-color: transparent; caret-color: transparent; }
.field .cells input:focus { background: transparent; }
.field .cells input::selection { background: transparent; }
