/* =====================================================================
   Atelier CNC — feuille de style
   Direction : plaque de machine. Étiquettes gravées, chiffres tabulaires,
   et une réglette de provenance à gauche de chaque valeur.
   ===================================================================== */

:root {
  --ink:        #14181B;
  --ink-2:      #4C555B;
  --ink-3:      #78838A;
  --line:       #C6CCC5;
  --line-soft:  #DCE0DA;
  --panel:      #FFFFFF;
  --bg:         #E3E7E0;

  --blue:       #1B4D8F;
  --blue-deep:  #123A6E;
  --blue-wash:  #E4EBF5;

  --stop:       #A82C22;
  --stop-wash:  #F8E4E1;
  --warn:       #99590A;
  --warn-wash:  #FAEEDA;
  --go:         #0D6249;
  --go-wash:    #DFEFE7;

  --r:          3px;
  --gut:        16px;
  --col:        540px;

  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
button { font: inherit; }

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: #fff; padding: 10px 14px; z-index: 50;
}
.skip:focus { left: 8px; top: 8px; }

:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
   Réglette de statut : l'élément signature.
   Chaque valeur porte une bande qui dit d'où elle vient.
   --------------------------------------------------------------------- */

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.plate {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--line);
  border-radius: var(--r);
}
.plate--blue { border-left-color: var(--blue); }
.plate--stop { border-left-color: var(--stop); }
.plate--warn { border-left-color: var(--warn); }
.plate--go   { border-left-color: var(--go); }

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ---------------------------------------------------------------------
   Bandeau haut : lecture d'état, comme l'afficheur d'un contrôleur
   --------------------------------------------------------------------- */

.rail {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink);
  color: #EDF0EC;
  padding-top: env(safe-area-inset-top);
}
.rail-in {
  max-width: var(--col); margin: 0 auto;
  padding: 10px var(--gut);
  display: flex; align-items: center; gap: 12px;
}
.rail-id { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.rail-name {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-sub {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: #97A2A8;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lamp {
  width: 9px; height: 9px; border-radius: 50%;
  background: #3F9B78; box-shadow: 0 0 0 3px rgba(63,155,120,.22);
  flex: none;
}
.lamp[data-off] { background: #B2802F; box-shadow: 0 0 0 3px rgba(178,128,47,.22); }

.rail-btn {
  background: none; border: 1px solid #3A4348; color: #B7C0C5;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  padding: 5px 9px; border-radius: var(--r); cursor: pointer;
}

/* ---------------------------------------------------------------------
   Colonne principale
   --------------------------------------------------------------------- */

main {
  max-width: var(--col); margin: 0 auto;
  padding: 18px var(--gut) 28px;
}

.screen-head { margin-bottom: 16px; }
.screen-head h1 { font-size: 22px; margin-top: 4px; }
.screen-head p.lede { color: var(--ink-2); font-size: 14px; margin-top: 6px; }

section { margin-bottom: 22px; }
.sec-label { margin-bottom: 9px; }

/* ---------------------------------------------------------------------
   Modules de l'écran d'accueil
   --------------------------------------------------------------------- */

.mods { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.mod {
  display: block; text-decoration: none; color: inherit;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r); padding: 13px 13px 15px;
  position: relative;
}
.mod::after {
  content: ""; position: absolute; left: 13px; right: 13px; top: 40px;
  height: 1px; background: var(--line-soft);
}
.mod svg { width: 21px; height: 21px; fill: none; stroke: var(--blue); stroke-width: 1.6; }
.mod-name { font-size: 14.5px; font-weight: 600; margin-top: 18px; }
.mod-sub { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; line-height: 1.35; }
.mod[aria-disabled="true"] { opacity: .55; }
.mod[aria-disabled="true"] svg { stroke: var(--ink-3); }

.mod-flag {
  position: absolute; top: 13px; right: 13px;
  font-family: var(--mono); font-size: 9px; letter-spacing: .1em;
  color: var(--ink-3); text-transform: uppercase;
}

/* ---------------------------------------------------------------------
   Formulaires
   --------------------------------------------------------------------- */

.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 5px; }

input[type="text"], input[type="number"], select {
  width: 100%; padding: 10px 11px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r);
  font-family: var(--mono); font-size: 15px;
  font-variant-numeric: tabular-nums;
  appearance: none;
}
select {
  font-family: var(--sans);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%234C555B' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  background-size: 11px; padding-right: 32px;
}

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: grid; grid-auto-flow: column; gap: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button {
  background: var(--panel); border: 0; border-right: 1px solid var(--line);
  padding: 9px 4px; cursor: pointer; color: var(--ink-2);
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .06em;
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--blue); color: #fff; }

.range { width: 100%; accent-color: var(--blue); }

.btn {
  width: 100%; padding: 13px; cursor: pointer;
  background: var(--blue); color: #fff; border: 0; border-radius: var(--r);
  font-weight: 600; font-size: 15px;
}
.btn:disabled { background: var(--ink-3); cursor: not-allowed; }
.btn--ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }

/* ---------------------------------------------------------------------
   Résultat de devis
   --------------------------------------------------------------------- */

.lines { width: 100%; border-collapse: collapse; }
.lines th, .lines td { padding: 7px 0; text-align: left; font-weight: 400; font-size: 14px; }
.lines td:last-child { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.lines tr.total th, .lines tr.total td {
  border-top: 1px solid var(--line); padding-top: 10px; font-weight: 600;
}
.lines .muted td, .lines .muted th { color: var(--ink-3); }

.price { padding: 14px; margin-top: 12px; background: var(--go-wash); border-radius: var(--r); border-left: 4px solid var(--go); }
.price-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.price-row + .price-row { margin-top: 7px; }
.price-big { font-size: 26px; color: #06392C; }
.price-lbl { font-size: 13px; color: #14584A; }
.price-lot { margin-top: 10px; font-size: 12.5px; color: #14584A; font-family: var(--mono); }

/* ---------------------------------------------------------------------
   Dangers
   --------------------------------------------------------------------- */

.haz { padding: 13px; margin-bottom: 9px; }
.haz--stop { background: var(--stop-wash); border-left-color: var(--stop); }
.haz--warn { background: var(--warn-wash); border-left-color: var(--warn); }
.haz--info { background: var(--panel); }
.haz h3 { font-size: 14.5px; }
.haz--stop h3 { color: #6E1B14; }
.haz--warn h3 { color: #5E3606; }
.haz p { font-size: 13.5px; color: var(--ink-2); margin-top: 5px; line-height: 1.45; }
.haz .todo { margin-top: 7px; font-size: 13.5px; color: var(--ink); }
.haz .todo b { font-weight: 600; }
.haz .src { margin-top: 7px; font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }

.gate {
  padding: 13px; background: var(--stop); color: #fff; border-radius: var(--r);
  display: flex; gap: 10px; align-items: flex-start;
}
.gate p { font-size: 13.5px; }
.gate strong { display: block; font-size: 14.5px; margin-bottom: 3px; }

/* Signes d'usure */
.signs { list-style: none; margin: 8px 0 0; padding: 0; }
.signs li {
  font-size: 13.5px; color: var(--ink-2); padding-left: 16px; position: relative;
  margin-bottom: 4px; line-height: 1.4;
}
.signs li::before {
  content: ""; position: absolute; left: 0; top: 8px;
  width: 7px; height: 1px; background: var(--ink-3);
}

.chip {
  display: inline-block; font-family: var(--mono); font-size: 9.5px;
  letter-spacing: .1em; text-transform: uppercase; padding: 2px 6px;
  border-radius: 2px; background: var(--line-soft); color: var(--ink-2);
}
.chip--go { background: var(--go-wash); color: var(--go); }
.chip--blue { background: var(--blue-wash); color: var(--blue); }
.chip--warn { background: var(--warn-wash); color: var(--warn); }

/* ---------------------------------------------------------------------
   Barre d'onglets
   --------------------------------------------------------------------- */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--panel); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 0 8px; text-decoration: none; color: var(--ink-3);
}
.tab svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.tab span { font-family: var(--mono); font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase; }
.tab[aria-current="page"] { color: var(--blue); }

/* ---------------------------------------------------------------------
   Divers
   --------------------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(76px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: 10px 15px; border-radius: var(--r);
  font-size: 13.5px; max-width: calc(100% - 32px); z-index: 40;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast[data-on] { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { padding: 22px 16px; text-align: center; }
.empty p { color: var(--ink-2); font-size: 14px; margin-top: 6px; }

.note { font-size: 12.5px; color: var(--ink-2); margin-top: 9px; line-height: 1.45; }

.pad { padding: 14px; }

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