* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex; height: 100vh; overflow: hidden; background: #0f172a; color: #f8fafc;
}
#sidebar {
  width: 380px; min-width: 380px; background: #0f172a; padding: 18px; display: flex; flex-direction: column;
  gap: 12px; border-right: 1px solid #334155; z-index: 1001; overflow-y: auto; box-shadow: 4px 0 12px rgba(0,0,0,.3);
}
#map-container { position: relative; flex: 1; height: 100%; }
#map { width: 100%; height: 100%; background: #e2e8f0; }

#playbar {
  position: absolute; top: 16px; left: 16px; right: 16px; z-index: 1000; background: rgba(15,23,42,.92);
  backdrop-filter: blur(8px); border: 1px solid #334155; border-radius: 10px; padding: 10px 18px;
  display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 25px -5px rgba(0,0,0,.5);
}
.playbar-btn {
  background: #2563eb; color: #fff; border: none; border-radius: 6px; padding: 6px 14px; font-weight: 600;
  font-size: .85rem; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: background .15s, transform .1s;
}
.playbar-btn:hover { background: #1d4ed8; }
.playbar-btn:active { transform: scale(.96); }
.playbar-btn.secondary { background: #334155; color: #cbd5e1; padding: 6px 10px; }
.playbar-btn.secondary:hover { background: #475569; color: #fff; }
.playbar-time-info { display: flex; flex-direction: column; font-family: monospace; font-size: .75rem; color: #38bdf8; min-width: 210px; line-height: 1.3; }
.timeline-slider-container { flex: 1; display: flex; align-items: center; }
select.speed-select { background: #1e293b; border: 1px solid #334155; color: #cbd5e1; padding: 6px 8px; border-radius: 6px; font-size: .78rem; outline: none; cursor: pointer; }

h2 { font-size: 1.1rem; color: #f1f5f9; border-bottom: 1px solid #334155; padding-bottom: 6px; font-weight: 700; }
.section-title { font-size: .72rem; text-transform: uppercase; color: #94a3b8; font-weight: 700; letter-spacing: .5px; margin-top: 2px; }
.hint { font-size: .7rem; color: #94a3b8; }
.control-group { display: flex; flex-direction: column; gap: 4px; }
.label-val { display: flex; justify-content: space-between; font-size: .8rem; color: #cbd5e1; }
input[type="range"] { width: 100%; accent-color: #2563eb; cursor: pointer; }
select, input[type="number"], input[type="date"] {
  background: #1e293b; border: 1px solid #334155; color: #f8fafc; padding: 7px 10px; border-radius: 6px; font-size: .82rem; outline: none; width: 100%;
}
select:focus, input:focus { border-color: #2563eb; }
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
button.btn-primary { background: #2563eb; color: #fff; border: none; padding: 8px; border-radius: 6px; font-weight: 600; font-size: .82rem; cursor: pointer; transition: background .2s; margin-top: 2px; }
button.btn-primary:hover { background: #1d4ed8; }
.checkbox-group { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: #cbd5e1; cursor: pointer; }
.checkbox-group input { width: 15px; height: 15px; accent-color: #2563eb; cursor: pointer; }

.status-msg { font-size: .75rem; padding: 8px; border-radius: 6px; display: none; line-height: 1.3; }
.status-msg.loading { display: block; background: #1e3a8a; color: #93c5fd; border: 1px solid #3b82f6; }
.status-msg.warn { display: block; background: #422006; color: #fcd34d; border: 1px solid #d97706; }
.status-msg.error { display: block; background: #450a0a; color: #fca5a5; border: 1px solid #ef4444; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stats-card { background: #1e293b; padding: 8px 10px; border-radius: 6px; border-left: 3px solid #2563eb; }
.stats-card.alert { border-left-color: #dc2626; }
.stats-title { font-size: .65rem; color: #94a3b8; text-transform: uppercase; }
.stats-value { font-size: 1.1rem; font-weight: bold; color: #f8fafc; margin-top: 2px; }

.legend { background: #1e293b; padding: 10px; border-radius: 6px; border: 1px solid #334155; font-size: .75rem; line-height: 1.4; color: #94a3b8; }
.legend-gradient-events { height: 7px; border-radius: 4px; background: linear-gradient(to right, blue, cyan, lime, yellow, red); margin: 4px 0; }
.legend-gradient-cusum { height: 7px; border-radius: 4px; background: linear-gradient(to right, rgba(168,85,247,.3), #d946ef, #ef4444, #facc15); margin: 4px 0; }
.legend-labels { display: flex; justify-content: space-between; font-size: .65rem; color: #94a3b8; }
.legend-item { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.legend-color { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

#timeline {
  position: absolute; left: 16px; right: 16px; bottom: 16px; height: 84px; z-index: 1000; background: rgba(15,23,42,.92);
  backdrop-filter: blur(8px); border: 1px solid #334155; border-radius: 10px; padding: 6px 10px 4px; display: flex; flex-direction: column; gap: 3px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,.5);
}
#timeline-canvas { flex: 1; width: 100%; min-height: 0; cursor: ew-resize; touch-action: none; }
#timeline-hint { font-size: .66rem; color: #94a3b8; text-align: center; user-select: none; }
.leaflet-bottom.leaflet-right { margin-bottom: 104px; }
.kernel-layer { position: absolute; left: 0; top: 0; }
.stats-card.alert .stats-value { color: #fca5a5; }
