:root {
  color-scheme: light;
  --bg: #f5f7f3;
  --panel: #ffffff;
  --ink: #1d2522;
  --muted: #66716d;
  --line: #d9e0dc;
  --accent: #0b6f7a;
  --accent-dark: #074d55;
  --warn: #8a5b00;
  --warn-bg: #fff7df;
  --shadow: 0 18px 50px rgba(36, 49, 43, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(920px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 18px 36px;
}

.view {
  display: grid;
  gap: 22px;
}

.hidden {
  display: none;
}

.masthead,
.results-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.masthead {
  align-items: flex-start;
  flex-direction: column;
}

.kicker {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.route-summary {
  display: grid;
  gap: 2px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.route-summary p {
  margin: 0;
}

h1 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.form-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.pin-panel {
  max-width: 430px;
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-weight: 650;
}

.form-message.error {
  color: #8f1d1d;
}

.quick-actions,
.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  border: 0;
}

label span,
legend {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

input[type="text"],
input:not([type]),
input[type="date"] {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: var(--ink);
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(11, 111, 122, 0.16);
}

button {
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}

button:hover {
  border-color: var(--accent);
}

.primary {
  min-height: 52px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-dark);
}

.ghost {
  min-width: 86px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
}

.segmented label {
  display: block;
  position: relative;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--ink);
  font-size: 0.95rem;
}

.segmented label + label span {
  border-left: 1px solid var(--line);
}

.segmented input:checked + span {
  background: #dff2f4;
  color: var(--accent-dark);
}

.status {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 24px;
  color: var(--muted);
  font-weight: 650;
}

.status.error {
  color: #8f1d1d;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid #cfd8d4;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.drive-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 112px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.drive-bar {
  flex: 1 1 4px;
  min-width: 0;
  min-height: 8px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: #e1e7e3;
}

.drive-bar.fast {
  background: #a9dfad;
}

.drive-bar.moderate {
  background: #ffc86f;
}

.drive-bar.slow {
  background: #ff9b92;
}

.drive-bar.very-slow {
  background: #a92922;
}

.drive-bar.unavailable,
.drive-bar.loading {
  background: #d7ddda;
}

.drive-bar.active {
  outline: 3px solid var(--accent-dark);
  outline-offset: 2px;
}

.table-shell {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.table-head,
.row {
  display: grid;
  grid-template-columns: minmax(120px, 0.9fr) minmax(140px, 1.1fr);
  gap: 12px;
  align-items: center;
}

.table-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 16px;
  background: #e9efec;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.rows {
  max-height: calc(100vh - 215px);
  overflow-y: auto;
  scroll-behavior: smooth;
}

.row {
  min-height: 58px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}

.day-divider {
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  background: #f7faf8;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 850;
}

.row strong {
  font-size: 1.02rem;
}

.row .muted {
  color: var(--muted);
}

.row.current {
  background: #e0f5f7;
  box-shadow: inset 4px 0 0 var(--accent);
}

.row.fast {
  background: #e7f7e8;
}

.row.moderate {
  background: #fff0d5;
}

.row.slow {
  background: #ffe2df;
}

.row.very-slow {
  background: #ffd0cc;
  color: #64120e;
}

.row.current.fast,
.row.current.moderate,
.row.current.slow,
.row.current.very-slow {
  box-shadow: inset 4px 0 0 var(--accent);
}

.row.past {
  background: var(--warn-bg);
  color: var(--warn);
}

.row.unavailable {
  background: #fff1f1;
  color: #8f1d1d;
}

@media (max-width: 640px) {
  .shell {
    padding: 20px 12px 28px;
  }

  .quick-actions,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .results-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .ghost {
    width: 100%;
  }

  .rows {
    max-height: calc(100vh - 250px);
  }
}
