:root {
  --bg: #07090d;
  --panel: rgba(12, 16, 24, 0.82);
  --panel-border: rgba(140, 160, 190, 0.18);
  --text: #e8edf5;
  --muted: #8b97a8;
  --accident: #ff5a3c;
  --accident-soft: rgba(255, 90, 60, 0.22);
  --police: #3db8ff;
  --police-soft: rgba(61, 184, 255, 0.2);
  --live: #38d39f;
  --glow: rgba(61, 184, 255, 0.35);
  --font-display: "Orbitron", sans-serif;
  --font-ui: "Manrope", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 70% -10%, rgba(61, 184, 255, 0.08), transparent 55%),
    radial-gradient(900px 500px at 10% 100%, rgba(255, 90, 60, 0.06), transparent 50%),
    linear-gradient(180deg, #0a0e16 0%, var(--bg) 45%, #05070b 100%);
  overflow: hidden;
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.015) 0px,
    rgba(255, 255, 255, 0.015) 1px,
    transparent 2px,
    transparent 4px
  );
  mix-blend-mode: overlay;
  opacity: 0.35;
}

.vignette {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem 0.5rem;
  background: linear-gradient(180deg, rgba(5, 8, 12, 0.92), rgba(5, 8, 12, 0));
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  letter-spacing: 0.18em;
  text-shadow: 0 0 24px rgba(61, 184, 255, 0.25);
}

.tagline {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.top-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--live);
  border: 1px solid rgba(56, 211, 159, 0.35);
  background: rgba(56, 211, 159, 0.08);
  padding: 0.2rem 0.55rem;
  letter-spacing: 0.12em;
}

.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--live);
  box-shadow: 0 0 10px var(--live);
  animation: pulse 1.6s infinite;
}

.city, .active-count { color: var(--muted); }
.active-count { color: #c7d2e0; }

.filters {
  position: fixed;
  top: 5.4rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  gap: 0.45rem;
  max-width: calc(100vw - 2rem);
  overflow-x: auto;
  padding: 0.2rem;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }

.filter-btn {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  padding: 0.55rem 0.95rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}
.filter-btn:hover { border-color: rgba(200, 220, 255, 0.35); }
.filter-btn.active {
  border-color: rgba(61, 184, 255, 0.55);
  box-shadow: 0 0 18px rgba(61, 184, 255, 0.18);
  background: rgba(20, 30, 44, 0.92);
}
.filter-btn[data-type="accident"].active {
  border-color: rgba(255, 90, 60, 0.6);
  box-shadow: 0 0 18px rgba(255, 90, 60, 0.18);
}
.filter-btn[data-type="police"].active {
  border-color: rgba(61, 184, 255, 0.65);
}

.map-shell {
  position: fixed;
  inset: 0;
  z-index: 1;
}
#map { width: 100%; height: 100%; background: #0b1018; }

.leaflet-container { background: #0b1018; font: inherit; }
.leaflet-control-zoom a {
  background: rgba(12, 16, 24, 0.9) !important;
  color: var(--text) !important;
  border-color: var(--panel-border) !important;
}
.leaflet-control-attribution {
  background: rgba(0, 0, 0, 0.45) !important;
  color: #7d8796 !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: #9aa7ba !important; }

/* Darken OSM tiles */
.leaflet-tile-pane { filter: grayscale(0.35) brightness(0.55) contrast(1.15) saturate(0.7); }

.hud-corners .c {
  position: absolute;
  width: 28px; height: 28px;
  border: 1.5px solid rgba(160, 180, 210, 0.28);
  z-index: 20;
  pointer-events: none;
}
.hud-corners .tl { top: 5.8rem; left: 1rem; border-right: 0; border-bottom: 0; }
.hud-corners .tr { top: 5.8rem; right: 1rem; border-left: 0; border-bottom: 0; }
.hud-corners .bl { bottom: 1.2rem; left: 1rem; border-right: 0; border-top: 0; }
.hud-corners .br { bottom: 1.2rem; right: 1rem; border-left: 0; border-top: 0; }

.side-panel {
  position: fixed;
  top: 6.8rem;
  right: 1.1rem;
  width: min(340px, calc(100vw - 2rem));
  max-height: calc(100vh - 8rem);
  z-index: 25;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow: hidden;
  animation: panelIn 0.45s ease-out;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-title {
  font-family: var(--font-display);
  font-size: 0.82rem;
  letter-spacing: 0.14em;
}
.panel-close {
  display: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.stat {
  border: 1px solid var(--panel-border);
  padding: 0.65rem 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--font-mono);
}
.stat .label { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.08em; }
.stat span:last-child { font-size: 1.25rem; font-weight: 600; }
.stat.accident { border-color: rgba(255, 90, 60, 0.35); box-shadow: inset 0 0 20px var(--accident-soft); }
.stat.police { border-color: rgba(61, 184, 255, 0.35); box-shadow: inset 0 0 20px var(--police-soft); }
.total-line { color: var(--muted); font-size: 0.85rem; }
.total-line strong { color: var(--text); font-family: var(--font-mono); }
.list-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 0.2rem;
}

.event-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-right: 0.2rem;
}

.event-item {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.02);
  padding: 0.65rem 0.7rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
}
.event-item:hover {
  border-color: rgba(200, 220, 255, 0.35);
  transform: translateY(-1px);
}
.event-item .etype {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.2rem;
}
.event-item.accident .etype { color: var(--accident); }
.event-item.police .etype { color: var(--police); }
.event-item .place { font-weight: 600; font-size: 0.92rem; }
.event-item .ago { color: var(--muted); font-family: var(--font-mono); font-size: 0.72rem; margin-top: 0.25rem; }

.disclaimer {
  font-size: 0.7rem;
  line-height: 1.4;
  color: #6d7888;
  border-top: 1px solid rgba(140, 160, 190, 0.12);
  padding-top: 0.65rem;
}

.fab-panel {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 1.1rem;
  transform: translateX(-50%);
  z-index: 28;
  border: 1px solid var(--panel-border);
  background: rgba(12, 16, 24, 0.92);
  color: var(--text);
  font-family: var(--font-mono);
  letter-spacing: 0.1em;
  padding: 0.75rem 1.4rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}
.detail-backdrop.open { opacity: 1; pointer-events: auto; }

.detail-sheet {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  width: min(380px, calc(100vw - 2rem));
  z-index: 36;
  background: rgba(10, 14, 22, 0.94);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  padding: 1rem 1.05rem 1.15rem;
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.28s ease, opacity 0.28s ease;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.detail-sheet.open { transform: translateY(0); opacity: 1; }
.sheet-handle {
  width: 42px; height: 3px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 auto 0.75rem;
  border-radius: 2px;
}

.detail-type {
  font-family: var(--font-mono);
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  margin-bottom: 0.35rem;
}
.detail-type.accident { color: var(--accident); }
.detail-type.police { color: var(--police); }
.detail-address {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.detail-landmark { color: var(--muted); margin-top: 0.15rem; }
.detail-desc { margin: 0.7rem 0; color: #d5dce8; line-height: 1.45; }
.meta-grid {
  display: grid;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #b7c2d1;
}
.meta-grid strong { color: var(--text); font-weight: 500; }
.conf-high { color: #38d39f; }
.conf-medium { color: #e6c35c; }
.conf-low { color: #ff6b6b; }

.actions { display: flex; gap: 0.5rem; margin-top: 0.9rem; flex-wrap: wrap; }
.btn {
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
}
.btn.primary {
  border-color: rgba(61, 184, 255, 0.45);
  background: rgba(61, 184, 255, 0.1);
}

.marker-wrap {
  position: relative;
  width: 18px; height: 18px;
}
.marker-core {
  width: 12px; height: 12px;
  border-radius: 50%;
  position: absolute;
  top: 3px; left: 3px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 10px currentColor;
}
.marker-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid currentColor;
  animation: radarPulse 2.2s ease-out infinite;
  opacity: 0.7;
}
.marker-wrap.accident { color: var(--accident); }
.marker-wrap.police { color: var(--police); }
.marker-wrap.fresh .marker-core { animation: popIn 0.45s ease-out; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 5rem;
  transform: translateX(-50%) translateY(20px);
  background: rgba(12, 16, 24, 0.95);
  border: 1px solid var(--panel-border);
  padding: 0.65rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@keyframes radarPulse {
  0% { transform: scale(0.6); opacity: 0.7; }
  100% { transform: scale(2.4); opacity: 0; }
}
@keyframes popIn {
  0% { transform: scale(0.2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes panelIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 860px) {
  .side-panel {
    top: auto;
    right: 0; left: 0;
    bottom: 0;
    width: 100%;
    max-height: 48vh;
    border-radius: 14px 14px 0 0;
    transform: translateY(110%);
    transition: transform 0.28s ease;
    animation: none;
  }
  .side-panel.open { transform: translateY(0); }
  .panel-close { display: block; }
  .fab-panel { display: block; }
  .hud-corners .c { display: none; }
  .detail-sheet {
    left: 0; right: 0; bottom: 0;
    width: 100%;
    border-radius: 14px 14px 0 0;
  }
  .topbar { padding-right: 1rem; }
  .brand { letter-spacing: 0.12em; font-size: 1.2rem; }
}
