:root {
  --bg: #0b0e14;
  --card: #12161f;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --faint: #6b7280;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --text: #111827;
    --muted: #4b5563;
    --faint: #6b7280;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 14px 18px;
}
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: 0.02em; }
.status-line { font-size: 13px; color: var(--faint); }

.truck-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 18px 10px;
}
.truck-buttons button {
  padding: 2px 6px;
  font-size: 11px;
  line-height: 1.5;
  border-radius: 5px;
  border: 1px solid rgba(128, 128, 128, 0.35);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
}
.truck-buttons button.active {
  background: #f43f5e;
  border-color: #f43f5e;
  color: #fff;
}

.map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 12px;
}
.map-canvas {
  position: absolute;
  inset: 0;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}
.map-canvas svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.map-canvas svg:active { cursor: grabbing; }
.map-canvas svg { shape-rendering: geometricPrecision; }

.machine-loading, .machine-miss {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 15px; margin: 0;
}

.map-zoom {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-zoom button {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(128, 128, 128, 0.3);
  background: var(--card);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.map-zoom button:active { transform: scale(0.95); }

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 18px 0;
  font-size: 13px;
  color: var(--muted);
}
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot-truck { background: #22d3ee; }
.dot-loader { background: #fbbf24; }
.dot-cat980 { background: #f97316; }
.dot-other { background: #52525b; }

.map-info {
  padding: 6px 18px 16px;
  font-size: 13px;
  color: var(--faint);
  min-height: 1.4em;
}

.map-canvas .roads polyline {
  fill: none;
  stroke: rgba(128, 128, 128, 0.35);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}
.map-canvas circle { cursor: pointer; }
.map-canvas .dot-truck { fill: #22d3ee; }
.map-canvas .dot-loader { fill: #fbbf24; }
.map-canvas .dot-cat980 { fill: #f97316; }
.map-canvas .dot-other { fill: #52525b; }
.map-canvas circle {
  transition: cx 1.2s linear, cy 1.2s linear;
}
@media (prefers-reduced-motion: reduce) {
  .map-canvas circle { transition: none; }
}
.map-canvas .moving { opacity: 1; }
.map-canvas circle:not(.moving) { opacity: 0.55; }

/* Sonar-style ping ring around a toggled truck — separate from the dot so its
   own colour (kind) never changes, just a red ring pulsing around it. */
.ping-ring {
  fill: none;
  stroke: #f43f5e;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: ping-pulse 1.8s ease-out infinite;
}
@keyframes ping-pulse {
  0% { transform: scale(0.8); opacity: 0.9; }
  70%, 100% { transform: scale(1.35); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ping-ring { animation: none; opacity: 0.9; }
}
