:root {
  --marine: #17253f;
  --marine-2: #22365a;
  --turquoise: #50bcbd;
  --turquoise-fonce: #2f8f90;
  --turquoise-clair: #eef8f8;
  --ambre: #f7a833;
  --gris: #7c879c;
  --ligne: #dfe5ec;
  --fond: #f5f7fa;
  --blanc: #fff;
  --rouge: #c0392b;
  --rayon: 14px;
  --haut: env(safe-area-inset-top, 0px);
  --bas: env(safe-area-inset-bottom, 0px);
  --police: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.45 var(--police);
  color: var(--marine);
  background: var(--fond);
  padding: calc(64px + var(--haut)) 0 calc(84px + var(--bas));
  min-height: 100vh;
}
body.sans-nav { padding-bottom: calc(110px + var(--bas)); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2, h3 { line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 28px 0 10px; }
input, textarea, select, button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- En-tête et navigation ---------- */
.entete {
  position: fixed; inset: 0 0 auto 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--haut)) 16px 10px;
  min-height: calc(60px + var(--haut));
  background: var(--marine); color: var(--blanc);
}
.entete h1 { flex: 1; font-size: 1.1rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete-logo { width: 30px; height: 30px; }
.entete-retour { background: none; border: 0; color: var(--blanc); padding: 8px; margin: -8px 0 -8px -8px; display: flex; }
.entete-retour svg { width: 28px; height: 28px; }
.entete-retour:not([hidden]) + .entete-logo { display: none; }
.synchro { font-size: .75rem; padding: 4px 10px; border-radius: 99px; background: rgba(255,255,255,.12); white-space: nowrap; }
.synchro:empty { display: none; }
.synchro.ok { color: #bfe9e9; }
.synchro.hors-ligne { background: var(--ambre); color: var(--marine); }
.synchro.erreur, .synchro.deconnecte { background: var(--rouge); }

.nav {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex; background: var(--blanc); border-top: 1px solid var(--ligne);
  padding-bottom: var(--bas);
}
.nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 0 8px; color: var(--gris); text-decoration: none; font-size: .78rem; font-weight: 600;
}
.nav a svg { width: 28px; height: 28px; }
.nav a.actif { color: var(--turquoise-fonce); }

main { max-width: 760px; margin: 0 auto; padding: 16px; }

/* ---------- Boutons ---------- */
.bouton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 12px 18px; border-radius: var(--rayon);
  border: 1.5px solid var(--ligne); background: var(--blanc); color: var(--marine);
  font-weight: 600; text-decoration: none; cursor: pointer;
}
.bouton:active { transform: scale(.98); }
.bouton:disabled { opacity: .5; }
.bouton.principal { background: var(--turquoise); border-color: var(--turquoise); color: var(--marine); }
.bouton.grand { display: flex; width: 100%; min-height: 60px; font-size: 1.08rem; margin: 4px 0 14px; }
.bouton.enorme { width: 100%; min-height: 76px; font-size: 1.25rem; }
.bouton.danger { color: var(--rouge); border-color: #f1c9c4; width: 100%; margin-top: 18px; }
.bouton.lien { border: 0; background: none; color: var(--gris); min-height: 44px; }
.bouton.rond { width: 52px; height: 52px; min-height: 52px; padding: 0; border-radius: 50%; }
.bouton.discret-bouton { width: 100%; border-style: dashed; color: var(--gris); font-weight: 500; margin-top: 14px; }
.lien { background: none; border: 0; color: var(--turquoise-fonce); font-weight: 600; padding: 6px; cursor: pointer; }
.pied-page { display: block; margin: 24px auto 0; }

/* ---------- Listes et cartes ---------- */
.liste { display: flex; flex-direction: column; gap: 10px; }
.carte {
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px; background: var(--blanc); border-radius: var(--rayon);
  border: 1px solid var(--ligne); color: inherit; text-decoration: none;
}
.carte:active { background: var(--turquoise-clair); }
.carte span, .carte small { color: var(--gris); }
.carte small { font-size: .82rem; }
.pastille { background: var(--turquoise-clair); color: var(--turquoise-fonce); padding: 1px 8px; border-radius: 99px; font-size: .8rem; }
.vide { text-align: center; color: var(--gris); padding: 24px 8px; }
.discret { color: var(--gris); }
.erreur { color: var(--rouge); font-weight: 600; }
.aide { background: var(--turquoise-clair); border-radius: var(--rayon); padding: 12px 14px; margin: 0 0 12px; }
.recherche, .formulaire input, .formulaire textarea, .feuille textarea, .feuille input, .feuille select, .connexion input {
  width: 100%; padding: 14px; border: 1.5px solid var(--ligne); border-radius: var(--rayon); background: var(--blanc); font-size: 17px;
}
.recherche { margin-bottom: 12px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--turquoise); }

/* ---------- Formulaires ---------- */
.formulaire { display: flex; flex-direction: column; gap: 14px; }
.formulaire label, .feuille label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .92rem; }
.ligne { display: flex; gap: 8px; }
.ligne input { flex: 1; }

/* ---------- Connexion ---------- */
body.ecran-connexion .entete { display: none; }
body.ecran-connexion { background: var(--marine); padding-top: var(--haut); }
.connexion { max-width: 360px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 14px; text-align: center; color: var(--blanc); }
.connexion h1 { margin: 0; font-size: 1.8rem; }
.connexion p { margin: 0 0 12px; }
.connexion .discret { color: #aab4c6; }
.connexion input { color: var(--marine); }
.connexion-logo { width: 96px; height: 96px; margin: 0 auto; background: var(--blanc); border-radius: 24px; padding: 12px; }
.connexion .erreur { color: #ffb4a8; }

/* ---------- Fiche client ---------- */
.fiche { background: var(--blanc); border-radius: var(--rayon); padding: 16px; border: 1px solid var(--ligne); margin-bottom: 14px; }
.fiche p { margin: 0 0 8px; }
.fiche .notes { background: var(--fond); border-radius: 10px; padding: 10px 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions .bouton { flex: 1 1 120px; }

/* ---------- Visite ---------- */
.visite-tete { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.titre-visite { flex: 1; border: 0; border-bottom: 1.5px dashed var(--ligne); background: none; padding: 8px 2px; font-weight: 600; font-size: 1.05rem; min-width: 0; }
.pieces { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 12px; margin: 0 -16px; scrollbar-width: none; }
.pieces::-webkit-scrollbar { display: none; }
.puce {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  min-height: 46px; padding: 10px 16px; border-radius: 99px; border: 1.5px solid var(--ligne);
  background: var(--blanc); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.puce svg { width: 18px; height: 18px; }
.puce.active { background: var(--marine); border-color: var(--marine); color: var(--blanc); }
.puce.ajout { border-style: dashed; color: var(--turquoise-fonce); }
.piece h3 { margin: 20px 0 8px; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; margin-bottom: 10px; }
.vignette { aspect-ratio: 1; border: 0; padding: 0; border-radius: 10px; overflow: hidden; background: var(--ligne); cursor: pointer; }
.vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vignette span { font-size: .7rem; color: var(--gris); padding: 4px; }
.note { background: var(--blanc); border: 1px solid var(--ligne); border-radius: var(--rayon); padding: 12px 14px; margin-bottom: 10px; }
.note-tete { display: flex; align-items: center; gap: 8px; color: var(--gris); font-size: .88rem; }
.note-tete span { flex: 1; }
.note-tete svg { width: 20px; height: 20px; color: var(--turquoise-fonce); }
.note p { margin: 8px 0 0; }
.note audio { width: 100%; margin-top: 8px; height: 40px; }
.bloc-cr { margin-top: 26px; }

.barre-actions {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex; gap: 8px; padding: 10px 12px calc(10px + var(--bas));
  background: var(--marine);
}
.action {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 74px; border-radius: var(--rayon); border: 0; cursor: pointer;
  background: var(--marine-2); color: var(--blanc); font-weight: 600; font-size: .9rem;
}
.action svg { width: 32px; height: 32px; }
.action:first-child { background: var(--turquoise); color: var(--marine); }
.action:active { transform: scale(.97); }
.action:disabled { opacity: .5; }

/* ---------- Feuilles (panneaux du bas) ---------- */
.feuille-fond { position: fixed; inset: 0; z-index: 20; background: rgba(23, 37, 63, .55); display: flex; align-items: flex-end; justify-content: center; }
.feuille {
  width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto;
  background: var(--fond); border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + var(--bas)); display: flex; flex-direction: column; gap: 12px;
  animation: monte .2s ease-out;
}
@keyframes monte { from { transform: translateY(40px); opacity: 0; } }
.feuille h2 { margin: 0; }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-grande { width: 100%; border-radius: 12px; max-height: 60vh; object-fit: contain; background: #000; }

.enregistrement { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0; }
.enregistrement p { margin: 0; font-weight: 600; }
.point-rouge { width: 22px; height: 22px; border-radius: 50%; background: var(--rouge); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.8); } }
.chrono { font-size: 3.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Compte-rendu ---------- */
.attente { text-align: center; padding: 40px 10px; }
.roue { width: 48px; height: 48px; margin: 0 auto 16px; border-radius: 50%; border: 5px solid var(--ligne); border-top-color: var(--turquoise); animation: tourne 1s linear infinite; }
@keyframes tourne { to { transform: rotate(360deg); } }
.cr h1 { font-size: 1.4rem; margin: 4px 0; }
.cr h2 { border-bottom: 2px solid var(--turquoise); padding-bottom: 4px; }
.cr h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gris); margin: 14px 0 6px; }
.cr ul { margin: 0; padding-left: 20px; }
.cr li { margin-bottom: 4px; }
.synthese { background: var(--turquoise-clair); border-left: 4px solid var(--turquoise); border-radius: 0 var(--rayon) var(--rayon) 0; padding: 12px 14px; margin: 14px 0; }
.point { border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; }
.point.urgent { background: #fde8e8; } .point.urgent b { color: #b42318; }
.point.a_surveiller { background: #fff4e0; } .point.a_surveiller b { color: #b54708; }
.point.info { background: #eef1f5; } .point.info b { color: #475467; }
.cr-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 10px; }
.cr-photos figure { margin: 0; }
.cr-photos img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; display: block; }
.cr-photos figcaption { font-size: .75rem; color: var(--gris); text-align: center; }
.internes { background: #fffaf0; border: 1px dashed var(--ambre); border-radius: var(--rayon); padding: 4px 14px 14px; margin-top: 24px; }
.internes h2 { border-color: var(--ambre); }
.action.large { flex-direction: row; gap: 10px; font-size: 1.05rem; }

/* ---------- Questions ---------- */
body.page-question { padding-bottom: calc(96px + var(--bas)); }
.fil { display: flex; flex-direction: column; gap: 12px; }
.bulle { max-width: 88%; padding: 12px 14px; border-radius: 18px; overflow-wrap: anywhere; }
.bulle.user { align-self: flex-end; background: var(--marine); color: var(--blanc); border-bottom-right-radius: 6px; }
.bulle.assistant { align-self: flex-start; background: var(--blanc); border: 1px solid var(--ligne); border-bottom-left-radius: 6px; }
.bulle p { margin: 0 0 8px; } .bulle p:last-child { margin-bottom: 0; }
.bulle ul, .bulle ol { margin: 4px 0 8px; padding-left: 22px; }
.bulle h4 { margin: 10px 0 4px; }
.bulle code { background: var(--fond); padding: 1px 5px; border-radius: 5px; font-size: .9em; }
.bulle pre { background: var(--fond); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: .85em; }
.points { display: inline-flex; gap: 4px; }
.points i { width: 8px; height: 8px; border-radius: 50%; background: var(--gris); animation: pulse 1s infinite; }
.points i:nth-child(2) { animation-delay: .2s; } .points i:nth-child(3) { animation-delay: .4s; }
.saisie {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 12px calc(10px + var(--bas)); background: var(--blanc); border-top: 1px solid var(--ligne);
}
.saisie textarea { flex: 1; resize: none; padding: 13px 14px; border: 1.5px solid var(--ligne); border-radius: 24px; max-height: 160px; font-size: 17px; }
@media (min-width: 800px) { .saisie { padding-left: calc(50% - 364px); padding-right: calc(50% - 364px); } }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(110px + var(--bas)); z-index: 30;
  max-width: 520px; margin: 0 auto; padding: 14px 16px; border-radius: var(--rayon);
  background: var(--marine); color: var(--blanc); text-align: center; box-shadow: 0 6px 24px rgba(0,0,0,.2);
}

/* ---------- Schémas ---------- */
.brouillon {
  background: #fff4e0; border: 1.5px solid var(--ambre); color: #8a4b00;
  border-radius: var(--rayon); padding: 10px 14px; font-weight: 700; font-size: .92rem; margin-bottom: 12px;
}
.schema-image { display: block; width: 100%; padding: 6px; border: 1px solid var(--ligne); border-radius: var(--rayon); background: #fff; cursor: zoom-in; }
.schema-image img { width: 100%; display: block; }
.petit { font-size: .82rem; text-align: center; margin: 4px 0 12px; }
.tableau { width: 100%; border-collapse: collapse; background: var(--blanc); border-radius: 10px; overflow: hidden; font-size: .95rem; }
.tableau th, .tableau td { text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--ligne); }
.tableau th { white-space: nowrap; color: var(--turquoise-fonce); }
.tableau thead th { color: var(--gris); font-size: .82rem; }
.defile { overflow-x: auto; }
.case { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.case input { width: 24px; height: 24px; flex: none; margin: 0; }
.case.inactive { color: var(--gris); }
.feuille.plein { max-width: none; height: 96vh; max-height: 96vh; }
.zoom { flex: 1; overflow: auto; background: #fff; border-radius: 12px; -webkit-overflow-scrolling: touch; }
.zoom img { width: 230%; max-width: none; display: block; }
@media (min-width: 900px) { .zoom img { width: 140%; } }
a.puce { color: inherit; text-decoration: none; }

/* ---------- Visite guidée ---------- */
.bouton.guidee { background: var(--ambre); border-color: var(--ambre); color: var(--marine); }
.guidee-note { border-color: var(--ambre); border-width: 1.5px; }
.guidee-note details { margin-top: 8px; }
.guidee-note summary { color: var(--turquoise-fonce); font-weight: 600; cursor: pointer; }
.petit-gauche { font-size: .85rem; margin: 4px 0 0; }
body.mode-guidee { overflow: hidden; }
.guidee-ecran {
  position: fixed; inset: 0; z-index: 50; background: #000; color: #fff;
  display: flex; flex-direction: column;
  padding: calc(8px + var(--haut)) 0 calc(12px + var(--bas));
}
.guidee-haut { display: flex; align-items: center; gap: 10px; padding: 4px 14px 10px; }
.guidee-haut .point-rouge { width: 14px; height: 14px; }
.guidee-chrono { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.guidee-nb { flex: 1; color: #c9d1dc; font-size: .9rem; }
.guidee-haut .bouton { min-height: 46px; }
.guidee-cadre { position: relative; flex: 1; min-height: 0; }
.guidee-cadre video { width: 100%; height: 100%; object-fit: cover; display: block; }
.guidee-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.guidee-flash.actif { animation: flash .35s ease-out; }
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }
.guidee-pieces { padding: 12px 14px 4px; margin: 0; }
.guidee-pieces .puce { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.guidee-pieces .puce.active { background: var(--turquoise); border-color: var(--turquoise); color: var(--marine); }
.guidee-pieces .puce.ajout { color: var(--turquoise); }
.guidee-bas { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 10px 18px 0; }
.guidee-annuler { color: #c9d1dc; justify-self: start; }
.declencheur {
  width: 82px; height: 82px; border-radius: 50%; border: 5px solid #fff; background: var(--turquoise);
  box-shadow: 0 0 0 3px rgba(255,255,255,.25); cursor: pointer;
}
.declencheur:active { transform: scale(.92); }
.guidee-vignette { justify-self: end; width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 2px solid #fff; }

/* ---------- Résumé client ---------- */
.bouton-resume { border-color: var(--turquoise); color: var(--turquoise-fonce); }
.etape { display: inline-block; background: var(--marine); color: #fff; font-weight: 700; padding: 6px 12px; border-radius: 99px; margin: 0; }
.resume-bloc h2 { margin-top: 24px; }
.resume-qui h3 { font-size: .95rem; text-transform: none; letter-spacing: 0; color: var(--marine); margin: 14px 0 6px; }
.tache { display: flex; gap: 12px; align-items: flex-start; background: var(--blanc); border: 1px solid var(--ligne); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.tache input { width: 26px; height: 26px; flex: none; margin: 0; accent-color: var(--turquoise-fonce); }
.tache small { color: var(--gris); }
.tache.faite span { text-decoration: line-through; color: var(--gris); }
.tache .urgent { color: #b42318; }
.resume-bloc.decisions ul { list-style: none; padding: 0; }
.resume-bloc.decisions li { background: var(--turquoise-clair); border-left: 4px solid var(--turquoise); border-radius: 0 10px 10px 0; padding: 8px 12px; margin-bottom: 6px; }
.resume-bloc.choix li { margin-bottom: 6px; }
.resume-bloc.choix ul { background: #fff4e0; border: 1px dashed var(--ambre); border-radius: 12px; padding: 10px 14px 10px 30px; }
