:root {
  --bg: #0e1116;
  --panel: #161b22;
  --card: #1c2230;
  --line: #2a3142;
  --text: #e6edf3;
  --muted: #8b97a8;
  --accent: #36c5f0;
  --ontime: #3fb950;
  --late: #f85149;
  --early: #d29922;
  --unknown: #6e7681;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
}
header {
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 20px; letter-spacing: -0.3px; }
.pulse {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(54,197,240,0.7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(54,197,240,0.6); }
  70% { box-shadow: 0 0 0 12px rgba(54,197,240,0); }
  100% { box-shadow: 0 0 0 0 rgba(54,197,240,0); }
}
.tag { color: var(--muted); font-size: 13px; margin-top: 4px; }

.views { display: flex; gap: 6px; margin-left: 18px; }
.view-btn {
  background: var(--card); color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.view-btn:hover { color: var(--text); }
.view-btn.active { background: var(--accent); color: #00222e; font-weight: 600; }

.city-bar {
  display: flex; gap: 8px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.city-btn {
  background: var(--card); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: all .15s;
}
.city-btn:hover { border-color: var(--accent); }
.city-btn.active { background: var(--accent); color: #00222e; font-weight: 600; border-color: var(--accent); }
.city-btn .country { color: var(--muted); font-size: 11px; }
.city-btn.active .country { color: #00384a; }

main { flex: 1; display: flex; min-height: 0; }
main[hidden] { display: none; }
#map { flex: 1; background: #0a0d12; }

#panel {
  width: 340px; background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto; padding: 14px;
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px; margin-bottom: 14px;
}
.card h2 { font-size: 17px; }
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 12px; line-height: 1.5; }

#feed-health { font-size: 12px; margin-top: 6px; }
#feed-health.ok { color: var(--ontime); }
#feed-health.down { color: var(--late); }

.now-grid { display: flex; gap: 8px; margin: 12px 0 8px; }
.now { flex: 1; text-align: center; background: var(--bg); border-radius: 8px; padding: 8px 4px; }
.big { font-size: 22px; font-weight: 700; display: block; }
.big.bad { color: var(--late); }
.now label { font-size: 10px; color: var(--muted); text-transform: uppercase; }

.windows { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.win-btn {
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 9px; font-size: 12px; cursor: pointer;
}
.win-btn:hover { color: var(--text); }
.win-btn.active { background: var(--accent); color: #00222e; font-weight: 600; }

.stat-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.stat-row:last-child { border-bottom: none; }
.stat-row .v { font-weight: 600; }
.bar { height: 8px; border-radius: 4px; overflow: hidden; display: flex; margin: 8px 0 12px; background: var(--bg); }
.bar span { display: block; height: 100%; }
.empty-note { color: var(--early); font-size: 12px; margin-top: 8px; }

.route { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }

/* ─────────── compare view ─────────── */
.cmp-wrap { flex: 1; overflow-y: auto; padding: 16px; max-width: 1100px; margin: 0 auto; width: 100%; }
.cmp-cities { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 13px; font-size: 13px; cursor: pointer; transition: all .12s;
}
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.on { background: var(--accent); color: #00222e; font-weight: 600; border-color: var(--accent); }
.cmp-actions { display: flex; gap: 8px; margin-top: 10px; }
.mini-btn {
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.mini-btn:hover { color: var(--text); }

.highlights { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.hl {
  flex: 1; min-width: 160px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px;
}
.hl label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.hl-v { display: block; font-size: 22px; font-weight: 700; color: var(--accent); margin: 4px 0 2px; }
.hl-c { font-size: 13px; color: var(--text); }

#cmp-output { overflow-x: auto; }
table.cmp { width: 100%; border-collapse: collapse; font-size: 13px; }
table.cmp th {
  text-align: right; padding: 8px 10px; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.cmp th:nth-child(2) { text-align: left; }
table.cmp td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.cmp td.city { text-align: left; font-weight: 600; }
table.cmp td.v { color: var(--accent); font-weight: 700; }
table.cmp td.bad { color: var(--late); font-weight: 600; }
table.cmp tbody tr:hover { background: var(--card); }
.barcell { width: 90px; }
.minibar { display: block; height: 8px; background: var(--accent); border-radius: 4px; min-width: 2px; }

.legend ul { list-style: none; }
.legend li { font-size: 12px; padding: 3px 0; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.on_time { background: var(--ontime); }
.dot.late { background: var(--late); }
.dot.early { background: var(--early); }
.dot.unknown { background: var(--unknown); }

footer {
  padding: 8px 20px; font-size: 11px; color: var(--muted);
  background: var(--panel); border-top: 1px solid var(--line);
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--card); color: var(--text); }
.leaflet-popup-content { font-size: 12px; }

@media (max-width: 720px) {
  main { flex-direction: column; }
  #panel { width: 100%; border-left: none; border-top: 1px solid var(--line); }
  #map { min-height: 50vh; }
}
