:root {
  --navy: #0b1f3a;
  --navy-mid: #14325a;
  --gold: #d4a017;
  --gold-press: #b8860b;
  --white: #ffffff;
  --ink: #f4f7fb;
  --muted: #9bb0c9;
  --ok: #1f9d55;
  --warn: #e67e22;
  --bad: #c0392b;
  --live: #2ecc71;
  --stale: #f1c40f;
  --offline: #7f8c9b;
  --card: #102744;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--navy);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow-x: clip;
  max-width: 100%;
}
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app {
  min-height: 100dvh;
  max-width: 100%;
  padding: calc(12px + var(--safe-top)) 12px 0;
}

.screen { min-height: calc(100dvh - var(--safe-top)); display: flex; flex-direction: column; max-width: 100%; }
.main { flex: 1 1 auto; min-width: 0; padding-bottom: 168px; }
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  gap: 10px;
  padding: 10px 12px calc(14px + var(--safe-bottom));
  background: var(--navy);
  max-width: 100%;
}

.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.brand { font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.identity { font-size: 22px; font-weight: 750; line-height: 1.15; overflow-wrap: anywhere; }
.meta { color: var(--muted); font-size: 14px; margin-top: 4px; overflow-wrap: anywhere; }

.banner {
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}
.banner.live { background: #123d2a; color: #b7f0c8; }
.banner.reconnecting { background: #3d2c12; color: #ffd48a; }
.banner.offline { background: #3d1515; color: #ffb4b0; }
.banner.info { background: var(--navy-mid); color: var(--ink); }

.pills { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; min-width: 0; }
.pill { background: var(--card); border-radius: 16px; padding: 12px 10px; min-height: 72px; min-width: 0; }
.pill .label { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.pill .value { font-size: 18px; font-weight: 800; margin-top: 6px; overflow-wrap: anywhere; }
.pill.gps-live .value { color: var(--live); }
.pill.gps-stale .value { color: var(--stale); }
.pill.gps-off .value { color: var(--offline); }
.pill.duty-free .value { color: var(--live); }
.pill.duty-busy .value { color: #7ec8ff; }
.pill.duty-off .value { color: var(--offline); }

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 16px 14px;
  margin-bottom: 12px;
  max-width: 100%;
  min-width: 0;
}
.card h2 { margin: 0 0 8px; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.card .title { font-size: 22px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.card .line { margin-top: 10px; font-size: 16px; line-height: 1.35; overflow-wrap: anywhere; }
.card .line span { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.countdown { margin-top: 12px; font-size: 28px; font-weight: 800; color: var(--gold); text-align: center; }

.actions { display: grid; gap: 10px; min-width: 0; }
.actions.pair { grid-template-columns: 1fr 1fr; }
.trip-actions { margin-top: 16px; }
.notes-heading { margin-top: 18px; }
.notes-actions { margin-top: 10px; }
.btn {
  min-height: 56px;
  width: 100%;
  border: 0;
  border-radius: 16px;
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
  background: var(--gold);
  padding: 0 10px;
}
.btn:disabled { opacity: 0.45; }
.btn.accept, .btn.go { background: var(--ok); color: white; }
.btn.reject, .btn.stop { background: var(--bad); color: white; }
.btn.next { background: #1b6ca8; color: white; }
.btn.ghost { background: var(--navy-mid); color: var(--ink); }
.btn.logout { background: #4a1d1d; color: #ffd0cc; min-height: 56px; font-size: 17px; }

.login { max-width: 420px; margin: 0 auto; padding-top: 24px; }
.pin-display {
  background: var(--card);
  border-radius: 18px;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  letter-spacing: 0.28em;
  font-weight: 800;
  margin: 20px 0;
}
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pad button {
  min-height: 72px;
  border: 0;
  border-radius: 18px;
  background: var(--navy-mid);
  color: white;
  font-size: 28px;
  font-weight: 800;
}
.hint { margin-top: 18px; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.45; }
.error { color: #ffb4b0; text-align: center; font-weight: 700; min-height: 24px; }

textarea {
  width: 100%;
  min-height: 88px;
  border-radius: 14px;
  border: 0;
  padding: 12px;
  background: #0a1a30;
  color: var(--ink);
  resize: vertical;
}
.empty { color: var(--muted); font-size: 16px; line-height: 1.4; }

.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(4, 10, 20, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
.confirm-sheet {
  width: min(100%, 420px);
  background: var(--card);
  border-radius: 20px;
  padding: 18px 14px calc(14px + var(--safe-bottom));
  max-height: min(70dvh, 420px);
  overflow: auto;
}
.confirm-sheet h2 { margin: 0 0 8px; font-size: 22px; }
.confirm-sheet p { margin: 0 0 16px; color: var(--muted); font-size: 16px; line-height: 1.4; }

.school-route .route-header { margin-bottom: 14px; }
.school-route .route-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-weight: 700;
}
.school-route .route-meta span {
  background: #0a1a30;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 14px;
}
.route-timeline {
  list-style: none;
  margin: 16px 0 0;
  padding: 0 0 0 14px;
  border-left: 3px solid #1d3d66;
  display: grid;
  gap: 10px;
}
.route-timeline > li { min-width: 0; }
.stop-card {
  position: relative;
  background: #0a1a30;
  border-radius: 18px;
  padding: 14px 12px 12px;
  border: 2px solid transparent;
}
.stop-card.current {
  border-color: var(--gold);
  background: #17345c;
}
.stop-card.next { border-color: #2a6aa8; }
.stop-card.done { opacity: 0.72; }
.stop-kicker {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 800;
}
.stop-seq {
  position: absolute;
  top: 12px;
  right: 12px;
  min-width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}
.stop-time { margin-top: 8px; font-size: 28px; font-weight: 800; line-height: 1; }
.stop-type { margin-top: 6px; font-size: 16px; font-weight: 800; }
.stop-address { margin-top: 6px; font-size: 20px; font-weight: 750; line-height: 1.25; overflow-wrap: anywhere; }
.stop-school, .stop-notes, .stop-progress { margin-top: 8px; color: var(--muted); font-size: 15px; overflow-wrap: anywhere; }
.stop-progress { color: var(--ink); font-weight: 800; }
.stop-children { display: grid; gap: 8px; margin-top: 12px; }
.child-row {
  background: var(--navy);
  border-radius: 14px;
  padding: 10px;
}
.child-name { font-size: 18px; font-weight: 800; overflow-wrap: anywhere; }
.child-outcome { margin-top: 4px; color: var(--muted); font-weight: 700; }
.child-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.child-act {
  width: auto;
  min-height: 48px;
  padding: 0 12px;
  font-size: 15px;
  flex: 1 1 calc(50% - 8px);
}
.stop-actions { display: grid; gap: 10px; margin-top: 14px; }
.stop-actions .btn { text-decoration: none; display: flex; align-items: center; justify-content: center; }

.child-chip {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  background: var(--navy);
  border-radius: 14px;
  padding: 10px 12px;
}
.child-chip .child-outcome { margin-top: 0; }
.stop-card.compact { padding: 10px 12px; }
.stop-card.compact .stop-time { font-size: 16px; margin-top: 4px; }
.stop-card.compact .stop-address { font-size: 16px; font-weight: 700; }
.happy-path-actions .btn.go { min-height: 64px; font-size: 20px; }
.linkish {
  width: 100%;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--gold);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  padding: 0;
}
.exception-toggle { margin-top: 2px; }
.exception-panel {
  display: grid;
  gap: 10px;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #1d3d66;
}
.exception-child {
  background: var(--navy);
  border-radius: 14px;
  padding: 10px;
}
.route-lifecycle { margin: 12px 0 4px; }
.notes-collapse { margin-top: 14px; }
.dock.school-dock { gap: 8px; }
.main:has(.school-route) { padding-bottom: 120px; }

@media (max-width: 400px) {
  .identity { font-size: 20px; }
  .card .title { font-size: 20px; }
  .btn { min-height: 56px; font-size: 17px; }
  .pad button { min-height: 64px; font-size: 24px; }
  .stop-time { font-size: 24px; }
  .stop-address { font-size: 18px; }
}
