* {
  box-sizing: border-box;
}

:root {
  --bg: #0d1117;
  --panel: #141a22;
  --panel2: #1a222d;
  --text: #eef2f6;
  --muted: #9da8b6;
  --line: #2a3441;
  --accent: #f2f4f8;
  --danger: #ff4d4f;
  --major: #ff8a00;
  --serious: #ffd166;
  --minor: #6cc4ff;
  --ok: #38c172;
}

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

body {
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100vh;
}

.topbar {
  min-height: 74px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.4px;
}

.subtitle {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.status-wrap {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.live {
  background: var(--ok);
}

.status-dot.error {
  background: var(--danger);
}

.controls {
  min-height: 58px;
  padding: 10px 14px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  background: var(--panel2);
  border-bottom: 1px solid var(--line);
}

label {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

button, select {
  border: 1px solid var(--line);
  background: #222b36;
  color: var(--text);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
}

button {
  cursor: pointer;
  background: var(--accent);
  color: #111;
  font-weight: 700;
}

button.secondary {
  background: #222b36;
  color: var(--text);
}

button.compact {
  padding: 6px 9px;
  font-size: 12px;
}

main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
}

#map {
  width: 100%;
  height: 100%;
  background: #10141a;
}

.panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel.hidden {
  display: none;
}

.panel-header {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.muted {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.incident-list {
  overflow-y: auto;
  padding: 8px;
}

.incident-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #111720;
  padding: 11px;
  margin-bottom: 8px;
  cursor: pointer;
}

.incident-card:hover {
  background: #18202a;
}

.incident-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
  color: #111;
}

.badge.major { background: var(--danger); color: white; }
.badge.serious { background: var(--major); }
.badge.moderate { background: var(--serious); }
.badge.minor { background: var(--minor); }

.road {
  margin-top: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.details {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.distance {
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}

footer {
  padding: 6px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel);
  font-size: 11px;
  text-align: center;
}

.accident-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,.35);
}

.marker-major { background: var(--danger); }
.marker-serious { background: var(--major); }
.marker-moderate { background: var(--serious); }
.marker-minor { background: var(--minor); }

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #151c25;
  color: var(--text);
}

@media (max-width: 800px) {
  body { overflow: auto; }

  #app {
    height: auto;
    min-height: 100vh;
  }

  main {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh auto;
  }

  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 40vh;
  }
}
