/* Navette — feuille de style (direction UI validée au Gate 4) */
@font-face { font-family: "Barlow"; font-weight: 400; font-display: swap; src: url("fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-weight: 600; font-display: swap; src: url("fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-weight: 700; font-display: swap; src: url("fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }
/* Layout : une seule colonne mobile — bandeau totaux collant en haut, liste au pouce, action « Fin de contrôle » fixe en bas.
   Ordinateur (≥ 1024 px) : panneau latéral fixe (totaux, filtres, fin de contrôle) + tableau des envois. */
:root {
  --bg: #eef1f4; --surface: #ffffff; --ink: #16202b; --muted: #5a6676; --line: #d6dce4;
  --accent: #1d4ed0; --accent-ink: #ffffff;
  --ok: #17703f; --ok-bg: #e2f2e8;
  --warn: #a85300; --warn-bg: #fdecd6;
  --add: #1d4ed0; --add-bg: #e3eafb;
  --pending: #7d8796; --danger: #b8232a; --track: #dfe4ea;
  --shade: rgba(16, 24, 34, .45);
  --f-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --f-body: "Barlow", -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0e1319; --surface: #17202a; --ink: #e7ecf2; --muted: #9aa6b6; --line: #2a3644;
  --accent: #7d9fff; --accent-ink: #0b1220;
  --ok: #62d394; --ok-bg: #12301f; --warn: #ffb257; --warn-bg: #3a2610;
  --add: #8fb0ff; --add-bg: #1a2648; --pending: #7f8a99; --danger: #ff6b6b; --track: #26313d;
  --shade: rgba(0, 0, 0, .6); color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0e1319; --surface: #17202a; --ink: #e7ecf2; --muted: #9aa6b6; --line: #2a3644;
  --accent: #7d9fff; --accent-ink: #0b1220;
  --ok: #62d394; --ok-bg: #12301f; --warn: #ffb257; --warn-bg: #3a2610;
  --add: #8fb0ff; --add-bg: #1a2648; --pending: #7f8a99; --danger: #ff6b6b; --track: #26313d;
  --shade: rgba(0, 0, 0, .6); color-scheme: dark }

* { box-sizing: border-box; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 16px; -webkit-tap-highlight-color: transparent; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.gutter { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wrap { max-width: 560px; margin: 0 auto; }

/* ---------- Écrans plein (connexion, import) ---------- */
.screen-center { min-height: 100%; display: flex; flex-direction: column; justify-content: center; padding-block: 32px; }
.brand { font-family: var(--f-display); font-weight: 700; font-size: 44px; letter-spacing: .02em; margin: 0; }
.brand-sub { color: var(--muted); margin: 4px 0 28px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.field input { font: inherit; font-size: 18px; padding: 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); width: 100%; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 56px; padding: 0 20px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-weight: 600; font-size: 17px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-big { min-height: 72px; font-size: 19px; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.note { font-size: 13px; color: var(--muted); line-height: 1.45; }
.err { color: var(--danger); font-size: 14px; min-height: 1.2em; margin: 0; }

/* ---------- Bandeau collant ---------- */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { padding-block: 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.titlebar { display: flex; align-items: center; gap: 8px; }
.title-block { flex: 1; min-width: 0; }
.title-block .progress { margin: 2px 0 0; font-size: 14px; color: var(--muted); }
.titlebar h1 { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { position: relative; width: 48px; height: 48px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn .pill { position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 600; display: grid; place-items: center; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tot { display: flex; flex-direction: column; min-width: 0; }
.tot-k { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tot-v { font-family: var(--f-display); font-weight: 700; font-size: 28px; line-height: 1.05; }
.tot-s { font-size: 13px; color: var(--muted); }
.gauge { display: flex; flex-direction: column; gap: 4px; }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width .25s; }
.gauge.over .bar i { background: var(--danger); }
.gauge.over b { color: var(--danger); }
.tot .bar { margin-top: 5px; height: 6px; }
.tot .tot-s b { color: var(--ink); font-weight: 600; }
.progress .w { color: var(--warn); font-weight: 600; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--track); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; min-height: 40px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

/* ---------- Lignes ---------- */
.list { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
.row { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border-bottom: 1px solid var(--line); border-left: 6px solid var(--pending); padding-block: 12px; }
.row.st-ok { border-left-color: var(--ok); background: var(--ok-bg); }
.row.st-warn { border-left-color: var(--warn); background: var(--warn-bg); }
.row.st-add { border-left-color: var(--add); background: var(--add-bg); }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; }
.name span:last-child { min-width: 0; overflow-wrap: anywhere; line-height: 1.25; }
.name { font-size: 17px; }
.row-bottom { display: flex; align-items: center; gap: 10px; }
.prev { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.badge { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; border: 2px solid var(--pending); color: var(--pending); }
.st-ok .badge { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.st-warn .badge { background: var(--warn); border-color: var(--warn); color: var(--surface); }
.st-add .badge { background: var(--add); border-color: var(--add); color: var(--surface); }
.meta { font-size: 14px; color: var(--muted); }
.delta { font-size: 14px; font-weight: 600; color: var(--warn); }
.st-add .delta { color: var(--add); }
.prev { font-size: 13px; color: var(--muted); }
.prev b { font-family: var(--f-display); font-size: 22px; color: var(--ink); }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button { width: 52px; height: 52px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); font-size: 26px; font-weight: 500; display: grid; place-items: center; touch-action: manipulation; }
.stepper button:active { transform: scale(.95); }
.stepper .val { width: 56px; font-family: var(--f-display); font-weight: 700; font-size: 30px; border-width: 2px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.st-pending .val { color: var(--pending); }
.add-line { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent; min-height: 60px; color: var(--accent); font-weight: 600; font-size: 16px; }
.empty { padding-block: 40px; text-align: center; color: var(--muted); }
.demo-tag { font-size: 12px; color: var(--muted); padding-block: 8px; }

/* ---------- Barre basse ---------- */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--line); padding-top: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
.bottom .btn { width: 100%; }

/* ---------- Feuilles (bottom sheets) ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--shade); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; max-height: 92%; overflow-y: auto; background: var(--surface); border-radius: 18px 18px 0 0; padding-top: 10px; padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
.sheet h2 { margin: 0; font-family: var(--f-display); font-weight: 700; font-size: 26px; }
.sheet-sub { margin: -8px 0 0; color: var(--muted); font-size: 14px; }
.pad-display { display: flex; align-items: baseline; justify-content: center; gap: 14px; padding-block: 4px; }
.pad-display .big { font-family: var(--f-display); font-weight: 700; font-size: 64px; line-height: 1; min-width: 1.2em; text-align: center; }
.pad-display .vs { color: var(--muted); }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keys button { min-height: 60px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--bg); font-family: var(--f-display); font-weight: 600; font-size: 28px; touch-action: manipulation; }
.keys .k-small { font-family: var(--f-body); font-size: 15px; font-weight: 600; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.recap { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.recap div { background: var(--bg); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; }
.recap b { font-family: var(--f-display); font-size: 28px; }
.recap span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.alert { background: var(--warn-bg); color: var(--ink); border-left: 4px solid var(--warn); padding: 10px 12px; border-radius: 6px; font-size: 15px; }
.ecarts { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; font-size: 15px; }
.ecarts li b { white-space: nowrap; }
.ecarts li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.mail { background: var(--bg); border-radius: 10px; padding: 12px; font-size: 14px; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.mail span { color: var(--muted); }
.success { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.success .tick { width: 72px; height: 72px; border-radius: 50%; background: var(--ok); color: var(--surface); display: grid; place-items: center; font-size: 40px; font-weight: 700; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumbs button { padding: 0; border: 0; border-radius: 10px; overflow: hidden; aspect-ratio: 1; max-width: 100%; background: var(--bg); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewer { position: fixed; inset: 0; z-index: 30; background: #000; display: flex; align-items: center; justify-content: center; }
.viewer img { max-width: 100%; max-height: 100%; }
.viewer button { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.9); color: #111; font-size: 22px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(100px + env(safe-area-inset-bottom, 0px)); z-index: 40; background: var(--ink); color: var(--surface); padding: 12px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 360px) { .stepper button { width: 46px; height: 46px; } .stepper .val { width: 48px; } .tot-v { font-size: 26px; } }
.full { width: 100%; }
html { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* Colonnes réservées à la vue ordinateur */
.c, .thead { display: none; }

/* ================= Ordinateur (≥ 1024 px) ================= */
@media (min-width: 1024px) {
  :root { --side: 340px; }
  body::before { display: none; }
  #scr-main:not([hidden]) { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100%; }
  .wrap { max-width: none; }

  /* Panneau latéral */
  .top { position: sticky; top: 0; height: 100vh; overflow-y: auto; border-bottom: 0; border-right: 1px solid var(--line); }
  .top-in { padding: 24px 24px 120px; gap: 20px; }
  .titlebar { flex-wrap: wrap; }
  .titlebar h1 { font-size: 26px; white-space: normal; }
  .title-block { flex-basis: 100%; order: 2; }
  .totals { grid-template-columns: 1fr; gap: 18px; }
  .tot-v { font-size: 38px; }
  .seg { grid-template-columns: 1fr; }
  .seg button { text-align: left; padding: 0 14px; }
  .bottom { left: 0; right: auto; width: var(--side); border-right: 1px solid var(--line); padding-inline: 24px; }
  .bottom .gutter { padding: 0; }

  /* Tableau des envois */
  .list { padding: 24px 32px 48px; }
  .thead, .row {
    display: grid; align-items: center; column-gap: 16px;
    grid-template-columns: minmax(160px, 2fr) minmax(120px, 1.2fr) 96px 88px 70px 48px 160px minmax(110px, 1fr);
    grid-template-areas: "name ville ref kg m prev step delta";
  }
  .thead { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 0 16px 8px 22px; border-bottom: 2px solid var(--line);
           font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
  .thead span:nth-child(n+4):nth-child(-n+6) { text-align: right; }
  .thead span:nth-child(7) { text-align: center; }
  .row { padding: 6px 16px; row-gap: 0; }
  .row:hover { filter: brightness(.98); }
  .row-bottom, .row-main { display: contents; }
  .meta { display: none; }
  .c { display: block; min-width: 0; overflow-wrap: break-word; color: var(--muted); font-size: 15px; }
  .name { grid-area: name; font-size: 16px; }
  .c-ville { grid-area: ville; }
  .c-ref { grid-area: ref; }
  .c-kg { grid-area: kg; text-align: right; color: var(--ink); }
  .c-m { grid-area: m; text-align: right; color: var(--ink); }
  .prev { grid-area: prev; align-items: flex-end; }
  .prev { font-size: 0; }                       /* le libellé « Prévu » est dans l'en-tête */
  .prev b { font-size: 22px; }
  .stepper { grid-area: step; justify-content: center; }
  .stepper button { width: 44px; height: 44px; font-size: 22px; border-radius: 10px; }
  .stepper .val { width: 52px; font-size: 26px; }
  .delta { grid-area: delta; }
  .add-line { text-align: left; padding-left: 22px; }

  /* Fenêtres centrées */
  .overlay { align-items: center; }
  .sheet { max-width: 480px; max-height: 85vh; border-radius: 18px; padding-block: 20px 24px; }
  .grab { display: none; }
  .toast { left: calc(var(--side) + (100% - var(--side)) / 2); bottom: 32px; }
}
