:root {
  --bg: #f7f7f5;
  --panel: #ffffff;
  --ink: #1d1f22;
  --muted: #6b7078;
  --line: #e3e3df;
  --now: #d6363a;
  --today: #ee8a1b;
  --week: #d9b300;
  --later: #8c96a3;
  --selected: #1f5fbf;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  display: grid;
  grid-template-columns: 400px 1fr;
  background: var(--bg);
}

#panel {
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px;
}

#map { height: 100vh; }

h1 { font-size: 18px; margin: 0 0 4px; }
h2 { font-size: 14px; margin: 20px 0 8px; }
.muted { color: var(--muted); font-weight: normal; }

.controls { margin-top: 12px; display: grid; gap: 10px; }
.radius { display: grid; gap: 4px; }
.radius input { width: 100%; }

.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.toggles label {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border: 1px solid var(--line); border-radius: 12px;
  cursor: pointer; user-select: none;
}
.toggles input { margin: 0; }

.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.bucket-now { --c: var(--now); }
.bucket-today { --c: var(--today); }
.bucket-week { --c: var(--week); }
.bucket-later, .bucket-expired { --c: var(--later); }
.swatch, .chip { background: var(--c); }

#airfields { display: grid; gap: 8px; margin-top: 16px; }
.airfield {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  cursor: pointer; background: var(--panel); text-align: left; font: inherit; color: inherit;
}
.airfield.selected { border-color: var(--selected); box-shadow: 0 0 0 1px var(--selected); }
.airfield .title { display: flex; justify-content: space-between; align-items: baseline; }
.airfield .icao { font-weight: 700; font-size: 15px; }
.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.count { border-left: 3px solid var(--c); padding-left: 6px; }
.count b { font-size: 20px; display: block; line-height: 1.1; }
.count small { color: var(--muted); display: block; }
.extras { margin-top: 6px; color: var(--muted); font-size: 12px; }

.notams { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.notam {
  border: 1px solid var(--line); border-left: 4px solid var(--c);
  border-radius: 6px; padding: 8px 10px; cursor: pointer;
}
.notam.focused { border-color: var(--selected); border-left-color: var(--c); }
.notam .head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.notam .id { font-weight: 700; }
.notam .when { font-size: 12px; }
.notam .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.notam pre {
  white-space: pre-wrap; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace;
  margin: 6px 0 0; max-height: 4.2em; overflow: hidden;
}
.notam.open pre { max-height: none; }
.flag { font-size: 11px; padding: 0 5px; border-radius: 3px; background: #eceae4; color: #5a5a55; }
.chip { font-size: 11px; padding: 0 6px; border-radius: 3px; color: #fff; }

footer { margin-top: 24px; font-size: 12px; line-height: 1.5; word-break: break-all; }

.maplibregl-popup-content { max-width: 380px; font-size: 13px; }
.maplibregl-popup-content pre { white-space: pre-wrap; font: 12px/1.35 ui-monospace, Menlo, Consolas, monospace; margin: 6px 0 0; }

@media (max-width: 800px) {
  body { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  #map { height: 55vh; grid-row: 1; }
  #panel { grid-row: 2; border-right: 0; }
}
header p { margin: 2px 0; }

.tabs { display: flex; gap: 4px; margin-top: 10px; border-bottom: 1px solid var(--line); }
.tabs button {
  font: inherit; border: 0; background: none; padding: 6px 10px; cursor: pointer; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--ink); border-bottom-color: var(--selected); font-weight: 600; }
.badge { font-size: 11px; padding: 0 5px; border-radius: 8px; background: var(--now); color: #fff; }
.badge.warn { background: var(--today); }
.banner { background: #fdecec; color: #8a1c1f; border: 1px solid #f3b9ba; border-radius: 6px; padding: 6px 10px; }

.changes, .issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.changes li, .issues li { border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
.changes li { cursor: pointer; }
.changes .day { border: 0; padding: 8px 0 0; font-weight: 600; cursor: default; }
.event { font-size: 11px; padding: 0 6px; border-radius: 3px; color: #fff; }
.event-appeared { background: #2e8b57; }
.event-changed { background: #1f5fbf; }
.event-removed { background: #8c96a3; }
.event-reappeared { background: #7a4fbf; }
.changes pre, .issues pre { white-space: pre-wrap; font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; margin: 4px 0 0; }
.history { margin-top: 6px; border-top: 1px dashed var(--line); padding-top: 6px; }
.sev-error { border-left: 4px solid var(--now) !important; }
.sev-warning { border-left: 4px solid var(--today) !important; }
.issues .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.runs { width: 100%; border-collapse: collapse; font-size: 12px; }
.runs td, .runs th { text-align: left; padding: 3px 4px; border-bottom: 1px solid var(--line); }
.status-ok { color: #2e8b57; font-weight: 600; }
.status-bad { color: var(--now); font-weight: 600; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 8px 0; font-size: 13px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

.zone-swatch { background: #6b3fa0; opacity: 0.6; }
.zone-chip { background: #6b3fa0; }
.extras.zones { color: #4b2d73; }
.extras.zones .zone-schedule { font-style: italic; }
