/* Driver Portal styles. Mobile first; big touch targets; follows the device's light/dark setting. */

:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #5f6b7d;
  --line: #e1e5eb;
  --brand: #0e1a2b;
  --brand-muted: #a9b6c8;
  --accent: #f5a524;
  --primary: #0e1a2b;
  --primary-ink: #ffffff;
  --link: #1d5bd6;
  --focus: #2f6df6;
  --ok: #157a45;   --ok-bg: #e5f5ec;
  --warn: #9a5200; --warn-bg: #fff2dc;
  --bad: #b42318;  --bad-bg: #fdecea;
  --todo-bg: #fff6e5;
  --info-bg: #eef3fb;
  --ok-solid: #16834a;
  --bad-solid: #c8322b;
  --na-solid: #475467;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --topbar-h: 58px;
  --grid: #d9dee5;        /* spreadsheet cell lines */
  --sheet-head: #f1f3f6;  /* spreadsheet header row and row numbers */
  --cell-active: #e8f0fe;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b1220;
    --surface: #131c2c;
    --surface-2: #101827;
    --ink: #e8edf5;
    --ink-2: #c3ccda;
    --muted: #93a0b4;
    --line: #253149;
    --brand: #070d18;
    --primary: #f5a524;
    --primary-ink: #1a1200;
    --link: #8ab4ff;
    --focus: #8ab4ff;
    --ok: #4cd08a;   --ok-bg: #0f2a1d;
    --warn: #f3b04f; --warn-bg: #2e2310;
    --bad: #ff7a70;  --bad-bg: #351816;
    --todo-bg: #2b220f;
    --info-bg: #15213a;
    --shadow: none;
    --grid: #2a3650;
    --sheet-head: #182238;
    --cell-active: #1b2c4d;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
a { color: var(--link); }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.icon { width: 1.15em; height: 1.15em; flex: none; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.boot, .loading { padding: 3rem 1rem; text-align: center; color: var(--muted); }

/* ---------- top bar and navigation ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.25rem;
  background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; }
.brand .icon { color: var(--accent); width: 1.6em; height: 1.6em; }
.tabs { display: flex; gap: .25rem; margin-left: 1.25rem; }
.tabs a {
  display: flex; align-items: center; gap: .45rem;
  padding: .45rem .85rem; border-radius: 9px;
  color: var(--brand-muted); text-decoration: none; font-weight: 600;
}
.tabs a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.tabs a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .14); }
.who { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.who-name { color: var(--brand-muted); font-size: .9rem; }
.btn-signout {
  display: flex; align-items: center; gap: .4rem;
  padding: .4rem .75rem; border-radius: 9px; cursor: pointer;
  background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .25); font-size: .9rem;
}
.btn-signout:hover { background: rgba(255, 255, 255, .08); }

.brand, .tabs a, .btn-signout, .who-name { white-space: nowrap; }
@media (max-width: 1100px) { .who-name { display: none; } }
@media (min-width: 721px) and (max-width: 960px) {
  .tabs { margin-left: .5rem; }
  .tabs a { padding: .45rem .6rem; }
  .tabs a .icon { display: none; }
}
/* the admin bar has seven tabs: drop icons sooner, then the brand name */
@media (min-width: 721px) and (max-width: 1340px) {
  .tabs[data-count="6"], .tabs[data-count="7"] { margin-left: .5rem; gap: .1rem; }
  .tabs[data-count="6"] a, .tabs[data-count="7"] a { padding: .45rem .55rem; }
  .tabs[data-count="6"] a .icon, .tabs[data-count="7"] a .icon { display: none; }
}
@media (min-width: 721px) and (max-width: 1000px) {
  .topbar:has(.tabs[data-count="6"]) .brand > span:not(.brand-tag),
  .topbar:has(.tabs[data-count="7"]) .brand > span:not(.brand-tag) { display: none; }
}
@media (min-width: 721px) and (max-width: 860px) {
  .tabs[data-count="7"] a { padding: .45rem .4rem; font-size: .9rem; }
}

.main { max-width: 860px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.main:focus { outline: none; }

@media (max-width: 720px) {
  .topbar { padding: 0 1rem; }
  .who-name { display: none; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; margin: 0;
    justify-content: space-around;
    padding: .3rem .5rem calc(.3rem + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabs a { flex-direction: column; gap: .1rem; padding: .35rem .5rem; min-width: 64px; font-size: .75rem; color: var(--muted); }
  .tabs a .icon { width: 1.5em; height: 1.5em; }
  .tabs a:hover { background: transparent; color: var(--ink); }
  .tabs a[aria-current="page"] { background: transparent; color: var(--ink); }
  .tabs a[aria-current="page"] .icon { color: var(--accent); }
  .main { padding: 1.1rem 1rem calc(6rem + env(safe-area-inset-bottom)); }
}

/* ---------- page structure ---------- */

.page-head { margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.65rem; margin: .15rem 0 .2rem; }
.head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-weight: 600; font-size: .9rem; }
.section-title { font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1.75rem 0 .65rem; }
.back { display: inline-flex; align-items: center; gap: .2rem; margin-bottom: .75rem; text-decoration: none; font-weight: 600; color: var(--muted); }
.back:hover { color: var(--ink); }
.list { display: grid; gap: .65rem; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}
.card-title { font-size: 1.05rem; margin-bottom: .6rem; }
.empty {
  padding: 1.5rem; text-align: center; color: var(--muted);
  border: 1.5px dashed var(--line); border-radius: var(--radius);
}
.empty.tone-bad { color: var(--ink); border-color: var(--bad); background: var(--bad-bg); border-style: solid; display: grid; gap: .5rem; justify-items: center; }

/* ---------- chips ---------- */

.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .55rem; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.chip-today { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.chip-upcoming { background: var(--info-bg); color: var(--link); border-color: transparent; }
.chip-past { color: var(--muted); }
.chip-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.chip-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip-bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.chip-delivery { background: var(--info-bg); color: var(--link); border-color: transparent; }
.chip-pickup { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip-school { background: #0f4a37; color: #fff; border-color: transparent; }
.chip-plain { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 600; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 44px; padding: .55rem 1rem; border-radius: 10px; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.btn-primary:hover { border-color: transparent; filter: brightness(1.12); }
.btn-ghost { background: transparent; }
.btn-small { min-height: 38px; padding: .35rem .75rem; font-size: .9rem; }
.btn-lg { min-height: 52px; padding: .75rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: progress; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- status cards ---------- */

.status-card {
  display: flex; align-items: center; gap: .9rem;
  padding: 1rem 1.1rem; border-radius: var(--radius);
  border: 1px solid transparent; text-decoration: none; color: var(--ink);
  margin-bottom: .5rem;
}
.status-card > .icon { margin-left: auto; color: var(--muted); }
.status-icon {
  width: 2.6rem; height: 2.6rem; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff;
}
.status-icon .icon { width: 1.4rem; height: 1.4rem; }
.status-text { display: grid; gap: .1rem; min-width: 0; flex: 1 1 0; }
.status-text strong { font-size: 1.05rem; }
.status-text span { color: var(--ink-2); font-size: .92rem; }
.status-card .btn { margin-left: auto; }
.tone-todo { background: var(--todo-bg); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.tone-todo .status-icon { background: var(--accent); color: #1a1200; }
.tone-ok { background: var(--ok-bg); }
.tone-ok .status-icon { background: var(--ok-solid); }
.tone-warn { background: var(--warn-bg); }
.tone-warn .status-icon { background: var(--accent); color: #1a1200; }
.tone-bad { background: var(--bad-bg); }
.tone-bad .status-icon { background: var(--bad-solid); }
.tone-plain { background: var(--surface); border-color: var(--line); box-shadow: var(--shadow); }
.tone-plain .status-icon { background: var(--primary); color: var(--primary-ink); }

/* post-trip */
.child-check { border: 2px solid var(--accent); background: var(--todo-bg); }
.child-check legend { display: flex; align-items: center; gap: .45rem; font-size: 1.2rem; }
.child-check legend .icon { width: 1.4em; height: 1.4em; color: var(--warn); }
.child-check > p { margin-bottom: .25rem; }
.check-big { padding: .8rem .9rem; margin: .75rem 0; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 1.02rem; }
.check-big input { width: 1.6rem; height: 1.6rem; }
.field-time { max-width: 12rem; margin-bottom: 0; }
#fuel-field { margin-top: .9rem; }
.run-list { margin-bottom: .5rem; }
.run-row { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
.run-row:last-child { border-bottom: 0; }
.run-row .chip .icon { width: 1em; height: 1em; }
.child-done .icon { width: 1.4em; height: 1.4em; }
.alert-card { margin-bottom: 1rem; border-color: var(--bad-solid); }

@media (max-width: 520px) {
  .status-card { flex-wrap: wrap; }
  .status-card .btn { margin-left: 0; width: 100%; }
}

.verdict {
  display: flex; align-items: center; gap: .6rem;
  padding: .85rem 1.1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 1.05rem;
}
.verdict .icon { width: 1.4em; height: 1.4em; }
.verdict.tone-ok { color: var(--ok); }
.verdict.tone-warn { color: var(--warn); }
.verdict.tone-bad { color: var(--bad); }

.flash {
  display: flex; align-items: center; gap: .55rem;
  padding: .75rem 1rem; margin-bottom: 1rem; border-radius: var(--radius);
  background: var(--ok-bg); color: var(--ok); font-weight: 600;
}

.callout {
  padding: .9rem 1.1rem; margin: 0 0 1rem; border-radius: var(--radius);
  background: var(--info-bg); border-left: 4px solid var(--link);
  display: grid; gap: .25rem;
}
.callout-quiet { border-left-color: var(--line); background: var(--surface-2); color: var(--ink-2); font-size: .92rem; }

/* ---------- route cards ---------- */

.route-card { display: block; position: relative; text-decoration: none; color: var(--ink); padding-right: 2.75rem; }
.route-card:hover, .row-card:hover { border-color: var(--muted); }
.route-card-top { display: flex; align-items: center; gap: .6rem; margin-bottom: .35rem; }
.route-card h3 { font-size: 1.15rem; margin-bottom: .2rem; }
.route-school { color: var(--ink-2); margin-bottom: .45rem; font-size: .95rem; }
.meta { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; color: var(--ink-2); font-size: .92rem; }
.meta span { display: inline-flex; align-items: center; gap: .35rem; }
.meta .icon { color: var(--muted); }
.card-go { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); color: var(--muted); display: flex; }

.row-card { display: flex; align-items: center; gap: .75rem; position: relative; text-decoration: none; color: var(--ink); padding-right: 2.75rem; }
.row-main { display: grid; gap: .1rem; min-width: 0; margin-right: auto; }
.row-main .muted { font-size: .92rem; }

/* ---------- route detail ---------- */

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem 1rem; margin-bottom: 1rem; }
.fact { display: grid; gap: .05rem; min-width: 0; }
.fact span, .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.fact strong { font-size: 1.05rem; overflow-wrap: anywhere; }
.fact .fact-sub { font-style: normal; font-size: .85rem; color: var(--muted); }
@media (max-width: 520px) { .facts { grid-template-columns: repeat(2, 1fr); } }

.depot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.depot > div:first-child { display: grid; gap: .1rem; }

.stops { list-style: none; margin: 0; padding: 0; }
.stop { position: relative; display: grid; grid-template-columns: 2.3rem 1fr; gap: .85rem; padding-bottom: .9rem; }
.stop::before {
  content: ""; position: absolute; left: calc(1.15rem - 1px); top: 2.5rem; bottom: .15rem;
  width: 2px; background: var(--line);
}
.stop:last-child::before { display: none; }
.stop-num {
  width: 2.3rem; height: 2.3rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary); color: var(--primary-ink); font-weight: 800;
}
.stop-body {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .9rem 1rem; display: grid; gap: .45rem; min-width: 0;
}
.stop-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.stop-window { display: inline-flex; align-items: center; gap: .35rem; font-weight: 700; font-size: .95rem; }
.stop-body h3 { font-size: 1.1rem; }
.addr { color: var(--ink-2); }
.kv { margin: 0; display: grid; gap: .25rem; }
.kv div { display: flex; align-items: center; gap: .5rem; }
.kv dt { color: var(--muted); display: flex; }
.kv dd { margin: 0; }
.note {
  padding: .5rem .7rem; border-radius: 9px; font-size: .93rem;
  background: var(--todo-bg); color: var(--ink);
}
.kv-line { display: flex; align-items: center; gap: .45rem; color: var(--ink-2); }
.kv-line .icon { color: var(--muted); }
.stop-foot { display: flex; align-items: center; gap: .4rem .75rem; flex-wrap: wrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .8rem; }
.stop-school .stop-num { background: #0f4a37; color: #fff; border-radius: 9px; }
.stop.is-active .stop-body { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.stop.is-active .stop-num { background: var(--accent); color: #1a1200; }

/* ---------- Neo Querétaro map ---------- */

.nqmap { position: relative; overflow: hidden; background: #d9dfca; touch-action: none; color-scheme: light; }
.nqmap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; outline: none; }
.nqmap canvas.drag { cursor: grabbing; }
.nqmap canvas:focus-visible { box-shadow: inset 0 0 0 3px var(--focus); }
.nqmap-ctl { position: absolute; right: 10px; bottom: 10px; display: grid; gap: 6px; }
.nqmap-ctl button {
  min-width: 42px; height: 42px; padding: 0 8px; border-radius: 10px; cursor: pointer;
  border: 1px solid #c9c8ba; background: #fff; color: #1c2219; box-shadow: 0 1px 2px #0002;
  font: 600 20px/1 system-ui, sans-serif;
}
.nqmap-ctl button:hover { background: #eef3e6; }
.nqmap-ctl .nqmap-home { font-size: 13px; }
.nqmap-coord {
  position: absolute; left: 10px; bottom: 10px; max-width: calc(100% - 80px);
  padding: 3px 8px; border-radius: 6px; background: #ffffffe6; color: #2b3127;
  font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none;
}
@media (hover: none) { .nqmap-coord { display: none; } }
.nqmap-tip {
  position: absolute; z-index: 2; transform: translate(14px, -50%); pointer-events: none;
  padding: 5px 9px; border-radius: 6px; background: #101828; color: #fff;
  font-size: 13px; font-weight: 600; white-space: nowrap;
}
.nqmap-tip.flip { transform: translate(calc(-100% - 14px), -50%); }
.nqmap-hint {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  background: rgba(16, 24, 40, .45); color: #fff; font-weight: 700; text-align: center; padding: 1rem;
}
.nqmap-hint[hidden] { display: none; }

.route-map { height: 400px; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: var(--radius); }
@media (max-width: 720px) { .route-map { height: 320px; margin-left: -1rem; margin-right: -1rem; border-radius: 0; border-left: 0; border-right: 0; } }

.main.main-wide { max-width: none; padding: 0; }
.map-page {
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
}
.map-bar {
  display: flex; align-items: center; gap: .6rem 1rem; flex-wrap: wrap;
  padding: .7rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.map-bar > div:first-child { margin-right: auto; }
.map-bar h1 { font-size: 1.2rem; }
.seg-pick .opt input:checked + span { background: var(--primary); color: var(--primary-ink); }
.map-full { min-height: 0; }
@media (max-width: 720px) {
  .map-page { height: calc(100dvh - var(--topbar-h) - 62px - env(safe-area-inset-bottom)); }
  .map-bar { padding: .6rem 1rem; }
  .map-bar .muted { display: none; }
}

/* ---------- route overlap (#/admin/overlap) ---------- */

.ovl-page {
  display: grid; grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  height: calc(100vh - var(--topbar-h)); height: calc(100dvh - var(--topbar-h));
}
.ovl-side {
  display: flex; flex-direction: column; gap: 1rem; min-height: 0; overflow-y: auto;
  padding: 1rem 1.1rem 2rem; background: var(--surface); border-right: 1px solid var(--line);
}
.ovl-side h1 { font-size: 1.3rem; margin-top: .2rem; }
.ovl-side .back { margin-bottom: .2rem; }
.ovl-side .status-card { margin: 0; }
.ovl-map { min-height: 0; }
.ovl-day { margin: 0; flex-wrap: wrap; }
.ovl-sub { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .45rem; }
.ovl-sub h2 { font-size: 1rem; }
.ovl-sub h2 .muted { font-weight: 500; }
.ovl-swatch { display: inline-block; flex: none; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); }
.ovl-lines { display: flex; flex-direction: column; gap: 2px; }
.ovl-line {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: .6rem; align-items: center;
  padding: .45rem .55rem; border-radius: 8px; cursor: pointer;
}
.ovl-line:hover { background: var(--surface-2); }
.ovl-line input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--primary); }
.ovl-line small { display: block; color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.ovl-key { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .6rem; padding: 0 .55rem; font-size: .8rem; color: var(--muted); }
.ovl-key i { display: inline-block; width: 22px; margin-right: .4rem; vertical-align: middle; border-top: 4px solid var(--ink-2); border-radius: 2px; }
.ovl-key i.dash { border-top: 3px dashed var(--ink-2); }
.ovl-key i.red { border-top: 10px solid rgba(220, 38, 38, .5); }
.ovl-pairs { display: flex; flex-direction: column; gap: .55rem; }
.ovl-pair {
  border: 1px solid var(--line); border-left: 4px solid var(--warn); border-radius: 10px;
  background: var(--surface); cursor: pointer;
}
.ovl-pair.tone-bad { border-left-color: var(--bad); }
.ovl-pair:hover { background: var(--surface-2); }
.ovl-pair.is-picked { box-shadow: 0 0 0 2px var(--focus); }
.ovl-pair-head {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem; width: 100%;
  padding: .6rem .75rem .3rem; border: 0; background: none; color: inherit; font: inherit; font-weight: 700; text-align: left; cursor: pointer;
}
.ovl-pair-head .ovl-swatch { margin-right: .3rem; }
.ovl-pair-head .muted { font-weight: 500; margin: 0 .2rem; }
.ovl-show { display: inline-flex; align-items: center; gap: .15rem; flex: none; font-size: .8rem; font-weight: 600; color: var(--link); }
.ovl-show svg { width: 14px; height: 14px; }
.ovl-pair ul { list-style: none; margin: 0; padding: 0 .75rem .65rem; display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; }
.ovl-pair li .chip { margin-right: .3rem; }
@media (max-width: 900px) {
  .ovl-page { display: flex; flex-direction: column; height: auto; }
  .ovl-map { order: -1; height: 58vh; height: 58dvh; flex: none; scroll-margin-top: var(--topbar-h); }
  .ovl-side { overflow: visible; border-right: 0; }
}
@media (max-width: 720px) {
  .ovl-side { padding-bottom: calc(2rem + 62px + env(safe-area-inset-bottom)); } /* clear of the bottom tabs */
}

/* ---------- forms ---------- */

fieldset { border: 0; margin: 0 0 1rem; min-width: 0; }
fieldset.card { padding: 1rem 1.1rem; }
legend { float: left; width: 100%; padding: 0; margin-bottom: .75rem; font-weight: 700; font-size: 1.1rem; }
legend + * { clear: both; }

.field { display: grid; gap: .35rem; margin-bottom: .9rem; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-label { font-weight: 600; font-size: .93rem; }
input[type=text], input:not([type]), input[type=password], input[type=search], textarea {
  width: 100%; min-height: 46px; padding: .6rem .75rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
input:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--focus) 40%, transparent); outline-offset: 0; border-color: var(--focus); }
textarea { resize: vertical; }
.grid-3, .grid-2 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 .field, .grid-2 .field { margin: 0; }
@media (max-width: 620px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.check { display: flex; gap: .7rem; align-items: flex-start; margin: 1rem 0; cursor: pointer; }
.check input { width: 1.35rem; height: 1.35rem; margin: .1rem 0 0; flex: none; accent-color: var(--ok-solid); }

.form-error {
  padding: .65rem .85rem; border-radius: 10px; margin-bottom: .9rem;
  background: var(--bad-bg); color: var(--bad); font-weight: 600;
}
.form-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: 1.25rem; }
@media (max-width: 520px) {
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
}

/* ---------- segmented OK / Defect / N/A control ---------- */

.seg { display: inline-flex; flex: none; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg .opt { position: relative; display: flex; }
.seg .opt + .opt { border-left: 1px solid var(--line); }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg span {
  display: flex; align-items: center; justify-content: center;
  min-width: 4rem; min-height: 42px; padding: .4rem .8rem;
  font-weight: 700; font-size: .9rem; color: var(--ink-2); user-select: none;
}
.seg .opt:hover input:not(:checked) + span { background: var(--surface-2); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
.opt-ok input:checked + span { background: var(--ok-solid); color: #fff; }
.opt-defect input:checked + span { background: var(--bad-solid); color: #fff; }
.opt-na input:checked + span { background: var(--na-solid); color: #fff; }
.seg-wide { display: flex; }
.seg-wide .opt { flex: 1; }
.seg-wide span { width: 100%; }

/* ---------- pre-trip form ---------- */

.progress {
  position: sticky; top: var(--topbar-h); z-index: 10;
  margin: 0 -1.25rem 1rem; padding: .65rem 1.25rem .7rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.progress-text { display: flex; justify-content: space-between; gap: 1rem; font-size: .93rem; margin-bottom: .4rem; }
.progress-defects { color: var(--bad); font-weight: 700; }
.progress-error { color: var(--bad); font-weight: 700; text-align: right; }
.bar { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .2s ease; }
.bar-fill.is-done { background: var(--ok-solid); }
@media (max-width: 720px) { .progress { margin: 0 -1rem 1rem; padding-left: 1rem; padding-right: 1rem; } }

.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.section-head legend { float: none; width: auto; margin-bottom: .5rem; }
.section-actions { display: flex; gap: .4rem; }
.hint { margin: -.2rem 0 .5rem; }

.items { list-style: none; margin: 0; padding: 0; }
.item { padding: .65rem 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: .2rem; }
.item-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.item-label { font-weight: 500; }
.defect-note { display: none; margin-top: .55rem; }
.item.is-defect .defect-note { display: block; }
.item.is-defect .item-label { color: var(--bad); font-weight: 700; }
.item.is-missing { box-shadow: inset 4px 0 0 var(--bad-solid); padding-left: .75rem; background: var(--bad-bg); border-radius: 8px; }
.item.is-missing .item-label { color: var(--bad); font-weight: 700; }

@media (max-width: 560px) {
  .item-row { flex-direction: column; align-items: stretch; gap: .45rem; }
  .item .seg { display: flex; }
  .item .seg .opt { flex: 1; }
  .item .seg span { width: 100%; }
}

/* ---------- pre-trip detail ---------- */

.defect-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; }
.defect-list li { display: grid; gap: .1rem; padding-left: .8rem; border-left: 3px solid var(--bad-solid); }
.defect-list strong { color: var(--bad); }
.all-items { margin: 1rem 0; }
.all-items summary { cursor: pointer; font-weight: 700; padding: .15rem 0; }
.group-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1rem 0 .35rem; }
.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .4rem 0; border-top: 1px solid var(--line); }
.result-list li:first-child { border-top: 0; }
.certify-line { display: flex; align-items: center; gap: .4rem; }

/* ---------- login ---------- */

.login-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 1.5rem 1rem;
  background:
    radial-gradient(circle at 20% 0%, rgba(245, 165, 36, .18), transparent 45%),
    var(--brand);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border-radius: 18px; padding: 2rem 1.6rem 1.5rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.login-mark {
  width: 3.4rem; height: 3.4rem; border-radius: 14px; margin-bottom: 1rem;
  display: grid; place-items: center; background: var(--brand); color: var(--accent);
}
.login-mark .icon { width: 2rem; height: 2rem; }
.login-card h1 { font-size: 1.6rem; margin-bottom: .3rem; }
.login-card > .muted { margin-bottom: 1.4rem; }
.login-card form { margin-bottom: 1.2rem; }
.login-card .btn-block { margin-top: .4rem; }
.pw { position: relative; }
.pw input { padding-right: 4.5rem; }
.pw-toggle {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  padding: .35rem .6rem; border-radius: 8px; border: 0; cursor: pointer;
  background: transparent; color: var(--link); font-weight: 600; font-size: .9rem;
}

/* ---------- admin ---------- */

.brand-tag {
  margin-left: .15rem; padding: .05rem .45rem; border-radius: 999px;
  background: var(--accent); color: #1a1200; font-size: .72rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase;
}
.main.main-xl { max-width: 1320px; }
.section-row { align-items: center; margin: 1.75rem 0 .65rem; }
.section-row .section-title { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; }
.stat {
  display: grid; gap: .15rem; padding: .9rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.stat span { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.stat strong { font-size: 1.6rem; line-height: 1.1; }
a.stat-link { text-decoration: none; color: var(--ink); }
a.stat-link:hover { border-color: var(--muted); }
.stat em { font-style: normal; }
.stat-ok { border-left: 4px solid var(--ok-solid); }
.stat-warn { border-left: 4px solid var(--accent); }
.stat-bad { border-left: 4px solid var(--bad-solid); }
.stat-bad strong { color: var(--bad); }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card-flush { padding: 0; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: .7rem .9rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: .65rem .9rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table a:not(.btn):not(.chip) { color: var(--ink); text-decoration: none; }
.table a:not(.btn):not(.chip):hover { text-decoration: underline; }
.table .btn + .btn { margin-left: .3rem; }
a.chip { text-decoration: none; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .6rem; margin-bottom: 1rem; }
.toolbar-gap { flex: 1; }
.date-pick, .select {
  min-height: 40px; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font: inherit;
}
.select { padding-right: 1.8rem; max-width: 100%; }
.field .select { width: 100%; min-height: 46px; background: var(--surface-2); }
.select-small { min-height: 38px; padding: .3rem 1.6rem .3rem .5rem; font-size: .9rem; }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); }
.check-inline { margin: 0; align-items: center; }
.check-inline input { margin: 0; }
input[readonly] { color: var(--muted); }
input[type=date], input[type=time], input[type=number] {
  width: 100%; min-height: 46px; padding: .55rem .7rem;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.toolbar .date-pick { width: auto; min-height: 40px; }

.dialog {
  border: 0; border-radius: 16px; padding: 1.4rem 1.4rem 1.2rem; width: min(380px, calc(100vw - 2rem));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
}
.dialog::backdrop { background: rgba(14, 26, 43, .55); }
.dialog h2 { font-size: 1.15rem; margin-bottom: 1rem; }

/* route editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 1.25rem; align-items: start; }
.editor-form fieldset.card { margin-bottom: 1rem; }
.editor-map-wrap { position: sticky; top: calc(var(--topbar-h) + 1rem); }
.editor-map {
  height: calc(100vh - var(--topbar-h) - 4.5rem); min-height: 420px;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.map-help { margin-top: .4rem; }
.map-help.is-placing { color: var(--warn); font-weight: 700; }
.times { margin-top: .9rem; margin-bottom: .9rem; }
@media (max-width: 1000px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .editor-map-wrap { position: sticky; top: var(--topbar-h); z-index: 6; order: -1; background: var(--bg); padding-bottom: .5rem; }
  .editor-map { height: 42vh; min-height: 260px; }
}

.stop-edit-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .6rem; }
.stop-edit { border: 1px solid var(--line); border-radius: 12px; padding: .65rem .7rem; background: var(--surface-2); display: grid; gap: .5rem; }
.stop-edit.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.stop-edit.is-placing { border-color: var(--warn); border-style: dashed; }
.stop-edit-head { display: flex; align-items: center; gap: .45rem; }
.stop-edit-head input { min-height: 38px; padding: .35rem .6rem; }
.stop-badge {
  flex: none; width: 1.9rem; height: 1.9rem; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: var(--primary-ink); font-weight: 800; font-size: .9rem;
}
.stop-badge.is-school { background: #0f4a37; color: #fff; border-radius: 7px; }
.grow { flex: 1; min-width: 0; }
.icon-btns { display: flex; gap: .2rem; flex: none; }
.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-weight: 700;
}
.icon-btn:hover:not(:disabled) { border-color: var(--muted); color: var(--ink); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn-danger:hover:not(:disabled) { color: var(--bad); border-color: var(--bad); }
.stop-edit-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.stop-edit-row label { display: grid; gap: .15rem; font-size: .78rem; font-weight: 700; color: var(--muted); }
.stop-edit-row label:not(.grow) { width: 7.2rem; }
.stop-edit-row input { min-height: 38px; padding: .35rem .5rem; font-weight: 400; color: var(--ink); font-size: .95rem; }
.stop-edit-where { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.warn-text { color: var(--warn); font-weight: 700; }
.link-btn { border: 0; background: none; padding: 0; color: var(--link); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
@media (max-width: 560px) {
  .stop-edit-head { flex-wrap: wrap; }
  .stop-edit-head .grow { flex-basis: 100%; order: 3; }
  .icon-btns { margin-left: auto; }
}

/* ---------- shop ---------- */

.order-card .row-main { gap: .2rem; }
.cell-wide { min-width: 12rem; }
.cell-bus { min-width: 11rem; }
.table a.edit-link:not(.btn) { color: var(--link); font-weight: 600; }
.table a.edit-link:not(.btn):hover { text-decoration: underline; }
.row-actions { display: flex; flex-direction: column; align-items: stretch; gap: .3rem; }
.table .row-actions .btn + .btn { margin-left: 0; }
.order-top { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.toolbar-gap-top { margin-top: 1.25rem; }
.status-seg button {
  flex: 1; min-height: 44px; padding: .45rem .6rem; border: 0; cursor: pointer;
  background: var(--surface); color: var(--ink-2); font: inherit; font-weight: 700; font-size: .92rem;
}
.status-seg button + button { border-left: 1px solid var(--line); }
.status-seg button:hover { background: var(--surface-2); }
.status-seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); }
.order-actions { display: flex; align-items: center; gap: .5rem .75rem; flex-wrap: wrap; margin-top: .9rem; }
.order-actions > span:first-child { margin-right: auto; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); display: grid; gap: .9rem; }
.timeline li { position: relative; display: grid; gap: .15rem; }
.timeline li::before {
  content: ""; position: absolute; left: calc(-1rem - 6px); top: .35rem;
  width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid var(--surface);
}
.timeline-head { display: flex; flex-wrap: wrap; gap: .25rem .75rem; align-items: baseline; }
.wo-chip { margin-top: .35rem; width: fit-content; }
.wo-chip .icon { width: 1em; height: 1em; }
@media (max-width: 720px) {
  .tabs[data-count="6"] a, .tabs[data-count="7"] a { min-width: 0; flex: 1; padding: .35rem .1rem; font-size: .66rem; }
  .tabs[data-count="7"] { padding-left: .2rem; padding-right: .2rem; }
  .tabs[data-count="7"] a { font-size: .6rem; }
  .tabs[data-count="7"] a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .status-seg { flex-wrap: wrap; }
  .status-seg button { flex: 1 1 45%; }
  .status-seg button:nth-child(3) { border-left: 0; }
  .status-seg button:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ---------- rosters ---------- */

.riders { list-style: none; margin: .2rem 0 0; padding: 0; display: grid; gap: .35rem; }
.rider {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem .75rem; flex-wrap: wrap;
  padding: .45rem .6rem; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line);
}
.rider.is-rode { border-color: color-mix(in srgb, var(--ok-solid) 45%, var(--line)); background: var(--ok-bg); }
.rider.is-absent { opacity: .7; }
.rider.is-absent .rider-name strong { text-decoration: line-through; }
.rider-name { display: flex; align-items: center; gap: .35rem .5rem; flex-wrap: wrap; min-width: 0; }
.rider-marks { display: flex; gap: .3rem; flex: none; }
.mark-btn {
  display: inline-flex; align-items: center; gap: .3rem; min-height: 36px; padding: .3rem .7rem; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font: inherit; font-size: .88rem; font-weight: 700;
}
.mark-btn .icon { width: 1em; height: 1em; }
.mark-rode[aria-pressed="true"] { background: var(--ok-solid); border-color: var(--ok-solid); color: #fff; }
.mark-absent[aria-pressed="true"] { background: var(--na-solid); border-color: var(--na-solid); color: #fff; }
.mark-btn:disabled { opacity: .6; cursor: progress; }
.rider-tally { display: flex; align-items: center; justify-content: space-between; gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: .9rem; }
.rider-tally > div { display: grid; gap: .1rem; }
.tally { font-weight: 700; }

.roster-runs { margin-bottom: 1rem; }
.roster-search { max-width: 28rem; }
.roster-stop { margin-bottom: .6rem; }
.roster-stop h3 { display: flex; align-items: center; gap: .5rem; font-size: 1.02rem; margin-bottom: .5rem; }
.roster-list { list-style: none; margin: 0; padding: 0; display: grid; }
.roster-student { display: grid; gap: .35rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.roster-student:first-child { border-top: 0; padding-top: 0; }
.guardian { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; color: var(--ink-2); font-size: .93rem; }
.guardian > .icon { color: var(--muted); }

.seg-links { flex: none; }
.seg-links a {
  display: inline-flex; align-items: center; gap: .4rem; min-height: 40px; padding: .4rem .9rem;
  text-decoration: none; color: var(--ink-2); font-weight: 700; font-size: .92rem; background: var(--surface);
}
.seg-links a + a { border-left: 1px solid var(--line); }
.seg-links a[aria-current="page"] { background: var(--primary); color: var(--primary-ink); }
.roster-table .select { min-width: 10rem; }
.roster-table td .chip { margin: .1rem .25rem .1rem 0; }
.roster-table td .chip .icon { width: 1em; height: 1em; }
.roster-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
@media (max-width: 720px) { .roster-panels { grid-template-columns: minmax(0, 1fr); } }
.roster-board { list-style: none; margin: 0; padding: 0; display: grid; }
.roster-board li { display: flex; align-items: center; gap: .3rem .6rem; flex-wrap: wrap; padding: .5rem 0; border-top: 1px solid var(--line); }
.roster-board li:first-child { border-top: 0; }
.roster-board .muted { flex-basis: 100%; }

/* ---------- spreadsheet (rosters) ---------- */

.sheet-wrap {
  overflow: auto; max-height: calc(100vh - var(--topbar-h) - 13rem); min-height: 12rem;
  border: 1px solid var(--grid); border-radius: 6px; background: var(--surface);
}
.sheet { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; }
.sheet th, .sheet td {
  border-right: 1px solid var(--grid); border-bottom: 1px solid var(--grid);
  height: 34px; padding: 0; white-space: nowrap; vertical-align: middle;
}
.sheet th:last-child, .sheet td:last-child { border-right: 0; }
.sheet thead th {
  position: sticky; top: 0; z-index: 3; background: var(--sheet-head);
  text-align: left; font-size: .78rem; font-weight: 700; color: var(--ink-2); padding: 0 .6rem; user-select: none;
}
.sheet .rownum {
  position: sticky; left: 0; z-index: 2; width: 2.6rem; min-width: 2.6rem; padding: 0 .3rem;
  background: var(--sheet-head); color: var(--muted); text-align: center; font-size: .75rem; font-variant-numeric: tabular-nums;
}
.sheet thead .rownum { z-index: 4; }
.sort-btn {
  display: flex; align-items: center; gap: .3rem; width: 100%; height: 34px; padding: 0; border: 0; cursor: pointer;
  background: none; color: inherit; font: inherit; text-align: left;
}
.sort-btn::after { content: "↕"; opacity: .35; font-size: .85em; }
th[aria-sort="ascending"] .sort-btn::after { content: "▲"; opacity: .9; }
th[aria-sort="descending"] .sort-btn::after { content: "▼"; opacity: .9; }
.sheet tbody tr:hover td:not(.rownum) { background: color-mix(in srgb, var(--cell-active) 45%, transparent); }

/* read-only sheet (driver roster) */
.sheet-read td:not(.rownum) { padding: .3rem .6rem; }
.sheet-read .sheet-notes { white-space: normal; min-width: 14rem; color: var(--ink-2); }
.sheet-read td .chip { margin-right: .2rem; }
.sheet-stopno {
  display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; margin-right: .4rem; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink); font-size: .72rem; font-weight: 800;
}
.center { text-align: center; }

/* editable sheet (admin students): every cell is a field */
.sheet-edit td input:not([type=checkbox]), .sheet-edit td select {
  display: block; width: 100%; height: 34px; min-height: 0; margin: 0; padding: 0 .55rem;
  border: 0; border-radius: 0; background: transparent; color: var(--ink); font: inherit; font-size: .9rem;
}
.sheet-edit td select { padding-right: .2rem; cursor: pointer; }
.sheet-edit td input:focus, .sheet-edit td select:focus { outline: none; border: 0; }
.sheet-edit td:focus-within { outline: 2px solid var(--focus); outline-offset: -2px; background: var(--surface); position: relative; z-index: 1; }
/* spreadsheet column widths: the sheet scrolls sideways instead of squeezing cells */
.sheet-edit [data-f=name] { min-width: 11rem; }
.sheet-edit [data-f=grade] { min-width: 4.5rem; }
.sheet-edit [data-f=school] { min-width: 12rem; }
.sheet-edit [data-f=line] { min-width: 7.5rem; }
.sheet-edit [data-f=stop] { min-width: 11rem; }
.sheet-edit [data-f=guardian] { min-width: 10rem; }
.sheet-edit [data-f=phone] { min-width: 7.5rem; }
.sheet-edit [data-f=notes] { min-width: 18rem; }
/* the name column stays put while you scroll right, like a frozen column in a spreadsheet */
.sheet-freeze th:nth-child(2), .sheet-freeze td:nth-child(2) { position: sticky; left: 2.6rem; box-shadow: 1px 0 0 var(--grid), 3px 0 6px -3px rgba(0, 0, 0, .25); }
.sheet-freeze td:nth-child(2) { z-index: 2; background: var(--surface); }
.sheet-freeze thead th:nth-child(2) { z-index: 4; }
.sheet-freeze tbody tr:hover td:nth-child(2) { background: color-mix(in srgb, var(--cell-active) 45%, var(--surface)); }
.sheet-edit tr.is-new td:nth-child(2) { background: var(--surface-2); }
.sheet-edit td:nth-child(2):focus-within { position: sticky; z-index: 2; background: var(--surface); }
@media (max-width: 600px) { .sheet-read td:nth-child(2) strong { display: inline-block; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; } }
.sheet-edit .cell-check { text-align: center; }
.sheet-edit .cell-check input { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--ok-solid); cursor: pointer; }
.sheet-edit .cell-missing { background: var(--bad-bg); }
.sheet-edit tr.is-new td:not(.rownum) { background: var(--surface-2); }
.sheet-edit tr.is-new input::placeholder { color: var(--muted); font-style: italic; }
.sheet-edit tr.is-saving .rownum { color: var(--warn); font-weight: 800; }
.sheet-edit tr.is-error .rownum { background: var(--bad-solid); color: #fff; font-weight: 800; }
.sheet-edit tr.is-saved .rownum { animation: saved-flash 1.2s ease-out; }
@keyframes saved-flash { 0% { background: var(--ok-solid); color: #fff; } 100% { background: var(--sheet-head); } }
.cell-act { width: 2.2rem; text-align: center; }
.sheet-del {
  width: 28px; height: 28px; border: 0; border-radius: 6px; cursor: pointer; background: none; color: var(--muted); font-weight: 700;
}
.sheet-del:hover { background: var(--bad-bg); color: var(--bad); }
.sheet-status { font-size: .88rem; color: var(--muted); }
.sheet-status.is-bad { color: var(--bad); font-weight: 700; }
.sheet-help { margin-top: .5rem; }
.import-box { width: 100%; min-height: 9rem; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .85rem; white-space: pre; }
.dialog-wide { width: min(46rem, calc(100vw - 2rem)); }
.import-preview { max-height: 14rem; margin-top: .6rem; }

/* bus roster: one row per bus; run and driver cells are dropdowns */
.sheet-summary { margin: -.25rem 0 .6rem; }
.sheet-bus td.cell-text { padding: .3rem .6rem; }
.sheet-bus td:nth-child(2) { min-width: 6.5rem; }
.sheet-bus td:nth-child(3) { min-width: 11rem; }
.sheet-bus td:nth-child(4) { white-space: normal; min-width: 12rem; max-width: 16rem; }
.sheet-bus select[data-k=run] { min-width: 13rem; }
.sheet-bus select[data-k=driver] { min-width: 10rem; }
.sheet-bus .cell-lines > div + div { border-top: 1px dashed var(--grid); }
.sheet-bus .cell-run { display: flex; align-items: center; }
.sheet-bus .cell-run select { flex: 1; }
.cell-link { display: grid; place-items: center; flex: none; width: 28px; height: 34px; color: var(--muted); }
.cell-link:hover { color: var(--ink); background: var(--cell-active); }
.cell-link .icon { width: 1em; height: 1em; }
.sheet-bus .chip { margin: .1rem .25rem .1rem 0; }
.cell-busno { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.cell-busno .sheet-del { width: 24px; height: 24px; flex: none; font-size: .8rem; opacity: .55; }
.cell-busno .sheet-del:hover, .cell-busno .sheet-del:focus-visible { opacity: 1; }
.sheet-bus .chip .icon { width: 1em; height: 1em; }
.sheet-bus .cell-issues, .sheet-bus .cell-other { white-space: normal; min-width: 15rem; }
/* Status: a Spare / On runs picker, coloured like the chips */
.sheet-bus select[data-k=use], .sheet-bus select[data-n=use] { min-width: 8rem; font-weight: 700; }
.sheet-bus select[data-v=runs] { color: var(--ok); }
.sheet-bus select[data-v=spare] { color: var(--muted); }
.sheet-bus select[data-v] option { color: var(--ink); font-weight: 400; }
.sheet-bus tr.is-new select[data-n=am], .sheet-bus tr.is-new select[data-n=pm] { min-width: 13rem; }
/* the new-bus row: bus number, then year, make and model side by side in one cell */
.sheet-bus [data-n=bus] { min-width: 6.5rem; font-weight: 700; }
.sheet-bus .cell-trio { display: flex; min-width: 19rem; }
.sheet-bus .cell-trio input { flex: 1 1 0; width: auto; min-width: 0; }
.sheet-bus .cell-trio [data-n=year] { flex: 0 0 4.2rem; }
.sheet-bus .cell-trio input + input { border-left: 1px dashed var(--grid); }
.sheet-bus tr.is-new .btn { margin-right: .5rem; }
.sheet-bus tr.is-new .btn .icon { width: 1em; height: 1em; }
.sheet-bus tr.is-new td.cell-text { white-space: normal; }

/* the buses-and-drivers board gets grid lines too */
.table-grid th, .table-grid td { border: 1px solid var(--grid); }
.table-grid th { background: var(--sheet-head); }

/* ---------- print (pre-trip record) ---------- */

@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; }
  .topbar, .tabs, .back, [data-print], .flash { display: none !important; }
  .main { max-width: none; padding: 0; }
  .card, .callout, .verdict { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
