:root {
  --accent: #1592D0;
  --accent-fonce: #0e6fa0;
  --encre: #17202e;
  --encre-2: #4a5568;
  --encre-3: #8492a6;
  --fond: #f2f4f7;
  --carte: #ffffff;
  --ligne: #e1e6ee;
  --vert: #14804a;
  --vert-fond: #e3f5ea;
  --orange: #b85c00;
  --orange-fond: #fff1df;
  --rouge: #c42b1c;
  --rouge-fond: #fde8e6;
  --nuit: #0f1b2d;
  --rayon: 14px;
  --ombre: 0 1px 2px rgba(15, 27, 45, .06), 0 4px 14px rgba(15, 27, 45, .06);
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--fond); color: var(--encre); }
body { font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
small { color: var(--encre-3); }
.rouge { color: var(--rouge); }

/* ---------- Barre du haut ---------- */
.barre {
  position: sticky; top: 0; z-index: 20; background: var(--nuit); color: #fff;
  padding: calc(10px + var(--haut)) 14px 10px; display: flex; align-items: center; gap: 10px; min-height: 58px;
}
.barre .retour { background: none; border: 0; color: #fff; font-size: 26px; padding: 0 6px 0 0; line-height: 1; }
.barre .titre { flex: 1; min-width: 0; }
.barre .titre b { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre .titre small { color: #9fb0c8; font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo-barre { height: 34px; max-width: 120px; object-fit: contain; background: #fff; border-radius: 7px; padding: 3px 6px; }
.marque-app { font-weight: 800; letter-spacing: .02em; font-size: 15px; }
.marque-app span { color: #6cc4f0; font-weight: 600; }
.reseau { font-size: 12px; padding: 4px 9px; border-radius: 99px; background: rgba(255,255,255,.12); white-space: nowrap; border: 0; color: #fff; }
.reseau.hors { background: #7a3d00; }
.reseau .pt { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; margin-right: 6px; vertical-align: 1px; }
.reseau.hors .pt { background: #ffb347; }
.icone-btn { background: rgba(255,255,255,.1); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 10px; font-size: 18px; }

/* ---------- Mise en page ---------- */
.ecran { padding: 14px 14px calc(110px + var(--bas)); max-width: 760px; margin: 0 auto; }
.carte { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; margin-bottom: 12px; }
.section-titre { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-3); font-weight: 700; margin: 22px 4px 8px; display: flex; justify-content: space-between; align-items: center; }
.vide { text-align: center; color: var(--encre-3); padding: 26px 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 650; background: var(--accent); color: #fff; text-decoration: none; min-height: 48px; }
.btn:active { transform: translateY(1px); }
.btn.secondaire { background: #e8edf4; color: var(--encre); }
.btn.contour { background: transparent; border: 1.5px solid var(--ligne); color: var(--encre); }
.btn.danger { background: var(--rouge-fond); color: var(--rouge); }
.btn.large { width: 100%; }
.btn[disabled] { opacity: .5; }
.rang { display: flex; gap: 10px; flex-wrap: wrap; }
.rang > .btn { flex: 1; }

.fab { position: fixed; right: 18px; bottom: calc(22px + var(--bas)); z-index: 30; border-radius: 99px; padding: 15px 22px; box-shadow: 0 8px 24px rgba(21, 146, 208, .4); font-size: 16px; }

/* ---------- Connexion ---------- */
.connexion { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.connexion .logo-grand { text-align: center; margin-bottom: 26px; }
.connexion .logo-grand .marque-app { font-size: 24px; color: var(--nuit); }
.connexion .logo-grand .marque-app span { color: var(--accent); }
.connexion .logo-grand p { color: var(--encre-2); margin: 6px 0 0; }
.ou { text-align: center; color: var(--encre-3); margin: 16px 0; font-size: 14px; position: relative; }
.ou::before, .ou::after { content: ""; position: absolute; top: 50%; width: 38%; border-top: 1px solid var(--ligne); }
.ou::before { left: 0; } .ou::after { right: 0; }
.btn-thermensio { background: var(--nuit); }

/* ---------- Champs ---------- */
label, .champ { display: block; margin-bottom: 16px; }
.champ > .lib, label { font-weight: 600; font-size: 14.5px; color: var(--encre); }
.lib .req { color: var(--rouge); margin-left: 3px; }
.aide { font-size: 13px; color: var(--encre-3); margin-top: 3px; }
input[type=text], input[type=tel], input[type=email], input[type=number], input[type=password], input[type=date], input:not([type]), select, textarea {
  display: block; width: 100%; margin-top: 6px; border: 1.5px solid var(--ligne); border-radius: 11px; padding: 12px 13px; background: #fff; min-height: 48px; font-size: 16px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
textarea { min-height: 96px; resize: vertical; }
.unite { position: relative; }
.unite input { padding-right: 58px; }
.unite span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); margin-top: 3px; color: var(--encre-3); font-size: 14px; pointer-events: none; }
.champ.manque > .lib { color: var(--rouge); }
.champ.manque input, .champ.manque select, .champ.manque textarea { border-color: #f0b4ad; }

.puces { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.puce { border: 1.5px solid var(--ligne); background: #fff; border-radius: 11px; padding: 10px 13px; font-size: 14.5px; min-height: 44px; text-align: left; line-height: 1.25; }
.puce.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, #fff); color: var(--accent-fonce); font-weight: 650; }
.puces.oui-non .puce { min-width: 92px; text-align: center; }

/* ---------- Photos ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-top: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #dfe5ee; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .etat { position: absolute; left: 4px; bottom: 4px; font-size: 10.5px; background: rgba(15,27,45,.75); color: #fff; padding: 2px 6px; border-radius: 6px; }
.photo .etat.ok { background: rgba(20,128,74,.9); }
.photo .suppr { position: absolute; right: 4px; top: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(15,27,45,.7); color: #fff; font-size: 15px; line-height: 1; }
.ajout-photo { aspect-ratio: 1; border: 2px dashed #b9c4d4; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--encre-2); background: #f8fafc; font-size: 13px; gap: 2px; position: relative; overflow: hidden; }
.ajout-photo b { font-size: 24px; line-height: 1; }
.ajout-photo input { position: absolute; inset: 0; opacity: 0; }
.btn-photo-champ { margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--accent-fonce); background: color-mix(in srgb, var(--accent) 8%, #fff); border: 0; border-radius: 9px; padding: 8px 11px; position: relative; overflow: hidden; }
.btn-photo-champ input { position: absolute; inset: 0; opacity: 0; }

/* ---------- Liste répétable ---------- */
.item-liste { border: 1.5px solid var(--ligne); border-radius: 12px; padding: 12px; margin-top: 10px; background: #fbfcfe; }
.item-liste .entete-item { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 700; font-size: 14px; color: var(--encre-2); }
.item-liste .entete-item button { border: 0; background: none; color: var(--rouge); font-size: 14px; }

/* ---------- Assistant (étapes) ---------- */
.etapes { position: sticky; top: calc(58px + var(--haut)); z-index: 15; background: var(--fond); padding: 10px 0 8px; display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.etapes::-webkit-scrollbar { display: none; }
.etape-puce { flex: 0 0 auto; border: 0; background: #fff; border-radius: 99px; padding: 8px 12px; font-size: 13.5px; box-shadow: var(--ombre); color: var(--encre-2); white-space: nowrap; }
.etape-puce.actif { background: var(--accent); color: #fff; font-weight: 650; }
.etape-puce .compte { font-size: 11px; background: var(--rouge-fond); color: var(--rouge); border-radius: 99px; padding: 1px 6px; margin-left: 5px; }
.etape-puce.actif .compte { background: rgba(255,255,255,.25); color: #fff; }
.etape-puce .ok { color: var(--vert); margin-left: 4px; }
.etape-puce.actif .ok { color: #fff; }
.etape-titre { display: flex; align-items: center; gap: 10px; margin: 6px 2px 14px; }
.etape-titre .ico { font-size: 26px; }
.etape-titre h2 { font-size: 20px; }
.etape-titre small { display: block; }
.nav-bas { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--ligne); padding: 10px 14px calc(10px + var(--bas)); display: flex; gap: 10px; }
.nav-bas .btn { flex: 1; }
.nav-bas .info { font-size: 12px; color: var(--encre-3); text-align: center; position: absolute; top: -22px; left: 0; right: 0; }

/* ---------- Listes de prévisites ---------- */
.pv { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 13px 14px; margin-bottom: 9px; }
.pv .vignette { width: 44px; height: 44px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 21px; background: color-mix(in srgb, var(--c, var(--accent)) 13%, #fff); flex: 0 0 auto; overflow: hidden; }
.pv .vignette img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 3px; }
.pv .corps { flex: 1; min-width: 0; }
.pv .corps b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv .corps small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv .barre-prog { height: 4px; background: #e8edf4; border-radius: 9px; margin-top: 7px; overflow: hidden; }
.pv .barre-prog i { display: block; height: 100%; background: var(--accent); border-radius: 9px; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 650; padding: 3px 8px; border-radius: 99px; background: #e8edf4; color: var(--encre-2); white-space: nowrap; }
.badge.vert { background: var(--vert-fond); color: var(--vert); }
.badge.orange { background: var(--orange-fond); color: var(--orange); }
.badge.rouge { background: var(--rouge-fond); color: var(--rouge); }
.badge.bleu { background: color-mix(in srgb, var(--accent) 12%, #fff); color: var(--accent-fonce); }
.filtres { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filtres .puce { flex: 0 0 auto; display: flex; align-items: center; gap: 7px; }
.filtres img { height: 20px; max-width: 46px; object-fit: contain; }

/* ---------- Choix société / scénario ---------- */
.choix-grille { display: grid; gap: 10px; }
.choix { display: flex; align-items: center; gap: 14px; border: 2px solid transparent; background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 16px; text-align: left; width: 100%; }
.choix:active, .choix.on { border-color: var(--accent); }
.choix .logo-choix { width: 64px; height: 44px; object-fit: contain; flex: 0 0 auto; }
.choix .pastille { width: 64px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; flex: 0 0 auto; font-size: 18px; }
.choix .gros { font-size: 34px; width: 64px; text-align: center; flex: 0 0 auto; }
.choix b { display: block; font-size: 16.5px; }
.choix small { display: block; }

/* ---------- Signature ---------- */
.signature { border: 1.5px dashed #b9c4d4; border-radius: 12px; background: #fff; margin-top: 8px; position: relative; touch-action: none; }
.signature canvas { width: 100%; height: 170px; display: block; border-radius: 12px; }
.signature .effacer { position: absolute; right: 8px; top: 8px; border: 0; background: #eef2f7; border-radius: 8px; padding: 5px 10px; font-size: 13px; }
.signature .indic { position: absolute; left: 12px; bottom: 8px; font-size: 12px; color: var(--encre-3); pointer-events: none; }
.signature img { width: 100%; height: 170px; object-fit: contain; display: block; }

/* ---------- Divers ---------- */
.bandeau { border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 14.5px; }
.bandeau.info { background: color-mix(in srgb, var(--accent) 10%, #fff); color: var(--accent-fonce); }
.bandeau.alerte { background: var(--orange-fond); color: var(--orange); }
.bandeau.erreur { background: var(--rouge-fond); color: var(--rouge); }
.bandeau.ok { background: var(--vert-fond); color: var(--vert); }
.manquants a { color: var(--rouge); display: block; padding: 5px 0; text-decoration: none; border-bottom: 1px solid #f6d6d2; }
.toast { position: fixed; left: 50%; bottom: calc(94px + var(--bas)); transform: translateX(-50%); background: var(--nuit); color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 100; font-size: 14.5px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 92vw; text-align: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14.5px; }
.kv dt { color: var(--encre-3); }
.kv dd { margin: 0; font-weight: 550; }
.invit { display: flex; align-items: center; gap: 12px; }
.invit .corps { flex: 1; }
.chargement { display: flex; align-items: center; justify-content: center; min-height: 60vh; color: var(--encre-3); }
.voile { position: fixed; inset: 0; background: rgba(15,27,45,.55); z-index: 90; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; flex-direction: column; gap: 10px; padding: 30px; text-align: center; }
.voile .rond { width: 36px; height: 36px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: tourne 0.8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.consignes { white-space: pre-wrap; }

/* ---------- Pages serveur ---------- */
.page-serveur { display: flex; justify-content: center; padding: 30px 14px; }
.carte-serveur { background: #fff; border-radius: 16px; box-shadow: var(--ombre); padding: 26px; width: 100%; max-width: 1180px; }
.carte-serveur:has(form:only-of-type) { max-width: 440px; }
.carte-serveur .marque { color: var(--accent); font-size: 13px; letter-spacing: .06em; margin: 0 0 6px; }
.carte-serveur h1 { font-size: 22px; margin-bottom: 18px; }
.carte-serveur h2 { font-size: 17px; margin: 24px 0 10px; }
.carte-serveur .alerte { background: var(--rouge-fond); color: var(--rouge); padding: 10px 12px; border-radius: 10px; }
.carte-serveur .ok { background: var(--vert-fond); color: var(--vert); padding: 10px 12px; border-radius: 10px; }
.carte-serveur table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.carte-serveur th, .carte-serveur td { text-align: left; padding: 8px 7px; border-bottom: 1px solid var(--ligne); vertical-align: top; }
.carte-serveur th { color: var(--encre-3); font-weight: 600; font-size: 12px; text-transform: uppercase; }
.carte-serveur form.inline { display: inline; }
.carte-serveur form.inline button { border: 1px solid var(--ligne); background: #fff; border-radius: 7px; padding: 4px 9px; font-size: 13px; }
.onglets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.onglets a { padding: 8px 12px; border-radius: 9px; background: #eef2f7; color: var(--encre); text-decoration: none; font-size: 14px; }
.onglets a.actif { background: var(--accent); color: #fff; }
.mini-logo { height: 22px; vertical-align: middle; }
.carte-serveur { overflow-x: auto; }

@media (min-width: 700px) {
  .choix-grille.deux { grid-template-columns: 1fr 1fr; }
}
