/* Novel Abacus — design system "Ink & Bead".
   An exercise book on a desk: warm paper, aubergine ink, violet fountain-pen ink for actions, orange beads for what matters.
   Hairlines instead of boxes, few colours at a time, numbers set like a ledger.
   Type: Fraunces (headings & big figures) · Geist (everything else, tabular figures for numbers). */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght,SOFT@9..144,400..700,50&family=Geist:wght@400;500;600;700&display=swap');

:root {
  --bg: #f6f2ea; --surface: #fffdf8; --surface-2: #efe9de; --surface-3: #e6dfd1;
  --ink: #1e1a2c; --ink-2: #4a4458; --muted: #7a7385; --line: #e4dccd; --line-2: #d3c9b6;
  --primary: #4a26a8; --primary-hover: #3b1d8a; --primary-ink: #ffffff; --primary-soft: #ece6f7; --primary-text: #43229a;
  --accent: #e2611d; --accent-hover: #c9520f; --accent-ink: #ffffff; --accent-soft: #fbeadc; --accent-text: #a8450c;
  --ok: #1f7a4d; --ok-soft: #e2f1e8; --warn: #9a5d06; --warn-soft: #f8edd6; --bad: #b42f27; --bad-soft: #f8e3e0; --info: #2d5aa8; --info-soft: #e5ecf7;
  --shadow-1: 0 1px 0 rgba(30, 26, 44, .04);
  --shadow-2: 0 12px 32px -14px rgba(30, 20, 60, .28), 0 2px 6px rgba(30, 26, 44, .06);
  --shadow-3: 0 28px 70px -24px rgba(30, 20, 60, .5);
  --scrim: rgba(24, 18, 36, .42);
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ui: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: var(--ui);
  --r-sm: 6px; --r: 9px; --r-lg: 12px; --r-xl: 18px;
  --tap: 46px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14121b; --surface: #1b1924; --surface-2: #23202e; --surface-3: #2d2a3a;
    --ink: #eeeaf4; --ink-2: #c9c3d6; --muted: #918aa2; --line: #2e2a3b; --line-2: #3c374c;
    --primary: #a48cff; --primary-hover: #b8a4ff; --primary-ink: #15101f; --primary-soft: #2a2442; --primary-text: #bba9ff;
    --accent: #ff8a4c; --accent-hover: #ff9d66; --accent-ink: #1b0e05; --accent-soft: #3a2316; --accent-text: #ffad80;
    --ok: #4fcf8c; --ok-soft: #13291e; --warn: #f0b552; --warn-soft: #2d2412; --bad: #ff7468; --bad-soft: #35181a; --info: #86a8ff; --info-soft: #172038;
    --shadow-1: none; --shadow-2: 0 14px 34px -14px rgba(0, 0, 0, .7); --shadow-3: 0 28px 70px -24px rgba(0, 0, 0, .85);
    --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14121b; --surface: #1b1924; --surface-2: #23202e; --surface-3: #2d2a3a;
  --ink: #eeeaf4; --ink-2: #c9c3d6; --muted: #918aa2; --line: #2e2a3b; --line-2: #3c374c;
  --primary: #a48cff; --primary-hover: #b8a4ff; --primary-ink: #15101f; --primary-soft: #2a2442; --primary-text: #bba9ff;
  --accent: #ff8a4c; --accent-hover: #ff9d66; --accent-ink: #1b0e05; --accent-soft: #3a2316; --accent-text: #ffad80;
  --ok: #4fcf8c; --ok-soft: #13291e; --warn: #f0b552; --warn-soft: #2d2412; --bad: #ff7468; --bad-soft: #35181a; --info: #86a8ff; --info-soft: #172038;
  --shadow-1: none; --shadow-2: 0 14px 34px -14px rgba(0, 0, 0, .7); --shadow-3: 0 28px 70px -24px rgba(0, 0, 0, .85);
  --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--ui); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
h1, h2, h3 { font-family: var(--display); font-optical-sizing: auto; color: var(--ink); line-height: 1.12; margin: 0 0 .4em; font-weight: 600; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: clamp(32px, 5vw, 52px); letter-spacing: -.025em; }
h2 { font-size: clamp(23px, 3vw, 30px); }
h3 { font-size: 19px; }
h4 { font: 600 14.5px/1.3 var(--ui); margin: 0 0 .4em; }
p { margin: 0 0 .8em; }
a { color: var(--primary-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--primary); }
img { max-width: 100%; display: block; }
svg[viewBox="0 0 24 24"] { width: 20px; height: 20px; flex: none; vertical-align: middle; }
code, .mono, .num { font-family: var(--ui); font-variant-numeric: tabular-nums lining-nums; }
code { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--primary); color: var(--primary-ink); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.row.top { align-items: flex-start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 8px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } }
.eyebrow { font: 500 13px/1.2 var(--ui); color: var(--accent-text); }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 20px; }
@media (max-width: 560px) { .wrap { padding: 0 16px; } }

/* ---------------------------------------------------------------- buttons */
.btn { --b: var(--primary); --bh: var(--primary-hover); --bi: var(--primary-ink); --bb: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 17px; border-radius: var(--r);
  border: 1px solid var(--bb); background: var(--b); color: var(--bi); font: 600 14.5px/1 var(--ui); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .08s; -webkit-tap-highlight-color: transparent; user-select: none; }
.btn:hover { background: var(--bh); color: var(--bi); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn.accent { --b: var(--accent); --bh: var(--accent-hover); --bi: var(--accent-ink); }
.btn.ok { --b: var(--ok); --bh: var(--ok); --bi: #fff; }
.btn.danger { --b: transparent; --bh: var(--bad-soft); --bi: var(--bad); --bb: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn.soft { --b: var(--primary-soft); --bh: color-mix(in srgb, var(--primary-soft) 70%, var(--primary) 12%); --bi: var(--primary-text); }
.btn.ghost { --b: var(--surface); --bh: var(--surface-2); --bi: var(--ink); --bb: var(--line-2); }
.btn.plain { --b: transparent; --bh: var(--surface-2); --bi: var(--ink-2); padding: 0 10px; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn.lg { min-height: 50px; padding: 0 22px; font-size: 16px; border-radius: 11px; }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 42px; }
.btn.icon.sm { width: 34px; }
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font: 600 13px/1.3 var(--ui); color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--muted); }
.opt { font-weight: 400; color: var(--muted); }
input, select, textarea { font: 400 15.5px/1.4 var(--ui); color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r); padding: 11px 13px; width: 100%; min-height: var(--tap); transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 92px; resize: vertical; }
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%23857c90' stroke-width='1.8'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent); }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); }
input:disabled { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { width: 19px; height: 19px; min-height: 0; accent-color: var(--primary); margin: 0; flex: none; }
input[type="file"] { padding: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; cursor: pointer; line-height: 1.4; }
.check input { margin-top: 1px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
/* segmented control — underline tabs, not pills */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--surface-2); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button, .seg label { white-space: nowrap; flex: none; border: 0; background: transparent; color: var(--ink-2); font: 500 14px/1 var(--ui); padding: 9px 14px; border-radius: 8px; cursor: pointer; min-height: 36px; display: inline-flex; align-items: center; gap: 6px; }
.seg svg { width: 17px; height: 17px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg button.on, .seg label:has(input:checked) { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(30, 20, 50, .12); }
.seg.block { display: flex; } .seg.block > * { flex: 1; justify-content: center; white-space: normal; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label, .chips button { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 40px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); font: 500 14px/1 var(--ui); cursor: pointer; transition: border-color .12s, background .12s; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips label:has(input:checked), .chips button.on { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); font-weight: 600; }
.chips label:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------------------------------------------------------------- surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.card.tight { padding: 14px 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h3 { margin: 0; }
/* section heading with a rule running to the edge, like a register */
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 30px 0 12px; }
.section-title h3 { margin: 0; white-space: nowrap; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--line); align-self: center; order: 1; }
.section-title > .spacer { display: none; }
.section-title > a, .section-title > button, .section-title > .badge { order: 2; }
.panel { background: var(--surface-2); border-radius: var(--r); padding: 12px 14px; }
.alert { padding: 12px 14px; border-radius: var(--r); background: var(--info-soft); color: var(--ink); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; border-left: 3px solid var(--info); }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--info); }
.alert.ok { background: var(--ok-soft); border-left-color: var(--ok); } .alert.ok svg { color: var(--ok); }
.alert.warn { background: var(--warn-soft); border-left-color: var(--warn); } .alert.warn svg { color: var(--warn); }
.alert.err { background: var(--bad-soft); border-left-color: var(--bad); } .alert.err svg { color: var(--bad); }
/* status labels: a coloured dot and text — no candy-coloured pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 6px; font: 500 12.5px/1.45 var(--ui); color: var(--ink-2); white-space: nowrap; border: 1px solid var(--line); background: transparent; }
.pill svg { width: 13px; height: 13px; }
.pill.ok, .pill.warn, .pill.bad, .pill.info, .pill.violet, .pill.orange { border-color: transparent; padding-left: 2px; padding-right: 2px; font-weight: 600; }
.pill.ok::before, .pill.warn::before, .pill.bad::before, .pill.info::before, .pill.violet::before, .pill.orange::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); } .pill.info { color: var(--info); } .pill.violet { color: var(--primary-text); } .pill.orange { color: var(--accent-text); }
.pill.orange svg, .pill.violet svg { display: none; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.kv { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 9px 18px; margin: 0; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 40px 18px; color: var(--muted); border: 1px dashed var(--line-2); border-radius: var(--r-lg); }
.empty svg { width: 28px; height: 28px; color: var(--line-2); margin: 0 auto 10px; display: block; }
.empty b { display: block; color: var(--ink); font: 600 18px var(--display); margin-bottom: 4px; }
.empty p { margin: 0 auto; max-width: 420px; }

/* figures strip — big numbers separated by hairlines, like a ledger summary */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 16px 18px 16px 0; min-width: 0; position: relative; display: block; text-decoration: none; color: inherit; }
.stat + .stat { padding-left: 18px; border-left: 1px solid var(--line); }
.stat .k { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .k svg { display: none; }
.stat .v { font: 600 clamp(26px, 3.4vw, 36px)/1.05 var(--display); font-variant-numeric: lining-nums tabular-nums; letter-spacing: -.02em; margin-top: 6px; color: var(--ink); }
.stat .s { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.stat.hero .v { color: var(--primary-text); }
a.stat:hover .v { color: var(--primary); }
a.stat:hover .k { color: var(--ink-2); }
.up { color: var(--ok); } .down { color: var(--bad); }
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat, .stat + .stat { padding: 14px 12px 14px 0; border-left: 0; }
  .stat:nth-child(even) { padding-left: 14px; border-left: 1px solid var(--line); }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* list rows */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.list > .li { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--line); min-height: 60px; text-decoration: none; color: inherit; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; font: inherit; }
.list > .li:first-child { border-top: 0; }
.list > a.li, .list > button.li, .list > label.li { cursor: pointer; transition: background .12s; }
.list > a.li:hover, .list > button.li:hover, .list > label.li:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.li .main { flex: 1; min-width: 0; }
.li .t { font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .m { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .r { text-align: right; flex: none; display: flex; align-items: center; gap: 8px; }
.li .chev { width: 16px; height: 16px; color: var(--line-2); flex: none; }
.li > svg { color: var(--muted); }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font: 600 14px/1 var(--ui); letter-spacing: .02em; color: var(--ink-2); background: var(--surface-2); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar svg { width: 18px; height: 18px; }
.avatar.lg { width: 68px; height: 68px; font: 600 24px/1 var(--display); }
/* a count in the "needs attention" list */
.count { min-width: 38px; height: 38px; flex: none; display: grid; place-items: center; font: 600 22px/1 var(--display); color: var(--accent-text); font-variant-numeric: lining-nums; }

/* tables (wide screens, reports) */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font: 500 12.5px/1.2 var(--ui); color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line-2); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.t .r, table.t td.num { text-align: right; }
table.t tfoot td { font-weight: 700; background: var(--surface-2); }

/* ---------------------------------------------------------------- bead track: the 8 levels on an abacus rod */
.beads { display: flex; align-items: center; position: relative; padding: 6px 2px; }
.beads::before { content: ''; position: absolute; left: 10px; right: 10px; top: 50%; height: 2px; margin-top: -1px; background: var(--line-2); }
.beads .b { position: relative; flex: 1; display: flex; justify-content: center; }
.beads .b i { width: 26px; height: 15px; border-radius: 50%; background: var(--surface); border: 1.5px solid var(--line-2); display: block; transition: transform .2s; }
.beads .b.done i { background: var(--primary); border-color: var(--primary); }
.beads .b.ms.done i { background: var(--accent); border-color: var(--accent); }
.beads .b.cur i { background: var(--primary-soft); border-color: var(--primary); border-width: 2px; transform: scale(1.18); }
.beads .b span { position: absolute; top: 100%; margin-top: 5px; font: 500 11px/1 var(--ui); color: var(--muted); font-variant-numeric: tabular-nums; }
.beads .b.ms span { color: var(--accent-text); font-weight: 600; }
.beads .b.cur span { color: var(--primary-text); font-weight: 700; }
.beads.lab { padding-bottom: 20px; }

/* ---------------------------------------------------------------- overlays */
.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 80; animation: fade .18s ease-out; }
.sheet { position: fixed; z-index: 81; background: var(--surface); box-shadow: var(--shadow-3); display: flex; flex-direction: column; max-height: 100%;
  right: 0; top: 0; bottom: 0; width: min(540px, 100%); animation: slideL .22s cubic-bezier(.2, .8, .2, 1); }
.sheet-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 14px 22px; border-bottom: 1px solid var(--line); }
.sheet-h h2 { margin: 0; font-size: 22px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-b { padding: 20px 22px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; }
.sheet-f { padding: 14px 22px calc(14px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; background: var(--surface); }
.sheet-f .btn { flex: 1; }
@media (max-width: 720px) {
  .sheet { top: auto; left: 0; width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; animation: slideU .25s cubic-bezier(.2, .8, .2, 1); }
  .sheet::before { content: ''; width: 36px; height: 4px; border-radius: 4px; background: var(--line-2); position: absolute; top: 7px; left: 50%; margin-left: -18px; }
  .sheet-h, .sheet-b, .sheet-f { padding-left: 18px; padding-right: 18px; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes slideL { from { transform: translateX(40px); opacity: 0; } }
@keyframes slideU { from { transform: translateY(60px); opacity: 0; } }
#toasts { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 32px)); pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 10px; font-size: 14.5px; font-weight: 500; box-shadow: var(--shadow-3); display: flex; gap: 10px; align-items: center; animation: slideU .2s ease-out; pointer-events: auto; }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.ok svg { color: #6fdc9f; } .toast.err svg { color: #ff8f86; } .toast.warn svg { color: #f3c26b; }
body.has-tabbar #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
body:has(.sheet) #toasts { top: calc(14px + env(safe-area-inset-top)); bottom: auto; }

/* ---------------------------------------------------------------- brand */
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand img { width: 36px; height: 36px; border-radius: 8px; flex: none; }
.brand b { font: 600 17px/1.05 var(--display); display: block; white-space: nowrap; }
.brand span { font-size: 12px; color: var(--muted); display: block; white-space: nowrap; margin-top: 2px; }
.theme-btn svg { width: 19px; height: 19px; }

/* ---------------------------------------------------------------- app shell */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--bg); border-right: 1px solid var(--line); }
.side .brand { padding: 20px 20px 16px; }
.side-scope { margin: 0 14px 8px; }
.side-scope select { min-height: 38px; padding-top: 7px; padding-bottom: 7px; font-size: 14px; font-weight: 600; background-color: var(--surface); }
.nav { flex: 1; overflow: auto; padding: 4px 10px 14px; }
.nav .grp { font: 500 12px/1 var(--ui); color: var(--muted); padding: 18px 12px 7px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 0 12px; min-height: 37px; border-radius: 7px; color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 14.5px; position: relative; }
.nav a svg { width: 18px; height: 18px; color: var(--muted); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.nav a.on::before { content: ''; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav a.on svg { color: var(--primary-text); }
.nav a .badge { margin-left: auto; }
.badge { min-width: 19px; height: 19px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font: 700 11px/19px var(--ui); font-variant-numeric: tabular-nums; text-align: center; }
.side-foot { border-top: 1px solid var(--line); padding: 10px 10px 10px 14px; display: flex; align-items: center; gap: 8px; }
.side-foot .who { flex: 1; min-width: 0; font-size: 13px; line-height: 1.25; }
.side-foot .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.side-foot .who span { color: var(--muted); }
.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 14px 32px; min-height: 66px; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar h1 { font-size: 24px; margin: 0; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .back { display: none; }
.page { padding: 6px 32px 56px; max-width: 1220px; }
.page-h { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 4px 0 20px; }
.page-h .sub { color: var(--muted); margin: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .search { flex: 1; min-width: 200px; position: relative; }
.toolbar .search input { padding-left: 40px; }
.toolbar .search svg { position: absolute; left: 13px; top: 50%; margin-top: -9px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.toolbar select { width: auto; min-width: 150px; }
.tabbar { display: none; }
.m-only { display: none; }

@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar { padding: 10px 16px; min-height: 58px; }
  .topbar h1 { font-size: 21px; }
  .topbar .back { display: inline-flex; }
  .page { padding: 4px 16px calc(100px + env(safe-area-inset-bottom)); }
  .m-only { display: initial; }
  .d-only { display: none !important; }
  body.has-tabbar .tabbar { display: grid; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; grid-auto-flow: column; grid-auto-columns: 1fr;
    background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a, .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 54px; color: var(--muted); text-decoration: none; font: 500 11px/1 var(--ui); border: 0; background: none; position: relative; cursor: pointer; }
  .tabbar svg { width: 22px; height: 22px; }
  .tabbar .on { color: var(--ink); font-weight: 600; }
  .tabbar .on svg { color: var(--primary-text); stroke-width: 2.1; }
  .tabbar .on::before { content: ''; position: absolute; top: -4px; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: var(--primary); }
  .tabbar .badge { position: absolute; top: 5px; left: 50%; margin-left: 5px; height: 16px; min-width: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }
}
@media (min-width: 961px) { .tabbar { display: none !important; } }

/* "More" menu on phones */
.menu-grid { display: grid; grid-template-columns: 1fr; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.menu-grid a { display: flex; align-items: center; gap: 12px; padding: 0 16px; min-height: 52px; color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 500; border-top: 1px solid var(--line); position: relative; }
.menu-grid a:first-child { border-top: 0; }
.menu-grid a svg { width: 20px; height: 20px; color: var(--muted); }
.menu-grid a .badge { margin-left: auto; }

/* quick actions — plain labelled buttons */
.actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 8px; }
.action { display: flex; align-items: center; gap: 11px; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font: 600 14.5px/1.25 var(--ui); cursor: pointer; text-align: left; transition: border-color .15s, background .15s; }
.action:hover { border-color: var(--primary); color: var(--ink); }
.action .ic { flex: none; color: var(--primary-text); display: grid; place-items: center; }
.action .ic svg { width: 21px; height: 21px; }
.action.orange { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.action.orange .ic, .action.orange small { color: var(--accent-ink); }
.action.orange:hover { background: var(--accent-hover); color: var(--accent-ink); }
.action small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
@media (max-width: 560px) { .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } .action { padding: 11px 12px; } }

/* attendance marking */
.att-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.att { display: flex; align-items: center; gap: 12px; padding: 9px 12px 9px 14px; border-top: 1px solid var(--line); transition: background .12s; }
.att:first-child { border-top: 0; }
.att .main { flex: 1; min-width: 0; }
.att .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att .m { font-size: 12.5px; color: var(--muted); }
.att .pa { display: flex; gap: 6px; }
.att .pa button { width: 52px; height: 44px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); font: 600 15px/1 var(--ui); color: var(--muted); cursor: pointer; transition: all .12s; }
.att.P { background: color-mix(in srgb, var(--ok-soft) 60%, var(--surface)); }
.att.A { background: color-mix(in srgb, var(--bad-soft) 60%, var(--surface)); }
.att.P .pa .p { background: var(--ok); border-color: var(--ok); color: #fff; }
.att.A .pa .a { background: var(--bad); border-color: var(--bad); color: #fff; }
.sticky-foot { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 35%); display: flex; gap: 10px; align-items: center; }
@media (max-width: 960px) { .sticky-foot { bottom: calc(62px + env(safe-area-inset-bottom)); } }

/* level timeline */
.timeline { display: flex; flex-direction: column; }
.tl { display: grid; grid-template-columns: 28px 1fr; gap: 12px; position: relative; padding-bottom: 18px; }
.tl::before { content: ''; position: absolute; left: 13px; top: 28px; bottom: 2px; width: 1px; background: var(--line-2); }
.tl:last-child::before { display: none; }
.tl .mk { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--muted); border: 1px solid var(--line-2); font: 600 13px/1 var(--display); }
.tl.done .mk { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.tl.ms.done .mk { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tl.cur .mk { border: 2px solid var(--primary); color: var(--primary-text); }

/* charts */
.chart { position: relative; }
.chart-plot svg { display: block; overflow: visible; }
.chart .grid-l { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 500 11px var(--ui); }
.chart .barfill { fill: var(--primary); opacity: .82; transition: opacity .12s, fill .12s; }
.chart .bar.on .barfill, .chart .bar:hover .barfill { fill: var(--accent); opacity: 1; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); border-radius: 8px; padding: 7px 10px; font-size: 12.5px; white-space: nowrap; box-shadow: var(--shadow-2); z-index: 3; }
.chart-tip b { display: block; font: 600 15px var(--display); }
.chart-empty { color: var(--muted); padding: 30px 0; text-align: center; font-size: 14px; }
details.chart-data summary { cursor: pointer; font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* UPI pay box */
.pay { display: grid; grid-template-columns: 160px 1fr; gap: 18px; align-items: center; }
.pay .qr { background: #fff; padding: 10px; border-radius: 10px; border: 1px solid var(--line); }
.pay .qr img { width: 100%; image-rendering: pixelated; }
@media (max-width: 560px) { .pay { grid-template-columns: 1fr; } .pay .qr { max-width: 190px; margin: 0 auto; order: 2; } }

/* ---------------------------------------------------------------- login */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-art { position: relative; overflow: hidden; background: #17132a; color: #fff; padding: 44px; display: flex; flex-direction: column; justify-content: space-between; }
/* faint ruled lines, like an exercise book */
.auth-art::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(transparent 0 31px, rgba(255, 255, 255, .05) 31px 32px); pointer-events: none; }
.auth-art::before { content: ''; position: absolute; top: 0; bottom: 0; left: 72px; width: 1px; background: rgba(226, 97, 29, .35); }
.auth-art > * { position: relative; z-index: 1; }
.auth-art .logo { width: 150px; height: 150px; margin: 34px auto; filter: drop-shadow(0 24px 40px rgba(0, 0, 0, .55)); }
.auth-art blockquote { margin: 0; font: 500 clamp(24px, 2.6vw, 34px)/1.2 var(--display); letter-spacing: -.01em; max-width: 520px; color: #fff; }
.auth-art blockquote em { font-style: italic; color: #ffb085; }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 410px; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 20px 20px 24px; }
  .auth-art::before { left: 40px; }
  .auth-art .logo { display: none; }
  .auth-art blockquote { margin-top: 18px; }
  .auth-art blockquote { font-size: 22px; }
  .auth-art .foot { display: none; }
}

@media print { .no-print { display: none !important; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
/* a fixed row of three figures (e.g. inside a card) */
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats.three .stat { border-top: 0; padding: 12px 10px 12px 0; }
.stats.three .stat + .stat { border-left: 1px solid var(--line); padding-left: 14px; }
