:root {
  --bg: #14161a;
  --panel: #1b1e24;
  --line: #2b3039;
  --text: #e8eaee;
  --muted: #9aa3b0;
  --accent: #ff5a36;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: grid;
  grid-template-columns: 340px 1fr;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
#map { height: 100%; }
#panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
header { padding: 16px 16px 8px; }
h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.live {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  vertical-align: 2px;
}
#status { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
#status.stale { color: #ffb020; }

#filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px 12px; border-bottom: 1px solid var(--line); }
#filters button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit; font-size: 12px;
  cursor: pointer;
}
#filters button[aria-pressed="false"] { color: var(--muted); opacity: 0.55; }
#filters .n { color: var(--muted); font-variant-numeric: tabular-nums; }

ol { list-style: none; margin: 0; padding: 0; }
#list { flex: 1; overflow-y: auto; }
#list:empty::after { content: "No active incidents."; display: block; padding: 16px; color: var(--muted); }
li.incident {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 2px 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
li.incident:hover, li.incident.selected { background: #232832; }
li.incident .dot { width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; }
li.incident .type { font-weight: 600; }
li.incident .when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
li.incident .where, li.incident .units { grid-column: 2 / 4; color: var(--muted); font-size: 12px; }
li.incident .alarm { color: #ffb020; font-weight: 600; }
li.incident.is-cleared { opacity: 0.6; }

#cleared-wrap { border-top: 1px solid var(--line); max-height: 35%; overflow-y: auto; }
#cleared-wrap summary { padding: 10px 16px; color: var(--muted); cursor: pointer; }

footer { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.legend { display: grid; grid-template-columns: 20px 1fr; gap: 4px 8px; margin: 0 0 8px; align-items: center; }
.legend dd { margin: 0; }
.key { display: block; width: 14px; height: 14px; border-radius: 50%; }
.key.exact { background: var(--accent); border: 2px solid #fff; }
.key.approx { background: color-mix(in srgb, var(--accent) 35%, transparent); border: 2px solid var(--accent); }
.key.area { background: #2ec4b6; opacity: 0.35; filter: blur(1px); }
.key.line { height: 0; border-radius: 0; border-top: 2px dashed var(--text); }
.source { margin: 0 0 8px; }
.source a { color: var(--muted); }
#theme {
  padding: 3px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: transparent; color: var(--text); font: inherit; cursor: pointer;
}

.maplibregl-popup-content {
  background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; font-size: 13px; min-width: 220px;
}
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; }
.popup h2 { margin: 0 0 2px; font-size: 15px; }
.popup .meta { color: var(--muted); margin: 0 0 8px; }
.popup .note { color: var(--muted); font-size: 12px; font-style: italic; margin: 6px 0 0; }
.popup ul { margin: 4px 0 0; padding-left: 16px; }

@media (max-width: 720px) {
  body { grid-template-columns: 1fr; grid-template-rows: 55% 45%; }
  #map { grid-row: 1; }
  #panel { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); }
}
