:root {
    --accent: #00ffcc;
    --accent-dim: rgba(0, 255, 204, 0.14);
    --panel: rgba(14, 18, 22, 0.86);
    --panel-border: rgba(255, 255, 255, 0.09);
    --card: rgba(255, 255, 255, 0.04);
    --text: #e8eef2;
    --muted: #8b98a5;
    --warn: #ffb547;
    --bad: #ff5c7a;
    --rare: #ff8a3d;
}
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: #111;
    font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--text);
}
#map { height: 100%; width: 100%; background: #000; }
.leaflet-container { background: #111; }

/* ── Floating panel ─────────────────────────────────────────────── */
#panel {
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 1000;
    width: 330px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    backdrop-filter: blur(14px) saturate(140%);
    -webkit-backdrop-filter: blur(14px) saturate(140%);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 255, 204, 0.04) inset;
    transition: width 0.35s cubic-bezier(.2,.8,.2,1), transform 0.25s ease;
    overflow: hidden;
    animation: panelIn .5s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes panelIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.brand { font-size: 15px; }
.card h3 span { color: var(--muted); }
#panel.wide { width: 460px; }
#panel.collapsed .panel-body { display: none; }

.panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 10px 16px;
    border-bottom: 1px solid var(--panel-border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; letter-spacing: 0.2px; flex: 1; min-width: 0; }
.brand small { color: var(--muted); font-weight: 500; }
.live-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--muted);
    flex: none;
}
.live-dot.on { background: var(--accent); box-shadow: 0 0 0 0 rgba(0,255,204,.6); animation: pulse 1.8s infinite; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0,255,204,.55); }
    70% { box-shadow: 0 0 0 8px rgba(0,255,204,0); }
    100% { box-shadow: 0 0 0 0 rgba(0,255,204,0); }
}
.icon-btn {
    background: transparent; border: 0; color: var(--muted);
    width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
    font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: rgba(255,255,255,0.07); color: var(--text); }

.tabs {
    display: flex;
    gap: 4px;
    margin: 10px 12px 0;
    padding: 4px;
    background: rgba(0,0,0,0.28);
    border-radius: 11px;
}
.tab {
    flex: 1;
    border: 0;
    background: transparent;
    color: var(--muted);
    padding: 7px 10px;
    border-radius: 8px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent-dim); color: var(--accent); }

.panel-body { overflow-y: auto; padding: 12px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.15) transparent; }
#panel { color-scheme: dark; }
.no-anim #panel, .no-anim .tab { transition: none !important; }
.panel-body::-webkit-scrollbar { width: 8px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 8px; }
.view[hidden] { display: none !important; }

/* Cards & stats */
.card {
    background: var(--card);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
}
.card h3 {
    margin: 0 0 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.1px;
    text-transform: uppercase;
    color: var(--muted);
    display: flex; justify-content: space-between; align-items: baseline;
}
.card h3 span { text-transform: none; letter-spacing: 0; font-weight: 500; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat .v { font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .v.small { font-size: 15px; }
.stat .l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.accent { color: var(--accent); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }

.progress { height: 6px; background: rgba(255,255,255,0.07); border-radius: 6px; overflow: hidden; margin: 8px 0 6px; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, #00c9a7, var(--accent)); border-radius: 6px; transition: width .6s ease; }
.row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); gap: 8px; }
.row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.rows .row { padding: 5px 0; border-bottom: 1px dashed rgba(255,255,255,0.06); }
.rows .row:last-child { border-bottom: 0; }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 42px; margin-top: 10px; }
.spark div { flex: 0 1 16px; min-width: 4px; background: rgba(0,255,204,.35); border-radius: 3px 3px 0 0; }
.spark div:last-child { background: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 11.5px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,0.06); color: var(--text); }
.chip em { font-style: normal; color: var(--muted); margin-left: 4px; }

.alert-item { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.alert-item:last-child { border-bottom: 0; }
.badge { flex: none; min-width: 44px; text-align: center; font-size: 11px; font-weight: 700; padding: 4px 6px; border-radius: 8px; background: rgba(255,255,255,.07); font-variant-numeric: tabular-nums; }
.alert-item .t { flex: 1; min-width: 0; }
.alert-item .t div:first-child { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-item .t div:last-child { font-size: 11.5px; color: var(--muted); }
.alert-item a { color: var(--accent); text-decoration: none; font-size: 12px; flex: none; }
.empty { color: var(--muted); font-size: 12.5px; text-align: center; padding: 8px 0; }

.toggle { display: flex; align-items: center; justify-content: space-between; font-size: 13px; padding: 4px 0; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.foot { font-size: 11px; color: var(--muted); text-align: center; padding: 2px 0 4px; }
.foot.disclaimer { font-size: 10.5px; line-height: 1.4; opacity: .8; padding: 6px 8px 4px; border-top: 1px solid var(--panel-border); margin-top: 6px; }

/* ── Blue Sky markers ─────────────────────────────────────────── */
.bs-icon { pointer-events: none; }
.bs-marker { position: relative; width: 0; height: 0; --c: #38bdf8; pointer-events: auto; cursor: pointer; }
.bs-marker.amber { --c: #ffb547; }
.bs-marker.red { --c: #ff5c7a; }
.bs-marker .halo {
    position: absolute; left: -26px; top: -26px; width: 52px; height: 52px; border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--c) 45%, transparent) 0%, transparent 70%);
}
.bs-marker .ring {
    position: absolute; left: -11px; top: -11px; width: 22px; height: 22px; border-radius: 50%;
    border: 2px solid var(--c); opacity: .9; animation: bsPulse 2.2s ease-out infinite;
}
.bs-marker .dot {
    position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%;
    background: var(--c); box-shadow: 0 0 12px var(--c), 0 0 0 2px rgba(0,0,0,.55);
}
.bs-marker .lbl {
    position: absolute; left: 50%; top: 13px; transform: translateX(-50%);
    white-space: nowrap; font: 600 11px/1 ui-sans-serif, system-ui, sans-serif; color: #fff;
    background: rgba(10,14,18,.82); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
    padding: 3px 6px; border-radius: 6px; font-variant-numeric: tabular-nums;
}
/* ── Special aircraft (14+, 1 of 1, unknown type) ─────────────── */
.ac-icon { pointer-events: none; }
.ac { position: relative; width: 0; height: 0; --c: #ff8a3d; pointer-events: auto; cursor: pointer; }
.ac .glow {
    position: absolute; left: -20px; top: -20px; width: 40px; height: 40px; border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--c) 55%, transparent) 0%, transparent 68%);
    animation: acGlow 2.4s ease-in-out infinite;
}
.ac svg {
    position: absolute; left: -14px; top: -14px; width: 28px; height: 28px; overflow: visible;
    filter: drop-shadow(0 0 3px var(--c)) drop-shadow(0 0 9px var(--c));
}
.ac svg .body { fill: #f4f7fb; stroke: var(--c); stroke-width: 1.1; stroke-linejoin: round; }
.ac svg .line { stroke: var(--c); stroke-width: 1.3; stroke-linecap: round; fill: none; }
.ac svg .disc { fill: color-mix(in srgb, var(--c) 18%, transparent); stroke: var(--c); stroke-width: .8; opacity: .8; }
.ac .lbl {
    position: absolute; left: 50%; top: 15px; transform: translateX(-50%);
    white-space: nowrap; font: 600 11px/1 ui-sans-serif, system-ui, sans-serif; color: #fff;
    background: rgba(10,14,18,.85); border: 1px solid color-mix(in srgb, var(--c) 60%, transparent);
    padding: 3px 6px; border-radius: 6px; font-variant-numeric: tabular-nums;
}
@keyframes acGlow { 0%, 100% { opacity: .55; transform: scale(.9); } 50% { opacity: 1; transform: scale(1.15); } }
.bs-compact .ac .lbl { display: none; }
.bs-compact .ac:hover .lbl { display: block; z-index: 1; }
.tag { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 6px; margin-right: 4px; color: #0b0f13; }
.tag.one_of_one { background: #ff3d9a; }
.tag.rare { background: #ff8a3d; }
.tag.unknown { background: #a78bfa; }
.ac-item { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 8px; cursor: pointer; }
.ac-item:hover { background: rgba(255,255,255,0.05); }
.ac-item .mini { width: 22px; height: 22px; flex: none; }
.ac-item .mini svg { width: 22px; height: 22px; overflow: visible; }
.ac-item .mini .body { fill: #f4f7fb; stroke: var(--c); stroke-width: 1.2; }
.ac-item .mini .line { stroke: var(--c); stroke-width: 1.4; fill: none; }
.ac-item .mini .disc { fill: none; stroke: var(--c); stroke-width: .9; }
.ac-item .t { flex: 1; min-width: 0; }
.ac-item .t div:first-child { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-item .t div:last-child { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ac-filters label { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.06); cursor: pointer; user-select: none; }
.ac-filters input { accent-color: var(--accent); margin: 0; }
.ac-filters .dot { width: 8px; height: 8px; border-radius: 50%; }

/* Zoomed far out, nearby areas overlap: show labels on hover only */
.bs-compact .bs-marker .lbl { display: none; }
.bs-compact .bs-marker:hover .lbl { display: block; z-index: 1; }
@keyframes bsPulse {
    0% { transform: scale(.6); opacity: .95; }
    100% { transform: scale(2.4); opacity: 0; }
}
.bs-item { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 8px; cursor: pointer; }
.bs-item:hover { background: rgba(255,255,255,0.05); }
.bs-item .pip { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #38bdf8; box-shadow: 0 0 8px #38bdf8; }
.bs-item .pip.amber { background: #ffb547; box-shadow: 0 0 8px #ffb547; }
.bs-item .pip.red { background: #ff5c7a; box-shadow: 0 0 8px #ff5c7a; }
.bs-item .t { flex: 1; min-width: 0; }
.bs-item .t div:first-child { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-item .t div:last-child { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bs-item .cd { font-size: 12.5px; font-weight: 650; font-variant-numeric: tabular-nums; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: rgba(14,18,22,.95); color: var(--text); border: 1px solid var(--panel-border); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; line-height: 1.45; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }

/* Keep Leaflet's attribution readable on dark */
.leaflet-control-attribution { background: rgba(0,0,0,.5) !important; color: #889 !important; }
.leaflet-control-attribution a { color: #9ab !important; }

@media (max-width: 520px) {
    #panel, #panel.wide { left: 12px; right: 12px; top: 12px; width: auto; max-width: none; max-height: 70vh; }
}

.tabs[hidden] { display: none; }
