@font-face { font-family: "Barlow"; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Barlow Semi Condensed"; src: url("../fonts/barlow-semi-condensed-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow Semi Condensed"; src: url("../fonts/barlow-semi-condensed-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --bleu: #1f3a68;
  --bleu-fonce: #142847;
  --bleu-pale: #e7edf6;
  --platre: #f2f4f6;
  --blanc: #ffffff;
  --encre: #17202e;
  --gris: #586273;
  --trait: #d3d9e1;
  --orange: #c9420c;
  --orange-pale: #fdeee5;
  --vert: #2b7349;
  --vert-pale: #e4f2e9;
  --rouge: #b42318;
  --rayon: 10px;
  --titre: "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --texte: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--platre);
  color: var(--encre);
  font: 400 17px/1.45 var(--texte);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--bleu); }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-family: var(--titre); font-weight: 700; line-height: 1.12; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
p { margin: 0 0 10px; }
:focus-visible { outline: 3px solid #f2b705; outline-offset: 2px; }
.cache { display: none !important; }
.discret { color: var(--gris); }
.petit { font-size: 14px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; word-break: break-all; }

/* ---------- barre du haut ---------- */
.barre {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bleu); color: var(--blanc);
}
.marque { display: flex; align-items: center; gap: 10px; color: var(--blanc); text-decoration: none; font: 700 21px var(--titre); letter-spacing: 0.01em; }
.marque svg { width: 26px; height: 26px; flex: none; }
.synchro {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid rgba(255,255,255,0.35); background: transparent; color: var(--blanc);
  border-radius: 999px; padding: 6px 12px; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.synchro .point { width: 9px; height: 9px; border-radius: 50%; background: #7fd49b; }
.synchro.hors .point { background: #b8c2d0; }
.synchro.attente .point { background: #f2b705; }
.synchro.erreur { border-color: #ffb48a; }
.synchro.erreur .point { background: #ff7a3d; }
.synchro.envoi .point { animation: pulse 1s infinite alternate; background: #f2b705; }
@keyframes pulse { to { opacity: 0.3; } }

/* ---------- navigation basse ---------- */
.nav-bas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--blanc); border-top: 1px solid var(--trait);
}
.nav-bas a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--gris); font-size: 13px; font-weight: 600;
}
.nav-bas a svg { width: 24px; height: 24px; }
.nav-bas a.actif { color: var(--bleu); }
.nav-bas a.actif svg { stroke-width: 2.4; }

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

/* ---------- boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--rayon);
  border: 1.5px solid var(--bleu); background: var(--blanc); color: var(--bleu);
  font-weight: 700; font-size: 16px; text-decoration: none; cursor: pointer;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.primaire { background: var(--bleu); color: var(--blanc); }
.btn.primaire:active { background: var(--bleu-fonce); }
.btn.alerte { border-color: var(--orange); color: var(--orange); }
.btn.danger { border-color: var(--rouge); color: var(--rouge); background: var(--blanc); }
.btn.lien { border: 0; background: none; padding: 0 4px; min-height: 40px; text-decoration: underline; }
.btn.plein { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.rangee { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- formulaires ---------- */
label { display: block; font-weight: 600; font-size: 15px; margin: 14px 0 0; }
label .aide { display: block; font-weight: 400; color: var(--gris); font-size: 13px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  display: block; width: 100%; margin-top: 6px; min-height: 48px; padding: 10px 12px;
  border: 1.5px solid var(--trait); border-radius: var(--rayon); background: var(--blanc);
}
textarea { min-height: 84px; resize: vertical; }
.mdp-zone { position: relative; display: block; }
.mdp-zone input { padding-right: 52px !important; }
.mdp-oeil { position: absolute; right: 2px; bottom: 2px; width: 46px; height: 44px; display: flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--gris); cursor: pointer; border-radius: var(--rayon); }
.mdp-oeil svg { width: 22px; height: 22px; }
.mdp-oeil:focus-visible { outline: 2px solid var(--bleu); outline-offset: -2px; }
input:focus, select:focus, textarea:focus { border-color: var(--bleu); outline: none; box-shadow: 0 0 0 3px var(--bleu-pale); }
.choix { display: flex; gap: 12px; align-items: flex-start; padding: 14px; margin-top: 10px; border: 1.5px solid var(--trait); border-radius: var(--rayon); background: var(--blanc); font-weight: 400; cursor: pointer; }
.choix input { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--bleu); }
.choix:has(input:checked) { border-color: var(--bleu); background: var(--bleu-pale); }
.choix:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
.choix strong { display: block; }
fieldset { border: 0; padding: 0; margin: 0; }

/* ---------- blocs ---------- */
.panneau { background: var(--blanc); border: 1px solid var(--trait); border-radius: 14px; padding: 18px; margin: 14px 0; }
.panneau > h2:first-child, .panneau > h3:first-child { margin-bottom: 8px; }
.entete-page { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.quota { margin: 6px 0 14px; font-size: 15px; color: var(--gris); }
.jauge { height: 6px; border-radius: 3px; background: var(--trait); overflow: hidden; margin-top: 6px; max-width: 280px; }
.jauge span { display: block; height: 100%; background: var(--bleu); }
.jauge.pleine span { background: var(--orange); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.badge-cours { background: var(--bleu-pale); color: var(--bleu); }
.badge-alerte { background: var(--orange-pale); color: var(--orange); }
.badge-ok { background: var(--vert-pale); color: var(--vert); }
.badge-attente { background: #fff5d6; color: #7a5a00; }

/* liste des chantiers */
.liste { display: grid; gap: 10px; }
.carte-chantier {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 16px; background: var(--blanc); border: 1px solid var(--trait); border-left: 5px solid var(--bleu);
  border-radius: 12px; text-decoration: none; color: inherit;
}
.carte-chantier.receptionne { border-left-color: var(--orange); }
.carte-chantier.clos { border-left-color: var(--vert); }
.carte-chantier h3 { font-size: 20px; }
.carte-chantier .adresse { grid-column: 1 / -1; color: var(--gris); font-size: 15px; }
.carte-chantier .compteurs { grid-column: 1 / -1; display: flex; gap: 14px; font-size: 14px; color: var(--gris); }
.carte-chantier .compteurs .ouvertes { color: var(--orange); font-weight: 700; }
.vide { text-align: left; padding: 26px 20px; background: var(--blanc); border: 1.5px dashed var(--trait); border-radius: 14px; }
.vide h2 { margin-bottom: 8px; }

/* fiche chantier */
.fiche-tete h1 { font-size: 28px; }
.fiche-tete .adresse { color: var(--gris); margin: 4px 0 8px; }
.onglets { display: flex; gap: 4px; margin: 16px -16px 0; padding: 0 16px; overflow-x: auto; border-bottom: 1px solid var(--trait); position: sticky; top: 58px; background: var(--platre); z-index: 10; }
.onglets a { flex: none; padding: 12px 14px; text-decoration: none; color: var(--gris); font-weight: 700; border-bottom: 3px solid transparent; }
.onglets a.actif { color: var(--bleu); border-bottom-color: var(--bleu); }
.onglets .nb { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; background: var(--trait); color: var(--encre); font-size: 12px; text-align: center; }
.onglets .nb.alerte { background: var(--orange); color: var(--blanc); }

.groupe-photos h3 { margin: 18px 0 8px; display: flex; justify-content: space-between; align-items: baseline; }
.grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.tuile { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #dde3ea; border: 0; padding: 0; cursor: pointer; }
.tuile img { width: 100%; height: 100%; object-fit: cover; }
.tuile .etat { position: absolute; left: 5px; bottom: 5px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--blanc); box-shadow: 0 0 0 2px rgba(0,0,0,0.08); }
.tuile .etat svg { width: 14px; height: 14px; }
.tuile .etat.ok { color: var(--vert); }
.tuile .etat.attente { color: #9a7300; }
.tuile .etat.erreur { color: var(--rouge); }

/* barre de prise de vue */
.prise-vue {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 15;
  padding: 10px 16px; background: rgba(242, 244, 246, 0.96); border-top: 1px solid var(--trait);
  backdrop-filter: blur(6px);
}
.prise-vue .interieur { max-width: 728px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.prise-vue select { margin: 0; }
.bouton-photo {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 60px; padding: 0 22px; border-radius: 30px;
  background: var(--bleu); color: var(--blanc); font: 700 18px var(--titre); letter-spacing: 0.01em;
  cursor: pointer; box-shadow: 0 6px 18px rgba(31, 58, 104, 0.35);
}
.bouton-photo svg { width: 26px; height: 26px; }
.bouton-photo input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.avec-prise-vue { padding-bottom: 110px; }

/* réserves */
.reserve { display: grid; grid-template-columns: 44px 1fr; gap: 4px 12px; padding: 14px 0; border-top: 1px solid var(--trait); }
.reserve:first-of-type { border-top: 0; }
.reserve .num { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 700 18px var(--titre); background: var(--orange-pale); color: var(--orange); }
.reserve.levee .num { background: var(--vert-pale); color: var(--vert); }
.reserve .desc { font-weight: 600; }
.reserve .meta { font-size: 14px; color: var(--gris); }
.reserve .actions { grid-column: 2; margin-top: 6px; }

/* PV */
.carte-pv { border-left: 5px solid var(--vert); }
.ligne-preuve { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; font-size: 15px; }
.ligne-preuve svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.ligne-preuve.ok svg { color: var(--vert); }
.ligne-preuve.attente svg { color: #9a7300; }
.verif-liste { list-style: none; padding: 0; margin: 10px 0; }
.verif-liste li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.verif-liste li svg { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.verif-liste li.ok svg { color: var(--vert); }
.verif-liste li.manque svg { color: var(--orange); }

.zone-signature { position: relative; margin-top: 8px; }
.zone-signature canvas { display: block; width: 100%; height: 180px; background: var(--blanc); border: 1.5px dashed #9aa6b6; border-radius: var(--rayon); touch-action: none; }
.zone-signature .ligne-base { position: absolute; left: 18px; right: 18px; bottom: 44px; border-bottom: 1px solid #c4ccd6; pointer-events: none; }
.zone-signature .indication { position: absolute; left: 18px; bottom: 18px; font-size: 13px; color: #8c97a6; pointer-events: none; }
.zone-signature button { position: absolute; top: 8px; right: 8px; min-height: 36px; padding: 0 12px; font-size: 14px; }

.recap dt { color: var(--gris); font-size: 14px; margin-top: 8px; }
.recap dd { margin: 0; font-weight: 600; }

/* journal */
.journal { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.journal li { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--trait); }
.journal time { color: var(--gris); }

/* fenêtre photo */
dialog { border: 0; padding: 0; border-radius: 14px; max-width: min(720px, 96vw); width: 100%; max-height: 92vh; }
dialog::backdrop { background: rgba(10, 20, 35, 0.75); }
dialog .contenu { padding: 16px; overflow: auto; max-height: 92vh; }
dialog img { width: 100%; max-height: 60vh; object-fit: contain; background: #0f1a2b; border-radius: 8px; }
dialog .fermer { float: right; }

/* tarifs */
.tarifs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tarif { padding: 14px; border: 1.5px solid var(--trait); border-radius: 12px; background: var(--blanc); }
.tarif.actuel { border-color: var(--bleu); background: var(--bleu-pale); }
.tarif .prix { font: 700 22px var(--titre); margin: 4px 0; }

/* connexion */
.accueil { max-width: 440px; margin: 6vh auto 0; }
.accueil .promesse { font: 700 34px/1.08 var(--titre); margin: 14px 0 10px; }
.accueil .sous { color: var(--gris); margin-bottom: 18px; }
.bascule { display: grid; grid-template-columns: 1fr 1fr; background: var(--trait); border-radius: var(--rayon); padding: 3px; }
.bascule button { border: 0; background: none; min-height: 42px; border-radius: 8px; font-weight: 700; cursor: pointer; color: var(--gris); }
.bascule button.actif { background: var(--blanc); color: var(--bleu); }

.alerte-boite { padding: 12px 14px; border-radius: var(--rayon); background: var(--orange-pale); color: #7a2a06; margin: 12px 0; font-size: 15px; }
.info-boite { padding: 12px 14px; border-radius: var(--rayon); background: var(--bleu-pale); color: var(--bleu-fonce); margin: 12px 0; font-size: 15px; }
.ok-boite { padding: 12px 14px; border-radius: var(--rayon); background: var(--vert-pale); color: #1d4d31; margin: 12px 0; font-size: 15px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 12px;
  background: var(--encre); color: var(--blanc); font-weight: 600; font-size: 15px;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast-erreur { background: var(--rouge); }
.toast-ok { background: var(--vert); }

.chargement { padding: 40px 0; color: var(--gris); text-align: center; }

@media (min-width: 900px) {
  h1 { font-size: 36px; }
  main { padding-top: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* import de devis */
.import-devis { border-style: dashed; border-width: 1.5px; border-color: #9aa6b6; }
.import-devis .rangee { margin-top: 10px; }
input.pre-rempli, textarea.pre-rempli { border-color: var(--bleu); background: #f4f7fd; }
.accueil .slogan { margin: 0; font: 700 15px var(--titre); color: var(--bleu); letter-spacing: 0.02em; }
