:root {
  --bg: #07111f;
  --card: #0f1b2d;
  --card-border: #1e2b40;
  --inset: #060d19;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --faint: #64748b;
  --sky: #38bdf8;
  --green: #34d399;
  --amber: #fbbf24;
  --rose: #fda4af;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
.wrap { max-width: 80rem; margin: 0 auto; padding: max(2rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) max(3rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left)); }

.login-body { display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
.login-card { width: 100%; max-width: 22rem; display: flex; flex-direction: column; gap: 0.75rem; }
.login-card h1 { font-size: 1.6rem; }
.login-card .sub { margin: 0; }
.login-card .form-error { margin: 0; min-height: 1.2em; }
.login-card input { background: var(--inset); border: 1px solid #334155; color: var(--text); border-radius: 0.6rem; padding: 0.7rem 0.8rem; font: inherit; }
.icon { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.15em; }
.icon.sky { color: var(--sky); width: 1.25rem; height: 1.25rem; }

.top { display: flex; flex-wrap: wrap; gap: 1.25rem; justify-content: space-between; align-items: flex-end; margin-bottom: 1.75rem; }
.eyebrow { color: var(--sky); font-size: 0.8rem; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; margin-bottom: 0.5rem; }
h1 { margin: 0; font-size: clamp(1.9rem, 4vw, 3rem); letter-spacing: -0.02em; }
h2 { margin: 0 0 1rem; font-size: 1.15rem; display: flex; align-items: center; gap: 0.5rem; }
.sub { color: var(--muted); max-width: 42rem; margin: 0.5rem 0 0; }
.actions { display: flex; gap: 0.5rem; }

.btn { border: 1px solid #334155; background: #1e293b; color: var(--text); padding: 0.6rem 1.1rem; border-radius: 0.6rem; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: #2a3a52; }
.btn.outline { background: #0f172a; }
.btn.primary { background: #0ea5e9; border-color: #0ea5e9; color: #04111d; }
.btn.primary:hover { background: #38bdf8; }
.btn:disabled { opacity: 0.6; cursor: default; }

.card { background: var(--card); border: 1px solid var(--card-border); border-radius: 1rem; padding: 1.25rem; }
.banner { background: #3b1220; border: 1px solid #7f1d3a; color: var(--rose); padding: 0.75rem 1rem; border-radius: 0.75rem; margin-bottom: 1.25rem; font-size: 0.9rem; }

.stats { flex: 1 1 100%; order: 3; display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 1rem; margin: 0; }
.stat .label { margin: 0; color: var(--muted); font-size: 0.85rem; }
@media (max-width: 600px) {
  .stats { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .stat { padding: 0.8rem; }
  .stat .label { font-size: 0.72rem; }
  .stat .value { font-size: 1.7rem; }
}
.stat .value { margin: 0.35rem 0 0; font-size: 2.4rem; font-weight: 700; }
.value.green { color: var(--green); }
.value.sky { color: var(--sky); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }

.settings { margin-bottom: 1.5rem; border-color: #0c4a6e; }
.add-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; }
.add-row input { flex: 1; background: var(--inset); border: 1px solid #334155; color: var(--text); border-radius: 0.6rem; padding: 0.6rem 0.8rem; font: inherit; text-transform: uppercase; }
.add-row input::placeholder { text-transform: none; color: var(--faint); }
.form-error { color: var(--rose); font-size: 0.85rem; margin: 0 0 0.5rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.chip { background: #334155; color: var(--text); border: 0; border-radius: 999px; padding: 0.45rem 0.9rem; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.chip:hover { background: #7f1d3a; }
.hint { color: var(--faint); font-size: 0.78rem; margin: 0.5rem 0 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(21rem, 1fr)); gap: 1rem; }
.plane { display: flex; flex-direction: column; }
.plane.selected { border-color: var(--sky); }
.track-btn { margin-top: 1rem; align-self: flex-start; font-size: 0.82rem; padding: 0.4rem 0.8rem; }

.mapcard { margin-bottom: 1.5rem; }
.map-head { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: space-between; align-items: center; }
.map-head h2 { margin: 0; }
.map-pick { color: var(--muted); font-size: 0.85rem; display: flex; align-items: center; gap: 0.5rem; }
.map-pick select { background: var(--inset); color: var(--text); border: 1px solid #334155; border-radius: 0.5rem; padding: 0.4rem 0.6rem; font: inherit; }
.map-info { color: var(--muted); font-size: 0.88rem; margin: 0.6rem 0; min-height: 1.3em; }
#map { height: 30rem; border-radius: 0.75rem; background: #0b1626; border: 1px solid var(--card-border); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-size: 0.78rem; color: var(--muted); }
.legend .ramp { width: 7rem; height: 0.5rem; border-radius: 999px; background: linear-gradient(90deg, hsl(40 90% 55%), hsl(120 80% 50%), hsl(200 90% 60%)); }
.legend .spacer { color: var(--faint); }
.legend .dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; border: 2px solid #fff; margin-left: 0.6rem; }
.legend .dot.takeoff { background: #10b981; }
.legend .dot.landing { background: #f43f5e; }
.legend .hint { margin: 0 0 0 auto; }

/* Light tiles are darkened in the tile pane only, so markers and tracks keep their colors. */
.darken-tiles .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9) saturate(0.55); }
.leaflet-container { font: inherit; }
.leaflet-control-attribution { background: rgba(7, 17, 31, 0.8) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--sky) !important; }
.leaflet-tooltip { background: #0f1b2d; color: var(--text); border: 1px solid #334155; box-shadow: none; font-weight: 600; }
.leaflet-tooltip-right::before { border-right-color: #334155; }
.leaflet-tooltip-left::before { border-left-color: #334155; }
.leaflet-tooltip-top::before { border-top-color: #334155; }
.leaflet-tooltip-bottom::before { border-bottom-color: #334155; }
.tail-label { font-size: 0.75rem; padding: 0.1rem 0.4rem; }
.plane-icon svg { width: 30px; height: 30px; fill: currentColor; stroke: #04111d; stroke-width: 1; stroke-linejoin: round; filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.7)); }
.plane-icon { color: #94a3b8; }
.plane-icon.airborne { color: #34d399; }
.plane-icon.stale { color: #fbbf24; }
.plane-icon.not-seen { color: #64748b; opacity: 0.8; }
.plane-icon.sel svg { stroke: #fff; stroke-width: 1.5; }
.plane.airborne { box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.6); }
.plane-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.9rem; }
.plane-head .tail { font-size: 1.5rem; font-weight: 700; margin: 0; }
.plane-head .model { color: var(--muted); font-size: 0.85rem; margin: 0.25rem 0 0; }
.badge { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; padding: 0.3rem 0.65rem; border-radius: 999px; color: #fff; white-space: nowrap; }
.badge.airborne { background: #10b981; }
.badge.ground { background: #334155; }
.badge.stale { background: #f59e0b; }
.badge.not-seen { background: #e2e8f0; color: #334155; }
.badge.unknown { background: #8b5cf6; }
.badge.pending { background: #3b82f6; }

.hero { height: 6rem; display: flex; align-items: center; justify-content: center; background: var(--inset); border-radius: 1rem; margin-bottom: 1rem; color: #475569; }
.hero svg { width: 3rem; height: 3rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.plane.airborne .hero { color: var(--green); }
.plane.airborne .hero svg { transform: rotate(-12deg); }

dl.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin: 0; font-size: 0.88rem; }
dl.facts dt { color: var(--faint); }
dl.facts dd { margin: 0.1rem 0 0; font-weight: 600; }
dl.facts a { color: var(--sky); text-decoration: none; }
dl.facts a:hover { text-decoration: underline; }
.warn { margin-top: 1rem; font-size: 0.78rem; color: var(--amber); }

.lower { display: grid; grid-template-columns: 1fr; gap: 1.5rem; margin-top: 1.75rem; }
@media (min-width: 1024px) { .lower { grid-template-columns: 1fr 22rem; } }
.event { display: flex; justify-content: space-between; align-items: center; gap: 1rem; background: var(--inset); border-radius: 0.75rem; padding: 0.7rem 0.9rem; margin-bottom: 0.6rem; }
.event p { margin: 0; }
.event .meta { color: var(--muted); font-size: 0.78rem; margin-top: 0.15rem; }
.event .when { color: var(--faint); font-size: 0.78rem; text-align: right; }
.empty { color: var(--faint); font-size: 0.9rem; margin: 0; }
.rules p { color: var(--muted); font-size: 0.88rem; margin: 0 0 0.75rem; }
.rules strong { color: var(--text); }

/* Widescreen / TV: everything fits in one viewport, with the map on the left and
   aircraft status plus recent events on the right. Text scales with the screen. */
@media (min-width: 1100px) and (min-aspect-ratio: 4/3) {
  html { font-size: clamp(14px, min(1vw, 1.7vh), 40px); }
  html, body { height: 100%; overflow: hidden; }
  body { min-height: 0; }
  .wrap { max-width: none; height: 100vh; padding: 0.9rem 1.25rem 1rem; display: flex; flex-direction: column; }

  .top { flex: 0 0 auto; flex-wrap: nowrap; align-items: center; gap: 1.5rem; margin-bottom: 0.8rem; }
  .top > div:first-child { min-width: 0; flex: 1 1 auto; }
  .eyebrow { margin-bottom: 0.15rem; }
  h1 { font-size: 2rem; white-space: nowrap; }
  .sub { font-size: 0.8rem; margin-top: 0.25rem; max-width: 56rem; }
  .last-checked { margin: 0.15rem 0 0; }
  .stats { flex: 0 0 auto; order: 0; display: flex; gap: 0.75rem; }
  .stat { padding: 0.55rem 1.1rem; min-width: 9rem; }
  .stat .value { font-size: 2.2rem; margin-top: 0.1rem; line-height: 1.1; }
  .actions { flex: 0 0 auto; }
  .banner { flex: 0 0 auto; margin-bottom: 0.8rem; }

  .settings { position: fixed; top: 5.5rem; right: 1.25rem; z-index: 1000; width: 30rem; max-height: 70vh; overflow-y: auto; margin: 0; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6); }

  .layout { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; }
  .mapcard { margin: 0; min-height: 0; display: flex; flex-direction: column; padding: 1rem; }
  .map-info { margin: 0.4rem 0; }
  #map { flex: 1 1 auto; height: auto; min-height: 0; }
  .legend .hint { display: none; }

  .side { min-height: 0; display: flex; flex-direction: column; gap: 1rem; }
  .grid { flex: 0 1 auto; min-height: 0; overflow-y: auto; align-content: start; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.75rem; padding: 3px; }
  .plane { padding: 0.8rem 0.95rem; }
  .plane-head { margin-bottom: 0.55rem; }
  .plane-head .tail { font-size: 1.4rem; }
  .hero { display: none; }
  dl.facts { gap: 0.4rem 0.8rem; font-size: 0.9rem; }
  .track-btn { margin-top: 0.6rem; padding: 0.3rem 0.7rem; }
  .warn { margin: 0.5rem 0 0; font-size: 0.7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .lower { flex: 1 1 0; min-height: 5.5rem; display: flex; margin: 0; }
  .lower > .card { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0.9rem 1rem; }
  .lower h2 { margin-bottom: 0.6rem; }
  .lower .rules { display: none; }
  .event { padding: 0.45rem 0.8rem; margin-bottom: 0.4rem; }
}
