/* achats — styles propres au module (0.4.16 : fournisseurs, paramètres ;
   0.4.19 : en-tête et filtres du modèle du stock, logo, pays, marges des
   feuilles de réglage). Les composants communs couvrent tableaux, feuilles,
   onglets, notes et boutons-icônes (.btn.icone-revele). */
.ach-onglet { margin-top: 14px; }
.ach-onglet > .sheet + .sheet { margin-top: 12px; }

/* 0.4.19 — K.sheet pose son corps SANS marge : c'est voulu pour un tableau,
   qui porte ses propres retraits, pas pour des champs. Collés au bord, et
   coupés par l'overflow: clip de la feuille dès qu'ils débordaient, les
   champs des conditions de paiement « mordaient » sur le cadre. */
.ach-corps { padding: 2px 18px 16px; min-width: 0; }
.ach-corps > :first-child { margin-top: 0; }
.ach-corps + .tablewrap, .ach-corps + table { margin-top: 0; }

/* Grille de formulaire : deux à trois champs par ligne selon la largeur,
   un seul sous 560 px. Les champs larges (raison sociale, adresse, numéro
   de compte) prennent deux colonnes. */
.ach-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 12px; }
.ach-grille .field { min-width: 0; }
.ach-large { grid-column: span 2; }
@media (max-width: 560px) { .ach-large { grid-column: auto; } }

/* Lignes d'échéance d'une condition : une grille à colonnes fixes, qui tient
   dans la feuille à toute largeur. Sous 640 px : deux champs par ligne. */
.ach-echs { display: flex; flex-direction: column; gap: 8px; }
.ach-ech {
  display: grid; align-items: end; gap: 8px 10px;
  grid-template-columns: 22px minmax(70px, 1fr) minmax(70px, 1fr) minmax(170px, 2.2fr) minmax(70px, 1fr) 32px;
  padding: 8px 10px; border-radius: var(--r-ctl); background: var(--panneau); box-shadow: 0 0 0 1px var(--trait2, var(--trait));
}
.ach-ech .field { min-width: 0; }
.ach-ech .inp { min-width: 0; }
.ach-ech-n { align-self: center; color: var(--encre3); font: 500 12px/1 var(--mono); text-align: center; }
.ach-ech-x { align-self: end; width: 32px; height: 38px; padding: 0; justify-content: center; }
@media (max-width: 640px) {
  .ach-ech { grid-template-columns: 1fr 1fr; }
  .ach-ech-n { grid-column: 1 / -1; text-align: left; }
  .ach-ech .field:nth-of-type(3) { grid-column: 1 / -1; }
  .ach-ech-x { grid-column: 2; justify-self: end; }
}

/* Simulation d'échéancier : montant, date, bouton — même garde-fou. */
.ach-sim { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px 12px; align-items: end; }
.ach-sim .field { min-width: 0; }

/* Un compte bancaire : une carte par compte, le principal souligné. */
.ach-compte { padding: 10px 12px; margin: 0 0 8px; border-radius: var(--r-ctl);
  background: var(--panneau); box-shadow: 0 0 0 1px var(--trait); }
.ach-compte.principal { box-shadow: 0 0 0 1px var(--encre); }
.ach-compte .hint { margin: 4px 0 0; }
.ach-gestes, .ach-rejet { gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.ach-rejet .inp { flex: 1 1 240px; min-width: 0; }
.ach-role { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.ach-role .inp { width: 120px; }

/* ---- Liste : vignette du logo ---- */
.ach-tbl td.ach-c-logo { width: 44px; padding-right: 0; }
.ach-vignette {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 7px;
  object-fit: contain; background: var(--papier); box-shadow: 0 0 0 1px var(--trait); vertical-align: middle;
}
.ach-vignette.vide { background: var(--voile2); color: var(--encre2); font: 600 12px/1 var(--sans); box-shadow: none; }

/* ---- Fiche : logo ---- */
.ach-logo { display: flex; align-items: center; gap: 14px; margin: 0 0 14px; }
.ach-logo-apercu {
  flex: 0 0 88px; width: 88px; height: 88px; border-radius: 12px; display: grid; place-items: center;
  background: var(--panneau); box-shadow: 0 0 0 1px var(--trait); color: var(--encre3); overflow: hidden;
}
.ach-logo-apercu img { max-width: 100%; max-height: 100%; object-fit: contain; }
.ach-logo-cmd { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ach-logo-titre { font-size: var(--fs-xs); color: var(--encre3); }
.ach-logo-cmd .hint { margin: 0; }
.ach-logo-cmd label.btn { cursor: pointer; position: relative; }
.ach-logo-cmd label.btn:focus-within { box-shadow: 0 0 0 2px var(--encre); }
.ach-fichier-cache { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ach-lien { border: 0; background: none; padding: 0; font: inherit; color: var(--encre2);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ach-lien:hover { color: var(--encre); }

/* ---- Filtres (0.4.19, calqués sur ceux du stock) ---- */
.ach-filtres {
  display: flex; flex-direction: column; gap: 10px; margin: 0 0 14px;
  padding: 12px 14px; border-radius: var(--r-ctl); background: var(--panneau); box-shadow: 0 0 0 1px var(--trait);
}
.ach-f-entete { display: flex; align-items: center; justify-content: space-between; }
.ach-f-nom { font-weight: 600; font-size: var(--fs-sm); }
.ach-btn-filtres { position: relative; }
.ach-btn-filtres.ouvert, .ach-btn-filtres.filtre-actif { box-shadow: inset 0 0 0 1px var(--encre); }
.ach-f-compte {
  display: inline-grid; place-items: center; min-width: 17px; height: 17px; padding: 0 4px;
  margin-left: 4px; border-radius: 9px; background: var(--encre); color: var(--panneau);
  font-size: 11px; font-weight: 600; line-height: 1;
}
.ach-f-resume { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 12px; }
.ach-f-titre { font-size: var(--fs-sm); color: var(--encre2); margin-right: 2px; }
.ach-f-pastille, .ach-pays-pastille {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px;
  border-radius: 999px; background: var(--panneau); box-shadow: 0 0 0 1px var(--trait);
  font-size: var(--fs-sm); color: var(--encre);
}
.ach-f-retirer {
  border: 0; background: none; cursor: pointer; color: var(--encre2);
  width: 22px; height: 22px; border-radius: 50%; font-size: 15px; line-height: 1;
}
.ach-f-retirer:hover { background: var(--trait); color: var(--encre); }
.ach-f-retirer:focus-visible { outline: 2px solid var(--encre); outline-offset: 1px; }
.ach-f-crit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.ach-f { display: inline-flex; flex-direction: column; gap: 3px; min-width: 0; }
.ach-f > span:first-child { font-size: var(--fs-xs); color: var(--encre3); }
.ach-f .inp { min-width: 190px; max-width: 260px; }
.ach-f-listes { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.ach-fm { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.ach-fm legend { font-size: var(--fs-xs); color: var(--encre3); padding: 0; margin-bottom: 4px; }
.ach-fm-n {
  display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; margin-left: 4px;
  border-radius: 8px; background: var(--encre); color: var(--panneau); font-size: 10px; font-weight: 600;
}
.ach-fm-liste { max-height: 168px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
  padding: 4px; border-radius: var(--r-ctl); box-shadow: 0 0 0 1px var(--trait); }
.ach-fm-opt { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 4px; font-size: var(--fs-sm); cursor: pointer; }
.ach-fm-opt:hover { background: var(--trait); }
.ach-fm-opt[hidden] { display: none; }
.ach-fm-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ach-fm .btn { align-self: flex-start; }
@media (max-width: 640px) { .ach-f { flex: 1 1 160px; } .ach-f .inp { max-width: none; } }

/* ---- Choix des colonnes ---- */
.ach-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 2px 18px; }
.ach-col {
  display: flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 7px 8px; border-radius: 8px; font-size: 13px; color: var(--encre2);
}
.ach-col:hover { background: var(--voile2); }
.ach-col input { width: 15px; height: 15px; margin: 0; accent-color: var(--encre); cursor: pointer; }
.ach-col.fixe { cursor: default; color: var(--encre3); }
.ach-col.fixe:hover { background: none; }
.ach-col .hint { margin: 0 0 0 auto; font-size: var(--fs-xs); }

/* ---- Paramètres : pays ---- */
.ach-pays-liste { display: flex; flex-wrap: wrap; gap: 6px 8px; }
.ach-pays-pastille { padding-right: 8px; }
.ach-pays-pastille:has(.ach-f-retirer) { padding-right: 4px; }
.ach-pays-pastille .mono { font-family: var(--mono); font-size: 11.5px; color: var(--encre3); }
.ach-pays-pastille .badge { transform: scale(.9); }

/* ---- Pièces d'achat (0.4.20) ------------------------------------------------ */
.achp-barre { margin: 12px 0; }
.achp-recherche { flex: 1 1 320px; max-width: 460px; }
.achp-resume { gap: 8px 20px; flex-wrap: wrap; margin-bottom: 12px; font-size: var(--fs-sm); }
.achp-liees { gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
/* Une ligne de saisie : n°, article, désignation, quantité, prix, remise,
   TVA, retrait. Elle tient dans la fenêtre ; sous 760 px, deux colonnes. */
.achp-ligne { display: grid; grid-template-columns: 1.5em minmax(140px, 1.2fr) minmax(160px, 2fr) repeat(4, minmax(70px, .7fr)) 32px;
  gap: 8px; align-items: end; margin-top: 8px; }
.achp-ligne.sans-prix { grid-template-columns: 1.5em minmax(140px, 1.2fr) minmax(160px, 2fr) minmax(70px, .7fr) 32px; }   /* 0.4.31.P10 (VEN) */
.achp-ligne > .mono { align-self: center; color: var(--encre3); }
.achp-ligne .field { min-width: 0; }
@media (max-width: 760px) {
  .achp-ligne { grid-template-columns: 1fr 1fr; }
  .achp-ligne > .mono, .achp-ligne .achp-des { grid-column: 1 / -1; }
}
.achp-qte { width: 110px; margin-left: auto; }

/* ---- Clôture des achats (0.4.21) ----------------------------------------- */
.achc-barre { gap: 10px 14px; align-items: flex-end; flex-wrap: wrap; margin: 12px 0 16px; }
.achc-passer { gap: 12px; align-items: center; flex-wrap: wrap; margin: 4px 0 20px; }
.achc-annuler { gap: 6px; justify-content: flex-end; }
.achc-annuler .inp { width: 220px; }

/* ---- Importations (0.4.22) ------------------------------------------------ */
/* Une ligne de liquidation : taxe, article, position, base, taux, montant,
   payeur, retrait. Deux colonnes sous 760 px. */
.achi-taxe { display: grid; grid-template-columns: minmax(130px, 1.2fr) minmax(140px, 1.3fr) minmax(100px, 1fr) repeat(3, minmax(70px, .7fr)) minmax(110px, 1fr) 32px;
  gap: 8px; align-items: end; margin-top: 8px; }
.achi-taxe .field { min-width: 0; }
@media (max-width: 760px) { .achi-taxe { grid-template-columns: 1fr 1fr; } }

/* 0.4.31.P10 (VEN) — Coûts à compléter : champs compacts, le bouton « Compléter » reste dans le cadre (passage Brave UIUX-1). */
.cac-tbl .cac-cout input { width: 80px; }
.cac-tbl .cac-motif input { width: 180px; }
