:root {
  --bar: #16202b;
  --bar-ink: #ffffff;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #5d6673;
  --line: #e1e4e9;
  --accent: #1d6fb8;
  --live: #2fb35a;
  --problem: #e2a400;
  --panel-width: 330px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { display: flex; flex-direction: column; font-size: 15px; line-height: 1.35; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- header ------------------------------------------------------------ */

.bar {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--bar); color: var(--bar-ink);
}
.bar h1 { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 17px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { flex: 0 1 auto; max-width: 62%; margin: 0; display: flex; align-items: center; gap: 7px; font-size: 13px; color: #c9d3de; text-align: right; }
.status-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #8793a1; }
.status.live .status-dot { background: var(--live); animation: pulse 2s infinite; }
.status.problem { color: #ffd772; }
.status.problem .status-dot { background: var(--problem); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(47,179,90,.6); } 70% { box-shadow: 0 0 0 7px rgba(47,179,90,0); } 100% { box-shadow: 0 0 0 0 rgba(47,179,90,0); } }

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

.layout { flex: 1; display: flex; min-height: 0; position: relative; }
.map-wrap { flex: 1; position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: #dfe5ea; }

.panel {
  flex: none; width: var(--panel-width); display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-right: 1px solid var(--line); z-index: 1000;
}
.panel-toggle { display: none; }
.list-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.search { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.search input {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid #c3c9d1; border-radius: 8px; background: #fff; color: var(--ink);
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.list-empty { padding: 16px; color: var(--muted); margin: 0; }
.row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 12px; background: none; border: 0; border-bottom: 1px solid var(--line);
}
.row:hover { background: #f3f6f9; }
.row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.row.selected { background: #e6f0fa; }
.row-text { min-width: 0; display: flex; flex-direction: column; }
.row-text strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-text span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.stale .row-text span { color: #9a6700; }
.row.waiting .chip, .row.stale .chip { opacity: .45; }

.chip {
  flex: none; min-width: 34px; height: 34px; padding: 0 6px; border-radius: 17px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25);
}

/* ---- selected vehicle card --------------------------------------------- */

.card { padding: 12px; border-bottom: 1px solid var(--line); background: #f7f9fb; }
.card-head { display: flex; align-items: center; gap: 10px; }
.card-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.card-title strong { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title span { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-status { margin: 8px 0 10px; font-size: 14px; }
.card-status.stale { color: #9a6700; font-weight: 600; }
.card-actions { display: flex; gap: 8px; }
.card-actions button, .map-buttons button {
  padding: 7px 12px; border-radius: 8px; border: 1px solid #c3c9d1; background: #fff;
}
.card-actions button:hover, .map-buttons button:hover { background: #f0f3f6; }
.card-actions button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.icon-button { flex: none; width: 34px; height: 34px; border-radius: 50%; border: 0; background: none; font-size: 16px; color: var(--muted); }
.icon-button:hover { background: #e7ebf0; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

.map-buttons { position: absolute; left: 12px; top: 12px; z-index: 900; display: flex; gap: 8px; }
.map-buttons button { box-shadow: 0 1px 4px rgba(0,0,0,.3); font-size: 14px; }
.noscript { position: absolute; inset: 40% 10% auto; text-align: center; background: #fff; padding: 16px; border-radius: 8px; z-index: 2000; }

.pin-wrap { background: none; border: 0; }
.pin {
  position: relative; width: 34px; height: 34px; border-radius: 50%;
  background: var(--pin); color: var(--ink);
  border: 2.5px solid #fff; box-shadow: 0 1px 5px rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  font: 700 13px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: transform .15s;
}
.pin-label { position: relative; letter-spacing: -.02em; }
.pin.stale { filter: grayscale(.85); opacity: .6; border-style: dashed; }
.pin.stale.selected { opacity: .9; }
.pin.selected { transform: scale(1.25); box-shadow: 0 0 0 4px rgba(29,111,184,.35), 0 2px 8px rgba(0,0,0,.5); }
/* A small arrowhead that orbits the pin to show the direction of travel. */
.pin-arrow { position: absolute; inset: -9px; pointer-events: none; }
.pin-arrow::before {
  content: ""; position: absolute; left: 50%; top: -3px; margin-left: -6px;
  border: 6px solid transparent; border-top: 0; border-bottom: 9px solid var(--pin);
  filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 1px #fff);
}

.checkpoint-wrap { background: none; border: 0; }
.checkpoint { display: block; width: 14px; height: 14px; background: #fff; border: 3px solid #16202b; transform: rotate(45deg); }
.leaflet-tooltip.checkpoint-label {
  background: rgba(255,255,255,.92); border: 0; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  font-weight: 600; font-size: 12px; padding: 2px 6px; color: #16202b;
}
.leaflet-tooltip.checkpoint-label::before { display: none; }

/* ---- embedded in another page (?embed=1) -------------------------------- */

body.embed .bar { padding: 6px 12px; }
body.embed .bar h1 { font-size: 14px; }

/* ---- phones: the panel becomes a sheet at the bottom --------------------- */

@media (max-width: 720px) {
  .bar h1 { font-size: 15px; }
  .status { font-size: 12px; }
  .panel {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; max-height: 70%;
    border-right: 0; border-radius: 14px 14px 0 0; box-shadow: 0 -2px 14px rgba(0,0,0,.25);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .panel-toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    padding: 13px 16px; background: none; border: 0; font-weight: 600;
  }
  .chevron { width: 9px; height: 9px; border: solid var(--muted); border-width: 2px 2px 0 0; transform: rotate(-45deg); margin-top: 4px; transition: transform .2s; }
  .panel.open .chevron { transform: rotate(135deg); margin-top: -4px; }
  .list-area { display: none; }
  .panel.open .list-area { display: flex; height: 55vh; border-top: 1px solid var(--line); }
  .card { border-radius: 14px 14px 0 0; }
  .panel.open .card { display: none; }
  .leaflet-bottom { bottom: 52px; }
  body.has-selection .leaflet-bottom { bottom: 176px; }
}
