/* Luxury Shop DZ — Stock et transferts
   Identité : cadran bleu nuit, laiton, acier. Les chiffres sont en Lora (comme sur un cadran),
   le texte en Carlito, les codes-barres en DejaVu Sans Mono. */

@font-face { font-family: "Lora"; src: url("fonts/lora.woff") format("woff"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("fonts/carlito-regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Carlito"; src: url("fonts/carlito-bold.woff") format("woff"); font-weight: 700; font-display: swap; }
@font-face { font-family: "DejaVu Sans Mono"; src: url("fonts/dejavu-mono.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DejaVu Sans Mono"; src: url("fonts/dejavu-mono-bold.woff") format("woff"); font-weight: 700; font-display: swap; }

:root {
  --cadran: #10283E;
  --cadran-2: #1B3A57;
  --cadran-3: #2B5176;
  --laiton: #B5893A;
  --laiton-clair: #E3C07A;
  --laiton-fonce: #7F5D1C;
  --acier: #EDF0F2;
  --papier: #FFFFFF;
  --filet: #D3DAE0;
  --filet-fort: #AEB9C3;
  --encre: #17212B;
  --brume: #566471;
  --brume-2: #77838F;

  --ok: #17703F;      --ok-bg: #DDF3E6;
  --ko: #B3261E;      --ko-bg: #FBE3E1;
  --warn: #7E5200;    --warn-bg: #FFEFCC;
  --info: #1D5FA8;    --info-bg: #E3EEF9;
  --neutre: #44535F;  --neutre-bg: #E4E9ED;

  --r: 4px;
  --r-lg: 10px;
  --font-ui: "Carlito", Calibri, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Lora", Georgia, "Times New Roman", serif;
  --font-code: "DejaVu Sans Mono", ui-monospace, Menlo, Consolas, monospace;
  --topbar: 54px;
  --tabbar: 60px;
  --rail: 236px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--acier); color: var(--encre);
  font-family: var(--font-ui); font-size: 17px; line-height: 1.38;
  font-variant-numeric: lining-nums;   /* PAS de tabular-nums global : dans Lora, « tnum » élargit aussi l'espace entre les mots */
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; line-height: 1.18; color: var(--encre); }
h1 { font-size: 28px; }
h2 { font-size: 21px; }
h3 { font-size: 18px; }
p { margin: 0 0 .6em; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--laiton); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--brume); }
.small { font-size: 14.5px; }
.code { font-family: var(--font-code); font-size: .82em; letter-spacing: .01em; color: var(--brume); word-break: break-all; }
.num, .tile .n, .dial .big { font-variant-numeric: tabular-nums lining-nums; }
.qty .of { font-variant-numeric: lining-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.hstack { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ------------------------------------------------------------------ squelette */
.app { min-height: 100vh; min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: calc(var(--topbar) + var(--safe-t)); padding-top: var(--safe-t);
  background: var(--cadran); color: #fff; display: flex; align-items: center; gap: 8px; padding-left: 6px; padding-right: 10px;
  border-bottom: 2px solid var(--laiton);
}
.topbar h1 { color: #fff; font-size: 19px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; }
.topbar .brand-mini { display: flex; align-items: center; gap: 8px; padding-left: 8px; flex: 1 1 auto; min-width: 0; }
.topbar .brand-mini span { font-family: var(--font-display); font-weight: 600; font-size: 18px; white-space: nowrap; }
.iconbtn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; border-radius: 50%; color: inherit; flex: 0 0 auto;
}
.iconbtn:hover { background: rgba(255,255,255,.12); }
.iconbtn.dark:hover { background: var(--neutre-bg); }
.who-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 150px; height: 44px; padding: 0 14px 0 10px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); border-radius: 22px; color: #fff; font-size: 15px;
}
.who-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-chip.unset { background: var(--laiton); border-color: var(--laiton); color: #1b1305; font-weight: 700; }

.main { padding-bottom: calc(var(--tabbar) + var(--safe-b) + 12px); }
.page { max-width: 1180px; margin: 0 auto; padding: 16px 16px 24px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { flex: 1 1 220px; }
.page-head .title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .title-row h1 { flex: 0 1 auto; }
.page-head .sub { color: var(--brume); font-size: 15.5px; margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--tabbar) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--papier); border-top: 1px solid var(--filet-fort); display: flex;
}
.tabbar a, .tabbar button {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--brume); font-size: 13.5px; background: none; border: 0; text-decoration: none; position: relative; min-width: 0;
}
.tabbar a[aria-current="page"], .tabbar button.on { color: var(--cadran); font-weight: 700; }
.tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; background: var(--laiton); border-radius: 0 0 3px 3px; }
.tabbar .badge { position: absolute; top: 5px; left: calc(50% + 8px); }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--ko); color: #fff; font-size: 12.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1;
}
.badge.brass { background: var(--laiton); color: #1b1305; }

.rail { display: none; }

@media (min-width: 960px) {
  body { font-size: 16.5px; }
  .app { display: grid; grid-template-columns: var(--rail) 1fr; }
  .rail {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; background: var(--cadran); color: #dfe7ee;
    padding: 18px 12px 14px; border-right: 2px solid var(--laiton);
  }
  .rail .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-family: var(--font-display); font-size: 18px; font-weight: 600; line-height: 1.1; white-space: nowrap; }
  .rail nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1 1 auto; }
  .rail nav a, .rail nav button {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r); color: #cbd6e0; background: none; border: 0;
    text-align: left; font-size: 16.5px; text-decoration: none; position: relative;
  }
  .rail nav a:hover, .rail nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
  .rail nav a[aria-current="page"] { background: rgba(255,255,255,.1); color: #fff; font-weight: 700; }
  .rail nav a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; background: var(--laiton); border-radius: 0 3px 3px 0; }
  .rail .sep { height: 1px; background: rgba(255,255,255,.14); margin: 8px 6px; }
  .rail .group { font-size: 13.5px; color: #8fa3b6; padding: 10px 12px 4px; }
  .rail .me { border-top: 1px solid rgba(255,255,255,.14); padding: 12px 8px 0; font-size: 15px; }
  .rail .me b { display: block; color: #fff; font-size: 16px; }
  .rail .me .who-chip { margin-top: 8px; max-width: none; width: 100%; justify-content: flex-start; }
  .topbar.mobile-only, .tabbar { display: none; }
  .main { padding-bottom: 24px; }
  .page { padding: 26px 32px 40px; }
  h1 { font-size: 31px; }
}

/* ------------------------------------------------------------------ boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border-radius: var(--r); border: 1.5px solid var(--cadran); background: var(--papier); color: var(--cadran);
  font-weight: 700; font-size: 16.5px; text-decoration: none; line-height: 1.1; white-space: nowrap;
}
.btn:hover { background: #F3F6F8; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--cadran); color: #fff; }
.btn.primary:hover { background: var(--cadran-2); }
.btn.brass { background: var(--laiton); border-color: var(--laiton); color: #1b1305; }
.btn.brass:hover { background: #c49a4b; }
.btn.danger { border-color: var(--ko); color: var(--ko); }
.btn.danger:hover { background: var(--ko-bg); }
.btn.danger.solid { background: var(--ko); color: #fff; }
.btn.quiet { border-color: transparent; background: none; color: var(--info); padding: 0 10px; }
.btn.quiet:hover { background: var(--info-bg); }
.btn.lg { min-height: 52px; font-size: 18px; padding: 0 24px; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 15px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.is-busy { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn .spin { width: 16px; height: 16px; }
.spin { display: inline-block; width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ formulaires */
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .field > .lbl { font-weight: 700; font-size: 15px; color: var(--encre); }
.field .hint { font-size: 14px; color: var(--brume); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 8px 12px; background: var(--papier); border: 1.5px solid var(--filet-fort);
  border-radius: var(--r); font-size: 17px; color: var(--encre);
}
.textarea { min-height: 88px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--brume) 50%), linear-gradient(135deg, var(--brume) 50%, transparent 50%); background-position: calc(100% - 20px) 54%, calc(100% - 14px) 54%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
.input:focus, .select:focus, .textarea:focus { outline: 3px solid rgba(181,137,58,.45); border-color: var(--laiton-fonce); }
.input.code-input { font-family: var(--font-code); font-size: 16px; letter-spacing: .02em; }
.input[aria-invalid="true"] { border-color: var(--ko); }
.form { display: flex; flex-direction: column; gap: 14px; max-width: 520px; }
.form-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.check input { width: 22px; height: 22px; accent-color: var(--cadran); }

/* ------------------------------------------------------------------ pastilles, puces, états */
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 13px; font-size: 14px; font-weight: 700;
  background: var(--neutre-bg); color: var(--neutre); white-space: nowrap;
}
.chip svg { flex: 0 0 auto; }
.chip[data-s="en_preparation"] { background: var(--neutre-bg); color: var(--neutre); }
.chip[data-s="envoye"] { background: var(--info-bg); color: var(--info); }
.chip[data-s="reception_en_cours"] { background: var(--warn-bg); color: var(--warn); }
.chip[data-s="conforme"] { background: var(--ok-bg); color: var(--ok); }
.chip[data-s="non_conforme"] { background: var(--ko-bg); color: var(--ko); }
.chip[data-s="cloture"] { background: var(--cadran); color: #fff; }
.chip[data-s="annule"] { background: #ECEEF0; color: var(--brume); text-decoration: line-through; text-decoration-thickness: 1px; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.ko { background: var(--ko-bg); color: var(--ko); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.plain { background: transparent; border: 1px solid var(--filet-fort); color: var(--brume); }

.pl {
  display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px;
  border: 1.5px solid var(--cadran); font-family: var(--font-code); font-size: 13px; font-weight: 700; color: var(--cadran); background: var(--papier);
  white-space: nowrap;
}
.pl.on { background: var(--cadran); color: #fff; }
.pl small { font-family: var(--font-ui); font-weight: 400; margin-left: 5px; color: inherit; opacity: .85; font-size: 13px; }
.pl.empty { border-style: dashed; color: var(--brume); border-color: var(--filet-fort); }
button.pl { cursor: pointer; }
button.pl:hover { background: #E9F0F6; }
button.pl.on:hover { background: var(--cadran-2); }

/* ------------------------------------------------------------------ registre (listes) */
.panel { background: var(--papier); border: 1px solid var(--filet); border-radius: var(--r-lg); }
.panel.pad { padding: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--filet); }
.panel-head h2, .panel-head h3 { font-size: 18px; }
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger > li, .ledger > .row {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--filet); min-height: 56px;
}
.ledger > li:last-child, .ledger > .row:last-child { border-bottom: 0; }
.ledger > li.link:hover, a.row:hover { background: #F6F8FA; }
a.row, .ledger a.row { color: inherit; text-decoration: none; }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-title { font-weight: 700; }
.row-sub { color: var(--brume); font-size: 15px; }
.row-end { flex: 0 0 auto; text-align: right; }
.empty { padding: 34px 20px; text-align: center; color: var(--brume); }
.empty h3 { color: var(--encre); margin-bottom: 6px; font-size: 19px; }
.empty .icon-big { color: var(--filet-fort); margin-bottom: 8px; }
.loading { padding: 40px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--brume); }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-size: 14.5px; font-weight: 700; color: var(--brume); padding: 9px 12px; border-bottom: 1.5px solid var(--filet-fort); white-space: nowrap; background: var(--papier); position: sticky; top: 0; }
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--filet); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td.num, table.grid th.num { text-align: right; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* tuiles de l'accueil */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; min-height: 104px; padding: 14px 14px 12px; background: var(--papier);
  border: 1px solid var(--filet); border-radius: var(--r-lg); color: var(--encre); text-decoration: none; position: relative;
}
.tile:hover { border-color: var(--filet-fort); text-decoration: none; background: #FBFCFD; }
.tile .n { font-family: var(--font-display); font-size: 40px; font-weight: 500; line-height: 1; letter-spacing: -.01em; }
.tile .l { font-size: 15.5px; color: var(--brume); margin-top: 6px; }
.tile.hot { border-color: var(--laiton); box-shadow: inset 4px 0 0 var(--laiton); }
.tile.hot .n { color: var(--laiton-fonce); }
.tile.zero .n { color: var(--filet-fort); }

/* ------------------------------------------------------------------ barre de scan */
.scanbar { display: flex; gap: 8px; align-items: stretch; }
.scanbar .scan-field { position: relative; flex: 1 1 auto; min-width: 0; }
.scanbar .scan-field svg.lead { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--brume); pointer-events: none; }
.scanbar input {
  width: 100%; height: 56px; padding: 0 14px 0 46px; font-size: 19px; font-family: var(--font-code); letter-spacing: .02em;
  background: var(--papier); border: 2px solid var(--cadran); border-radius: var(--r);
}
.scanbar input::placeholder { font-family: var(--font-ui); letter-spacing: 0; color: var(--brume-2); }
.scanbar input:focus { outline: 4px solid rgba(181,137,58,.45); }
.scanbar .tool { width: 56px; height: 56px; border: 2px solid var(--cadran); border-radius: var(--r); background: var(--papier); color: var(--cadran); display: inline-flex; align-items: center; justify-content: center; }
.scanbar .tool.on { background: var(--cadran); color: #fff; }
.scanbar.flash-ok input { border-color: var(--ok); animation: flash-ok .55s ease-out; }
.scanbar.flash-ko input { border-color: var(--ko); animation: flash-ko .55s ease-out; }
@keyframes flash-ok { 0% { background: #bfe8cf; } 100% { background: var(--papier); } }
@keyframes flash-ko { 0% { background: #f6c5c1; } 100% { background: var(--papier); } }
.scan-queue { font-size: 14px; color: var(--warn); margin-top: 4px; }

.lastscan {
  display: flex; gap: 12px; align-items: center; min-height: 72px; padding: 10px 14px; border-radius: var(--r); border: 1.5px solid var(--filet);
  background: var(--papier); margin-top: 10px;
}
.lastscan .ic { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--neutre-bg); color: var(--neutre); }
.lastscan .what { flex: 1 1 auto; min-width: 0; }
.lastscan .ref { font-weight: 700; font-size: 19px; overflow-wrap: anywhere; }
.lastscan .msg { font-size: 15.5px; color: var(--brume); }
.lastscan .qty { font-family: var(--font-display); font-size: 34px; font-weight: 500; line-height: 1; }
.lastscan.ok { border-color: #8fd0a9; background: #F2FBF6; }
.lastscan.ok .ic { background: var(--ok); color: #fff; }
.lastscan.warn { border-color: #e8c277; background: #FFF9EA; }
.lastscan.warn .ic { background: var(--laiton); color: #1b1305; }
.lastscan.ko { border-color: #e59a94; background: #FEF3F2; }
.lastscan.ko .ic { background: var(--ko); color: #fff; }
.lastscan.ko .ref { color: var(--ko); }

/* ------------------------------------------------------------------ cadran (progression) */
.dial { display: block; width: 100%; max-width: 230px; height: auto; margin: 0 auto; }
.dial .tick { stroke: #C9D1D8; stroke-width: 2.6; stroke-linecap: round; }
.dial .tick.major { stroke-width: 4; }
.dial .tick.ok { stroke: var(--ok); }
.dial .tick.todo { stroke: var(--laiton); }
.dial .tick.miss { stroke: var(--ko); }
.dial .tick.extra { stroke: #E0A526; stroke-width: 3.4; }
.dial text { font-family: var(--font-display); fill: var(--encre); text-anchor: middle; }
.dial .big { font-size: 54px; font-weight: 500; }
.dial .small { font-family: var(--font-ui); font-size: 15px; fill: var(--brume); }
.dial .tick { transition: stroke .18s; }
@media (prefers-reduced-motion: reduce) { .dial .tick { transition: none; } * { animation-duration: .01ms !important; } }

.counts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.counts button {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 7px 12px; border: 1.5px solid var(--filet-fort); border-radius: 20px;
  background: var(--papier); font-size: 15.5px; color: var(--encre);
}
.counts button b { font-family: var(--font-display); font-size: 19px; font-weight: 600; }
.counts button.on { border-color: var(--cadran); background: var(--cadran); color: #fff; }
.counts button[data-k="manquants"] b { color: var(--ko); }
.counts button[data-k="surplus"] b, .counts button[data-k="incorrects"] b { color: var(--warn); }
.counts button[data-k="conformes"] b { color: var(--ok); }
.counts button.on b { color: #fff !important; }
.counts button.zero { opacity: .55; }

/* ------------------------------------------------------------------ lignes de transfert */
.line {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "ref qty" "meta meta" "extra extra";
  gap: 4px 12px; padding: 12px 16px; border-bottom: 1px solid var(--filet); align-items: center;
}
.line:last-child { border-bottom: 0; }
.line .ref { grid-area: ref; font-weight: 700; font-size: 18px; overflow-wrap: anywhere; min-width: 0; }
.line .meta { grid-area: meta; display: flex; gap: 6px 10px; flex-wrap: wrap; align-items: center; color: var(--brume); font-size: 15px; min-width: 0; }
.line .qty-box { grid-area: qty; justify-self: end; display: flex; align-items: center; gap: 6px; }
.line .extra { grid-area: extra; min-width: 0; }
.line[data-state="manquant"] { background: #FFF8F7; box-shadow: inset 4px 0 0 var(--ko); }
.line[data-state="surplus"], .line[data-state="non_prevu"] { background: #FFFAEE; box-shadow: inset 4px 0 0 #E0A526; }
.line[data-state="conforme"] { box-shadow: inset 4px 0 0 var(--ok); }
.line.just { animation: just 1.1s ease-out; }
@keyframes just { 0% { background: #d4efdf; } 100% { background: transparent; } }
.qty { font-family: var(--font-display); font-size: 26px; font-weight: 500; min-width: 36px; text-align: center; line-height: 1; }
.qty .of { color: var(--brume); font-size: 19px; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--filet-fort); border-radius: var(--r); background: var(--papier); }
.stepper button { width: 42px; height: 42px; border: 0; background: none; color: var(--cadran); display: grid; place-items: center; }
.stepper button:hover { background: var(--neutre-bg); }
.stepper .val { width: 58px; min-width: 0; height: 42px; border: 0; border-left: 1.5px solid var(--filet); border-right: 1.5px solid var(--filet); text-align: center; font-family: var(--font-display); font-size: 21px; background: none; padding: 0; }
.line .note-input { width: 100%; }
.state-word { font-weight: 700; font-size: 14.5px; }
.state-word.manquant { color: var(--ko); }
.state-word.surplus, .state-word.non_prevu { color: var(--warn); }
.state-word.conforme { color: var(--ok); }

.sticky-actions {
  position: sticky; bottom: 0; z-index: 20; display: flex; gap: 10px; padding: 12px 16px calc(12px + var(--safe-b)); background: rgba(255,255,255,.96);
  border-top: 1px solid var(--filet-fort); backdrop-filter: blur(4px); margin: 0 -16px; flex-wrap: wrap;
}
.sticky-actions .btn { flex: 1 1 160px; }
@media (min-width: 960px) { .sticky-actions { margin: 0; border-radius: var(--r-lg); border: 1px solid var(--filet-fort); position: static; } }

.two-col { display: grid; gap: 16px; }
@media (min-width: 960px) { .two-col { grid-template-columns: minmax(0, 1fr) 330px; align-items: start; } .two-col.wide { grid-template-columns: minmax(0, 1fr) 380px; } .aside-sticky { position: sticky; top: 16px; } }

.tl { list-style: none; margin: 0; padding: 0 16px; }
.tl li { position: relative; padding: 0 0 14px 22px; }
.tl li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--cadran); }
.tl li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: -2px; width: 1.5px; background: var(--filet-fort); }
.tl li:last-child::after { display: none; }
.tl .t { font-size: 14px; color: var(--brume); }
.tl .x { font-size: 16px; }

dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 15.5px; }
dl.facts dt { color: var(--brume); }
dl.facts dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

.seg { display: inline-flex; border: 1.5px solid var(--cadran); border-radius: var(--r); overflow: hidden; flex-wrap: wrap; }
.seg button { padding: 8px 14px; border: 0; background: var(--papier); color: var(--cadran); font-weight: 700; font-size: 15.5px; min-height: 40px; }
.seg button + button { border-left: 1.5px solid var(--cadran); }
.seg button.on { background: var(--cadran); color: #fff; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.filters .field { min-width: 150px; flex: 1 1 150px; }
.filters .field.wide { flex: 2 1 260px; }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1.5px solid; font-size: 16px; }
.banner.info { background: var(--info-bg); border-color: #b4cdea; color: #0f3f75; }
.banner.warn { background: var(--warn-bg); border-color: #e8c277; color: #5b3b00; }
.banner.ko { background: var(--ko-bg); border-color: #e59a94; color: #7d1710; }
.banner.ok { background: var(--ok-bg); border-color: #9bd3b3; color: #0e4a29; }
.banner svg { flex: 0 0 auto; margin-top: 2px; }
.banner b { display: block; }
.banner > div { min-width: 0; }
.tech { margin: 8px 0 0; font-size: 13px; line-height: 1.4; opacity: .92; overflow-wrap: anywhere; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ------------------------------------------------------------------ fenêtres, avis */
.backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(10,22,34,.55); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal { width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; background: var(--papier); border-radius: 14px 14px 0 0; padding: 20px 18px calc(18px + var(--safe-b)); box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
.modal h2 { font-size: 21px; margin-bottom: 10px; }
.modal .body { margin-bottom: 16px; }
.modal .actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.modal .actions .btn { flex: 1 1 140px; }
@media (min-width: 700px) {
  .backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: var(--r-lg); padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
  .modal .actions .btn { flex: 0 0 auto; }
}
.toasts { position: fixed; z-index: 90; left: 12px; right: 12px; bottom: calc(var(--tabbar) + var(--safe-b) + 12px); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (min-width: 960px) { .toasts { bottom: 22px; left: calc(var(--rail) + 20px); } }
.toast { pointer-events: auto; max-width: 560px; width: 100%; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--cadran); color: #fff; font-size: 16px; box-shadow: 0 6px 20px rgba(0,0,0,.28); }
.toast.ok { background: #14532f; }
.toast.ko { background: #8c1d16; }
.toast svg { flex: 0 0 auto; margin-top: 1px; }

.net-banner { position: fixed; z-index: 70; top: calc(var(--topbar) + var(--safe-t) + 6px); left: 50%; transform: translateX(-50%); background: #7a1d17; color: #fff; padding: 8px 14px; border-radius: 18px; font-size: 15px; box-shadow: 0 4px 14px rgba(0,0,0,.3); }
@media (min-width: 960px) { .net-banner { top: 12px; } }

/* caméra */
.camera { position: fixed; inset: 0; z-index: 100; background: #000; display: flex; flex-direction: column; }
.camera video { flex: 1 1 auto; width: 100%; min-height: 0; object-fit: cover; }
.camera .frame { position: absolute; left: 10%; right: 10%; top: 30%; height: 22%; border: 3px solid rgba(227,192,122,.95); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); pointer-events: none; }
.camera .bar { background: rgba(10,22,34,.92); color: #fff; padding: 12px 14px calc(12px + var(--safe-b)); display: flex; gap: 10px; align-items: center; }
.camera .bar .last { flex: 1 1 auto; min-width: 0; font-size: 16px; }

/* ------------------------------------------------------------------ connexion */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: var(--cadran); background-image: radial-gradient(circle at 50% -20%, #2B5176 0, rgba(43,81,118,0) 60%); }
.login-card { width: 100%; max-width: 410px; background: var(--papier); border-radius: 14px; padding: 28px 24px 24px; }
.login-card .brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 18px; text-align: center; }
.login-card .brand h1 { font-size: 26px; }
.login-card .brand p { color: var(--brume); margin: 0; font-size: 16px; }

/* ------------------------------------------------------------------ rapport / impression */
.report { background: #fff; padding: 22px; border: 1px solid var(--filet); }
.report h1 { font-size: 24px; margin-bottom: 4px; }
.report .sig { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 40px; }
.report .sig div { border-top: 1.5px solid var(--encre); padding-top: 6px; font-size: 14.5px; color: var(--brume); }
.only-print { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 12.5pt; }
  .topbar, .tabbar, .rail, .toasts, .sticky-actions, .no-print, .scanbar, .lastscan, .net-banner, .page-actions { display: none !important; }
  .app { display: block; }
  .page { max-width: none; padding: 0; }
  .panel, .report { border: 0; }
  .only-print { display: block; }
  .line { break-inside: avoid; }
  a { color: inherit; }
}

/* ------------------------------------------------------------------ ajouts : choix, routes, mises en page des fiches */
.route { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.route svg { color: var(--brume-2); }
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.choice {
  min-height: 64px; padding: 10px 14px; border: 1.5px solid var(--filet-fort); border-radius: var(--r-lg); background: var(--papier);
  text-align: left; display: flex; flex-direction: column; justify-content: center; gap: 2px; font-size: 17px; font-weight: 700; color: var(--encre);
}
.choice small { font-weight: 400; color: var(--brume); font-size: 14.5px; }
.choice:hover { border-color: var(--cadran); }
.choice[aria-pressed="true"] { border-color: var(--cadran); background: var(--cadran); color: #fff; box-shadow: inset 0 -4px 0 var(--laiton); }
.choice[aria-pressed="true"] small { color: #cbd6e0; }
.formblock { margin-bottom: 20px; }
.formblock > h2 { font-size: 18px; margin-bottom: 10px; }

/* fiche de transfert */
.tdetail { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "scan" "side" "lines"; }
.t-scan { grid-area: scan; }
.t-side { grid-area: side; }
.t-lines { grid-area: lines; min-width: 0; }
@media (min-width: 960px) {
  /* « 1fr » sur la 2e ligne : la hauteur que le panneau latéral réclame en plus va à la liste des lignes, pas à la ligne « scan » (vide hors réception) */
  .tdetail { grid-template-columns: minmax(0, 1fr) 340px; grid-template-rows: auto 1fr; grid-template-areas: "scan side" "lines side"; align-items: start; gap: 16px; }
}
.line[data-state="attente"] { box-shadow: none; }
.line[data-state="partiel"] { box-shadow: inset 4px 0 0 var(--laiton); }
.line .note-input { min-height: 40px; font-size: 16px; }
.line .note-input[aria-invalid="true"] { border-color: var(--ko); background: #FFF8F7; }
.line .extra:not(:empty) { margin-top: 4px; }
.t-side .panel.pad { padding: 14px; }
.sticky-actions:empty { display: none; }

.hstack.stretch > .btn { flex: 1 1 230px; }
.hstack.stretch > .btn.lg { justify-content: flex-start; }
@media (min-width: 960px) { .hstack.stretch > .btn { flex: 0 0 auto; } }

/* ------------------------------------------------------------------ ajouts : activité d'un magasin, commandes SQL, lignes à zéro */
.actrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 10px; padding: 12px 16px; border-bottom: 1px solid var(--filet); align-items: end; }
.actrow .what { grid-column: 1 / -1; min-width: 0; }
.actrow .n { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.actrow .n .l { font-size: 12.5px; color: var(--brume); line-height: 1.15; }
.actrow .n .v { font-family: var(--font-display); font-size: 22px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums lining-nums; }
.actrow .v.zero { color: var(--filet-fort); }
.actrow.head { display: none; }
.actrow.total { background: #F6F8FA; }
.actrow.total .v { font-weight: 700; }
@media (min-width: 760px) {
  .actrow { grid-template-columns: minmax(0, 1fr) repeat(4, 118px); align-items: center; }
  .actrow .what { grid-column: auto; }
  .actrow .n { text-align: right; align-items: flex-end; }
  .actrow .n .l { display: none; }
  .actrow.head { display: grid; position: sticky; top: 0; z-index: 2; background: var(--papier); font-size: 13.5px; color: var(--brume); font-weight: 700; align-items: end; }
}
pre.sql {
  margin: 0 0 8px; padding: 12px 14px; background: var(--cadran); color: #E7EEF5; border-radius: var(--r); font-family: var(--font-code);
  font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto;
}
.ledger > .row.zero .row-title, a.row.zero .row-title { color: var(--brume); }
.ledger > .row.zero .qty, a.row.zero .qty { color: var(--filet-fort); }
.report-table td.num, .report-table th.num { text-align: right; }
.report-table tr.diff td { background: #FFF8F7; }
.report-table th { position: static; }
@media print { table.grid th { position: static; } .report-table { font-size: 11pt; } .report .sig { margin-top: 60px; } }
/* un code-barres ne se coupe jamais en deux lignes (écran comme papier) */
.report-table .code { white-space: nowrap; }
@media print { .report-table .code { font-size: 9.5pt; } }
details > summary { list-style-position: inside; }

/* ------------------------------------------------------------------ barre de scan sur téléphone
   Trois boutons d'outils + le champ tiennent sur 360 px : les boutons gardent leur taille (jamais écrasés)
   et le champ prend le reste, sans l'icône décorative, pour que son texte d'aide reste lisible. */
.scanbar .tool { flex: 0 0 auto; }
.scanbar .scan-field { flex: 1 1 0; }
@media (max-width: 480px) {
  .scanbar { gap: 6px; }
  .scanbar .tool { width: 48px; }
  .scanbar input { padding-left: 12px; padding-right: 8px; font-size: 18px; }
  .scanbar .scan-field svg.lead { display: none; }
}
/* très petit téléphone (360 px) : le champ occupe toute la largeur, les trois outils passent dessous, chacun bien large */
@media (max-width: 380px) {
  .scanbar { flex-wrap: wrap; }
  .scanbar .scan-field { flex: 1 1 100%; }
  .scanbar .tool { flex: 1 1 0; width: auto; min-width: 48px; }
}

/* ------------------------------------------------------------------ écrans tactiles
   Téléphone et tablette : toutes les commandes (même les petits boutons) font au moins 44 px de haut. */
@media (max-width: 959px), (pointer: coarse) {
  .btn.sm { min-height: 44px; }
  .seg button { min-height: 44px; }
  .counts button { min-height: 44px; align-items: center; }
  .stepper button { width: 44px; height: 44px; }
  .stepper .val { height: 44px; }
  .check { min-height: 44px; }
  .line .note-input { min-height: 44px; }
}
