/* LDS Interventions — application terrain. Charte claire : blanc, argent et bleu du logo. */
:root {
  --bleu: #0f5bb5;
  --bleu-2: #0b4a96;
  --bleu-clair: #e9f1fb;
  --bleu-moyen: #6aa3d7;
  --fond: #f3f6fa;
  --carte: #ffffff;
  --bord: #dfe5ec;
  --bord-2: #c8d1dc;
  --texte: #1d2939;
  --gris: #5f6b7a;
  --gris-2: #98a2b3;
  --rouge-action: #c0262d;
  --ombre: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --rayon: 14px;
  /* couleurs des statuts : identiques au rapport */
  --s-vert: #15803d; --s-vert-f: #dcfce7;
  --s-orange: #b45309; --s-orange-f: #fef3c7;
  --s-bleu: #1d4ed8; --s-bleu-f: #dbeafe;
  --s-rouge: #b91c1c; --s-rouge-f: #fee2e2;
  --s-violet: #6d28d9; --s-violet-f: #ede9fe;
  --s-gris: #475569; --s-gris-f: #e2e8f0;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--fond); color: var(--texte); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px; line-height: 1.4; -webkit-tap-highlight-color: transparent;
  min-height: 100vh; padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- barre du haut */
.barre {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
  background: linear-gradient(#ffffff, #f8fafc); border-bottom: 3px solid var(--bleu);
}
.barre .retour { border: 0; background: none; padding: 8px; margin-left: -6px; border-radius: 10px; color: var(--bleu-2); display: flex; }
.barre .retour[hidden] { display: none; }
.barre .logo { width: 38px; height: 38px; object-fit: contain; mix-blend-mode: multiply; }
.barre .titres { flex: 1; min-width: 0; }
.barre .titre { font-weight: 700; font-size: 17px; color: var(--bleu-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barre .sous-titre { font-size: 12.5px; color: var(--gris); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etat {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--bord); background: #fff;
  border-radius: 999px; padding: 6px 10px; font-size: 13px; font-weight: 600; color: var(--gris); white-space: nowrap;
}
.etat .point { width: 9px; height: 9px; border-radius: 50%; background: var(--gris-2); }
.etat.en-ligne .point { background: #16a34a; }
.etat .compte { background: var(--bleu); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 12px; }

/* ---- mise en page */
main { max-width: 760px; margin: 0 auto; padding: 4px 0 16px; }
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--gris); margin: 20px 16px 8px; font-weight: 700; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 14px; margin: 10px 12px; }
.carte.cliquable { cursor: pointer; }
.carte.cliquable:active { background: #fafcff; }
.vide { text-align: center; color: var(--gris); padding: 28px 16px; }
.aide { color: var(--gris); font-size: 14px; }
.petit { font-size: 13px; color: var(--gris); }
.ligne-flex { display: flex; align-items: center; gap: 10px; }
.espace { flex: 1; }
.hidden { display: none !important; }

/* ---- boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--bord-2); background: #fff; font-weight: 600; font-size: 16px; color: var(--texte);
  text-decoration: none; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn.primaire { background: var(--bleu); border-color: var(--bleu); color: #fff; }
.btn.primaire:active { background: var(--bleu-2); }
.btn.secondaire { background: var(--bleu-clair); border-color: #cfe0f5; color: var(--bleu-2); }
.btn.large { width: 100%; }
.btn.xl { min-height: 60px; font-size: 18px; border-radius: 16px; }
.btn.pointille { border-style: dashed; border-width: 2px; color: var(--bleu-2); background: #fbfdff; }
.btn.danger { color: var(--rouge-action); border-color: #f0c5c7; background: #fff; }
.btn.lien { border: 0; background: none; color: var(--bleu-2); min-height: 40px; padding: 0 8px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.bloc-boutons { padding: 6px 12px; display: grid; gap: 10px; }
.icone-btn { border: 1px solid var(--bord); background: #fff; border-radius: 10px; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--gris); }

/* ---- barre d'action en bas */
.bas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; display: flex; gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .96);
  border-top: 1px solid var(--bord); backdrop-filter: blur(6px);
}
.bas:empty { display: none; }
.bas .btn { flex: 1; }
.bas .btn.court { flex: 0 0 auto; }

/* ---- formulaires */
.champ { margin-top: 12px; }
.champ:first-child { margin-top: 0; }
.champ > label, .etiquette { display: block; font-size: 12.5px; font-weight: 700; color: var(--gris); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .5px; }
.etiquette small, .champ > label small { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--gris-2); }
input[type=text], input[type=search], input[type=date], input[type=time], input[type=number], input:not([type]), select, textarea {
  width: 100%; padding: 12px; border: 1px solid var(--bord-2); border-radius: 10px; background: #fff; font-size: 16px;
  outline: none; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--gris) 50%), linear-gradient(135deg, var(--gris) 50%, transparent 50%);
  background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
input:focus, select:focus, textarea:focus { border-color: var(--bleu); box-shadow: 0 0 0 3px rgba(15, 91, 181, .15); }
textarea { min-height: 84px; resize: vertical; line-height: 1.45; field-sizing: content; }
textarea.court { min-height: 56px; }
.deux-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.case { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; }
.case input[type=checkbox] { width: 24px; height: 24px; margin: 0; accent-color: var(--bleu); flex: none; }

/* ---- puces (choix) */
.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce-choix {
  border: 1px solid var(--bord-2); background: #fff; border-radius: 999px; padding: 9px 14px; font-size: 14.5px; font-weight: 600; color: var(--texte);
}
.puce-choix.actif { background: var(--bleu-clair); border-color: var(--bleu); color: var(--bleu-2); }
.puce-choix.ajout { border-style: dashed; color: var(--bleu-2); }

/* ---- statuts (mêmes couleurs que le rapport) */
.statut { display: inline-block; border: 1px solid; border-radius: 999px; padding: 2px 9px; font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.statut.vert { color: var(--s-vert); background: var(--s-vert-f); border-color: rgba(21, 128, 61, .25); }
.statut.orange { color: var(--s-orange); background: var(--s-orange-f); border-color: rgba(180, 83, 9, .25); }
.statut.bleu { color: var(--s-bleu); background: var(--s-bleu-f); border-color: rgba(29, 78, 216, .25); }
.statut.rouge { color: var(--s-rouge); background: var(--s-rouge-f); border-color: rgba(185, 28, 28, .25); }
.statut.violet { color: var(--s-violet); background: var(--s-violet-f); border-color: rgba(109, 40, 217, .25); }
.statut.gris { color: var(--s-gris); background: var(--s-gris-f); border-color: rgba(71, 85, 105, .25); }
.choix-statut { border: 2px solid transparent; border-radius: 999px; padding: 8px 13px; font-size: 14px; font-weight: 700; background: #fff; }
.choix-statut.vert { color: var(--s-vert); border-color: var(--s-vert-f); }
.choix-statut.orange { color: var(--s-orange); border-color: var(--s-orange-f); }
.choix-statut.bleu { color: var(--s-bleu); border-color: var(--s-bleu-f); }
.choix-statut.rouge { color: var(--s-rouge); border-color: var(--s-rouge-f); }
.choix-statut.violet { color: var(--s-violet); border-color: var(--s-violet-f); }
.choix-statut.gris { color: var(--s-gris); border-color: var(--s-gris-f); }
.choix-statut.actif.vert { background: var(--s-vert-f); border-color: var(--s-vert); }
.choix-statut.actif.orange { background: var(--s-orange-f); border-color: var(--s-orange); }
.choix-statut.actif.bleu { background: var(--s-bleu-f); border-color: var(--s-bleu); }
.choix-statut.actif.rouge { background: var(--s-rouge-f); border-color: var(--s-rouge); }
.choix-statut.actif.violet { background: var(--s-violet-f); border-color: var(--s-violet); }
.choix-statut.actif.gris { background: var(--s-gris-f); border-color: var(--s-gris); }

/* ---- accueil */
.bienvenue { padding: 16px 16px 4px; }
.bienvenue .bonjour { font-size: 22px; font-weight: 700; }
.bienvenue .jour { color: var(--gris); }
.bienvenue .jour::first-letter { text-transform: uppercase; }
.nouvelle { margin: 14px 12px 4px; }
.inter-carte .haut { display: flex; align-items: flex-start; gap: 10px; }
.inter-carte .client { font-weight: 700; font-size: 16.5px; }
.inter-carte .infos { color: var(--gris); font-size: 14px; margin-top: 2px; }
.inter-carte .etat-envoi { margin-top: 8px; font-size: 13.5px; color: var(--gris); display: flex; align-items: center; gap: 6px; }
.inter-carte .etat-envoi.erreur { color: var(--s-orange); }
.etiquette-statut { font-size: 12px; font-weight: 700; border-radius: 6px; padding: 3px 8px; white-space: nowrap; }
.etiquette-statut.brouillon { background: #eef2f6; color: var(--gris); }
.etiquette-statut.attente { background: var(--s-orange-f); color: var(--s-orange); }
.etiquette-statut.envoyee { background: var(--s-vert-f); color: var(--s-vert); }
.etiquette-statut.validee { background: var(--bleu-clair); color: var(--bleu-2); }
.synchro-info { text-align: center; color: var(--gris); font-size: 13px; margin: 18px 12px; }

/* ---- intervention */
.resume .client { font-weight: 700; font-size: 17px; }
.resume .meta { color: var(--gris); font-size: 14px; margin-top: 2px; }
.resume .contexte { margin-top: 8px; font-size: 14.5px; color: var(--texte); white-space: pre-wrap; }
.resume .modifier { color: var(--bleu-2); font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; }
.engin-carte .haut { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.engin-carte .nom { font-weight: 700; font-size: 16px; }
.engin-carte .type { color: var(--gris); font-size: 13.5px; }
.engin-carte .details { display: flex; flex-wrap: wrap; gap: 12px; color: var(--gris); font-size: 13.5px; margin-top: 8px; }
.engin-carte .details span { display: inline-flex; align-items: center; gap: 4px; }
.engin-carte .details svg.ic { width: 16px; height: 16px; }
.engin-carte .manque { color: var(--s-orange); font-weight: 600; }
.num { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px; border-radius: 8px; background: var(--bleu-clair); color: var(--bleu-2); font-weight: 700; font-size: 13px; margin-right: 8px; }

/* ---- fiche engin */
.fiche-tete { border-left: 6px solid var(--bleu); }
.fiche-tete .nom { font-size: 20px; font-weight: 700; }
.fiche-tete .type { color: var(--gris); }
.situation { background: #f6f8fb; }
.situation .source { font-size: 12.5px; color: var(--gris); margin-bottom: 6px; }
.action-ouverte { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--bord); }
.action-ouverte:first-of-type { border-top: 0; }
.action-ouverte input { width: 24px; height: 24px; accent-color: var(--s-vert); flex: none; margin: 2px 0 0; }
.action-ouverte .des { font-weight: 600; }
.besoin { border: 1px solid var(--bord); border-radius: 12px; padding: 10px; margin-top: 10px; background: #fbfcfe; }
.besoin .ligne2 { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.besoin select { flex: 1; padding-top: 9px; padding-bottom: 9px; }
.besoin .remarque { margin-top: 8px; padding: 9px 12px; font-size: 15px; }
.qte { display: inline-flex; align-items: center; border: 1px solid var(--bord-2); border-radius: 10px; overflow: hidden; background: #fff; }
.qte button { border: 0; background: #fff; width: 40px; height: 40px; font-size: 20px; color: var(--bleu-2); }
.qte span { min-width: 30px; text-align: center; font-weight: 700; }
.photos-grille { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 4px; }
.vignette { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #e9eef4; border: 1px solid var(--bord); padding: 0; }
.vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vignette .marque { position: absolute; left: 6px; bottom: 6px; background: rgba(255, 255, 255, .92); color: var(--bleu-2); border-radius: 6px; padding: 1px 6px; font-size: 11.5px; font-weight: 700; }
.vignette .annotee { position: absolute; right: 6px; top: 6px; background: var(--bleu); color: #fff; border-radius: 6px; padding: 1px 5px; font-size: 11px; font-weight: 700; }
.legende-vignette { font-size: 12px; color: var(--gris); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.boutons-photo { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; margin-top: 12px; }
.chargement { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--bleu-clair); border-top-color: var(--bleu); animation: tourne .8s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }

/* ---- clôture */
.alerte { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-top: 8px; }
.alerte.bloquante { background: var(--s-rouge-f); color: var(--s-rouge); }
.alerte.info { background: var(--s-orange-f); color: var(--s-orange); }
.alerte.ok { background: var(--s-vert-f); color: var(--s-vert); }
.chiffres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.chiffre { border: 1px solid var(--bord); border-top: 3px solid var(--bleu); border-radius: 10px; padding: 8px; background: #f9fbfd; }
.chiffre b { font-size: 22px; color: var(--bleu-2); display: block; line-height: 1.1; }
.chiffre span { font-size: 12.5px; color: var(--gris); }
.recap-ligne { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--bord); font-size: 15px; }
.recap-ligne:first-child { border-top: 0; }

/* ---- activation */
.activation { max-width: 420px; margin: 0 auto; padding: 32px 8px; text-align: center; }
.activation img { width: 132px; height: 132px; mix-blend-mode: multiply; }
.activation h1 { color: var(--bleu-2); margin: 8px 0 4px; font-size: 24px; }
.activation .carte { text-align: left; }
.activation input { font-size: 22px; letter-spacing: 4px; text-align: center; }
.erreur-texte { color: var(--s-rouge); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* ---- feuilles (sélection d'engin, saisie) */
.voile { position: fixed; inset: 0; z-index: 40; background: rgba(29, 41, 57, .32); display: flex; align-items: flex-end; justify-content: center; animation: apparait .15s ease-out; }
@keyframes apparait { from { opacity: 0; } }
.feuille { width: 100%; max-width: 760px; max-height: 92vh; background: #fff; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; box-shadow: 0 -8px 30px rgba(16, 24, 40, .15); animation: monte .2s ease-out; }
.feuille.pleine { height: 92vh; }
@keyframes monte { from { transform: translateY(30px); opacity: .6; } }
.feuille-tete { display: flex; align-items: center; gap: 10px; padding: 12px; border-bottom: 1px solid var(--bord); }
.feuille-tete h3 { margin: 0; font-size: 17px; flex: 1; }
.feuille-corps { overflow-y: auto; padding: 8px 12px 18px; -webkit-overflow-scrolling: touch; }
.feuille-pied { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--bord); display: flex; gap: 10px; }
.feuille-pied .btn { flex: 1; }
.groupe-titre { font-size: 12.5px; font-weight: 700; color: var(--gris); text-transform: uppercase; letter-spacing: .5px; margin: 14px 4px 6px; }
.choix-engin { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--bord); border-radius: 12px; padding: 11px 12px; margin-top: 8px; }
.choix-engin:active { background: var(--bleu-clair); }
.choix-engin .nom { font-weight: 700; }
.choix-engin .type { font-size: 13px; color: var(--gris); }
.choix-engin .droite { margin-left: auto; text-align: right; display: grid; gap: 4px; justify-items: end; }
.choix-engin.deja { opacity: .45; }
.choix-engin .attente { font-size: 12px; color: var(--s-orange); font-weight: 700; }
.dialogue { width: calc(100% - 32px); max-width: 420px; background: #fff; border-radius: 16px; padding: 18px; margin: auto; box-shadow: 0 10px 40px rgba(16, 24, 40, .2); align-self: center; }
.dialogue h3 { margin: 0 0 8px; }
.dialogue p { margin: 0 0 14px; color: var(--gris); }
.dialogue .boutons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.voile.centre { align-items: center; }

/* ---- message bref */
.toast { position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; background: #fff; color: var(--texte); padding: 12px 16px; border-radius: 12px; border: 1px solid var(--bord); border-left: 5px solid var(--bleu); font-size: 14.5px; font-weight: 600; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(16, 24, 40, .16); opacity: 0; pointer-events: none; transition: opacity .2s; }
.toast.visible { opacity: 1; }
.toast.ok { border-left-color: var(--s-vert); }
.toast.erreur { border-left-color: var(--s-rouge); }

/* ---- éditeur de photo (fond clair) */
.ed { position: fixed; inset: 0; z-index: 50; background: #eef2f6; display: flex; flex-direction: column; }
.ed-haut { display: flex; align-items: center; gap: 8px; padding: 8px 10px; padding-top: calc(8px + env(safe-area-inset-top)); background: #fff; border-bottom: 1px solid var(--bord); }
.ed-haut .titre { flex: 1; text-align: center; font-weight: 700; color: var(--bleu-2); }
.ed-zone { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px; }
.ed-zone canvas { touch-action: none; box-shadow: 0 2px 10px rgba(16, 24, 40, .15); background: #fff; border-radius: 4px; }
.ed-outils { background: #fff; border-top: 1px solid var(--bord); padding: 8px 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: center; }
.ed-groupe { display: flex; gap: 6px; align-items: center; }
.ed-outil { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--bord); background: #fff; display: inline-flex; align-items: center; justify-content: center; color: var(--texte); }
.ed-outil.actif { background: var(--bleu-clair); border-color: var(--bleu); color: var(--bleu-2); }
.ed-couleur { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--bord-2); }
.ed-couleur.actif { box-shadow: 0 0 0 3px var(--bleu); }
.ed-separateur { width: 1px; height: 30px; background: var(--bord); margin: 0 2px; }
.ed-bas { background: #fff; padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); display: flex; gap: 8px; align-items: center; }
.ed-bas input { flex: 1; }
.ed-texte { position: absolute; left: 12px; right: 12px; top: 30%; background: #fff; border-radius: 14px; padding: 14px; box-shadow: 0 10px 30px rgba(16, 24, 40, .25); z-index: 2; }
.ed-texte .boutons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }

@media (min-width: 700px) {
  .photos-grille { grid-template-columns: repeat(4, 1fr); }
}

/* Enregistrement impossible (mémoire pleine…) : bandeau permanent tant que le problème dure */
.alerte-sauvegarde { position: fixed; left: 0; right: 0; top: 0; z-index: 70; background: var(--s-rouge-f); color: var(--s-rouge); border-bottom: 2px solid var(--s-rouge); padding: calc(10px + env(safe-area-inset-top)) 16px 10px; font-size: 14px; font-weight: 700; line-height: 1.35; }
/* Photo référencée dans la fiche mais absente du téléphone */
.vignette.manquante { border: 2px dashed var(--s-rouge); background: var(--s-rouge-f); }
.vignette .introuvable { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--s-rouge); font-size: 11.5px; font-weight: 700; text-align: center; padding: 6px; }
.vignette .introuvable .ic { width: 22px; height: 22px; }
