:root {
  --page-plane: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #202020;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --border: rgba(255, 255, 255, 0.10);

  --series-airplane: #3987e5;
  --series-helicopter: #c98500;
  --series-other: #199e70;
  --series-unknown: #898781;

  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-critical: #d03b3b;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- Top navigation ---------- */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 1000;
}
.topnav .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.2px;
}
.topnav .brand .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--status-good);
  box-shadow: 0 0 8px var(--status-good);
}
.topnav .brand .dot.stale { background: var(--status-warning); box-shadow: 0 0 8px var(--status-warning); }
.topnav .brand .dot.off { background: var(--text-muted); box-shadow: none; }
.topnav nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.topnav nav a {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-secondary);
}
.topnav nav a:hover { background: var(--surface-2); color: var(--text-primary); }
.topnav nav a.active { color: var(--text-primary); background: var(--surface-2); }

/* ---------- Map page ---------- */
.map-page {
  position: relative;
  height: calc(100vh - 56px);
  width: 100%;
}
#map {
  height: 100%;
  width: 100%;
  background: var(--page-plane);
}
.leaflet-container { font-family: var(--font); }

.panel {
  background: rgba(26, 26, 25, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
}

.map-legend {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 900;
  padding: 12px 14px;
  min-width: 190px;
}
.map-legend h3 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
}
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-secondary); padding: 3px 0; }
.legend-swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.legend-row .count { margin-left: auto; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.map-status {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 900;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.aircraft-popup { font-family: var(--font); color: #111; min-width: 180px; }
.aircraft-popup .callsign { font-weight: 700; font-size: 15px; margin-bottom: 2px; }
.aircraft-popup .sub { color: #666; font-size: 12px; margin-bottom: 8px; }
.aircraft-popup table { border-collapse: collapse; width: 100%; }
.aircraft-popup td { padding: 2px 0; font-size: 12.5px; }
.aircraft-popup td.k { color: #777; padding-right: 8px; }
.aircraft-popup td.v { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; }

.aircraft-marker { display: flex; align-items: center; justify-content: center; }
.aircraft-marker svg { filter: drop-shadow(0 0 3px rgba(0,0,0,0.7)); }

.home-marker {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-primary);
  border: 2px solid var(--page-plane);
  box-shadow: 0 0 0 2px var(--text-primary), 0 0 10px rgba(255,255,255,0.6);
}

/* ---------- Content pages (dashboard) ---------- */
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}
.page h1 {
  font-size: 22px;
  margin: 0 0 4px;
  font-weight: 600;
}
.page .lede {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0 0 24px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
}
.stat-tile .label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-tile .value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: normal;
}
.stat-tile .value .unit { font-size: 14px; color: var(--text-secondary); font-weight: 500; margin-left: 4px; }
.stat-tile.airplane .value { color: var(--series-airplane); }
.stat-tile.helicopter .value { color: var(--series-helicopter); }

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar select, .filter-bar input {
  background: var(--surface-1);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  font-family: var(--font);
}
.filter-bar button {
  background: var(--series-airplane);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.filter-bar button:hover { opacity: 0.9; }

table.passes {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
table.passes th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--gridline);
  font-weight: 600;
}
table.passes td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gridline);
  font-size: 13.5px;
  color: var(--text-secondary);
}
table.passes tbody tr:hover { background: var(--surface-2); cursor: pointer; }
table.passes tbody tr:last-child td { border-bottom: none; }
table.passes td.num { font-variant-numeric: tabular-nums; text-align: right; }

.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.type-badge .dot { width: 8px; height: 8px; border-radius: 50%; }
.type-badge.airplane .dot { background: var(--series-airplane); }
.type-badge.helicopter .dot { background: var(--series-helicopter); }
.type-badge.other .dot { background: var(--series-other); }
.type-badge.unknown .dot { background: var(--series-unknown); }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 820px) {
  .detail-grid { grid-template-columns: 1fr; }
}
#track-map {
  height: 420px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.detail-side { display: flex; flex-direction: column; gap: 12px; }
.back-link { display: inline-block; margin-bottom: 14px; color: var(--text-secondary); font-size: 13.5px; }
.back-link:hover { color: var(--text-primary); }

.auth-cta {
  background: var(--series-airplane);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: 7px;
  font-weight: 600;
}
