/* Facturation — feuille de style unique (aucun style en ligne : politique de sécurité du contenu stricte).
   Identité : encre et jaune de signalisation (RAL 1003), titres et montants en caractères de type DIN,
   statuts en voyants. Polices du système uniquement (aucune police téléchargée). */
:root {
  --encre: #16233a;
  --encre-2: #24375a;
  --papier: #f3f5f8;
  --blanc: #ffffff;
  --trait: #d5dbe5;
  --trait-fort: #aeb7c6;
  --texte: #1b2430;
  --texte-2: #586274;
  --signal: #f2c200;
  --signal-fonce: #c99f00;
  --vert: #1f7a45;
  --ambre: #a86f00;
  --rouge: #b42318;
  --fond-vert: #e8f4ec;
  --fond-ambre: #fdf3dc;
  --fond-rouge: #fbeceb;
  --din: "Bahnschrift", "DIN Alternate", "DIN 2014", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --corps: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --rayon: 6px;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--papier); color: var(--texte); font-family: var(--corps); line-height: 1.5; }
a { color: var(--encre-2); text-underline-offset: 2px; }
a:hover { color: var(--encre); }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--din); color: var(--encre); font-weight: 600; letter-spacing: .01em; line-height: 1.2; }
h1 { font-size: 1.85rem; margin: 0 0 .25rem; }
h2 { font-size: 1.3rem; margin: 1.8rem 0 .7rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }
.chiffre, td.num, th.num, .montant { font-variant-numeric: tabular-nums; }
.lien-evitement { position: absolute; left: -9999px; }
.lien-evitement:focus { left: 1rem; top: 1rem; z-index: 10; background: var(--signal); color: var(--encre); padding: .5rem 1rem; }

/* ---------------------------------------------------------------- cadre */
.cadre { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.barre { background: var(--encre); color: #dfe6f1; padding: 1.2rem 0; display: flex; flex-direction: column; }
.marque { font-family: var(--din); font-size: 1.25rem; color: var(--blanc); padding: 0 1.2rem 1rem; text-decoration: none; display: block; }
.marque span { display: block; font-family: var(--corps); font-size: .78rem; color: #9fb0c8; margin-top: .15rem; }
.marque::after { content: ""; display: block; height: 3px; width: 36px; background: var(--signal); margin-top: .7rem; }
.nav { list-style: none; margin: .4rem 0; padding: 0; }
.nav a { display: block; padding: .5rem 1.2rem; color: #dfe6f1; text-decoration: none; border-left: 3px solid transparent; }
.nav a:hover { background: var(--encre-2); color: var(--blanc); }
.nav a[aria-current="page"] { border-left-color: var(--signal); background: var(--encre-2); color: var(--blanc); }
.nav-titre { color: #8193ad; font-size: .8rem; padding: 1rem 1.2rem .2rem; }
.barre-pied { margin-top: auto; padding: 1rem 1.2rem 0; font-size: .85rem; color: #9fb0c8; }
.barre-pied form { margin-top: .5rem; }
.barre-pied a { color: #dfe6f1; }
.bouton-lien { background: none; border: 0; padding: 0; color: #dfe6f1; text-decoration: underline; cursor: pointer; font: inherit; }
.principal { min-width: 0; }
.entete { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 2rem;
          background: var(--blanc); border-bottom: 1px solid var(--trait); font-size: .9rem; color: var(--texte-2); }
.entete strong { color: var(--texte); }
.contenu { padding: 1.6rem 2rem 3rem; max-width: 1240px; }
.bandeau-demo { background: var(--signal); color: var(--encre); padding: .35rem 2rem; font-size: .88rem; }
.menu-mobile { display: none; }

/* ---------------------------------------------------------------- titres de page */
.titre-page { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.titre-page p { margin: .2rem 0 0; color: var(--texte-2); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- boutons */
.bouton { display: inline-flex; align-items: center; gap: .4rem; font: inherit; font-weight: 600; padding: .5rem .95rem;
          border-radius: var(--rayon); border: 1px solid var(--trait-fort); background: var(--blanc); color: var(--encre);
          text-decoration: none; cursor: pointer; line-height: 1.2; }
.bouton:hover { border-color: var(--encre-2); color: var(--encre); }
.bouton-principal { background: var(--encre); border-color: var(--encre); color: var(--blanc); }
.bouton-principal:hover { background: var(--encre-2); color: var(--blanc); }
.bouton-signal { background: var(--signal); border-color: var(--signal-fonce); color: var(--encre); }
.bouton-signal:hover { background: #ffd21f; color: var(--encre); }
.bouton-danger { color: var(--rouge); border-color: #e4b4ae; }
.bouton-danger:hover { border-color: var(--rouge); color: var(--rouge); }
.bouton-petit { padding: .3rem .6rem; font-size: .88rem; font-weight: 500; }
.bouton[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- messages */
.messages { list-style: none; padding: 0; margin: 0 0 1.2rem; }
.messages li { padding: .65rem 1rem; border-radius: var(--rayon); margin-bottom: .5rem; border: 1px solid; }
.messages .success { background: var(--fond-vert); border-color: #a9d6b8; color: #14532d; }
.messages .error { background: var(--fond-rouge); border-color: #efb5af; color: #7a1a12; }
.messages .info, .messages .warning { background: var(--fond-ambre); border-color: #ecd08e; color: #5c3d00; }

/* ---------------------------------------------------------------- surfaces */
.surface { background: var(--blanc); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 1.2rem 1.4rem; }
.surface + .surface { margin-top: 1.2rem; }
.grille-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; }
.grille-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; }

/* tableau de bord : relevé de compteurs */
.compteurs { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--trait); border-radius: var(--rayon);
             background: var(--blanc); margin-bottom: 1.6rem; }
.compteur { padding: 1rem 1.2rem; border-left: 1px solid var(--trait); text-decoration: none; color: inherit; }
.compteur:first-child { border-left: 0; }
.compteur .valeur { font-family: var(--din); font-size: 1.9rem; color: var(--encre); font-variant-numeric: tabular-nums; display: block; }
.compteur .libelle { color: var(--texte-2); font-size: .9rem; }
a.compteur:hover .valeur { text-decoration: underline; text-decoration-color: var(--signal); text-decoration-thickness: 3px; }

/* ---------------------------------------------------------------- tableaux */
.tableau { width: 100%; border-collapse: collapse; background: var(--blanc); }
.tableau th { text-align: left; font-weight: 600; color: var(--texte-2); font-size: .85rem; padding: .55rem .7rem;
              border-bottom: 2px solid var(--trait-fort); white-space: nowrap; }
.tableau td { padding: .55rem .7rem; border-bottom: 1px solid var(--trait); vertical-align: top; }
.tableau tbody tr:hover { background: #f8f9fb; }
.tableau .num { text-align: right; white-space: nowrap; }
.tableau .vide { text-align: center; color: var(--texte-2); padding: 2rem; }
.tableau-cadre { border: 1px solid var(--trait); border-radius: var(--rayon); overflow-x: auto; background: var(--blanc); }
.tableau-cadre .tableau { border: 0; }
.secondaire { color: var(--texte-2); font-size: .88rem; }

/* voyants de statut */
.voyant { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; white-space: nowrap; }
.voyant::before { content: ""; width: .62rem; height: .62rem; border-radius: 50%; background: var(--trait-fort); box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.voyant-brouillon::before { background: var(--blanc); box-shadow: inset 0 0 0 2px var(--trait-fort); }
.voyant-emise::before { background: var(--vert); }
.voyant-annulee::before { background: var(--rouge); }
.voyant-a_qualifier::before { background: var(--ambre); }
.voyant-retard::before { background: var(--rouge); }
.voyant-solde::before { background: var(--vert); }
.voyant-partiel::before { background: var(--ambre); }
.voyant-du::before { background: var(--blanc); box-shadow: inset 0 0 0 2px var(--ambre); }
.champ-affectation { width: 7.5rem; text-align: right; font-variant-numeric: tabular-nums; }
.tranches { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--blanc); margin: 1rem 0 1.4rem; }
.tranches > div { padding: .9rem 1.1rem; border-left: 1px solid var(--trait); }
.tranches > div:first-child { border-left: 0; }
.tranches .valeur { font-family: var(--din); font-size: 1.5rem; color: var(--encre); display: block; font-variant-numeric: tabular-nums; }
.tranches .critique .valeur { color: var(--rouge); }
@media (max-width: 760px) { .tranches { grid-template-columns: 1fr 1fr; } .tranches > div:nth-child(3) { border-left: 0; } .tranches > div:nth-child(n+3) { border-top: 1px solid var(--trait); } }

/* ---------------------------------------------------------------- formulaires */
.filtres { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filtres input[type="search"] { min-width: 18rem; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"],
input[type="date"], select, textarea {
  font: inherit; width: 100%; padding: .48rem .6rem; border: 1px solid var(--trait-fort); border-radius: var(--rayon);
  background: var(--blanc); color: var(--texte); }
textarea { min-height: 4.5rem; }
input:focus, select:focus, textarea:focus { border-color: var(--encre-2); outline: 3px solid rgba(242, 194, 0, .55); outline-offset: 0; }
.champ { margin-bottom: 1rem; }
.champ .aide { color: var(--texte-2); font-size: .84rem; margin-top: .2rem; }
.champ .erreur, .erreurs-form { color: var(--rouge); font-size: .88rem; margin-top: .25rem; }
.erreurs-form { background: var(--fond-rouge); border: 1px solid #efb5af; padding: .6rem .9rem; border-radius: var(--rayon); margin-bottom: 1rem; }
.champ-invalide input, .champ-invalide select, .champ-invalide textarea { border-color: var(--rouge); }
.champs { display: grid; grid-template-columns: repeat(12, 1fr); gap: 0 1rem; }
.l-12 { grid-column: span 12; } .l-8 { grid-column: span 8; } .l-6 { grid-column: span 6; } .l-4 { grid-column: span 4; }
.l-3 { grid-column: span 3; } .l-2 { grid-column: span 2; }
.case { display: flex; gap: .5rem; align-items: center; font-weight: 500; }
.case input { width: auto; }
fieldset { border: 0; padding: 0; margin: 0 0 .5rem; }
legend { font-family: var(--din); font-size: 1.05rem; color: var(--encre); margin-bottom: .6rem; padding: 0; }
.radio-liste { list-style: none; padding: 0; margin: 0; }
.radio-liste label { font-weight: 500; display: flex; gap: .5rem; align-items: center; padding: .6rem .8rem; border: 1px solid var(--trait);
                     border-radius: var(--rayon); margin-bottom: .5rem; background: var(--blanc); }
.pied-form { display: flex; gap: .6rem; justify-content: flex-end; align-items: center; border-top: 1px solid var(--trait);
             padding-top: 1rem; margin-top: .5rem; }

/* ---------------------------------------------------------------- connexion */
.page-seule { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: var(--encre); }
.boite-connexion { width: 100%; max-width: 410px; background: var(--blanc); border-radius: var(--rayon); padding: 2rem 2rem 1.6rem;
                   border-top: 6px solid var(--signal); }
.boite-connexion h1 { font-size: 1.6rem; }
.boite-connexion .sous-titre { color: var(--texte-2); margin: 0 0 1.4rem; }
.boite-connexion .bouton { width: 100%; justify-content: center; padding: .65rem; margin-top: .4rem; }
.qr { display: block; margin: .5rem auto 1rem; width: 210px; height: 210px; border: 1px solid var(--trait); }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; letter-spacing: .06em; background: var(--papier);
          padding: .5rem .7rem; border-radius: var(--rayon); text-align: center; word-break: keep-all; word-spacing: .3em; }
.etapes { color: var(--texte-2); font-size: .9rem; padding-left: 1.2rem; }

/* ---------------------------------------------------------------- pièce : édition */
.lignes td { padding: .35rem .3rem; }
.lignes th { padding: .45rem .3rem; }
.lignes input, .lignes select { padding: .35rem .4rem; font-size: .92rem; }
.lignes .c-type { width: 7.5rem; } .lignes .c-designation { min-width: 16rem; } .lignes .c-qte { width: 5.5rem; }
.lignes .c-designation select { margin-bottom: .3rem; }
.lignes tr:not(.ligne-article) .champ-article { display: none; }
.lignes .c-unite { width: 7rem; } .lignes .c-pu { width: 7.5rem; } .lignes .c-remise { width: 5rem; }
.lignes .c-tva { width: 9rem; } .lignes .c-nature { width: 6.5rem; } .lignes .c-montant { width: 7rem; }
.lignes .c-outils { width: 5.5rem; white-space: nowrap; }
.lignes tr.ligne-texte .seul-chiffre { visibility: hidden; }
.lignes input[type="number"] { text-align: right; }
.lignes .montant-ligne { text-align: right; padding-top: .65rem; }
.outil { background: none; border: 1px solid transparent; border-radius: 4px; cursor: pointer; padding: .15rem .35rem; color: var(--texte-2); font: inherit; }
.outil:hover { border-color: var(--trait-fort); color: var(--encre); }
.ligne-erreur td { background: var(--fond-rouge); }

/* récapitulatif des montants : le bloc qui se lit en premier sur une pièce */
.bas-piece { display: grid; grid-template-columns: 1fr 360px; gap: 1.5rem; align-items: start; margin-top: 1.2rem; }
.totaux { border: 2px solid var(--encre); border-radius: var(--rayon); background: var(--blanc); }
.totaux table { width: 100%; border-collapse: collapse; }
.totaux td { padding: .45rem 1rem; font-variant-numeric: tabular-nums; }
.totaux td.num { text-align: right; }
.totaux tr.tva td { color: var(--texte-2); font-size: .9rem; padding-top: .15rem; padding-bottom: .15rem; }
.totaux tr.net td { background: var(--encre); color: var(--blanc); font-family: var(--din); font-size: 1.35rem; padding: .7rem 1rem; }
.totaux tr.net td.num { color: var(--signal); }
.totaux .note { padding: .5rem 1rem .7rem; color: var(--texte-2); font-size: .85rem; }
.meta-piece { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem 1.4rem; margin: 0; }
.meta-piece dt { color: var(--texte-2); font-size: .85rem; }
.meta-piece dd { margin: 0; font-weight: 600; }
.empreinte { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; color: var(--texte-2); word-break: break-all; }
.confirmation { border-left: 6px solid var(--signal); }

/* ---------------------------------------------------------------- pagination */
.pagination { display: flex; gap: .4rem; align-items: center; margin-top: 1rem; color: var(--texte-2); font-size: .9rem; }

.etroit-seul { display: none; }

/* ---------------------------------------------------------------- écrans étroits */
@media (max-width: 900px) {
  .cadre { grid-template-columns: 1fr; }
  .barre { display: none; }
  .menu-mobile { display: block; background: var(--encre); color: var(--blanc); }
  .menu-mobile summary { padding: .8rem 1rem; cursor: pointer; font-family: var(--din); font-size: 1.1rem; }
  .menu-mobile .nav a { padding: .6rem 1rem; }
  .menu-mobile form { padding: .6rem 1rem 1rem; }
  .contenu { padding: 1rem; }
  .entete { padding: .6rem 1rem; flex-wrap: wrap; }
  .compteurs { grid-template-columns: 1fr 1fr; }
  .compteur:nth-child(3) { border-left: 0; }
  .compteur:nth-child(n+3) { border-top: 1px solid var(--trait); }
  .grille-2, .grille-3, .bas-piece { grid-template-columns: 1fr; }
  .champs > * { grid-column: span 12; }
  .meta-piece { grid-template-columns: 1fr 1fr; }
  .filtres input[type="search"] { min-width: 0; width: 100%; }
  .etroit-masque { display: none; }
  .etroit-seul { display: block; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.alerte { background: var(--fond-ambre); border: 1px solid #ecd08e; color: #5c3d00; padding: .55rem .85rem; border-radius: var(--rayon); }
details.surface > summary { cursor: pointer; font-family: var(--din); color: var(--encre); font-size: 1.05rem; }
details.surface[open] > summary { margin-bottom: 1rem; }
.lignes tr.ligne-supprimee td { opacity: .45; text-decoration: line-through; }
.lignes .c-outils .case { display: inline-flex; font-weight: 400; margin: 0; cursor: pointer; }
.liste-simple { margin: .6rem 0 0; padding-left: 1.1rem; }
.liste-simple li { margin: .2rem 0; }
.chronologie { list-style: none; margin: .6rem 0 0; padding: 0; border-left: 2px solid var(--trait); }
.chronologie li { padding: .15rem 0 .35rem .9rem; position: relative; }
.chronologie li::before { content: ""; position: absolute; left: -.4rem; top: .55rem; width: .62rem; height: .62rem; border-radius: 50%; background: var(--encre); }
.onglets { display: flex; gap: .3rem; border-bottom: 1px solid var(--trait); margin: 1rem 0; }
.onglets a { padding: .5rem .9rem; text-decoration: none; color: var(--texte-2); border-bottom: 3px solid transparent; }
.onglets a[aria-current="page"] { color: var(--encre); border-bottom-color: var(--signal); font-weight: 600; }
.compteurs-3 { grid-template-columns: repeat(3, 1fr); margin-top: 1rem; }
.compteur-alerte .valeur { color: var(--rouge); }
@media (max-width: 760px) { .compteurs-3 { grid-template-columns: 1fr; } .compteurs-3 .compteur { border-left: 0; border-top: 1px solid var(--trait); } .compteurs-3 .compteur:first-child { border-top: 0; } }
