:root {
  --bg: #070c18;
  --bg2: #0d1428;
  --card: rgba(24, 34, 60, 0.72);
  --card-solid: #16213a;
  --card2: #1c2a49;
  --line: rgba(96, 129, 194, 0.22);
  --text: #eaf1ff;
  --muted: #8ea1c9;
  --accent: #38bdf8;
  --accent2: #6366f1;
  --hot: #fb7185;
  --warn: #fbbf24;
  --ok: #34d399;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(56, 189, 248, 0.14), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(13, 20, 40, 0.9), rgba(7, 12, 24, 0.55));
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  flex: none; z-index: 600;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.logo {
  font-size: 22px; width: 40px; height: 40px; flex: none;
  display: grid; place-items: center; border-radius: 13px;
  background: linear-gradient(145deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.35);
}
.brand-txt { min-width: 0; }
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: .3px; font-weight: 700;
  display: flex; align-items: center; gap: 7px; }
.ver { font-size: 12px; font-weight: 800; letter-spacing: .3px; color: #04121f;
  background: linear-gradient(145deg, var(--accent), var(--accent2));
  padding: 2px 7px; border-radius: 8px; }
.status { margin: 1px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 48vw; }
.controls { display: flex; align-items: center; gap: 8px; }
.ctl { display: flex; flex-direction: column; font-size: 9px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted); gap: 2px; }
.ctl select {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 6px 8px; font-size: 13px;
}
.btn {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 11px; padding: 9px 12px; font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: transform .1s, background .2s, box-shadow .2s;
}
.btn.icon { padding: 9px 11px; }
.btn:active { transform: scale(.95); }
.btn.on {
  background: linear-gradient(145deg, var(--accent), var(--accent2));
  color: #04121f; border-color: transparent; font-weight: 700;
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.35);
}

/* ---- tabs ---- */
.tabs {
  display: flex; gap: 6px; padding: 8px 12px; flex: none; z-index: 500;
  background: rgba(7, 12, 24, 0.6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1; padding: 9px 10px; border: 1px solid transparent; border-radius: 11px;
  background: transparent; color: var(--muted); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all .18s;
}
.tab.active {
  background: var(--card); color: var(--text); border-color: var(--line);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.12);
}

/* ---- views ---- */
.view { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.view.hidden { display: none; }

/* ---- manual location panel ---- */
.loc-panel {
  position: absolute; top: 108px; right: 12px; z-index: 700;
  background: var(--card-solid); border: 1px solid var(--line); border-radius: 16px;
  padding: 13px; width: min(300px, calc(100vw - 24px)); box-shadow: var(--shadow);
}
.loc-panel.hidden { display: none; }
.loc-title { font-size: 13px; font-weight: 700; margin-bottom: 9px; }
.loc-row { display: flex; gap: 8px; margin-bottom: 8px; }
.loc-row label { flex: 1; font-size: 11px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.loc-row input {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px; font-size: 14px; width: 100%;
}
.loc-row.btns .btn { flex: 1; text-align: center; }
.loc-tip { font-size: 11px; color: var(--muted); margin: 4px 0 0; }

/* ---- map ---- */
#map { flex: 1 1 45%; min-height: 200px; background: #060a14; z-index: 0; }
.leaflet-container { background: #060a14; font-family: inherit; }

/* ---- panel ---- */
.panel {
  flex: 1 1 55%; display: flex; flex-direction: column; min-height: 0;
}
.forecast-panel { flex: 1 1 auto; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 15px 7px;
}
.panel-head h2 { font-size: 15px; margin: 0; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line); transition: background .3s; }
.dot.live { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.flights { overflow-y: auto; padding: 4px 12px 12px; -webkit-overflow-scrolling: touch; }
.hint { text-align: center; color: var(--muted); font-size: 11px;
  padding: 4px 10px max(10px, env(safe-area-inset-bottom)); margin: 0; }

/* ---- section header (forecast) ---- */
.sec-head {
  display: flex; align-items: baseline; gap: 8px; margin: 14px 4px 8px;
}
.sec-head:first-child { margin-top: 6px; }
.sec-head h3 { font-size: 14px; margin: 0; font-weight: 700; }
.sec-head .sub { font-size: 11px; color: var(--muted); }
.sec-note { font-size: 11.5px; color: var(--muted); background: rgba(56,189,248,0.07);
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; margin: 2px 4px 10px;
  line-height: 1.45; }

/* ---- flight card ---- */
.card {
  display: grid; grid-template-columns: 82px 1fr auto; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 11px; margin-bottom: 10px; align-items: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
  animation: pop .25s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card.in_zone { border-color: var(--hot); box-shadow: 0 0 0 1px var(--hot) inset, 0 6px 20px rgba(251,113,133,.2); }
.card.approaching { border-color: rgba(251,191,36,.6); }
.thumb {
  width: 82px; height: 60px; border-radius: 12px; object-fit: cover;
  background: linear-gradient(145deg, var(--card2), #24365c);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 24px; overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.info { min-width: 0; }
.info .model { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info .op { color: var(--muted); font-size: 12px; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.info .route { font-size: 12.5px; margin-top: 4px; color: var(--text); display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.info .route .arrow { color: var(--accent); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.badge { font-size: 10px; padding: 2px 8px; border-radius: 20px; background: var(--card2); color: var(--muted); }
.badge.hot { background: rgba(251,113,133,.18); color: var(--hot); }
.badge.warn { background: rgba(251,191,36,.16); color: var(--warn); }
.badge.time { background: rgba(56,189,248,.16); color: var(--accent); font-weight: 600; }
.metrics { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.metrics .big { font-size: 18px; font-weight: 800; color: var(--text); }
.metrics .eta { color: var(--warn); font-weight: 800; font-size: 18px; }
.metrics .zone { color: var(--hot); font-weight: 800; }
.metrics .clock { color: var(--accent); font-weight: 800; font-size: 17px; }
.metrics .soon { color: var(--accent); font-size: 11px; font-weight: 600; }

/* confidence bar (recurring) */
.conf { margin-top: 7px; }
.conf .bar { height: 5px; border-radius: 4px; background: var(--card2); overflow: hidden; }
.conf .bar > span { display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--ok)); }
.conf .lbl { font-size: 10px; color: var(--muted); margin-top: 3px; }

.empty { text-align: center; color: var(--muted); padding: 34px 14px; font-size: 14px; line-height: 1.5; }

/* plane marker — contour net sombre + légère ombre (sobre, pas de halo brillant) */
.plane-marker { transition: transform .3s linear; will-change: transform; }
.plane-marker svg { display: block;
  filter: drop-shadow(0 0 0.6px rgba(8,12,22,.95)) drop-shadow(0 1px 1.5px rgba(0,0,0,.55)); }
/* glow atténué réservé aux avions spéciaux (rouges) pour les faire ressortir */
.plane-marker.jumbo svg, .plane-marker.fighter svg {
  filter: drop-shadow(0 0 2px rgba(248,113,113,.85)) drop-shadow(0 0 1px rgba(255,255,255,.5))
          drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.leaflet-marker-icon { transition: none !important; }   /* pas de lag sur la position */

/* contrôles de carte (style + recentrage) */
.map-ctl { display: flex; gap: 4px; }
.map-style { background: rgba(9,14,26,.82); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.map-style button, .map-recenter button {
  border: none; background: transparent; color: var(--text); cursor: pointer;
  font-size: 16px; line-height: 1; width: 34px; height: 30px; border-radius: 8px; }
.map-style button.active { background: linear-gradient(145deg, var(--accent), var(--accent2)); }
.map-recenter, .map-filter { background: rgba(9,14,26,.82); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.map-recenter button, .map-filter button { width: 36px; height: 34px; font-size: 18px;
  border: none; background: transparent; color: var(--text); cursor: pointer;
  border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.map-filter button.on { background: linear-gradient(145deg, var(--accent), var(--accent2)); color: #04121f; }

/* popup avion + itinéraire */
.plane-popup .leaflet-popup-content-wrapper {
  background: var(--card-solid); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.plane-popup .leaflet-popup-tip { background: var(--card-solid); border: 1px solid var(--line); }
.plane-popup .leaflet-popup-content { margin: 11px 13px; font-family: inherit; }
.plane-popup a.leaflet-popup-close-button { color: var(--muted); }
.pop-title { font-weight: 700; font-size: 14px; }
.pop-sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.pop-meta { font-size: 12px; margin-top: 5px; color: var(--text); }
.pop-route { margin-top: 7px; font-size: 13px; font-weight: 600; }
.pop-route .arrow { color: var(--accent); margin: 0 5px; }
.pop-route.muted { color: var(--muted); font-weight: 400; font-style: italic; }
.pop-photo { display: block; margin: 0 0 8px; width: 100%; max-width: 220px; height: 96px;
  border-radius: 8px; object-fit: cover; }
.pop-prog { height: 4px; border-radius: 3px; background: var(--card2); overflow: hidden; margin-top: 7px; }
.pop-prog > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.pop-times { font-size: 11.5px; color: var(--accent); margin-top: 4px; font-weight: 600; }

/* badge / métrique « Passé » */
.badge.pass { background: rgba(52,211,153,.18); color: var(--ok); }
.metrics .big.pass { color: var(--ok); font-size: 15px; }

/* skeleton loader */
.skel { height: 84px; border-radius: 16px; margin-bottom: 10px;
  background: linear-gradient(100deg, var(--card2) 30%, #24365c 50%, var(--card2) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== panneau détaillé d'un avion (façon FR24) ===== */
.detail {
  position: fixed; z-index: 900; background: rgba(11,17,32,.96);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text);
}
.detail.hidden { display: none; }
.detail-close {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card2); color: var(--text); font-size: 14px; cursor: pointer;
}
#detailBody { padding: 12px; overflow-y: auto; max-height: 100%; }
.d-head { padding-right: 32px; }
.d-title { font-size: 15.5px; font-weight: 800; }
.d-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.d-photo { margin: 11px 0; border-radius: 12px; overflow: hidden; position: relative; background: var(--card2); }
.d-photo img { display: block; width: 100%; height: 148px; object-fit: cover; }
.d-photo.d-skel { height: 148px; background: linear-gradient(100deg, var(--card2) 30%, #24365c 50%, var(--card2) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.d-photo-tag { position: absolute; bottom: 6px; right: 6px; font-size: 10px; color: var(--text);
  background: rgba(0,0,0,.55); padding: 2px 7px; border-radius: 10px; }
.d-route { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: 6px; }
.d-ap .d-code { font-size: 20px; font-weight: 800; }
.d-ap .d-city { font-size: 11px; color: var(--muted); max-width: 88px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d-ap.right { text-align: right; }
.d-prog { min-width: 0; }
.d-line { position: relative; height: 4px; border-radius: 3px; background: var(--card2); }
.d-line > span { display: block; height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.d-line > i { position: absolute; top: -8px; transform: translateX(-50%); font-style: normal; font-size: 13px; }
.d-dist { text-align: center; font-size: 10.5px; color: var(--muted); margin-top: 6px; }
.d-route-load { color: var(--muted); font-style: italic; font-size: 13px; margin-top: 8px; }
.d-times { display: flex; justify-content: space-between; font-size: 12px; margin-top: 8px; color: var(--muted); }
.d-times .d-remain { color: var(--accent); font-weight: 700; }
.d-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 14px; }
.d-cell { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 9px; }
.d-cell .d-l { font-size: 10px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.d-cell .d-v { font-size: 14px; font-weight: 700; margin-top: 2px; }

/* ===== disposition mobile : liste = volet coulissant ===== */
@media (max-width: 819px) {
  #view-live { position: relative; }
  #view-live #map { position: absolute; inset: 0; min-height: 0; height: auto; }
  #view-live .panel {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 500;
    height: 60vh; max-height: 78vh;
    background: rgba(9,14,26,.94); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px rgba(0,0,0,.4);
    transition: transform .28s ease; transform: translateY(0);
  }
  #view-live .panel.peek { transform: translateY(calc(60vh - 96px)); }
  .sheet-grab { display: flex; justify-content: center; padding: 8px 0 2px; cursor: grab; }
  .sheet-handle { width: 40px; height: 4px; border-radius: 3px; background: var(--muted); opacity: .6; }
  .panel-head { cursor: grab; }
  .detail { left: 0; right: 0; bottom: 0; max-height: 72vh; border-radius: 18px 18px 0 0;
    animation: sheetUp .28s ease; }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
}

/* la poignée n'apparaît que sur mobile */
@media (min-width: 820px) {
  .sheet-grab { display: none; }
  #view-live { flex-direction: row; }
  #map { flex: 1 1 62%; height: 100%; }
  #view-live .panel { flex: 0 0 430px; height: 100%; border-left: 1px solid var(--line); }
  .status { max-width: 30vw; }
  .forecast-panel { max-width: 760px; margin: 0 auto; width: 100%; }
  /* panneau détail = carte flottante en bas à gauche, au-dessus de la carte */
  .detail { left: 16px; bottom: 16px; width: 360px; max-height: 74vh; border-radius: 16px; }
}

/* ===== pins d'aéroports (style Google Maps) ===== */
.apt-pin { cursor: pointer; }
.apt-pin svg { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.55)); }

/* ===== panneau de filtres ===== */
.filter-panel { position: absolute; top: 66px; left: 56px; z-index: 700;
  background: var(--card-solid); border: 1px solid var(--line); border-radius: 16px;
  padding: 13px; width: min(340px, calc(100vw - 68px)); box-shadow: var(--shadow);
  max-height: 78vh; overflow-y: auto; }
.filter-panel.hidden { display: none; }
.fp-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; margin-bottom: 10px; }
.fp-x { background: var(--card2); border: 1px solid var(--line); color: var(--text);
  border-radius: 8px; width: 28px; height: 28px; cursor: pointer; }
.fp-input { width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; }
.fp-section { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 12px 0 6px; }
.fp-hint { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 10.5px; }
.fp-add { width: 100%; margin-bottom: 2px; }
.fp-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.fp-empty { font-size: 12px; color: var(--muted); padding: 6px 2px; line-height: 1.4; }
.fp-item { display: flex; align-items: center; gap: 9px; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.fp-item input { width: 17px; height: 17px; accent-color: var(--accent); flex: none; }
.fp-item-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fp-item-name { font-size: 13px; font-weight: 600; }
.fp-item-terms { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fp-del { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 13px; flex: none; }

/* ===== indicateur de chargement (bas-droite) ===== */
.loader { position: fixed; bottom: 16px; right: 16px; z-index: 950;
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.22); border-top-color: var(--accent);
  background: rgba(9,14,26,.5); animation: spin .8s linear infinite;
  box-shadow: 0 2px 10px rgba(0,0,0,.4); }
.loader.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== panneaux flottants (PC) : actualités + fun facts ===== */
.info-stack, .infopanel { display: none; }
.ip-head { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; border-bottom: 1px solid var(--line); }
.ip-title { font-weight: 700; font-size: 11.5px; }
.ip-actions { display: flex; gap: 4px; }
.ip-actions button { width: 23px; height: 23px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--card2); color: var(--text); cursor: pointer; font-size: 11px; line-height: 1; }
.ip-body { padding: 10px 12px; font-size: 12px; line-height: 1.45; color: var(--text);
  overflow-y: auto; animation: ffIn .4s ease; }
@keyframes ffIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.news-title { color: var(--text); font-weight: 600; text-decoration: none; display: block; }
.news-title:hover { color: var(--accent); text-decoration: underline; }
.news-src { color: var(--accent); font-size: 11px; margin-top: 5px; font-weight: 600; }

@media (min-width: 820px) {
  /* les deux panneaux À DROITE (sur la carte, collés à la liste des vols) */
  .info-stack { display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
    position: fixed; right: 430px; bottom: 14px; width: 300px; z-index: 900; }
  .infopanel { width: 100%; display: flex; flex-direction: row; max-height: 25vh;
    background: rgba(11,17,32,.96); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--line); border-radius: 14px 0 0 14px; box-shadow: var(--shadow);
    color: var(--text); transition: transform .3s ease; }
  /* rangé sous la liste : il ne reste que l'onglet (30 px) à gauche */
  .infopanel.retracted { transform: translateX(calc(100% - 30px)); }
  .ip-tab { flex: none; width: 30px; border: none; cursor: pointer; color: var(--text);
    background: var(--card2); display: grid; place-items: center; border-right: 1px solid var(--line);
    border-radius: 14px 0 0 14px; }
  .ip-tab:hover { background: var(--card); }
  .ip-chev { font-size: 13px; }
  .ip-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
  /* la liste des vols reste opaque et AU-DESSUS → les panneaux glissent dessous */
  #view-live .panel { position: relative; z-index: 950; background: var(--bg); }
  /* le panneau détail d'un avion reste à gauche (côté opposé) */
  .detail { left: 16px; right: auto; bottom: 14px; width: 312px; }
}
