:root {
  color-scheme: dark;
  --bg: #071018;
  --panel: #0d1923;
  --panel-2: #112330;
  --line: #203846;
  --text: #e8f4f7;
  --muted: #8ca5ae;
  --cyan: #41d9d0;
  --orange: #ffad5a;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 80% -10%, #153a49 0, transparent 32rem), var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header, main, footer { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }

header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  padding: 44px 0 26px;
}

.eyebrow { margin: 0 0 8px; color: var(--cyan); font: 700 12px/1 monospace; letter-spacing: .18em; }
h1 { margin: 0; font-size: clamp(32px, 5vw, 58px); line-height: .95; letter-spacing: -.045em; }
.subtitle { margin: 13px 0 0; color: var(--muted); }

.controls {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) .45fr auto auto;
  gap: 12px;
  padding: 16px;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.location-field { position: relative; min-width: 0; }
.location-results { position: absolute; z-index: 1200; top: calc(100% + 6px); right: 0; left: 0; overflow: hidden; padding: 5px; background: #08131bf5; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 32px #000a; }
.location-results[hidden] { display: none; }
.location-result { display: block; width: 100%; min-height: 38px; padding: 8px 10px; color: var(--text); background: transparent; border: 0; border-radius: 7px; text-align: left; font-size: 13px; font-weight: 600; }
.location-result:hover, .location-result:focus { color: #041313; background: var(--cyan); outline: none; }

label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
input, button { min-height: 42px; border-radius: 9px; font: inherit; }
input { width: 100%; padding: 0 11px; color: var(--text); background: #08131b; border: 1px solid var(--line); }
button { align-self: end; padding: 0 16px; border: 1px solid var(--cyan); background: var(--cyan); color: #041313; font-weight: 750; cursor: pointer; }
button.secondary { color: var(--text); background: transparent; border-color: var(--line); }
button:hover { filter: brightness(1.08); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0; }
.stats article { display: flex; align-items: baseline; gap: 9px; padding: 16px 18px; border: 1px solid var(--line); background: var(--panel); border-radius: 14px; }
.stats span { font: 700 26px/1 monospace; color: var(--orange); }
.stats small { color: var(--muted); }

.map-panel, .table-panel { overflow: hidden; border: 1px solid var(--line); background: var(--panel); border-radius: 16px; }
.map-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.map-toolbar > span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.map-style-buttons { display: flex; gap: 6px; }
.map-style { min-height: 34px; padding: 0 12px; color: var(--muted); background: #08131b; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; font-weight: 700; }
.map-style.active { color: #041313; background: var(--cyan); border-color: var(--cyan); }
#map { height: clamp(430px, 62vh, 680px); background: #09131a; }
.map-note { margin: 0; padding: 10px 14px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

.table-panel { margin-top: 14px; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; padding: 18px; }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading span { color: var(--muted); font-size: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 18px; border-top: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
td { font: 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.aircraft-row { cursor: pointer; transition: background-color .16s ease, box-shadow .16s ease; }
.aircraft-row:hover, .aircraft-row:focus { background: #17303d; outline: none; }
.aircraft-row.selected { background: #174148; box-shadow: inset 4px 0 0 var(--cyan); }

.plane-marker { display: grid; place-items: center; width: 24px; height: 24px; margin: 1px; color: #06171a; background: var(--cyan); border: 1px solid #bffffa; border-radius: 50%; box-shadow: 0 3px 9px #000a, 0 0 0 2px #41d9d024; }
.plane-marker.selected { background: var(--orange); border-color: #ffe5c4; box-shadow: 0 4px 12px #000c, 0 0 0 3px #ffad5a45; transform: scale(1.1); }
.plane-marker.emergency, .plane-marker.selected.emergency { background: var(--danger); border-color: #ffe1e1; box-shadow: 0 4px 12px #000c, 0 0 0 3px #ff6b6b55; }
.plane-marker svg { display: block; width: 18px; height: 18px; fill: currentColor; filter: drop-shadow(0 1px 0 #fff7); transform-origin: center; transition: transform 1s linear; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { color: var(--text); background: var(--panel-2); }
.leaflet-popup-content { line-height: 1.55; }
.leaflet-bar a { color: var(--text); background: #0d1923; border-color: var(--line); }
.leaflet-bar a:hover { color: #041313; background: var(--cyan); }
.leaflet-control-attribution { color: #9ab1b9; background: #071018dd !important; }
.leaflet-control-attribution a { color: var(--cyan); }
footer { padding: 22px 0 36px; color: var(--muted); font-size: 12px; }
a { color: var(--cyan); }

@media (max-width: 820px) {
  header { align-items: start; }
  .controls { grid-template-columns: 1fr 1fr; }
  .location-field { grid-column: span 2; }
  .stats { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  header { display: grid; gap: 18px; padding-top: 28px; }
  .controls { grid-template-columns: 1fr; }
  .location-field { grid-column: auto; }
  button { width: 100%; }
  .map-toolbar { align-items: stretch; flex-direction: column; }
  .map-style-buttons { display: grid; grid-template-columns: repeat(3, 1fr); }
  .map-style { width: auto; }
  #map { height: 58vh; min-height: 440px; }
}

.route-confidence { display: block; font-size: 0.65rem; opacity: 0.65; }

.data-notice { color: var(--muted); margin: 0 0 1rem; font-size: .9rem; }
