:root {
  --bg: #0b1220;
  --bg2: #0f1829;
  --panel: #131e33;
  --panel2: #18253e;
  --line: #22314f;
  --line2: #2c3e62;
  --text: #e6ecf7;
  --muted: #8a9abb;
  --dim: #5d6d8f;
  --accent: #f5b544;      /* ambre « cockpit » */
  --accent-ink: #1a1203;
  --pax: #5cc8ff;         /* passager */
  --crew: #f5b544;        /* équipage */
  --dh: #b48cff;          /* mise en place */
  --ok: #4fd1a1;
  --danger: #ff6b6b;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h2 { font-size: 15px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Barre supérieure ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  background: rgba(11, 18, 32, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 18px; letter-spacing: .02em; }
.brand svg { width: 24px; height: 24px; fill: var(--accent); transform: rotate(45deg); }
.brand b { color: var(--accent); font-weight: 700; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); white-space: nowrap; }
.nav a:hover { color: var(--text); background: var(--panel); }
.nav a.active { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--accent); }
.filters { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 7px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--panel2); color: var(--text); box-shadow: 0 0 0 1px var(--line2); }
select, input[type=text], input[type=date], input[type=time], input[type=search], input[type=password], input[type=number], textarea {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; width: 100%;
}
select { width: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(245, 181, 68, .15); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line2); white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); border-color: var(--line); }
.btn.sm { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

main { padding: 20px; max-width: 1480px; margin: 0 auto; }

/* ---------- Panneaux / tuiles ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel > .body { padding: 14px 16px; }
.grid { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.kpi .value { font-family: var(--mono); font-size: 26px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 3px; }
.kpi .sub { color: var(--dim); font-size: 12px; margin-top: 2px; }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); opacity: .7; }

.dash { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; }
.map { height: 560px; border-radius: 0 0 var(--radius) var(--radius); background: #0a0f1b; }
.map.tall { height: 620px; }
.maplibregl-map { font: inherit; }
.maplibregl-ctrl-attrib { background: rgba(11, 18, 32, .75) !important; color: var(--dim) !important; }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }
.maplibregl-ctrl-attrib-button { filter: invert(1); }
.maplibregl-ctrl-group { background: var(--panel) !important; border: 1px solid var(--line); box-shadow: none !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(.9); }
.basemap-ctrl { display: flex; align-items: center; }
.basemap-ctrl select { background: transparent; border: 0; color: var(--text); padding: 4px 6px; font-size: 12px; cursor: pointer; }
.basemap-ctrl select option { background: var(--panel); }
.basemap-ctrl .globe-btn { width: 30px; height: 29px; border-left: 1px solid var(--line) !important; border-top: 0 !important; opacity: .45; font-size: 15px; }
.basemap-ctrl .globe-btn.on { opacity: 1; }
.apt-pop .maplibregl-popup-content { background: var(--panel2); color: var(--text); border: 1px solid var(--line2); font-family: var(--mono); font-size: 12px; padding: 4px 8px; border-radius: 6px; box-shadow: none; }
.apt-pop .maplibregl-popup-tip { display: none; }
.apt-mk { display: flex; align-items: center; gap: 6px; pointer-events: none; }
.apt-mk i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #0b1220; box-shadow: 0 0 0 1px rgba(255,255,255,.5); }
.apt-mk span { background: rgba(24, 37, 62, .92); border: 1px solid var(--line2); color: var(--text); font-family: var(--mono); font-size: 12px; padding: 2px 6px; border-radius: 5px; white-space: nowrap; }
.plane-mk { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; box-shadow: 0 0 0 4px rgba(245, 181, 68, .3); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* ---------- Badges / rôles ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; padding: 2px 8px; border-radius: 99px; border: 1px solid; white-space: nowrap; }
.badge.passenger { color: var(--pax); border-color: rgba(92, 200, 255, .35); background: rgba(92, 200, 255, .08); }
.badge.crew { color: var(--crew); border-color: rgba(245, 181, 68, .35); background: rgba(245, 181, 68, .08); }
.badge.deadhead { color: var(--dh); border-color: rgba(180, 140, 255, .35); background: rgba(180, 140, 255, .08); }
.badge.track { color: var(--ok); border-color: rgba(79, 209, 161, .35); background: rgba(79, 209, 161, .08); }

/* ---------- Liste de vols ---------- */
.flight-list { list-style: none; margin: 0; padding: 0; }
.flight-list li a { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.flight-list li a:hover { background: var(--panel2); }
.flight-list .date { font-family: var(--mono); color: var(--muted); font-size: 12px; text-align: center; line-height: 1.2; }
.flight-list .date b { display: block; font-size: 17px; color: var(--text); }
.route { font-family: var(--mono); font-weight: 600; font-size: 15px; letter-spacing: .03em; }
.route .arrow { color: var(--dim); margin: 0 6px; font-weight: 400; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h1 { font-size: 20px; margin-right: auto; }
.toolbar input[type=search] { width: 280px; }
table.flights { width: 100%; border-collapse: collapse; }
table.flights th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 57px; background: var(--panel); }
table.flights td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.flights tbody tr { cursor: pointer; }
table.flights tbody tr:hover td { background: var(--panel2); }
table.flights td.r, table.flights th.r { text-align: right; }
.al { display: flex; align-items: center; gap: 8px; }
.al img { height: 18px; max-width: 54px; object-fit: contain; background: #fff; border-radius: 3px; padding: 1px 3px; }
.year-sep td { background: var(--bg2) !important; color: var(--accent); font-family: var(--mono); font-weight: 600; cursor: default; padding: 6px 12px !important; }

/* ---------- Détail ---------- */
.hero { display: flex; align-items: center; gap: 28px; padding: 18px 20px; flex-wrap: wrap; }
.hero .apt { min-width: 160px; }
.hero .apt .code { font-family: var(--mono); font-size: 40px; font-weight: 700; letter-spacing: .04em; line-height: 1; }
.hero .apt .city { color: var(--muted); margin-top: 4px; }
.hero .apt .time { font-family: var(--mono); font-size: 18px; margin-top: 8px; }
.hero .apt .time s { color: var(--dim); font-size: 13px; margin-left: 6px; }
.hero .mid { flex: 1; min-width: 160px; text-align: center; color: var(--muted); }
.hero .mid .line { height: 2px; background: linear-gradient(90deg, var(--line2), var(--accent), var(--line2)); margin: 10px 0; position: relative; }
.hero .mid .line::after { content: "✈"; position: absolute; left: 50%; top: -11px; transform: translateX(-50%); color: var(--accent); background: var(--panel); padding: 0 6px; font-size: 16px; }
.hero .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; margin-top: 16px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.facts div { padding: 10px 16px; border-bottom: 1px solid var(--line); }
.facts div:nth-child(odd) { border-right: 1px solid var(--line); }
.facts dt { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .08em; }
.facts dd { margin: 2px 0 0; font-family: var(--mono); }
.profile-wrap { position: relative; height: 180px; }
.profile-wrap canvas { width: 100%; height: 100%; display: block; }
.notes { white-space: pre-wrap; color: var(--muted); }
.stars { color: var(--accent); letter-spacing: 2px; }

/* ---------- Formulaire ---------- */
.form { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.fieldset { margin-bottom: 16px; }
.fieldset .body { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; position: relative; }
.field label { font-size: 12px; color: var(--muted); }
.field.span2 { grid-column: span 2; }
.field.span4 { grid-column: 1 / -1; }
.field .hint { font-size: 11px; color: var(--dim); }
.ac-list { position: absolute; top: 100%; left: 0; right: 0; z-index: 50; margin-top: 4px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 8px; max-height: 300px; overflow: auto; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); min-width: 280px; }
.ac-list div { padding: 7px 10px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.ac-list div b { font-family: var(--mono); color: var(--accent); min-width: 44px; }
.ac-list div span { color: var(--muted); font-size: 12px; }
.ac-list div.hl, .ac-list div:hover { background: var(--line); }
.ac-sel { font-size: 12px; color: var(--muted); min-height: 16px; }
.dropzone { display: block; border: 1.5px dashed var(--line2); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; background: var(--bg2); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); color: var(--text); background: rgba(245, 181, 68, .05); }
.dropzone b { color: var(--accent); }
.dropzone svg { display: block; margin: 0 auto 6px; width: 28px; height: 28px; stroke: currentColor; fill: none; margin-bottom: 6px; }
.sticky { position: sticky; top: 74px; }
.mini-map { height: 300px; border-radius: 0 0 var(--radius) var(--radius); }
.formbar { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 0; }
.stars-input { display: flex; gap: 2px; }
.stars-input button { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--line2); padding: 0 2px; }
.stars-input button.on { color: var(--accent); }

/* ---------- Statistiques ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stats .wide { grid-column: span 2; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding: 10px 4px 0; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.bars .bar .stack { width: 100%; max-width: 46px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; }
.bars .bar .stack i { display: block; }
.bars .bar .v { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.bars .bar .k { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: 6px; white-space: nowrap; }
.rank { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.rank li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; position: relative; }
.rank li::before { counter-increment: r; content: counter(r); font-family: var(--mono); font-size: 11px; color: var(--dim); text-align: right; }
.rank .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .meter { position: absolute; left: 32px; right: 0; bottom: 0; height: 2px; background: var(--line); }
.rank .meter i { display: block; height: 100%; background: var(--accent); opacity: .7; }
.rank .n { font-family: var(--mono); color: var(--muted); }
.records { display: grid; gap: 10px; }
.records a { display: flex; justify-content: space-between; padding: 10px 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; }
.records a:hover { border-color: var(--line2); }

/* ---------- Données ---------- */
.data-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.data-grid .body p { margin: 0 0 12px; color: var(--muted); }
.log { font-family: var(--mono); font-size: 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; max-height: 260px; overflow: auto; white-space: pre-wrap; margin-top: 12px; }
.log .ok { color: var(--ok); } .log .err { color: var(--danger); }
code { font-family: var(--mono); background: var(--bg2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* ---------- Divers ---------- */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 18px; margin-bottom: 8px; }
.empty .btn { margin-top: 16px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line2); padding: 10px 18px; border-radius: 10px; z-index: 3000; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.toast.err { border-color: var(--danger); color: var(--danger); }
.login { max-width: 360px; margin: 12vh auto; padding: 28px; }
.login h1 { font-size: 22px; margin-bottom: 18px; text-align: center; }
.login .btn { width: 100%; justify-content: center; margin-top: 12px; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .dash, .detail, .form { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .data-grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
}
@media (max-width: 760px) {
  main { padding: 12px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .filters { margin-left: 0; order: 4; width: 100%; }
  .topbar > .btn { margin-left: auto; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .stats { grid-template-columns: 1fr; }
  .stats .wide { grid-column: auto; }
  .fieldset .body { grid-template-columns: 1fr 1fr; }
  .map { height: 380px; }
  .hide-sm { display: none; }
  .hero .apt .code { font-size: 30px; }
  .toolbar input[type=search] { width: 100%; }
  table.flights th { top: 0; }
}
