/* Gignoux Production — interface atelier
   Palette froide et mate, pensee pour un ecran d'atelier et une tablette.
   Les numeros de serie et references sont en mono : ce sont des donnees. */

:root {
  --papier: #eceff1;
  --carte: #ffffff;
  --encre: #101518;
  --encre-douce: #5a666d;
  --graphite: #1f262a;
  --graphite-clair: #2c353a;
  --trait: #d2d9dc;
  --glace: #0f6478;
  --glace-clair: #e2eef1;
  --programme: #6c787e;
  --moule: #a66300;
  --verifie: #0f6478;
  --check: #15633b;
  --alerte: #a1291f;
  --alerte-fond: #fbeae8;
  --rayon: 3px;
  --ombre: 0 1px 2px rgba(16, 21, 24, .08);
  --sans: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", system-ui, sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  color: var(--encre);
  background: var(--papier);
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; color: var(--encre-douce); font-weight: 600; }
a { color: var(--glace); }

.mono, .ref { font-family: var(--mono); font-size: .92em; }
.ref { font-weight: 600; letter-spacing: .02em; }

/* ---------- Ossature ---------- */
.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

.rail {
  background: var(--graphite);
  color: #e7ecee;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.marque { padding: 18px 18px 14px; border-bottom: 1px solid #333c41; }
.marque strong { display: block; font-size: 15px; letter-spacing: .06em; }
.marque span { font-size: 12px; color: #93a1a7; }
.rail nav { display: flex; flex-direction: column; padding: 8px 0; overflow-y: auto; }
.rail a {
  color: #cdd6d9;
  text-decoration: none;
  padding: 11px 18px;
  font-size: 14.5px;
  border-left: 3px solid transparent;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
  align-items: center;
}
.rail a:hover { background: var(--graphite-clair); color: #fff; }
.rail a.actif { background: var(--graphite-clair); color: #fff; border-left-color: var(--glace); }
.rail a .pastille {
  background: #3c464c; color: #dfe6e8; border-radius: 10px;
  padding: 1px 7px; font-size: 12px;
}
.rail a .pastille.rouge { background: var(--alerte); color: #fff; }
.rail .bas { margin-top: auto; padding: 14px 18px; font-size: 12px; color: #8b989e; }

main { padding: 0 0 56px; min-width: 0; }
.barre {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 24px; background: var(--carte); border-bottom: 1px solid var(--trait);
  position: sticky; top: 0; z-index: 5;
}
.barre .semaine { margin-left: auto; font-size: 13px; color: var(--encre-douce); }
.contenu { padding: 22px 24px; max-width: 1400px; }
.section { margin-bottom: 28px; }
.section > h2 { margin-bottom: 10px; }

/* ---------- Flux de production ---------- */
.flux { display: flex; gap: 2px; align-items: stretch; flex-wrap: wrap; }
.flux .etape {
  flex: 1 1 130px; background: var(--carte); border: 1px solid var(--trait);
  padding: 14px 16px; position: relative;
}
.flux .etape + .etape { border-left: none; }
.flux .etape b { display: block; font-size: 30px; font-weight: 600; line-height: 1.1; }
.flux .etape span { font-size: 13px; color: var(--encre-douce); }
.flux .etape i {
  display: block; width: 28px; height: 3px; margin-bottom: 10px; background: var(--programme);
}
.flux .etape.moule i { background: var(--moule); }
.flux .etape.verifie i { background: var(--verifie); }
.flux .etape.check i { background: var(--check); }

.cartes { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.carte {
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon);
  padding: 14px 16px; box-shadow: var(--ombre);
}
.carte .valeur { font-size: 26px; font-weight: 600; }
.carte .libelle { font-size: 13px; color: var(--encre-douce); }
.carte.danger { border-color: var(--alerte); background: var(--alerte-fond); }

/* ---------- Tableaux ---------- */
.tableau-enveloppe {
  background: var(--carte); border: 1px solid var(--trait); border-radius: var(--rayon);
  overflow: auto; max-height: 70vh;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  position: sticky; top: 0; background: #f6f8f9; text-align: left; font-weight: 600;
  font-size: 12.5px; color: var(--encre-douce); padding: 9px 12px;
  border-bottom: 1px solid var(--trait); white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid #eceff1; vertical-align: middle; }
tbody tr:hover { background: #f7fafb; }
tbody tr.cliquable { cursor: pointer; }
td.num, th.num { text-align: right; }
td.neg { color: var(--alerte); font-weight: 600; }
.vide { padding: 28px; text-align: center; color: var(--encre-douce); }

.etat {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px; white-space: nowrap;
  background: #eceff1; color: var(--programme);
}
.etat.Moulé { background: #fdf0dc; color: var(--moule); }
.etat.Vérifié { background: var(--glace-clair); color: var(--verifie); }
.etat.Check { background: #e2f0e8; color: var(--check); }
.etat.Rebut { background: var(--alerte-fond); color: var(--alerte); }
.etat.rupture { background: var(--alerte-fond); color: var(--alerte); }
.etat.bas { background: #fdf0dc; color: var(--moule); }

/* ---------- Formulaires ---------- */
label { display: block; font-size: 12.5px; color: var(--encre-douce); margin-bottom: 4px; }
input, select, textarea, button {
  font-family: inherit; font-size: 15px; color: inherit;
}
input, select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--trait);
  border-radius: var(--rayon); background: #fff; min-height: 40px;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--glace); outline-offset: 1px;
}
.champs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.champ-court { max-width: 160px; }
.ligne-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-top: 12px; }

button {
  border: 1px solid var(--graphite); background: var(--graphite); color: #fff;
  padding: 9px 16px; border-radius: var(--rayon); cursor: pointer; min-height: 40px;
  font-weight: 500;
}
button:hover { background: var(--graphite-clair); }
button.principal { background: var(--glace); border-color: var(--glace); }
button.principal:hover { background: #0b5263; }
button.discret { background: #fff; color: var(--encre); border-color: var(--trait); }
button.discret:hover { background: #f1f4f5; }
button.danger { background: #fff; color: var(--alerte); border-color: #e3bdb8; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.petit { padding: 5px 10px; min-height: 32px; font-size: 13px; }

.filtres { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filtres > div { min-width: 120px; }

/* Controles de verification : grandes cibles tactiles */
.controles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px; }
.controle {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--trait); border-radius: var(--rayon); background: #fff;
  cursor: pointer; user-select: none; min-height: 52px;
}
.controle input { width: 22px; height: 22px; min-height: 22px; accent-color: var(--glace); }
.controle.ok { background: #f2f8f5; border-color: #b9d7c6; }
.controle span { font-size: 14.5px; }

/* Panneau lateral */
.panneau {
  position: fixed; top: 0; right: 0; width: min(520px, 100%); height: 100vh;
  background: var(--carte); border-left: 1px solid var(--trait); z-index: 20;
  box-shadow: -4px 0 16px rgba(16, 21, 24, .12); overflow-y: auto;
}
.panneau header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--trait); position: sticky; top: 0;
  background: var(--carte);
}
.panneau .corps { padding: 20px; }
.panneau .corps > * + * { margin-top: 18px; }
.voile { position: fixed; inset: 0; background: rgba(16, 21, 24, .3); z-index: 19; }

/* Messages */
.message {
  padding: 10px 14px; border-radius: var(--rayon); margin-bottom: 14px; font-size: 14px;
  border: 1px solid var(--trait); background: var(--carte);
}
.message.ok { background: #eef7f1; border-color: #bcd9c8; }
.message.ko { background: var(--alerte-fond); border-color: #e3bdb8; color: var(--alerte); }

/* Histogramme hebdomadaire */
.histo { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding-top: 8px; }
.histo .sem { flex: 1; display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; gap: 3px; min-width: 24px; }
.histo .paire { display: flex; align-items: flex-end; gap: 2px; width: 100%; height: 118px; }
.histo .barre { flex: 1; background: var(--moule); border-radius: 1px 1px 0 0; min-height: 2px; }
.histo .barre.validee { background: var(--check); }
.histo .etiquette { font-size: 10.5px; color: var(--encre-douce); }
.legende { display: flex; gap: 16px; font-size: 12.5px; color: var(--encre-douce); margin-top: 6px; }
.legende i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; }

/* Connexion */
.connexion {
  min-height: 100vh; display: grid; place-items: center; background: var(--graphite);
}
.connexion form {
  background: var(--carte); padding: 28px; border-radius: var(--rayon);
  width: min(360px, 90vw); box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.connexion h1 { margin-bottom: 4px; }
.connexion p { color: var(--encre-douce); font-size: 14px; margin: 0 0 18px; }

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

/* Tablette et mobile : navigation en bas, cibles plus grandes */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; bottom: 0; top: auto; height: auto; width: 100%; flex-direction: row;
    z-index: 30; border-top: 1px solid #333c41;
  }
  .marque, .rail .bas { display: none; }
  .rail nav { flex-direction: row; overflow-x: auto; width: 100%; padding: 0; }
  .rail a { border-left: none; border-top: 3px solid transparent; padding: 10px 14px; white-space: nowrap; }
  .rail a.actif { border-left-color: transparent; border-top-color: var(--glace); }
  main { padding-bottom: 76px; }
  .contenu { padding: 16px; }
  .barre { padding: 12px 16px; }
  .panneau { width: 100%; }
}
