:root {
  --bg: #0b1020;
  --panel: #131a2e;
  --panel-2: #1a2240;
  --text: #e8ecf5;
  --muted: #8d97b3;
  --accent: #58a6ff;
  --border: #29335c;
  --outbound: #1e88e5;
  --mike: #7c3aed;
  --kass: #10b981;
  --ground: #f59e0b;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #131a2e 0%, #0b1020 100%);
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.title h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 0.2rem 0 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.filter {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.15s background, 0.15s border-color;
}
.filter:hover { border-color: var(--accent); }
.filter.active {
  background: var(--accent);
  color: #0b1020;
  border-color: var(--accent);
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: calc(100vh - 88px);
  min-height: 540px;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  #map { height: 60vh; }
}

#map {
  width: 100%;
  height: 100%;
  background: #0b1020;
}

.sidebar {
  overflow-y: auto;
  padding: 1rem 1rem 1.5rem;
  border-left: 1px solid var(--border);
  background: var(--panel);
}

.summary-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}
.summary-card h2 {
  margin: 0 0 0.6rem 0;
  font-size: 1rem;
  color: var(--accent);
}
.quick-facts {
  list-style: none;
  padding: 0;
  margin: 0 0 0.6rem 0;
  font-size: 0.9rem;
}
.quick-facts li { padding: 0.15rem 0; }
.totals {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
  gap: 0.4rem;
}
.muted { color: var(--muted); }

.journey-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
  position: relative;
  overflow: hidden;
}
.journey-card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--journey-color, var(--accent));
}
.journey-card.dimmed { opacity: 0.35; }
.journey-card h3 {
  margin: 0 0 0.15rem 0;
  font-size: 0.98rem;
}
.journey-meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.8rem;
  margin-bottom: 0.55rem;
}
.journey-meta strong { color: var(--text); font-weight: 600; }

.leg {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.6rem;
  padding: 0.55rem 0;
  border-top: 1px dashed var(--border);
  font-size: 0.85rem;
}
.leg:first-of-type { border-top: none; }
.leg-route {
  font-weight: 700;
  letter-spacing: 0.02em;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--text);
}
.leg-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.leg-detail { color: var(--muted); font-size: 0.8rem; grid-column: 2; }
.layover {
  font-size: 0.78rem;
  color: var(--ground);
  padding: 0.25rem 0;
  font-style: italic;
}

.timeline-wrap {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem 1.5rem;
  background: linear-gradient(180deg, #0b1020 0%, #131a2e 100%);
}
.timeline-wrap h2 {
  margin: 0 0 0.8rem 0;
  font-size: 1rem;
  color: var(--accent);
}
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: relative;
  padding-left: 1.2rem;
  border-left: 2px solid var(--border);
}
.tl-event {
  display: grid;
  grid-template-columns: 130px 80px 1fr;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.02);
  border-left: 3px solid var(--journey-color, var(--accent));
  position: relative;
}
.tl-event::before {
  content: "";
  position: absolute;
  left: -1.45rem;
  top: 50%;
  transform: translateY(-50%);
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--journey-color, var(--accent));
  box-shadow: 0 0 0 2px var(--bg);
}
.tl-when { color: var(--muted); white-space: nowrap; }
.tl-route { font-family: ui-monospace, monospace; font-weight: 700; }
.tl-desc { color: var(--text); }

.footer {
  padding: 0.9rem 1.5rem 1.2rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

/* Leaflet popups in dark theme */
.leaflet-popup-content-wrapper {
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.leaflet-popup-tip { background: var(--panel-2); }
.leaflet-popup-content { margin: 0.7rem 0.85rem; font-size: 0.85rem; }
.leaflet-popup-content strong { color: var(--accent); }

.airport-marker {
  background: var(--text);
  color: #0b1020;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  padding: 3px 6px;
  border-radius: 6px;
  border: 2px solid #0b1020;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  white-space: nowrap;
  font-family: ui-monospace, monospace;
}

.plane-icon {
  font-size: 1.4rem;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.6));
}
