:root {
    --encre: #1d2433; --discret: #5d6577; --fond: #f4f5f9; --carte: #fff; --bord: #dfe2ea;
    --accent: #4b45b8; --accent-clair: #ecebfb; --ok: #1f7a4d; --ok-clair: #e3f4ea; --alerte: #a15a00; --alerte-clair: #fdf0d8;
    --danger: #b3261e; --danger-clair: #fbe9e7; --rayon: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--encre); background: var(--fond); line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; } h2 { font-size: 1.1rem; margin: 0 0 .75rem; } h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.haut { background: var(--carte); border-bottom: 1px solid var(--bord); }
.haut .barre { max-width: 1280px; margin: 0 auto; padding: .6rem 1.25rem; display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.haut .marque { font-weight: 600; color: var(--encre); text-decoration: none; margin-right: auto; }
.haut a.nav { text-decoration: none; color: var(--discret); } .haut a.nav:hover, .haut a.nav.actif { color: var(--accent); }
.haut form { margin: 0; }
main { max-width: 1280px; margin: 0 auto; padding: 1.25rem; }
.sous-titre { color: var(--discret); margin: 0 0 1.25rem; }
.carte { background: var(--carte); border: 1px solid var(--bord); border-radius: 12px; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.deux { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
@media (max-width: 1000px) { .deux { grid-template-columns: minmax(0, 1fr); } }
.sticky { position: sticky; top: 1rem; }
label { display: block; font-size: .85rem; color: var(--discret); margin: .7rem 0 .25rem; }
input, select, textarea { width: 100%; padding: .5rem .6rem; border: 1px solid var(--bord); border-radius: var(--rayon); font: inherit; background: #fff; color: var(--encre); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { resize: vertical; min-height: 4.2rem; }
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; } .grille3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; }
.ligne-check { display: flex; align-items: center; gap: .5rem; margin: .7rem 0 0; color: var(--encre); font-size: .95rem; }
.ligne-check input { margin: 0; }
button, .bouton { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .95rem; border-radius: var(--rayon); border: 1px solid var(--bord); background: #fff; color: var(--encre); font: inherit; cursor: pointer; text-decoration: none; }
button:hover, .bouton:hover { border-color: var(--accent); }
.primaire { background: var(--accent); border-color: var(--accent); color: #fff; } .primaire:hover { background: #3d379f; }
.discret { border-color: transparent; background: transparent; color: var(--discret); padding: .3rem .5rem; }
.danger { color: var(--danger); }
.actions { display: flex; justify-content: space-between; gap: .75rem; margin-top: 1.25rem; flex-wrap: wrap; }
.etapes { display: flex; gap: .5rem; margin: 0 0 1.25rem; padding: 0; list-style: none; flex-wrap: wrap; }
.etapes li { flex: 1; min-width: 150px; }
.etapes a, .etapes span { display: flex; align-items: center; gap: .55rem; padding: .55rem .8rem; border: 1px solid var(--bord); border-radius: var(--rayon); background: #fff; color: var(--discret); text-decoration: none; font-size: .92rem; }
.etapes .n { width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--fond); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 600; }
.etapes .en-cours { border-color: var(--accent); background: var(--accent-clair); color: var(--encre); } .etapes .en-cours .n { background: var(--accent); color: #fff; }
.etapes .fait .n { background: var(--ok-clair); color: var(--ok); }
.alerte { padding: .65rem .9rem; border-radius: var(--rayon); margin-bottom: 1rem; font-size: .93rem; }
.alerte.erreur { background: var(--danger-clair); color: var(--danger); border: 1px solid #f0c4be; } .alerte.succes { background: var(--ok-clair); color: var(--ok); border: 1px solid #bfe3cd; }
.alerte.info { background: var(--alerte-clair); color: var(--alerte); border: 1px solid #f0d9a8; }
.alerte ul { margin: 0; padding-left: 1.1rem; }
.erreur-champ { color: var(--danger); font-size: .82rem; margin-top: .2rem; }
table.liste { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.liste th { text-align: left; font-weight: 500; color: var(--discret); padding: .5rem .6rem; border-bottom: 1px solid var(--bord); }
table.liste td { padding: .6rem; border-bottom: 1px solid var(--bord); vertical-align: middle; } table.liste .d { text-align: right; white-space: nowrap; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 99px; font-size: .78rem; background: var(--alerte-clair); color: var(--alerte); } .badge.valide { background: var(--ok-clair); color: var(--ok); }
.ligne-service { border: 1px solid var(--bord); border-radius: 10px; padding: .75rem .9rem; margin-bottom: .75rem; background: #fcfcfe; }
.ligne-service .prix-ligne { font-weight: 600; text-align: right; padding-top: .2rem; }
.entete-ligne { display: flex; justify-content: space-between; align-items: center; }
.totaux { background: var(--fond); border-radius: var(--rayon); padding: .8rem 1rem; }
.totaux div { display: flex; justify-content: space-between; } .totaux .ttc { font-size: 1.2rem; font-weight: 600; margin-top: .2rem; }
.filtres { display: flex; gap: .6rem; margin-bottom: 1rem; flex-wrap: wrap; } .filtres input { max-width: 280px; } .filtres select { max-width: 180px; }
.onglets { display: flex; gap: .4rem; margin-bottom: .5rem; flex-wrap: wrap; } .onglets button { font-size: .85rem; padding: .3rem .75rem; } .onglets button.actif { background: var(--accent-clair); border-color: var(--accent); }
.doc { background: #fff; color: #222; border: 1px solid var(--bord); border-radius: 4px; padding: 1.1rem; font-size: .8rem; line-height: 1.5; min-height: 360px; max-height: 78vh; overflow: auto; }
.doc .m { color: #777; } .doc .petit { font-size: .7rem; } .doc .droite { margin: .8rem 0 .2rem 45%; } .doc p { margin: .5rem 0; }
.doc .var { background: #fff59d; padding: 0 2px; }
.doc table { width: 100%; border-collapse: collapse; margin-top: .5rem; } .doc td, .doc th { border: 1px solid #333; padding: 4px 6px; text-align: left; vertical-align: top; font-weight: 400; }
.doc th { font-style: italic; } .doc td.c { text-align: center; } .doc .total { text-align: right; }
.legende { font-size: .78rem; color: var(--discret); margin-top: .4rem; }
.legende .var { background: #fff59d; padding: 0 3px; }
iframe.pdf { width: 100%; height: 78vh; border: 1px solid var(--bord); border-radius: 8px; background: #fff; }
.connexion { max-width: 380px; margin: 8vh auto; }
.aide { font-size: .8rem; color: var(--discret); margin-top: .2rem; }
.vide { text-align: center; padding: 2.5rem 1rem; color: var(--discret); }
.pagination { display: flex; gap: .4rem; margin-top: 1rem; flex-wrap: wrap; } .pagination a, .pagination span { padding: .25rem .6rem; border: 1px solid var(--bord); border-radius: 6px; text-decoration: none; background: #fff; font-size: .85rem; }

textarea.code { font-family: ui-monospace, Consolas, 'Courier New', monospace; font-size: .82rem; line-height: 1.45; }
.sommaire { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 1rem; } .sommaire a { padding: .25rem .7rem; border: 1px solid var(--bord); border-radius: 99px; background: #fff; text-decoration: none; font-size: .85rem; } .sommaire a:hover { border-color: var(--accent); }
html { scroll-behavior: smooth; } form.carte, #historique { scroll-margin-top: 1rem; }

/* ---- Tableau de bord ---- */
.tdb { --serie-valide: #2a78d6; --serie-brouillon: #898781; --jauge-fond: #cde2fb; --grille: #e1e0d9; --axe: #c3c2b7; --encre-discrete: #52514e; --encre-muette: #898781; }
.tdb .serie-valide { background: var(--serie-valide); } .tdb .serie-brouillon { background: var(--serie-brouillon); }
.tdb-etiquette { font-size: .85rem; color: var(--encre-discrete); }
.tdb-hero { padding: 1.4rem 1.5rem; }
.tdb-hero-valeur { font-size: 3.4rem; line-height: 1.1; font-weight: 600; letter-spacing: -.02em; margin: .2rem 0 .3rem; }
.tdb-tuiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.tdb-tuile { background: var(--carte); border: 1px solid var(--bord); border-radius: 12px; padding: 1rem 1.15rem; }
.tdb-valeur { font-size: 2rem; line-height: 1.2; font-weight: 600; margin: .1rem 0; }
.tdb-jauge { height: 8px; border-radius: 4px; background: var(--jauge-fond); overflow: hidden; margin-top: .5rem; } .tdb-jauge span { display: block; height: 100%; background: var(--serie-valide); border-radius: 4px 0 0 4px; }
.tdb-legende { display: flex; gap: 1.1rem; font-size: .85rem; color: var(--encre-discrete); margin: .2rem 0 .8rem; }
.tdb-legende i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.tdb-legende .serie-valide { background: var(--serie-valide); } .tdb-legende .serie-brouillon { background: var(--serie-brouillon); }

/* Colonnes empilées */
.tdb-colonnes { position: relative; padding-left: 52px; margin-top: 1.6rem; }
.tdb-axe { position: absolute; left: 0; right: 0; top: 0; height: 220px; pointer-events: none; }
.tdb-trait { position: absolute; left: 52px; right: 0; border-top: 1px solid var(--grille); height: 0; }
.tdb-trait:first-child { border-top-color: var(--axe); }
.tdb-trait span { position: absolute; left: -52px; width: 46px; text-align: right; top: -.6em; font-size: .75rem; color: var(--encre-muette); font-variant-numeric: tabular-nums; }
.tdb-mois-liste { position: relative; display: flex; min-width: 0; }
.tdb-mois { flex: 1 1 0; min-width: 0; outline: none; border-radius: 6px; cursor: default; }
.tdb-mois:hover, .tdb-mois:focus-visible { background: rgba(75, 69, 184, .06); }
.tdb-mois:focus-visible, .tdb-barre:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.tdb-zone { height: 220px; display: flex; align-items: flex-end; justify-content: center; }
.tdb-pile { width: 100%; max-width: 24px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 2px; position: relative; }
.tdb-pile .seg { display: block; width: 100%; flex: none; }
.tdb-pile .seg.haut { border-radius: 4px 4px 0 0; }
.tdb-mois:hover .seg, .tdb-mois:focus-visible .seg { filter: brightness(1.1); }
.tdb-valeur-max { font-size: .75rem; font-weight: 600; white-space: nowrap; margin-bottom: 2px; color: var(--encre); }
.tdb-mois-nom { display: block; text-align: center; font-size: .72rem; color: var(--encre-muette); padding-top: .35rem; min-height: 2.2rem; line-height: 1.15; }
.tdb-mois-nom small { display: block; font-size: .68rem; }
@media (max-width: 700px) { .tdb-mois-nom { font-size: .72rem; white-space: nowrap; overflow: visible; } .tdb-mois:nth-child(even) .tdb-mois-nom { visibility: hidden; } .tdb-hero-valeur { font-size: 2.6rem; } }

/* Barres horizontales */
.tdb-barres { list-style: none; margin: 0 0 1rem; padding: 0; }
.tdb-barre { display: grid; grid-template-columns: minmax(7rem, 16rem) 1fr; align-items: center; gap: .75rem; padding: .3rem .4rem; border-radius: 6px; outline: none; }
.tdb-barre:hover, .tdb-barre:focus-visible { background: rgba(75, 69, 184, .06); }
.tdb-nom { font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tdb-piste { display: flex; align-items: center; min-height: 24px; border-left: 1px solid var(--axe); }
.tdb-remplissage { display: block; height: 18px; flex: none; border-radius: 0 4px 4px 0; }
.tdb-barre:hover .tdb-remplissage, .tdb-barre:focus-visible .tdb-remplissage { filter: brightness(1.1); }
.tdb-barre-valeur { margin-left: .5rem; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.tdb-tableau, .tdb-tableau-employes { margin-top: .8rem; } .tdb-tableau summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.tdb-tableau-employes tfoot th { border-top: 1px solid var(--bord); padding: .5rem .6rem; font-weight: 600; text-align: left; } .tdb-tableau-employes tfoot th.d { text-align: right; }

/* Info-bulle */
.tdb-infobulle { position: fixed; z-index: 50; pointer-events: none; background: #fff; border: 1px solid var(--bord); border-radius: 8px; padding: .55rem .7rem; box-shadow: 0 6px 20px rgba(11, 11, 11, .12); font-size: .82rem; min-width: 12rem; max-width: 20rem; }
.tdb-infobulle[hidden] { display: none; }
.ib-titre { font-weight: 600; margin-bottom: .3rem; }
.ib-ligne { display: flex; align-items: center; gap: .5rem; padding: .1rem 0; } .ib-libelle { color: #52514e; flex: 1; } .ib-ligne strong { font-variant-numeric: tabular-nums; }
.ib-cle { width: 14px; height: 0; border-top: 3px solid transparent; border-radius: 2px; flex: none; }
.ib-cle.serie-valide { border-top-color: #2a78d6; } .ib-cle.serie-brouillon { border-top-color: #898781; }

/* Menu d'export du tableau de bord */
.tdb-export { position: relative; margin-left: auto; } .tdb-export summary { list-style: none; cursor: pointer; } .tdb-export summary::-webkit-details-marker { display: none; }
.tdb-export[open] summary { border-color: var(--accent); }
.tdb-export-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 15rem; background: #fff; border: 1px solid var(--bord); border-radius: 8px; padding: .4rem; box-shadow: 0 6px 20px rgba(11, 11, 11, .12); }
.tdb-export-menu a { display: block; padding: .45rem .6rem; border-radius: 6px; color: var(--encre); text-decoration: none; } .tdb-export-menu a:hover, .tdb-export-menu a:focus-visible { background: var(--accent-clair); }
.tdb-export-menu .aide { margin: .3rem .6rem .2rem; }

.defilement-x { overflow-x: auto; max-width: 100%; }

/* ---- Gestion des services ---- */
.entete-page { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.entete-page .sous-titre { margin-bottom: 1rem; }
.bouton-ajout .icone { width: 18px; height: 18px; }
.tableau-carte { padding: .45rem 1rem; }
.services-tableau td { height: 3.4rem; }
.services-tableau .colonne-actions { width: 1%; }
.sr-seulement { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.sans-defilement { overflow: hidden; }
.fenetre-fond { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 1rem; background: rgba(20, 20, 35, .52); backdrop-filter: blur(2px); }
.fenetre { width: min(100%, 31rem); max-height: calc(100vh - 2rem); overflow: auto; background: var(--carte); border: 1px solid var(--bord); border-radius: 14px; padding: 1.25rem; box-shadow: 0 22px 65px rgba(22, 18, 51, .28); }
.fenetre-entete, .fenetre-entete > div { display: flex; align-items: center; gap: .7rem; }
.fenetre-entete { justify-content: space-between; margin-bottom: 1rem; }
.fenetre-entete h2 { margin: 0; }
.fenetre-puce { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 9px; color: var(--accent); background: var(--accent-clair); }
.fenetre-fermer { border: 0; padding: .15rem .5rem; background: transparent; color: var(--discret); font-size: 1.65rem; line-height: 1; }
.fenetre-actions { justify-content: flex-end; padding-top: .35rem; }
@media (max-width: 560px) { .bouton-ajout span { display: none; } .bouton-ajout { padding: .6rem; } }

/* ---- Composition professionnelle du devis ---- */
.etapes { display: grid; grid-template-columns: minmax(105px,.72fr) minmax(185px,1.35fr) minmax(150px,1.08fr) minmax(125px,.88fr) minmax(125px,.88fr) minmax(145px,1fr); overflow-x: auto; padding: .45rem; }
.etapes li { min-width: 0; }
.etapes a, .etapes span { height: 100%; padding: .48rem .58rem; font-size: clamp(.7rem, .9vw, .88rem); white-space: nowrap; }
.etapes .n { flex: 0 0 1.4rem; width: 1.4rem; height: 1.4rem; }
.ajout-en-ligne { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .65rem; align-items: end; margin: .75rem 0 1rem; }
.bloc-service-technique, .groupe-installation { padding: 1rem; margin: .8rem 0; border: 1px solid var(--bord); border-radius: 12px; background: #fcfcff; }
.bloc-service-technique h3, .groupe-installation h3 { margin: 0; color: var(--accent); }
.editeur-barre { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; padding: .4rem; border: 1px solid var(--bord); border-bottom: 0; border-radius: 9px 9px 0 0; background: #f4f4fa; }
.editeur-barre button { min-height: 32px; padding: .25rem .6rem; border-radius: 6px; }
.editeur-barre .separateur-outils { width: 1px; height: 24px; margin: 0 .12rem; background: var(--bord); }
.editeur-riche { min-height: 220px; padding: .85rem .95rem; border: 1px solid var(--bord); border-radius: 0 0 9px 9px; background: #fff; font-size: 1rem; line-height: 1.55; }
.editeur-riche p { margin: 0 0 .85rem; }
.editeur-riche ul, .editeur-riche ol { margin: .55rem 0 .85rem; padding-left: 1.7rem; }
.editeur-riche:focus { outline: 2px solid var(--accent); }
.editeur-riche:empty::before { content: attr(data-placeholder); color: #9295a6; }
.periodicite { margin-top: .55rem; }
.ligne-libelle { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, .25fr) auto; gap: .5rem; margin-bottom: .5rem; }
.entete-groupe-modifiable { display: grid; grid-template-columns: auto minmax(0,1fr) auto; margin-bottom: .7rem; }
.entete-groupe-modifiable .lettre-groupe { color: var(--accent); font-weight: 800; }
.entete-groupe-modifiable input { min-height: 38px; font-weight: 700; }
.separation-section { margin-top: 1.7rem; padding-top: 1.25rem; border-top: 1px solid var(--bord); }
.liste-zones { padding: 0; list-style: none; }
.liste-zones li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .45rem .2rem; border-bottom: 1px solid var(--bord); }
.liste-zones li span::before { content: "- "; color: var(--accent); font-weight: 800; }
.table-prix { overflow: hidden; margin: 1rem 0; border: 1px solid var(--bord); border-radius: 11px; }
.table-prix-entete, .table-prix-ligne { display: grid; grid-template-columns: minmax(220px, 2fr) minmax(140px, 1fr) 90px 120px; gap: .7rem; align-items: center; padding: .65rem .8rem; }
.table-prix-entete { color: var(--discret); background: #f4f4fa; font-size: .76rem; font-weight: 800; text-transform: uppercase; }
.table-prix-ligne { border-top: 1px solid var(--bord); }
.table-prix-ligne small { display: block; max-width: 38rem; margin-top: .18rem; color: var(--discret); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.totaux-devis { width: min(100%, 430px); margin: 1rem 0 1.4rem auto; }
.totaux-devis > div { display: grid; grid-template-columns: 1fr 95px 120px; align-items: center; gap: .6rem; padding: .5rem .7rem; border-bottom: 1px solid var(--bord); text-align: right; }
.totaux-devis .total-final { grid-template-columns: 1fr 120px; color: #fff; background: var(--accent); border-radius: 8px; font-size: 1.08rem; }
.champ-suffixe { display: flex; align-items: center; gap: .5rem; }.champ-suffixe input { max-width: 120px; }
.texte-fixe-formulaire { margin-top: .85rem; padding: .75rem .85rem; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; background: var(--accent-clair); }
.texte-fixe-formulaire span { display: block; color: var(--discret); font-size: .76rem; font-weight: 700; text-transform: uppercase; }
.texte-fixe-formulaire p { margin: .25rem 0 0; }
.actions-rubrique .bouton-enregistrer { margin-left: auto; }
.actions-rubrique button:last-child { margin-left: 0; }
@media(max-width:760px){.table-prix{overflow-x:auto}.table-prix-entete,.table-prix-ligne{min-width:680px}.ligne-libelle{grid-template-columns:1fr}.ajout-en-ligne{grid-template-columns:1fr}}
