/* App PRIMINOX — pensée téléphone d'abord. Charte de la vitrine priminox.fr (bleus #1E6EA6 / #3E97D1). */
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("/polices/Barlow-400.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 500; font-display: swap; src: url("/polices/Barlow-500.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("/polices/Barlow-600.woff2") format("woff2"); }
@font-face { font-family: "Barlow Semi Condensed"; font-weight: 700; font-display: swap; src: url("/polices/BarlowSemiCondensed-700.woff2") format("woff2"); }

:root {
  --bleu: #1E6EA6; --bleu-vif: #3E97D1; --bleu-pale: #EAF4FB; --sur-bleu: #FFFFFF;
  --fond: #F3F6F9; --carte: #FFFFFF; --carte-2: #F7F9FB; --trait: #DCE3E9;
  --encre: #1C242B; --encre-2: #55626D; --encre-3: #85919B;
  --ambre: #8A5300; --ambre-fond: #FFF3D6; --rouge: #B42318; --rouge-fond: #FDECEA;
  --vert: #2D6B30; --vert-fond: #E5F3E6; --violet: #5B3FA8; --violet-fond: #EFEAFB;
  --orange: #A6480F; --orange-fond: #FDEBDD; --ciel: #0E6680; --ciel-fond: #E1F3F8;
  --bulle-moi: #1E6EA6; --bulle-autre: #FFFFFF;
  --rayon: 14px; --nav-h: 56px; --entete-h: 52px;
  --ombre: 0 1px 2px rgba(20, 40, 60, .06);
  --police: "Barlow", -apple-system, system-ui, sans-serif;
  --police-titre: "Barlow Semi Condensed", "Barlow", -apple-system, system-ui, sans-serif;
  color-scheme: light;
}
:root[data-theme="sombre"] {
  --bleu: #4FA6DD; --bleu-vif: #6BB8E8; --bleu-pale: #13293A; --sur-bleu: #06131D;
  --fond: #0D1217; --carte: #161D24; --carte-2: #1B232B; --trait: #26313B;
  --encre: #E7EDF2; --encre-2: #A6B2BC; --encre-3: #75828D;
  --ambre: #F1C36A; --ambre-fond: #3A2C10; --rouge: #F49A90; --rouge-fond: #3B1A17;
  --vert: #8FD18F; --vert-fond: #173019; --violet: #C2B1F2; --violet-fond: #2A2342;
  --orange: #F3AE7E; --orange-fond: #3A2416; --ciel: #8AD3E8; --ciel-fond: #12303A;
  --bulle-moi: #2C7DB8; --bulle-autre: #1E272F;
  --ombre: none;
  color-scheme: dark;
}
:root[data-taille="petit"] { font-size: 15px; }
:root[data-taille="normal"] { font-size: 16px; }
:root[data-taille="grand"] { font-size: 18px; }
:root[data-taille="tres_grand"] { font-size: 20px; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--fond); }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--fond); color: var(--encre);
  font: 400 1rem/1.45 var(--police); overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--bleu); text-decoration: none; }
h1, h2, h3 { font-family: var(--police-titre); font-weight: 700; letter-spacing: .01em; margin: 0; }
.cache { display: none !important; }
.visuellement-cache { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg.ic { width: 1.35rem; height: 1.35rem; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
svg.ic.petite { width: 1rem; height: 1rem; }

/* --- Coquille : en-tête, contenu, onglets ------------------------------------------- */
.entete { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--fond) 88%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  padding: env(safe-area-inset-top) 12px 0; border-bottom: 1px solid transparent; }
.entete.defile { border-bottom-color: var(--trait); }
.entete-ligne { height: var(--entete-h); display: flex; align-items: center; gap: 8px; }
.entete h1 { font-size: 1.55rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entete .sous-titre { font-size: .82rem; color: var(--encre-2); margin: -10px 0 6px 2px; }
.bouton-icone { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 40px; height: 40px;
  border: 0; border-radius: 12px; background: transparent; color: var(--bleu); padding: 0 6px; }
.bouton-icone:active { background: var(--bleu-pale); }
.retour { font-size: 1rem; padding-left: 0; margin-left: -6px; }

main.contenu { padding: 8px 14px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); max-width: 720px; margin: 0 auto; }
body.avec-composeur main.contenu { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 96px); }
body.clavier main.contenu { padding-bottom: 110px; }

nav.onglets { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  background: color-mix(in srgb, var(--carte) 92%, transparent); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--trait); padding-bottom: env(safe-area-inset-bottom); }
body.clavier nav.onglets { display: none; }
.onglet { flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border: 0; background: none; color: var(--encre-3); font-size: .68rem; font-weight: 500; position: relative; }
.onglet svg.ic { width: 1.5rem; height: 1.5rem; }
.onglet.actif { color: var(--bleu); }
.onglet.bientot { opacity: .55; }
.pastille { position: absolute; top: 5px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #E5484D; color: #fff; font-size: .7rem; font-weight: 600; line-height: 18px; text-align: center; }

/* --- Blocs génériques ---------------------------------------------------------------- */
.section { margin: 18px 0 8px; display: flex; align-items: baseline; gap: 8px; }
.section h2 { font-size: 1.12rem; }
.section .compte { color: var(--encre-3); font-weight: 500; font-size: .9rem; }
.carte { background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre); }
.liste { display: flex; flex-direction: column; gap: 8px; }
.ligne { display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; text-align: left;
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon); box-shadow: var(--ombre); color: inherit; }
button.ligne:active, a.ligne:active { background: var(--carte-2); }
.ligne .corps { flex: 1; min-width: 0; }
.ligne .titre { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ligne .meta { color: var(--encre-2); font-size: .86rem; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 2px; }
.ligne .meta span { display: inline-flex; align-items: center; gap: 3px; }
.ligne .fin { color: var(--encre-3); }
.vide { text-align: center; color: var(--encre-2); padding: 22px 12px; background: var(--carte); border: 1px dashed var(--trait); border-radius: var(--rayon); }
.vide strong { display: block; color: var(--encre); margin-bottom: 2px; }
.erreur { color: var(--rouge); background: var(--rouge-fond); border-radius: var(--rayon); padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.erreur button { margin-left: auto; }
.chargement { color: var(--encre-3); padding: 28px 0; text-align: center; }
.resume { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 4px; }
.resume .carte { padding: 12px 14px; }
.resume .valeur { font-family: var(--police-titre); font-size: 1.5rem; font-weight: 700; color: var(--bleu); }
.resume .etiquette { font-size: .8rem; color: var(--encre-2); }

.bouton { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--trait); background: var(--carte); color: var(--encre); font-weight: 600; }
.bouton.principal { background: var(--bleu); border-color: var(--bleu); color: var(--sur-bleu); }
.bouton.danger { color: var(--rouge); }
.bouton.large { width: 100%; }
.bouton:active { transform: scale(.98); }
.bouton:disabled { opacity: .55; }

/* Étapes : mêmes teintes que dans Twenty */
.etape { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.etape-RDV { background: var(--ciel-fond); color: var(--ciel); }
.etape-VISITE { background: var(--bleu-pale); color: var(--bleu); }
.etape-DEVIS_SIGNE { background: var(--violet-fond); color: var(--violet); }
.etape-POSE { background: var(--orange-fond); color: var(--orange); }
.etape-DOSSIER_CEE { background: var(--ambre-fond); color: var(--ambre); }
.etape-PRIME_VERSEE { background: var(--vert-fond); color: var(--vert); }
.retard { color: var(--rouge); font-weight: 600; }
.alerte-ligne { background: var(--ambre-fond); border-color: color-mix(in srgb, var(--ambre) 25%, transparent); }
.alerte-ligne .titre, .alerte-ligne .meta { color: var(--ambre); }
.manque { margin: 4px 0 0; padding-left: 18px; color: var(--ambre); font-size: .86rem; }

/* --- Aujourd'hui ----------------------------------------------------------------------- */
.installer { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--bleu-pale);
  border-radius: var(--rayon); color: var(--encre); font-size: .9rem; margin-top: 6px; }
.installer .bouton-icone { margin: -8px -8px 0 auto; min-width: 32px; height: 32px; color: var(--encre-2); }
.message-court { display: flex; gap: 10px; align-items: flex-start; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--bleu-pale); color: var(--bleu); font-weight: 600; font-size: .85rem; }
.avatar.agent { background: var(--ambre-fond); color: var(--ambre); }
.avatar.whatsapp { background: var(--vert-fond); color: var(--vert); }
.texte-2l { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }

/* --- Chantiers ------------------------------------------------------------------------- */
.recherche { display: flex; align-items: center; gap: 8px; background: var(--carte); border: 1px solid var(--trait);
  border-radius: 12px; padding: 0 12px; height: 42px; color: var(--encre-3); }
.recherche input { border: 0; outline: 0; background: transparent; flex: 1; height: 100%; color: var(--encre); font-size: 1rem; }
.puces { display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px; margin: 0 -14px; scrollbar-width: none; scroll-snap-type: x proximity; }
.puces::-webkit-scrollbar { display: none; }
.puce { flex: none; scroll-snap-align: start; border: 1px solid var(--trait); background: var(--carte); color: var(--encre-2);
  border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: .86rem; display: inline-flex; gap: 6px; align-items: center; }
.puce b { color: var(--encre-3); font-weight: 600; }
.puce.active { background: var(--bleu); border-color: var(--bleu); color: var(--sur-bleu); }
.puce.active b { color: var(--sur-bleu); opacity: .8; }
.total { color: var(--encre-2); font-size: .86rem; margin: 0 2px 10px; }
.total strong { color: var(--encre); }

/* --- Fiche chantier --------------------------------------------------------------------- */
.frise { display: flex; gap: 4px; margin: 6px 0 6px; }
.frise span { flex: 1; height: 5px; border-radius: 3px; background: var(--trait); }
.frise span.fait { background: var(--bleu); }
.frise-legende { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; color: var(--encre-2); margin-bottom: 12px; }
.bloc { padding: 12px 14px; margin-bottom: 10px; }
.bloc h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-3); margin-bottom: 6px; font-family: var(--police); font-weight: 600; }
.bloc .gros { font-weight: 600; font-size: 1.05rem; }
.actions-contact { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.actions-contact .bouton { min-height: 38px; padding: 0 12px; font-size: .9rem; }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.grille-2 .bloc { margin: 0; }
.valeur-chiffre { font-family: var(--police-titre); font-weight: 700; font-size: 1.3rem; }
.vignettes { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.vignette { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--carte-2); border: 1px solid var(--trait);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--encre-2); font-size: .7rem; padding: 4px; text-align: center; }
.vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vignette.doc { word-break: break-all; }
.vignette.doc svg.ic { width: 1.8rem; height: 1.8rem; color: var(--bleu); }

/* --- Fils : commentaires et discussion ---------------------------------------------------- */
.fil { display: flex; flex-direction: column; gap: 6px; }
.jour { align-self: center; font-size: .75rem; color: var(--encre-3); background: var(--carte-2); border-radius: 999px; padding: 3px 10px; margin: 10px 0 4px; font-weight: 500; }
.bulle { max-width: 82%; padding: 8px 12px; border-radius: 18px; background: var(--bulle-autre); border: 1px solid var(--trait);
  align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--ombre); }
.bulle .qui { font-size: .74rem; color: var(--encre-3); margin-bottom: 1px; font-weight: 500; }
.bulle .quand { font-size: .7rem; color: var(--encre-3); margin-left: 8px; float: right; margin-top: 6px; }
.bulle.moi { align-self: flex-end; background: var(--bulle-moi); border-color: transparent; color: #fff; border-bottom-right-radius: 6px; }
.bulle.moi .quand, .bulle.moi .qui { color: rgba(255, 255, 255, .78); }
.bulle.autre { border-bottom-left-radius: 6px; }
.bulle.alerte { align-self: stretch; max-width: none; background: var(--ambre-fond); border-color: color-mix(in srgb, var(--ambre) 25%, transparent); color: var(--ambre); border-radius: 14px; }
.bulle.alerte .qui, .bulle.alerte .quand { color: var(--ambre); }
.bulle.alerte a { color: var(--ambre); font-weight: 600; text-decoration: underline; }
.bulle.whatsapp .qui { color: var(--vert); }
.vu { align-self: flex-end; font-size: .72rem; color: var(--encre-3); margin: -2px 4px 0; }
.plus-ancien { align-self: center; }

.composeur { position: fixed; left: 0; right: 0; z-index: 25; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 8px 12px; background: color-mix(in srgb, var(--fond) 92%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border-top: 1px solid var(--trait); }
body.clavier .composeur { bottom: 0; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.composeur form { display: flex; align-items: flex-end; gap: 8px; max-width: 720px; margin: 0 auto; }
.composeur textarea { flex: 1; resize: none; border: 1px solid var(--trait); background: var(--carte); border-radius: 20px;
  padding: 9px 14px; max-height: 140px; min-height: 40px; line-height: 1.35; outline: 0; font-size: 1rem; }
.composeur textarea:focus { border-color: var(--bleu-vif); }
.envoyer { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--bleu); color: var(--sur-bleu); display: flex; align-items: center; justify-content: center; flex: none; }
.envoyer:disabled { background: var(--trait); color: var(--encre-3); }

/* --- Réglages ------------------------------------------------------------------------------- */
.groupe { margin-bottom: 18px; }
.groupe h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-3); font-family: var(--police); font-weight: 600; margin: 0 4px 6px; }
.groupe .carte { overflow: hidden; }
.reglage { display: flex; align-items: center; gap: 12px; padding: 11px 14px; min-height: 50px; border-top: 1px solid var(--trait); }
.reglage:first-child { border-top: 0; }
.reglage .libelle { flex: 1; min-width: 0; }
.reglage .aide { display: block; font-size: .8rem; color: var(--encre-2); }
.reglage.colonne { flex-direction: column; align-items: stretch; }
.note-groupe { font-size: .8rem; color: var(--encre-2); margin: 6px 4px 0; }
.interrupteur { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: var(--trait);
  position: relative; flex: none; transition: background .2s; margin: 0; }
.interrupteur::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.interrupteur:checked { background: #34C759; }
.interrupteur:checked::after { transform: translateX(20px); }
.compteur { display: flex; align-items: center; gap: 0; border: 1px solid var(--trait); border-radius: 10px; overflow: hidden; flex: none; }
.compteur button { width: 36px; height: 34px; border: 0; background: var(--carte-2); color: var(--bleu); font-size: 1.2rem; font-weight: 600; }
.compteur output { min-width: 52px; text-align: center; font-weight: 600; font-size: .92rem; }
.segments { display: flex; background: var(--carte-2); border-radius: 10px; padding: 2px; gap: 2px; }
.segments button { flex: 1; border: 0; background: transparent; border-radius: 8px; padding: 7px 4px; font-size: .85rem; font-weight: 600; color: var(--encre-2); }
.segments button.actif { background: var(--carte); color: var(--encre); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
select.choix, input.champ { border: 1px solid var(--trait); background: var(--carte); border-radius: 10px; padding: 8px 10px; font-size: .95rem; max-width: 55%; }
input.champ.heure { max-width: 110px; }
input.champ.plein { max-width: none; width: 100%; }
.formulaire { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.message-etat { font-size: .85rem; }
.message-etat.ok { color: var(--vert); }
.message-etat.ko { color: var(--rouge); }

/* --- Connexion, toast, rafraîchissement ----------------------------------------------------------- */
.connexion { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 22px calc(24px + env(safe-area-inset-bottom)); max-width: 420px; margin: 0 auto; }
.connexion .logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 14px; display: block; }
.connexion h1 { text-align: center; font-size: 2rem; color: var(--bleu); letter-spacing: .08em; }
.connexion p { text-align: center; color: var(--encre-2); margin: 4px 0 24px; }
.connexion label { font-size: .85rem; color: var(--encre-2); font-weight: 500; margin: 10px 2px 4px; display: block; }
.connexion input { width: 100%; height: 48px; border-radius: 12px; border: 1px solid var(--trait); background: var(--carte); padding: 0 14px; font-size: 1.05rem; outline: 0; }
.connexion input:focus { border-color: var(--bleu-vif); }
.connexion .bouton { margin-top: 20px; min-height: 50px; font-size: 1.05rem; }
.connexion .erreur { margin-top: 14px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); z-index: 50;
  background: var(--encre); color: var(--fond); padding: 9px 16px; border-radius: 999px; font-size: .88rem; font-weight: 500; pointer-events: none;
  opacity: 0; transition: opacity .2s; }
.toast.visible { opacity: 1; }
.tirer { height: 0; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; color: var(--encre-3); font-size: .8rem; transition: height .15s; }
.pictogramme { width: 38px; height: 38px; flex: none; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; background: var(--carte-2); color: var(--encre-2); }
.pictogramme.dossier { color: var(--bleu); }
.pictogramme.pdf { color: var(--rouge); }
.pictogramme.image { color: var(--vert); }
.ariane { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--encre-3); font-size: .86rem; margin: 0 0 12px; }
.ariane a { color: var(--bleu); }
.ligne .titre.deux-lignes { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; }
.titre-dossier { font-size: 1.4rem; margin: 4px 0 4px; overflow-wrap: anywhere; }
.lien-drive { margin-top: 8px; }
.bientot-page { text-align: center; padding: 48px 18px; color: var(--encre-2); }
.bientot-page svg.ic { width: 3rem; height: 3rem; color: var(--bleu); margin-bottom: 10px; }
.bientot-page h2 { color: var(--encre); margin-bottom: 6px; }
@media (min-width: 760px) { .composeur, nav.onglets { padding-left: calc((100vw - 720px) / 2); padding-right: calc((100vw - 720px) / 2); } }
