:root {
  --bg: #050908;
  --panel: #09110f;
  --panel-2: #0d1815;
  --line: rgba(179, 255, 220, .14);
  --line-strong: rgba(179, 255, 220, .28);
  --text: #edf9f3;
  --muted: #7f9b8e;
  --green: #55f0a7;
  --green-soft: rgba(85, 240, 167, .12);
  --amber: #ffbd66;
  --red: #ff6d74;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 8%, rgba(85, 240, 167, .08), transparent 28rem),
    linear-gradient(135deg, #060b0a 0%, #040706 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }
a { color: inherit; }

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 9, 8, .88);
  backdrop-filter: blur(18px);
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--line-strong); color: var(--green); font-size: .75rem; font-weight: 900; letter-spacing: .08em; }
.brand b, .brand small { display: block; }
.brand b { font-size: .94rem; letter-spacing: .02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: .69rem; text-transform: uppercase; letter-spacing: .14em; }
.topbar-actions { display: flex; align-items: center; gap: 22px; }
.live-state { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .12em; }
.live-state i { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 14px currentColor; }
.live-state.connected { color: var(--green); }
.live-state.connected i { background: var(--green); }
.live-state.error { color: var(--red); }
.live-state.error i { background: var(--red); }
.home-link { color: var(--muted); font-size: .78rem; text-decoration: none; border-bottom: 1px solid var(--line-strong); padding-bottom: 3px; }
.home-link:hover { color: var(--text); }

.dashboard {
  min-height: calc(100vh - 74px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
}

.radar-card { min-width: 0; padding: 26px; border-right: 1px solid var(--line); }
.radar-heading { min-height: 66px; display: flex; align-items: start; justify-content: space-between; gap: 24px; }
.kicker { margin: 0 0 5px; color: var(--green); font: 700 .65rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .14em; }
h1 { margin: 0; font-size: clamp(1.35rem, 2vw, 2rem); letter-spacing: -.03em; font-weight: 650; }
.range-control { display: flex; align-items: baseline; gap: 10px; padding-top: 6px; color: var(--muted); font: 700 .66rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: uppercase; letter-spacing: .12em; }
.range-control strong { color: var(--text); font-size: .78rem; }
.range-control button { width: 27px; height: 27px; padding: 0; color: var(--green); border: 1px solid var(--line-strong); background: var(--green-soft); cursor: pointer; font-size: 1rem; line-height: 1; }
.range-control button:hover:not(:disabled) { color: #08110e; background: var(--green); }
.range-control button:disabled { color: #40564b; background: transparent; cursor: default; }

.scope-wrap {
  position: relative;
  height: calc(100vh - 166px);
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #06100d;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, .4);
}
#road-map, #radar { position: absolute; inset: 0; width: 100%; height: 100%; }
#road-map { z-index: 0; background: #06100d; }
#radar { z-index: 1; display: block; pointer-events: none; }
.leaflet-container { background: #06100d; font-family: inherit; }
.leaflet-tile-pane { filter: grayscale(1) invert(1) brightness(.68) contrast(1.4) sepia(.14) hue-rotate(92deg); opacity: .8; }
.leaflet-control-attribution { padding: 2px 5px !important; color: #6f887b !important; background: rgba(3, 9, 7, .78) !important; font-size: 9px !important; }
.leaflet-control-attribution a { color: #8eaa9c !important; }
.leaflet-control-container { position: relative; z-index: 2; }
.scope-overlay { position: absolute; z-index: 2; color: var(--muted); pointer-events: none; font: 600 .61rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; text-transform: uppercase; text-shadow: 0 1px 4px #020706; }
.scope-overlay span, .scope-overlay b { display: block; }
.scope-overlay b { color: rgba(237, 249, 243, .7); font-weight: 600; }
.top-left { top: 18px; left: 18px; }
.bottom-left { bottom: 18px; left: 18px; }
.bottom-right { top: 18px; right: 18px; text-align: right; }

.radar-error { position: absolute; z-index: 4; top: 62px; right: 18px; display: grid; justify-items: start; gap: 5px; width: min(360px, calc(100% - 36px)); padding: 13px 15px; color: var(--text); background: rgba(18, 12, 10, .94); border: 1px solid rgba(255, 109, 116, .45); box-shadow: 0 12px 34px rgba(0, 0, 0, .34); pointer-events: none; }
.radar-error[hidden] { display: none; }
.radar-error b { font-size: .85rem; }
.radar-error span { color: var(--muted); font-size: .72rem; line-height: 1.45; }
.radar-error button { margin-top: 5px; padding: 7px 11px; color: var(--green); border: 1px solid var(--line-strong); background: var(--green-soft); cursor: pointer; pointer-events: auto; }

.traffic-panel { min-height: 0; display: flex; flex-direction: column; background: rgba(9, 17, 15, .72); }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--line); }
.summary-grid div { padding: 20px 16px; border-right: 1px solid var(--line); }
.summary-grid div:last-child { border-right: 0; }
.summary-grid span, .summary-grid strong { display: block; }
.summary-grid span { color: var(--muted); font-size: .6rem; text-transform: uppercase; letter-spacing: .13em; }
.summary-grid strong { margin-top: 7px; font: 650 1.2rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.traffic-tools { padding: 20px 18px 14px; border-bottom: 1px solid var(--line); }
.traffic-tools label { font-weight: 700; font-size: .82rem; letter-spacing: .05em; text-transform: uppercase; }
.traffic-tools > span { float: right; color: var(--muted); font-size: .68rem; }
.traffic-tools input { width: 100%; margin-top: 14px; padding: 11px 12px; color: var(--text); border: 1px solid var(--line); outline: 0; background: rgba(255, 255, 255, .025); }
.traffic-tools input:focus { border-color: rgba(85, 240, 167, .42); }
.traffic-tools input::placeholder { color: #52665d; }
.traffic-list { flex: 1; min-height: 160px; overflow: auto; }
.aircraft-row { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 15px 18px; color: var(--text); text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; }
.aircraft-row:hover, .aircraft-row.selected { background: var(--green-soft); }
.aircraft-row.selected { box-shadow: inset 2px 0 var(--green); }
.aircraft-identity { min-width: 0; }
.aircraft-identity b { display: block; overflow: hidden; text-overflow: ellipsis; font: 700 .86rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; letter-spacing: .04em; }
.aircraft-identity span, .aircraft-metrics span { color: var(--muted); font-size: .68rem; }
.aircraft-metrics { text-align: right; }
.aircraft-metrics b { display: block; color: var(--green); font: 650 .78rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.emergency .aircraft-metrics b { color: var(--red); }
.empty-state { margin: auto; padding: 30px; color: var(--muted); text-align: center; font-size: .8rem; }
.data-credit { padding: 14px 18px; color: #60766c; border-top: 1px solid var(--line); font-size: .64rem; line-height: 1.5; }
.data-credit a { color: var(--muted); }

.detail-drawer { position: fixed; z-index: 10; left: 26px; right: 406px; bottom: 26px; display: grid; grid-template-columns: 180px 1fr; gap: 26px; padding: 18px 22px; border: 1px solid var(--line-strong); background: rgba(7, 15, 13, .94); box-shadow: 0 20px 60px rgba(0, 0, 0, .45); backdrop-filter: blur(16px); }
.detail-drawer[hidden] { display: none; }
.detail-drawer span, .detail-drawer dt { color: var(--muted); font-size: .58rem; text-transform: uppercase; letter-spacing: .12em; }
.detail-drawer h2 { margin: 4px 0 0; font: 750 1.25rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.detail-drawer p { margin: 3px 0 0; color: var(--muted); font-size: .72rem; }
.detail-drawer dl { margin: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: center; }
.detail-drawer dt, .detail-drawer dd { margin: 0; }
.detail-drawer dd { margin-top: 5px; font: 650 .73rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.drawer-close { position: absolute; top: 8px; right: 10px; color: var(--muted); border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; }

@media (max-width: 980px) {
  .dashboard { grid-template-columns: 1fr; }
  .radar-card { border-right: 0; padding: 18px; }
  .scope-wrap { height: min(72vh, 720px); min-height: 480px; }
  .traffic-panel { border-top: 1px solid var(--line); }
  .traffic-list { max-height: 420px; }
  .detail-drawer { left: 18px; right: 18px; bottom: 18px; grid-template-columns: 150px 1fr; }
  .detail-drawer dl { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 620px) {
  .topbar { height: 66px; padding: 0 14px; }
  .brand small, .home-link { display: none; }
  .dashboard { min-height: calc(100vh - 66px); }
  .radar-card { padding: 14px; }
  .radar-heading { min-height: 58px; }
  .kicker { font-size: .56rem; }
  h1 { font-size: 1.18rem; }
  .range-control span { display: none; }
  .scope-wrap { height: 58vh; min-height: 390px; }
  .bottom-left { right: 14px; bottom: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-right { top: 14px; right: 14px; bottom: auto; }
  .bottom-right b { display: none; }
  .summary-grid div { padding: 16px 10px; }
  .summary-grid strong { font-size: 1rem; }
  .detail-drawer { grid-template-columns: 1fr; gap: 12px; }
  .detail-drawer dl { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
