/* Facilite - feuille de style unique, sans dependance externe */
:root {
  --fond: #f2f5f4;
  --surface: #ffffff;
  --surface-2: #e9efed;
  --encre: #12211f;
  --encre-douce: #4a5c59;
  --encre-pale: #7d8f8c;
  --trait: #d3dcda;
  --trait-fin: #e6ecea;
  --accent: #0e6b63;
  --accent-fonce: #084a44;
  --accent-pale: #d9ebe8;
  --ok: #2a6b3f;
  --ok-pale: #dff0e4;
  --alerte: #8a5c00;
  --alerte-pale: #f7ebd0;
  --danger: #97242c;
  --danger-pale: #f6dedf;
  --ombre: 0 1px 2px rgba(18,33,31,.06), 0 8px 22px -14px rgba(18,33,31,.25);
  --rayon: 6px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--fond); color: var(--encre);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-pale); }

/* ---- structure ---- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.lateral { background: #0d1a19; color: #cfdedb; padding: 18px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.marque { padding: 0 20px 18px; font-size: 19px; font-weight: 700; color: #fff; letter-spacing: -.02em; }
.marque span { color: #4cbfb1; }
.nav-groupe { padding: 14px 20px 6px; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: #6d8582; }
.lateral a { display: block; padding: 8px 20px; color: #cfdedb; font-size: 14px; border-left: 3px solid transparent; }
.lateral a:hover { background: #142523; text-decoration: none; }
.lateral a.actif { background: #142523; border-left-color: #4cbfb1; color: #fff; font-weight: 600; }
.contenu { padding: 22px 28px 60px; max-width: 1680px; min-width: 0; }
.contenu > form > .panneau, .panneau > .carte:last-child { margin-bottom: 0; }
.barre { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.barre-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fil { font-size: 13px; color: var(--encre-pale); margin-bottom: 4px; }

/* ---- cartes ---- */
.carte { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 18px 20px; margin-bottom: 16px; }
.carte > h2 { margin-bottom: 12px; }
.grille { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* ---- indicateurs ---- */
.indic { background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon); padding: 14px 16px; }
.indic .valeur { font-size: 25px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.indic .cle { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--encre-pale); margin-top: 2px; }
.indic.attention .valeur { color: var(--danger); }
.indic.bien .valeur { color: var(--ok); }

/* ---- tableaux ---- */
.tableau-cadre { overflow-x: auto; border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--trait-fin); vertical-align: middle; }
thead th { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-douce); font-weight: 650; white-space: nowrap; }
tbody tr:hover { background: #f7faf9; }
tbody tr:last-child td { border-bottom: none; }
td.nb, th.nb { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 650; background: var(--surface-2); }
.vide { padding: 26px; text-align: center; color: var(--encre-pale); }

/* ---- pastilles ---- */
.pastille { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--encre-douce); }
.p-ok { background: var(--ok-pale); color: var(--ok); }
.p-attente { background: var(--accent-pale); color: var(--accent-fonce); }
.p-alerte { background: var(--alerte-pale); color: var(--alerte); }
.p-danger { background: var(--danger-pale); color: var(--danger); }

/* ---- boutons ---- */
.bouton, button.bouton, input[type=submit].bouton {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--rayon);
  border: 1px solid var(--trait); background: var(--surface); color: var(--encre); font-size: 14px;
  font-weight: 550; cursor: pointer; font-family: inherit;
}
.bouton:hover { background: var(--surface-2); text-decoration: none; }
.bouton.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
.bouton.primaire:hover { background: var(--accent-fonce); }
.bouton.danger { border-color: var(--danger); color: var(--danger); }
.bouton.danger:hover { background: var(--danger-pale); }
.bouton:disabled { opacity: .5; cursor: not-allowed; }
.bouton.petit { padding: 4px 9px; font-size: 12.5px; }

/* ---- formulaires ---- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--encre); margin-bottom: 6px; }
label .requis { color: var(--danger); margin-left: 3px; font-weight: 700; }
input[type=text], input[type=number], input[type=date], input[type=month], input[type=file],
input[type=password], input[type=email], input[type=tel], input[type=time], input[type=search], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid #cfd8d6; border-radius: 8px;
  background-color: var(--surface); font: inherit; font-size: 14.5px; color: var(--encre);
  box-shadow: 0 1px 1px rgba(18,33,31,.04); transition: border-color .12s, box-shadow .12s;
}
select { appearance: none; padding-right: 34px; background: var(--surface) no-repeat right 12px center / 12px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%234a5c59' stroke-width='1.6'/%3E%3C/svg%3E"); }
select[size], select[multiple] { background-image: none; padding-right: 8px; }
input[type=file] { padding: 6px; background-color: var(--fond); }
input:hover, select:hover, textarea:hover { border-color: #aebcb9; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-pale); }
input::placeholder, textarea::placeholder { color: #9fadaa; }
textarea { resize: vertical; min-height: 72px; }
select[size] { padding: 4px; }
select[size] option { padding: 6px 8px; border-radius: 4px; }
.aide { font-size: 12.5px; color: var(--encre-pale); margin-top: 5px; line-height: 1.4; }
.erreur { color: var(--danger); font-size: 12.5px; margin-top: 5px; font-weight: 550; }
.champ.en-erreur input, .champ.en-erreur select, .champ.en-erreur textarea { border-color: var(--danger); background-color: #fffafa; }
input.repris, select.repris, textarea.repris { background-color: var(--accent-pale); }

/* Grille de 6 colonnes : chaque champ prend la largeur de son contenu (voir templatetags/presentation.py). */
.champs-en-ligne { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 18px 16px; container-type: inline-size; }
.champs-en-ligne > * { grid-column: span 3; min-width: 0; }
.champs-en-ligne > .l-xs { grid-column: span 1; }
.champs-en-ligne > .l-s { grid-column: span 2; }
.champs-en-ligne > .l-m { grid-column: span 3; }
.champs-en-ligne > .l-l, .champs-en-ligne > .large { grid-column: 1 / -1; }
@container (max-width: 620px) {
  .champs-en-ligne > * { grid-column: 1 / -1; }
  .champs-en-ligne > .l-xs, .champs-en-ligne > .l-s { grid-column: span 3; }
}
.champ { margin: 0; }
.champ[hidden], .vente [data-sans-serie][hidden] { display: none; }
form > .champ, .carte > .champ, details > .champ { margin-bottom: 14px; }

/* Case a cocher : un interrupteur suivi de son libelle. */
.champ.case { align-self: end; }
.bascule { display: flex; align-items: center; gap: 10px; margin: 0; min-height: 40px; cursor: pointer; font-weight: 550; }
.bascule input { position: absolute; opacity: 0; pointer-events: none; }
.bascule .glissiere { flex: none; width: 38px; height: 22px; border-radius: 99px; background: #cfd8d6; position: relative; transition: background .15s; }
.bascule .glissiere::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.bascule input:checked + .glissiere { background: var(--accent); }
.bascule input:checked + .glissiere::after { transform: translateX(16px); }
.bascule input:focus-visible + .glissiere { box-shadow: 0 0 0 3px var(--accent-pale); }
.bascule .texte { display: grid; }
.bascule .aide { margin-top: 0; font-weight: 400; }

/* Formulaire en sections : titre a gauche, champs a droite. */
.formulaire-sections { padding: 0; }
.section-formulaire { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; padding: 24px 28px; }
.section-formulaire + .section-formulaire { border-top: 1px solid var(--trait-fin); }
.section-formulaire > h2 { font-size: 15px; margin: 8px 0 0; color: var(--encre); }
@media (max-width: 900px) { .section-formulaire { grid-template-columns: 1fr; gap: 12px; padding: 18px; } }

.actions-formulaire { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--trait-fin); }
.actions-formulaire form { margin: 0; }
.bouton.large { width: 100%; justify-content: center; padding: 10px 14px; }
.bouton.primaire { box-shadow: 0 1px 2px rgba(8,74,68,.25); }
fieldset { border: 1px solid var(--trait); border-radius: var(--rayon); padding: 14px 16px; margin: 0 0 16px; }
legend { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--encre-pale); font-weight: 650; padding: 0 6px; }

/* ---- messages ---- */
.messages { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.message { padding: 10px 14px; border-radius: var(--rayon); border-left: 3px solid var(--accent); background: var(--accent-pale); color: var(--accent-fonce); font-size: 14px; }
.message.success { background: var(--ok-pale); border-color: var(--ok); color: var(--ok); }
.message.warning { background: var(--alerte-pale); border-color: var(--alerte); color: var(--alerte); }
.message.error { background: var(--danger-pale); border-color: var(--danger); color: var(--danger); }

/* ---- divers ---- */
.paires { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px 20px; }
.paire .cle { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--encre-pale); }
.paire .valeur { font-size: 15px; font-weight: 550; }
.mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 13px; }
.jauge { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.jauge i { display: block; height: 100%; background: var(--accent); }
.filtres { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.filtres .champ { margin: 0; }
.filtres input[type=text] { min-width: 300px; }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 14px; font-size: 14px; }
.onglets { display: flex; gap: 6px; border-bottom: 1px solid var(--trait); margin-bottom: 16px; flex-wrap: wrap; }
.onglets a { padding: 8px 14px; font-size: 14px; border-bottom: 2px solid transparent; color: var(--encre-douce); }
.onglets a.actif { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }

/* ---- onglets pilotes par le clavier / la souris ---- */
.onglet {
  padding: 8px 14px; font: inherit; font-size: 14px; background: none; border: none;
  border-bottom: 2px solid transparent; color: var(--encre-douce); cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
}
.onglet:hover { color: var(--accent); }
.onglet.actif { border-bottom-color: var(--accent); color: var(--accent); font-weight: 600; }
.onglet .compteur {
  background: var(--surface-2); color: var(--encre-douce); border-radius: 99px;
  padding: 0 7px; font-size: 11.5px; font-weight: 600;
}
.onglet.actif .compteur { background: var(--accent-pale); color: var(--accent-fonce); }
.onglet.en-erreur { color: var(--danger); }
.onglet.en-erreur::after { content: "!"; font-weight: 700; }
.panneau[hidden] { display: none !important; }

/* ---- barre d'actions collante en haut ---- */
.barre.collante {
  position: sticky; top: 0; z-index: 20; background: var(--fond);
  padding: 14px 0 12px; margin: -22px 0 14px; border-bottom: 1px solid var(--trait);
}
.alerte-bloc { border-left: 3px solid var(--alerte); background: var(--alerte-pale); color: var(--alerte); padding: 10px 14px; border-radius: var(--rayon); font-size: 14px; margin-bottom: 12px; }
.alerte-bloc.grave { border-color: var(--danger); background: var(--danger-pale); color: var(--danger); }

/* ---- ecran de reglages ---- */
.reglages { display: grid; grid-template-columns: 1fr; gap: 22px; align-items: start; }
@media (min-width: 1000px) { .reglages { grid-template-columns: 236px minmax(0, 1fr); } }

.reglages-menu {
  background: var(--surface); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: 8px 0; position: sticky; top: 74px;
}
.reglages-groupe {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--encre-pale);
  padding: 12px 16px 5px; font-weight: 650;
}
.reglages-groupe:first-child { padding-top: 4px; }
.reglages-lien {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 16px; font-size: 14px; color: var(--encre); border-left: 3px solid transparent;
}
.reglages-lien:hover { background: var(--surface-2); text-decoration: none; }
.reglages-lien.actif {
  background: var(--accent-pale); border-left-color: var(--accent);
  color: var(--accent-fonce); font-weight: 600;
}
.reglages-lien .compteur { background: var(--surface-2); color: var(--encre-pale); }
.reglages-lien.actif .compteur { background: var(--surface); color: var(--accent-fonce); }
.reglages-pied { padding: 12px 16px 6px; border-top: 1px solid var(--trait-fin); margin-top: 8px; }
.reglages-pied a { font-size: 13px; display: block; padding: 4px 0; }

.section-entete { margin-bottom: 16px; }
.section-entete h2 { font-size: 20px; letter-spacing: -.015em; }
.section-entete p { color: var(--encre-soft, var(--encre-douce)); font-size: 14.5px; margin: 6px 0 0; max-width: 62ch; }
.section-compte { font-size: 13px; color: var(--encre-pale); margin-top: 8px; }

.carte.edition { border-left: 3px solid var(--accent); }
tr.en-cours-edition { background: var(--accent-pale); }
tr.inactive td:not(.actions) { color: var(--encre-pale); }

/* ---- connexion ---- */
.connexion { min-height: 100vh; display: grid; place-items: center; background: #0d1a19; }
.connexion .boite { background: var(--surface); padding: 32px; border-radius: 10px; width: 360px; box-shadow: var(--ombre); }

/* ---- impression ---- */
.document { background: #fff; max-width: 19cm; margin: 20px auto; padding: 1.6cm; color: #000; font-size: 12.5px; }
.document h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.document .entete { display: flex; justify-content: space-between; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 18px; }
.document table { font-size: 12px; }
.document th, .document td { border: 1px solid #999; padding: 5px 7px; }
.document .signatures { display: flex; justify-content: space-between; margin-top: 50px; }
.rtl { direction: rtl; text-align: right; font-family: "Amiri", "Noto Naskh Arabic", "Traditional Arabic", serif; font-size: 15px; }
@media print {
  .lateral, .barre-actions, .sans-impression { display: none !important; }
  body { background: #fff; }
  .app { display: block; }
  .contenu { padding: 0; max-width: none; }
  .document { margin: 0; padding: 0; max-width: none; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: static; height: auto; }
}

/* ---- roles : niveaux d'acces ---- */
.niveau { display: inline-block; padding: 2px 8px; margin: 0 2px 3px 0; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-2); color: var(--encre-douce); }
.n-consultation { background: var(--accent-pale); color: var(--accent-fonce); }
.n-saisie { background: var(--alerte-pale); color: var(--alerte); }
.n-complet { background: var(--ok-pale); color: var(--ok); }
.mode-emploi h3 { margin: 0 0 8px; }
.mode-emploi ol { margin: 0 0 12px; padding-left: 20px; }
.mode-emploi li { margin-bottom: 3px; }
.legende-niveaux { display: grid; gap: 6px; font-size: 13.5px; color: var(--encre-douce); }
.legende-niveaux .niveau { min-width: 104px; text-align: center; }
.choix-niveau > div { display: flex; flex-wrap: wrap; gap: 6px; }
.choix-niveau label { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 5px 11px; border: 1px solid var(--trait); border-radius: 99px; background: var(--surface); color: var(--encre-douce); font-size: 13px; font-weight: 550; cursor: pointer; }
.choix-niveau label:has(input:checked) { border-color: var(--accent); background: var(--accent-pale); color: var(--accent-fonce); }
.choix-niveau label:has(input:disabled) { cursor: default; }
.choix-niveau input { margin: 0; accent-color: var(--accent); }

/* ---- dossier : frise des quatre interventions ---- */
.frise { list-style: none; margin: 0 0 16px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.frise li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--surface); }
.frise .rond { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--surface-2); color: var(--encre-pale); }
.frise li.fait .rond { background: var(--ok-pale); color: var(--ok); }
.frise li.en-cours { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.frise li.en-cours .rond { background: var(--accent); color: #fff; }
.frise li.a-venir { opacity: .7; }
.carte.a-faire { border-left: 3px solid var(--accent); }
.autres-decisions { margin-top: 14px; }
.autres-decisions summary { cursor: pointer; font-size: 13.5px; color: var(--encre-douce); font-weight: 550; }
.autres-decisions form { margin-top: 10px; }
.verifications { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 4px; font-size: 14px; }
.verifications li::before { display: inline-block; width: 20px; font-weight: 700; }
.verifications li.ok::before { content: "\2713"; color: var(--ok); }
.verifications li.ko::before { content: "\2717"; color: var(--danger); }
@media (max-width: 900px) { .frise { grid-template-columns: 1fr 1fr; } }
form.numerotation { display: flex; gap: 6px; align-items: center; margin: 0; }
form.numerotation input[type=number] { width: 110px; }

/* ---- preparation de la vente : saisie a gauche, recapitulatif a droite ---- */
.vente { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 1100px) { .vente { grid-template-columns: minmax(0, 1fr) 320px; } }
.vente-principal .carte:last-child { margin-bottom: 0; }
/* Tableau des articles, comme sur une facture ; l'article s'ajoute par la barre sous le tableau. */
.tableau-vente table { table-layout: fixed; min-width: 1020px; font-size: 13px; }
.tableau-vente th, .tableau-vente td { padding: 9px 5px; }
.tableau-vente th:first-child, .tableau-vente td:first-child { padding-left: 10px; }
.tableau-vente th:nth-child(1) { width: 50px; } .tableau-vente th:nth-child(3) { width: 64px; }
.tableau-vente th:nth-child(4) { width: 52px; }
.tableau-vente th:nth-child(5), .tableau-vente th:nth-child(6), .tableau-vente th:nth-child(7) { width: 58px; }
/* Vente : 8 N° de serie, 9-10 prix, 11 montant, 12 retirer. */
.tableau-vente th:nth-child(8) { width: 118px; }
.tableau-vente th:nth-child(9), .tableau-vente th:nth-child(10) { width: 100px; }
.tableau-vente th:nth-child(11) { width: 104px; }
.tableau-vente th:nth-child(12) { width: 48px; }
.tableau-vente td.quantite input { padding: 4px 6px; }
.tableau-vente thead th, .tableau-articles thead th { white-space: normal; line-height: 1.25; vertical-align: bottom; }
.tableau-vente td.quantite [data-sans-colis], .tableau-vente td.quantite [data-sans-vrac] { display: block; text-align: right; padding-top: 6px; color: var(--encre-pale); }
.tableau-vente td.quantite [hidden] { display: none; }
.tableau-cadre.tableau-vente { overflow-x: auto; }
.tableau-vente th.centre, .tableau-vente td.centre { text-align: center; }
.tableau-vente td.fort { font-weight: 650; }
.tableau-vente td.photo { padding-top: 6px; padding-bottom: 6px; }
.code-article { font-size: 11.5px; color: var(--encre-pale); }
.vignette { display: block; width: 36px; height: 36px; border-radius: 6px; object-fit: cover;
  border: 1px solid var(--trait-fin); background: var(--surface-2); }
span.vignette { background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%237d8f8c' d='M4 5h16a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1Zm1 2v8.6l3.3-3.3 2.7 2.7 4.3-4.3L19 14.4V7H5Zm4 1.5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z'/%3E%3C/svg%3E") center / 18px no-repeat; }
.tableau-vente td.mono { font-size: 13px; color: var(--encre-douce); }
.tableau-vente td.quantite { padding-top: 5px; padding-bottom: 5px; }
.tableau-vente td.quantite input { width: 100%; height: 32px; padding: 4px 8px; text-align: right; }
.tableau-vente td.action { text-align: center; padding-top: 5px; padding-bottom: 5px; }
.tableau-vente tbody.ligne-vente tr:first-child:not(:last-child) td { border-bottom: none; }
.tableau-vente input.en-erreur { border-color: var(--danger); background: var(--danger-fond, #fdecec); }
.tableau-vente-directe tfoot td.quantite input { width: 100%; height: 30px; padding: 3px 8px; text-align: right; }
.tableau-vente td.vide { text-align: center; color: var(--encre-pale); padding: 18px; }
.tableau-vente tfoot td { background: var(--surface-2); border-bottom: none; padding-top: 6px; padding-bottom: 6px; font-weight: 500; color: var(--encre-douce); }
.tableau-vente tfoot tr:first-child td { padding-top: 10px; border-top: 1px solid var(--trait); }
.tableau-vente tfoot tr.total td { color: var(--encre); font-weight: 700; padding-bottom: 10px; }
.tableau-vente td.series { min-width: 110px; white-space: nowrap; padding-top: 5px; padding-bottom: 5px; }
.tableau-vente td.series .sans-series { display: block; padding-top: 6px; color: var(--encre-pale); }
.tableau-vente td.series .sans-series[hidden] { display: none; }
.compteur-series { font-size: 11.5px; color: var(--danger); margin-top: 3px; }
.compteur-series:empty { display: none; }
.compteur-series.complet { color: var(--encre-pale); }
.ajout-article { display: grid; grid-template-columns: 220px minmax(0, 1fr) 90px auto; gap: 8px; margin-top: 12px; }
#quantite-ajout { text-align: right; }
.ajout-article .a-choisir .ts-control, .ajout-article select.a-choisir, #code-barres.a-choisir { border-color: var(--danger); }
.bouton-icone { width: 30px; height: 30px; border: 1px solid var(--trait); border-radius: var(--rayon);
  background: var(--surface); color: var(--encre-douce); font-size: 17px; line-height: 1; cursor: pointer; }
.bouton-icone:hover { color: var(--danger); border-color: var(--danger); }
.bouton[hidden], .bouton-icone[hidden], tbody[hidden] { display: none; }
tbody.ligne-vente.retiree td:not(.action) { opacity: .45; text-decoration: line-through; }

/* ---- bon de transfert : meme tableau que la vente, sans prix ---- */
.tableau-vente.tableau-transfert table { min-width: 760px; }
.tableau-vente.tableau-transfert th:nth-child(3) { width: 88px; }
.tableau-vente.tableau-transfert th:nth-child(4), .tableau-vente.tableau-transfert th:nth-child(5) { width: 64px; }
.tableau-vente.tableau-transfert th:nth-child(6) { width: 76px; }
.tableau-vente.tableau-transfert th:nth-child(7) { width: 30%; }
.tableau-vente.tableau-transfert th:nth-child(8) { width: 48px; }
.tableau-transfert td.ko { color: var(--danger); font-weight: 700; }
.tableau-transfert td.series-texte { padding-top: 5px; padding-bottom: 5px; }
.tableau-transfert td.series-texte input { width: 100%; height: 32px; padding: 4px 8px; }

/* ---- demande d'achat et bon de commande : meme tableau que la vente ---- */
/* Demande et bon de commande : la precision a sa colonne, juste apres l'article. */
.tableau-vente.tableau-achat table { min-width: 760px; }
.tableau-vente.tableau-achat th:nth-child(1) { width: 50px; }
.tableau-vente.tableau-achat th:nth-child(3) { width: 30%; }
.tableau-vente.tableau-achat th:nth-child(4) { width: 80px; }
.tableau-vente.tableau-achat th:nth-child(5), .tableau-vente.tableau-achat th:nth-child(6) { width: 64px; }
.tableau-vente.tableau-achat th:nth-child(7) { width: 76px; }
.tableau-vente.tableau-achat th:nth-child(8) { width: 48px; }
.tableau-vente.tableau-achat-commande table { min-width: 1150px; }
.tableau-vente.tableau-achat-commande th:nth-child(3) { width: 170px; }
.tableau-vente.tableau-achat-commande th:nth-child(8) { width: 120px; }
.tableau-vente.tableau-achat-commande th:nth-child(9) { width: 76px; }
.tableau-vente.tableau-achat-commande th:nth-child(10) { width: 100px; }
.tableau-vente.tableau-achat-commande th:nth-child(11) { width: 130px; }
.tableau-vente.tableau-achat-commande th:nth-child(12) { width: 48px; }
.tableau-achat .remise input { width: 100%; }
.tableau-achat .negatif { color: var(--danger, #b42318); }
/* Demande de transfert : disponible chez l'entrepot source (vert) ou manquant (rouge). */
tr.stock-ok td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
tr.stock-ko td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.stock-ok td:first-child a { color: var(--ok); font-weight: 600; }
tr.stock-ko td:first-child a { color: var(--danger); font-weight: 600; }
.tableau-achat tbody.stock-ok td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
.tableau-achat tbody.stock-ko td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.tableau-achat tbody.stock-ok [data-designation] { color: var(--ok); font-weight: 600; }
.tableau-achat tbody.stock-ko [data-designation] { color: var(--danger); font-weight: 600; }
.tableau-achat tbody.stock-ok td[data-disponible], .tableau-achat tbody.stock-ko td[data-disponible] { font-weight: 700; }
.tableau-achat tbody.stock-ok td[data-disponible] { color: var(--ok); background: var(--ok-pale); }
.tableau-achat tbody.stock-ko td[data-disponible] { color: var(--danger); background: var(--danger-pale); }
.tableau-achat [data-brut] { font-weight: 400; white-space: pre-line; line-height: 1.35; margin-top: 2px; }
.tableau-achat td.precision input { width: 100%; height: 32px; padding: 4px 8px; text-align: left; }
.tableau-achat td.choix-ligne { padding-top: 5px; padding-bottom: 5px; }
.tableau-achat td.choix-ligne select { width: 100%; height: 32px; }
.champ[hidden] { display: none; }
.recap { position: sticky; top: 84px; margin-bottom: 0; }
.recap dl { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; margin: 0; font-size: 14px; }
.recap dt { color: var(--encre-douce); }
.recap dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
.recap .fort { font-weight: 700; color: var(--encre); font-size: 15px; }
.recap hr { border: none; border-top: 1px solid var(--trait-fin); margin: 12px 0; }
.recap-etat { margin: 14px 0 12px; padding: 9px 12px; border-radius: var(--rayon); font-size: 13.5px; }
.recap-etat.ok { background: var(--ok-pale); color: var(--ok); }
.recap-etat.ko { background: var(--danger-pale); color: var(--danger); }

/* ======================================================================= */
/*  Dossiers de vente : liste et fiche                                      */
/* ======================================================================= */
.sous-titre { color: var(--encre-pale); font-size: 13.5px; margin-top: 2px; }

/* Couleur de chaque etape, reprise partout (liste, fiche, compteurs). */
.pastille.etape-brouillon { background: #eef1f0; color: var(--encre-douce); }
.pastille.etape-en_etude { background: #e3ecfb; color: #234a8a; }
.pastille.etape-approuve { background: var(--alerte-pale); color: var(--alerte); }
.pastille.etape-a_fermer { background: #efe4f7; color: #5e2a84; }
.pastille.etape-transforme { background: var(--ok-pale); color: var(--ok); }
.pastille.etape-rejete, .pastille.etape-annule { background: var(--danger-pale); color: var(--danger); }

.compteurs-etapes { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; margin-bottom: 14px; }
.compteurs-etapes a {
  display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border-radius: var(--rayon);
  background: var(--surface); border: 1px solid var(--trait); color: var(--encre); border-top: 3px solid var(--trait);
}
.compteurs-etapes a:hover { text-decoration: none; border-color: var(--accent); }
.compteurs-etapes a.actif { background: var(--accent-pale); border-color: var(--accent); }
.compteurs-etapes a.vide { opacity: .55; }
.compteurs-etapes .nombre { font-size: 22px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.compteurs-etapes .libelle { font-size: 13px; font-weight: 600; }
.compteurs-etapes .qui { font-size: 11.5px; color: var(--encre-pale); }
.compteurs-etapes .etape-en_etude { border-top-color: #4a78c4; }
.compteurs-etapes .etape-approuve { border-top-color: #c99a2e; }
.compteurs-etapes .etape-a_fermer { border-top-color: #8a4fb8; }
.compteurs-etapes .etape-transforme { border-top-color: var(--ok); }
.compteurs-etapes .etape-rejete, .compteurs-etapes .etape-annule { border-top-color: var(--danger); }

.recherche { display: flex; gap: 8px; margin-bottom: 14px; }
.recherche input[type=search] {
  flex: 1; min-height: 40px; padding: 8px 12px 8px 36px; border: 1px solid var(--trait); border-radius: var(--rayon);
  font: inherit; font-size: 14.5px; background: var(--surface) no-repeat 12px center / 16px
  url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237d8f8c' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
}
.recherche input[type=search]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-pale); }

.liste-dossiers td { padding-top: 11px; padding-bottom: 11px; }
.liste-dossiers tbody tr { cursor: pointer; }
.colonne-choix { width: 36px; text-align: center; padding-left: 8px; padding-right: 4px; }
.colonne-choix input[type=checkbox] { margin: 0; cursor: pointer; }
.liste-dossiers .client { font-weight: 650; color: var(--encre); }
.liste-dossiers .aide { margin-top: 1px; }

/* ---- fiche ---- */
.dos-entete { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin: 2px 0 16px; }
.dos-entete h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 26px; }
.dos-entete h1 .pastille { font-size: 12.5px; padding: 3px 10px; }
.dos-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--encre-pale); font-size: 13.5px; margin-top: 4px; }
.dos-facture {
  display: grid; padding: 10px 16px; background: var(--surface); border: 1px solid var(--trait);
  border-left: 4px solid var(--ok); border-radius: var(--rayon); min-width: 210px;
}
.dos-facture .cle { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--encre-pale); }
.dos-facture .numero { font-size: 18px; font-weight: 700; color: var(--encre); }
.dos-facture.annulee { border-left-color: var(--danger); }
.dos-facture.annulee .numero { text-decoration: line-through; color: var(--danger); }

.etapes { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.etapes li { display: flex; align-items: center; gap: 10px; padding-right: 10px; }
.etapes li:not(:last-child)::after { content: ""; flex: 1; height: 2px; background: var(--trait); margin-left: 4px; min-width: 16px; }
.etapes li.fait:not(:last-child)::after { background: var(--ok); }
.etapes .rond {
  flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; background: var(--surface); border: 2px solid var(--trait); color: var(--encre-pale);
}
.etapes .texte { display: grid; line-height: 1.25; white-space: nowrap; }
.etapes .texte strong { font-size: 14px; }
.etapes li.fait .rond { background: var(--ok); border-color: var(--ok); color: #fff; }
.etapes li.en-cours .rond { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-pale); }
.etapes li.en-cours strong { color: var(--accent-fonce); }
.etapes li.a-venir .texte { opacity: .6; }

.dos-grille { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
@media (min-width: 1100px) { .dos-grille { grid-template-columns: minmax(0, 1fr) 300px; } }
.dos-cote { display: grid; gap: 16px; position: sticky; top: 16px; }
.dos-cote .carte { margin: 0; }

.carte-titre { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.carte-titre h2 { margin: 0; }
.carte-titre a { font-size: 13.5px; }

.carte.action { border: 1px solid var(--accent); box-shadow: 0 0 0 3px var(--accent-pale), var(--ombre); }
.carte.action > h2 { font-size: 18px; }
.carte.action p { margin: 0 0 12px; }
.carte.action.attente { border-color: var(--trait); box-shadow: none; background: var(--surface-2); }
.carte.action.termine { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-pale); }
.carte.action.refuse { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-pale); }
.retour { background: var(--alerte-pale); color: var(--alerte); padding: 9px 12px; border-radius: var(--rayon); margin-bottom: 12px; font-size: 14px; }
.bloquant, .signal { padding: 8px 12px; border-radius: var(--rayon); font-size: 13.5px; margin-bottom: 8px; }
.bloquant, .signal.bloquant { background: var(--danger-pale); color: var(--danger); }
.signal.alerte { background: var(--alerte-pale); color: var(--alerte); }

.deux-colonnes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 28px; }
.deux-colonnes form { margin-top: 10px; }
dl.infos { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0; font-size: 14px; align-content: start; }
dl.infos dt { color: var(--encre-pale); }
dl.infos dd { margin: 0; font-weight: 550; text-align: right; }
dl.infos.en-ligne { grid-template-columns: repeat(4, auto 1fr); }
dl.infos.en-ligne dd { text-align: left; }
@media (max-width: 900px) { dl.infos.en-ligne { grid-template-columns: auto 1fr; } }
dd.depasse { color: var(--danger); }
.manque { color: var(--danger); font-weight: 600; }

.tableau-simple { font-size: 14px; }
.tableau-simple th { background: none; padding: 6px 8px; border-bottom: 1px solid var(--trait); }
.tableau-simple td { padding: 9px 8px; }
.tableau-simple tbody tr:hover { background: none; }
.tableau-simple tfoot td { background: none; border-top: 1px solid var(--trait); border-bottom: none; }
.tableau-simple tfoot tr.discret td { font-weight: 500; color: var(--encre-douce); border-top: none; padding-top: 0; }
.carte .vide { padding: 14px 0; text-align: left; }

.chiffres .principal { display: grid; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--trait-fin); }
.chiffres .principal .valeur { font-size: 28px; font-weight: 700; letter-spacing: -.02em; color: var(--accent-fonce); }
.chiffres .principal .cle { font-size: 13px; color: var(--encre-pale); }
.chiffres .aide { margin-top: 10px; }

.fil-historique { list-style: none; margin: 0; padding: 0; }
.fil-historique li {
  display: grid; grid-template-columns: 82px 1fr; gap: 12px; padding: 9px 0 9px 14px; margin-left: 6px;
  border-left: 2px solid var(--trait-fin); position: relative; font-size: 14px;
}
.fil-historique li::before {
  content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent);
}
.fil-historique .quand { color: var(--encre-douce); font-size: 13px; line-height: 1.3; }
.fil-historique strong { display: block; font-weight: 600; }
.fil-historique .historique-articles { margin: 4px 0 0; padding-left: 18px; list-style: disc; color: var(--encre-douce); font-size: 13px; }
.fil-historique .historique-articles li { display: list-item; padding: 1px 0; margin: 0; border: none; }
.fil-historique .historique-articles li::before { content: none; }
@media (max-width: 900px) { .etapes { grid-template-columns: 1fr 1fr; gap: 10px; } .etapes li::after { display: none; } }

/* ---- filtres sous les colonnes des listes ---- */
.barre-filtres { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 10px; min-height: 30px; font-size: 13.5px; }
.barre-filtres .resultat { color: var(--encre-douce); margin-right: 4px; }
.soumission-cachee { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.impression-vente { margin-top: 8px; }
.impression-vente > summary { list-style: none; cursor: pointer; text-align: center; }
.impression-vente > summary::-webkit-details-marker { display: none; }
.impression-vente-choix { display: grid; gap: 6px; margin-top: 8px; }
.etiquette-filtre { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 11px; border-radius: 99px;
  background: var(--accent-pale); color: var(--accent-fonce); font-size: 12.5px; font-weight: 600; }
.etiquette-filtre span { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font-size: 14px; line-height: 1; }
.etiquette-filtre:hover { text-decoration: none; background: #c9e2de; }
.etiquette-filtre:hover span { background: var(--accent); color: #fff; }
.tout-effacer { font-size: 12.5px; color: var(--encre-pale); margin-left: 4px; }

.ligne-filtres th { background: #fbfcfc; padding: 6px 6px 7px; border-bottom: 1px solid var(--trait); text-transform: none; letter-spacing: 0; font-weight: 400; }
.ligne-filtres th:first-child { padding-left: 10px; }
.ligne-filtres input, .ligne-filtres select, .filtre-intervalle summary {
  min-height: 30px; height: 30px; padding: 4px 9px; font-size: 13px; font-weight: 400; border: 1px solid transparent;
  border-radius: 6px; background-color: transparent; box-shadow: none; color: var(--encre); width: 100%;
}
.ligne-filtres input[type=search] { min-width: 80px; padding-left: 26px; background: no-repeat 8px center / 13px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239fadaa' stroke-width='2.4'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); }
.ligne-filtres select { min-width: 80px; padding-right: 24px; background-position: right 8px center; background-size: 10px; color: var(--encre-pale); }
.ligne-filtres input:hover, .ligne-filtres select:hover, .filtre-intervalle summary:hover { border-color: var(--trait); background-color: var(--surface); }
.ligne-filtres input:focus, .ligne-filtres select:focus { border-color: var(--accent); background-color: var(--surface); box-shadow: 0 0 0 2px var(--accent-pale); }
.ligne-filtres .rempli, .filtre-intervalle.rempli summary { border-color: var(--accent); background-color: var(--accent-pale); color: var(--accent-fonce); font-weight: 600; }

.filtre-intervalle { position: relative; }
.filtre-intervalle summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  white-space: nowrap; color: var(--encre-pale); text-align: left; }
.filtre-intervalle summary::-webkit-details-marker { display: none; }
.filtre-intervalle summary::after { content: ""; width: 10px; height: 10px; flex: none; background: no-repeat center / 10px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%234a5c59' stroke-width='1.6'/%3E%3C/svg%3E"); }
.panneau-intervalle { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: 250px; padding: 14px;
  background: var(--surface); border: 1px solid var(--trait); border-radius: 10px; box-shadow: 0 12px 32px -12px rgba(18,33,31,.35);
  display: grid; gap: 10px; text-align: left; }
th.nb .panneau-intervalle, th:last-child .panneau-intervalle { left: auto; right: 0; }
.panneau-intervalle label { margin: 0; font-size: 12px; font-weight: 600; color: var(--encre-douce); display: grid; gap: 4px; }
.panneau-intervalle input { height: 34px; min-height: 34px; border: 1px solid var(--trait); background: var(--surface); font-size: 13.5px; text-align: left; }
.panneau-intervalle .raccourcis { display: flex; flex-wrap: wrap; gap: 5px; padding-bottom: 10px; border-bottom: 1px solid var(--trait-fin); }
.panneau-intervalle .raccourcis button { font: inherit; font-size: 12px; padding: 4px 9px; border-radius: 99px; border: 1px solid var(--trait);
  background: var(--surface); color: var(--encre-douce); cursor: pointer; }
.panneau-intervalle .raccourcis button:hover { border-color: var(--accent); color: var(--accent-fonce); background: var(--accent-pale); }
.panneau-intervalle .pied { display: flex; justify-content: space-between; gap: 8px; padding-top: 4px; }

/* ---- reglage d'une automatisation ---- */
.tache-entete { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin: 2px 0 18px; }
.tache-entete h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tache-entete h1 .pastille { font-size: 12.5px; padding: 3px 10px; }
.tache-description { margin: 6px 0 0; color: var(--encre-douce); max-width: 70ch; }
.tache-grille { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; margin-bottom: 16px; }
@media (min-width: 1000px) { .tache-grille { grid-template-columns: minmax(0, 1fr) 300px; } }
.tache-grille > .carte, .tache-etat .carte { margin: 0; }
.tache-etat { display: grid; gap: 16px; }
.tache-etat .grand { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
.tache-etat .grand span { font-size: 15px; font-weight: 500; color: var(--encre-douce); }
.tache-etat .grand.discret { color: var(--encre-pale); }
.derniere { display: flex; gap: 10px; align-items: flex-start; }
.derniere .icone { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; }
.derniere.ok .icone { background: var(--ok); }
.derniere.ko .icone { background: var(--danger); }
.derniere strong { display: block; }

.interrupteur { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; margin: 0 0 18px; padding-bottom: 16px; border-bottom: 1px solid var(--trait-fin); font-size: 14.5px; color: var(--encre); font-weight: 400; }
.interrupteur input { position: absolute; opacity: 0; pointer-events: none; }
.interrupteur .glissiere { flex: none; width: 42px; height: 24px; border-radius: 99px; background: var(--trait); position: relative; transition: background .15s; margin-top: 1px; }
.interrupteur .glissiere::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.interrupteur input:checked + .glissiere { background: var(--accent); }
.interrupteur input:checked + .glissiere::after { transform: translateX(18px); }
.interrupteur input:focus-visible + .glissiere { box-shadow: 0 0 0 3px var(--accent-pale); }
.interrupteur strong { display: block; }

.frequences { border: none; padding: 0; margin: 0 0 8px; transition: opacity .15s; }
.frequences.eteint { opacity: .5; }
.frequences legend { padding: 0; margin-bottom: 10px; font-size: 15px; font-weight: 650; text-transform: none; letter-spacing: 0; color: var(--encre); }
.choix-cartes { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.choix-carte { display: flex; align-items: center; gap: 8px; margin: 0; padding: 11px 12px; border: 1px solid var(--trait); border-radius: var(--rayon); background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 550; color: var(--encre); }
.choix-carte:hover { border-color: var(--accent); }
.choix-carte:has(input:checked) { border-color: var(--accent); background: var(--accent-pale); color: var(--accent-fonce); box-shadow: inset 0 0 0 1px var(--accent); }
.choix-carte input { accent-color: var(--accent); margin: 0; }
.frequences .quand { max-width: 560px; }
.frequences .champ[hidden] { display: none; }
.resume-frequence { margin: 4px 0 0; padding: 10px 12px; background: var(--surface-2); border-radius: var(--rayon); font-size: 14px; color: var(--encre-douce); }
.resume-frequence:empty { display: none; }
.identification { margin: 16px 0 4px; }
.identification summary { cursor: pointer; font-size: 13.5px; color: var(--encre-douce); font-weight: 550; margin-bottom: 10px; }

.fil-executions { list-style: none; margin: 0; padding: 0; }
.fil-executions li { display: grid; grid-template-columns: 82px 1fr; gap: 12px; padding: 9px 0 9px 14px; margin-left: 6px; border-left: 2px solid var(--trait-fin); position: relative; font-size: 14px; }
.fil-executions li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.fil-executions li.ko::before { background: var(--danger); }
.fil-executions li.ko strong { color: var(--danger); }
.fil-executions .quand { color: var(--encre-douce); font-size: 13px; line-height: 1.3; }
.fil-executions .quoi strong { display: block; font-weight: 600; }
.fil-executions pre { white-space: pre-wrap; font-size: 12.5px; background: var(--surface-2); padding: 8px 10px; border-radius: var(--rayon); margin: 6px 0 0; }
.fil-executions details summary { cursor: pointer; font-size: 12.5px; color: var(--accent); }
.frequences input[type=time] { max-width: 160px; }


/* ---- tableaux : lisibilite ---- */
td.mono { white-space: nowrap; }
.tableau-cadre { overflow: visible; }
@media (max-width: 1200px) { .tableau-cadre { overflow-x: auto; } }

/* ======================================================================= */
/*  Listes de choix (Tom Select) aux couleurs de l'application              */
/* ======================================================================= */
.ts-wrapper { width: 100%; }
.ts-wrapper.single .ts-control, .ts-wrapper .ts-control {
  min-height: 40px; padding: 8px 34px 8px 12px; border: 1px solid #cfd8d6; border-radius: 8px;
  background: var(--surface) no-repeat right 12px center / 12px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%234a5c59' stroke-width='1.6'/%3E%3C/svg%3E"); box-shadow: 0 1px 1px rgba(18,33,31,.04);
  font: inherit; font-size: 14.5px; color: var(--encre); cursor: pointer; display: flex; align-items: center; flex-wrap: nowrap;
}
.ts-wrapper.single .ts-control::after { display: none; }
.ts-wrapper .ts-control:focus, .ts-wrapper .ts-control:focus-visible { outline: none; }
.ts-wrapper .ts-control:hover { border-color: #aebcb9; }
.ts-wrapper.focus .ts-control { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-pale); }
.ts-wrapper.dropdown-active .ts-control { border-radius: 8px; }
.ts-control > .item { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-wrapper .ts-control > input, .ts-wrapper .ts-control > input:focus, .ts-wrapper .ts-control > input:hover {
  flex: 1 1 auto; width: auto; min-width: 4ch; min-height: 0; height: auto; margin: 0; padding: 0; border: none; border-radius: 0;
  background: none; box-shadow: none; outline: none; font: inherit; font-size: 14.5px; color: var(--encre);
}
.ts-control > input::placeholder { color: #9fadaa; }
.ts-wrapper.has-items .ts-control > input { position: absolute; opacity: 0; }
.ts-wrapper.input-active .ts-control > input, .ts-wrapper.dropdown-active .ts-control > input { position: static; opacity: 1; }
.ts-wrapper.dropdown-active.has-items .ts-control > .item { display: none; }

.ts-dropdown {
  margin-top: 6px; border: 1px solid var(--trait); border-radius: 10px; background: var(--surface);
  box-shadow: 0 16px 36px -14px rgba(18,33,31,.35); overflow: hidden; z-index: 60; font-size: 14px;
}
.ts-dropdown .ts-dropdown-content { max-height: 300px; padding: 6px; }
.ts-dropdown .option { padding: 8px 10px; border-radius: 6px; color: var(--encre); cursor: pointer; }
.ts-dropdown .option.active { background: var(--accent-pale); color: var(--accent-fonce); }
.ts-dropdown .option.selected { font-weight: 650; }
.ts-dropdown .option.selected::after { content: "\2713"; float: right; color: var(--accent); }
.ts-dropdown .option[data-value=""] { color: var(--encre-pale); }
.ts-dropdown .highlight { background: #fff1c2; border-radius: 3px; color: inherit; }
.ts-dropdown .no-results { padding: 10px; color: var(--encre-pale); }
.champ.en-erreur .ts-control { border-color: var(--danger); background-color: #fffafa; }
.vente td .ts-control { min-height: 38px; }

/* ---- formulaires : une largeur de lecture, pas tout l'ecran ---- */
.formulaire-sections { max-width: 1120px; }
.section-formulaire { grid-template-columns: 200px minmax(0, 1fr); }
.section-formulaire > h2 { font-size: 14.5px; letter-spacing: -.005em; }

/* Les champs restent dans l'ordre du formulaire (pas de remontee automatique pour combler les trous). */

/* Page de formulaire : en-tete, alertes et formulaire sur la meme largeur. */
.contenu:has(> form > .formulaire-sections), .contenu:has(> .formulaire-sections) { max-width: 1180px; }

/* Choix de fichier : un vrai bouton plutot que celui du systeme. */
input[type=file] { padding: 5px; cursor: pointer; color: var(--encre-douce); font-size: 13.5px; }
input[type=file]::file-selector-button {
  margin-right: 12px; padding: 6px 14px; border: 1px solid var(--trait); border-radius: 6px; background: var(--surface);
  color: var(--encre); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
}
input[type=file]::file-selector-button:hover { background: var(--surface-2); }

/* ---- nouveau dossier de vente : le client a gauche, la demande a droite ---- */
.demande { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; max-width: 1180px; }
@media (min-width: 1000px) { .demande { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); } }
.demande > .carte { margin: 0; padding: 22px 24px; }
.demande h2 { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; font-size: 16px; }
.demande h2 .numero { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; }
.demande-saisie > .aide { margin: -6px 0 18px; }
.fiche-client { margin-top: 16px; padding: 16px; border-radius: 10px; background: var(--fond); border: 1px solid var(--trait-fin); }
.fiche-client .nom { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.fiche-client .nom a { color: var(--encre); }
.fiche-client dl.infos { font-size: 13.5px; }
.fiche-client .aide { margin-top: 12px; }
.fiche-vide { margin-top: 16px; padding: 22px 16px; border: 1px dashed var(--trait); border-radius: 10px;
  text-align: center; color: var(--encre-pale); font-size: 13.5px; display: grid; gap: 6px; }
.fiche-vide[hidden] { display: none; }
.contenu:has(> .demande), .contenu:has(> form.demande) { max-width: 1180px; }

/* Option de liste avec une ligne de detail (code et CCP d'un client...). */
.option-riche { display: grid; line-height: 1.3; }
.option-riche small { color: var(--encre-pale); font-size: 12px; margin-top: 2px; }
.ts-dropdown .option.active .option-riche small { color: var(--accent-fonce); }

/* ---- formulaire long en onglets (client, fournisseur, article...) ---- */
.formulaire-onglets { padding: 0; max-width: 1120px; }
.contenu:has(> form > .formulaire-onglets) { max-width: 1180px; }
.onglets-formulaire { margin: 0; padding: 0 16px; gap: 2px; border-bottom: 1px solid var(--trait); background: #fbfcfc;
  border-radius: var(--rayon) var(--rayon) 0 0; overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap; scrollbar-width: thin; }
.onglets-formulaire .onglet { padding: 14px 14px 12px; white-space: nowrap; font-weight: 550; border-bottom-width: 3px; margin-bottom: -1px; }
.onglets-formulaire .onglet .rang { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-2); color: var(--encre-douce); font-size: 12px; font-weight: 700; }
.onglets-formulaire .onglet.actif .rang { background: var(--accent); color: #fff; }
.onglets-formulaire .onglet.en-erreur .rang { background: var(--danger); color: #fff; }
.onglets-formulaire .onglet.en-erreur::after { content: none; }
.formulaire-onglets > .panneau { padding: 26px 28px 20px; }
.pied-onglet { display: flex; justify-content: space-between; gap: 8px; margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--trait-fin); }

/* « + Creer ... » en bas d'une liste de choix */
.ts-dropdown .create { padding: 9px 10px; border-radius: 6px; color: var(--accent-fonce); font-weight: 600; cursor: pointer; }
.ts-dropdown .create.active { background: var(--accent-pale); }

/* Bouton « + Creer un(e) nouveau(elle) ... » toujours en bas d'une liste de choix */
.ts-pied-creation { border-top: 1px solid var(--trait-fin); padding: 6px; background: var(--surface); }
.ts-pied-creation button { width: 100%; text-align: left; padding: 9px 10px; border: none; border-radius: 6px; background: none;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--accent-fonce); cursor: pointer; }
.ts-pied-creation button:hover { background: var(--accent-pale); }

/* Fenetre de creation */
.dialogue-creation { width: min(420px, calc(100vw - 32px)); border: none; border-radius: 12px; padding: 0;
  box-shadow: 0 24px 60px -20px rgba(18,33,31,.45); color: var(--encre); }
.dialogue-creation::backdrop { background: rgba(13,26,25,.45); }
.dialogue-creation form { padding: 22px 24px; display: grid; gap: 14px; }
.dialogue-creation h2 { font-size: 17px; }
.dialogue-series { width: min(560px, calc(100vw - 32px)); }
.dialogue-series .contenu-dialogue { padding: 22px 24px; display: grid; gap: 12px; }
.dialogue-series textarea { width: 100%; min-height: 280px; resize: vertical; font-size: 13px; line-height: 1.6; }
.etat-series { font-size: 13px; color: var(--encre-douce); }
.etat-series.complet { color: var(--accent-fonce); font-weight: 600; }
.fiche-client-vd { margin-top: 6px; padding: 8px 10px; border-radius: 6px; background: var(--fond-doux, rgba(0,0,0,.03)); line-height: 1.6; }
.fiche-client-vd[hidden] { display: none; }
.etat-series.bloque { color: var(--danger); font-weight: 600; }
.dialogue-series [data-dialogue-quantite] { justify-self: start; }
.dialogue-series [data-dialogue-quantite][hidden] { display: none; }
.dialogue-creation .pied { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* La coche du choix en cours reste sur la ligne, meme avec une ligne de detail. */
.ts-dropdown .option { position: relative; padding-right: 30px; }
.ts-dropdown .option.selected::after { float: none; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }

/* Champ en lecture seule (calcule) : il ne doit pas avoir l'air modifiable. */
input[readonly], input:disabled, select:disabled, textarea[readonly] {
  background-color: var(--surface-2); color: var(--encre-douce); border-style: dashed; cursor: default; box-shadow: none;
}

/* Sections d'un formulaire place dans une carte deja encadree (ex. Depots) */
.carte > form > .section-formulaire { padding: 18px 0; }
.carte > form > .section-formulaire:first-of-type { padding-top: 4px; }

/* ---- pieces jointes ---- */
.liste-pieces { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.liste-pieces li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--trait-fin);
  border-radius: 8px; background: var(--surface); }
.liste-pieces .nom { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.liste-pieces .nom::before { content: "\1F4CE"; margin-right: 6px; }
.liste-pieces .aide { margin: 0; flex: 1; white-space: nowrap; }
.liste-pieces form { margin: 0; }
.pieces-jointes .carte-titre { align-items: center; }
.pieces-jointes .carte-titre h2 { display: flex; align-items: center; gap: 8px; }
.ajout-pieces { margin: 0; }
.ajout-pieces label { margin: 0; cursor: pointer; color: var(--accent-fonce); }

/* ---- fiche du dossier : tableau des articles ---- */
.tableau-articles { font-size: 13.5px; }
.tableau-articles th, .tableau-articles td { padding: 9px 8px; }
.tableau-articles th:first-child { width: 52px; }
.tableau-articles td.photo { padding-top: 6px; padding-bottom: 6px; }
.tableau-articles th.centre, .tableau-articles td.centre { text-align: center; }
.tableau-articles td.fort { font-weight: 650; }
.tableau-articles tfoot td { border-bottom: none; color: var(--encre-douce); padding-top: 6px; padding-bottom: 6px; }
.tableau-articles tfoot tr:first-child td { border-top: 1px solid var(--trait); padding-top: 10px; }
.tableau-articles tfoot tr.total td { color: var(--encre); font-weight: 700; border-top: 1px solid var(--trait-fin); padding-top: 10px; }

/* ---- tableaux de saisie d'articles (achats, transferts) : colonnes fixes, champs pleine largeur ---- */
.tableau-saisie { table-layout: fixed; min-width: 760px; }
.tableau-saisie th, .tableau-saisie td { padding: 8px; vertical-align: top; }
.tableau-saisie td input:not([type=checkbox]), .tableau-saisie td select, .tableau-saisie td .ts-wrapper { width: 100%; min-width: 0; }
.tableau-saisie td.nb input { text-align: right; }
.tableau-saisie th.centre, .tableau-saisie td.centre { text-align: center; }
.tableau-saisie td.centre input[type=checkbox] { margin-top: 10px; }

/* Bon de commande : bloc Montants (remise globale en % et en DA regroupees, unites affichees). */
.montants-grille { display: grid; grid-template-columns: minmax(280px, 2fr) minmax(180px, 1fr); gap: 16px 20px; align-items: start; }
@media (max-width: 760px) { .montants-grille { grid-template-columns: 1fr; } }
.saisies-remise { display: flex; align-items: center; gap: 8px; }
.saisies-remise .saisie-unite { flex: 1; }
.saisie-unite { position: relative; display: flex; align-items: stretch; }
.saisie-unite input { flex: 1; min-width: 0; text-align: right; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.saisie-unite .unite { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--trait);
  border-left: 0; border-radius: 0 var(--rayon) var(--rayon) 0; background: var(--fond); color: var(--encre-pale);
  font-size: 12.5px; font-weight: 600; min-width: 38px; justify-content: center; }
.montants-commande .discret { font-weight: 400; color: var(--encre-pale); }
.resume-remise { display: block; margin-top: 2px; font-weight: 600; color: var(--danger); }
