:root {
  --bg: #0b0e14;
  --panel: #11151d;
  --panel-2: #161b26;
  --border: #232a3a;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --accent: #38bdf8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body { display: flex; flex-direction: column; overflow: hidden; }

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { color: var(--accent); font-size: 22px; line-height: 1; }
.brand h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: 0.2px; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.subtitle a { color: var(--accent); text-decoration: none; }
.subtitle a:hover { text-decoration: underline; }

.controls { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--panel-2);
  white-space: nowrap;
}
.badge.ok { color: #34d399; border-color: #1f4d3a; }
.badge.warn { color: #fbbc04; border-color: #5c4a12; }
.updated { color: var(--muted); font-size: 12px; white-space: nowrap; }
.toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; white-space: nowrap; }
#refresh-btn {
  background: var(--accent);
  color: #06121a;
  border: none;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}
#refresh-btn:hover { filter: brightness(1.1); }
#refresh-btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- layout ---------- */
#layout { display: flex; flex: 1 1 auto; min-height: 0; }

#sidebar {
  width: 300px;
  flex: 0 0 300px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#airport-search {
  margin: 12px 12px 4px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
#airport-search:focus { border-color: var(--accent); }

#sidebar h2 {
  margin: 10px 14px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  font-weight: 650;
}

#airport-list, #flight-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 12px;
  overflow-y: auto;
}
#airport-list { max-height: 38%; border-bottom: 1px solid var(--border); }
#flight-list { flex: 1 1 auto; }

.airport-row, .flight-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.airport-row:hover, .flight-row:hover { background: var(--panel-2); }
.airport-row.active { background: #1a2f45; }

.iata {
  flex: 0 0 46px;
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 0;
}
.airport-row.active .iata { background: var(--accent); border-color: var(--accent); color: #06121a; }
.airport-meta { min-width: 0; }
.airport-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.airport-city { font-size: 11px; color: var(--muted); }

.flight-row { cursor: pointer; font-variant-numeric: tabular-nums; }
.callsign { font-weight: 650; flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flight-sub { font-size: 11px; color: var(--muted); white-space: nowrap; }
.muted { color: var(--muted); font-size: 13px; cursor: default; }

/* ---------- map ---------- */
#map-wrap { position: relative; flex: 1 1 auto; min-width: 0; }
#map { position: absolute; inset: 0; background: #05070b; }

#stats {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 500;
}
.stat {
  background: rgba(17, 21, 29, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  text-align: center;
  min-width: 86px;
  backdrop-filter: blur(4px);
}
.stat-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); }
.stat-value { display: block; font-size: 17px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

#banner {
  position: absolute;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  background: #3a2a10;
  border: 1px solid #7a5a1c;
  color: #ffd98a;
  font-size: 13px;
  padding: 9px 14px;
  border-radius: 10px;
  max-width: min(560px, 90%);
  text-align: center;
}
#banner button {
  margin-left: 10px;
  background: transparent;
  border: 1px solid #7a5a1c;
  color: #ffd98a;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 12px;
}

#legend {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 500;
  display: flex;
  gap: 12px;
  background: rgba(17, 21, 29, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--muted);
  backdrop-filter: blur(4px);
}
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }

.hidden { display: none !important; }

/* leaflet tweaks */
.airport-pill {
  background: #16202f;
  border: 1px solid #2b3a55;
  color: #cfe3ff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  cursor: pointer;
}
.airport-pill.active { background: var(--accent); border-color: var(--accent); color: #06121a; }
.plane-marker { background: transparent; border: none; }
.leaflet-popup-content { font-size: 13px; line-height: 1.5; margin: 10px 12px; }
.leaflet-popup-content b { font-size: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  #layout { flex-direction: column; }
  #sidebar { width: 100%; flex: 0 0 34%; border-right: none; border-bottom: 1px solid var(--border); }
  #airport-list { max-height: 120px; }
  #topbar { flex-wrap: wrap; }
  #stats { top: 8px; }
  .stat { min-width: 70px; padding: 6px 10px; }
  .updated { display: none; }
}
