:root {
  --bg: #f4f3ef;
  --card: #fff;
  --ink: #1d1d1b;
  --muted: #6b6a64;
  --line: #dcdad2;
  --accent: #1f6f43;
  --err: #b3261e;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
header { padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--card); display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 1.2rem; font-weight: 700; }
h1 span { color: var(--accent); }
h2 { margin: 0 0 8px; font-size: .95rem; }
main { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 20px; padding: 20px 24px; align-items: start; }
.step { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 14px; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 0; }
select, input, textarea { width: 100%; font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
textarea { min-height: 110px; resize: vertical; }
label { display: block; font-size: .85rem; margin: 10px 0 4px; color: var(--muted); }
label:first-child { margin-top: 0; }
.from-dol { font-size: .75rem; color: var(--accent); margin-left: 4px; }
#resultats { list-style: none; margin: 6px 0 0; padding: 0; max-height: 240px; overflow: auto; }
#resultats li { padding: 6px 8px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
#resultats li:hover, #resultats li:focus { background: #e8f1ec; outline: none; }
#resultats small { color: var(--muted); white-space: nowrap; }
.produit-ligne { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.produit-ligne button { white-space: nowrap; }
.preview { position: sticky; top: 20px; }
.paper { background: #cfcdc5; border-radius: 8px; padding: 28px; display: flex; justify-content: center; }
#apercu { image-rendering: pixelated; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.25); border-radius: 6px; max-width: 100%; }
.actions { display: flex; gap: 10px; align-items: end; margin-top: 14px; flex-wrap: wrap; }
.actions label { margin: 0; }
.actions input { width: 90px; }
.actions #dec-x, .actions #dec-y { width: 70px; }
.actions select { width: auto; }
button { font: inherit; padding: 8px 18px; border-radius: 6px; border: 1px solid var(--line); background: #fff; cursor: pointer; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .5; cursor: wait; }
#statut { min-height: 1.4em; font-size: .9rem; }
#statut.ok { color: var(--accent); }
#statut.err { color: var(--err); }
#relais-etat.ok { color: var(--accent); font-weight: 600; }
#relais-etat.err { color: var(--err); font-weight: 600; }
nav { display: flex; align-items: center; gap: 6px; flex: 1; }
nav #qui { margin-left: auto; color: var(--muted); font-size: .9rem; }
.tab { border: 0; background: none; padding: 6px 12px; border-radius: 6px; color: var(--muted); }
.tab.actif { background: #e8f1ec; color: var(--accent); font-weight: 600; }
button.lien { border: 0; background: none; color: var(--accent); padding: 6px 8px; text-decoration: underline; }
[hidden] { display: none !important; }
.login { display: flex; justify-content: center; padding: 60px 16px; }
.login form { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 24px; width: 100%; max-width: 340px; }
.login button { width: 100%; margin-top: 16px; }
.err { color: var(--err); font-size: .9rem; min-height: 1.2em; margin: 10px 0 0; }
.historique { padding: 20px 24px; }
.historique .barre { max-width: 420px; margin-bottom: 12px; }
.historique tbody tr:nth-child(even) { background: #f3f2ec; }
.historique table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; }
.historique th, .historique td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.historique th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.historique td.num { text-align: right; }
.historique tr.erreur td { color: var(--err); }
.historique small { color: var(--muted); }
.historique button { padding: 3px 10px; font-size: .85rem; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-top: 16px; }
.panel h3 { font-size: .9rem; margin: 16px 0 8px; }
.panel-titre { display: flex; justify-content: space-between; align-items: baseline; }
#prix-vente { color: var(--muted); font-size: .9rem; }
table.zebra { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.zebra th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.zebra td { padding: 6px 8px; vertical-align: top; }
table.zebra tbody tr:nth-child(even) { background: #f3f2ec; }
table.zebra tr.total td { font-weight: 600; border-top: 1px solid var(--line); background: var(--card); }
table.zebra .num { text-align: right; white-space: nowrap; }
.pos { color: var(--accent); font-weight: 600; }
.neg { color: var(--err); font-weight: 600; }
.barre-annule { text-decoration: line-through; color: var(--muted); }
table.zebra button { padding: 3px 10px; font-size: .82rem; }
.form-stock { display: grid; grid-template-columns: max-content 1fr max-content 1fr; gap: 8px 12px; align-items: center; }
.form-stock label { margin: 0; }
.form-stock .large { grid-column: span 3; }
.qte-sens { display: flex; gap: 6px; }
.qte-sens select { width: auto; }
.stock-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
label.check { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--ink); font-size: .92rem; }
label.check input { width: auto; }
label.check.bouton { padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; font-size: inherit; }
label.check.bouton:has(input:checked) { border-color: var(--err); background: #fbeeed; color: var(--err); font-weight: 600; }
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 20px 22px; max-width: 460px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0,0,0,.35); }
dialog ul { padding-left: 18px; margin: 8px 0 16px; line-height: 1.5; }
dialog li.alerte { color: var(--err); font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 1100px) { .form-stock { grid-template-columns: max-content 1fr; } .form-stock .large { grid-column: auto; } }
@media (max-width: 800px) { .historique { overflow-x: auto; } main { grid-template-columns: 1fr; padding: 16px; } .preview { position: static; } }
