:root {
  --bleu: #0957A2; --bleu-f: #06396B; --bleu-c: #E8F0FA;
  --fond: #F3F5F8; --carte: #FFFFFF; --texte: #14284B; --gris: #5F6B7A; --ligne: #DDE2EA;
  --vert: #1E8E4F; --ambre: #D98E04; --rouge: #B03A2E;
  --ombre: 0 8px 30px rgba(10, 30, 60, .18);
  --r: 10px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--texte); background: var(--fond); display: flex; flex-direction: column; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ en-tête */
header { background: var(--bleu); color: #fff; display: flex; align-items: center; gap: 14px; padding: 8px 16px; flex-wrap: wrap; z-index: 5; }
header .logo { height: 38px; width: auto; }
header .titre { flex: 1; min-width: 180px; line-height: 1.15; }
header .titre b { display: block; font-size: 17px; }
header .titre span { font-size: 12.5px; opacity: .85; }
.modes { display: flex; background: rgba(255,255,255,.14); border-radius: 999px; padding: 3px; gap: 2px; }
.modes button { border: 0; background: transparent; color: #fff; padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.modes button[aria-pressed="true"] { background: #fff; color: var(--bleu); }
.compteur { font-size: 13px; background: rgba(255,255,255,.14); border-radius: 999px; padding: 6px 12px; white-space: nowrap; }
.compteur b { font-size: 15px; }

/* ------------------------------------------------------------ disposition */
main { flex: 1; display: flex; min-height: 0; }
#scene { flex: 1; position: relative; min-width: 0; background: #AEBFD6; touch-action: none; }
#scene canvas { display: block; width: 100%; height: 100%; outline: none; }
aside { width: 380px; background: var(--carte); border-left: 1px solid var(--ligne); display: flex; flex-direction: column; min-height: 0; }

/* ------------------------------------------------------------ superpositions de la scène */
.bulle { position: absolute; pointer-events: none; background: rgba(20, 40, 75, .92); color: #fff; padding: 6px 10px; border-radius: 8px; font-size: 13px; transform: translate(-50%, calc(-100% - 14px)); white-space: nowrap; z-index: 3; }
.bulle i { font-style: normal; opacity: .8; }
.outils { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; flex-wrap: wrap; z-index: 2; }
.outils button { border: 0; background: rgba(255,255,255,.94); color: var(--texte); border-radius: 8px; padding: 7px 11px; font-size: 13px; font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.outils button:hover { background: #fff; }
.aide-clavier { position: absolute; left: 12px; bottom: 12px; background: rgba(20,40,75,.85); color: #fff; border-radius: 8px; padding: 8px 12px; font-size: 12.5px; line-height: 1.55; z-index: 2; max-width: 300px; }
.aide-clavier kbd { background: rgba(255,255,255,.18); border-radius: 4px; padding: 0 5px; font-family: inherit; font-size: 12px; }
.viseur { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border: 2px solid rgba(255,255,255,.9); border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 1px rgba(0,0,0,.25); z-index: 2; }
#joystick { position: absolute; left: 24px; bottom: 24px; width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.22); border: 2px solid rgba(255,255,255,.6); z-index: 3; touch-action: none; }
#joystick span { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255,255,255,.85); box-shadow: 0 2px 8px rgba(0,0,0,.2); }

#chargement { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--fond); z-index: 6; color: var(--gris); }
#chargement img { height: 70px; }
.barre { width: 260px; height: 6px; background: var(--ligne); border-radius: 3px; overflow: hidden; }
.barre div { height: 100%; width: 0; background: var(--bleu); transition: width .2s; }

/* ------------------------------------------------------------ accueil */
#accueil { position: absolute; inset: 0; background: rgba(6, 57, 107, .55); display: flex; align-items: center; justify-content: center; z-index: 5; padding: 16px; }
#accueil .carte { background: #fff; border-radius: 14px; padding: 26px 28px; max-width: 520px; box-shadow: var(--ombre); }
#accueil h2 { margin: 0 0 6px; font-size: 22px; color: var(--bleu-f); }
#accueil p { margin: 0 0 14px; color: var(--gris); line-height: 1.5; }
#accueil ol { margin: 0 0 18px; padding-left: 20px; line-height: 1.7; }
#accueil .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------ boutons */
.bt { border: 0; border-radius: 8px; padding: 10px 16px; font-weight: 600; background: var(--bleu); color: #fff; }
.bt:hover { background: var(--bleu-f); }
.bt.second { background: var(--bleu-c); color: var(--bleu); }
.bt.second:hover { background: #d6e5f6; }
.bt.large { width: 100%; padding: 12px; font-size: 15px; }
.bt:disabled { opacity: .5; cursor: default; }

/* ------------------------------------------------------------ panneau latéral */
.onglets { display: flex; border-bottom: 1px solid var(--ligne); }
.onglets button { flex: 1; border: 0; background: none; padding: 12px 6px; font-weight: 600; color: var(--gris); border-bottom: 3px solid transparent; }
.onglets button[aria-selected="true"] { color: var(--bleu); border-bottom-color: var(--bleu); }
.volet { flex: 1; overflow: auto; padding: 14px 16px; min-height: 0; }

#plan { width: 100%; height: auto; display: block; border: 1px solid var(--ligne); border-radius: var(--r); background: #FAFBFC; touch-action: manipulation; }
#plan .stand { stroke: #fff; stroke-width: 3; cursor: pointer; }
#plan .stand:hover { filter: brightness(1.1); stroke: var(--texte); }
#plan .stand.sel { stroke: var(--texte); stroke-width: 8; }
#plan .stand.masque { opacity: .18; }
#plan text { font-size: 26px; font-weight: 600; fill: #14284B; pointer-events: none; text-anchor: middle; dominant-baseline: central; }
#plan .moi { fill: #E53935; stroke: #fff; stroke-width: 4; }
#plan .champ { fill: rgba(229, 57, 53, .25); }

.legende { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12.5px; color: var(--gris); margin: 10px 0 0; }
.legende span { display: inline-flex; align-items: center; gap: 5px; }
.legende i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legende .raye { background: repeating-linear-gradient(45deg, #D98E04 0 3px, #f6dfae 3px 6px); }

.filtres { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.filtres input[type=search] { width: 100%; padding: 9px 11px; border: 1px solid #C9D0DA; border-radius: 8px; }
.puces { display: flex; flex-wrap: wrap; gap: 6px; }
.puces button { border: 1px solid #C9D0DA; background: #fff; border-radius: 999px; padding: 4px 11px; font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.puces button i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.puces button[aria-pressed="true"] { background: var(--texte); border-color: var(--texte); color: #fff; }
.case { display: flex; align-items: center; gap: 8px; font-size: 14px; }

#liste { list-style: none; margin: 0; padding: 0; }
#liste li button { width: 100%; display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 10px; text-align: left; border: 0; background: none; padding: 9px 6px; border-bottom: 1px solid #EEF1F5; border-radius: 6px; }
#liste li button:hover, #liste li button.sel { background: var(--bleu-c); }
#liste li i { width: 12px; height: 12px; border-radius: 3px; }
#liste li small { color: var(--gris); display: block; font-size: 12.5px; }
.pastille { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: #fff; white-space: nowrap; }
.pastille.libre { background: var(--vert); } .pastille.en_attente { background: var(--ambre); } .pastille.reserve { background: var(--rouge); }
.pastille.non_reservable { background: #8A94A3; }
#plan .stand.nonres { opacity: .45; }

/* signature de l'agence */
.signature { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--ligne); font-size: 11.5px; color: var(--gris); background: #FAFBFC; }
.signature img { height: 26px; width: auto; }

/* fiche du stand */
.fiche h3 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.fiche .cat { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin: 6px 0 10px; }
.fiche .cat i { width: 12px; height: 12px; border-radius: 3px; }
.fiche dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0; font-size: 14px; }
.fiche dt { color: var(--gris); } .fiche dd { margin: 0; font-weight: 600; }
.fiche p { color: var(--gris); line-height: 1.5; margin: 8px 0; font-size: 14px; }
.fiche ul { margin: 6px 0 14px; padding-left: 18px; font-size: 14px; line-height: 1.6; }
.fiche .actions { display: flex; gap: 8px; margin-top: 10px; }
.fiche .actions .bt { flex: 1; }
.vide { color: var(--gris); font-size: 14px; line-height: 1.6; text-align: center; padding: 30px 10px; }
.vide b { display: block; color: var(--texte); font-size: 15px; margin-bottom: 4px; }

/* ------------------------------------------------------------ formulaire (fenêtre) */
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); box-shadow: var(--ombre); color: var(--texte); }
dialog::backdrop { background: rgba(6, 30, 60, .55); }
dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.d-tete { padding: 18px 22px 12px; border-bottom: 1px solid var(--ligne); }
.d-tete h2 { margin: 0; font-size: 19px; }
.d-tete p { margin: 4px 0 0; color: var(--gris); font-size: 13.5px; }
.etapes { display: flex; gap: 6px; margin-top: 12px; }
.etapes span { flex: 1; height: 4px; border-radius: 2px; background: var(--ligne); }
.etapes span.fait { background: var(--bleu); }
.d-corps { padding: 16px 22px; overflow: auto; }
.d-pied { padding: 12px 22px 18px; display: flex; gap: 10px; justify-content: space-between; border-top: 1px solid var(--ligne); }
.d-pied .bt { min-width: 120px; }
.champ-f { margin-bottom: 12px; }
.champ-f label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.champ-f label em { color: var(--rouge); font-style: normal; }
.champ-f input, .champ-f select, .champ-f textarea { width: 100%; padding: 9px 11px; border: 1px solid #C9D0DA; border-radius: 8px; background: #fff; }
.champ-f input:focus, .champ-f select:focus, .champ-f textarea:focus { outline: 2px solid var(--bleu); outline-offset: -1px; border-color: var(--bleu); }
.champ-f input:user-invalid { border-color: var(--rouge); }
.champ-f small { color: var(--gris); font-size: 12.5px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.coches { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 14px; }
.coches label { display: flex; gap: 7px; align-items: flex-start; font-weight: 400; }
.recap { background: var(--bleu-c); border-radius: var(--r); padding: 10px 14px; font-size: 14px; margin-bottom: 14px; display: flex; gap: 12px; align-items: center; }
.recap b { font-size: 17px; }
.erreur { background: #FBEAE8; color: var(--rouge); border-radius: 8px; padding: 9px 12px; font-size: 14px; margin-bottom: 12px; }
.piege { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.succes { text-align: center; padding: 10px 0; }
.succes .coche { width: 64px; height: 64px; border-radius: 50%; background: #E3F4EA; color: var(--vert); font-size: 34px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.succes .ref { font-family: Consolas, monospace; font-size: 20px; font-weight: 700; background: var(--fond); border-radius: 8px; padding: 8px 14px; display: inline-block; margin: 8px 0 12px; letter-spacing: .5px; }
.succes p { color: var(--gris); line-height: 1.55; margin: 6px 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--texte); color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px; z-index: 20; box-shadow: var(--ombre); max-width: calc(100vw - 32px); }

/* ------------------------------------------------------------ petits écrans */
@media (max-width: 860px) {
  header { padding: 8px 12px; gap: 10px; }
  header .logo { height: 30px; }
  header .titre span, .compteur { display: none; }
  .modes { width: 100%; }
  .modes button { flex: 1; padding: 7px 4px; font-size: 12.5px; }
  main { flex-direction: column; }
  aside { width: 100%; height: 46vh; border-left: 0; border-top: 1px solid var(--ligne); }
  .aide-clavier { display: none; }
  .deux, .coches { grid-template-columns: 1fr; }
}
@media (hover: hover) and (pointer: fine) { #joystick { display: none; } }
