:root {
  --ink: #f5f8fb;
  --muted: #8fa2b4;
  --panel: rgba(6, 16, 25, 0.91);
  --line: rgba(160, 181, 199, 0.16);
  --red: #e31837;
  --red-bright: #ff3652;
  --cyan: #55d6d2;
  --amber: #f5b63d;
  --bg: #061019;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.shell { height: 100%; display: grid; grid-template-rows: 6.5rem 1fr 2rem; }
.topbar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2.25rem;
  background: linear-gradient(90deg, #08141f 0%, #0b1823 58%, #101a24 100%);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 40px rgba(0,0,0,.32);
}
.brand, .header-stats { display: flex; align-items: center; }
.brand { gap: 1.15rem; }
.brand-mark {
  width: 3.7rem; height: 3.7rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(227,24,55,.13), 0 8px 25px rgba(227,24,55,.23);
}
.brand-mark span { font-size: 2rem; font-weight: 900; font-style: italic; letter-spacing: -.16rem; transform: translateX(-.08rem); }
.eyebrow { color: var(--red-bright); font-size: .68rem; font-weight: 800; letter-spacing: .19em; }
h1 { font-size: 1.35rem; letter-spacing: .015em; margin: .2rem 0 0; font-weight: 650; }
.header-stats { height: 100%; gap: 1.6rem; }
.stat-block { display: flex; gap: .75rem; align-items: baseline; }
.stat-label { font-size: .66rem; font-weight: 800; color: var(--muted); letter-spacing: .16em; }
.stat-block strong { font-size: 2.3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.divider { height: 2.7rem; width: 1px; background: var(--line); }
.clock-block { display: flex; flex-direction: column; align-items: flex-end; min-width: 9.8rem; }
.clock-block strong { font-size: 1.75rem; font-variant-numeric: tabular-nums; line-height: 1.05; }
.clock-block span { color: var(--muted); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; margin-top: .25rem; }

.stage { position: relative; min-height: 0; overflow: hidden; }
#map {
  position: absolute; inset: 0;
  background-color: #07131e;
  background-image: url('/world-fallback.svg');
  background-size: cover;
  background-position: center;
}
.map-vignette { position: absolute; inset: 0; pointer-events: none; z-index: 2; background: radial-gradient(circle at 43% 40%, transparent 30%, rgba(2,8,13,.2) 100%); }
.maplibregl-ctrl-bottom-right { right: 1.2rem; bottom: 2.8rem; opacity: .48; }

.status-chip {
  position: absolute; z-index: 10; top: 1.25rem; left: 1.5rem;
  display: flex; align-items: center; gap: .58rem;
  background: rgba(5,15,23,.83); border: 1px solid var(--line); border-radius: 999px;
  padding: .58rem .85rem; backdrop-filter: blur(12px);
  color: #c6d1d9; font-size: .65rem; font-weight: 800; letter-spacing: .12em;
}
.pulse { width: .52rem; height: .52rem; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 0 rgba(85,214,210,.5); animation: ping 2.2s infinite; }
.status-chip.stale .pulse { background: var(--amber); animation: none; }
.status-chip.error .pulse { background: var(--red-bright); animation: none; }
@keyframes ping { 70% { box-shadow: 0 0 0 7px rgba(85,214,210,0); } 100% { box-shadow: 0 0 0 0 rgba(85,214,210,0); } }

.flight-panel {
  position: absolute; z-index: 10; right: 1rem; top: 50%; bottom: auto; width: 23.5rem;
  height: min(57.92rem, calc(100% - .6rem)); transform: translateY(-50%);
  display: grid; grid-template-rows: auto 1fr auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 1rem;
  box-shadow: 0 22px 55px rgba(0,0,0,.42); backdrop-filter: blur(16px); overflow: hidden;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.2rem .8rem; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 1.25rem; margin: .22rem 0 0; letter-spacing: .01em; }
.demo-badge { padding: .38rem .55rem; color: #ffd16f; border: 1px solid rgba(245,182,61,.35); border-radius: .35rem; font-size: .58rem; font-weight: 900; letter-spacing: .1em; background: rgba(245,182,61,.09); }
.flight-list {
  display: grid;
  grid-template-rows: repeat(14, minmax(0, 1fr));
  min-height: 0;
  overflow: hidden;
}
.flight-row {
  display: grid; grid-template-columns: 2.25rem 1fr auto; gap: .7rem; align-items: center;
  min-height: 0; padding: .7rem 1.15rem; border-bottom: 1px solid rgba(160,181,199,.09);
  animation: reveal .45s ease both;
}
@keyframes reveal { from { opacity: 0; transform: translateX(8px); } }
.plane-icon { width: 2.1rem; height: 2.1rem; display: grid; place-items: center; border-radius: 50%; color: white; background: rgba(227,24,55,.14); }
.plane-icon svg { width: 1.15rem; height: 1.15rem; transform: rotate(var(--heading)); filter: drop-shadow(0 2px 4px rgba(0,0,0,.4)); }
.flight-main { min-width: 0; }
.flight-title { display: flex; align-items: baseline; gap: .5rem; }
.flight-title strong { font-size: .95rem; letter-spacing: .035em; }
.flight-title span { color: var(--muted); font-size: .65rem; }
.route { margin-top: .26rem; font-size: .72rem; color: #b7c4ce; letter-spacing: .06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.route b { color: var(--red-bright); margin: 0 .3rem; }
.flight-metrics { text-align: right; font-variant-numeric: tabular-nums; }
.flight-metrics strong { display: block; font-size: .79rem; }
.flight-metrics span { display: block; margin-top: .23rem; color: var(--muted); font-size: .63rem; }
.panel-foot { min-height: 2.35rem; display: flex; align-items: center; justify-content: space-between; padding: 0 1.15rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .62rem; letter-spacing: .04em; }
.empty-state { height: 100%; min-height: 12rem; display: grid; place-content: center; justify-items: center; color: var(--muted); font-size: .8rem; }
.loading-ring { width: 1.8rem; height: 1.8rem; border: 2px solid rgba(255,255,255,.12); border-top-color: var(--red-bright); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.aircraft-marker { position: absolute; width: 2.3rem; height: 2.3rem; display: grid; place-items: center; cursor: default; }
.aircraft-marker::before { content: ''; position: absolute; inset: .17rem; border-radius: 50%; background: var(--red); box-shadow: 0 4px 15px rgba(227,24,55,.5), 0 0 0 4px rgba(227,24,55,.13); }
.aircraft-marker.ground::before { background: #718394; box-shadow: 0 4px 15px rgba(0,0,0,.4), 0 0 0 4px rgba(113,131,148,.15); }
.aircraft-marker svg { position: relative; z-index: 1; width: 1.15rem; transform: rotate(var(--heading)); }
.aircraft-label {
  position: absolute;
  z-index: 2;
  left: 2.55rem;
  top: 50%;
  transform: translateY(-50%);
  min-width: max-content;
  padding: .3rem .42rem .28rem;
  border: 1px solid rgba(160,181,199,.22);
  border-radius: .35rem;
  background: rgba(5,15,23,.88);
  box-shadow: 0 4px 14px rgba(0,0,0,.34);
  color: var(--ink);
  line-height: 1.05;
  pointer-events: none;
  backdrop-filter: blur(8px);
}
.aircraft-label strong { display: block; font-size: .75rem; letter-spacing: .055em; }
.aircraft-label span { display: block; margin-top: .16rem; color: #b7c4ce; font-size: .54rem; letter-spacing: .035em; }
.aircraft-marker.ground .aircraft-label { border-color: rgba(160,181,199,.15); }
.maplibregl-popup-content { background: #0b1823; color: var(--ink); border: 1px solid var(--line); border-radius: .6rem; box-shadow: 0 10px 30px rgba(0,0,0,.4); padding: .8rem 1rem; }
.maplibregl-popup-tip { border-top-color: #0b1823 !important; }
.popup-title { font-weight: 800; letter-spacing: .04em; }
.popup-detail { color: var(--muted); font-size: .72rem; margin-top: .2rem; }
.map-key { position: absolute; z-index: 10; left: 1.5rem; bottom: 1.25rem; display: flex; gap: 1.2rem; padding: .55rem .75rem; border-radius: .45rem; background: rgba(5,15,23,.72); color: var(--muted); font-size: .6rem; font-weight: 800; letter-spacing: .1em; }
.map-key span { display: flex; align-items: center; gap: .4rem; }
.map-key i { width: .48rem; height: .48rem; border-radius: 50%; }
.key-plane { background: var(--red); box-shadow: 0 0 0 3px rgba(227,24,55,.15); }
.key-ground { background: #718394; }

.footer { position: relative; z-index: 20; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 1.5rem; background: #050d14; color: #607486; font-size: .54rem; font-weight: 800; letter-spacing: .12em; }
.footer-note { text-transform: none; font-weight: 500; letter-spacing: .02em; }
.footer-provider-group { justify-self: end; display: flex; align-items: center; gap: .85rem; }
.map-credits { display: flex; align-items: center; gap: .4rem; }
.map-credits a { color: inherit; text-decoration: none; }

@media (max-width: 900px) {
  .shell { grid-template-rows: 5rem 1fr 1.8rem; }
  .topbar { padding: 0 1rem; }
  .brand-mark { width: 2.8rem; height: 2.8rem; }
  h1 { font-size: 1rem; }
  .stat-label, .divider, .clock-block span { display: none; }
  .stat-block strong { font-size: 1.6rem; }
  .clock-block { min-width: auto; }
  .clock-block strong { font-size: 1.2rem; }
  .flight-panel { width: 20rem; right: .6rem; }
  .status-chip { top: .6rem; left: .6rem; }
  .footer-note { display: none; }
}

@media (max-width: 620px) {
  .flight-panel { width: calc(100% - 1rem); top: auto; height: 43%; left: .5rem; right: .5rem; bottom: .5rem; transform: none; grid-template-rows: auto 1fr auto; }
  .flight-list { display: block; }
  .map-key { display: none; }
  .header-stats .stat-block { display: none; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }
