:root {
  color-scheme: light;
  --bg: #f4f6f5; --card: #ffffff; --ink: #111827; --ink2: #4b5563; --muted: #6b7280; --line: #e5e7eb;
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #ccfbf1; --accent: #f59e0b;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --pos: #2a78d6; --neg: #e34948; --mid: #f0efec;
  --radius: 16px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0f1312; --card: #1a1f1e; --ink: #f3f4f6; --ink2: #c7cbd1; --muted: #9ca3af; --line: #2b3331;
    --brand: #14b8a6; --brand-ink: #04211e; --brand-soft: #134e4a; --accent: #fbbf24;
    --ok: #4ade80; --ok-soft: #14361f; --warn: #fbbf24; --warn-soft: #3b2d0c; --bad: #f87171; --bad-soft: #3d1717;
    --pos: #3987e5; --neg: #e66767; --mid: #383835;
    --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; }
h1, h2, h3 { margin: 0; }
.splash { display: grid; place-items: center; height: 80vh; font-size: 22px; color: var(--muted); }

/* layout */
header.top { position: sticky; top: 0; z-index: 5; background: var(--brand); color: var(--brand-ink); padding: calc(12px + env(safe-area-inset-top)) 16px 12px; display: flex; align-items: center; gap: 10px; }
header.top h1 { font-size: 20px; flex: 1; }
header.top .who { display: flex; align-items: center; gap: 8px; font-weight: 600; background: rgba(255,255,255,.15); border: 0; border-radius: 99px; padding: 4px 10px 4px 4px; color: inherit; }
main { max-width: 640px; margin: 0 auto; padding: 14px 14px 24px; }
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { flex: 1; border: 0; background: none; padding: 8px 0 10px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); }
nav.tabs button .ic { font-size: 22px; line-height: 1; }
nav.tabs button.on { color: var(--brand); font-weight: 700; }
.fab { position: fixed; right: 18px; bottom: calc(88px + env(safe-area-inset-bottom)); z-index: 7; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: #1f1300; font-size: 30px; box-shadow: 0 6px 18px rgba(0,0,0,.25); }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 17px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.card h2 .sub { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--muted); }
.hero { background: linear-gradient(135deg, var(--brand), #115e59); color: #fff; border: 0; }
.hero .muted, .hero .small { color: rgba(255,255,255,.85); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }
.center { text-align: center; }
.mt { margin-top: 10px; }
.mb { margin-bottom: 10px; }
.callout { border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 8px 0; }
.callout.info { background: var(--brand-soft); }
.callout.warn { background: var(--warn-soft); }
.callout.bad { background: var(--bad-soft); }
.callout.ok { background: var(--ok-soft); }

/* buttons */
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; background: var(--line); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.accent { background: var(--accent); color: #1f1300; }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 11px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.actions.three { grid-template-columns: 1fr 1fr 1fr; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.quick button { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 6px; font-size: 13px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.quick button .ic { font-size: 22px; }

/* avatars & chips */
.av { --c: #888; width: 30px; height: 30px; border-radius: 50%; background: var(--c); color: #fff; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; text-shadow: 0 1px 1px rgba(0,0,0,.25); }
.av.lg { width: 44px; height: 44px; font-size: 18px; }
.av.xs { width: 22px; height: 22px; font-size: 11px; }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 3px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); font-size: 14px; font-weight: 600; }
.pill.me { outline: 2px solid var(--accent); }
.pill.off { opacity: .6; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 2px solid var(--line); background: var(--card); border-radius: 99px; padding: 8px 14px 8px 8px; display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 15px; min-height: 44px; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); }
.chip.on.rider { border-color: var(--muted); background: var(--bg); }
.chip .ck { font-size: 14px; margin-left: 2px; }
.chip.plain { padding: 8px 14px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 8px 6px; font-size: 14px; font-weight: 600; color: var(--ink2); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; border-radius: 99px; padding: 2px 8px; background: var(--bg); color: var(--ink2); border: 1px solid var(--line); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--brand-soft); color: var(--ink); border-color: transparent; }

/* week grid */
.week { display: grid; grid-template-columns: 54px 1fr 1fr; gap: 6px; }
.week .h { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.week .d { font-size: 13px; font-weight: 700; display: flex; flex-direction: column; justify-content: center; }
.week .d small { font-weight: 500; color: var(--muted); }
.week .d.today { color: var(--brand); }
.cell { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 6px; min-height: 44px; display: flex; flex-wrap: wrap; align-items: center; gap: 3px; text-align: left; position: relative; }
.cell.past { opacity: .75; }
.cell.mod { border-color: var(--accent); }
.cell.off { justify-content: center; font-size: 12px; color: var(--muted); background: transparent; border-style: dashed; }
.cell.cancel { justify-content: center; font-size: 12px; color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.cell.mine { box-shadow: inset 0 0 0 2px var(--accent); }
.cell .flag { position: absolute; top: -6px; right: -4px; font-size: 12px; }

/* planning list */
.day { margin-bottom: 14px; }
.day > .dh { font-weight: 800; font-size: 15px; margin: 0 2px 6px; display: flex; align-items: center; gap: 8px; }
.day > .dh.today { color: var(--brand); }
.slot { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 6px; display: block; width: 100%; text-align: left; }
.slot.off { background: transparent; border-style: dashed; color: var(--muted); }
.slot.cancel { background: var(--bad-soft); border-color: transparent; }
.slot.mine { border-left: 5px solid var(--accent); }
.slot .top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 700; }
.slot .top .t { color: var(--muted); font-weight: 600; font-size: 14px; }
.slot .riders { margin-top: 6px; font-size: 13px; color: var(--muted); }
.weeknav { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.weeknav .lbl { flex: 1; text-align: center; font-weight: 800; }
.weeknav button { border: 1px solid var(--line); background: var(--card); border-radius: 12px; width: 44px; height: 44px; font-size: 18px; }

/* stats */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi .v { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 13px; color: var(--muted); }
.person { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); }
.person:first-of-type { border-top: 0; padding-top: 2px; }
.nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; }
.nums div { background: var(--bg); border-radius: 10px; padding: 6px 8px; }
.nums b { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }
.nums span { font-size: 11px; color: var(--muted); }
.eq { position: relative; height: 10px; background: var(--mid); border-radius: 99px; margin: 8px 0 2px; }
.eq .bar { position: absolute; top: 0; bottom: 0; border-radius: 99px; }
.eq .bar.pos { background: var(--pos); }
.eq .bar.neg { background: var(--neg); }
.eq .zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--ink2); }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 22px; border-bottom: 1px solid var(--line); }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; position: relative; }
.bars .b .fill { width: 100%; max-width: 42px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .b .val { font-size: 11px; font-weight: 700; color: var(--ink2); margin-bottom: 3px; white-space: nowrap; }
.bars .b.on .fill { filter: brightness(1.15); outline: 2px solid var(--accent); }
.bars-x { display: flex; gap: 8px; }
.bars-x span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); padding-top: 4px; }
.progress { height: 12px; border-radius: 99px; background: rgba(255,255,255,.25); overflow: hidden; margin: 8px 0 4px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; }
.card .progress { background: var(--bg); }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { padding: 7px 4px; border-bottom: 1px solid var(--line); text-align: right; font-variant-numeric: tabular-nums; }
table.t th:first-child, table.t td:first-child { text-align: left; }
table.t th { font-size: 12px; color: var(--muted); font-weight: 700; }

/* lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 10px; padding: 12px 2px; border-top: 1px solid var(--line); background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%; }
.li:first-child { border-top: 0; }
.li .ic { font-size: 22px; width: 30px; text-align: center; }
.li .chev { margin-left: auto; color: var(--muted); }
.log { padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.log:first-child { border-top: 0; }
.log .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* sheet */
#sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); animation: fade .15s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92vh; overflow: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; animation: up .2s ease-out; }
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 10px; }
.sheet h3 { font-size: 19px; margin-bottom: 4px; }
.sheet .lab { font-size: 13px; font-weight: 700; color: var(--ink2); margin: 14px 0 6px; display: flex; align-items: center; gap: 6px; }
.sheet .lab .right { font-weight: 600; }
.sheet .foot { position: sticky; bottom: calc(-18px - env(safe-area-inset-bottom)); background: var(--card); padding: 12px 0 4px; margin-top: 10px; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.pinpad button { height: 58px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); font-size: 24px; font-weight: 700; }
.dots { display: flex; justify-content: center; gap: 14px; margin: 14px 0 4px; }
.dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand); }
.dots span.f { background: var(--brand); }
.login { max-width: 460px; margin: 0 auto; padding: 40px 18px; }
.login h1 { font-size: 30px; margin-bottom: 4px; }
.login .who-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.login .who-grid button { border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 16px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 30; background: #111827; color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: 90vw; box-shadow: 0 6px 18px rgba(0,0,0,.3); }
#toast.err { background: #b91c1c; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.hide { display: none !important; }
.hero .pill { background: rgba(255,255,255,.95); color: #111827; border-color: transparent; }
.quick { grid-template-columns: repeat(4, 1fr); }
.cell .tm { font-size: 10px; font-weight: 700; color: var(--warn); width: 100%; }
.cal { display: grid; grid-template-columns: 38px repeat(7, 1fr); gap: 4px; }
.cal .ch { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); }
.cal .wk { border: 1px solid var(--line); background: var(--card); border-radius: 10px; font-size: 11px; font-weight: 800; color: var(--brand); padding: 0; }
.cal .dc { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--line); background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; position: relative; padding: 0; line-height: 1.1; }
.cal .dc small { font-size: 10px; }
.cal .dc.on, .lg.on { background: var(--ok-soft); border-color: var(--ok); }
.cal .dc.off, .lg.off { background: repeating-linear-gradient(45deg, var(--bg), var(--bg) 4px, var(--line) 4px, var(--line) 8px); color: var(--muted); }
.cal .dc.none { color: var(--muted); }
.cal .dc.abs, .lg.abs { background: var(--warn-soft); border-color: var(--accent); }
.cal .dc.out { opacity: .4; }
.cal .dc.past { opacity: .35; }
.cal .dc.today { outline: 2px solid var(--brand); outline-offset: 1px; }
.cal .dc .mk { position: absolute; top: 1px; right: 4px; font-size: 8px; color: var(--ink2); }
.legend { margin-top: 8px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lg { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--line); vertical-align: middle; }
.day > .dh .btn { font-weight: 600; }
