:root {
  --bg: #0b0e13;
  --panel: #121722;
  --panel-head: #182030;
  --border: #263042;
  --text: #dfe6f0;
  --muted: #8b97ab;
  --accent: #39b3ff;
  --accent-dim: #1d5c86;
}

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

/* --- top bar --- */
#topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 8px 16px; background: var(--panel-head);
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.brand { font-weight: 600; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 8px var(--accent); }
.layout-group, .play-group { display: flex; gap: 4px; align-items: center; }
button {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 10px; cursor: pointer; font-size: 14px;
}
button:hover { border-color: var(--accent-dim); }
.layout-group button.active,
#archiveBtn.active { background: var(--accent-dim); border-color: var(--accent); }
.speed { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 5px; }
select {
  background: var(--panel); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 6px; font-size: 12.5px; max-width: 160px;
}
.clock { margin-left: auto; text-align: right; }
#frameTime { font-variant-numeric: tabular-nums; font-weight: 600; }
.clock .sub { display: block; font-size: 11px; color: var(--muted); }

/* --- grid --- */
#grid { flex: 1 1 auto; display: grid; gap: 4px; padding: 4px; min-height: 0; }
#grid.layout-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
#grid.layout-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
#grid.layout-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
#grid.layout-1 .panel:nth-child(n+2),
#grid.layout-2 .panel:nth-child(n+3) { display: none; }

.panel {
  display: flex; flex-direction: column; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden; min-height: 0;
}
.panel-head {
  display: flex; gap: 6px; align-items: center; padding: 6px 8px;
  background: var(--panel-head); border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.hover-readout {
  margin-left: auto; font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 46%;
}
.hover-readout b { color: var(--text); }
.panel .map { flex: 1 1 auto; min-height: 0; background: #05070a; position: relative; }

/* loading / no-data overlay shown while a product renders */
.map-loading {
  position: absolute; inset: 0; z-index: 800; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: rgba(5, 7, 10, .55); pointer-events: none;
}
.map-loading.show { display: flex; }
.map-loading .spinner {
  width: 34px; height: 34px; border: 3px solid rgba(255, 255, 255, .18);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite;
}
.map-loading.nodata .spinner { display: none; }
.map-loading span { font-size: 12px; color: var(--text); background: rgba(11,14,19,.7);
  padding: 2px 8px; border-radius: 5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- legend --- */
.legend { flex: 0 0 auto; height: 26px; display: flex; align-items: center;
  gap: 8px; padding: 0 10px; background: var(--panel-head);
  border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.legend .bar { flex: 1 1 auto; height: 10px; border-radius: 3px;
  border: 1px solid var(--border); }
.legend .lbl { font-variant-numeric: tabular-nums; }

/* --- timeline --- */
#timeline { flex: 0 0 auto; padding: 8px 16px 10px; background: var(--panel-head);
  border-top: 1px solid var(--border); }
#timeSlider { width: 100%; accent-color: var(--accent); cursor: pointer; }
.ticks { display: flex; justify-content: space-between; font-size: 10px;
  color: var(--muted); margin-top: 2px; }

/* Leaflet dark tweaks */
.leaflet-container { background: #05070a; }
.leaflet-control-attribution { font-size: 9px; background: rgba(0,0,0,.5) !important;
  color: #6b7688 !important; }
.leaflet-control-attribution a { color: #8b97ab !important; }
.radar-overlay { image-rendering: pixelated; }
.radar-tip {
  background: rgba(11, 14, 19, .85); color: #ffd23f; border: 1px solid #ffd23f;
  border-radius: 4px; font-size: 11px; font-weight: 600; padding: 1px 5px;
  box-shadow: none;
}
.radar-tip::before { display: none; }         /* hide tooltip arrow */
.leaflet-tooltip.radar-tip { white-space: nowrap; }
