/* Démo VM Industries : fiches de production. Charte VMI (vert #7FCB28, texte #404040, Montserrat). */
:root {
  --vert: #7fcb28;
  --vert-fonce: #3e7a0c;
  --vert-pale: #eef7e3;
  --sur-vert: #142306;
  --ambre: #febd33;
  --ambre-fonce: #6e4b00;
  --ambre-pale: #fff4d8;
  --rouge: #d7244c;
  --reglage: #6e8aa6;
  --texte: #404040;
  --titre: #23272a;
  --gris: #646c72;
  --trait: #d5dade;
  --fond: #e7eaec;
  --blanc: #fff;
  --encre: #22409a;
  --ombre-papier: 0 1px 2px rgb(30 40 50 / 0.1), 0 22px 44px -18px rgb(30 40 50 / 0.42);
  --bandeau: 96px; /* place laissée au bandeau Grafen injecté en bas de page */
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--fond);
  color: var(--texte);
  font: 400 15px/1.5 Montserrat, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-variant-numeric: tabular-nums lining-nums;
  overflow-x: hidden;
}
h1, h2, h3 { color: var(--titre); margin: 0; }
h1 { font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 14px; font-weight: 600; margin-top: 22px; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--titre); outline-offset: 2px; }

.evitement { position: absolute; left: -999px; top: 8px; z-index: 50; background: var(--blanc); padding: 8px 14px; border-radius: 8px; }
.evitement:focus { left: 16px; }
.invisible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.noscript { padding: 24px; }
.ico { width: 20px; height: 20px; flex: none; }
.nowrap { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }

/* Barre du haut et étapes */
.barre {
  display: flex; align-items: center; gap: 18px;
  padding: 12px 24px; background: var(--blanc); border-bottom: 1px solid var(--trait);
}
.barre__logo { display: block; height: 34px; width: auto; }
.barre__titre { display: flex; flex-direction: column; line-height: 1.25; padding-left: 18px; border-left: 1px solid var(--trait); }
.barre__titre strong { color: var(--titre); font-size: 16px; }
.barre__titre span { font-size: 13px; color: var(--gris); }
.barre__utilisateur { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--titre); }

.etapes { background: var(--blanc); border-bottom: 1px solid var(--trait); overflow-x: auto; scrollbar-width: none; }
.etapes ol { display: flex; gap: 4px; margin: 0 auto; padding: 0 16px; list-style: none; max-width: 1320px; }
.etapes button {
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
  min-height: 52px; padding: 0 14px; border: 0; background: none; cursor: pointer;
  color: var(--gris); font-size: 14px; font-weight: 600; box-shadow: inset 0 -3px 0 transparent;
}
.etapes button:hover { color: var(--titre); }
.etapes button:focus-visible { outline-offset: -3px; }
.etapes__n {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  border: 1.5px solid #aeb5ba; font-size: 13px;
}
.etapes button.faite .etapes__n { background: var(--vert-pale); border-color: var(--vert); color: var(--vert-fonce); }
.etapes button[aria-current] { color: var(--titre); box-shadow: inset 0 -3px 0 var(--vert); }
.etapes button[aria-current] .etapes__n { background: var(--vert); border-color: var(--vert); color: var(--sur-vert); }

main { max-width: 1320px; margin: 0 auto; padding: 28px 24px var(--bandeau); }
#vue:focus, #vue:focus-visible { outline: none; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 50px; padding: 0 22px; border-radius: 10px; border: 1.5px solid transparent;
  font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn--vert { background: var(--vert); color: var(--sur-vert); }
.btn--vert:hover { background: #72bb20; }
.btn--sec { background: var(--blanc); border-color: #aeb5ba; color: var(--titre); }
.btn--sec:hover { border-color: var(--titre); }

/* Mise en page commune */
.ecran { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 36px; align-items: start; }
.intro { margin: 8px 0 22px; color: var(--gris); max-width: 62ch; }
.aide { margin: 22px 4px 0; font-size: 14px; color: var(--gris); max-width: 60ch; }

/* Fiche papier */
.fiche { display: block; width: 100%; height: auto; }
.f-papier { fill: #fff; }
.f-cadre { fill: none; stroke: #7d868d; stroke-width: 1.3; }
.f-trait { stroke: #9aa2a8; stroke-width: 1; }
.f-quart { stroke: #dde1e4; stroke-width: 0.8; stroke-dasharray: 2 3; }
.f-label { font: 500 11px Montserrat, sans-serif; fill: #6b7379; }
.f-option { font: 500 13px Montserrat, sans-serif; fill: #2a2e33; }
.f-titre { font: 600 22px Montserrat, sans-serif; fill: #23272a; }
.f-titre2 { font: 600 15px Montserrat, sans-serif; fill: #23272a; }
.f-aide { font: 400 10.5px Montserrat, sans-serif; fill: #6b7379; }
.f-entete { font: 600 12px Montserrat, sans-serif; fill: #2a2e33; text-anchor: middle; }
.f-heure { font: 600 12px Montserrat, sans-serif; fill: #4a5157; }
.hw { font-family: Kalam, 'Comic Sans MS', cursive; font-size: 27px; fill: var(--encre); }
.hw--petit { font-size: 14px; }
.hw--note { font-size: 17px; }
.hw-trait { fill: none; stroke: var(--encre); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.papier-pose { margin: 6px 10px 0; background: #fff; box-shadow: var(--ombre-papier); transform: rotate(-2.2deg); }
.feuille { position: relative; background: #fff; box-shadow: var(--ombre-papier); }

/* Cadres de lecture posés sur la fiche */
.lu { fill: rgb(127 203 40 / 0.1); stroke: var(--vert); stroke-width: 2.5; }
.lu--doute { fill: rgb(254 189 51 / 0.28); stroke: var(--ambre); stroke-width: 3.5; }
.lu--evt { fill: none; stroke-width: 2; }
.lu--marche { stroke: var(--vert); }
.lu--arret { stroke: var(--rouge); }
.lu--reglage { stroke: var(--reglage); }
.lu--defaut { stroke: var(--ambre); }
.balayage { fill: var(--vert); opacity: 0; }
[data-valide] .lu--doute { fill: rgb(127 203 40 / 0.16); stroke: var(--vert); stroke-width: 2.5; }
[data-valide] .loupe { display: none; }

.loupe {
  position: absolute; left: 3%; top: 30.5%; width: 46%; max-width: 230px;
  background: #fff; border: 3px solid var(--ambre); border-radius: 14px;
  box-shadow: 0 16px 34px -14px rgb(30 40 50 / 0.5); overflow: hidden;
}
.loupe .fiche { aspect-ratio: 52 / 38; }
.loupe span {
  display: block; padding: 4px 10px 6px; background: var(--ambre); color: var(--ambre-fonce);
  font-size: 13px; font-weight: 700; text-align: center;
}

/* Écran 1 : fiches du poste */
.fiches { list-style: none; margin: 0; padding: 0; background: var(--blanc); border: 1px solid var(--trait); border-radius: 12px; overflow: hidden; }
.fiche-ligne {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) auto; align-items: center; gap: 4px 14px;
  padding: 14px 18px; border-top: 1px solid var(--trait);
}
.fiche-ligne:first-child { border-top: 0; }
.fiche-ligne__presse { font-size: 21px; font-weight: 700; color: var(--titre); }
.fiche-ligne__piece { font-size: 14px; }
.fiche-ligne--courante { background: var(--vert-pale); box-shadow: inset 4px 0 0 var(--vert); }
.fiche-ligne--courante .btn { grid-column: 1 / -1; justify-self: start; margin-top: 10px; }
.statut { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--gris); white-space: nowrap; }
.statut--ok { color: var(--vert-fonce); }
.statut .ico { width: 18px; height: 18px; }

/* Écran 2 : lecture */
.champs { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; margin: 0 0 20px; }
.champ { padding: 9px 0; border-bottom: 1px solid var(--trait); }
.champ dt { font-size: 12px; color: var(--gris); }
.champ dd { margin: 2px 0 0; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.champ__valeur { font-size: 16px; font-weight: 600; color: var(--titre); }
.champ__conf { font-size: 12px; font-weight: 500; color: var(--vert-fonce); white-space: nowrap; }

.doute { background: var(--ambre-pale); border: 2px solid var(--ambre); border-radius: 14px; padding: 18px 20px 20px; margin-bottom: 24px; }
.sous-titre { font-size: 13px; font-weight: 600; color: var(--gris); margin: 0 0 2px; }
.doute__tete { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.doute__tete > span { font-size: 13px; font-weight: 700; color: var(--ambre-fonce); }
.doute__tete strong { font-size: 24px; color: var(--titre); }
.doute__tete .doute__alt { color: #6f7478; font-weight: 600; }
.doute > p { margin: 6px 0 10px; }
.preuves { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.preuves li { padding: 10px 12px; background: rgb(255 255 255 / 0.7); border-radius: 10px; font-size: 14px; }
.preuves b { display: block; color: var(--titre); font-size: 13px; }
.verdict { display: block; margin-top: 4px; font-weight: 600; color: var(--titre); }
.doute__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.doute--tranche { background: var(--vert-pale); border-color: var(--vert); }
.doute--tranche .doute__tete > span { color: var(--vert-fonce); }
.doute--force { background: var(--ambre-pale); border-color: var(--ambre); }
.saisie-libre { margin-top: 14px; display: grid; gap: 6px; }
.saisie-libre label { font-size: 13px; font-weight: 600; color: var(--titre); }
.saisie-libre input {
  min-height: 50px; padding: 0 14px; border: 1.5px solid #8a9196; border-radius: 10px;
  font: 600 20px Montserrat, sans-serif; color: var(--titre); background: #fff; max-width: 260px;
}
.saisie-libre__msg { margin: 4px 0 0; font-size: 14px; color: #8a1a33; font-weight: 600; }
.confidentiel { display: flex; align-items: center; gap: 8px; margin: 16px 0 0; font-size: 13px; color: var(--gris); }
.confidentiel .ico { width: 18px; height: 18px; }

/* Écran 3 : TRS du poste */
.feuille--releve .lu--ok, .feuille--releve .lu--doute { display: none; }
.frise { margin: 4px 0 18px; }
.frise__barre { position: relative; height: 46px; background: #f1f3f4; border-radius: 8px; overflow: hidden; }
.seg { position: absolute; top: 0; bottom: 0; transform-origin: left center; }
.seg + .seg { box-shadow: inset 1.5px 0 0 #fff; }
.seg--marche { background: var(--vert); }
.seg--arret { background: var(--rouge); }
.seg--reglage { background: var(--reglage); }
.seg--defaut { background: var(--ambre); }
.frise__heures { position: relative; height: 22px; margin-top: 4px; }
.frise__heures span { position: absolute; transform: translateX(-50%); font-size: 12px; color: var(--gris); }
.frise__heures span:first-child { transform: none; }
.frise__heures span:last-child { transform: translateX(-100%); }

.arrets { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--blanc); border-radius: 12px; overflow: hidden; }
.arrets caption { text-align: left; font-size: 13px; font-weight: 600; color: var(--titre); margin-bottom: 6px; }
.arrets th { text-align: left; font-size: 12px; font-weight: 600; color: var(--gris); padding: 8px 10px; border-bottom: 1px solid var(--trait); }
.arrets td { padding: 9px 10px; border-bottom: 1px solid var(--trait); vertical-align: top; }
.arrets tr:last-child td { border-bottom: 0; }
.arrets .note { color: var(--titre); }
.pastille { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: 0; }
.pastille--arret { background: var(--rouge); }
.pastille--reglage { background: var(--reglage); }
.pastille--defaut { background: var(--ambre); }

.equation { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin-top: 24px; }
.facteur { flex: 1 1 110px; display: flex; flex-direction: column; padding: 12px 4px; }
.facteur b { font-size: 25px; line-height: 1.1; color: var(--titre); white-space: nowrap; }
.facteur span { font-size: 13px; font-weight: 600; color: var(--titre); margin-top: 4px; }
.facteur small { font-size: 12px; color: var(--gris); margin-top: 2px; }
.op { align-self: center; font-size: 24px; color: #8a8f93; }
.facteur--resultat { background: var(--vert); border-radius: 12px; padding: 12px 18px; flex-grow: 1.2; }
.facteur--resultat b { font-size: 34px; color: var(--sur-vert); }
.facteur--resultat span { color: var(--sur-vert); }
.pied-action { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 24px; }
.envoye { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--vert-fonce); font-weight: 600; }

/* Écran 4 : les deux ateliers */
.ecran--ateliers { display: block; }
.bilan p { margin: 10px 0 0; font-size: 17px; max-width: 74ch; }
.bilan b { color: var(--titre); }
.ateliers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 26px; }
.atelier { background: var(--blanc); border: 1px solid var(--trait); border-radius: 14px; padding: 22px; min-width: 0; }
.atelier__trs { margin: 6px 0 16px; }
.atelier__trs b { font-size: 28px; color: var(--titre); margin-right: 4px; }
.defile { overflow-x: auto; }
.chaleur { border-collapse: separate; border-spacing: 3px; min-width: 360px; }
.chaleur caption { text-align: left; font-size: 13px; color: var(--gris); padding: 0 3px 4px; }
.chaleur th { font-size: 12px; font-weight: 600; color: var(--gris); padding: 4px 6px; text-align: center; }
.chaleur th[scope='row'] { text-align: left; color: var(--titre); padding-right: 10px; }
.chaleur td { width: 58px; height: 38px; text-align: center; font-size: 14px; font-weight: 600; color: #1d2a0e; border-radius: 6px; }
.chaleur td.marque { outline: 3px solid var(--titre); outline-offset: -3px; }
.legende { margin: 6px 3px 0; font-size: 12px; color: var(--gris); }
.pareto { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.pareto li { display: grid; grid-template-columns: 170px minmax(0, 1fr) 62px; align-items: center; gap: 12px; font-size: 14px; }
.pareto__barre { height: 12px; width: var(--w); background: #5b6167; border-radius: 3px; }
.pareto__val { text-align: right; color: var(--titre); font-weight: 600; white-space: nowrap; }
.corrections { margin-top: 26px; background: var(--blanc); border: 1px solid var(--trait); border-radius: 14px; padding: 22px; }
.corrections ul { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 8px; }
.corrections b { color: var(--titre); }
.corrections span { color: var(--gris); }
.rejouer { text-align: center; margin: 30px 0 0; }

/* Prise de vue simulée */
#capture { position: fixed; inset: 0; z-index: 1000; background: #1c1f22; }
.viseur { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.viseur__fiche {
  position: relative; width: min(52vh, 78vw); background: #fff;
  transform: rotate(-6deg) scale(0.9) translate(4%, 3%); transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  filter: brightness(0.9) contrast(0.96); box-shadow: 0 30px 60px -20px rgb(0 0 0 / 0.7);
}
.coin { position: absolute; width: 36px; height: 36px; border: 0 solid var(--vert); opacity: 0; transition: all 0.7s cubic-bezier(0.2, 0.8, 0.2, 1); }
.coin--hg { top: -46px; left: -46px; border-top-width: 5px; border-left-width: 5px; }
.coin--hd { top: -46px; right: -46px; border-top-width: 5px; border-right-width: 5px; }
.coin--bg { bottom: -46px; left: -46px; border-bottom-width: 5px; border-left-width: 5px; }
.coin--bd { bottom: -46px; right: -46px; border-bottom-width: 5px; border-right-width: 5px; }
.cadre .coin { opacity: 1; }
.cadre .coin--hg { top: -8px; left: -8px; }
.cadre .coin--hd { top: -8px; right: -8px; }
.cadre .coin--bg { bottom: -8px; left: -8px; }
.cadre .coin--bd { bottom: -8px; right: -8px; }
.detecte .viseur__fiche { transform: none; filter: none; }
.viseur__etat { margin: 22px 0 0; color: #fff; font-size: 15px; font-weight: 600; }
.viseur__declencheur { position: absolute; right: 32px; top: 50%; width: 68px; height: 68px; margin-top: -34px; border-radius: 50%; border: 4px solid #fff; box-shadow: inset 0 0 0 5px #1c1f22, inset 0 0 0 40px #fff; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.declenche .flash { animation: flash 0.3s ease-out; }
@keyframes flash { 0% { opacity: 0; } 30% { opacity: 0.9; } 100% { opacity: 0; } }

/* Animations d'entrée : une seule séquence par écran, rejouée seulement à l'arrivée */
@keyframes trace { from { stroke-dashoffset: 100; fill-opacity: 0; } to { stroke-dashoffset: 0; } }
@keyframes balaie { 0% { opacity: 0.6; transform: translateY(0); } 92% { opacity: 0.6; } 100% { opacity: 0; transform: translateY(1126px); } }
@keyframes apparait { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }
@keyframes surgit { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes loupe { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: none; } }
@keyframes pose { from { opacity: 0.4; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes pousse { from { transform: scaleX(0); } to { transform: none; } }

.entree .feuille { animation: pose 0.45s ease-out both; }
.ecran--lecture.entree .balayage { animation: balaie 1.7s 0.3s linear both; }
.ecran--lecture.entree .lu { stroke-dasharray: 100; animation: trace 0.5s calc(0.35s + var(--t) * 1.7s) ease-out both; }
.ecran--lecture.entree .champ { animation: apparait 0.35s calc(0.5s + var(--i) * 0.11s) ease-out both; }
.ecran--lecture.entree .doute { animation: surgit 0.45s 2.15s ease-out both; }
.ecran--lecture.entree .loupe { transform-origin: 20% 0; animation: loupe 0.45s 2.05s cubic-bezier(0.2, 0.9, 0.3, 1.2) both; }
.ecran--trs.entree .lu--evt { stroke-dasharray: 100; animation: trace 0.4s calc(0.3s + var(--i) * 0.16s) ease-out both; }
.ecran--trs.entree .seg { animation: pousse 0.4s calc(0.3s + var(--i) * 0.16s) ease-out both; }
.ecran--trs.entree .facteur, .ecran--trs.entree .op { animation: surgit 0.4s calc(1.7s + var(--i, 0) * 0.3s) ease-out both; }
.ecran--trs.entree .op { --i: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Tablette portrait et en dessous */
@media (max-width: 960px) {
  .ecran { gap: 26px; }
  .ateliers { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .ecran { grid-template-columns: minmax(0, 1fr); }
  .ecran--poste .col--papier { max-width: 520px; }
  .viseur { justify-content: flex-start; padding-top: 8vh; }
  .viseur__fiche { width: min(44vh, 72vw); }
  .viseur__declencheur { position: static; flex: none; margin: 16px 0 0; }
}
@media (max-width: 560px) {
  h1 { font-size: 22px; }
  .barre { padding: 10px 16px; gap: 12px; }
  .barre__logo { height: 28px; }
  .barre__titre { padding-left: 12px; }
  .barre__utilisateur { display: none; }
  .etapes ol { padding: 0 8px; }
  .etapes button { padding: 0 10px; font-size: 13px; }
  main { padding: 20px 16px var(--bandeau); }
  .champs { grid-template-columns: minmax(0, 1fr); }
  .fiche-ligne { grid-template-columns: 52px minmax(0, 1fr); padding: 12px 14px; }
  .fiche-ligne .statut { grid-column: 2; }
  .fiche-ligne--courante .btn { width: 100%; }
  .doute { padding: 16px; }
  .doute__actions .btn { flex: 1 1 100%; }
  .loupe { width: 34%; border-width: 2px; border-radius: 10px; }
  .loupe span { font-size: 11px; padding: 2px 6px 4px; }
  .chaleur { min-width: 0; border-spacing: 2px; }
  .chaleur td { width: 44px; height: 34px; font-size: 13px; }
  .chaleur th { padding: 4px 2px; }
  .chaleur th[scope='row'] { padding-right: 6px; }
  .arrets th:nth-child(2), .arrets td:nth-child(2) { display: none; }
  .equation .op { display: none; }
  .facteur { flex: 1 1 40%; }
  .pareto li { grid-template-columns: 118px minmax(0, 1fr) 54px; gap: 8px; font-size: 13px; }
  .bilan p { font-size: 15px; }
  .atelier, .corrections { padding: 16px; }
}
