:root {
  --bleu: #1F3A5F; --bleu-2: #2C4F7C; --jaune: #F5C400; --brun: #8A5A2B;
  --fond: #F2F4F7; --carte: #FFFFFF; --texte: #1A1A1A; --doux: #5B6470; --trait: #DCE1E8;
  --vert: #2E7D4F; --orange: #D9822B; --rouge: #C0392B; --gris: #8A939E;
  --vert-f: #E5F3EA; --orange-f: #FCEFE0; --rouge-f: #FBE7E5; --jaune-f: #FFF6D1;
  --rayon: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--fond); color: var(--texte); font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h2 { font-size: 1.25rem; color: var(--bleu); }
h3 { font-size: 1.05rem; color: var(--bleu); }
.barre { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 10px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--bleu); color: #fff; }
.barre-logo { width: 34px; height: 41px; object-fit: contain; background: #fff; border-radius: 6px; padding: 2px; }
.barre-titre { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.barre-titre strong { font-size: 1rem; letter-spacing: .02em; }
.barre-titre span { font-size: .82rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre-droite { display: flex; align-items: center; gap: 10px; flex: none; }
.pastille { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; padding: 3px 9px; border-radius: 99px; background: rgba(255,255,255,.14); }
.pastille::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--vert); }
.pastille.horsligne::before { background: var(--orange); }
.btn-lien { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; padding: 4px; }
.bandeau { background: var(--jaune-f); color: var(--texte); padding: 10px 16px; font-size: .92rem; border-bottom: 1px solid #EAD98A; }
main { max-width: 1180px; margin: 0 auto; padding: 16px; }
.etroit { max-width: 520px; margin: 0 auto; }
.carte { background: var(--carte); border-radius: var(--rayon); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.chargement { text-align: center; color: var(--doux); padding: 40px 0; }
label { display: block; font-weight: 600; font-size: .92rem; margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--trait); border-radius: 10px; background: #fff; color: var(--texte); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--jaune); border-color: var(--bleu); }
textarea { min-height: 80px; resize: vertical; }
.aide { font-size: .84rem; color: var(--doux); margin: 4px 0 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 16px; border-radius: 10px; border: 1px solid var(--bleu); background: var(--bleu); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.secondaire { background: #fff; color: var(--bleu); }
.btn.jaune { background: var(--jaune); border-color: var(--jaune); color: var(--bleu); }
.btn.danger { background: #fff; color: var(--rouge); border-color: var(--rouge); }
.btn.petit { padding: 6px 10px; font-size: .85rem; border-radius: 8px; }
.btn.plein { width: 100%; }
.rangee { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grille2 { grid-template-columns: 1fr; } }

/* écran agent */
.service-entete { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.service-site { font-size: 1.2rem; font-weight: 700; color: var(--bleu); }
.service-horaire { color: var(--doux); }
.grand-bouton { width: 100%; min-height: 96px; font-size: 1.35rem; font-weight: 800; letter-spacing: .02em; border-radius: 16px; border: 0; cursor: pointer; margin-top: 14px; box-shadow: 0 3px 0 rgba(0,0,0,.18); }
.grand-bouton.debut { background: var(--jaune); color: var(--bleu); }
.grand-bouton.fin { background: var(--bleu); color: #fff; }
.grand-bouton:disabled { opacity: .6; }
.gps { display: flex; gap: 10px; align-items: center; margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--fond); font-size: .92rem; }
.gps .point { width: 12px; height: 12px; border-radius: 50%; background: var(--gris); flex: none; }
.gps.ok .point { background: var(--vert); } .gps.loin .point { background: var(--rouge); } .gps.moyen .point { background: var(--orange); }
.resultat { margin-top: 12px; padding: 12px; border-radius: 10px; font-size: .95rem; }
.resultat.valide { background: var(--vert-f); } .resultat.reserve { background: var(--orange-f); } .resultat.anomalie { background: var(--rouge-f); } .resultat.attente { background: var(--jaune-f); }
.resultat ul { margin: 6px 0 0; padding-left: 18px; }
.urgence { display: flex; gap: 10px; flex-wrap: wrap; }
.urgence a { flex: 1 1 140px; text-align: center; padding: 14px; border-radius: 12px; background: var(--rouge); color: #fff; font-weight: 700; text-decoration: none; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.b-valide, .b-vert, .b-faible { background: var(--vert-f); color: var(--vert); }
.b-reserve, .b-orange, .b-moyenne, .b-moyen { background: var(--orange-f); color: #A55C12; }
.b-anomalie, .b-rouge, .b-haute, .b-eleve { background: var(--rouge-f); color: var(--rouge); }
.b-critique { background: var(--rouge); color: #fff; }
.b-gris, .b-cloturee { background: #ECEFF3; color: var(--doux); }
.b-ouverte, .b-transmise_direction { background: var(--jaune-f); color: #7A5F00; }
.b-attente { background: var(--jaune-f); color: #7A5F00; }

/* listes */
.liste { list-style: none; margin: 0; padding: 0; }
.liste > li { padding: 12px 0; border-bottom: 1px solid var(--trait); }
.liste > li:last-child { border-bottom: 0; }
.liste .ligne1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.petit-texte { font-size: .86rem; color: var(--doux); }
.vide { color: var(--doux); font-style: italic; }

/* encadrement */
.onglets { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: thin; }
.onglets button { flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--trait); background: #fff; color: var(--bleu); font-weight: 600; cursor: pointer; }
.onglets button.actif { background: var(--bleu); color: #fff; border-color: var(--bleu); }
.onglets .compteur { display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 99px; background: var(--rouge); color: #fff; font-size: .75rem; }
.tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tuile { background: #fff; border-radius: var(--rayon); padding: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.tuile .valeur { font-size: 2rem; font-weight: 800; color: var(--bleu); line-height: 1.1; }
.tuile .libelle { font-size: .86rem; color: var(--doux); }
.tuile.alerte .valeur { color: var(--rouge); }
.tuile.bon .valeur { color: var(--vert); }
#carte { height: 380px; border-radius: var(--rayon); z-index: 1; }
.legende { display: flex; gap: 14px; flex-wrap: wrap; font-size: .84rem; color: var(--doux); margin-top: 8px; }
.legende i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }
.tableau-boite { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--doux); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; padding: 8px; border-bottom: 2px solid var(--trait); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--trait); vertical-align: top; }
tr.retard td:first-child { box-shadow: inset 3px 0 0 var(--rouge); }
.deux-colonnes { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
@media (max-width: 900px) { .deux-colonnes { grid-template-columns: 1fr; } }
details.formulaire > summary { cursor: pointer; font-weight: 700; color: var(--bleu); list-style: none; }
details.formulaire > summary::before { content: "+ "; }
details.formulaire[open] > summary::before { content: "− "; }
.integrite { padding: 10px 12px; border-radius: 10px; font-weight: 600; margin-bottom: 10px; }
.integrite.ok { background: var(--vert-f); color: var(--vert); } .integrite.ko { background: var(--rouge-f); color: var(--rouge); }

.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: #1A1A1A; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px); z-index: 2000; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: .95rem; }
.toast.erreur { background: var(--rouge); }

.presence { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--trait); }
.presence .choix { display: flex; gap: 6px; }
.presence .choix button { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--trait); background: #fff; cursor: pointer; font-size: .86rem; font-weight: 600; }
.presence .choix button.on-present { background: var(--vert); color: #fff; border-color: var(--vert); }
.presence .choix button.on-absent { background: var(--rouge); color: #fff; border-color: var(--rouge); }

@media print {
  .barre, .onglets, .bandeau, .no-print { display: none !important; }
  body { background: #fff; }
}
.affiche { text-align: center; padding: 30px; }
.affiche .code { font-size: 4rem; font-weight: 900; letter-spacing: .2em; color: var(--bleu); margin: 16px 0; }
.affiche #qr { display: inline-block; margin: 10px auto; }

/* onglets du bas (téléphone) */
body:has(.nav-bas) main { padding-bottom: 92px; }
.nav-bas { position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; display: flex; background: #fff; border-top: 1px solid var(--trait); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -2px 10px rgba(16,24,40,.06); }
.nav-bas button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 9px 4px 10px; border: 0; background: none; color: var(--doux); font-size: .78rem; font-weight: 600; cursor: pointer; }
.nav-bas button span { font-size: 1.25rem; line-height: 1; }
.nav-bas button.actif { color: var(--bleu); box-shadow: inset 0 3px 0 var(--jaune); }

/* fenêtres par-dessus : caméra, alarme, photo */
.voile { position: fixed; inset: 0; z-index: 3000; background: rgba(10,20,35,.82); display: flex; align-items: center; justify-content: center; padding: 16px; }
.voile-boite { background: #fff; border-radius: 16px; padding: 18px; width: 100%; max-width: 420px; text-align: center; }
.voile-boite video { width: 100%; border-radius: 12px; background: #000; max-height: 55vh; object-fit: cover; margin: 8px 0; }
.voile-boite video.miroir { transform: scaleX(-1); }
.voile-boite .rangee { justify-content: center; margin-top: 10px; }
.voile.alarme { background: rgba(192,57,43,.92); }
.alarme-heure { font-size: 3.2rem; font-weight: 900; color: var(--rouge); line-height: 1; margin-bottom: 8px; }

/* plein temps */
.horloge-carte { text-align: center; background: var(--bleu); color: #fff; }
.horloge-carte .petit-texte { color: rgba(255,255,255,.85); }
.horloge { font-size: 3.4rem; font-weight: 800; letter-spacing: .04em; line-height: 1.1; }
.interrupteur { display: flex; align-items: center; gap: 12px; font-weight: 600; margin: 8px 0; cursor: pointer; }
.interrupteur input { width: 46px; height: 26px; appearance: none; -webkit-appearance: none; background: #CBD3DD; border-radius: 99px; position: relative; flex: none; cursor: pointer; padding: 0; border: 0; }
.interrupteur input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left .15s; }
.interrupteur input:checked { background: var(--vert); }
.interrupteur input:checked::after { left: 23px; }
h4 { margin: 16px 0 4px; color: var(--brun); font-size: .95rem; }
.lecteur-etat { padding: 10px 12px; background: var(--fond); border-radius: 10px; margin: 8px 0; font-size: .92rem; }

/* formation */
.jauge { height: 10px; background: #E6EAF0; border-radius: 99px; overflow: hidden; }
.jauge span { display: block; height: 100%; background: var(--vert); }
li.cliquable { cursor: pointer; }
li.cliquable:hover { background: var(--fond); }
.cours h3 { margin-top: 18px; }
.cours ul { padding-left: 20px; }
.cours li { margin: 4px 0; }
.question { border: 1px solid var(--trait); border-radius: 10px; margin: 0 0 12px; padding: 10px 12px; }
.question legend { font-weight: 700; padding: 0 4px; }
.choix-q { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 6px 0; padding: 6px; border-radius: 8px; }
.choix-q input { width: auto; margin-top: 3px; }
.question.faux { border-color: var(--rouge); }
.question.juste { border-color: var(--vert); }
.choix-q.bonne-reponse { background: var(--vert-f); }

/* guide de l'agent */
.guide-entete { display: flex; gap: 14px; align-items: center; }
.guide-entete img { width: 56px; height: 68px; object-fit: contain; }
.guide-entete h2 { margin: 0; }
.guide-sujet { padding: 0; overflow: hidden; }
.guide-sujet summary { display: flex; align-items: center; gap: 12px; padding: 16px; font-weight: 700; color: var(--bleu); cursor: pointer; list-style: none; font-size: 1.02rem; }
.guide-sujet summary::-webkit-details-marker { display: none; }
.guide-sujet summary::after { content: "+"; margin-left: auto; font-size: 1.4rem; color: var(--brun); }
.guide-sujet[open] summary::after { content: "−"; }
.guide-sujet > :not(summary) { margin-left: 16px; margin-right: 16px; }
.guide-sujet > :last-child { margin-bottom: 16px; }
.guide-num { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--jaune); color: var(--bleu); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.guide-etapes { padding-left: 22px; }
.guide-etapes li { margin: 0 0 10px; padding-left: 4px; }
.guide-etapes li::marker { font-weight: 800; color: var(--brun); }
.guide-note { background: var(--jaune-f); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-size: .92rem; }
.nav-bas button { font-size: .72rem; }
