/* ==========================================================================
   Air Logistique — système visuel (voir docs/DESIGN.md)
   ========================================================================== */

/* --- Polices embarquées (IBM Plex, licence OFL : fonts/OFL.txt) ----------- */
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/ibm-plex-mono-latin-700-normal.woff2") format("woff2"); }

/* --- Jetons : thème jour (défaut) ----------------------------------------- */
:root {
  --paper: #f5f4ef;        /* fond de page, papier de carte */
  --surface: #ffffff;
  --sunken: #ecebe5;       /* zones en retrait, en-têtes de tableau */
  --ink: #0f1923;          /* texte principal */
  --ink-2: #3f4b57;        /* texte secondaire */
  --ink-3: #66717c;        /* annotations */
  --rule: #d6d3ca;         /* filets */
  --rule-strong: #0f1923;

  --accent: #0a4f8f;       /* bleu « espace contrôlé » : actions */
  --accent-hover: #083f73;
  --accent-ink: #ffffff;
  --accent-soft: #e1ebf5;
  --zone: #9c1f62;         /* magenta : zones réglementées (carte) */

  --go: #0a6e38;        --go-soft: #dff0e5;
  --cond: #9a5800;      --cond-soft: #fbecd5;
  --nogo: #b3121b;      --nogo-soft: #fbe3e3;
  --unknown: #4b3a99;   --unknown-soft: #ebe7f7;
  --na: #66717c;        --na-soft: #ecebe5;
  --terrain: #d8d2bf;      /* sol nu du profil */
  --canopy: #6f7a5c;       /* sursol : arbres, bâti */
  --people: #3d4652;       /* carreaux habités : gris, l'opacité porte la densité */

  --font: "IBM Plex Sans", "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont,
    Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;

  --radius: 2px;
  --gap: 16px;
  --sidebar: 232px;
  --rail: 76px;
  --tabbar: 64px;
  --control: 38px;
  color-scheme: light;
}

/* --- Thème nuit ----------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0a111b; --surface: #101a26; --sunken: #0c1520;
    --ink: #e4eaf1; --ink-2: #a9b5c2; --ink-3: #7d8a98;
    --rule: #22303f; --rule-strong: #e4eaf1;
    --accent: #6aa8e8; --accent-hover: #8bbcf0; --accent-ink: #06101b; --accent-soft: #14273c;
    --zone: #e070ae;
    --go: #4fcf87; --go-soft: #0f2a1d; --cond: #f0b04e; --cond-soft: #2e2210;
    --nogo: #ff7a74; --nogo-soft: #351416; --unknown: #a998f2; --unknown-soft: #1e1838;
    --na: #7d8a98; --na-soft: #16202c;
    --terrain: #2a3542; --canopy: #8d9a76; --people: #c6d0db;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0a111b; --surface: #101a26; --sunken: #0c1520;
  --ink: #e4eaf1; --ink-2: #a9b5c2; --ink-3: #7d8a98;
  --rule: #22303f; --rule-strong: #e4eaf1;
  --accent: #6aa8e8; --accent-hover: #8bbcf0; --accent-ink: #06101b; --accent-soft: #14273c;
  --zone: #e070ae;
  --go: #4fcf87; --go-soft: #0f2a1d; --cond: #f0b04e; --cond-soft: #2e2210;
  --nogo: #ff7a74; --nogo-soft: #351416; --unknown: #a998f2; --unknown-soft: #1e1838;
  --na: #7d8a98; --na-soft: #16202c;
  --terrain: #2a3542; --canopy: #8d9a76; --people: #c6d0db;
  color-scheme: dark;
}

/* --- Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
.muted { color: var(--ink-3); }
.icon { display: inline-flex; flex: none; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* --- Coquille : barre latérale / rail / onglets ---------------------------- */
.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink); text-decoration: none;
}
.brand-mark {
  width: 28px; height: 28px; display: grid; place-items: center;
  background: var(--ink); color: var(--paper);
  font: 700 13px/1 var(--mono); letter-spacing: 0.02em;
}
.brand-name { font-weight: 600; letter-spacing: 0.01em; line-height: 1.15; }
.brand-name small { display: block; font-weight: 400; font-size: 11px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; padding: 10px 0; flex: 1; }
.nav-label {
  padding: 14px 20px 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3);
}
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 20px; color: var(--ink-2); text-decoration: none;
  border-left: 3px solid transparent;
}
.nav a:hover { background: var(--sunken); color: var(--ink); }
.nav a.active { color: var(--ink); font-weight: 600; border-left-color: var(--accent); background: var(--accent-soft); }
.nav-short { display: none; }
.linklist { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--rule); }
.linklist a {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px;
  color: var(--ink); text-decoration: none; font-weight: 600; border-bottom: 1px solid var(--rule);
}
.linklist a:last-child { border-bottom: 0; }
.linklist a::after { content: "›"; margin-left: auto; color: var(--ink-3); font-size: 20px; }
.sidebar-foot { border-top: 1px solid var(--rule); padding: 10px 12px; }
.theme-switch { display: flex; border: 1px solid var(--rule); }
.theme-switch button {
  flex: 1; display: grid; place-items: center; height: 32px; border: 0; background: none;
  color: var(--ink-3); cursor: pointer;
}
.theme-switch button + button { border-left: 1px solid var(--rule); }
.theme-switch button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.main { margin-left: var(--sidebar); min-width: 0; }
.tabbar { display: none; }

/* --- Pages ---------------------------------------------------------------- */
.page { max-width: 1280px; margin: 0 auto; padding: 24px 32px 48px; }
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px;
  padding-bottom: 16px; margin-bottom: 24px; border-bottom: 2px solid var(--rule-strong);
}
.page-head h1 { margin: 0; font-size: 24px; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
.kicker {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
}
.kicker a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.kicker a:hover { color: var(--accent); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.lead { color: var(--ink-2); max-width: 70ch; margin: -8px 0 24px; }

/* Sections : intitulé en capitales + filet, pas de carte ombrée. */
.section { margin-bottom: 32px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid var(--rule); padding-bottom: 8px; margin-bottom: 12px;
}
.section-head h2 {
  margin: 0; font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2);
}
.section-head .count { color: var(--ink-3); font-weight: 400; margin-left: 6px; }
.panel { background: var(--surface); border: 1px solid var(--rule); padding: 16px; }
.hint { color: var(--ink-3); font-size: 13px; margin: 8px 0; }
.empty { color: var(--ink-3); padding: 20px 0; border-bottom: 1px solid var(--rule); }
.error-box { border-left: 4px solid var(--nogo); background: var(--nogo-soft); padding: 12px 16px; }

/* Mise en page de la fiche mission */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 32px; align-items: start; }
.split > * { min-width: 0; }
.split > aside { position: sticky; top: 16px; }

/* --- Boutons -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control); padding: 0 16px;
  font: 600 14px/1 var(--font); letter-spacing: 0.01em;
  border: 1px solid var(--ink); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--sunken); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); padding: 0 10px; }
.btn.quiet:hover { color: var(--ink); background: var(--sunken); }
.btn.danger { border-color: var(--nogo); color: var(--nogo); }
.btn.danger:hover { background: var(--nogo-soft); }
.btn.small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: 0.55; cursor: progress; }

/* --- Tableaux ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-3); background: var(--sunken); padding: 8px 12px; border-bottom: 1px solid var(--rule);
  white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--accent-soft); }
td.num, th.num { text-align: right; }

/* --- Statuts -------------------------------------------------------------- */
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px 2px 6px;
  font: 700 12px/18px var(--font); letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap;
  border: 1px solid currentColor; border-radius: var(--radius);
}
.tag::before { font-family: var(--mono); font-weight: 700; }
.tag.go, .tag.pass { color: var(--go); background: var(--go-soft); }
.tag.go::before, .tag.pass::before { content: "✓"; }
.tag.conditional_go, .tag.warn { color: var(--cond); background: var(--cond-soft); }
.tag.conditional_go::before, .tag.warn::before { content: "!"; }
.tag.no_go, .tag.fail { color: var(--nogo); background: var(--nogo-soft); }
.tag.no_go::before, .tag.fail::before { content: "✕"; }
.tag.unknown { color: var(--unknown); background: var(--unknown-soft); }
.tag.unknown::before { content: "?"; }
.tag.not_applicable, .tag.none { color: var(--na); background: var(--na-soft); border-style: dashed; }
.tag.not_applicable::before, .tag.none::before { content: "–"; }

/* Bloc verdict : l'élément le plus visible de la fiche mission. */
.verdict {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 20px; align-items: center;
  padding: 20px 24px; border: 1px solid currentColor; border-left-width: 8px;
}
.verdict.go { color: var(--go); background: var(--go-soft); }
.verdict.conditional_go { color: var(--cond); background: var(--cond-soft); }
.verdict.no_go { color: var(--nogo); background: var(--nogo-soft); }
.verdict.none { color: var(--ink-3); background: var(--surface); border-style: dashed; border-left-style: solid; }
.verdict-word { grid-row: span 2; font: 700 32px/1 var(--font); letter-spacing: 0.02em; white-space: nowrap; }
.verdict-reason { color: var(--ink); font-weight: 600; font-size: 16px; }
.verdict-meta { color: var(--ink-2); font-size: 13px; }
.verdict-meta .mono { color: var(--ink); }
.review-flag {
  display: flex; gap: 10px; align-items: baseline; margin-top: 12px; padding: 10px 14px;
  border-left: 4px solid var(--unknown); background: var(--unknown-soft); color: var(--ink); font-weight: 600;
}
.conditions { margin: 12px 0 0; padding: 12px 16px; border-left: 4px solid var(--cond); background: var(--cond-soft); }
.conditions h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cond); }
.conditions ul { margin: 0; padding-left: 18px; }

/* Liste de contrôle des règles, regroupée par famille. */
.checklist { background: var(--surface); border: 1px solid var(--rule); }
.checklist h3 {
  margin: 0; padding: 8px 14px; background: var(--sunken); border-bottom: 1px solid var(--rule);
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
}
.check {
  display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 4px 14px;
  padding: 10px 14px; border-bottom: 1px solid var(--rule);
}
.check:last-child { border-bottom: 0; }
.check-title { font-weight: 600; }
.check-title .mono { color: var(--ink-3); font-weight: 400; font-size: 11px; margin-left: 6px; overflow-wrap: anywhere; }
.check-msg { color: var(--ink-2); grid-column: 2; }
.check.fail { box-shadow: inset 4px 0 0 var(--nogo); }
.check.unknown { box-shadow: inset 4px 0 0 var(--unknown); }
.check.warn { box-shadow: inset 4px 0 0 var(--cond); }

/* Fiche de synthèse (colonne de droite) */
.facts { margin: 0; background: var(--surface); border: 1px solid var(--rule); }
.facts div { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--rule); }
.facts div:last-child { border-bottom: 0; }
.facts dt { color: var(--ink-3); font-size: 13px; }
.facts dd { margin: 0; font-weight: 400; overflow-wrap: anywhere; }

/* --- Formulaires ---------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 20px; }
fieldset { border: 0; border-top: 1px solid var(--rule); margin: 0; padding: 14px 0 0; min-width: 0; }
legend {
  padding: 0 8px 0 0; font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field > span .req { color: var(--nogo); margin-left: 2px; }
.field small { color: var(--ink-3); font-size: 12px; }
.wide { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%; min-height: var(--control); padding: 7px 10px;
  font: 15px/1.4 var(--font); color: var(--ink);
  background: var(--surface); border: 1px solid var(--ink-3); border-radius: var(--radius);
}
textarea { resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 13px; }
input:hover, select:hover, textarea:hover { border-color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
details.disclosure > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  font-weight: 600; padding: 10px 0; color: var(--accent);
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::before { content: "+"; font-family: var(--mono); width: 14px; }
details.disclosure[open] > summary::before { content: "−"; }
pre {
  margin: 8px 0 0; padding: 12px; overflow: auto; max-height: 420px;
  background: var(--sunken); border: 1px solid var(--rule);
  font: 12px/1.5 var(--mono); white-space: pre-wrap;
}

/* --- Fenêtres ------------------------------------------------------------- */
dialog.sheet {
  width: min(880px, calc(100vw - 48px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--rule-strong); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
}
dialog.sheet::backdrop { background: rgb(5 12 20 / 55%); }
.sheet-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--rule);
}
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-body { padding: 20px; }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; }

/* --- Notifications -------------------------------------------------------- */
#toast {
  position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 200%);
  max-width: min(560px, calc(100vw - 32px)); padding: 12px 16px;
  background: var(--ink); color: var(--paper); border-left: 6px solid var(--accent);
  white-space: pre-line; transition: transform 0.18s ease-out;
}
#toast.show { transform: translate(-50%, 0); }
#toast.error { border-left-color: var(--nogo); }

/* --- Éditeur de trajet ------------------------------------------------------ */
.editor {
  display: grid; height: 100vh; height: 100dvh;
  grid-template-columns: minmax(0, 1fr) 400px;
  grid-template-rows: auto minmax(0, 1fr) 230px;
  grid-template-areas: "head head" "map panel" "profile panel";
}
.editor-head {
  grid-area: head; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  padding: 12px 20px; background: var(--surface); border-bottom: 2px solid var(--rule-strong);
}
.editor-title h1 { margin: 0; font-size: 20px; font-weight: 600; }
.editor-title .kicker { margin-bottom: 2px; }
.editor-head .page-actions { margin-left: auto; }
.segmented { display: inline-flex; border: 1px solid var(--ink); }
.segmented > a, .segmented > button {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; min-height: 34px;
  font: 600 13px/1 var(--font); color: var(--ink-2); text-decoration: none; background: var(--surface);
  border: 0; cursor: pointer;
}
.segmented > * + * { border-left: 1px solid var(--ink); }
.segmented > [aria-current="page"], .segmented > [aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.segmented.tools { display: flex; margin-bottom: 12px; }
.segmented.tools > * { flex: 1; justify-content: center; }
.editor-map { grid-area: map; position: relative; min-height: 0; border-right: 1px solid var(--rule); }
.editor-map-canvas, .pack-map { width: 100%; height: 100%; background: var(--sunken); }
.pack-map { height: 420px; border: 1px solid var(--rule); }
.map-toolbar { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; z-index: 2; }
.editor-status {
  position: absolute; left: 10px; right: 60px; top: 52px; z-index: 1; max-width: 520px; width: fit-content;
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--rule-strong);
  border-left: 6px solid var(--ink-3); font-size: 13px; font-weight: 600;
}
.editor-status.ok { border-left-color: var(--go); }
.editor-status.bad { border-left-color: var(--nogo); }
.editor-status.stale, .editor-status.busy { border-left-color: var(--cond); }
.editor-panel { grid-area: panel; overflow-y: auto; background: var(--paper); padding: 0 16px 24px; }
.panel-section { padding: 16px 0; border-bottom: 1px solid var(--rule); }
.panel-section h2 {
  margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2);
}
.panel-section h3.sub { margin: 14px 0 6px; font-size: 13px; }
.panel-section select { margin-bottom: 6px; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.inline-fields .field > span { font-size: 12px; }
.editor-profile { grid-area: profile; min-height: 0; background: var(--surface); border-top: 1px solid var(--rule); border-right: 1px solid var(--rule); }
.wp-table { max-height: 320px; overflow: auto; }
.wp-table td, .wp-table th { padding: 4px 6px; }
.wp-table input, .wp-table select { min-height: 32px; padding: 4px 6px; font-size: 13px; }
.wp-table input[type="number"] { width: 72px; }
.wp-table small { display: block; font-size: 11px; white-space: nowrap; }
.wp-table tr.selected td { background: var(--accent-soft); }
.wp-badge, .wp-marker {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px;
  background: var(--accent); color: var(--accent-ink); font: 700 12px/1 var(--mono);
}
.wp-marker { border: 2px solid var(--paper); cursor: grab; box-shadow: 0 0 0 1px var(--accent); }
.wp-marker.selected { background: var(--ink); box-shadow: 0 0 0 3px var(--accent); }
.wp-marker.land, .wp-marker.drop { border-radius: 50%; }
.wp-marker.hover { outline: 2px dashed var(--accent); outline-offset: 2px; }
.compact .wp-marker:not(.endpoint):not(.selected) { min-width: 10px; width: 10px; height: 10px; padding: 0; font-size: 0; border-width: 1px; }
.mini-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 8px 0; font-size: 13px; }
.mini-facts dt { color: var(--ink-3); }
.mini-facts dd { margin: 0; overflow-wrap: anywhere; }
.mini-facts dd.bad { color: var(--nogo); font-weight: 600; }
.notes { margin: 8px 0; padding-left: 18px; font-size: 13px; color: var(--ink-2); }
.warn-text { color: var(--cond); font-weight: 600; }
.notice { margin: 0 0 10px; padding: 8px 12px; border-left: 4px solid var(--accent); background: var(--accent-soft); font-size: 13px; }
.notice.bad { border-left-color: var(--nogo); background: var(--nogo-soft); }
.notice p { margin: 0 0 4px; }
.notice ul { margin: 0; padding-left: 18px; }
.obstacle-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--rule); background: var(--surface); }
.obstacle-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; padding: 8px 10px;
  border-bottom: 1px solid var(--rule); cursor: pointer; font-size: 13px;
}
.obstacle-row:last-child { border-bottom: 0; }
.obstacle-row:hover { background: var(--accent-soft); }
.obstacle-row .tag { grid-row: span 2; align-self: start; }
.obstacle-label { font-weight: 600; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.inline-form { display: flex; gap: 6px; }
.inline-form input { width: 80px; min-height: 30px; }
.auto-weather {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 14px; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent);
}
.auto-weather p { margin: 4px 0 0; }

/* Fenêtre d'obstacle sur la carte (MapLibre) */
.maplibregl-popup-content {
  padding: 12px 14px; border-radius: var(--radius); background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule-strong); box-shadow: none; font: 13px/1.4 var(--font);
}
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { font-size: 20px; width: 28px; height: 28px; color: var(--ink-2); }
.obstacle-card { max-height: min(340px, 55vh); overflow-y: auto; }
.obstacle-card-head { display: flex; align-items: center; gap: 8px; padding-right: 22px; }
.maplibregl-ctrl-group { border-radius: var(--radius); box-shadow: none; border: 1px solid var(--rule-strong); }

/* --- Profil altimétrique ---------------------------------------------------- */
.profile { position: relative; height: 100%; min-height: 180px; }
.pack-profile .profile { height: 220px; border: 1px solid var(--rule); border-top: 0; background: var(--surface); }
.profile svg { display: block; }
.profile .grid { stroke: var(--rule); stroke-width: 1; }
.profile .axis { fill: var(--ink-3); font: 11px var(--font); }
.profile .terrain { fill: var(--terrain); }
.profile .surface { fill: none; stroke: var(--canopy); stroke-width: 1; stroke-dasharray: 2 2; }
.profile .flight { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.profile .ceiling { fill: none; stroke: var(--zone); stroke-width: 1.5; stroke-dasharray: 6 4; }
.profile .clearance { fill: none; stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.profile .obstacle { stroke: var(--ink-2); stroke-width: 3; }
.profile .obstacle.prudent { stroke: var(--cond); }
.profile .obstacle.conflict { stroke: var(--nogo); stroke-width: 4; }
.profile .cursor { stroke: var(--ink); stroke-width: 1; }
.profile .hint { padding: 16px; margin: 0; }
.profile-readout {
  position: absolute; top: 8px; right: 12px; display: flex; flex-wrap: wrap; gap: 4px 12px; max-width: 70%;
  padding: 6px 10px; background: var(--surface); border: 1px solid var(--rule-strong); font-size: 12px; pointer-events: none;
}
.profile-readout[hidden] { display: none; }
.profile-readout .key { font-weight: 700; color: var(--accent); }
.profile-legend { position: absolute; left: 52px; top: 6px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--ink-3); pointer-events: none; }
.lg::before { content: ""; display: inline-block; width: 14px; height: 0; margin-right: 4px; vertical-align: middle; border-top: 2px solid; }
.lg.terrain::before { border-top: 8px solid var(--terrain); }
.lg.surface::before { border-top: 2px dotted var(--canopy); }
.lg.flight::before { border-top-color: var(--accent); }
.lg.ceiling::before { border-top: 2px dashed var(--zone); }
.lg.clearance::before { border-top: 1px dashed var(--ink-3); }

/* --- Dossiers de vol ---------------------------------------------------------- */
.toolbar-row { display: flex; gap: 12px; margin-bottom: 16px; max-width: 420px; }
.checklist-items { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--rule); }
.checklist-items li { border-bottom: 1px solid var(--rule); }
.checklist-items li:last-child { border-bottom: 0; }
.checklist-items label { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; cursor: pointer; }
.checklist-items input { width: 22px; min-height: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--accent); }
.checklist-items input:checked + span { color: var(--ink-3); text-decoration: line-through; }

body.editor-mode .tabbar { display: none; }

/* --- Tablette : rail d'icônes ---------------------------------------------- */
@media (max-width: 1099px) {
  .sidebar { width: var(--rail); }
  .brand { justify-content: center; padding: 16px 0; }
  .brand-name, .nav-label, .nav-text { display: none; }
  .nav-short { display: inline; }
  .nav a { flex-direction: column; gap: 4px; padding: 10px 4px; font-size: 11px; text-align: center; border-left: 0; border-right: 3px solid transparent; }
  .nav a.active { border-right-color: var(--accent); }
  .theme-switch { flex-direction: column; }
  .theme-switch button + button { border-left: 0; border-top: 1px solid var(--rule); }
  .main { margin-left: var(--rail); }
  .page { padding: 20px 24px 40px; }
  .split { grid-template-columns: 1fr; }
  .split > aside { position: static; }
  .editor {
    height: auto; grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto 60vh 220px auto; grid-template-areas: "head" "map" "profile" "panel";
  }
  .editor-map, .editor-profile { border-right: 0; }
  .editor-panel { overflow: visible; }
  .facts { display: grid; grid-template-columns: 1fr 1fr; }
  .facts div:nth-last-child(2):nth-child(odd) { border-bottom: 0; }
}

/* --- Téléphone : onglets en bas, tableaux empilés --------------------------- */
@media (max-width: 699px) {
  body { font-size: 16px; }
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .page { padding: 16px 16px 32px; }
  .page-head { margin-bottom: 16px; }
  .page-head h1 { font-size: 20px; }
  .page-actions { width: 100%; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }

  .tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--rule-strong);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    font-size: 11px; color: var(--ink-3); text-decoration: none; border-top: 3px solid transparent;
  }
  .tabbar a.active { color: var(--ink); font-weight: 600; border-top-color: var(--accent); }

  /* Tableaux → lignes empilées libellé / valeur. */
  .table-wrap { border-left: 0; border-right: 0; background: transparent; }
  table.stack thead { display: none; }
  table.stack tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--rule); background: var(--surface); }
  table.stack td { display: grid; grid-template-columns: 38% 1fr; gap: 8px; padding: 3px 14px; border: 0; }
  table.stack td::before { content: attr(data-label); color: var(--ink-3); font-size: 13px; }
  table.stack td:first-child { font-weight: 600; }
  table.stack td.num { text-align: left; }
  table.stack td[data-label=""] { grid-template-columns: 1fr; }

  .verdict { grid-template-columns: minmax(0, 1fr); padding: 16px; }
  .verdict-meta { overflow-wrap: anywhere; }
  .verdict-word { grid-row: auto; font-size: 28px; }
  .check { grid-template-columns: 1fr; }
  .check-msg { grid-column: 1; }
  .facts { display: block; }
  .facts div { grid-template-columns: 100px minmax(0, 1fr); }
  .facts div:nth-last-child(2):nth-child(odd) { border-bottom: 1px solid var(--rule); }

  input, select, textarea { font-size: 16px; }
  dialog.sheet { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border: 0; }
  body.editor-mode .main { padding-bottom: 0; }
  .editor { grid-template-rows: auto 55vh 200px auto; }
  .editor-head { padding: 10px 16px; }
  .editor-head .page-actions { width: auto; margin-left: 0; }
  .editor-status { right: 10px; }
  .pack-map { height: 320px; }
  .profile-legend { display: none; }
}

/* --- Écrans tactiles : cibles de 44 px ------------------------------------- */
@media (pointer: coarse) {
  :root { --control: 44px; }
  .btn.small { min-height: 40px; }
  .nav a { min-height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  #toast { transition: none; }
}
.editor-map-canvas.stale .maplibregl-canvas { filter: saturate(0.6); }

/* Vérifications humaines (fiche mission) */
.check-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.check-row {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--rule);
}
.check-main { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; min-width: 0; flex: 1 1 240px; }
.check-main a { font-size: 13px; }
.check-state { flex-basis: 100%; font-size: 13px; color: var(--ink-2); }
.check-actions { display: flex; gap: 6px; }

/* Import d'un tracé (éditeur) */
.import-route { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; }

/* Zones géographiques UAS (éditeur, dossier de vol) */
.zone-list { list-style: none; margin: 0 0 12px; padding: 0; border-top: 1px solid var(--rule); }
.zone-list li {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 13px;
}
.zone-list li.above { color: var(--ink-2); }
.zone-list .zone-msg { flex-basis: 100%; color: var(--ink-2); }

/* Levée d'un NO-GO */
.override-box {
  margin-top: 12px; padding: 12px 16px; border: 1px solid var(--cond);
  border-left-width: 4px; background: var(--cond-soft); border-radius: var(--radius);
}
.override-box h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 6px; color: var(--cond); }
.override-box p { margin: 4px 0; }
.override-cta { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-top: 12px; }
.override-rules { list-style: none; margin: 0 0 16px; padding: 0; }
.override-rules li { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.override-rules label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.override-rules input { margin-top: 3px; flex: none; }

/* Journal d'audit */
.audit-changes { margin: 0; font-size: 12px; white-space: pre-wrap; word-break: break-word; max-width: 46ch; }

/* Bandeau d'alerte global (jeu de zones UAS à importer) */
.alerts:empty { display: none; }
.alert {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 32px; border-bottom: 1px solid var(--cond);
  background: var(--cond-soft); color: var(--ink); font-size: 14px;
}
.alert > .icon { color: var(--cond); flex: none; }
.alert > span:not(.icon) { flex: 1 1 260px; }
.alert.bad { background: var(--nogo-soft); border-bottom-color: var(--nogo); }
.alert.bad > .icon { color: var(--nogo); }
body.editor-mode .alerts { display: none; }

/* Mise à jour du jeu de zones */
.update-card {
  margin: 0 0 16px; padding: 16px; border: 1px solid var(--rule);
  background: var(--surface); border-radius: var(--radius);
}
.update-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: baseline; }
.update-cycles { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 12px 0; font-size: 14px; }
.update-cycles dt { color: var(--ink-3); }
.update-cycles dd { margin: 0; }
.update-steps { margin: 0 0 12px; padding-left: 20px; }
.update-steps li { margin: 0 0 8px; line-height: 1.6; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  width: 100%; min-height: 104px; padding: 16px; cursor: pointer;
  border: 2px dashed var(--rule); border-radius: var(--radius);
  background: var(--sunken); color: var(--ink-2); font: inherit; font-size: 15px;
}
.dropzone small { color: var(--ink-3); font-size: 12px; }
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.dropzone:disabled { cursor: progress; opacity: .7; }
@media (max-width: 699px) {
  .alert { padding: 10px 16px; }
  .update-cycles { grid-template-columns: 1fr; gap: 0; }
  .update-cycles dd { margin-bottom: 6px; }
}
.update-steps ul { margin: 4px 0; padding-left: 18px; }
.link-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.link-form input { flex: 1 1 320px; min-width: 0; }
.bookmarklet {
  display: inline-block; padding: 2px 8px; border: 1px dashed var(--accent); border-radius: var(--radius);
  color: var(--accent); font-weight: 600; text-decoration: none; cursor: grab; white-space: nowrap;
}

/* --- Connexion ------------------------------------------------------------- */
body.logged-out .shell { display: none; }
.login {
  min-height: 100vh; display: grid; place-items: center;
  padding: 24px 16px; background: var(--paper);
}
.login-card {
  width: 100%; max-width: 440px; background: var(--surface);
  border: 1px solid var(--rule); padding: 28px 28px 20px;
}
.login-brand { padding: 0 0 18px; margin-bottom: 18px; justify-content: flex-start; }
.login-brand .brand-name { display: block; }
.login-card h1 { font-size: 22px; margin: 0 0 12px; }
.login-main { width: 100%; justify-content: center; min-height: 44px; }
.login-message { border-left: 3px solid var(--cond); background: var(--cond-soft); padding: 8px 12px; }
.login-dev { margin-top: 16px; }
.login-accounts { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.login-accounts .btn {
  width: 100%; justify-content: flex-start; text-align: left; flex-wrap: wrap;
  column-gap: 8px; row-gap: 0; height: auto; padding: 8px 10px;
}
.login-accounts .muted { font-size: 13px; }
.login-offline { margin-top: 20px; }

/* --- Compte (pied de la barre latérale) ----------------------------------- */
.account { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.account-link {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  color: var(--ink); text-decoration: none; padding: 4px 2px;
}
.account-link:hover { color: var(--accent); }
.account-text { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.account-text strong, .account-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-text small { color: var(--ink-3); font-size: 11px; }
@media (max-width: 1099px) {
  .account { flex-direction: column; }
  .account-text { display: none; }
  .account-link { justify-content: center; }
}

/* --- Administration des accès -------------------------------------------------- */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rule); margin: -8px 0 20px; overflow-x: auto; overflow-y: hidden; }
.tabs a {
  padding: 10px 16px; color: var(--ink-2); text-decoration: none; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tabs a.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.perm-group ul { margin: 6px 0 0; padding-left: 18px; }
.perm-group li { margin: 2px 0; }
.perm-flag { color: var(--cond); vertical-align: -2px; }
.perm-picker { display: grid; gap: 12px; margin: 8px 0 16px; }
.perm-pick { border: 1px solid var(--rule); padding: 8px 12px 10px; margin: 0; }
.perm-pick legend { font-weight: 600; padding: 0 4px; }
.perm-box { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.perm-box input { width: 20px; height: 20px; min-height: 20px; flex: none; margin-top: 2px; accent-color: var(--accent); }
.perm-box > span { display: flex; flex-direction: column; }
.perm-box small { font-size: 12px; }
.token-once {
  font: 14px/1.4 var(--mono); background: var(--sunken); padding: 10px 12px;
  border: 1px solid var(--rule); white-space: pre-wrap; word-break: break-all; user-select: all;
}
.stepup p:first-child { font-weight: 600; }
