/* app.css — interface admin CDGN (lot L3). Charte : fond noir, or #C8A34E, Archivo + IBM Plex Sans. */
@font-face { font-family: "Archivo"; src: url("assets/fonts/Archivo.woff2") format("woff2"); font-weight: 500 900; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("assets/fonts/IBMPlexSans.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }

:root {
  --noir: #0A0A0B;
  --s1: #131315;
  --s2: #111113;
  --s3: #1B1B1E;
  --s4: #232327;
  --trait: #2A2A2E;
  --trait2: #3A3A40;
  --txt: #F2EFE8;
  --txt2: #B9B5AB;
  --txt3: #8E8B84;
  --or: #C8A34E;
  --or-vif: #DDB95F;
  --or-fond: rgba(200, 163, 78, .12);
  --or-fond2: rgba(200, 163, 78, .22);
  --ok: #7FBF93;
  --alerte: #E58B4F;
  --err: #E8675C;
  --supp: #7FB2C9;
  --titre: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --corps: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --cible: 44px;
  --hc: 44px;        /* hauteur d'une cellule de tableau éditable */
  --code-w: 104px;
  --vis-w: 900px;    /* largeur visible du tableau, mise à jour par JS */
  color-scheme: dark;
}
@media (pointer: fine) { :root { --hc: 40px; } }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--noir); color: var(--txt); font: 400 15px/1.45 var(--corps);
  display: flex; flex-direction: column; overflow: hidden;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { font-family: var(--titre); font-weight: 700; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; line-height: 1.15; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0; }
a { color: var(--or); }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--txt2); }
.faible { color: var(--txt3); }
.droite { text-align: right; }
.cache { display: none !important; }
:focus-visible { outline: 2px solid var(--or); outline-offset: 1px; }

/* ---------- Barre du haut ---------- */
.haut {
  flex: none; display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 56px;
  background: var(--s2); border-bottom: 1px solid var(--trait);
}
.haut .logo { display: flex; align-items: center; height: 44px; }
.haut .logo img { height: 26px; width: auto; display: block; }
.haut nav { display: flex; gap: 4px; }
.haut nav a { display: inline-flex; align-items: center; min-height: var(--cible); padding: 0 14px; color: var(--txt2); text-decoration: none; border-radius: 6px; font-weight: 500; }
.haut nav a:hover { color: var(--txt); background: var(--s3); }
.haut nav a.actif { color: var(--or); }
.haut .droite-haut { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.haut .moi { color: var(--txt3); font-size: 14px; }

/* Indicateur d'enregistrement */
.indic { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--txt3); min-height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid transparent; max-width: 46vw; }
.indic::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.indic.vide { visibility: hidden; }
.indic.ok { color: var(--ok); }
.indic.cours { color: var(--or); }
.indic.cours::before { animation: pulse 1s ease-in-out infinite; }
.indic.err { color: var(--err); border-color: var(--err); background: rgba(232, 103, 92, .08); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; line-height: 30px; }
.indic.err::before { display: inline-block; margin-right: 8px; vertical-align: middle; }
@keyframes pulse { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .indic.cours::before { animation: none; } }

/* ---------- Structure ---------- */
main#vue { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page { flex: 1; min-height: 0; overflow: auto; padding: 28px 28px 48px; }
.page > .large { max-width: 1280px; margin: 0 auto; }
.etroit { max-width: 860px; margin: 0 auto; }
.entete-page { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.entete-page p { color: var(--txt2); margin-top: 4px; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--cible); padding: 0 16px;
  background: var(--s3); border: 1px solid var(--trait2); border-radius: 8px; color: var(--txt); font-weight: 500; cursor: pointer;
  text-decoration: none; white-space: nowrap; -webkit-tap-highlight-color: transparent; line-height: 1.2;
}
.btn:hover:not(:disabled) { border-color: var(--or); }
.btn:active:not(:disabled) { background: var(--s4); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.or { background: var(--or); border-color: var(--or); color: #14110A; font-weight: 600; }
.btn.or:hover:not(:disabled) { background: var(--or-vif); border-color: var(--or-vif); }
.btn.danger { color: var(--err); border-color: rgba(232, 103, 92, .45); background: transparent; }
.btn.danger:hover:not(:disabled) { border-color: var(--err); background: rgba(232, 103, 92, .08); }
.btn.discret { background: transparent; border-color: transparent; color: var(--txt2); }
.btn.discret:hover:not(:disabled) { color: var(--txt); background: var(--s3); border-color: transparent; }
.btn.petit { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.icone { width: var(--cible); padding: 0; }
.btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.seg { display: inline-flex; border: 1px solid var(--trait2); border-radius: 8px; overflow: hidden; background: var(--s2); }
.seg button { min-height: 40px; padding: 0 14px; background: transparent; border: 0; border-right: 1px solid var(--trait2); color: var(--txt2); cursor: pointer; font-weight: 500; }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--txt); background: var(--s3); }
.seg button[aria-pressed="true"] { background: var(--or-fond2); color: var(--or-vif); }
.seg.grand button { min-height: var(--cible); }

/* ---------- Champs ---------- */
.champ { display: flex; flex-direction: column; gap: 6px; }
.champ > label, .champ > .lib { font-weight: 500; color: var(--txt2); font-size: 14px; }
.champ .aide { color: var(--txt3); font-size: 13px; line-height: 1.4; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], input[type=number], select, textarea.champ-texte {
  width: 100%; min-height: var(--cible); padding: 8px 12px; background: var(--s2); border: 1px solid var(--trait2); border-radius: 8px; color: var(--txt);
}
input:hover, select:hover, textarea:hover { border-color: #55555c; }
input:focus, select:focus, textarea:focus { border-color: var(--or); outline: none; box-shadow: 0 0 0 3px var(--or-fond); }
input::placeholder, textarea::placeholder { color: var(--txt3); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--txt2) 50%), linear-gradient(135deg, var(--txt2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--or); margin: 0; }
.avec-suffixe { position: relative; }
.avec-suffixe input { padding-right: 36px; }
.avec-suffixe::after { content: attr(data-suffixe); position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--txt3); pointer-events: none; }

/* ---------- Pastilles ---------- */
.pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: 12px; font-size: 13px; font-weight: 500; background: var(--s4); color: var(--txt2); border: 1px solid var(--trait2); white-space: nowrap; }
.pill.or { color: var(--or-vif); border-color: rgba(200, 163, 78, .5); background: var(--or-fond); }
.pill.ok { color: var(--ok); border-color: rgba(127, 191, 147, .45); background: rgba(127, 191, 147, .08); }
.pill.alerte { color: var(--alerte); border-color: rgba(229, 139, 79, .5); background: rgba(229, 139, 79, .08); }
.pill.err { color: var(--err); border-color: rgba(232, 103, 92, .5); background: rgba(232, 103, 92, .08); }
.pill.supp { color: var(--supp); border-color: rgba(127, 178, 201, .45); background: rgba(127, 178, 201, .08); }
.pill.demo { color: #14110A; background: var(--or); border-color: var(--or); font-weight: 600; }

/* ---------- Barre d'avancement ---------- */
.barre { height: 8px; background: var(--s4); border-radius: 4px; overflow: hidden; }
.barre > i { display: block; height: 100%; background: var(--or); border-radius: 4px; }
.barre.fine { height: 6px; }

/* ---------- Écran Chantiers ---------- */
.grille-chantiers { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.carte-ch { display: flex; flex-direction: column; gap: 14px; padding: 18px 18px 16px; background: var(--s1); border: 1px solid var(--trait); border-radius: 10px; text-decoration: none; color: inherit; min-height: 190px; }
.carte-ch:hover { border-color: var(--or); }
.carte-ch .ligne1 { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.carte-ch .ref { color: var(--or); font-weight: 600; font-variant-numeric: tabular-nums; font-size: 14px; }
.carte-ch h3 { font-size: 18px; line-height: 1.25; }
.carte-ch .cl { color: var(--txt2); font-size: 14px; }
.carte-ch .bas { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.carte-ch .mt { font-family: var(--titre); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; }
.carte-ch .mt small { font-family: var(--corps); font-weight: 400; color: var(--txt3); font-size: 13px; margin-left: 6px; }
.carte-ch .av { display: flex; justify-content: space-between; color: var(--txt2); font-size: 13px; }
.badges { display: flex; gap: 6px; flex-wrap: wrap; }
.vide-etat { padding: 48px 20px; text-align: center; color: var(--txt2); border: 1px dashed var(--trait2); border-radius: 10px; }
.vide-etat p { margin-bottom: 16px; }

/* ---------- Cadre chantier ---------- */
.chantier { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ch-tete { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; padding: 6px 20px 0; background: var(--s2); border-bottom: 1px solid var(--trait); }
.ch-titre { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 1 1 0; padding-bottom: 6px; }
.ch-titre a.retour { color: var(--txt3); text-decoration: none; }
.ch-titre a.retour:hover { color: var(--or); }
.ch-titre .ref { color: var(--or); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ch-titre h1 { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.ch-titre .cl { color: var(--txt2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.onglets { display: flex; gap: 2px; flex: none; }
.onglets a { display: inline-flex; align-items: center; min-height: 48px; padding: 0 16px; color: var(--txt2); text-decoration: none; font-weight: 500; border-bottom: 3px solid transparent; }
.onglets a:hover { color: var(--txt); }
.onglets a.actif { color: var(--or-vif); border-bottom-color: var(--or); }
.ch-corps { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.ch-corps.plein { overflow: hidden; }
.panneau { padding: 24px 28px 48px; width: 100%; max-width: 1180px; margin: 0 auto; }
.bloc { background: var(--s1); border: 1px solid var(--trait); border-radius: 10px; padding: 20px; margin-bottom: 18px; }
.bloc > h2 { margin-bottom: 14px; }
.grille2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grille3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 760px) { .grille2, .grille3 { grid-template-columns: 1fr; } }

/* ---------- Devis ---------- */
.barre-outils { flex: none; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 20px; background: var(--s1); border-bottom: 1px solid var(--trait); position: relative; z-index: 20; }
.recherche { position: relative; flex: 1 1 360px; min-width: 260px; max-width: 620px; }
.recherche input { padding-left: 40px; }
.recherche > svg { position: absolute; left: 12px; top: 13px; width: 18px; height: 18px; stroke: var(--txt3); fill: none; stroke-width: 2; pointer-events: none; }
.resultats { position: absolute; left: 0; right: 0; top: calc(100% + 4px); max-height: min(420px, 55vh); overflow: auto; background: var(--s3); border: 1px solid var(--or); border-radius: 8px; box-shadow: 0 16px 40px rgba(0, 0, 0, .6); z-index: 40; }
.resultats button { display: grid; grid-template-columns: 84px 1fr auto; gap: 10px; align-items: baseline; width: 100%; text-align: left; min-height: var(--cible); padding: 8px 12px; background: transparent; border: 0; border-bottom: 1px solid var(--trait); cursor: pointer; }
.resultats button:last-child { border-bottom: 0; }
.resultats button:hover, .resultats button.sel { background: var(--or-fond2); }
.resultats .code { color: var(--or); font-variant-numeric: tabular-nums; font-size: 14px; }
.resultats .un { color: var(--txt3); font-size: 13px; }
.resultats .niv { color: var(--txt3); font-size: 12px; margin-left: 6px; }
.resultats .aucun { padding: 14px; color: var(--txt2); }
.chip-actif { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 6px 0 12px; border-radius: 18px; background: rgba(127, 178, 201, .12); border: 1px solid rgba(127, 178, 201, .5); color: var(--supp); font-size: 14px; }
.chip-actif button { width: 28px; height: 28px; border-radius: 14px; border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 18px; line-height: 1; }
.chip-actif button:hover { background: rgba(127, 178, 201, .2); }

.devis-wrap { flex: 1; min-height: 0; overflow: auto; position: relative; background: var(--noir); overscroll-behavior: contain; }
table.devis { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 100%; min-width: 1000px; }
table.devis th, table.devis td { padding: 0; border-bottom: 1px solid var(--trait); vertical-align: top; background: var(--noir); }
table.devis thead th { position: sticky; top: 0; z-index: 6; background: var(--s1); height: 36px; padding: 0 8px; font-weight: 500; font-size: 13px; color: var(--txt2); text-align: left; border-bottom: 1px solid var(--trait2); vertical-align: middle; }
table.devis thead th.d { text-align: right; }
table.devis .st1 { position: sticky; left: 0; z-index: 3; }
table.devis .st2 { position: sticky; left: var(--code-w); z-index: 3; box-shadow: 1px 0 0 var(--trait2); }
table.devis thead .st1, table.devis thead .st2 { z-index: 8; }
table.devis td.c-in { padding: 2px; }
.c-in input, .c-in textarea { width: 100%; min-height: calc(var(--hc) - 4px); padding: 0 8px; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--txt); font: inherit; }
.c-in input { height: calc(var(--hc) - 4px); }
.c-in input.n { text-align: right; font-variant-numeric: tabular-nums; }
.c-in textarea { padding: 9px 8px 8px; resize: none; overflow: hidden; display: block; line-height: 1.4; field-sizing: content; }
.c-in input:hover, .c-in textarea:hover { border-color: var(--trait2); background: var(--s2); }
.c-in input:focus, .c-in textarea:focus { border-color: var(--or); background: var(--s2); box-shadow: 0 0 0 2px var(--or-fond); outline: none; }
.c-in input.calc { color: var(--txt3); font-style: italic; }
.c-in input.calc:focus { color: var(--txt); font-style: normal; }
.c-in input.err, .c-in textarea.err { border-color: var(--err); }
.c-in .code-in { color: var(--or); font-variant-numeric: tabular-nums; }
table.devis td.c-tot { padding: 0 10px; text-align: right; font-variant-numeric: tabular-nums; line-height: var(--hc); white-space: nowrap; }
table.devis td.c-tot.hors { color: var(--txt3); font-size: 13px; }
table.devis td.c-tot.inc { color: var(--alerte); }
.alertes { padding: 0 10px 8px; display: flex; flex-direction: column; gap: 4px; }
.al { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.35; color: var(--alerte); }
.al::before { content: "!"; flex: none; width: 16px; height: 16px; margin-top: 1px; border-radius: 50%; border: 1.5px solid currentColor; font-weight: 700; font-size: 11px; line-height: 13px; text-align: center; }
.al.err { color: var(--err); }
.al.info { color: var(--txt2); }
.al.info::before { content: "i"; }
.al button { background: transparent; border: 0; padding: 0 4px; margin-left: 4px; color: var(--or-vif); text-decoration: underline; cursor: pointer; min-height: 24px; }
.mode-pill { align-self: flex-start; }

tr.ligne.active td { background: #17170f; }
tr.ligne.active td.st1, tr.ligne.active td.st2 { background: #17170f; }
tr.ligne.active td:first-child { box-shadow: inset 3px 0 0 var(--or); }
tr.ligne.flash td { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { background: var(--or-fond2); } 100% { } }
@media (prefers-reduced-motion: reduce) { tr.ligne.flash td { animation: none; } }
tr.n-sous-titre .c-in textarea { font-family: var(--titre); font-weight: 600; font-size: 15px; color: var(--txt); }
tr.n-texte .c-in textarea { color: var(--txt2); font-size: 14px; }
tr.mode-pm .c-in input.n, tr.mode-offert .c-in input.n { color: var(--txt3); }

tr.ch-ligne td { background: #15130d; border-bottom: 1px solid var(--trait2); }
tr.ch-ligne td.st1, tr.ch-ligne td.st2 { background: #15130d; }
tr.ch-ligne .c-in textarea { font-family: var(--titre); font-weight: 700; font-size: 16px; letter-spacing: .01em; color: var(--txt); }
table.devis td .ch-code { display: flex; align-items: center; height: 100%; min-height: var(--hc); }
.bascule { width: 40px; height: var(--hc); background: transparent; border: 0; color: var(--or); cursor: pointer; display: grid; place-items: center; flex: none; }
.bascule svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
tbody.replie .bascule svg { transform: rotate(-90deg); }
tbody.replie tr:not(.ch-ligne) { display: none; }
.ch-code .cd { color: var(--or); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14px; }
table.devis td.sous-total { padding: 0 10px; text-align: right; font-family: var(--titre); font-weight: 700; color: var(--or-vif); line-height: var(--hc); font-variant-numeric: tabular-nums; white-space: nowrap; }

tr.supp-ligne td:first-child { box-shadow: inset 3px 0 0 var(--supp); }
tr.supp-ligne.active td:first-child { box-shadow: inset 3px 0 0 var(--or); }
tr.supp-refuse td, tr.supp-propose td { }
tr.supp-refuse .c-in textarea, tr.supp-refuse .c-in input { color: var(--txt3); text-decoration: line-through; text-decoration-color: rgba(232, 103, 92, .6); }
tr.supp-propose .c-tot { color: var(--txt3); }
tr.bandeau td { background: #0F1A1F; border-bottom: 1px solid rgba(127, 178, 201, .35); border-top: 1px solid rgba(127, 178, 201, .35); }
.bandeau-in { position: sticky; left: 0; width: var(--vis-w); display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 6px 12px; }
.bandeau-in .t { color: var(--supp); font-family: var(--titre); font-weight: 700; white-space: nowrap; }
.bandeau-in input { flex: 1 1 200px; min-width: 160px; min-height: 36px; height: 36px; background: transparent; border-color: transparent; }
.bandeau-in input:hover { border-color: var(--trait2); }
.bandeau-in .seg button[aria-pressed="true"].s-accepte { background: rgba(127, 191, 147, .18); color: var(--ok); }
.bandeau-in .seg button[aria-pressed="true"].s-propose { background: rgba(229, 139, 79, .18); color: var(--alerte); }
.bandeau-in .seg button[aria-pressed="true"].s-refuse { background: rgba(232, 103, 92, .18); color: var(--err); }

tr.strip td { background: #1A1A1E; border-bottom: 1px solid var(--or); }
.strip-in { position: sticky; left: 0; width: var(--vis-w); display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 8px 12px; }
.strip-in .sep { width: 1px; align-self: stretch; background: var(--trait2); margin: 0 4px; }
.strip-in label.ret { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; color: var(--txt2); }
.strip-in .lib { color: var(--txt3); font-size: 13px; }

.chargement, .vide-corps { padding: 60px 20px; text-align: center; color: var(--txt2); }
.vide-corps .btn { margin-top: 12px; }

/* Pied collant (totaux) */
.pied { flex: none; display: flex; align-items: center; gap: 10px 22px; flex-wrap: wrap; padding: 10px 20px; background: var(--s2); border-top: 1px solid var(--or); position: relative; z-index: 15; }
.pied .m { display: flex; flex-direction: column; min-width: 0; }
.pied .m .l { color: var(--txt3); font-size: 13px; line-height: 1.2; }
.pied .m .v { font-family: var(--titre); font-weight: 700; font-size: 20px; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pied .m.grand .v { font-size: 26px; color: var(--or-vif); }
.pied .m .v small { font-family: var(--corps); font-weight: 400; font-size: 13px; color: var(--txt3); margin-left: 4px; }
.pied .m.moins .v { color: var(--txt2); }
.pied .espace { flex: 1; }
.pied .alerte-btn { display: inline-flex; align-items: center; gap: 8px; min-height: var(--cible); padding: 0 14px; border-radius: 8px; border: 1px solid var(--trait2); background: var(--s3); color: var(--txt2); cursor: pointer; }
.pied .alerte-btn.a { color: var(--alerte); border-color: rgba(229, 139, 79, .6); background: rgba(229, 139, 79, .08); }
.pied .alerte-btn.a:hover { border-color: var(--alerte); }
.pied .av { min-width: 150px; }
.pied .av .barre { margin-top: 6px; }

/* ---------- États d'avancement ---------- */
table.liste { width: 100%; border-collapse: collapse; }
table.liste th { text-align: left; font-weight: 500; font-size: 13px; color: var(--txt3); padding: 8px 12px; border-bottom: 1px solid var(--trait2); }
table.liste td { padding: 0 12px; height: 56px; border-bottom: 1px solid var(--trait); white-space: nowrap; }
table.liste th.d, table.liste td.d { text-align: right; font-variant-numeric: tabular-nums; }
table.liste tbody tr.cliquable { cursor: pointer; }
table.liste tbody tr.cliquable:hover td { background: var(--s1); }
table.liste tfoot td { font-weight: 600; border-bottom: 0; background: var(--s1); }
table.liste .nu { font-family: var(--titre); font-weight: 700; color: var(--or); font-size: 17px; }
.cartes-decompte { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { padding: 14px 16px; background: var(--s2); border: 1px solid var(--trait); border-radius: 8px; }
.kpi .l { color: var(--txt3); font-size: 13px; }
.kpi .v { font-family: var(--titre); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi.fort { border-color: rgba(200, 163, 78, .5); }
.kpi.fort .v { color: var(--or-vif); }
@media (max-width: 860px) { .cartes-decompte { grid-template-columns: repeat(2, 1fr); } }

.etat-tete { flex: none; display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding: 10px 20px; background: var(--s1); border-bottom: 1px solid var(--trait); }
.etat-tete .ti { display: flex; align-items: center; gap: 12px; margin-right: auto; flex-wrap: wrap; }
.etat-tete h2 { font-size: 20px; }
.etat-tete .retour { color: var(--txt3); text-decoration: none; display: inline-flex; align-items: center; min-height: var(--cible); }
.etat-tete .retour:hover { color: var(--or); }
.al-bascule { display: flex; justify-content: space-between; align-items: center; gap: 12px; width: 100%; min-height: 36px; padding: 0; background: transparent; border: 0; cursor: pointer; text-align: left; }
.zone-alertes { flex: none; padding: 8px 20px; background: rgba(229, 139, 79, .06); border-bottom: 1px solid rgba(229, 139, 79, .4); display: flex; flex-direction: column; gap: 4px; max-height: 170px; overflow: auto; }
.zone-alertes .al button { color: var(--or-vif); }
.filtres { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 20px; background: var(--s2); border-bottom: 1px solid var(--trait); flex: none; }
.filtres label { display: inline-flex; align-items: center; gap: 10px; min-height: var(--cible); cursor: pointer; }

table.etat { border-collapse: separate; border-spacing: 0; table-layout: fixed; width: 100%; min-width: 1000px; }
table.etat th, table.etat td { padding: 0; border-bottom: 1px solid var(--trait); vertical-align: middle; background: var(--noir); }
table.etat thead th { position: sticky; top: 0; z-index: 6; background: var(--s1); height: 36px; padding: 0 8px; font-weight: 500; font-size: 13px; color: var(--txt2); text-align: left; border-bottom: 1px solid var(--trait2); }
table.etat thead th.d { text-align: right; }
table.etat .st1 { position: sticky; left: 0; z-index: 3; }
table.etat .st2 { position: sticky; left: 68px; z-index: 3; box-shadow: 1px 0 0 var(--trait2); }
table.etat thead .st1, table.etat thead .st2 { z-index: 8; }
table.etat td.tx { padding: 8px 10px; }
table.etat td.m { text-align: right; padding: 0 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.etat td.prec { color: var(--txt3); text-align: right; padding: 0 10px; font-variant-numeric: tabular-nums; background: var(--s2); }
table.etat .cd { color: var(--or); font-variant-numeric: tabular-nums; font-size: 14px; padding: 0 8px; }
table.etat .des { line-height: 1.35; }
table.etat .des small { display: block; color: var(--txt3); font-size: 12.5px; margin-top: 2px; }
table.etat tr.mod td { background: #17170f; }
table.etat tr.mod td.st1, table.etat tr.mod td.st2, table.etat tr.mod td.prec { background: #17170f; }
table.etat tr.mod td:first-child { box-shadow: inset 3px 0 0 var(--or); }
table.etat tr.baisse td:first-child { box-shadow: inset 3px 0 0 var(--err); }
table.etat tr.chap td { background: #15130d; border-bottom: 1px solid var(--trait2); }
table.etat tr.chap td.st1, table.etat tr.chap td.st2 { background: #15130d; }
.chap-in { position: sticky; left: 0; width: var(--vis-w); display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding: 6px 12px; min-height: 52px; }
.chap-in .t { font-family: var(--titre); font-weight: 700; font-size: 16px; margin-right: auto; }
.chap-in .t span { color: var(--or); margin-right: 10px; font-variant-numeric: tabular-nums; }
.chap-in .tout { display: inline-flex; align-items: center; gap: 8px; color: var(--txt2); font-size: 14px; }
.chap-in .tout .avec-suffixe { width: 96px; }
.chap-in .tout input { min-height: 40px; }
.ctrl { display: flex; align-items: center; gap: 4px; padding: 4px 8px; justify-content: flex-end; }
.ctrl button { width: 44px; height: 44px; padding: 0; background: var(--s3); border: 1px solid var(--trait2); border-radius: 8px; color: var(--txt); font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; flex: none; }
.ctrl button:hover { border-color: var(--or); }
.ctrl button:active { background: var(--s4); }
.ctrl .avec-suffixe { width: 84px; flex: none; }
.ctrl input { min-height: 44px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; padding-left: 8px; }
.ctrl-lecture { padding: 0 10px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.flag-supp { font-size: 12px; margin-left: 6px; }
.pied.etat-pied .m .v { font-size: 18px; }

.dec-note { color: var(--txt2); font-size: 14px; margin-bottom: 12px; max-width: 70ch; }

/* ---------- Client ---------- */
.lien-boite { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; margin: 14px 0 10px; }
.lien-boite input { flex: 1 1 360px; font-variant-numeric: tabular-nums; }
.avert { padding: 12px 14px; border-left: 3px solid var(--alerte); background: rgba(229, 139, 79, .07); color: var(--txt); border-radius: 0 8px 8px 0; font-size: 14px; }
.avert.info { border-left-color: var(--or); background: var(--or-fond); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- Infos ---------- */
.regimes { display: grid; gap: 10px; }
.regime { display: grid; grid-template-columns: 28px 1fr; gap: 4px 12px; align-items: start; padding: 14px 16px; border: 1px solid var(--trait2); border-radius: 8px; cursor: pointer; background: var(--s2); }
.regime:hover { border-color: #55555c; }
.regime.sel { border-color: var(--or); background: var(--or-fond); }
.regime input { margin-top: 2px; accent-color: var(--or); width: 20px; height: 20px; }
.regime .n { font-weight: 600; }
.regime .aide { grid-column: 2; color: var(--txt2); font-size: 13.5px; line-height: 1.45; }

/* ---------- Dialogues ---------- */
dialog { background: var(--s1); color: var(--txt); border: 1px solid var(--trait2); border-radius: 12px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 30px 80px rgba(0, 0, 0, .7); }
dialog::backdrop { background: rgba(0, 0, 0, .72); }
dialog form { display: flex; flex-direction: column; gap: 16px; padding: 22px; }
dialog h2 { font-size: 20px; }
dialog .corps { color: var(--txt2); }
dialog .corps strong { color: var(--txt); }
dialog .pied-dlg { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
dialog .err-dlg { color: var(--err); font-size: 14px; }
dialog .err-dlg:empty { display: none; }

#toasts { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; pointer-events: none; }
.toast { padding: 12px 18px; background: var(--s4); border: 1px solid var(--trait2); border-radius: 8px; box-shadow: 0 8px 30px rgba(0, 0, 0, .6); max-width: min(640px, 92vw); }
.toast.err { border-color: var(--err); color: var(--txt); }
.toast.ok { border-color: var(--ok); }

/* ---------- Connexion ---------- */
.connexion { flex: 1; display: grid; place-items: center; padding: 24px; overflow: auto; }
.connexion .boite { width: min(420px, 100%); display: flex; flex-direction: column; gap: 22px; }
.connexion .boite img { height: 44px; width: auto; align-self: flex-start; }
.connexion form { display: flex; flex-direction: column; gap: 16px; padding: 24px; background: var(--s1); border: 1px solid var(--trait); border-radius: 12px; }
.connexion .err { color: var(--err); min-height: 1.4em; font-size: 14px; }
.connexion p.sous { color: var(--txt2); margin-top: -12px; }

/* ---------- Petits écrans ---------- */
@media (max-width: 760px) {
  .haut { padding: 0 12px; gap: 8px; }
  .haut .moi { display: none; }
  .page { padding: 18px 14px 40px; }
  .ch-titre h1 { max-width: 60vw; }
  .ch-titre .cl { display: none; }
  .onglets a { padding: 0 11px; }
  .panneau { padding: 16px 14px 40px; }
}

/* ---------- Éditeur d'état : filtre des lignes modifiées ---------- */
.filtre-mod tr.ligne-e:not(.mod):not(.touche) { display: none; }
.filtre-mod tbody[data-vide] { display: none; }
table.etat tr.flash td { animation: flash 1.4s ease-out; }

.th-plier { display: flex; align-items: center; gap: 6px; width: 100%; height: 36px; padding: 0 8px; background: transparent; border: 0; color: var(--txt2); cursor: pointer; font-weight: 500; font-size: 13px; }
.th-plier:hover { color: var(--or-vif); }
.th-plier svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.th-plier.tout-plie svg { transform: rotate(-90deg); }
table.devis thead th.st1 { padding: 0; }

/* Désignations longues : 2 lignes au repos, texte complet au toucher (état) ou à l'édition (devis) */
table.etat td.des .txt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
table.etat td.des.ouvert .txt { display: block; overflow: visible; }
table.etat td.des .txt::after { content: ""; }
table.devis tr.n-poste td.c-in textarea[data-f=designation]:not(:focus) { max-height: calc(2 * 1.4em + 14px); }

/* ---------- Onglet Client : signature du devis (L5) ---------- */
.sig-signe { margin-bottom: 16px; }
.sig-sous { font-size: 15px; margin-bottom: 6px; }
.sig-sous-liste { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--trait); margin-bottom: 10px; }
.sig-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 14px; align-items: end; }
.sig-nouveau { margin-top: 16px; }
.sig-nouveau .lien-boite { margin: 12px 0 10px; }
.sig-liste { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--trait); }
.sig-ligne { display: grid; grid-template-columns: 92px minmax(0, 1fr) 128px 150px; gap: 6px 14px; align-items: center; min-height: 56px; padding: 10px 0; border-bottom: 1px solid var(--trait); }
.sig-qui { display: flex; flex-direction: column; min-width: 0; }
.sig-qui > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sig-mont { text-align: right; white-space: nowrap; }
.sig-etat { display: flex; justify-content: flex-end; }
.sig-act { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.sig-act:empty { display: none; }
.sig-act .btn.petit { min-height: var(--cible); }
@media (max-width: 900px) {
  .sig-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .sig-envoyer { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .sig-form { grid-template-columns: 1fr; }
  .sig-ligne { grid-template-columns: 1fr auto; }
  .sig-date { grid-column: 1 / -1; }
  .sig-mont { text-align: left; }
  .sig-etat { justify-content: flex-start; }
}
