:root {
  --bg: #0f1720;
  --panel: #172230;
  --panel-2: #1e2c3d;
  --text: #e6edf3;
  --muted: #8aa0b5;
  --accent: #4cc2ff;
  --border: #26374a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
}

#sidebar {
  width: 360px;
  min-width: 300px;
  height: 100%;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#sidebar header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
}
#subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--accent); cursor: pointer; }

.card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.card h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }
.card-head { display: flex; align-items: center; justify-content: space-between; }

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

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 14px; }
.kv .k { color: var(--muted); }
.kv .v { text-align: right; font-variant-numeric: tabular-nums; }

#live-body .big {
  font-size: 15px;
  margin-bottom: 6px;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #14351f;
  color: #57d98a;
  border: 1px solid #1f5333;
}
.badge.stale { background: #3a2a12; color: #e0a94b; border-color: #5a4520; }

#stage-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.stage-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.stage-item:hover { background: #223247; border-color: var(--accent); }
.stage-item .swatch { width: 12px; height: 12px; border-radius: 3px; flex: 0 0 auto; }
.stage-item .info { flex: 1; min-width: 0; }
.stage-item .date { font-size: 14px; font-weight: 600; }
.stage-item .sub { font-size: 12px; color: var(--muted); }

.chart-wrap { position: relative; height: 150px; margin-top: 8px; }
#elev-sub { font-size: 12px; margin-top: 2px; }

#map { flex: 1; height: 100%; }

footer { margin-top: auto; }

.stop-icon { }

/* Live position marker: pulsing dot */
.live-dot {
  width: 16px; height: 16px;
  background: var(--accent);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(76, 194, 255, 0.6);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(76, 194, 255, 0.55); }
  70%  { box-shadow: 0 0 0 16px rgba(76, 194, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(76, 194, 255, 0); }
}

/* Break / overnight (tracker off) marker */
.gap-dot {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  background: #6b7b8c;
  color: #fff;
  border: 2px solid #fff;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  font-style: italic;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.leaflet-popup-content { font-size: 13px; }

@media (max-width: 720px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; min-width: 0; height: 45%; border-right: none; border-bottom: 1px solid var(--border); }
  #map { height: 55%; }
}
