/* « La fiche de stock » (page Stock) : la fiche cartonnée d'un article, comme dans le fichier du magasin.
   Au défilement, chaque mouvement écrit sa ligne (entrée, sortie, stock, coût moyen, valeur) ; la jauge suit le stock,
   l'étiquette passe de « OK » à « À surveiller » puis « Bas », l'inventaire et la prévision s'affichent à leur étape. */
.defile { padding-block: var(--space-24); background: var(--papier); }
.defile__grille { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 56px; align-items: start; }

/* Les étapes, comme celles de la liasse */
.defile__etapes { margin: 0; padding: 0; list-style: none; }
.defile__etape { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 4px 16px; min-height: 58vh; align-content: center; padding-block: 24px;
  opacity: .38; transition: opacity .3s ease; }
.defile__etape:first-child { min-height: 48vh; }
.defile__etape.est-active, .defile:not(.defile--active) .defile__etape { opacity: 1; }
.defile__etape .num { grid-row: span 2; width: 36px; height: 36px; display: grid; place-items: center; border: 1.5px solid var(--carbone); border-radius: 50%;
  font: 600 14px/1 var(--font-mono); }
.defile__etape.est-active .num { background: var(--bic); border-color: var(--bic); color: #fff; }
.defile__etape h3 { margin: 4px 0 0; font: 800 clamp(22px, 2vw, 27px)/1.2 var(--font-sans); letter-spacing: -.01em; }
.defile__etape p { grid-column: 2; margin: 10px 0 0; font-size: 17px; line-height: 1.6; max-width: 32em; }
.defile__scene { position: sticky; top: calc(var(--entete) + 36px); }

/* ── La fiche cartonnée ── */
.fiche { --carte: #fbfaf3; position: relative; padding: 34px 26px 22px; border-radius: 4px; background: var(--carte); color: #20253b;
  background-image: repeating-linear-gradient(to bottom, transparent 0 25px, rgba(31, 63, 176, .1) 25px 26px);
  background-position: 0 128px; box-shadow: var(--ombre-soulevee); }
/* L'encoche de la tringle du fichier */
.fiche::before { content: ""; position: absolute; left: 50%; top: -1px; width: 46px; height: 16px; translate: -50% 0; border-radius: 0 0 23px 23px; background: var(--papier);
  box-shadow: inset 0 -1px 0 rgba(29, 35, 64, .15); }
.fiche__tete { display: flex; justify-content: space-between; align-items: end; gap: 16px; padding-bottom: 12px; border-bottom: 2px solid #20253b; }
.fiche__titre { margin: 0; font: 800 20px/1.1 var(--font-sans); text-transform: uppercase; letter-spacing: .06em; }
.fiche__tete dl { display: grid; gap: 2px; margin: 0; font-size: 13px; }
.fiche__tete dl div { display: flex; gap: 8px; justify-content: flex-end; }
.fiche__tete dt { color: #4a5070; }
.fiche__tete dd { margin: 0; font-weight: 700; }
.fiche table { width: 100%; margin-top: 6px; border-collapse: collapse; font-size: 13px; }
.fiche th { padding: 8px 6px 6px; font: 600 10.5px/1.2 var(--font-mono); letter-spacing: .05em; text-transform: uppercase; color: #4a5070; text-align: right; }
.fiche th:nth-child(-n+2) { text-align: left; }
.fiche td { height: 26px; padding: 0 6px; text-align: right; white-space: nowrap; border-bottom: 1px solid transparent; }
.fiche td:nth-child(-n+2) { text-align: left; }
.fiche td:nth-child(2) strong { font-weight: 700; }
.fiche td:nth-child(2) span { color: #4a5070; font-size: 12px; }
.fiche td.chiffre { font-size: 12.5px; }
.fiche__stock { font-weight: 700; }
.fiche tr { transition: opacity .35s ease, background-color .6s ease; }
.defile--active .fiche tr[data-depuis]:not(.est-la) { opacity: 0; }
.fiche tr.est-nouvelle { background-color: rgba(31, 63, 176, .1); }

.fiche__bas { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "jauge etat" "note note"; gap: 10px 18px; align-items: center;
  margin-top: 16px; padding-top: 14px; border-top: 1px dashed rgba(29, 35, 64, .25); }
/* La jauge : le stock sur 100 ramettes, avec le seuil (20) et une fois et demie le seuil (30) */
.jauge { grid-area: jauge; position: relative; height: 14px; border-radius: 7px; background: #e8eaf1; overflow: hidden; }
.jauge__niveau { position: absolute; inset: 0; border-radius: 7px; background: var(--bic); transform-origin: 0 50%; transform: scaleX(var(--niveau, .18));
  transition: transform .6s cubic-bezier(.4, 0, .2, 1); }
.jauge__seuil { position: absolute; z-index: 1; top: -2px; bottom: -2px; left: calc(var(--n) * 100%); width: 2px; background: var(--encre-retard); }
.jauge__seuil--surveiller { background: rgba(143, 84, 0, .4); }
/* L'étiquette d'état, puis l'inventaire et la prévision, superposés : leur place est gardée, rien ne saute */
.fiche__etat { display: contents; }
.statut { grid-area: etat; justify-self: end; padding: 4px 10px; border-radius: 3px; font: 700 13px/1.3 var(--font-sans); transition: opacity .3s ease; }
.statut--ok { background: #dcf0e4; color: var(--encre-payee); }
.statut--surveiller { background: #f8ead2; color: var(--encre-retard); }
.statut--bas { background: #fbe0dc; color: #9b2c2c; }
.inventaire, .prevision { grid-area: note; display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; font-size: 13px; color: #4a5070;
  transition: opacity .3s ease; }
.inventaire b, .prevision b { color: #20253b; }
.prevision b:last-child { color: var(--bic-fonce); }
[data-seulement] { opacity: 0; }
[data-seulement].est-la, .defile:not(.defile--active) [data-seulement].final { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .fiche tr, .jauge__niveau, .statut, .inventaire, .prevision, .defile__etape { transition: none; }
}
/* Téléphone et tablette : la fiche reste en haut, les étapes défilent dessous */
@media (max-width: 900px) {
  .defile__grille { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .defile__scene { order: -1; top: calc(var(--entete) + 4px); z-index: 2; margin-inline: calc(-1 * var(--gouttiere)); padding: 10px var(--gouttiere) 12px;
    background: var(--papier); box-shadow: 0 14px 14px -14px rgba(29, 35, 64, .25); }
  .fiche { padding: 22px 12px 12px; background-position: 0 92px; }
  .fiche__tete { align-items: center; padding-bottom: 8px; }
  .fiche__titre { font-size: 15px; }
  .fiche__tete dl div:not(:first-child) { display: none; }
  .fiche__tete dl { font-size: 11.5px; }
  .fiche table { font-size: 11px; }
  .fiche th { padding: 5px 3px 4px; font-size: 9px; }
  .fiche td { height: 21px; padding: 0 3px; }
  .fiche td.chiffre { font-size: 11px; }
  .fiche td:nth-child(2) span, .fiche th:nth-child(7), .fiche td:nth-child(7) { display: none; }
  .fiche__bas { margin-top: 10px; padding-top: 10px; gap: 10px; }
  .inventaire, .prevision { font-size: 11.5px; gap: 2px 10px; }
  .defile__etape { min-height: 0; padding-block: 34px 70px; }
  .defile__etape:first-child { padding-top: 30px; }
  .defile__etape:last-child { padding-bottom: 50vh; }
}
@media (max-width: 560px) {
  .defile { padding-block: 64px 32px; }
  .defile__etape { grid-template-columns: 36px minmax(0, 1fr); gap: 4px 12px; }
  .defile__etape .num { width: 30px; height: 30px; font-size: 13px; }
  .defile__etape p { font-size: 16px; }
}
