/* Admin dashboard styles (borrows the parent-app palette). */
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f172a; color: #e2e8f0; }
.hidden { display: none !important; }
a { color: #7dd3fc; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- login ---------- */
#login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #00263e 0%, #0f172a 100%); padding: 24px;
}
.login-card {
  background: #ffffff; border-radius: 16px; padding: 32px 28px; max-width: 340px; width: 100%;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4); color: #0f172a;
}
.login-logo { font-size: 44px; }
.login-card h1 { margin: 8px 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: #64748b; font-size: 14px; }
.login-card input { width: 100%; padding: 12px 14px; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 16px; margin-bottom: 10px; }
.login-card button { width: 100%; padding: 12px; border: 0; border-radius: 10px; background: #f59e0b; color: #1e293b; font-size: 16px; font-weight: 700; cursor: pointer; }
#login-error { color: #dc2626; font-size: 13px; margin-top: 8px; min-height: 16px; }

/* ---------- shell ---------- */
header.admin {
  background: #00263e; padding: 12px 18px;
  padding-top: calc(12px + env(safe-area-inset-top));
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  border-bottom: 1px solid #0b1f34;
}
header.admin .title { font-weight: 800; font-size: 18px; }
header.admin nav { display: flex; gap: 14px; flex-wrap: wrap; }
header.admin nav a { color: #cbd5e1; font-weight: 600; font-size: 14px; }
header.admin nav a.active { color: #fbbf24; }
header.admin .right { margin-left: auto; font-size: 12px; color: #94a3b8; }

/* TOUCH TARGETS IN THE SHARED HEADER (task 3090, QA judgement call J1).
   Map / Password / Sign out were 40px on the teacher attendance page and ~22px
   everywhere else - under the 44px that page holds for everything it owns. The
   consequence is not aesthetic: "Sign out" sits a few pixels from "Map" on a
   header tapped one-handed, outdoors, while 34 children board, and signing out
   by accident costs a teacher her session mid-dismissal.

   GATED ON A TOUCH POINTER ON PURPOSE. These ten pages are read at a desk with
   a mouse, where 22px is fine and 44px chunky buttons would be a regression for
   their only real user. `pointer: coarse` is the finger, and a finger gets the
   full target on every one of them - not just on /attendance. With a mouse,
   every rule below is inert and the rendered header is byte-for-byte what it
   was (measured: see the task 3090 report). */
@media (pointer: coarse) {
  header.admin nav { gap: 4px; }
  header.admin nav a {
    min-height: 44px; display: inline-flex; align-items: center; padding: 0 8px;
  }
  header.admin .acct { gap: 6px; }
  header.admin .acct-btn { min-height: 44px; min-width: 44px; padding: 0 12px; }
  /* Sign out is the one control here that cannot be undone, so it does not sit
     flush against its neighbours and does not wear the same filled chip. */
  header.admin .acct-btn[data-act="out"] {
    margin-left: 10px; background: transparent;
    border: 1px solid #475569; color: #cbd5e1;
  }
}
main { padding: 20px; max-width: 1200px; margin: 0 auto; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 24px 0 8px; color: #cbd5e1; }
p.muted, .muted { color: #94a3b8; font-size: 13px; }

/* ---------- cards / grids ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-top: 12px; }
/* Overview bus cards: fixed columns so 6 buses lay out as clean rows instead of
   an auto-fill remainder (was 5 + 1 on desktop). 1 col mobile, 2 col mid, 3 col
   desktop (two even rows of three for the current 6-bus fleet). */
#bus-cards { grid-template-columns: 1fr; }
@media (min-width: 480px) { #bus-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 820px) { #bus-cards { grid-template-columns: repeat(3, 1fr); } }
.card {
  background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 14px;
  cursor: pointer; transition: border-color .1s;
}
.card:hover { border-color: #f59e0b; }
.card .swatch { width: 16px; height: 16px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 8px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card .stat { color: #94a3b8; font-size: 12px; margin-top: 4px; }
.card .stat b { color: #e2e8f0; font-weight: 700; font-size: 14px; }

.kpi-row { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.kpi {
  background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 12px 16px; min-width: 140px;
}
.kpi .label { color: #94a3b8; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 22px; font-weight: 800; margin-top: 2px; }

/* ---------- tables ---------- */
table.data {
  width: 100%; border-collapse: collapse; background: #1e293b; border-radius: 8px; overflow: hidden;
  font-size: 13px; margin-top: 8px;
}
table.data th, table.data td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #334155; }
table.data th { background: #0f172a; color: #94a3b8; font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #263447; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.manual { background: #14532d; color: #86efac; }
.pill.auto { background: #0c4a6e; color: #7dd3fc; }
.pill.ambiguous { background: #78350f; color: #fcd34d; }
.pill.unassigned { background: #334155; color: #94a3b8; }
.pill.ignored { background: #7f1d1d; color: #fecaca; }
/* Day flags (task 2886): `abnormal` marks a flagged DAY, `excluded` marks a run
   that a flag takes out of the numbers. Excluded rows stay readable — dimmed,
   not hidden — so the admin can still see what was dropped. */
.pill.abnormal { background: #78350f; color: #fcd34d; cursor: help; }
.pill.excluded { background: #334155; color: #cbd5e1; font-weight: 600; cursor: help; }
/* Dim by color, not opacity: an opacity on the row would drag the pill and its
   reason down with it (opacity composites, so a child can't opt out) and the
   11px pill text would fall below AA contrast. */
tr.row-excluded td,
tr.row-excluded td b,
tr.row-excluded td a,
tr.row-excluded td .muted { color: #7c8ba2; }
tr.row-excluded td .pill.excluded { color: #cbd5e1; }
.excl-note { color: #94a3b8; font-size: 12px; }
/* Keep the date and the Flag button on one line on a phone — the Days table
   already sits in an overflow-x:auto wrapper, so it scrolls instead of
   breaking "2026-10-07" and "⚑ Flag" across two lines. */
#days-table td:first-child, #days-table td:last-child,
#days-table th:first-child, #days-table th:last-child { white-space: nowrap; }
/* ...and buy back the width that costs by tightening the cell padding, so the
   Flag column stays on-screen on a 375px phone instead of behind a scroll. */
@media (max-width: 520px) {
  #days-table th, #days-table td { padding: 8px 6px; }
  #days-table td:last-child button { padding: 6px 10px; }
}

/* ---------- forms / buttons ---------- */
button, .btn {
  background: #f59e0b; color: #1e293b; border: 0; padding: 8px 14px; border-radius: 8px;
  font-weight: 700; font-size: 13px; cursor: pointer;
}
button.secondary, .btn.secondary { background: #334155; color: #e2e8f0; }
button.danger, .btn.danger { background: #7f1d1d; color: #fecaca; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  background: #0f172a; color: #e2e8f0; border: 1px solid #334155; border-radius: 8px;
  padding: 8px 10px; font-size: 14px; font-family: inherit;
}
label { display: block; font-size: 12px; color: #94a3b8; margin: 8px 0 4px; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- map surfaces ---------- */
.map-wrap { height: 60vh; border-radius: 12px; overflow: hidden; border: 1px solid #334155; }
.leaflet-container { background: #0f172a; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #1e293b; color: #e2e8f0; }
.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content b { font-size: 14px; }
.leaflet-popup-content button { margin-top: 6px; }

/* ---------- visit sheet (modal) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; z-index: 2000;
}
.sheet {
  background: #1e293b; border-radius: 16px 16px 0 0; padding: 20px; max-width: 500px; width: 100%;
  max-height: 80vh; overflow-y: auto;
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 16px; }
}

/* ---------- day-flag sheet (task 2886) ---------- */
.df-h3 { font-size: 13px; margin: 20px 0 0; color: #cbd5e1; text-transform: uppercase; letter-spacing: .04em; }
.df-radios { display: flex; flex-direction: column; gap: 2px; }
.df-radio {
  display: flex; align-items: center; gap: 8px; margin: 0; padding: 7px 8px;
  border-radius: 8px; font-size: 14px; color: #e2e8f0; text-transform: none;
  letter-spacing: 0; cursor: pointer;
}
.df-radio:hover { background: #263447; }
.df-radio input { accent-color: #f59e0b; width: 16px; height: 16px; margin: 0; flex: 0 0 auto; }
.df-radio:focus-within { outline: 2px solid #f59e0b; outline-offset: -2px; }
.df-list { display: flex; flex-direction: column; gap: 6px; }
.df-item {
  display: flex; align-items: flex-start; gap: 10px; justify-content: space-between;
  background: #0f172a; border: 1px solid #334155; border-radius: 10px; padding: 9px 11px;
}
.df-item-text { min-width: 0; font-size: 13px; }
.df-item-text b { color: #fbbf24; font-size: 12px; }
.df-item-text .muted { word-break: break-word; }
.df-item-act { flex: 0 0 auto; display: flex; align-items: center; gap: 6px; }
.df-item-act button { padding: 5px 9px; font-size: 12px; }
.df-error { color: #fca5a5; font-size: 13px; margin-top: 8px; min-height: 17px; }
/* The sheet scrolls (80vh cap), so pin the actions to its bottom edge —
   otherwise Save sits below the fold on a 375px phone. The negative margins
   let the bar span the sheet's 20px padding. */
.df-actions {
  position: sticky; bottom: -20px; z-index: 1;
  display: flex; gap: 8px; justify-content: flex-end;
  margin: 12px -20px -20px; padding: 12px 20px;
  background: #1e293b; border-top: 1px solid #334155;
}

/* ---------- abnormal-day banner (/admin/live, task 2886) ---------- */
.banner.warn {
  background: #3b2508; border: 1px solid #78350f; color: #fcd34d;
  border-radius: 10px; padding: 9px 12px; font-size: 13px; font-weight: 600;
  display: flex; gap: 8px; align-items: flex-start;
}
.banner.warn .banner-reasons { color: #fde68a; font-weight: 400; }

/* ---------- little map dots (stops/zones/visits) ---------- */
.stop-marker { background: #f59e0b; width: 14px; height: 14px; border-radius: 50%; border: 2px solid #1e293b; }
.visit-marker {
  background: #7dd3fc; color: #0f172a; border: 2px solid #1e293b; border-radius: 50%;
  width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px;
}
.visit-marker.ambiguous { background: #fcd34d; }
.visit-marker.unassigned { background: #cbd5e1; }
.visit-marker.ignored { background: #334155; color: #94a3b8; }
.visit-marker.manual { background: #86efac; }

/* ---------- day replay bar (task 1758) ---------- */
.replay-bar { padding: 8px 16px 4px; display: flex; flex-direction: column; gap: 8px; }
.replay-controls { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.replay-controls input[type="date"] { flex: 1 1 auto; min-width: 0; padding: 6px 8px; font-size: 13px; color-scheme: dark; cursor: pointer; }
.replay-controls input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 1; }
.replay-controls button { padding: 6px 10px; font-size: 12px; white-space: nowrap; flex: 0 0 auto; }
.replay-slider-row { display: flex; align-items: center; gap: 10px; }
.replay-slider-row input[type="range"] { flex: 1 1 auto; min-width: 0; accent-color: #f59e0b; }
.replay-time { font-variant-numeric: tabular-nums; font-size: 13px; color: #e2e8f0; min-width: 76px; text-align: right; flex: 0 0 auto; }

/* ---------- feedback panel (task 2426) ---------- */
.fb-form { display: flex; flex-direction: column; gap: 10px; position: relative; margin-top: 12px; max-width: 560px; }
.fb-form textarea { resize: vertical; min-height: 64px; }
.fb-row { display: flex; align-items: center; gap: 10px; }
.fb-status { flex: 1; font-size: 12px; color: #94a3b8; }
.fb-status.err { color: #fca5a5; }
.fb-filter { margin-top: 20px; max-width: 560px; font-size: 13px; }
.fb-filter label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.fb-threads { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; max-width: 560px; }
.fb-empty { color: #94a3b8; font-size: 13px; text-align: center; padding: 16px; }
.fb-thread { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 14px; }
.fb-thread-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.fb-thread-title { font-weight: 700; font-size: 14px; }
.fb-thread-who { font-size: 12px; color: #94a3b8; margin-top: 2px; }
.fb-thread-msg { font-size: 13.5px; white-space: pre-wrap; margin-top: 8px; color: #cbd5e1; }
.fb-pill { flex: 0 0 auto; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.fb-pill.new { background: #78350f; color: #fcd34d; }
.fb-pill.in-progress { background: #0c4a6e; color: #7dd3fc; }
.fb-pill.done { background: #14532d; color: #86efac; }
.fb-bubbles { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.fb-bub { max-width: 88%; padding: 8px 11px; border-radius: 14px; font-size: 13.5px; white-space: pre-wrap; line-height: 1.4; }
.fb-bub.agent { align-self: flex-start; background: #1e3a8a; color: #dbeafe; border-top-left-radius: 4px; }
.fb-bub.me { align-self: flex-end; background: #334155; color: #e2e8f0; border-top-right-radius: 4px; }
.fb-bub small { display: block; font-size: 11px; color: #94a3b8; margin-bottom: 2px; font-weight: 700; }
.fb-reply { display: flex; gap: 8px; margin-top: 10px; }
.fb-reply input { flex: 1; }
.fb-reply button { padding: 8px 12px; font-size: 12px; }
.fb-acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- what's new badge + page (task 2427) ---------- */
.wn-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #f59e0b; margin-left: 5px; vertical-align: middle;
}
.wn-list { display: flex; flex-direction: column; gap: 10px; max-width: 720px; margin-top: 16px; }
.wn-entry { background: #1e293b; border: 1px solid #334155; border-radius: 12px; overflow: hidden; }
.wn-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: none; border: 0; border-radius: 0; padding: 14px 16px; cursor: pointer; text-align: left;
  color: inherit; font: inherit;
}
.wn-toggle:hover { background: #263447; }
.wn-toggle:focus-visible { outline: 2px solid #f59e0b; outline-offset: -2px; }
.wn-toggle-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.wn-date { font-weight: 700; font-size: 14px; color: #fbbf24; }
.wn-title { font-size: 12.5px; color: #94a3b8; }
.wn-chevron { flex: 0 0 auto; color: #94a3b8; transition: transform .15s; }
.wn-toggle[aria-expanded="true"] .wn-chevron { transform: rotate(180deg); }
.wn-panel { padding: 0 16px 16px; border-top: 1px solid #334155; }
.wn-panel.hidden { display: none; }
.wn-panel h4 { font-size: 14px; margin: 16px 0 6px; color: #e2e8f0; }
.wn-panel h4:first-child { margin-top: 16px; }
.wn-panel p { font-size: 13.5px; line-height: 1.55; color: #cbd5e1; margin: 8px 0; }
.wn-panel ul { margin: 6px 0; padding-left: 20px; }
.wn-panel li { font-size: 13.5px; line-height: 1.55; color: #cbd5e1; margin: 4px 0; }
.wn-panel a { color: #7dd3fc; }
.wn-panel b { color: #e2e8f0; }
.wn-panel code {
  background: #0f172a; border: 1px solid #334155; border-radius: 6px;
  padding: 1px 6px; font-size: 12px; color: #7dd3fc;
}

/* ---------- charts ---------- */
.chart-wrap { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 12px; margin-top: 8px; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-wrap text { fill: #94a3b8; font-family: inherit; font-size: 11px; }
.chart-wrap line.grid { stroke: #334155; stroke-width: 1; }
.chart-wrap line.axis { stroke: #64748b; stroke-width: 1; }

/* ---------- account menu + user management (task 3066) ---------- */
.acct { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct-who { font-size: 12px; color: #94a3b8; font-weight: 600; }
.acct-btn {
  background: #334155; color: #e2e8f0; border: 0; border-radius: 8px;
  padding: 5px 10px; font-size: 12px; font-weight: 700; cursor: pointer; width: auto;
}
.acct-btn:hover { background: #475569; }

.acct-modal {
  position: fixed; inset: 0; background: rgba(2, 6, 23, .7);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 2000;
}
.acct-card {
  background: #1e293b; border: 1px solid #334155; border-radius: 14px;
  padding: 18px; width: 100%; max-width: 360px;
}
.acct-card h3 { margin: 0 0 4px; font-size: 17px; }
.acct-card input, .acct-card select {
  width: 100%; padding: 10px 12px; margin-top: 8px; font-size: 15px;
  background: #0f172a; color: #e2e8f0; border: 1px solid #334155; border-radius: 9px;
}
.acct-err { color: #fca5a5; font-size: 13px; min-height: 18px; margin-top: 8px; }
.acct-actions { display: flex; gap: 8px; margin-top: 6px; }
.acct-actions button { flex: 1; }

.pill.role-admin { background: #581c87; color: #e9d5ff; }
.pill.role-teacher { background: #0c4a6e; color: #7dd3fc; }
.pill.role-parent { background: #334155; color: #cbd5e1; }
.pill.off { background: #7f1d1d; color: #fecaca; }
.pill.system { background: #422006; color: #fcd34d; }
.u-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.u-actions button { width: auto; padding: 5px 9px; font-size: 12px; }
tr.u-off td { opacity: .55; }
.audit-detail { color: #94a3b8; font-size: 12px; word-break: break-word; }
/* ---------- roster import (task 3067) ---------- */
#roster-form {
  background: #1e293b; border: 1px solid #334155; border-radius: 12px;
  padding: 14px; margin-top: 12px; display: grid; gap: 10px;
}
#roster-form textarea {
  width: 100%; box-sizing: border-box; resize: vertical; font-family: ui-monospace, Menlo, monospace;
  font-size: 12px; background: #0f172a; color: #e2e8f0;
  border: 1px solid #334155; border-radius: 8px; padding: 8px;
}
#roster-form input[type="text"] {
  width: 100%; box-sizing: border-box; background: #0f172a; color: #e2e8f0;
  border: 1px solid #334155; border-radius: 8px; padding: 8px;
}
#roster-form input[type="file"] { color: #94a3b8; font-size: 13px; }
.roster-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.banner.ok {
  background: #052e1a; border: 1px solid #166534; color: #86efac;
  border-radius: 10px; padding: 9px 12px; font-size: 13px; font-weight: 600;
}
.banner.info {
  background: #0f172a; border: 1px solid #334155; color: #94a3b8;
  border-radius: 10px; padding: 9px 12px; font-size: 13px;
}
/* The missed-import alarm (task 3099). Deliberately louder than .warn: this one
   means six buses are about to open to an empty list, and the person reading it
   has about 30 minutes to paste the email. */
.banner.alarm {
  background: #450a0a; border: 2px solid #dc2626; color: #fecaca;
  border-radius: 10px; padding: 14px 16px; font-size: 15px; line-height: 1.45;
  font-weight: 600; margin-bottom: 14px;
}
.banner.alarm b { color: #fff; }
/* Status cells in the email-deliveries table. */
table.data td.ok  { color: #86efac; font-weight: 600; }
table.data td.bad { color: #fca5a5; font-weight: 700; }
table.data td.num, table.data th.num { text-align: right; }
