/* Dispatch board styling. One file, no framework, no build step. */

:root {
  --bg: #0f1419;
  --panel: #171d24;
  --panel-2: #1e262f;
  --line: #2a343f;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #4da3ff;
  --good: #3fb950;
  --warn: #d29922;
  --bad: #f85149;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand strong {
  font-size: 16px;
}

.brand span {
  color: var(--muted);
  margin-left: 8px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

select,
button,
.link {
  font: inherit;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

select:hover,
button:hover,
.link:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121f;
  font-weight: 600;
}

button:disabled {
  opacity: 0.5;
  cursor: progress;
}

.status {
  color: var(--muted);
  min-width: 150px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- layout ---------- */

main {
  display: grid;
  grid-template-columns: minmax(320px, 26%) 1fr;
  gap: 16px;
  padding: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
  }
}

.pane h2,
.panel h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0 0 10px;
}

.input-pane {
  position: sticky;
  top: 76px;
}

/* ---------- settings panel ---------- */

.control {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 8px;
  margin-bottom: 9px;
}

.control-label {
  font-size: 12px;
  color: var(--muted);
}

.control output {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 12px;
}

.control input[type='range'] {
  grid-column: 1 / -1;
  width: 100%;
  height: 4px;
  margin: 0;
  accent-color: var(--accent);
}

.control-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

button.small {
  padding: 4px 10px;
  font-size: 12px;
}

textarea {
  width: 100%;
  height: 34vh;
  resize: vertical;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0b1016;
  color: var(--text);
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
  overflow-x: auto;
}

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

.hidden {
  display: none;
}

.error {
  background: #2a1416;
  border: 1px solid var(--bad);
  color: #ffb4ae;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
  white-space: pre-wrap;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}

/* ---------- metric cards ---------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.metric .value {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.metric .label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric.good .value {
  color: var(--good);
}
.metric.warn .value {
  color: var(--warn);
}
.metric.bad .value {
  color: var(--bad);
}

/* ---------- timeline ---------- */

.timeline {
  min-width: 720px;
}

.timeline-row {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 7px 0;
}

.timeline-row.head {
  border-top: 0;
  color: var(--muted);
  font-size: 11px;
}

.driver-cell .name {
  font-weight: 600;
}

.driver-cell .meta {
  color: var(--muted);
  font-size: 11px;
}

.track {
  position: relative;
  height: 30px;
  background: #0b1016;
  border-radius: 5px;
}

/* Shaded band showing when the driver is actually available. */
.shift {
  position: absolute;
  top: 0;
  bottom: 0;
  background: #131c26;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

/* Hatched block: a scheduled break, which explains a gap in the row. */
.break {
  position: absolute;
  top: 0;
  bottom: 0;
  background: repeating-linear-gradient(45deg, #3a2b16, #3a2b16 4px, #171d24 4px, #171d24 8px);
}

.tick {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed #222c36;
}

.tick-label {
  position: absolute;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

/* Empty run to the pickup, plus any waiting: hollow so it reads as overhead. */
.bar-approach {
  position: absolute;
  top: 10px;
  height: 10px;
  border-radius: 5px;
  opacity: 0.4;
}

/* Passenger on board. */
.bar-onboard {
  position: absolute;
  top: 4px;
  height: 22px;
  border-radius: 5px;
  cursor: pointer;
  overflow: hidden;
  /* Safety net: if the width estimate is slightly off, clip with an ellipsis
     rather than cutting a character in half. */
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #06121f;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 5px;
}

/* Label for bars too narrow to hold text. Never intercepts clicks. */
.bar-label {
  position: absolute;
  top: 8px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
  padding: 0 5px;
}

.bar-onboard.late {
  outline: 2px solid var(--bad);
}

.bar-onboard.selected {
  outline: 2px solid #fff;
}

/* ---------- map ---------- */

.map-svg {
  width: 100%;
  height: auto;
  background: #0b1016;
  border-radius: 8px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.legend .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 5px;
}

/* ---------- lists and detail ---------- */

.list {
  margin: 0;
  padding-left: 18px;
}

.list li {
  margin-bottom: 5px;
}

.subhead {
  font-weight: 600;
  margin: 12px 0 6px;
}

.subhead:first-child {
  margin-top: 0;
}

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  border: 1px solid var(--line);
  color: var(--muted);
  margin-right: 6px;
}

.tag.bad {
  border-color: var(--bad);
  color: #ffb4ae;
}
.tag.good {
  border-color: var(--good);
  color: #7ee787;
}

.kv {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 4px 12px;
}

.kv dt {
  color: var(--muted);
}

.kv dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

code {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
  color: #a5d6ff;
}
