:root {
  --bg: #1a1f2e;
  --panel: #1e2435;
  --panel2: #242a3d;
  --border: rgba(255,255,255,0.08);
  --accent: #f5a623;
  --accent2: #ffd166;
  --blue: #4d9ef5;
  --green: #3ecf8e;
  --red: #f56565;
  --text: #e8eaf0;
  --muted: #7a82a0;
  --topbar: 52px;
  --botbar: 68px;
  --panel-w: 320px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* MAP */
#map {
  position: absolute;
  inset: var(--topbar) 0 var(--botbar) 0;
  z-index: 0;
}

/* Force dark map text */
.leaflet-container { background: #0d1117; }

/* TOP BAR */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  z-index: 1000;
  backdrop-filter: blur(10px);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.logo-text {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.3px;
  color: var(--text);
}

.logo-text span { color: var(--accent); }

.logo-sub {
  font-size: 0.6rem;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 1px;
  display: block;
  font-family: 'DM Mono', monospace;
}

/* Search */
.search-wrap {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-wrap input {
  width: 100%;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 36px 7px 14px;
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-wrap input::placeholder { color: var(--muted); }
.search-wrap input:focus { border-color: rgba(245,166,35,0.4); }

.search-wrap .kbd {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.62rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'DM Mono', monospace;
}

/* Top stats */
.top-stats {
  display: flex;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
}

.stat-chip {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Mono', monospace;
}

.stat-chip .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.dot-green { background: var(--green); }
.dot-amber { background: var(--accent); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.stat-chip .num { color: var(--text); font-weight: 500; }
.stat-chip .lbl { color: var(--muted); font-size: 0.65rem; }

/* UTC Clock */
.utc-clock {
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  flex-shrink: 0;
}

.utc-clock .utc-label { color: var(--muted); font-size: 0.6rem; margin-left: 4px; }

/* Login / Menu */
.topbar-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.topbar-btn:hover { border-color: var(--accent); color: var(--accent); }

/* BOTTOM TOOLBAR */
#toolbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--botbar);
  background: rgba(30,36,53,0.96);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 1000;
  backdrop-filter: blur(12px);
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 24px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.3px;
  transition: all 0.18s;
  border: 1px solid transparent;
  background: none;
  font-family: 'DM Sans', sans-serif;
}

.tool-btn:hover { color: var(--text); background: var(--panel2); }
.tool-btn.active { color: var(--accent); border-color: rgba(245,166,35,0.25); background: rgba(245,166,35,0.07); }
.tool-btn svg { flex-shrink: 0; }

/* MAP CONTROLS */
.map-controls {
  position: fixed;
  right: 12px;
  top: calc(var(--topbar) + 12px);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 900;
}

.map-btn {
  width: 36px; height: 36px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  transition: all 0.18s;
  font-family: monospace;
  line-height: 1;
}

.map-btn:hover { background: var(--panel2); color: var(--text); border-color: rgba(255,255,255,0.15); }

/* FLIGHT PANEL */
#flight-panel {
  position: fixed;
  top: var(--topbar);
  right: 0;
  width: var(--panel-w);
  bottom: var(--botbar);
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 800;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#flight-panel.open { transform: translateX(0); }

.fp-header {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.fp-close {
  position: absolute;
  top: 14px; right: 14px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.9rem;
  transition: all 0.15s;
}

.fp-close:hover { color: var(--text); border-color: rgba(255,255,255,0.2); }

.fp-callsign {
  font-family: 'DM Mono', monospace;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--text);
}

.fp-airline {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.fp-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  background: rgba(62,207,142,0.12);
  border: 1px solid rgba(62,207,142,0.25);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* Route display */
.fp-route {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.route-display {
  display: flex;
  align-items: center;
  gap: 12px;
}

.route-airport {
  text-align: center;
  flex: 1;
}

.route-iata {
  font-family: 'DM Mono', monospace;
  font-size: 1.6rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1;
}

.route-city {
  font-size: 0.62rem;
  color: var(--muted);
  margin-top: 3px;
}

.route-arrow {
  flex: 2;
  position: relative;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 4px;
}

.route-line {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, var(--border), rgba(245,166,35,0.6), var(--border));
  position: relative;
}

.route-plane-icon {
  font-size: 1rem;
  margin-top: -2px;
}

.route-duration {
  font-size: 0.6rem;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

/* Data grid */
.fp-data {
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.data-cell {
  background: var(--panel2);
  border-radius: 8px;
  padding: 10px 12px;
}

.data-cell .d-label {
  font-size: 0.58rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.data-cell .d-value {
  font-family: 'DM Mono', monospace;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
}

.data-cell .d-unit {
  font-size: 0.6rem;
  color: var(--muted);
  margin-left: 2px;
}

/* Track plot */
.fp-track {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.fp-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.alt-chart {
  height: 48px;
  position: relative;
  overflow: hidden;
}

.alt-chart canvas { display: block; }

/* Aircraft info */
.fp-aircraft {
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
}

.aircraft-card {
  background: var(--panel2);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.aircraft-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.aircraft-info .ac-type {
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.aircraft-info .ac-reg {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 2px;
}

.fp-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
}

.fp-row .r-key { color: var(--muted); }
.fp-row .r-val { color: var(--text); font-family: 'DM Mono', monospace; font-size: 0.72rem; }
.fp-row .r-val.live { color: var(--green); }

/* CUSTOM PLANE MARKERS */
.plane-marker {
  cursor: pointer;
  transition: transform 0.15s;
}

/* TOOLTIP */
.flight-tooltip {
  background: var(--panel) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  color: var(--text) !important;
  font-family: 'DM Mono', monospace !important;
  font-size: 0.7rem !important;
  padding: 6px 10px !important;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4) !important;
}

.flight-tooltip .tt-callsign { font-weight: 600; font-size: 0.8rem; color: var(--accent); }
.flight-tooltip .tt-route { color: var(--muted); font-size: 0.65rem; margin-top: 2px; }

/* LAYER BADGE */
.view-badge {
  position: fixed;
  top: calc(var(--topbar) + 12px);
  left: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 900;
  color: var(--muted);
  font-family: 'DM Mono', monospace;
}

.view-badge .vb-label { color: var(--text); font-weight: 500; }

/* FLIGHT COUNT BADGE */
.flight-count-badge {
  position: fixed;
  bottom: calc(var(--botbar) + 12px);
  left: 12px;
  background: rgba(30,36,53,0.92);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.7rem;
  z-index: 900;
  backdrop-filter: blur(8px);
  font-family: 'DM Mono', monospace;
}

.flight-count-badge .fc-num { font-size: 1.1rem; font-weight: 600; color: var(--accent); display: block; }
.flight-count-badge .fc-lbl { color: var(--muted); font-size: 0.6rem; margin-top: 1px; }

/* Hide default Leaflet controls */
.leaflet-control-zoom { display: none !important; }
.leaflet-control-attribution {
  background: rgba(0,0,0,0.4) !important;
  color: rgba(255,255,255,0.3) !important;
  font-size: 0.55rem !important;
}
.leaflet-control-attribution a { color: rgba(255,255,255,0.4) !important; }
