:root {
  --fond: #f2f4f7; --surface: #ffffff; --surface-2: #f1f3f6; --texte: #1b1f24; --texte-2: #5b6470;
  --bord: #dde2ea; --accent: #0b57d0; --accent-doux: #e3ecfc; --sur-accent: #ffffff;
  --ok: #137333; --ok-doux: #e6f4ea; --att: #a5530a; --att-doux: #fff1dc; --err: #b3261e; --err-doux: #fce8e6;
  --ombre: 0 1px 2px rgba(20, 30, 50, .10), 0 4px 16px rgba(20, 30, 50, .12);
  --onglets: 62px; --sur: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #0f1216; --surface: #171b21; --surface-2: #222830; --texte: #e8ebef; --texte-2: #9aa4b1; --bord: #2f3640;
    --accent: #8ab4f8; --accent-doux: #1d2b44; --sur-accent: #0f1216; --ok: #81c995; --ok-doux: #15291c;
    --att: #f2b45c; --att-doux: #33260f; --err: #f28b82; --err-doux: #3a1a18;
    --ombre: 0 1px 2px rgba(0, 0, 0, .5), 0 4px 16px rgba(0, 0, 0, .45); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --fond: #0f1216; --surface: #171b21; --surface-2: #222830; --texte: #e8ebef; --texte-2: #9aa4b1; --bord: #2f3640;
  --accent: #8ab4f8; --accent-doux: #1d2b44; --sur-accent: #0f1216; --ok: #81c995; --ok-doux: #15291c;
  --att: #f2b45c; --att-doux: #33260f; --err: #f28b82; --err-doux: #3a1a18;
  --ombre: 0 1px 2px rgba(0, 0, 0, .5), 0 4px 16px rgba(0, 0, 0, .45); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden; background: var(--fond); color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* ---------- carte en fond ---------- */
.carte { position: fixed; inset: 0; z-index: 0; background: var(--surface-2); }
.leaflet-control-zoom { display: none; }
@media (min-width: 900px) { .leaflet-control-zoom { display: block; } }

/* ---------- recherche flottante ---------- */
.haut { position: fixed; z-index: 1000; top: 0; left: 0; right: 0; padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 0; pointer-events: none; }
.haut > * { pointer-events: auto; }
.recherche {
  position: relative; display: flex; align-items: center; gap: 4px; height: 52px; padding: 0 6px 0 12px;
  background: var(--surface); border-radius: 26px; box-shadow: var(--ombre);
}
.recherche.ouverte { border-radius: 26px 26px 0 0; }
.logo { width: 24px; height: 24px; flex: none; }
.logo path:first-child { fill: var(--accent); stroke: none; }
.logo .coche { stroke: var(--surface); stroke-width: 2.6; }
.recherche input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--texte); font-size: 17px; padding: 0 6px; -webkit-appearance: none; }
.recherche input::-webkit-search-cancel-button { display: none; }
.icone-btn { width: 44px; height: 44px; flex: none; border: 0; background: none; border-radius: 50%; display: grid; place-items: center; color: var(--texte-2); }
.icone-btn svg { width: 22px; height: 22px; }
.icone-btn:hover { background: var(--surface-2); }
#ouSuisJe.actif { color: var(--accent); }
.suggestions {
  position: absolute; left: 0; right: 0; top: 100%; margin: 0; padding: 4px 0 8px; list-style: none; background: var(--surface);
  border-top: 1px solid var(--bord); border-radius: 0 0 22px 22px; box-shadow: var(--ombre); max-height: 60dvh; overflow: auto;
}
.suggestions li { display: flex; gap: 12px; align-items: center; padding: 10px 16px; cursor: pointer; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--surface-2); }
.suggestions .s-t { flex: 1; min-width: 0; }
.suggestions b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggestions small { color: var(--texte-2); font-size: 14px; }
.suggestions .s-cp { color: var(--att); font-weight: 600; }
.suggestions .vide { color: var(--texte-2); cursor: default; }
.guidage { margin: 8px 0 0; padding: 10px 14px; border-radius: 14px; background: rgba(27, 31, 36, .9); color: #fff; font-size: 15px; box-shadow: var(--ombre); }
.guidage.arrive { background: rgba(19, 115, 51, .94); }

.flottants { position: fixed; z-index: 999; right: 12px; top: calc(74px + env(safe-area-inset-top, 0px)); }
body.guidage-on .flottants { top: calc(124px + env(safe-area-inset-top, 0px)); }
.rond {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 14px; border: 0; border-radius: 22px;
  background: var(--surface); color: var(--texte); box-shadow: var(--ombre); font-size: 14px; font-weight: 600;
}
.rond svg { width: 18px; height: 18px; fill: #1a73e8; stroke: none; }
.rond[aria-pressed="true"] { background: #1a73e8; color: #fff; }
.rond[aria-pressed="true"] svg { fill: #fff; }

/* ---------- panneau (bas sur téléphone, gauche sur ordinateur) ---------- */
.panneau {
  position: fixed; z-index: 1000; left: 0; right: 0; bottom: calc(var(--onglets) + var(--sur));
  max-height: calc(64dvh - var(--onglets)); overflow: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: var(--ombre); padding: 0 16px 16px;
  transition: max-height .2s;
}
.panneau[data-etat="ferme"] { display: none; }
.panneau[data-etat="replie"] { max-height: 102px; overflow: hidden; }
.poignee { position: sticky; top: 0; z-index: 2; display: block; width: calc(100% + 32px); margin: 0 -16px; height: 30px; border: 0; background: var(--surface); touch-action: none; cursor: grab; }
.poignee span { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--bord); margin: 10px auto 0; }

.verdict { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 8px; padding: 4px 12px 4px 8px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.verdict svg { width: 18px; height: 18px; }
.verdict.ok { background: var(--ok-doux); color: var(--ok); }
.verdict.att { background: var(--att-doux); color: var(--att); }
.verdict.err { background: var(--err-doux); color: var(--err); }
.adresse { font-size: 24px; line-height: 1.15; margin: 0; letter-spacing: -.01em; }
.lieu { margin: 3px 0 14px; font-size: 17px; }
.lieu small { display: block; color: var(--texte-2); font-size: 14px; }

.y-aller {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 54px; border: 0; border-radius: 14px;
  background: var(--accent); color: var(--sur-accent); font-weight: 700; font-size: 18px;
}
.y-aller svg { width: 22px; height: 22px; }
.y-aller:active { filter: brightness(.95); }
.changer { display: block; text-align: center; margin: 6px 0 0; font-size: 13px; color: var(--texte-2); }
.changer button { border: 0; background: none; color: var(--accent); padding: 4px; font-size: 13px; }

.numeros p { margin: 16px 0 8px; font-size: 15px; }
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce { min-width: 52px; min-height: 44px; border: 1px solid var(--bord); background: var(--surface); border-radius: 10px; padding: 0 12px; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.puce:hover { border-color: var(--accent); color: var(--accent); }
.filtre { width: 100%; min-height: 44px; border: 1px solid var(--bord); border-radius: 10px; padding: 0 12px; margin-bottom: 8px; background: var(--surface); color: var(--texte); font-size: 16px; }
.corrections details { margin-top: 14px; border: 1px solid var(--bord); border-radius: 12px; padding: 0 14px; }
.corrections summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; font-size: 15px; color: var(--texte-2); }
.corrections ul { margin: 0 0 12px; padding-left: 18px; font-size: 14px; color: var(--texte-2); }
.corrections li.fort { color: var(--texte); }
.corrections p { margin: 0 0 6px; font-size: 14px; color: var(--texte-2); }

/* ---------- tournée ---------- */
.t-tete { display: flex; align-items: baseline; gap: 10px; margin: 0 0 10px; }
.t-tete h1 { font-size: 20px; margin: 0; }
.t-resume { color: var(--texte-2); font-size: 14px; }
.t-err { color: var(--err); }
.ajout { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.scanner { position: relative; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 16px; border: 1.5px dashed var(--bord); border-radius: 14px; font-weight: 600; cursor: pointer; }
.scanner:hover, .scanner:focus-within { border-color: var(--accent); color: var(--accent); }
.scanner svg { width: 22px; height: 22px; flex: none; }
.scanner input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.ocr { margin: 0; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--texte-2); }
.barre { flex: 0 0 110px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.barre span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
textarea { width: 100%; border: 1px solid var(--bord); border-radius: 12px; padding: 10px 12px; font: 16px/1.5 inherit; background: var(--surface); color: var(--texte); resize: vertical; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.ligne-btn { display: flex; align-items: center; gap: 12px; }
.progression { color: var(--texte-2); font-size: 14px; }
.principal { min-height: 44px; padding: 0 20px; border: 0; border-radius: 22px; background: var(--accent); color: var(--sur-accent); font-weight: 650; font-size: 15px; }
.action { min-height: 44px; padding: 0 16px; border: 1px solid var(--bord); border-radius: 22px; background: var(--surface); font-size: 14px; white-space: nowrap; }
.action:hover { border-color: var(--accent); color: var(--accent); }
.action.discret { border-color: transparent; color: var(--texte-2); }
.outils { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px 8px; padding: 0 16px 4px; scrollbar-width: none; }
.outils > * { flex: none; }

.arrets { list-style: none; margin: 0; padding: 0; }
.arret { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--bord); }
.pastille { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--accent-doux); color: var(--accent); }
.arret.att .pastille { background: var(--att-doux); color: var(--att); }
.arret.err .pastille { background: var(--err-doux); color: var(--err); }
.arret.livre .pastille { background: var(--ok-doux); color: var(--ok); }
.arret.livre b { color: var(--texte-2); text-decoration: line-through; font-weight: 500; }
.arret.actuel { background: var(--accent-doux); margin: 0 -16px; padding: 10px 16px; }
.a-t b { display: block; font-weight: 600; line-height: 1.3; }
.a-t small { display: block; font-size: 13px; color: var(--texte-2); }
.arret.att small { color: var(--att); }
.arret.err small { color: var(--err); }
.a-t input { width: 100%; min-height: 40px; border: 1px solid var(--bord); border-radius: 8px; padding: 0 10px; font-size: 15px; background: var(--surface); color: var(--texte); }
.a-b { display: flex; gap: 6px; }
.mini { min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: var(--accent); color: var(--sur-accent); font-weight: 650; font-size: 14px; }
.arret.livre .mini { background: var(--surface-2); color: var(--texte-2); }
.carre { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--bord); background: var(--surface); color: var(--texte-2); font-size: 18px; }
.carre[aria-pressed="true"] { background: var(--ok-doux); border-color: transparent; color: var(--ok); }

.guide { border: 1px solid var(--bord); border-radius: 16px; padding: 14px; margin-bottom: 12px; }
.guide .g-n { font-size: 13px; color: var(--texte-2); }
.guide .g-a { font-size: 21px; font-weight: 700; line-height: 1.2; margin: 2px 0; }
.guide .g-l { color: var(--texte-2); margin-bottom: 12px; }
.guide .g-b { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.guide .fini { text-align: center; padding: 8px 0; }

/* ---------- onglets ---------- */
.onglets {
  position: fixed; z-index: 1001; left: 0; right: 0; bottom: 0; display: flex; height: calc(var(--onglets) + var(--sur));
  padding-bottom: var(--sur); background: var(--surface); border-top: 1px solid var(--bord);
}
.onglets button { position: relative; flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 600; color: var(--texte-2); }
.onglets svg { width: 24px; height: 24px; }
.onglets [aria-current="page"] { color: var(--accent); }
.pastille-onglet { position: absolute; top: 6px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--sur-accent); font-size: 11px; line-height: 18px; }

/* ---------- panneau « Y aller avec » ---------- */
.voile { position: fixed; inset: 0; z-index: 1999; background: rgba(0, 0, 0, .4); }
.choix {
  position: fixed; z-index: 2000; left: 0; right: 0; bottom: 0; max-height: 90dvh; overflow: auto; background: var(--surface);
  border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + var(--sur)); box-shadow: var(--ombre);
}
.poignee-deco { display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--bord); margin: 0 auto 10px; }
.choix h2 { font-size: 17px; margin: 0 0 14px; }
.applis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.applis button { display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: none; padding: 6px 0; font-size: 13px; font-weight: 600; border-radius: 12px; }
.applis button:hover { background: var(--surface-2); }
.applis .ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 20px; }
.applis .ico svg { width: 26px; height: 26px; }
.formats button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 50px; border: 0; border-top: 1px solid var(--bord); background: none; text-align: left; font-size: 15px; }
.formats svg { width: 20px; height: 20px; color: var(--texte-2); }
.toujours { display: flex; align-items: center; gap: 10px; min-height: 48px; border-top: 1px solid var(--bord); font-size: 15px; color: var(--texte-2); }
.toujours input { width: 20px; height: 20px; accent-color: var(--accent); }

.dialogue { border: 0; border-radius: 18px; padding: 22px; background: var(--surface); color: var(--texte); text-align: center; max-width: 320px; }
.dialogue::backdrop { background: rgba(0, 0, 0, .45); }
.qr-titre { margin: 0 0 12px; font-weight: 600; }
.qr { display: inline-block; background: #fff; padding: 12px; border-radius: 12px; }
.qr-texte { font-size: 13px; color: var(--texte-2); }
.toast { position: fixed; z-index: 3000; left: 50%; bottom: calc(var(--onglets) + var(--sur) + 16px); transform: translateX(-50%); background: var(--texte); color: var(--fond); padding: 10px 18px; border-radius: 22px; font-size: 14px; max-width: calc(100% - 32px); text-align: center; }

/* ---------- marqueurs de la carte ---------- */
.pin-dest { width: 34px; height: 44px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .35)); }
.pin-dest path { fill: #d93025; stroke: #fff; stroke-width: 1.5; }
.pin-dest.ok path { fill: #1e8e3e; }
.pin-dest.att path { fill: #e37400; }
.pin-dest circle { fill: #fff; stroke: none; }
.moi { width: 18px; height: 18px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(26, 115, 232, .25); }
.num-ico { background: none; border: 0; }
.num-label { display: inline-block; transform: translate(-50%, -50%); padding: 1px 5px; border-radius: 6px; background: #fff; border: 1px solid #8a929c; color: #1b1f24; font: 600 12px/1.3 system-ui, sans-serif; white-space: nowrap; cursor: pointer; }
.num-label.cible { background: #1e8e3e; border-color: #1e8e3e; color: #fff; font-size: 13px; transform: translate(-50%, 3px); }
.loin .num-label { font-size: 0; width: 8px; height: 8px; padding: 0; border-radius: 50%; }
.loin .num-label.cible { width: 10px; height: 10px; }
.pin-num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font: 700 14px system-ui, sans-serif; background: #0b57d0; color: #fff; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.pin-num.att { background: #e37400; }
.pin-num.livre { background: #1e8e3e; }
.pin-num.actuel { width: 40px; height: 40px; font-size: 16px; background: #d93025; }
.leaflet-popup-content { margin: 12px 14px; font: 14px/1.4 system-ui, sans-serif; }
.pop b { display: block; font-size: 15px; margin-bottom: 8px; }
.pop .pop-b { display: flex; gap: 6px; }

/* ---------- ordinateur : panneau à gauche ---------- */
@media (min-width: 900px) {
  :root { --onglets: 0px; }
  .haut { right: auto; width: 420px; }
  .onglets { top: calc(72px + env(safe-area-inset-top, 0px)); bottom: auto; left: 12px; right: auto; width: 420px; height: 48px; padding: 0; border: 0; border-radius: 14px; box-shadow: var(--ombre); }
  .onglets button { flex-direction: row; gap: 8px; font-size: 14px; }
  .onglets svg { width: 20px; height: 20px; }
  .pastille-onglet { position: static; }
  .panneau { top: 132px; bottom: 12px; left: 12px; right: auto; width: 420px; max-height: none; border-radius: 16px; }
  .panneau[data-etat="replie"] { max-height: 84px; bottom: auto; }
  .poignee { display: none; }
  .panneau { padding-top: 16px; }
  .flottants { top: 12px; right: 12px; }
  body.guidage-on .flottants { top: 12px; }
  .guidage { position: fixed; top: 12px; left: 444px; right: 160px; margin: 0; }
  .choix { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 420px; border-radius: 20px; }
  .poignee-deco { display: none; }
  .toast { bottom: 24px; }
}
