:root {
  --bg: #0b1014;
  --panel: #121a21;
  --line: #22303b;
  --text: #d8e1e8;
  --muted: #7d8d99;
  --accent: #3ddc84;
  --warn: #f5b13d;
  --bad: #ff4d4d;
  --mono: "Cascadia Mono", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.35 "Segoe UI", system-ui, sans-serif; }
body { display: flex; flex-direction: column; }

#topbar { display: flex; align-items: center; gap: 18px; padding: 0 14px; height: 44px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.brand { font-family: var(--mono); font-weight: 700; letter-spacing: .12em; color: var(--accent); }
.stat { color: var(--muted); white-space: nowrap; }
.stat b { color: var(--text); font-family: var(--mono); font-weight: 600; }
.badge { font: 700 11px var(--mono); padding: 3px 8px; border-radius: 3px; letter-spacing: .08em;
  background: #333; color: #ccc; }
.badge.live { background: #12391f; color: var(--accent); }
.badge.sim { background: #3d2c0b; color: var(--warn); }
.badge.offline { background: #3d1111; color: var(--bad); }
.toggles { display: flex; gap: 12px; margin-left: auto; color: var(--muted); }
.toggles label { cursor: pointer; user-select: none; }
#clock { font-family: var(--mono); color: var(--muted); white-space: nowrap; }

main { flex: 1; display: flex; min-height: 0; }
#map-wrap { flex: 1; position: relative; min-width: 0; display: flex; }
#map { flex: 1; background: #05080a; }
#offline { position: absolute; inset: 0; z-index: 1000; display: flex; align-items: center;
  justify-content: center; background: rgba(5, 8, 10, .55); pointer-events: none; }
#offline.hidden { display: none; }
.offline-card { max-width: 380px; margin: 20px; padding: 18px 22px; border-radius: 10px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.offline-title { font: 700 16px var(--mono); letter-spacing: .08em; color: var(--warn); text-transform: uppercase; }
.offline-card p { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
#side { width: 520px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--line);
  background: var(--panel); min-height: 0; }

/* detail card */
#detail { padding: 10px 14px 6px; border-bottom: 1px solid var(--line); }
#detail.hidden { display: none; }
.detail-head { display: flex; justify-content: space-between; align-items: center; }
#d-call { font: 700 18px var(--mono); color: var(--accent); }
.detail-sub { display: flex; justify-content: space-between; gap: 10px; margin-top: 2px; }
#d-type { font-weight: 600; font-size: 14px; }
#d-cat { font: 700 11px var(--mono); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.legend { background: rgba(18, 26, 33, .88); border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px;
  font: 11px/1.6 var(--mono); color: var(--text); }
.legend .swatch { vertical-align: -1px; }
#d-close { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; }
#d-close:hover { color: var(--text); }
#d-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 12px; margin: 8px 0; }
#d-grid div { min-width: 0; }
#d-grid dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
#d-grid dd { margin: 0; font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* table */
.tbl-wrap { flex: 1; overflow: auto; }
#tbl { width: 100%; border-collapse: collapse; font-family: var(--mono); font-size: 12px; }
#tbl th { position: sticky; top: 0; background: #17222b; color: var(--muted); font-weight: 600;
  text-align: left; padding: 6px 6px; cursor: pointer; user-select: none; border-bottom: 1px solid var(--line); }
#tbl th.sorted { color: var(--text); }
#tbl th.sorted::after { content: " \25BE"; }
#tbl th.sorted.asc::after { content: " \25B4"; }
#tbl td { padding: 4px 6px; border-bottom: 1px solid #18222a; white-space: nowrap; }
#tbl .num { text-align: right; }
#tbl tbody tr { cursor: pointer; }
#tbl tbody tr:hover { background: #1a2630; }
#tbl tr.sel { background: #1d3a2a !important; }
#tbl tr.nopos td { color: var(--muted); }
#tbl tr.stale td { opacity: .5; }
#tbl tr.emerg td { color: #fff; background: #5a1616; }
.swatch { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }

/* aircraft markers */
/* .plane is a Leaflet marker: it is already absolutely positioned, so don't override position. */
.dark-tiles { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.5); }
.plane .glyph { width: 32px; height: 32px; transition: transform .9s linear; display: block;
  filter: drop-shadow(0 0 2px rgba(0,0,0,.9)); }
.plane .glyph path { stroke: #000; stroke-width: .8; }
.plane.sel .glyph path { stroke: #fff; stroke-width: 1.6; }
.plane.stale { opacity: .4; }
.plane .lbl { position: absolute; left: 30px; top: 0; font: 11px/1.15 var(--mono); color: #e8eef2;
  white-space: pre; pointer-events: none; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.hide-labels .plane .lbl { display: none; }
.plane.emerg::before { content: ""; position: absolute; left: -8px; top: -8px; width: 44px; height: 44px;
  border-radius: 50%; border: 2px solid var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 0% { transform: scale(.6); opacity: 1; } 100% { transform: scale(1.3); opacity: 0; } }

.home-icon { width: 14px; height: 14px; border-radius: 50%; background: #29b6f6; border: 2px solid #fff;
  box-shadow: 0 0 6px #29b6f6; }
.apt { font: 700 10px var(--mono); color: #9fb3c2; white-space: nowrap; text-shadow: 0 0 3px #000; }
.apt::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 4px;
  border: 1.5px solid #9fb3c2; vertical-align: -1px; }
.apt.main { color: #e8eef2; }
.ring-lbl { font: 10px var(--mono); color: rgba(61,220,132,.7); white-space: nowrap; text-shadow: 0 0 3px #000; }
.leaflet-container { font-family: inherit; }

.brand a { color: inherit; text-decoration: none; }
.brand a:hover { text-decoration: underline; }
.brand .crumb { color: var(--muted); }

/* public view: no signal-strength column (the server doesn't send it) */
body.public #tbl th:nth-child(11), body.public #tbl td:nth-child(11) { display: none; }

/* ---------- phones and narrow windows: list goes under the map ---------- */
@media (max-width: 820px) {
  #topbar { height: auto; flex-wrap: wrap; gap: 6px 12px; padding: 6px 10px; }
  .brand { font-size: 12px; }
  .stat { font-size: 12px; }
  .toggles { margin-left: 0; gap: 10px; font-size: 12px; }
  #clock { font-size: 11px; }
  main { flex-direction: column; }
  #map-wrap { flex: 1 1 58%; min-height: 0; }
  #side { width: 100%; flex: 0 0 42%; border-left: 0; border-top: 1px solid var(--line); }
  #detail { padding: 6px 10px 2px; }
  #d-call { font-size: 15px; }
  #d-grid { gap: 4px 8px; margin: 4px 0; }
  #d-grid dd { font-size: 12px; }
  /* hide Hex, Sqk, Brg, RSSI, Age columns */
  #tbl th:nth-child(3), #tbl td:nth-child(3),
  #tbl th:nth-child(4), #tbl td:nth-child(4),
  #tbl th:nth-child(10), #tbl td:nth-child(10),
  #tbl th:nth-child(11), #tbl td:nth-child(11),
  #tbl th:nth-child(12), #tbl td:nth-child(12) { display: none; }
  .legend { font-size: 10px; padding: 4px 6px; line-height: 1.45; }
  #tbl td { padding: 6px 5px; }
}
