/* =============================================================================
   Listes et fiches du lot C (clients, fournisseurs, articles, tarifs, catalogues) —
   compléments de app.css : tri par colonne, pied de liste, sélection et actions groupées,
   menu « Plus », colonne résumé des fiches, listes imprimées (A4).
   ============================================================================= */

/* Tri par colonne */
.tbl-triable th a.tri { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.tbl-triable th a.tri:hover, .tbl-triable th a.tri.on { color: var(--ink); text-decoration: underline; }
.tri-sens { font-size: 10px; }

/* Cellules de liste */
.adresse-l1 { display: block; font-size: 12px; color: var(--muted); }
.cell-adresse, .cell-nom { white-space: normal; min-width: 160px; }
a.lien-discret { color: inherit; text-decoration: none; }
a.lien-discret:hover { text-decoration: underline; }
.chk-cell { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; cursor: pointer; }
.chk-cell input { width: 18px; height: 18px; }

/* Notes sous les listes (aussi dans articles.css) */
.liste-note { margin: 0; padding: 10px 18px; }

/* Pied de liste : pagination + lignes par page */
.liste-pied { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; padding: 0 18px 4px; }
.liste-pied .pager { padding-left: 0; padding-right: 0; flex-wrap: wrap; }
.liste-pied .pager span[aria-disabled] { opacity: .45; cursor: default; }
.par-page { padding: 0; border: 0; }
.periode { padding: 10px 0 4px; align-items: flex-end; }
.periode .fld input { min-height: 36px; }

/* Barre de sélection (actions groupées) */
.sel-barre { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); background: var(--surface-3); }
.sel-barre > .muted { margin-right: auto; }
.sel-barre.on { background: var(--blue-bg); }
.sel-barre.on > .muted { color: var(--blue-ink); font-weight: 500; }
.sel-barre .btn-sm { margin: 0; }
.btn.danger { color: var(--red-ink); }

/* Menu « Plus » des fiches (style commun dans app.css) */
.actions form { margin: 0; }
.btn[aria-disabled="true"] { color: var(--muted); background: var(--surface-2); cursor: not-allowed; }

/* Ordre de parcours des fiches (ancien bloc « Accès ») */
.ordre-parcours { padding: 6px 0 0; border: 0; }
.ordre-parcours .seg { min-height: 30px; font-size: 12.5px; }

/* Fiche avec colonne résumé */
.fiche-resume { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); gap: 20px; align-items: start; }
.fiche-resume > .fiche-principale { min-width: 0; margin: 0; }
.resume { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.resume .card { margin: 0; }
.resume-dl { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.resume-dl > div { display: flex; justify-content: space-between; gap: 12px; }
.resume-dl dt { color: var(--muted); font-size: 13px; }
.resume-dl dd { margin: 0; text-align: right; font-weight: 500; }
.resume-dl .resume-total { border-top: 1px solid var(--line-2); padding-top: 8px; }
.resume-grand { margin: 4px 0 2px; font-size: 24px; font-weight: 500; }
.resume-docs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.resume-docs li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
@media (max-width: 1099px) {
  .fiche-resume { grid-template-columns: minmax(0, 1fr); }
}

/* =============================================================================
   Statistiques mensuelles (views/partials/stats-mensuelles.php, fiches client, fournisseur, article) :
   tableau à gauche avec ◁ année ▷ dessous, graphique et légende à droite, « Actualiser » en bas à
   droite (captures 022, 119, 154). Option disposition « empile » : ancienne disposition web.
   ============================================================================= */
.stats-cote-a-cote { display: grid; grid-template-columns: minmax(0, max-content) minmax(280px, 1fr); grid-template-areas: "tableau graphe" "tableau actions"; gap: 4px 28px; align-items: start; }
.stats-cote-a-cote > .stats-tableau { grid-area: tableau; min-width: 0; }
.stats-cote-a-cote > .stats-graphe { grid-area: graphe; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.stats-cote-a-cote > .stats-actions { grid-area: actions; justify-self: end; align-self: end; }
.stats-graphe > .bars { flex: 1 1 320px; min-width: 0; max-width: 640px; margin: 4px 0; }
.stats-legende { flex: none; }
.stats-legende .legend { margin: 0; flex-direction: column; align-items: flex-start; gap: 6px; }
.legend-l { display: inline-flex; align-items: center; gap: 6px; }
.stats-annee { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 10px; }
.stats-annee .btn-sm, .stats-actions .btn-sm { margin: 0; }
.stats-annee strong { min-width: 4ch; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); text-align: center; font-size: 15px; }
.stats-tbl th, .stats-tbl td { padding: 3px 12px; }
.stats-tbl thead th, .stats-tbl thead th.num { font-family: var(--font); }
.bars .bars-grille { stroke: var(--line-2); stroke-width: 1; }
.bars .bars-axe { stroke: var(--field); stroke-width: 1; }
.stats-tbl tbody td:first-child { color: var(--ink-2); }
.stats-empile { display: flex; flex-direction: column; }
.stats-empile > .stats-graphe { order: 1; }
.stats-empile > .stats-tableau { order: 2; }
.stats-empile > .stats-actions { order: 3; align-self: flex-end; padding-top: 8px; }
.btn-sm[aria-disabled="true"] { color: var(--muted); background: var(--surface-2); cursor: not-allowed; }
@media (max-width: 899px) {
  .stats-cote-a-cote { grid-template-columns: minmax(0, 1fr); grid-template-areas: "tableau" "graphe" "actions"; }
}

/* =============================================================================
   Fiche client comme l'ancien programme (lot B, captures 010 à 054) : onglets de même hauteur,
   adresse à gauche sans libellés et coordonnées à droite, trois colonnes en Comptabilité,
   grilles numérotées (contacts, exceptions de prix), mouvements avec le choix du type en bas.
   ============================================================================= */
.cl-panneau { min-width: 0; }
.cl-2col { display: grid; grid-template-columns: minmax(0, 55fr) minmax(0, 45fr); gap: 6px 36px; align-items: start; }
.cl-3col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.3fr); gap: 6px 22px; align-items: start; --lbl: 124px; }
.cl-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cl-ligne { display: flex; gap: 6px; min-width: 0; }
.cl-ligne > .fld { flex: 1 1 auto; }
.cl-ligne > .cl-w-forme, .cl-ligne > .cl-w-cp { flex: 0 0 104px; }
.cl-adresse > .cl-w-pays { max-width: 300px; }
.cl-responsable { --lbl: 104px; margin-top: 6px; }
.cl-responsable > label { text-align: left; }
.cl-coord { --lbl: 92px; }
.cl-w-tva > input { max-width: 200px; }
.cl-w-tel > input { max-width: 160px; }
.cl-w-court > input, .cl-w-court > select { max-width: 110px; }
.cl-w-moyen > select { max-width: 200px; }
.cl-tel { display: grid; grid-template-columns: var(--lbl, 92px) minmax(0, 1fr) minmax(0, 1fr) minmax(0, .55fr); gap: 2px 6px; align-items: center; }
.cl-tel > .fld:first-child { display: contents; }
.cl-tel > .fld:first-child > label { padding-right: 4px; }
.cl-tel > .fld:first-child > .fld-err { grid-column: 2 / -1; }

/* Cadre d'en-tête : Famille [code ▼] [libellé] (capture 010) */
.cadre-ligne > .fld.cl-code { flex: 0 0 auto; }
.cl-code select { width: 120px; }
.cl-lib { flex: 1 1 160px; min-width: 0; min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--ink); -webkit-text-fill-color: var(--ink); font: 400 14px var(--font); opacity: 1; }

/* Cases « libellé puis case » (Comptabilité, Adresse de livraison : captures 011, 012) */
.chk.chk-avant { flex-direction: row-reverse; justify-content: flex-end; }
.cl-chk-titre { color: var(--blue-ink); font-weight: 600; }
.cl-cases { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; margin-top: 4px; }
.cl-cases .chk { color: var(--blue-ink); font-weight: 600; font-size: 13px; }
.cl-cases .chk.chk-avant { justify-content: flex-start; text-align: right; }

/* Mémos (Commentaire détaillé, Info) et textes à imprimer */
.cl-textes > .cl-chk-titre { margin-top: 18px; }
.cl-texte-1 textarea { min-height: 150px; }
.cl-texte-2 textarea { min-height: 130px; }
.cl-memo textarea { min-height: 380px; }

/* Grilles numérotées : 3 lignes de contacts, 5 exceptions, en-tête fixe, ascenseur */
.cl-grille { margin-top: 14px; border: 1px solid var(--line); border-radius: 8px; overflow: auto; }
.cl-grille-3 { max-height: 160px; }
.cl-grille-5 { max-height: 236px; }
.cl-grille .tbl thead th { position: sticky; top: 0; z-index: 1; color: var(--blue-ink); font-weight: 600; }
.cl-tbl { counter-reset: ligne; }
.cl-tbl th, .cl-tbl td { padding: 6px 10px; }
.cl-tbl.tbl-edit td { padding: 3px 4px; }
.cl-tbl.tbl-edit input, .cl-tbl.tbl-edit select { min-height: 30px; min-width: 0; }
.cl-tbl.tbl-edit input { min-width: 100px; }
.cl-tbl.tbl-edit .cl-c-email input { min-width: 170px; }
.cl-tbl.tbl-edit select { min-width: 64px; }
.cl-tbl th.col-n, .cl-tbl td.col-n { width: 30px; padding-left: 8px; padding-right: 2px; text-align: right; color: var(--blue-ink); font: 500 12px var(--mono); }
.cl-tbl tbody td.col-n { counter-increment: ligne; }
.cl-tbl tbody td.col-n::before { content: counter(ligne); }
.cl-tbl td.cl-retirer, .cl-tbl th.cl-retirer { width: 34px; text-align: center; }
.cl-tbl .cl-retirer .linkbtn { min-width: 26px; min-height: 26px; text-decoration: none; }
.cl-tbl td.cl-code-c { width: 96px; }
.cl-tbl td.cl-pv-c { width: 76px; }
.cl-tbl .cl-lib-c { min-width: 150px; color: var(--ink-2); white-space: normal; }
.cl-tbl tr.cl-aucun td { padding: 14px 12px; }
.cl-grille-pied { margin: 6px 0 0; }
.cl-btn { margin: 0; min-height: 30px; padding: 0 10px; font-size: 12.5px; }

/* Mouvements : « Liste des … », grille, choix du type en bas (captures 015-020, 023) */
.cl-mvt { display: flex; flex-direction: column; gap: 6px; }
.cl-mvt-titre { margin: 0; min-height: 24px; text-align: center; color: #1D3FD8; font-size: 17px; font-weight: 700; }
.cl-mvt-grille { height: 262px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.cl-mvt-grille .tbl thead th { position: sticky; top: 0; z-index: 1; }
.cl-tbl-mvt th, .cl-tbl-mvt td { padding: 6px 10px; }
.cl-mvt-vide { margin: 0; padding: 48px 12px; text-align: center; color: var(--muted); }
.cl-mvt-choix { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 26px; padding: 2px 2px 0; }
.acces-radios.cl-mvt-types { display: flex; flex-wrap: wrap; gap: 0 22px; }
.cl-mvt-types .acces-r { color: var(--ink-2); font-weight: 500; }
.cl-mvt-types .acces-r[aria-checked="true"] { color: var(--ink); }
.cl-mvt-types[aria-disabled="true"] .acces-r { color: var(--muted); cursor: default; }
.cl-mvt-types[aria-disabled="true"] .acces-r[aria-checked="true"] .acces-o { border-color: #9AA3B2; background: #9AA3B2; }
.cl-case { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; padding: 0 6px; border-radius: 6px; color: var(--ink-2); font-size: 13px; font-weight: 500; text-decoration: none; }
a.cl-case:hover { background: var(--blue-bg); color: var(--ink); }
.cl-case-o { flex: none; width: 15px; height: 15px; border: 1.5px solid #9AA3B2; border-radius: 3px; background: var(--surface); }
.cl-case[aria-checked="true"] .cl-case-o { border-color: var(--primary); background: var(--primary); }
.cl-case[aria-checked="true"] .cl-case-o::after { content: ''; display: block; width: 4px; height: 8px; margin: 1px auto 0; border: solid #FFFFFF; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.cl-case[aria-disabled="true"] { color: var(--muted); cursor: default; }
.cl-mvt-web { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-left: auto; padding-left: 14px; border-left: 1px solid var(--line-2); }
.cl-mvt-web .fld.cl-periode { flex-direction: row; align-items: center; gap: 6px; }
.cl-mvt-web .fld.cl-periode input { width: 150px; min-height: 30px; }
.cl-mvt .pager { padding: 6px 0 0; border-top: 0; }

/* Consultation des clients (captures 030-035) : critère à gauche, Accès à droite, grille, barre du bas */
.cl-consultation { margin: 0; }
.cl-cs-total { flex: none; font-size: 12.5px; color: #C9D3EA; }
.cl-cs-form { margin: 0; }
.cl-cs-tete { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: stretch; }
.cl-cs-cle { display: flex; flex-direction: column; gap: 4px; }
.cl-cs-cle .fld input { max-width: 340px; }
.cl-cs-aide { margin: 0; padding-left: 140px; }
.cl-cs-effacer { margin: 4px 0 0; padding-left: 140px; }
.cl-cs-filtres { padding: 2px 14px 10px; gap: 10px; }
.cl-cs-filtres .fld input, .cl-cs-filtres .fld select { min-height: 34px; }
.cl-cs-segments { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 8px 14px; border-top: 1px solid var(--line-2); border-bottom: 1px solid var(--line); }
.cl-cs-segments .segments, .cl-cs-segments .vues-menu { padding: 0; border: 0; }
.cl-cs-segments .seg { min-height: 30px; }
.cl-cs-grille .tbl td { padding: 7px 10px; }
.cl-cs-grille .tbl th { padding: 8px 10px; }
.cell-rue { white-space: normal; min-width: 140px; }
.cl-consultation .liste-note { padding: 8px 14px; }
.cl-consultation .empty { border-bottom: 1px solid var(--line-2); }

/* Colonne annexe : suivi de la fiche */
.cl-trace { margin: 0; }

@media (min-width: 900px) {
  /* Tous les onglets à la même hauteur : rien ne bouge en passant de l'un à l'autre (fiche dans 1440 × 900). */
  .cl-fiche .fiche-corps { min-height: 446px; }
}
@media (max-width: 899px) {
  .cl-2col, .cl-3col { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .cl-adresse .fld-sans > label.sr { position: static; width: auto; height: auto; overflow: visible; clip: auto; white-space: normal; font-size: 12px; color: var(--muted); }
  .cl-ligne { flex-wrap: wrap; }
  .cl-ligne > .fld { flex: 1 1 160px; }
  .cl-ligne > .cl-w-forme, .cl-ligne > .cl-w-cp { flex: 0 0 110px; }
  .cl-adresse > .cl-w-pays { max-width: none; }
  .cl-tel { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, .6fr); }
  .cl-tel > .fld:first-child > label { grid-column: 1 / -1; padding-right: 0; }
  .cl-w-tva > input, .cl-w-tel > input, .cl-w-court > input, .cl-w-court > select, .cl-w-moyen > select { max-width: none; }
  .cl-cases { grid-template-columns: minmax(0, 1fr); }
  .cl-cases .chk.chk-avant { justify-content: flex-end; }
  .cl-memo textarea { min-height: 220px; }
  .cl-mvt-grille { height: auto; max-height: 420px; }
  .cl-mvt-web { margin-left: 0; padding-left: 0; border-left: 0; }
  .cl-mvt-web .fld.cl-periode input { width: 140px; }
  .cl-code select { width: 104px; }
  .cl-cs-tete { grid-template-columns: minmax(0, 1fr); }
  .cl-cs-aide, .cl-cs-effacer { padding-left: 0; }
  .cl-cs-cle .fld input { max-width: none; }
  .cl-cs-total { display: none; }
}

/* Résumé de l'article (tuiles sous le bandeau) */
.kpis-article { margin: 0 0 16px; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.kpis-article .kpi { padding: 14px 16px; }
.kpis-article .kpi:hover { border-color: var(--line); }
.kpis-article .kpi .v { font-size: 20px; }

/* Onglet titre + interrupteur (tarifs) */
.titre-outils { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.sans-achat .col-achat { display: none; }

/* Page de choix « une commande par fournisseur » */
.propositions { display: flex; flex-direction: column; gap: 16px; }
.propositions .card-h-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

/* Listes imprimées (A4) */
.liste-a4 { background: #FFFFFF; border: 1px solid var(--line); border-radius: 10px; padding: 24px 28px; width: 100%; overflow-x: auto; }
.impression-entete { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 2px solid var(--ink); }
.impression-entete p { margin: 0; }
.impression-societe { font-size: 18px; font-weight: 700; letter-spacing: .02em; }
.impression-titre { text-align: right; }
.impression-titre h2 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.tbl-impression th { background: transparent; color: var(--ink-2); border-bottom: 1px solid var(--ink); }
.tbl-impression td { padding: 5px 8px; white-space: normal; }
.fiche-impression { padding: 12px 0; border-bottom: 1px solid var(--line); break-inside: avoid; }
.fiche-impression h3 { margin: 0 0 10px; font-size: 15px; }
@media (max-width: 599px) {
  .liste-a4 { padding: 14px; }
  .impression-titre { text-align: left; }
}
@media print {
  @page { size: A4 portrait; margin: 12mm 10mm 14mm; }
  .liste-a4 { border: 0; border-radius: 0; padding: 0; overflow: visible; }
  .tbl-impression { font-size: 9pt; }
  .tbl-impression thead { display: table-header-group; }
  .tbl-impression tr { break-inside: avoid; page-break-inside: avoid; }
  .tbl-impression td, .tbl-impression th { padding: 2pt 4pt; }
  .fiche-resume { display: block; }
  .resume, .menu-plus, .ordre-parcours, .sel-barre, .liste-pied, .check-col { display: none !important; }
  a { color: inherit; text-decoration: none; }
}
