/* OPSIS Pro — application terrain (téléphones Android 360–412 px, usage en extérieur) */
:root {
  --indigo: #2e3192; --indigo-fonce: #1f2170; --indigo-clair: #e8e9f6;
  --vert: #8dc63f; --vert-fonce: #4f7a16; --vert-clair: #eef7e1;
  --rouge: #c62828; --rouge-clair: #fdecea; --orange: #a35a00; --orange-clair: #fff3e0;
  --texte: #14152b; --texte-2: #4a4c66; --fond: #f4f5f9; --carte: #ffffff; --bord: #d5d7e3;
  --rayon: 14px; --ombre: 0 1px 3px rgba(20, 21, 43, .12);
  --tactile: 52px;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--fond); color: var(--texte);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  overflow-x: hidden; padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1.02rem; }
p { margin: 0 0 .6rem; }
a { color: var(--indigo); }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muet { color: var(--texte-2); font-size: .92rem; }
.coupe { overflow-wrap: anywhere; word-break: break-word; }

/* En-tête */
.entete {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--indigo); color: #fff; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  min-height: 56px;
}
.entete__marque { display: flex; align-items: center; gap: 10px; min-width: 0; }
.entete__logo { width: 36px; height: 36px; object-fit: contain; background: #fff; border-radius: 8px; padding: 2px; flex: none; }
.entete__titres { display: flex; flex-direction: column; min-width: 0; }
.entete__app { font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; }
.entete__serveur { font-size: .85rem; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete__droite { display: flex; align-items: center; gap: 6px; flex: none; }
.file-attente {
  flex: none; border: 0; border-radius: 999px; background: #ffd54f; color: #3b2a00; font: inherit; font-size: .85rem; font-weight: 700;
  min-height: 40px; padding: 4px 12px; cursor: pointer;
}
.deconnexion { border: 1px solid rgba(255, 255, 255, .5); border-radius: 10px; background: none; color: #fff; font: inherit; font-size: .8rem; min-height: 40px; padding: 4px 8px; cursor: pointer; }

/* Barre de service */
.service {
  display: flex; align-items: center; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap;
  background: #fff; border-bottom: 1px solid var(--bord); padding: 2px 12px;
}
.service__etat { font-size: .88rem; color: var(--texte-2); }
.service.actif { background: var(--vert-clair); }
.service.actif .service__etat { color: var(--vert-fonce); font-weight: 600; }
.interrupteur { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tactile); cursor: pointer; font-weight: 700; position: relative; }
.interrupteur input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.interrupteur__piste { width: 56px; height: 32px; border-radius: 16px; background: #b8bacb; position: relative; transition: background .15s; flex: none; }
.interrupteur__piste::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: var(--ombre); transition: transform .15s; }
.interrupteur input:checked + .interrupteur__piste { background: var(--vert-fonce); }
.interrupteur input:checked + .interrupteur__piste::after { transform: translateX(24px); }
.interrupteur input:focus-visible + .interrupteur__piste { outline: 3px solid var(--indigo); outline-offset: 2px; }

.hors-ligne { background: var(--orange-clair); color: var(--orange); padding: 8px 12px; font-size: .92rem; font-weight: 600; }

/* Vue */
.vue { padding: 12px; max-width: 640px; margin: 0 auto; outline: none; }
.chargement { text-align: center; color: var(--texte-2); padding: 40px 0; }
.carte { background: var(--carte); border-radius: var(--rayon); box-shadow: var(--ombre); padding: 14px; margin-bottom: 12px; border: 1px solid #e6e7ef; }
.titre-vue { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.titre-vue h1 { margin: 0; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tactile); padding: 10px 16px;
  border-radius: 12px; border: 2px solid var(--indigo); background: #fff; color: var(--indigo); font: inherit; font-weight: 700;
  text-decoration: none; cursor: pointer; text-align: center; touch-action: manipulation; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn--plein { background: var(--indigo); color: #fff; }
.btn--vert { background: var(--vert-fonce); border-color: var(--vert-fonce); color: #fff; }
.btn--danger { border-color: var(--rouge); color: var(--rouge); }
.btn--large { width: 100%; }
.btn--petit { min-height: 44px; padding: 6px 12px; font-size: .95rem; }
.rangee { display: flex; gap: 8px; flex-wrap: wrap; }
.rangee > .btn { flex: 1 1 0; min-width: 0; }
.retour { border: 0; background: none; color: var(--indigo); font: inherit; font-weight: 700; min-height: 44px; padding: 0 4px; cursor: pointer; }

/* Formulaires */
label.champ { display: block; margin-bottom: 12px; font-weight: 600; }
label.champ > span { display: block; margin-bottom: 4px; }
.champ input, .champ select {
  width: 100%; min-height: var(--tactile); border: 2px solid var(--bord); border-radius: 10px; padding: 8px 12px; font: inherit;
  background: #fff; color: var(--texte);
}
.champ input:focus, .champ select:focus { border-color: var(--indigo); outline: none; }
.erreur { background: var(--rouge-clair); color: var(--rouge); border-radius: 10px; padding: 10px 12px; font-weight: 600; margin-bottom: 12px; }
.succes { background: var(--vert-clair); color: var(--vert-fonce); border-radius: 10px; padding: 10px 12px; font-weight: 600; margin-bottom: 12px; }

/* Connexion */
.connexion { padding-top: 24px; }
.connexion__logo { display: block; width: 88px; height: 88px; margin: 0 auto 14px; border-radius: 20px; }

/* Missions */
.mission__tete { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.mission__ref { font-weight: 800; font-size: 1.08rem; color: var(--indigo); }
.mission__assure { font-weight: 700; margin: 2px 0; }
.mission__ligne { display: flex; gap: 6px; align-items: baseline; font-size: .95rem; color: var(--texte-2); margin: 2px 0; }
.mission__ligne b { color: var(--texte); }
.mission__actions { margin-top: 10px; }
.badge { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 700; background: var(--indigo-clair); color: var(--indigo); white-space: nowrap; }
.badge--rapide { background: #fff3cd; color: #7a5200; }
.badge--oblig { background: var(--rouge-clair); color: var(--rouge); }
.badge--facult { background: #eceef4; color: var(--texte-2); }
.badge--fait { background: var(--vert-clair); color: var(--vert-fonce); }
.badge--afaire { background: #fff3e0; color: var(--orange); }
.puces { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.puce { font-size: .82rem; background: #fff7e6; color: #7a4b00; border: 1px solid #f1d7a6; border-radius: 8px; padding: 2px 8px; }
.vide { text-align: center; color: var(--texte-2); padding: 30px 10px; }

/* Fiche mission */
.infos { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; font-size: .95rem; margin: 0; }
.infos div { display: flex; gap: 6px; flex-wrap: wrap; }
.infos dt { color: var(--texte-2); }
.infos dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.exigence { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid #eceef4; }
.exigence:last-child { border-bottom: 0; }
.exigence__nom { font-weight: 600; min-width: 0; }
.exigence__nom.fait { color: var(--vert-fonce); }
.exigence__badges { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; flex: none; max-width: 55%; }
.categories { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.categories button {
  min-height: 48px; border: 2px solid var(--bord); border-radius: 10px; background: #fff; font: inherit; font-size: .78rem; font-weight: 700;
  color: var(--texte-2); padding: 4px 2px; cursor: pointer; overflow-wrap: anywhere;
}
.categories button[aria-pressed="true"] { border-color: var(--indigo); background: var(--indigo); color: #fff; }
.galerie h3 { margin: 12px 0 6px; font-size: .95rem; color: var(--texte-2); }
.vignettes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.vignette { position: relative; aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: #dfe1ea; cursor: pointer; }
.vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vignette .marque { position: absolute; left: 4px; bottom: 4px; background: rgba(46, 49, 146, .9); color: #fff; font-size: .7rem; border-radius: 6px; padding: 1px 6px; }
.vignette--attente { display: flex; align-items: center; justify-content: center; font-size: .75rem; color: var(--orange); background: var(--orange-clair); text-align: center; padding: 4px; cursor: default; }
.etat-accord { margin-top: 10px; }

/* Panneaux plein écran (contrôle photo, annotation, signature, visionneuse) */
.panneau { position: fixed; inset: 0; z-index: 50; background: #fff; display: flex; flex-direction: column; overflow: hidden; }
.panneau__tete { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; background: var(--indigo); color: #fff; min-height: 56px; flex: none; }
.panneau__tete h2 { margin: 0; font-size: 1.05rem; }
.panneau__tete .retour { color: #fff; }
.panneau__corps { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px; }
.panneau__pied { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--bord); background: #fff; flex: none; }
.panneau--sombre { background: #111; }
.visionneuse { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.visionneuse img { max-width: 100%; max-height: 100%; object-fit: contain; }
.apercu { display: block; width: 100%; max-height: 45vh; object-fit: contain; border-radius: 10px; background: #222; margin-bottom: 10px; }
.refus { border-left: 6px solid var(--rouge); background: var(--rouge-clair); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.refus strong { display: block; color: var(--rouge); font-size: 1.05rem; margin-bottom: 4px; }
.accepte { border-left: 6px solid var(--vert-fonce); background: var(--vert-clair); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.accepte strong { display: block; color: var(--vert-fonce); font-size: 1.05rem; margin-bottom: 4px; }

/* Annotation */
.outils { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px; background: #f0f1f6; border-bottom: 1px solid var(--bord); flex: none; }
.outil { min-width: 48px; min-height: 48px; border: 2px solid var(--bord); border-radius: 10px; background: #fff; font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; padding: 4px 8px; color: var(--texte); }
.outil[aria-pressed="true"] { border-color: var(--indigo); box-shadow: inset 0 0 0 2px var(--indigo); }
.outil--couleur { width: 48px; padding: 0; }
.outil--couleur span { display: block; width: 26px; height: 26px; border-radius: 50%; margin: auto; border: 2px solid rgba(0, 0, 0, .25); }
.outils__sep { width: 1px; background: var(--bord); margin: 0 2px; }
.zone-annotation { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; background: #222; overflow: hidden; padding: 6px; }
.zone-annotation canvas { max-width: 100%; max-height: 100%; touch-action: none; display: block; }

/* Signature */
.pad { position: relative; border: 2px dashed var(--indigo); border-radius: 12px; background: #fff; height: 200px; touch-action: none; margin-bottom: 8px; }
.pad canvas { width: 100%; height: 100%; display: block; touch-action: none; border-radius: 10px; }
.pad__aide { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: .85rem; color: #9a9cb3; pointer-events: none; }
.pad.signe .pad__aide { display: none; }

/* Toast */
.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 80; background: #23243a; color: #fff;
  border-radius: 12px; padding: 12px 14px; font-weight: 600; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); max-width: 616px; margin: 0 auto;
}
.toast.toast--erreur { background: var(--rouge); }

/* Conversation du dossier (/chat/api) */
.mission__badges { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge--chat { background: var(--indigo); color: #fff; }
.chat__liste { max-height: 55vh; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 10px; padding: 10px;
  background: var(--fond); border: 1px solid var(--bord); border-radius: 12px; margin-bottom: 10px; }
.chat__vide { text-align: center; margin: 6px 0; }
.msg { max-width: 88%; align-self: flex-start; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.msg--moi { align-self: flex-end; align-items: flex-end; }
.msg__meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; font-size: .78rem; color: var(--texte-2); }
.msg--moi .msg__meta { justify-content: flex-end; }
.msg__meta b { color: var(--texte); }
.msg__role { background: var(--indigo-clair); color: var(--indigo); border-radius: 999px; padding: 0 8px; font-weight: 700; font-size: .72rem; }
.msg__bulle { background: #fff; border: 1px solid var(--bord); border-radius: 14px 14px 14px 4px; padding: 8px 12px; font-size: .98rem;
  max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.msg--moi .msg__bulle { background: var(--indigo); border-color: var(--indigo); color: #fff; border-radius: 14px 14px 4px 14px; }
.msg--retire .msg__bulle { background: transparent; color: var(--texte-2); border-style: dashed; }
.msg--attente .msg__bulle { background: var(--orange-clair); color: var(--orange); border-color: var(--orange-clair); }
.msg__texte { white-space: pre-wrap; }
.msg__photo { display: block; border: 0; padding: 0; margin-top: 6px; background: none; cursor: pointer; }
.msg__photo img { display: block; width: 180px; max-width: 100%; height: auto; border-radius: 10px; }
.msg__retirer { border: 0; background: none; color: var(--indigo); text-decoration: underline; font: inherit; font-size: .82rem; min-height: 32px; padding: 0 4px; cursor: pointer; }
.msg__lu { font-size: .75rem; color: var(--vert-fonce); }
.chat__zone { display: block; width: 100%; min-height: 72px; resize: vertical; border: 1px solid var(--bord); border-radius: 12px; padding: 10px 12px;
  font: inherit; color: var(--texte); background: #fff; margin-bottom: 8px; }
.chat__zone:focus { outline: 3px solid var(--indigo-clair); border-color: var(--indigo); }
.chat__jointe:empty { display: none; }
.chat__jointe { margin-bottom: 8px; }
.jointe { display: inline-flex; align-items: center; gap: 8px; background: var(--indigo-clair); color: var(--indigo); border-radius: 10px; padding: 4px 6px; font-size: .9rem; font-weight: 600; }
.jointe img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.jointe__retirer { border: 0; background: none; color: var(--indigo); font: inherit; font-size: 1rem; min-width: 40px; min-height: 40px; cursor: pointer; }
.chat__ro { background: #eceef4; border-radius: 10px; padding: 8px 12px; }
/* appareils approuvés : consentement à l'écran de connexion */
.consentement-appareil { margin: 4px 0 12px; font-size: 14px; line-height: 1.45; }
.consentement-appareil p { margin: 0 0 6px; }
.consentement-appareil .case { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; }
.consentement-appareil .case input { width: 22px; height: 22px; flex: none; margin: 0; }
.erreur.erreur--info { background: #e0f2fe; color: #0c4a6e; border-color: #7dd3fc; }
