/* Layout: mobile app shell — green top bar, scrolling content, fixed bottom tab bar.
   Flat colour blocks, thin rules, no gradients or shadows. Scoreboard numerals for money. */
:root {
  --pitch: #094426;        /* academy green (from the crest) */
  --pitch-2: #146B3E;
  --sun: #FCCA1B;          /* crest yellow */
  --sun-ink: #2A2100;
  --plum: #562F82;         /* crest purple, used sparingly */
  --bg: #F4F6F1;
  --surface: #FFFFFF;
  --line: #DDE3D8;
  --ink: #16211A;
  --muted: #5E6B62;
  --ok: #1E7A45;
  --ok-bg: #E2F1E6;
  --warn: #9A6A00;
  --warn-bg: #FBF0CC;
  --bad: #B3261E;
  --bad-bg: #F8E1DF;
  --on-pitch: #FFFFFF;
  --display: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --pitch: #0A3B22; --pitch-2: #1D6B41; --sun: #FCCA1B; --sun-ink: #2A2100; --plum: #8E6BC0;
    --bg: #0E1411; --surface: #151D18; --line: #26332B; --ink: #E7EDE8; --muted: #93A398;
    --ok: #6CCB8F; --ok-bg: #173323; --warn: #E8C25A; --warn-bg: #33290E; --bad: #F08A82; --bad-bg: #3A1B19;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 var(--body);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; margin: 0; line-height: 1.1; text-wrap: balance; }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* App shell */
.shell { display: flex; flex-direction: column; min-height: 100%; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--pitch); color: var(--on-pitch);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; gap: 12px;
}
.crest { display: block; width: 100%; height: 100%; }
.topbar .logo { width: 36px; height: 36px; border-radius: 6px; background: #fff; padding: 4px; color: var(--sun-ink); display: grid; place-items: center; font: 700 15px var(--display); overflow: hidden; flex: none; }
.topbar .logo img { width: 100%; height: 100%; object-fit: contain; }
.backup-card { display: flex; flex-direction: column; gap: 10px; }
.backup-card h3 { font-size: 20px; }
.backup-card p { margin: 0; font-size: 14px; color: var(--muted); }
.stamp { border-left: 3px solid var(--plum); padding-left: 10px; font-size: 14px; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title small { display: block; font-size: 12px; opacity: .75; text-transform: uppercase; letter-spacing: .08em; }
.topbar .title strong { display: block; font: 700 20px var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.iconbtn { background: none; border: 0; color: inherit; width: 40px; height: 40px; display: grid; place-items: center; position: relative; cursor: pointer; border-radius: 50%; }
.iconbtn:focus-visible, .btn:focus-visible, .tab:focus-visible, .row:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }
.iconbtn svg { width: 24px; height: 24px; }
.badge { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--sun); color: var(--sun-ink); font: 700 12px/18px var(--display); text-align: center; }
.back { margin-left: -8px; }

.offline { background: var(--warn-bg); color: var(--warn); font-size: 13px; padding: 6px max(16px, env(safe-area-inset-left, 0px)); }

main {
  flex: 1;
  padding: 16px max(16px, env(safe-area-inset-right, 0px)) calc(96px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 18px;
  max-width: 720px; width: 100%; margin: 0 auto;
}

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--surface); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px max(4px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(4px, env(safe-area-inset-left, 0px));
}
.tab { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.tab svg { width: 24px; height: 24px; }
.tab.on { color: var(--pitch-2); }
.tab.on svg { stroke-width: 2.4; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tab.on { color: var(--sun); } }

/* Blocks */
.section { display: flex; flex-direction: column; gap: 10px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-head h2 { font-size: 22px; }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.panel.pad { padding: 14px; }

/* Month hero: flat green block with scoreboard figures */
.board { background: var(--pitch); color: var(--on-pitch); border-radius: var(--r); padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.board .label { color: rgba(255,255,255,.7); }
.board .big { font: 700 40px/1 var(--display); font-variant-numeric: tabular-nums; }
.board .mid { font: 700 28px/1 var(--display); font-variant-numeric: tabular-nums; }
.board .span2 { grid-column: 1 / -1; }
.bar { height: 8px; background: rgba(255,255,255,.18); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--sun); }
.monthpick { display: flex; align-items: center; justify-content: space-between; }
.monthpick button { background: rgba(255,255,255,.12); border: 0; color: inherit; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.monthpick strong { font: 700 20px var(--display); }

/* Lists */
.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer; }
.list > .row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .grow strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .grow span { display: block; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font: 700 18px var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--ok-bg); color: var(--pitch-2); display: grid; place-items: center; font: 700 15px var(--display); flex: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { color: var(--ok); } }
.empty { padding: 22px 14px; text-align: center; color: var(--muted); font-size: 14px; }

.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 3px; white-space: nowrap; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.plain { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }

/* Scorebook strip: 12 months of fees */
.scorebook { display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px; }
.scorebook div { aspect-ratio: 1; max-width: 100%; border: 1px solid var(--line); display: grid; place-items: center; font: 600 11px var(--display); color: var(--muted); border-radius: 2px; }
.scorebook div.paid { background: var(--pitch-2); border-color: var(--pitch-2); color: #fff; }
.scorebook div.due { background: var(--warn-bg); border-color: var(--warn-bg); color: var(--warn); }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--r); padding: 12px 16px; font-weight: 600; cursor: pointer; background: var(--pitch); color: #fff; min-height: 46px; }
.btn.sun { background: var(--sun); color: var(--sun-ink); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }
.btnrow > .btn { flex: 1 1 140px; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); min-height: 46px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--pitch-2); outline-offset: -1px; border-color: transparent; }
.form { display: flex; flex-direction: column; gap: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 > * { min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.check input { width: 20px; height: 20px; accent-color: var(--pitch-2); }
.search { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface); }
.seg button { flex: 1; border: 0; background: none; padding: 9px 6px; font-weight: 600; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--pitch); color: #fff; }

.notice { padding: 12px 14px; border-radius: var(--r); font-size: 14px; }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; min-width: 0; overflow-wrap: anywhere; }

.install { display: flex; align-items: center; gap: 12px; background: var(--sun); color: var(--sun-ink); border-radius: var(--r); padding: 12px 14px; }
.install .grow { flex: 1; }
.install strong { display: block; font: 700 18px var(--display); }
.install span { font-size: 13px; }
.install .btn { background: var(--sun-ink); color: var(--sun); }

/* Bottom sheet */
.sheet[hidden], .toast[hidden] { display: none !important; }
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(8,16,11,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet .card { background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; border-radius: 12px 12px 0 0; padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 14px; }
.sheet .card header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet .card header h2 { font-size: 24px; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: -6px auto 0; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--r); font-size: 14px; font-weight: 600; max-width: calc(100% - 32px); }

/* Auth */
.auth { min-height: 100vh; display: flex; flex-direction: column; }
.auth .hero { background: var(--pitch); color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 48px) max(20px, env(safe-area-inset-right, 0px)) 32px max(20px, env(safe-area-inset-left, 0px)); }
.auth .hero .mark { width: 64px; height: 64px; background: #fff; border-radius: 8px; padding: 8px; margin-bottom: 18px; }
.auth .hero .rule { height: 3px; width: 48px; background: var(--plum); margin-top: 14px; }
.auth .hero h1 { font-size: 44px; }
.auth .hero p { margin: 8px 0 0; opacity: .8; }
.auth .body { padding: 24px max(20px, env(safe-area-inset-right, 0px)) 40px max(20px, env(safe-area-inset-left, 0px)); max-width: 480px; width: 100%; margin: 0 auto; }

/* Receipt preview — looks like the PDF */
.receipt { background: #fff; color: #16211A; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.receipt .rh { background: #0E4D2C; color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.receipt .rh .logo { width: 48px; height: 48px; border-radius: 6px; background: #fff; padding: 5px; display: grid; place-items: center; overflow: hidden; flex: none; }
.receipt .rh .logo img { width: 100%; height: 100%; object-fit: contain; }
.receipt .rno { border-bottom-color: #FCCA1B; }
.receipt .rh strong { font: 700 20px var(--display); display: block; }
.receipt .rh span { font-size: 12px; opacity: .8; }
.receipt .rb { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.receipt .rno { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid #F2C230; padding-bottom: 8px; }
.receipt .rno b { font: 700 22px var(--display); }
.receipt .total { display: flex; justify-content: space-between; align-items: baseline; background: #F4F6F1; padding: 10px 12px; }
.receipt .total b { font: 700 30px var(--display); }
.receipt .kv dt { color: #5E6B62; }

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