/* =========================================================
   FLIGHTDECK — moderne Oberfläche
   ========================================================= */

:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --border: #e3e6eb;
  --text: #0f1419;
  --muted: #5b6472;
  --faint: #8a93a1;
  --accent: #2f6fed;
  --accent-soft: rgba(47, 111, 237, 0.12);
  --good: #12a150;
  --warn: #d97706;
  --bad: #e5484d;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
  --shadow-float: 0 2px 6px rgba(16, 24, 40, 0.08), 0 10px 30px rgba(16, 24, 40, 0.12);
  --tile-filter: grayscale(1) brightness(1.04) contrast(0.86);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1015;
    --surface: #151920;
    --surface-2: #1b2029;
    --border: #262c36;
    --text: #e8ecf1;
    --muted: #9aa4b2;
    --faint: #6b7483;
    --accent: #5b8cff;
    --accent-soft: rgba(91, 140, 255, 0.16);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-float: 0 2px 6px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.4);
    --tile-filter: invert(1) grayscale(1) brightness(0.78) contrast(0.9);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1015;
  --surface: #151920;
  --surface-2: #1b2029;
  --border: #262c36;
  --text: #e8ecf1;
  --muted: #9aa4b2;
  --faint: #6b7483;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.16);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  --shadow-float: 0 2px 6px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.4);
  --tile-filter: invert(1) grayscale(1) brightness(0.78) contrast(0.9);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100dvh;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
svg { fill: currentColor; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 1000;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--text); font-weight: 700; font-size: 17px; letter-spacing: -0.01em;
  flex: none; margin-right: 4px;
}
.brand svg { width: 22px; height: 22px; color: var(--accent); transform: rotate(45deg); }

.loc, .search {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 38px; padding: 0 6px 0 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.loc:focus-within, .search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ico { width: 18px; height: 18px; color: var(--faint); flex: none; }
.loc select {
  border: 0; background: transparent; outline: none; cursor: pointer;
  max-width: 230px; padding: 0 2px; font-weight: 500;
}
.search { flex: 1; min-width: 180px; max-width: 460px; }
.search input { border: 0; background: transparent; outline: none; flex: 1; min-width: 0; height: 100%; }
.search input::placeholder { color: var(--faint); }
.search kbd {
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--faint);
  border: 1px solid var(--border); border-radius: 5px; padding: 0 6px; background: var(--surface);
}

.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: transparent; border: 1px solid transparent; cursor: pointer; color: var(--muted);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small svg { width: 18px; height: 18px; }
.loc .icon-btn { width: 30px; height: 30px; }

.settings-wrap { position: relative; }
.popover {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 260px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-float);
  display: grid; gap: 12px;
  animation: pop 0.16s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } }
.popover label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.popover select {
  height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2);
  padding: 0 8px; font-size: 14px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text);
}
.switch-link { font-size: 14px; font-weight: 600; padding-top: 4px; border-top: 1px solid var(--border); padding-top: 12px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  min-height: 0;
}
.map-area { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }
.sidebar {
  background: var(--bg);
  border-left: 1px solid var(--border);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 14px; display: flex; flex-direction: column; gap: 14px;
}

/* ---------- Karte ---------- */
.leaflet-container { font: inherit; background: var(--bg); }
.leaflet-tile-pane { filter: var(--tile-filter); }
.leaflet-control-zoom { border: 0 !important; box-shadow: var(--shadow-float) !important; border-radius: 10px !important; overflow: hidden; }
.leaflet-control-zoom a {
  background: var(--surface) !important; color: var(--text) !important;
  border-color: var(--border) !important; width: 34px !important; height: 34px !important; line-height: 34px !important;
}
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--surface) 85%, transparent) !important;
  color: var(--muted) !important; border-radius: 6px 0 0 0;
}
.leaflet-control-attribution a { color: var(--muted) !important; }

.map-status {
  position: absolute; left: 12px; top: 12px; z-index: 500;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-float);
  font-size: 13px; font-weight: 500; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.map-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); position: relative; }
.map-status .dot::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--good); opacity: 0; animation: ping 2s steps(3) infinite;
}
.map-status.err .dot { background: var(--bad); }
.map-status.err .dot::after { border-color: var(--bad); }
.map-status.busy .dot { background: var(--warn); }
@keyframes ping {
  0% { transform: scale(0.6); opacity: 0.8; }
  10% { transform: scale(0.793); opacity: 0.672; }
  20% { transform: scale(0.97); opacity: 0.553; }
  30% { transform: scale(1.134); opacity: 0.444; }
  40% { transform: scale(1.285); opacity: 0.343; }
  50% { transform: scale(1.422); opacity: 0.252; }
  60% { transform: scale(1.542); opacity: 0.172; }
  70% { transform: scale(1.645); opacity: 0.104; }
  80% { transform: scale(1.725); opacity: 0.05; }
  90% { transform: scale(1.78); opacity: 0.014; }
  100% { transform: scale(1.8); opacity: 0; }
}

.map-btn {
  position: absolute; right: 12px; top: 12px; z-index: 500;
  width: 38px; height: 38px; border-radius: 10px; border: 0; cursor: pointer;
  display: grid; place-items: center; color: var(--text);
  background: var(--surface); box-shadow: var(--shadow-float);
}
.map-btn svg { width: 20px; height: 20px; }
.map-btn:hover { color: var(--accent); }

.alt-legend {
  position: absolute; left: 12px; bottom: 22px; z-index: 500;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.alt-bar {
  width: 140px; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, #9aa3ad 0%, #f08c00 6%, #e8b400 18%, #74b816 32%, #12b886 48%, #15aabf 62%, #228be6 76%, #7048e8 100%);
}

.pin-hint {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 600;
  padding: 10px 14px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-float); white-space: nowrap;
}
.pin-hint button { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font-weight: 600; }

.obs-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15), 0 2px 6px rgba(0, 0, 0, 0.3);
  position: relative;
}
.obs-dot::after {
  content: ''; position: absolute; inset: -9px; border-radius: 50%;
  background: var(--accent); opacity: 0.25; animation: halo 2.4s steps(3) infinite;
}
@keyframes halo {
  0% { transform: scale(0.4); opacity: 0.35; }
  8.333% { transform: scale(0.535); opacity: 0.303; }
  16.667% { transform: scale(0.66); opacity: 0.259; }
  25% { transform: scale(0.778); opacity: 0.218; }
  33.333% { transform: scale(0.888); opacity: 0.179; }
  41.667% { transform: scale(0.991); opacity: 0.143; }
  50% { transform: scale(1.085); opacity: 0.11; }
  58.333% { transform: scale(1.169); opacity: 0.081; }
  66.667% { transform: scale(1.244); opacity: 0.055; }
  75% { transform: scale(1.307); opacity: 0.033; }
  83.333% { transform: scale(1.356); opacity: 0.016; }
  91.667% { transform: scale(1.388); opacity: 0.004; }
  100% { transform: scale(1.4); opacity: 0; }
}
.obs-label, .apt-label {
  font-size: 12px; font-weight: 600; white-space: nowrap;
  color: var(--text);
  text-shadow: 0 0 3px var(--surface), 0 0 3px var(--surface), 0 0 3px var(--surface);
}
.apt-marker {
  width: 10px; height: 10px; border-radius: 3px; background: var(--surface);
  border: 2px solid var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.leaflet-tooltip.plane-tip {
  background: var(--surface); color: var(--text); border: 0; border-radius: 8px;
  box-shadow: var(--shadow-float); padding: 6px 10px; font-size: 13px;
}
.leaflet-tooltip.plane-tip::before { border-top-color: var(--surface); }
.plane-tip b { font-weight: 700; }
.plane-tip span { color: var(--muted); }

/* ---------- Karten (Cards) ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Flugzeug-Karte */
.flight { padding: 16px; }
.flight-head { display: flex; align-items: center; justify-content: space-between; min-height: 30px; margin-bottom: 10px; }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); }
.eyebrow.tracking { color: var(--accent); }
.flight-actions { display: flex; align-items: center; gap: 6px; }
.pill-btn {
  height: 28px; padding: 0 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--muted);
}
.pill-btn.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.flight-content.swap { animation: swapIn 0.35s ease-out; }
@keyframes swapIn { from { opacity: 0; transform: translateY(6px); } }

.title-row { display: flex; align-items: center; gap: 12px; }
.airline-logo {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: 0.02em; color: #fff;
  background: var(--accent);
}
.title-text { min-width: 0; flex: 1; }
.title-text h2 { font-size: 19px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-text .sub { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.title-text .sub b { color: var(--text); font-weight: 600; }
.phase {
  flex: none; font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.phase.climb { background: rgba(18, 161, 80, 0.12); color: var(--good); }
.phase.descent { background: rgba(217, 119, 6, 0.13); color: var(--warn); }
.phase.cruise { background: var(--accent-soft); color: var(--accent); }
.phase.emergency { background: var(--bad); color: #fff; }

.photo {
  position: relative; margin-top: 14px; border-radius: 12px; overflow: hidden;
  aspect-ratio: 16 / 9; background: var(--surface-2);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 0.4s ease; }
.photo img.loaded { opacity: 1; }
.photo figcaption {
  position: absolute; right: 8px; bottom: 8px;
  font-size: 11px; padding: 3px 8px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(4px);
}
.photo figcaption a { color: #fff; }

.route { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-top: 16px; }
.apt .code { font-size: 26px; font-weight: 800; letter-spacing: 0.01em; line-height: 1; font-variant-numeric: tabular-nums; }
.apt .city { font-size: 13px; color: var(--muted); margin-top: 4px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apt.to { text-align: right; }
.apt.to .city { margin-left: auto; }
.route-mid .bar { position: relative; height: 4px; border-radius: 2px; background: var(--border); }
.route-mid .bar i {
  position: absolute; inset: 0; border-radius: 2px; background: var(--accent);
  transform-origin: left center; transform: scaleX(0); transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.route-mid .plane {
  position: absolute; top: 50%; left: 0%; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  color: var(--accent); transition: left 0.9s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 0 0 var(--surface)) drop-shadow(0 1px 1px rgba(0,0,0,0.2));
}
.route-mid .plane svg { width: 100%; height: 100%; transform: rotate(90deg); }
.route-meta { margin-top: 10px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.route-meta b { color: var(--text); font-weight: 600; }
.route.unknown .code { color: var(--faint); }

.metrics { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 14px; }
.metric { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.metric .k { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--faint); }
.metric .v { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric .v small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.metric .s { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric .up { color: var(--good); }
.metric .down { color: var(--warn); }

.empty { display: grid; gap: 10px; }
.empty p { color: var(--muted); font-size: 14px; }
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.skeleton.line { height: 16px; }
.skeleton.block { height: 150px; }
.w60 { width: 60%; } .w40 { width: 40%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Verkehrsliste */
.traffic { padding: 14px 0 6px; display: flex; flex-direction: column; min-height: 0; }
.traffic-head { display: flex; align-items: center; gap: 10px; padding: 0 16px 10px; }
.traffic-head h3 { font-size: 15px; font-weight: 700; flex: none; }
.count {
  display: inline-block; min-width: 24px; padding: 1px 7px; margin-left: 4px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums;
}
.traffic-head input {
  margin-left: auto; width: 150px; height: 32px; border-radius: 8px; padding: 0 10px;
  border: 1px solid var(--border); background: var(--surface-2); outline: none; font-size: 14px;
}
.traffic-head input:focus { border-color: var(--accent); }
.traffic-list { list-style: none; }
.traffic-list li {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 10px;
  padding: 8px 16px; cursor: pointer; border-top: 1px solid var(--border);
  transition: background 0.12s;
  content-visibility: auto; contain-intrinsic-size: auto 50px;
}
.traffic-list li:hover { background: var(--surface-2); }
.traffic-list li.sel { background: var(--accent-soft); }
.traffic-list .t-ico { width: 22px; height: 22px; }
.traffic-list .t-main { min-width: 0; }
.traffic-list .t-cs { font-weight: 700; font-size: 14px; }
.traffic-list .t-cs span { font-weight: 500; color: var(--muted); }
.traffic-list .t-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.traffic-list .t-side { text-align: right; font-variant-numeric: tabular-nums; }
.traffic-list .t-alt { font-size: 13px; font-weight: 600; }
.traffic-list .t-dist { font-size: 12px; color: var(--muted); }
.traffic-empty { padding: 16px; color: var(--muted); font-size: 14px; }
.traffic-more { padding: 10px 16px 8px; font-size: 12px; color: var(--faint); border-top: 1px solid var(--border); }

.credits { font-size: 12px; color: var(--faint); padding: 2px 4px 8px; line-height: 1.7; }
.credits a { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) 360px; }
  .loc select { max-width: 160px; }
}
@media (max-width: 860px) {
  body { display: block; height: auto; overflow: auto; }
  .topbar { flex-wrap: wrap; position: sticky; top: 0; gap: 8px; padding: 8px 10px; }
  .brand span { display: none; }
  .loc { flex: 1 1 0; min-width: 0; }
  .loc select { flex: 1; min-width: 0; max-width: none; }
  .top-right { margin-left: 0; gap: 4px; }
  .chip { padding: 0 9px; }
  .search { order: 5; flex-basis: 100%; max-width: none; }
  .search kbd { display: none; }
  .layout { display: block; }
  .map-area { height: 58vh; min-height: 320px; }
  .sidebar { border-left: 0; overflow: visible; }
  .alt-bar { width: 90px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
