/* Court Manager – Apple-style UI. Tokens follow the design canvas. */
:root {
  --bg: #F5F5F7; --surface: #FFFFFF; --grouped: #F2F2F7; --fill: #E3E3E8; --fill2: #EDEDF0; --sep: #E5E5EA; --line: #D2D2D7;
  --text: #1D1D1F; --muted: #6E6E73; --faint: #8A8A8E;
  --accent: #0071E3; --on-accent: #FFFFFF; --link: #0066CC; --accent-soft: #DCEBFC; --accent-soft-text: #003F80; --accent-tint: #F0F6FE;
  --green: #1E7A34; --green-soft: #E8F5EB; --orange: #A64B00; --orange-soft: #FFF1E0; --red: #C4001A; --red-soft: #FFECEE;
  --chart2: #F08A24; --track: #E8E8ED;
  --side: rgba(236, 236, 240, 0.85); --side-active: #DCDCE2; --bar: rgba(249, 249, 251, 0.94);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05); --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.28);
  --r: 18px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000000; --surface: #1C1C1E; --grouped: #000000; --fill: #3A3A3C; --fill2: #2C2C2E; --sep: #38383A; --line: #48484A;
  --text: #F5F5F7; --muted: #A1A1A6; --faint: #8D8D93;
  --accent: #0A84FF; --on-accent: #FFFFFF; --link: #4DA3FF; --accent-soft: #0B3A6E; --accent-soft-text: #CFE5FF; --accent-tint: #0F2742;
  --green: #4ADE80; --green-soft: #12301C; --orange: #FFB340; --orange-soft: #3A2508; --red: #FF7A70; --red-soft: #3A1414;
  --chart2: #FF9F0A; --track: #2C2C2E;
  --side: rgba(22, 22, 24, 0.92); --side-active: #2C2C2E; --bar: rgba(28, 28, 30, 0.94);
  --shadow: 0 0 0 1px rgba(255, 255, 255, 0.04); --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    --bg: #000000; --surface: #1C1C1E; --grouped: #000000; --fill: #3A3A3C; --fill2: #2C2C2E; --sep: #38383A; --line: #48484A;
    --text: #F5F5F7; --muted: #A1A1A6; --faint: #8D8D93;
    --accent: #0A84FF; --on-accent: #FFFFFF; --link: #4DA3FF; --accent-soft: #0B3A6E; --accent-soft-text: #CFE5FF; --accent-tint: #0F2742;
    --green: #4ADE80; --green-soft: #12301C; --orange: #FFB340; --orange-soft: #3A2508; --red: #FF7A70; --red-soft: #3A1414;
    --chart2: #FF9F0A; --track: #2C2C2E;
    --side: rgba(22, 22, 24, 0.92); --side-active: #2C2C2E; --bar: rgba(28, 28, 30, 0.94);
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.04); --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.4; letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 17px; font-weight: 600; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 600; }
.right { text-align: right; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.c-green { color: var(--green); }
.c-orange { color: var(--orange); }
.c-red { color: var(--red); }
.row { display: flex; align-items: center; gap: 12px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.gap16 { gap: 16px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loading { padding: 80px 20px; text-align: center; color: var(--muted); }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Layout ---------- */
.shell { min-height: 100vh; display: flex; }
.side { width: 240px; flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 20px 12px; background: var(--side); border-right: 1px solid var(--sep); display: flex; flex-direction: column; gap: 2px; -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 18px; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--text); color: var(--bg); display: flex; align-items: center; justify-content: center; }
.brand-mark svg.i { stroke: var(--bg); }
.brand b { display: block; font-size: 15px; font-weight: 600; }
.brand span { display: block; font-size: 12px; color: var(--muted); max-width: 160px; }
.nav { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 8px; color: var(--text); font-size: 14px; }
.nav:hover { text-decoration: none; background: color-mix(in srgb, var(--side-active) 60%, transparent); }
.nav svg.i { color: var(--accent); }
.nav[aria-current="page"] { background: var(--side-active); font-weight: 600; }
.side .spacer { flex: 1 1 auto; min-height: 16px; }
.side .who { padding: 10px; font-size: 12px; color: var(--muted); }
.main { flex: 1 1 auto; min-width: 0; padding: 32px clamp(16px, 3vw, 48px) 64px; }
.page { max-width: 1140px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.tabbar { display: none; }

.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

@media (max-width: 860px) {
  .side { display: none; }
  .main { padding: 20px 16px calc(100px + env(safe-area-inset-bottom)); }
  h1 { font-size: 30px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--bar); border-top: 1px solid var(--sep); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
  .tab { min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 10px; font-weight: 500; color: var(--muted); }
  .tab:hover { text-decoration: none; }
  .tab svg.i { width: 24px; height: 24px; }
  .tab[aria-current="page"] { color: var(--accent); font-weight: 600; }
}

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border: 0; border-radius: 980px; background: var(--surface); color: var(--link); font-size: 15px; font-weight: 600; box-shadow: var(--shadow), 0 0 0 1px var(--sep) inset; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.btn-primary svg.i { stroke: var(--on-accent); }
.btn-danger { color: var(--red); }
.btn-block { width: 100%; border-radius: 14px; min-height: 50px; font-size: 17px; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-plain { background: transparent; box-shadow: none; padding: 0 8px; }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--fill2); }

.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--fill); }
.seg button { min-height: 32px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; font-size: 13px; color: var(--text); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); font-weight: 600; }
:root[data-theme="dark"] .seg button[aria-pressed="true"] { background: #636366; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seg button[aria-pressed="true"] { background: #636366; } }
.seg.full { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); width: 100%; }
.seg.full button { min-height: 34px; font-size: 14px; padding: 0 6px; }

.datenav { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border-radius: 980px; padding: 2px; box-shadow: var(--shadow), 0 0 0 1px var(--sep) inset; }
.datenav .label { font-size: 15px; font-weight: 600; padding: 0 6px; white-space: nowrap; }
.datenav input[type="date"] { border: 0; background: transparent; font-size: 15px; font-weight: 600; min-height: 40px; padding: 0 6px; }

input[type="text"], input[type="tel"], input[type="number"], input[type="password"], input[type="date"], input[type="time"], input[type="search"], select, textarea {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px; width: 100%;
}
textarea { padding: 10px 12px; min-height: 72px; resize: vertical; }
.search { position: relative; }
.search svg.i { position: absolute; left: 12px; top: 13px; color: var(--muted); }
.search input { padding-left: 38px; border-radius: 12px; background: var(--fill2); border-color: transparent; }

.switch { width: 51px; height: 31px; border: 0; border-radius: 16px; background: var(--fill); padding: 2px; display: inline-flex; flex: none; transition: background 0.2s; }
.switch::after { content: ''; width: 27px; height: 27px; border-radius: 50%; background: #FFFFFF; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); transition: transform 0.2s; }
.switch[aria-checked="true"] { background: #34C759; }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--r); padding: 20px 22px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-head .sub { font-size: 13px; color: var(--muted); }
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.cols > .wide { flex: 999 1 560px; min-width: 0; }
.cols > .narrow { flex: 1 1 300px; min-width: 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 16px; font-weight: 500; color: var(--muted); }
.kpi .sub { font-size: 13px; color: var(--muted); }
.meter { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; margin-top: 4px; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-radius: 14px; background: var(--orange-soft); color: var(--text); }
.banner b { color: var(--orange); }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.split > div { padding: 4px 18px; border-left: 1px solid var(--sep); display: flex; flex-direction: column; gap: 4px; }
.split > div:first-child { border-left: 0; padding-left: 0; }
.split .label { font-size: 13px; color: var(--muted); }
.split .value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .split > div { border-left: 0; padding: 8px 0; border-top: 1px solid var(--sep); } .split > div:first-child { border-top: 0; } }

/* lists */
.list { display: flex; flex-direction: column; }
.li { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--sep); min-height: 56px; color: var(--text); background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; font-size: 15px; }
.li:first-child { border-top: 0; }
button.li:hover, a.li:hover { text-decoration: none; background: color-mix(in srgb, var(--fill2) 50%, transparent); }
.li .when { width: 70px; flex: none; display: flex; flex-direction: column; }
.li .when b { font-size: 15px; font-weight: 600; }
.li .when span, .li .meta { font-size: 12px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; flex: none; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 980px; white-space: nowrap; }
.pill.paid { color: var(--green); background: var(--green-soft); }
.pill.adv { color: var(--orange); background: var(--orange-soft); }
.pill.due { color: var(--red); background: var(--red-soft); }
.pill.off { color: var(--muted); background: var(--fill2); }
.pill.info { color: var(--accent-soft-text); background: var(--accent-soft); }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border: 0; border-radius: 980px; background: var(--accent-tint); color: var(--link); font-size: 13px; font-weight: 600; }
.chip:hover { text-decoration: none; filter: brightness(0.97); }

/* tables */
.tbox { overflow-x: auto; margin: 0 -4px; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 8px; white-space: nowrap; }
table.t td { padding: 12px 8px; border-top: 1px solid var(--sep); vertical-align: middle; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: color-mix(in srgb, var(--fill2) 50%, transparent); }
table.t .r { text-align: right; white-space: nowrap; }
table.t .nw { white-space: nowrap; }

@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px 16px; border-radius: 16px; }
  .kpi .value { font-size: 22px; }
  .kpi .value small { font-size: 14px; }
  .card { padding: 18px 16px; }
  .gr > label, .gr > .k { width: 92px; }
  .hide-phone { display: none; }
}

/* ---------- Timeline (Today) ---------- */
.tl { display: flex; flex-direction: column; gap: 12px; min-width: 520px; }
.tl-row { display: flex; align-items: center; gap: 14px; }
.tl-name { width: 84px; flex: none; display: flex; flex-direction: column; }
.tl-name b { font-size: 14px; font-weight: 600; }
.tl-name span { font-size: 12px; color: var(--muted); }
.tl-track { position: relative; flex: 1 1 auto; height: 44px; border-radius: 10px; background: var(--track); }
.tl-seg { position: absolute; top: 0; bottom: 0; border: 1px solid var(--surface); border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 600; padding: 0 6px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }
.tl-seg:hover { text-decoration: none; filter: brightness(1.08); }
.tl-now { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--text); pointer-events: none; }
.tl-ticks { position: relative; height: 16px; font-size: 11px; color: var(--muted); margin-left: 98px; }
.tl-ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.tl-ticks span:first-child { transform: none; }
.tl-ticks span:last-child { transform: translateX(-100%); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

/* ---------- Schedule grid ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { min-height: 70px; border: 0; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 6px 2px; }
.day .d1 { font-size: 12px; font-weight: 500; color: var(--muted); }
.day .d2 { font-size: 20px; font-weight: 700; }
.day .d3 { font-size: 11px; color: var(--muted); }
.day[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.day[aria-pressed="true"] .d1, .day[aria-pressed="true"] .d3 { color: var(--on-accent); opacity: 0.9; }
.day.today:not([aria-pressed="true"]) .d2 { color: var(--accent); }
@media (max-width: 520px) { .day .d3 { display: none; } .day { min-height: 56px; } }
.sg-wrap { overflow-x: auto; }
.sg-head, .sg { display: grid; gap: 10px; }
.sg-head { margin-bottom: 8px; }
.sg-head div { display: flex; flex-direction: column; padding: 0 4px; }
.sg-head b { font-size: 16px; font-weight: 600; }
.sg-head span { font-size: 12px; color: var(--muted); }
.sg { position: relative; }
.sg-col { display: grid; }
.sg-hours span { font-size: 11px; color: var(--muted); text-align: right; padding-right: 4px; transform: translateY(-7px); }
.cell { margin: 2px 0; border-radius: 10px; min-width: 0; overflow: hidden; }
.cell.free { border: 1.5px dashed var(--line); background: transparent; color: var(--muted); font-size: 12px; font-weight: 500; display: flex; align-items: center; justify-content: center; gap: 4px; }
.cell.free:hover { border-color: var(--accent); color: var(--link); background: var(--accent-tint); }
.cell.free.past { opacity: 0.45; }
.cell.peak.free { background: color-mix(in srgb, var(--orange-soft) 45%, transparent); }
.cell.booked { border: 0; background: var(--accent-soft); color: var(--accent-soft-text); padding: 5px 10px; display: flex; flex-direction: column; justify-content: flex-start; gap: 1px; text-align: left; }
.cell.booked:hover { filter: brightness(0.97); }
.cell.booked b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell.booked span { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell.booked.due { box-shadow: inset 0 0 0 1.5px var(--red); }
.sg-now { position: absolute; right: 0; height: 2px; background: var(--red); border-radius: 1px; pointer-events: none; z-index: 2; }
.sg-now-label { position: absolute; left: 0; font-size: 11px; font-weight: 700; color: var(--red); background: var(--surface); padding-right: 4px; z-index: 2; }

/* ---------- Bars chart ---------- */
.chart { display: flex; gap: 10px; min-width: 480px; }
.chart .yax { display: flex; flex-direction: column; justify-content: space-between; height: 220px; font-size: 11px; color: var(--muted); text-align: right; width: 40px; flex: none; }
.chart .plot { flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px; }
.chart .area { height: 220px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); align-items: end; border-bottom: 1px solid var(--line); background: linear-gradient(var(--fill2) 1px, transparent 1px) 0 0 / 100% 55px; }
.chart .grp { height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.chart .bar { width: 26px; border-radius: 4px 4px 0 0; position: relative; min-height: 1px; }
.chart .bar em { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 10px; font-weight: 600; color: var(--text); padding-bottom: 3px; white-space: nowrap; }
.chart .xax { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); font-size: 12px; color: var(--muted); text-align: center; }
.hbar { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; }
.hbar .top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.hbar .track { height: 8px; border-radius: 4px; background: var(--fill2); overflow: hidden; }
.hbar .track span { display: block; height: 100%; border-radius: 4px; }
.hours-chart { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; align-items: end; height: 140px; border-bottom: 1px solid var(--line); min-width: 480px; }
.hours-chart div { background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.hours-x { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; font-size: 10px; color: var(--muted); text-align: center; min-width: 480px; padding-top: 4px; }

/* ---------- Sheet (modal) ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, 0.36); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; animation: fade 0.18s ease-out; }
.sheet { width: 100%; max-width: 600px; background: var(--grouped); border-radius: 22px; box-shadow: var(--shadow-lg); overflow: hidden; animation: rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sheet.wide { max-width: 720px; }
.sheet-bar { position: sticky; top: 0; z-index: 1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 10px; background: var(--bar); border-bottom: 1px solid var(--sep); }
.sheet-bar h2 { font-size: 17px; text-align: center; }
.sheet-bar .r { justify-self: end; }
.sheet-body { padding: 18px 18px 24px; display: flex; flex-direction: column; gap: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .backdrop, .sheet { animation: none; } .switch, .switch::after { transition: none; } }
@media (max-width: 640px) { .backdrop { padding: 12px 0 0; align-items: flex-end; } .sheet { border-radius: 18px 18px 0 0; max-height: calc(100vh - 12px); overflow-y: auto; } }

/* grouped form (iOS inset list) */
.group { display: flex; flex-direction: column; gap: 6px; }
.group > .gl { font-size: 13px; color: var(--muted); padding: 0 16px; text-transform: uppercase; letter-spacing: 0.02em; }
.group > .gh { font-size: 13px; color: var(--muted); padding: 0 16px; }
.gbox { background: var(--surface); border-radius: 12px; display: flex; flex-direction: column; }
:root[data-theme="dark"] .gbox { background: var(--surface); }
.gr { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 16px; border-top: 1px solid var(--sep); font-size: 16px; }
.gr:first-child { border-top: 0; }
.gr.pad { padding: 12px 16px; display: block; }
.gr > label, .gr > .k { width: 120px; flex: none; }
.gr input, .gr select { border: 0; background: transparent; padding: 0; min-height: 44px; border-radius: 0; }
.gr input:focus-visible, .gr select:focus-visible { outline-offset: -2px; }
.gr .v { margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; }
.gr input.v { width: 140px; color: var(--link); }
.gr.total { font-weight: 600; font-size: 17px; }
.times { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.time { min-height: 46px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 14px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15; padding: 2px; }
.time small { font-size: 10px; font-weight: 500; color: var(--muted); }
.time.peak small { color: var(--orange); }
.time[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.time[aria-pressed="true"] small { color: var(--on-accent); }
.time:disabled { background: var(--fill2); border-color: var(--fill2); color: var(--faint); cursor: default; }
.time:disabled.booked { text-decoration: line-through; }
.time.past:not(:disabled):not([aria-pressed="true"]) { color: var(--muted); }
.err { color: var(--red); font-size: 13px; padding: 0 16px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 380px; padding: 32px 28px; display: flex; flex-direction: column; gap: 14px; }
.login .brand-mark { width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 4px; }
.login .brand-mark svg.i { width: 30px; height: 30px; }
.login h1 { font-size: 26px; text-align: center; }
.login p { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 32px; }
.check input { width: 18px; height: 18px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: rgba(29, 29, 31, 0.94); color: #FFFFFF; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); }
.toast.error { background: #C4001A; }
:root[data-theme="dark"] .toast:not(.error) { background: #3A3A3C; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .toast:not(.error) { background: #3A3A3C; } }
@media (max-width: 860px) { .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); } }

/* ---------- Public booking page ---------- */
.public { max-width: 560px; margin: 0 auto; padding: 28px 16px 48px; display: flex; flex-direction: column; gap: 20px; }
.pub-head { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 8px 0 4px; }
.pub-head .brand-mark { width: 56px; height: 56px; border-radius: 14px; }
.pub-head .brand-mark svg.i { width: 30px; height: 30px; }
.pub-head h1 { font-size: 30px; }
.pub-head p { margin: 0; }
.dates { display: grid; grid-auto-flow: column; grid-auto-columns: 74px; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scroll-snap-type: x proximity; }
.dates .day { scroll-snap-align: start; }

/* ---------- Badges & small bits ---------- */
.badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--red); color: #FFFFFF; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.tab { position: relative; }
.tab .badge { position: absolute; top: 2px; left: 50%; margin-left: 6px; }
.stock-low { color: var(--red); font-weight: 600; }
.req { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 14px 0; border-top: 1px solid var(--sep); }
.req:first-child { border-top: 0; }
.req .who { flex: 1 1 220px; min-width: 0; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--sep); font-size: 15px; }
.kv:first-of-type { border-top: 0; }
.kv > b { white-space: nowrap; }
.kv > span { min-width: 0; }
.kv.total { font-weight: 700; font-size: 17px; }

@media print {
  .side, .tabbar, .actions, .no-print, .toasts { display: none !important; }
  body { background: #FFFFFF; color: #000000; font-size: 12pt; }
  .main { padding: 0; }
  .card, .kpi { box-shadow: none; border: 1px solid #D2D2D7; break-inside: avoid; }
  .page { max-width: none; gap: 12px; }
}

/* ---------- Closed time ---------- */
.cell.blocked { border: 0; padding: 5px 10px; display: flex; flex-direction: column; justify-content: flex-start; gap: 1px; text-align: left; color: var(--muted); background: repeating-linear-gradient(135deg, var(--fill2) 0 6px, var(--surface) 6px 12px); box-shadow: inset 0 0 0 1px var(--fill); }
.cell.blocked b { display: flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell.blocked b svg.i { width: 14px; height: 14px; }
.cell.blocked span { font-size: 11px; white-space: nowrap; }
.tl-block { position: absolute; top: 0; bottom: 0; border-radius: 10px; color: var(--muted); font-size: 11px; font-weight: 600; padding: 0 6px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; background: repeating-linear-gradient(135deg, var(--fill) 0 5px, var(--track) 5px 10px); }
.legend i.hatch { background: repeating-linear-gradient(135deg, var(--fill) 0 3px, var(--surface) 3px 6px); border: 1px solid var(--fill); }
.pill svg.i { width: 12px; height: 12px; margin-right: 3px; }

/* ---------- Midnight markers ---------- */
.times-mid { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 600; color: var(--orange); padding: 6px 0 2px; }
.times-mid::before, .times-mid::after { content: ''; flex: 1 1 auto; height: 1px; background: var(--orange-soft); min-width: 12px; }
.sg-mid { position: absolute; right: 0; height: 0; border-top: 1.5px dashed var(--orange); pointer-events: none; z-index: 1; }
.sg-mid-label { position: absolute; right: 8px; font-size: 10.5px; font-weight: 600; color: var(--orange); background: var(--surface); padding: 2px 8px; border-radius: 980px; box-shadow: 0 0 0 1px var(--orange-soft); z-index: 1; pointer-events: none; max-width: calc(100% - 80px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
