/* Documents : fiche « comme l'ancien programme » (cadre d'en-tête, pied, onglets), grille des lignes, facturation groupée. */
.tbl-lignes td { vertical-align: middle; }
.tbl-lignes tr.texte td { color: var(--ink-2); white-space: normal; }
.tbl-lignes tr.auto td { color: var(--muted); font-size: 12.5px; padding-top: 4px; padding-bottom: 4px; }
.tbl-lignes .input-xs { width: 80px; min-height: 32px; border: 1px solid var(--field); border-radius: 6px; padding: 0 6px; text-align: right; font-family: var(--mono); }
.tbl-edit td[data-champ="total"] { padding-right: 12px; font-family: var(--mono); white-space: nowrap; }
.lignes-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 0; }
.lignes-actions .btn-sm { margin: 0; }

.actions form { margin: 0; }

.bulk { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-2); background: var(--surface-3); }
.bulk .fld { flex: 0 1 180px; }
.bulk .muted { margin-right: auto; align-self: center; }

.menu-phrases .menu { left: 0; right: auto; max-height: 320px; overflow-y: auto; }
.menu-phrases .menu button { white-space: nowrap; }

/* Fil Offre → Commande → Livraison → Facture (O3, C2, L2) */
.fil { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 6px; font-size: 13.5px; }
.badge.comptant { font-weight: 700; letter-spacing: .04em; }


/* Lignes en consultation */
.tbl-lignes tr.retour td { color: var(--red-ink); }
.tbl-lignes tr.on td { background: var(--blue-bg); }
.tbl-lignes .sous-total { float: right; font-family: var(--mono); font-weight: 500; }
.tbl-lignes tfoot td { padding-top: 10px; }
.tbl-lignes td .small { display: block; }

/* Grille en saisie (D4, D7) */
.lignes-outils { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding-bottom: 0; }
.lignes-outils .chk { margin: 0; }
.tbl-edit td.grille-actions { white-space: nowrap; }
.tbl-edit td.grille-actions .linkbtn { min-width: 26px; padding: 0 3px; }
.tbl-edit tr.texte input[data-champ="libelle"] { font-style: italic; }
.tbl-edit td[data-champ="dispo"] { font-family: var(--mono); white-space: nowrap; }
.tbl-edit td[data-champ="dispo"].txt-red { color: var(--red-ink); }
.tbl-edit tr.on td { background: var(--blue-bg); }
.fld-inline { display: inline-flex; align-items: center; gap: 8px; }
.fld-inline input { min-height: 36px; border: 1px solid var(--field); border-radius: 6px; padding: 0 6px; font: inherit; }


/* Note de crédit (F1), prêts (PR3) */
.note-credit > summary { cursor: pointer; list-style: none; }
.note-credit > summary::-webkit-details-marker { display: none; }
.cols-docs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr)); gap: 14px; }
.compta { background: var(--surface-3); }


/* Base externe (Maj+F2, T6) */
.dialog-large { width: 760px; }
.dialog .base-resultats { max-height: 50vh; overflow: auto; }
.dialog .base-resultats tr { cursor: pointer; }
.dialog .base-resultats tr:hover td { background: var(--bg); }
.dialog input[type="search"], .dialog input[type="text"] { width: 100%; min-height: 40px; border: 1px solid var(--field); border-radius: 8px; padding: 0 10px; font: inherit; }

@media (max-width: 599px) {
  .tbl-lignes .sous-total { float: none; display: block; }
}

/* =============================================================================
   Fiche « comme l'ancien programme » (lot D) : cadre d'en-tête, pied, onglets Commentaire,
   Adresse et Financier. Gabarit commun : app.css (« Gabarit commun »).
   ============================================================================= */
.fenetre-doc .fiche-entete { grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); }
.cadre-doc { gap: 4px; }
.cadre-doc .cadre-ligne > .fld { flex: 1 1 230px; }
.cadre-doc .cadre-ligne { gap: 4px 14px; }
.cadre-doc .lbl-m, .cadre-doc { --lbl: 112px; }
.fld-l > .fld-lbl { color: var(--blue-ink); font-weight: 600; text-align: right; line-height: 1.2; font-size: 13.5px; }
.fenetre-doc .fld-valeur { margin: 0; min-height: 34px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.tiers-champ { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tiers-champ > input, .tiers-champ > .combo-champ { flex: 0 0 104px; width: 104px; }
.tiers-nom { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chk-comptant { flex: none; min-height: 0; }
.comptant-rouge { flex: none; color: #C81E1E; font-weight: 700; letter-spacing: .04em; }
.comptant-rouge[hidden] { display: none; }
.cadre-ajouts .fld > label { color: var(--muted); font-weight: 500; }
.fenetre-doc .acces .statut-doc { font-size: 19px; }

/* Bandeau sur la ligne des onglets (une ligne, texte complet en infobulle) */
.onglets-ligne > .bandeau .badge { margin-left: 6px; vertical-align: 1px; }
.onglets-ligne > .bandeau a[data-bandeau-lien] { margin-left: 8px; }
.bandeau-tiers-doc a { color: inherit; }

/* Grille : boutons T / R sous leur colonne, ventilation de la TVA sous la grille */
.tbl-lignes tfoot .tr-pied td { padding: 4px; border-top: 1px solid var(--line); background: var(--surface-3); white-space: nowrap; }
.tbl-lignes tfoot .tr-pied td[data-resume-vers] { white-space: normal; }
.tbl-lignes .tr-btns { white-space: nowrap; }
.tbl-lignes .tr-btns .linkbtn { min-width: 28px; min-height: 28px; padding: 0 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.tbl-lignes .tr-enregistrer { text-align: right; }
.ventilation { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 16px; margin: 6px 2px 0; font-size: 12.5px; color: var(--ink-2); }
.lignes-outils { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 8px; }
.lignes-outils .btn-sm { margin: 0; }
.lignes-aide { margin-left: auto; }
.fiche-corps .lignes-actions { padding: 8px 0 0; }

/* Pied : boutons métier, boîtes de totaux, cases à droite */
.btn-pied, .btn-xs { min-height: 32px; padding: 0 12px; font-size: 13px; gap: 6px; }
.pied-action .btn-pied { min-height: 32px; }
.btn-pied[aria-disabled="true"], .btn-xs[aria-disabled="true"] { color: #A8AFBC; background: var(--surface); border-color: var(--line); cursor: not-allowed; }
.pied-seul .btn-large { flex: 1 1 auto; justify-content: center; max-width: 360px; }
.pied-droite { justify-content: flex-end; margin-top: 4px; }
.fiche-pied .fld-l { --lbl: 92px; }
.fiche-pied .pied-champs .fld { flex: 1 1 200px; }
.pied-totaux dd.dd-double { display: flex; gap: 6px; padding: 0; border: 0; background: none; }
.pied-boite { display: inline-block; min-width: 52px; padding: 3px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); font-family: var(--mono); text-align: right; }
.pied-totaux .pied-boite.grand { flex: 1 1 auto; font-weight: 600; }
input.pied-boite { width: 64px; min-height: 30px; font: inherit; font-family: var(--mono); }
.pied-totaux-zone .pied-fld-total { margin-top: 4px; --lbl: auto; grid-template-columns: auto minmax(0, 150px); justify-content: end; }
.fiche-pied .chk-pied { flex-direction: row-reverse; gap: 8px; color: var(--blue-ink); font-weight: 600; font-size: 13.5px; }
.pied-cases .fld-devise { --lbl: 60px; width: 200px; }
.pied-mention { margin: 0; color: var(--blue-ink); font-weight: 600; }
.fiche-pied .franco { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; justify-content: flex-end; margin-top: 4px; font-size: 12px; }
.fiche-pied .franco meter { width: 160px; height: 12px; }
.fld-solde { flex: 0 1 200px; }

/* Onglet Commentaire : champs d'origine à gauche, compléments du web à droite */
.commentaire-doc { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 12px 20px; align-items: start; }
.commentaire-doc.sans-complements { grid-template-columns: minmax(0, 1fr); }
.commentaire-doc[hidden] { display: none; }
.cm-origine { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cm-origine .fld-demi { max-width: 620px; }
.cm-origine .fld-l.fld-sans.fld-aligne { grid-template-columns: var(--lbl, 120px) minmax(0, 1fr); }
.cm-origine .fld-aligne > input { grid-column: 2; }
.cm-origine .fld-memo textarea { min-height: 150px; }
.cm-complements { display: flex; flex-direction: column; gap: 6px; --lbl: 104px; }

/* Onglet Adresse : une colonne étroite sans libellés visibles (captures 063, 075, 124) */
.adresse-doc { display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
.adresse-doc[hidden] { display: none; }
.adresse-bloc { display: flex; flex-direction: column; gap: 6px; }
.adresse-ligne { display: flex; gap: 6px; min-width: 0; }
.adresse-ligne > .fld { flex: 1 1 auto; min-width: 0; }
.adresse-ligne > .ad-forme { flex: 0 0 120px; }
.adresse-ligne > .ad-cp { flex: 0 0 100px; }
.adresse-bloc .ad-pays { max-width: 260px; }

/* Onglet Financier : boutons à gauche, Total payé et Reste à payer à droite */
.financier-grille { min-height: 180px; max-height: 312px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.tbl-financier tbody tr[data-paiement] { cursor: pointer; }
.tbl-financier tbody tr.on td { background: var(--blue-bg); }
.tbl-financier tbody tr:focus { outline: 2px solid var(--primary); outline-offset: -2px; }
.financier-doc .financier-pied { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; padding-top: 10px; }
.fin-boutons { display: flex; gap: 4px; }
.fin-btn { min-width: 34px; justify-content: center; padding: 0 8px; }

/* Compléments du web sous la fenêtre (État, suite des documents ; cartes propres au type) */
.doc-annexe .etat { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.doc-annexe .fil { margin-top: 10px; }
.doc-suite { max-width: 1120px; display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.doc-suite .achats-card, .doc-suite > .card, .doc-suite .cols-docs { margin-top: 0; }
.suivi-doc { display: flex; flex-direction: column; gap: 12px; }
.suivi-doc[hidden] { display: none; }

@media (max-width: 899px) {
  .fenetre-doc .fiche-entete { grid-template-columns: minmax(0, 1fr); }
  .commentaire-doc { grid-template-columns: minmax(0, 1fr); }
  .cm-origine .fld-l.fld-sans.fld-aligne { display: flex; }
  .pied-cases .fld-devise { width: auto; }
  .lignes-aide { margin-left: 0; }
  .ventilation { justify-content: flex-start; }
}

/* Fenêtre d'un document à 1440 × 900 : 8 lignes visibles dans la grille (capture 254), le pied reste à l'écran. */
@media (min-width: 900px) {
  .fenetre-doc .grille-lignes { min-height: 0; height: 296px; max-height: none; }
  .fenetre-doc .fiche-corps { padding-top: 8px; padding-bottom: 8px; }
  .fenetre-doc .tbl-lignes td, .fenetre-doc .tbl-lignes th { padding-top: 5px; padding-bottom: 5px; }
}
@media (min-width: 900px) {
  .fiche-pied .fld input, .fiche-pied .fld select { min-height: 30px; }
  .fiche-pied { padding-top: 8px; padding-bottom: 8px; gap: 6px 18px; }
  .fiche-pied .pied-champs, .fiche-pied .pied-cases { gap: 5px; }
  .fenetre-doc .bf-btn { min-width: 50px; padding: 4px 3px; }
}
/* Grille dans la fenêtre (1120 px) : cellules serrées, libellé qui prend la place restante (texte complet en infobulle) */
.fenetre-doc .tbl-lignes th, .fenetre-doc .tbl-lignes td { padding-left: 6px; padding-right: 6px; }
.fenetre-doc .tbl-lignes { width: 100%; }
.fenetre-doc #lignes-consultation td.col-lib { max-width: 1px; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fenetre-doc .tbl-lignes .input-xs { width: 64px; min-height: 28px; }
.fenetre-doc .tbl-lignes th.col-lib { min-width: 160px; }
/* Grille de saisie dans la fenêtre : champs resserrés pour tenir à 1440 px avec les actions de ligne */
.fenetre-doc .tbl-edit.tbl-lignes td { padding: 3px 3px; }
.fenetre-doc .tbl-edit.tbl-lignes .col-art input { min-width: 0; width: 100px; }
.fenetre-doc .tbl-edit.tbl-lignes .col-lib input { min-width: 134px; }
.fenetre-doc .tbl-edit.tbl-lignes .col-q input { min-width: 0; width: 64px; }
.fenetre-doc .tbl-edit.tbl-lignes .col-pct input { min-width: 0; width: 58px; }
.fenetre-doc .tbl-edit.tbl-lignes .col-pu input { min-width: 0; width: 84px; }
.fenetre-doc .tbl-edit.tbl-lignes .col-u select, .fenetre-doc .tbl-edit.tbl-lignes .col-tva select, .fenetre-doc .tbl-edit.tbl-lignes .col-d select { padding: 0 0 0 4px; }
.fenetre-doc .tbl-edit td.grille-actions .linkbtn { min-width: 22px; padding: 0 2px; }
.fenetre-doc .tbl-edit.tbl-lignes th, .fenetre-doc .tbl-edit.tbl-lignes td.ro { font-size: 12.5px; }
.fenetre-doc .tbl-lignes thead th { white-space: normal; line-height: 1.15; vertical-align: bottom; }
.fenetre-doc .tbl-edit td.grille-actions { padding-left: 0; padding-right: 0; }
.fenetre-doc .tbl-edit td.grille-actions .linkbtn { min-width: 20px; min-height: 26px; }
.fiche-pied .fld-large { flex: 1 1 100%; max-width: 560px; }
.fiche-pied .franco { flex-wrap: nowrap; white-space: nowrap; }
.fiche-pied .franco meter { width: 120px; }
@media (min-width: 900px) {
  .fenetre-doc .fiche-pied { grid-template-columns: auto minmax(0, 1.25fr) minmax(320px, 1fr) minmax(0, .75fr); }
  .fenetre-doc .pied-totaux dt { white-space: nowrap; }
  .fenetre-doc .pied-totaux dd { min-width: 110px; }
}
/* Rien ne bouge d'un onglet à l'autre : le pied garde sa place (hauteur de l'onglet des lignes). */
@media (min-width: 900px) {
  .fenetre-doc .fiche-corps > [role="tabpanel"] { min-height: 324px; }
  .fenetre-doc form[data-fiche] .fiche-corps > [role="tabpanel"] { min-height: 364px; }
}
@media (max-width: 899px) {
  .fld-l > .fld-lbl { text-align: left; }
  .tiers-champ > input, .tiers-champ > .combo-champ { flex-basis: 120px; width: 120px; }
}
.fiche-pied .pied-action > .fld-paye, .fiche-pied .pied-action > .fld-solde { flex: 1 1 130px; }
.fiche-pied .pied-action > .fld-solde { --lbl: 44px; }
.fiche-pied .pied-action > .fld-paye .pied-boite, .fiche-pied .pied-action > .fld-solde .pied-boite { width: 100%; }

/* Valeur affichée comme un champ grisé (« Facture n° » du pied, capture 081) : le cadre reste visible même vide. */
.fenetre-doc .fld-valeur.fld-cadre { min-width: 96px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); }
