/* GPM — Gestion Plainte McDonald's
   Rail à bons : rail inox, bons papier blancs, encre noire.
   Une seule couleur d'action : le vert sapin de GPM. Ambre pour ce qui expire, rouge pour les erreurs. */

:root {
    --bg: #e8eaeb;
    --steel-0: #f4f5f6;
    --steel-2: #d5d9db;
    --steel-3: #aab0b4;
    --card: #ffffff;
    --line: #e3e5e7;
    --line-2: #c9ced1;
    --ink: #131517;
    --ink-2: #3d4247;
    --ink-3: #5f666c;
    --ink-4: #8a9095;

    --signal: #1d5b52;
    --signal-press: #174a43;
    --signal-soft: #e5efec;
    /* Avertissement (expire bientôt, expiré) et erreur / suppression */
    --warn: #8a5a00;
    --warn-soft: #fbf2dd;
    --danger: #c0143c;
    --danger-soft: #fde8ed;
    --done: #1d6b45;
    --done-soft: #e7f2ec;
    --void: #6a7075;
    --grey-soft: #eef0f1;

    /* Alias des anciennes teintes : tout le code existant suit la nouvelle palette */
    --teal: var(--ink);
    --teal-hover: #000;
    --teal-soft: var(--grey-soft);
    --teal-line: var(--line-2);
    --rose: var(--danger);
    --rose-soft: var(--danger-soft);
    --rose-line: #f2c3ad;
    --amber: var(--warn);
    --amber-soft: var(--warn-soft);
    --blue: var(--ink);
    --blue-soft: var(--grey-soft);

    --r-sm: 10px;
    --r: 14px;
    --r-lg: 20px;
    --shadow: 0 1px 2px rgba(19, 21, 23, .08);
    --shadow-lg: 0 20px 50px rgba(19, 21, 23, .2);
    --paper-shadow: drop-shadow(0 8px 14px rgba(19, 21, 23, .13)) drop-shadow(0 1px 1px rgba(19, 21, 23, .1));

    --font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
    --ease: cubic-bezier(.16, 1, .3, 1);
    --nav-h: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    font-variation-settings: "wdth" 100;
    background: var(--bg);
    color: var(--ink);
    font-size: 16px;
    line-height: 1.45;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}
::selection { background: var(--ink); color: #fff; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
a.item, a.lrow, a.bon, a.user-pill, a.nav-item, a.btn, a.icon-btn { text-decoration: none; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

h1, h2, h3 { line-height: 1.1; color: var(--ink); }
h1 { font-size: 2rem; font-weight: 900; font-variation-settings: "wdth" 62; text-transform: uppercase; letter-spacing: 0; }
h2 { font-size: 1.3rem; font-weight: 800; }
h3 { font-size: 1rem; font-weight: 700; }
.muted { color: var(--ink-3); }
.small { font-size: .875rem; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

svg.lucide { width: 21px; height: 21px; stroke-width: 2.2; flex-shrink: 0; }

/* Petit libellé (À REMETTRE, CLIENT…) */
.label, .eyebrow {
    display: block;
    font-size: .72rem; font-weight: 800; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: .08em;
}

/* ---------- Marque ---------- */
.brand { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.brand-mark {
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--ink); color: #fff; display: grid; place-items: center; flex-shrink: 0;
}
.brand-mark svg.lucide { width: 22px; height: 22px; }
.brand-mark.lg { width: 64px; height: 64px; border-radius: 18px; }
.brand-mark.lg svg.lucide { width: 30px; height: 30px; }
.brand-text { min-width: 0; }
.brand-text .eyebrow { font-size: .7rem; }
.brand-name { font-weight: 800; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Boutons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .55rem;
    min-height: 50px; padding: 0 1.2rem;
    border-radius: var(--r); border: 1.5px solid transparent;
    font-weight: 800; font-size: 1rem;
    transition: background .15s, border-color .15s, transform .12s var(--ease);
    -webkit-tap-highlight-color: transparent; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* Action principale : la seule touche de couleur */
.btn-primary, .btn-gold { background: var(--signal); color: #fff; }
.btn-primary:hover:not(:disabled), .btn-gold:hover:not(:disabled) { background: var(--signal-press); }
.btn-success { background: var(--done); color: #fff; }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ghost { background: var(--card); border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); }
.btn-soft { background: var(--grey-soft); color: var(--ink); }
.btn-danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-lg { min-height: 60px; font-size: 1.08rem; border-radius: 16px; }
.btn-sm { min-height: 42px; padding: 0 .95rem; font-size: .9rem; border-radius: 12px; }
.icon-btn {
    width: 46px; height: 46px; border-radius: 12px;
    display: grid; place-items: center;
    background: transparent; border: none; color: var(--ink-2);
}
.icon-btn:hover { background: var(--grey-soft); color: var(--ink); }
.page-head .icon-btn.back { background: var(--card); box-shadow: var(--shadow); color: var(--ink); }

.spinner {
    width: 18px; height: 18px; border-radius: 50%;
    border: 2.5px solid currentColor; border-right-color: transparent;
    animation: spin .7s linear infinite;
}
.spinner.lg { width: 32px; height: 32px; border-width: 3px; color: var(--ink-3); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Formulaires ---------- */
.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.field > label { font-size: .86rem; font-weight: 700; color: var(--ink-2); }
.field .hint { font-size: .8rem; color: var(--ink-3); }
.req { color: var(--danger); }
.input {
    min-width: 0; max-width: 100%;
    width: 100%; min-height: 54px; padding: .75rem .95rem;
    background: var(--card); border: 1.5px solid var(--line-2); border-radius: var(--r);
    font-size: 1.05rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 88px; resize: vertical; }
.input:focus { border-color: var(--ink); box-shadow: 0 0 0 4px rgba(19, 21, 23, .08); }
.input::placeholder { color: var(--ink-4); }
.input.code {
    font-family: var(--font); font-variation-settings: "wdth" 62; font-weight: 900;
    font-size: 2.2rem; letter-spacing: .3em; text-indent: .3em; text-align: center; text-transform: uppercase;
    min-height: 72px; border-width: 2px;
}
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.row > * { min-width: 0; }
.order-datetime { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: .65rem; }
.contact-hint { color: var(--ink-3); font-size: .82rem; margin: -.35rem 0 .85rem; }
.input-lead { min-height: 76px; font-family: var(--mono); font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .06em; }
.when-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: -.4rem 0 1rem; color: var(--ink-2); font-size: .92rem; }
.when-bar button { background: none; border: 0; color: var(--ink); font-weight: 800; text-decoration: underline; text-underline-offset: 4px; min-height: 44px; padding: 0 .15rem; }
#newForm .chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#newForm .chip-main { min-height: 72px; font-size: 1.02rem; font-weight: 800; }
#newForm .chips-rest { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
#newForm .chips-rest .chip { min-height: 52px; font-size: .88rem; }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
#newForm .input { scroll-margin: 100px 0; }

.check { display: flex; align-items: center; gap: .75rem; font-weight: 700; cursor: pointer; min-height: 54px; padding: 0 .9rem; border: 1.5px solid var(--line-2); border-radius: var(--r); margin-bottom: .5rem; background: var(--card); }
.check:has(input:checked) { border-color: var(--ink); }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }
.check.disabled { color: var(--ink-3); cursor: not-allowed; background: var(--grey-soft); }

/* Choix du problème */
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: .5rem; margin-bottom: 1rem; }
.chip {
    display: flex; align-items: center; gap: .6rem;
    min-height: 56px; padding: .6rem .8rem; text-align: left; line-height: 1.2;
    background: var(--card); border: 1.5px solid var(--line-2); border-radius: var(--r);
    font-weight: 700; font-size: .92rem; color: var(--ink);
    transition: border-color .15s, background .15s;
}
.chip svg.lucide { width: 20px; height: 20px; color: var(--ink-3); }
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: #fff; }
.chip[aria-pressed="true"] svg.lucide { color: #fff; }

.quick { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .2rem; }
.quick button {
    min-height: 38px; padding: 0 .85rem; border-radius: 999px; font-size: .85rem; font-weight: 700;
    background: var(--grey-soft); border: 1.5px solid transparent; color: var(--ink-2);
}
.quick button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* Gestes les plus donnés : tuiles photo, un appui = +1 */
.gift-quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin: .8rem 0 .4rem; }
.gift-tile {
    position: relative; display: grid; justify-items: center; align-content: start; gap: .3rem;
    padding: .55rem .35rem .6rem; min-height: 112px;
    background: var(--card); border: 1.5px solid var(--line-2); border-radius: 16px;
    font-weight: 700; font-size: .8rem; line-height: 1.15; text-align: center;
    transition: border-color .15s, transform .12s var(--ease);
}
.gift-tile:active { transform: scale(.96); }
.gift-tile img { width: 64px; height: 56px; object-fit: contain; }
.gift-tile.on { border: 2.5px solid var(--ink); padding: calc(.55rem - 1px) calc(.35rem - 1px) calc(.6rem - 1px); }
.gift-tile .gift-n {
    position: absolute; top: 6px; right: 6px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px;
    background: var(--ink); color: #fff; font-family: var(--mono); font-size: .8rem; font-weight: 700;
    display: grid; place-items: center;
}
.gift-cell { position: relative; display: grid; }
.gift-minus {
    position: absolute; top: 4px; left: 4px; width: 34px; height: 34px; border-radius: 17px; border: 0;
    background: var(--grey-soft); color: var(--ink); display: grid; place-items: center; font-size: 1.2rem; font-weight: 800; line-height: 1;
}
.gift-hint { font-size: .8rem; color: var(--ink-3); }

/* ---------- Catalogue (ajout au texte) ---------- */
.product-picker { border-top: 1px solid var(--line); margin-top: .25rem; }
.product-picker summary { padding: .8rem 0; color: var(--ink); font-size: .9rem; font-weight: 800; cursor: pointer; min-height: 44px; }
.product-tools { display: grid; grid-template-columns: minmax(0, 1fr) 85px; gap: .65rem; }
.product-tools label { display: grid; gap: .4rem; min-width: 0; font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.product-tools label:first-child { grid-column: 1 / -1; }
.product-count { margin: .75rem 0 .4rem; }
.product-results { list-style: none; max-height: 260px; overflow-y: auto; overscroll-behavior: contain; border-block: 1px solid var(--line); }
.product-option { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .75rem .5rem; min-height: 48px; border: 0; border-bottom: 1px solid var(--line); background: var(--card); text-align: left; font-size: .9rem; font-weight: 600; }
.product-option > span:first-child { overflow-wrap: anywhere; }
.product-option > span:last-child { font-size: 1.3rem; font-weight: 800; }
.product-option:hover { background: var(--grey-soft); }
.product-added { color: var(--done); font-weight: 700; margin-top: .5rem; }
.product-added:empty { display: none; }
.product-note { font-size: .75rem; margin-top: .65rem; }

/* ---------- Feuilles ---------- */
.card { background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: 1.3rem 1.15rem; }
.card + .card { margin-top: .9rem; }
.card-section { padding: 1.25rem 1.15rem; }
.card-section + .card-section { border-top: 1.5px dashed var(--line-2); }
.section-title {
    font-size: 1.1rem; font-weight: 800; color: var(--ink); margin: 1.6rem 0 .8rem;
}
.card-pad > .section-title:first-child, .section-title:first-child { margin-top: 0; }

/* Le bon : papier blanc, bord dentelé, pince métal */
.hang-big { position: relative; filter: var(--paper-shadow); margin-top: 14px; }
.card.bon-sheet {
    border-radius: 4px 4px 0 0; box-shadow: none; padding-bottom: 10px;
    -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 16px 100%;
            mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 16px 100%;
}
.clip {
    position: absolute; top: -9px; left: 50%; width: 48px; height: 26px; margin-left: -24px; z-index: 3;
    border-radius: 5px 5px 8px 8px; background: linear-gradient(180deg, #eef0f1, #9da3a8 55%, #c8ccce);
    box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18), 0 2px 3px rgba(0, 0, 0, .2);
}
.clip::after { content: ""; position: absolute; left: 9px; right: 9px; top: 9px; height: 3px; border-radius: 2px; background: rgba(0, 0, 0, .25); }

/* Tampon de statut posé sur le bon */
.stamp {
    position: absolute; top: 120px; left: 50%; z-index: 4; pointer-events: none;
    transform: translateX(-50%) rotate(-11deg);
    font-size: 2.9rem; font-weight: 900; font-variation-settings: "wdth" 62; letter-spacing: .08em; text-transform: uppercase;
    padding: 2px 16px; border: 5px solid currentColor; border-radius: 12px; color: var(--done); opacity: .85; mix-blend-mode: multiply;
    white-space: nowrap;
}
.stamp.void { color: var(--void); }
.stamp.hot { color: var(--warn); }
.stamp.slam { animation: slam .55s var(--ease) both; }
@keyframes slam {
    0% { opacity: 0; transform: translateX(-50%) rotate(-24deg) scale(2.3); filter: blur(6px); }
    55% { opacity: 1; filter: blur(0); }
    100% { transform: translateX(-50%) rotate(-11deg) scale(1); }
}

/* Pastille texte libre */
.pill {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .55rem 1rem; border-radius: 999px;
    background: var(--grey-soft); color: var(--ink); font-weight: 700; font-size: 1rem; line-height: 1.3;
}

/* ---------- Badges (tampons miniatures) ---------- */
.badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: 1px 6px; border: 1.5px solid currentColor; border-radius: 4px;
    font-size: .66rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
}
.b-pending { color: var(--ink); }
.b-resolved { color: var(--done); }
.b-expired { color: var(--warn); }
.b-cancelled, .b-archived { color: var(--void); }
.b-admin { color: var(--ink); }
.b-manager { color: var(--ink-3); }

/* ---------- Toast ---------- */
.toast {
    position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
    transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
    background: var(--ink); color: #fff; padding: .85rem 1.15rem; border-radius: var(--r);
    font-weight: 700; font-size: .92rem; box-shadow: var(--shadow-lg);
    max-width: calc(100vw - 32px); width: max-content; z-index: 100;
    transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--done); }
body.no-nav .toast { bottom: 24px; }

/* ---------- Modale ---------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(19, 21, 23, .5); z-index: 90;
    display: flex; align-items: flex-end; justify-content: center;
}
.modal {
    background: var(--card); width: 100%; max-width: 480px;
    border-radius: 24px 24px 0 0; padding: 1.6rem 1.3rem calc(1.3rem + env(safe-area-inset-bottom));
    box-shadow: var(--shadow-lg); animation: up .3s var(--ease);
    max-height: 92dvh; overflow-y: auto;
}
.modal h2 { margin-bottom: .4rem; }
.modal p { color: var(--ink-3); margin-bottom: 1.1rem; }
.modal-actions { display: flex; gap: .6rem; margin-top: 1.3rem; }
.modal-actions .btn { flex: 1; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@media (min-width: 640px) {
    .modal-backdrop { align-items: center; padding: 1rem; }
    .modal { border-radius: 24px; }
}

/* =========================================================
   Pages centrées : connexion, installation
   ========================================================= */
.center-page {
    min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 28px 16px;
}
.center-box { width: 100%; max-width: 420px; }
.center-head { text-align: center; margin-bottom: 1.6rem; }
.center-head .brand-mark { margin: 0 auto 1.1rem; }
.center-head p { color: var(--ink-3); margin-top: .35rem; }
.center-foot { text-align: center; margin-top: 1.25rem; font-size: .85rem; color: var(--ink-3); display: flex; gap: .4rem; align-items: center; justify-content: center; }
.center-foot svg.lucide { width: 15px; height: 15px; }
.form-error {
    background: var(--danger-soft); color: var(--danger); border-radius: var(--r);
    padding: .8rem .95rem; font-weight: 700; font-size: .9rem; margin-bottom: 1.1rem;
}
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 52px; }
.pw-wrap .icon-btn { position: absolute; right: 4px; top: 4px; }

/* =========================================================
   Application (managers)
   ========================================================= */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .45rem 16px; padding-top: calc(.45rem + env(safe-area-inset-top));
    background: rgba(232, 234, 235, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
.topbar .brand-mark svg.lucide { width: 18px; height: 18px; }
.topbar .avatar { width: 30px; height: 30px; font-size: .8rem; }
.user-pill {
    display: flex; align-items: center; gap: .55rem; flex-shrink: 0;
    padding: .3rem .35rem .3rem .8rem; border-radius: 999px;
    background: var(--card); font-weight: 700; font-size: .875rem; box-shadow: var(--shadow);
}
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--ink); color: #fff; display: grid; place-items: center;
    font-weight: 800; font-size: .85rem; text-transform: uppercase; flex-shrink: 0;
}

.main { max-width: 760px; margin: 0 auto; padding: .5rem 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.1rem; }
.page-head-left { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.page-head h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-sub { font-size: .88rem; color: var(--ink-3); margin-top: .25rem; }
/* Accueil : titre et date sur une seule ligne */
.list-head { align-items: baseline; margin-bottom: .5rem; }
.list-head h1 { font-size: 1.7rem; }
.page-date { font-size: .85rem; color: var(--ink-3); white-space: nowrap; }

/* Navigation au pouce (mobile) / latérale (ordinateur) */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    background: rgba(232, 234, 235, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line-2);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: none; border-radius: 14px; color: var(--ink-3);
    font-size: .72rem; font-weight: 800; -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--ink); background: var(--card); box-shadow: var(--shadow); }
.nav-item[data-nav="new"] { background: var(--signal); color: #fff; box-shadow: 0 4px 10px rgba(19, 21, 23, .18); }
.nav-item[data-nav="new"]:active { background: var(--signal-press); }
.nav-item .nav-plus { display: grid; place-items: center; }
.nav-item .nav-plus svg.lucide { width: 24px; height: 24px; stroke-width: 2.8; }

@media (min-width: 900px) {
    .bottom-nav {
        top: 0; bottom: 0; right: auto; width: 104px; height: auto; gap: 8px;
        grid-auto-flow: row; grid-auto-rows: 76px; align-content: start; padding: 96px 12px 12px;
        border-top: none; border-right: 1px solid var(--line-2); background: var(--steel-0);
    }
    .topbar { padding-left: 120px; }
    .main { padding-left: 120px; max-width: 900px; padding-bottom: 48px; }
    .toast { bottom: 24px; }
}

/* ---------- Le rail des bons à remettre ---------- */
.rail-head { display: flex; justify-content: space-between; align-items: baseline; margin: 0; }
.rail-head strong { font-size: 1.05rem; font-weight: 800; }
.rail-head .mono { font-size: .8rem; color: var(--ink-3); }
.rail-wrap { position: relative; margin: 0 -16px 1.1rem; padding-top: 10px; }
.rail-bar {
    position: absolute; left: 0; right: 0; top: 16px; height: 12px; z-index: 2;
    background: linear-gradient(180deg, #fbfbfc 0%, #c3c8cb 40%, #8f969b 62%, #d9dcde 100%);
    box-shadow: 0 3px 6px rgba(19, 21, 23, .18);
}
.rail {
    display: flex; gap: 14px; overflow-x: auto; scroll-snap-type: x mandatory;
    padding: 14px 16px 22px; scroll-padding: 16px; scrollbar-width: none; align-items: flex-start;
}
.rail::-webkit-scrollbar { display: none; }
.hang {
    position: relative; flex: 0 0 236px; scroll-snap-align: start; filter: var(--paper-shadow);
    transform-origin: 50% 0; transition: transform .5s var(--ease);
}
.hang:nth-child(odd) { transform: rotate(-.6deg); }
.hang:nth-child(even) { transform: rotate(.5deg); }
.hang:active { transform: translateY(3px); }
.bon {
    position: relative; display: block; width: 100%; text-align: left; background: var(--card);
    padding: 26px 16px 24px; border: 0;
    -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 16px 100%;
            mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 16px 100%;
}
.bon-top { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-family: var(--mono); font-size: .76rem; color: var(--ink-3); }
.bon-age { font-weight: 700; color: var(--ink); }
.bon.hot .bon-age { color: var(--warn); }
.bon-code { font-size: 2.9rem; line-height: .9; font-weight: 900; font-variation-settings: "wdth" 62; letter-spacing: .02em; margin: 10px 0 6px; }
.bon-name { font-weight: 800; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bon-why { font-size: .86rem; color: var(--ink-3); }
.bon-lines { list-style: none; border-top: 1.5px dashed var(--line-2); margin-top: 12px; padding-top: 10px; display: grid; gap: 6px; }
.bon-lines li { display: flex; align-items: center; gap: 9px; font-size: .9rem; font-weight: 700; min-width: 0; }
.bon-lines li > span:nth-child(2) { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bon-lines .q { font-family: var(--mono); font-size: .8rem; }
.bon-lines .tag { font-size: .62rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.bon-lines .product-photo { width: 34px; height: 34px; border-radius: 8px; }
.bon-hot { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; font-size: .78rem; font-weight: 800; color: var(--warn); }
.bon-hot svg.lucide { width: 16px; height: 16px; }
.rail-empty {
    margin: 4px 16px 0; padding: 26px 16px; text-align: center; color: var(--ink-3); font-weight: 600;
    border: 2px dashed var(--line-2); border-radius: 6px; background: rgba(255, 255, 255, .4);
}

/* Recherche + onglets */
.search { position: relative; margin-bottom: .8rem; }
.search svg.lucide { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 19px; height: 19px; }
.search .input { padding-left: 46px; }
.tabs { display: flex; gap: .4rem; overflow-x: auto; scrollbar-width: none; margin: 0 -16px .8rem; padding: 0 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex-shrink: 0; min-height: 42px; padding: 0 .95rem; border-radius: 999px;
    background: var(--card); border: 1.5px solid var(--line-2); font-weight: 700; font-size: .9rem; color: var(--ink-2);
    display: inline-flex; align-items: center;
}
.tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab .count { margin-left: .4rem; font-family: var(--mono); font-size: .75rem; opacity: .7; }

/* Registre des bons décrochés */
.list { display: block; background: var(--card); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.list:has(> .empty) { background: transparent; box-shadow: none; }
.lrow {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center;
    width: 100%; padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.lrow:last-child { border-bottom: 0; }
.lrow:hover { background: var(--steel-0); }
.lrow-name { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow-code { font-family: var(--mono); font-weight: 700; font-size: .85rem; letter-spacing: .04em; text-align: right; }
.lrow-sub { font-size: .84rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow-side { display: flex; align-items: center; gap: 8px; justify-content: flex-end; font-family: var(--mono); font-size: .74rem; color: var(--ink-3); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--ink-3); }
.empty svg.lucide { width: 34px; height: 34px; margin-bottom: .6rem; color: var(--ink-4); }
.empty p { font-weight: 600; }
.loading { display: flex; justify-content: center; padding: 3rem; }

/* =========================================================
   Bon (fiche manager, validation et page client)
   ========================================================= */
.status-row { display: flex; align-items: center; gap: .9rem; }
.status-icon {
    width: 52px; height: 52px; border-radius: 14px; flex-shrink: 0;
    display: grid; place-items: center; background: var(--grey-soft); color: var(--ink);
}
.status-icon svg.lucide { width: 26px; height: 26px; }
.status-icon.rose { background: var(--danger-soft); color: var(--danger); }
.status-icon.amber { background: var(--warn-soft); color: var(--warn); }
.status-icon.grey { background: var(--grey-soft); color: var(--void); }
.status-icon.done { background: var(--done-soft); color: var(--done); }
.status-main { flex: 1; min-width: 0; }
.status-title { font-size: 1.35rem; font-weight: 900; font-variation-settings: "wdth" 75; line-height: 1.15; color: var(--ink); }
.status-title.rose { color: var(--danger); }
.status-title.amber { color: var(--warn); }
.status-title.grey { color: var(--ink-2); }
.status-title.done { color: var(--done); }
.status-aside { text-align: right; flex-shrink: 0; }
.status-aside .val { font-family: var(--mono); font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.center-block { text-align: center; }
.center-block .lead { color: var(--ink-3); margin-top: .35rem; }
.big-title { font-size: 1.6rem; font-weight: 900; font-variation-settings: "wdth" 70; line-height: 1.1; }
.big-sub { display: flex; align-items: center; justify-content: center; gap: .45rem; color: var(--ink-2); margin-top: .5rem; }
.big-sub svg.lucide { width: 18px; height: 18px; color: var(--ink-3); }

.qr-frame { display: inline-block; margin: 1rem auto 0; padding: 8px; background: #fff; }
.qr-frame img, .qr-frame canvas { display: block; width: 200px; height: 200px; image-rendering: pixelated; }

/* Code client : écrit en très grand, comme au marqueur */
.code-box {
    margin-top: .3rem; padding: 0;
    font-family: var(--font); font-variation-settings: "wdth" 62; font-size: 4.2rem; font-weight: 900;
    letter-spacing: .06em; text-indent: .06em; line-height: 1; color: var(--ink); text-align: center;
}

.steps { display: flex; flex-direction: column; gap: .5rem; margin-top: 1.4rem; text-align: left; }
.step { display: flex; align-items: center; gap: .9rem; padding: .9rem 1rem; background: var(--steel-0); border-radius: 14px; }
.step-n {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--ink); color: #fff; display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: .9rem;
}
.step-t { font-size: .98rem; color: var(--ink); line-height: 1.35; }

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.meta-grid .val { font-family: var(--mono); font-size: 1.05rem; font-weight: 700; margin-top: .25rem; }
.meta-grid .sub { color: var(--ink-3); font-size: .92rem; }

.note-box { display: flex; gap: .8rem; align-items: flex-start; padding: .95rem 1rem; background: var(--steel-0); border-radius: 14px; margin-top: .6rem; }
.note-box svg.lucide { color: var(--ink-3); margin-top: 2px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .6rem 1rem; font-size: .95rem; }
.kv dt { color: var(--ink-3); }
.kv dd { text-align: right; font-weight: 700; overflow-wrap: anywhere; }
.kv dd a { color: var(--ink); text-underline-offset: 3px; }

.alert { display: flex; gap: .75rem; align-items: flex-start; border-radius: 14px; padding: .95rem 1.05rem; font-size: .92rem; font-weight: 600; }
.alert svg.lucide { margin-top: 1px; width: 18px; height: 18px; }
.alert-red { background: var(--danger-soft); color: var(--danger); }
.alert-gold { background: var(--warn-soft); color: var(--warn); }
.alert-green { background: var(--done-soft); color: var(--done); }
.alert-grey { background: var(--grey-soft); color: var(--ink-2); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: 1rem; }
.actions .full { grid-column: 1 / -1; }
/* L'action principale reste sous le pouce pendant qu'on fait défiler le bon */
.action-dock { position: sticky; bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom)); z-index: 15; margin-top: 1rem; }
.action-dock .btn { min-height: 64px; font-size: 1.12rem; border-radius: 18px; box-shadow: 0 6px 16px rgba(19, 21, 23, .22); }
@media (min-width: 900px) { .action-dock { bottom: 16px; } }

.timeline { list-style: none; position: relative; padding-left: 1.3rem; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 7px; bottom: 7px; width: 2px; background: var(--line-2); }
.timeline li { position: relative; padding-bottom: .95rem; font-size: .92rem; }
.timeline li::before { content: ""; position: absolute; left: -1.3rem; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--ink); }
.timeline li:last-child { padding-bottom: 0; }
.timeline .t-what { font-weight: 700; }
.timeline .t-when { font-family: var(--mono); color: var(--ink-3); font-size: .76rem; }
.timeline .t-comment { font-style: italic; color: var(--ink-2); }

/* Équipe */
.member { display: flex; align-items: center; gap: .85rem; padding: .9rem 1.1rem; }
.member + .member { border-top: 1px solid var(--line); }
.member-info { flex: 1; min-width: 0; }
.member-name { font-weight: 800; }
.member-user { font-family: var(--mono); font-size: .82rem; color: var(--ink-3); }
.member.off { opacity: .55; }

/* Page ticket (client et validation) */
.ticket-page { max-width: 460px; margin: 0 auto; padding: calc(20px + env(safe-area-inset-top)) 16px 40px; }
.ticket-page > .brand { margin-bottom: 1.1rem; }
.ticket-page .hang-big + .card { margin-top: 1rem; }
.ticket-foot { text-align: center; color: var(--ink-3); font-size: .9rem; margin-top: 1.5rem; }
.ticket-foot .mono { display: block; margin-top: .3rem; font-size: .8rem; letter-spacing: .04em; }

.done-anim { animation: pop .45s var(--ease) both; }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }

/* Glisser pour confirmer la remise */
.slide {
    position: relative; height: 66px; border-radius: 20px; background: var(--ink); color: #fff;
    overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
}
.slide-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--signal); }
.slide-label { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; padding-left: 64px; padding-right: 14px; font-weight: 800; font-size: 1rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.slide-knob:active { cursor: grabbing; }
.slide-knob {
    position: absolute; top: 6px; left: 6px; width: 54px; height: 54px; border-radius: 15px; border: 0; padding: 0; z-index: 2;
    -webkit-tap-highlight-color: transparent; touch-action: none;
    background: #fff; color: var(--ink); display: grid; place-items: center; cursor: grab;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}
.slide-knob svg.lucide { width: 26px; height: 26px; }
.slide.done, .slide.done .slide-fill { background: var(--done); }
.slide.busy { opacity: .7; pointer-events: none; }

@media (max-width: 600px) {
    #newForm .card-pad { padding: 1.1rem; }
    #newForm .section-title { margin-top: 1.4rem; }
    #newForm .section-title:first-child { margin-top: 0; }
    #newForm .chip { padding: .6rem; gap: .45rem; }
    .topbar .brand { gap: .6rem; }
    .topbar .user-pill { padding: .3rem; }
    .topbar #userName { display: none; }
    .topbar .brand-text .eyebrow { display: none; }
}
@media (max-width: 380px) {
    .row { grid-template-columns: 1fr; gap: 0; }
    #newForm .name-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
    .code-box { font-size: 3.4rem; }
    .status-row { gap: .7rem; }
    .status-title { font-size: 1.15rem; }
    .gift-quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Scanner QR */
.scan-box {
    position: relative; margin: 0 auto; width: 100%; max-width: 360px; aspect-ratio: 1;
    border-radius: 24px; overflow: hidden; background: #0e1012;
}
.scan-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Quatre coins de visée */
.scan-frame {
    position: absolute; inset: 17%;
    --c: linear-gradient(#fff, #fff);
    background:
        var(--c) 0 0 / 40px 5px, var(--c) 0 0 / 5px 40px,
        var(--c) 100% 0 / 40px 5px, var(--c) 100% 0 / 5px 40px,
        var(--c) 0 100% / 40px 5px, var(--c) 0 100% / 5px 40px,
        var(--c) 100% 100% / 40px 5px, var(--c) 100% 100% / 5px 40px;
    background-repeat: no-repeat;
}
.scan-msg {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .75rem;
    padding: 1.5rem; text-align: center; color: #fff; background: #0e1012; font-size: .95rem;
}
.scan-msg svg.lucide { width: 30px; height: 30px; opacity: .8; }
.scan-or { display: flex; align-items: center; gap: 12px; margin: 1.3rem 0 .9rem; color: var(--ink-3); font-size: .85rem; font-weight: 700; }
.scan-or::before, .scan-or::after { content: ""; flex: 1; height: 1px; background: var(--line-2); }

/* Produits : recherche visible, choix visuels, commentaire séparé. */
.missing-picker { margin-bottom: 1.1rem; scroll-margin-top: 100px; }
.missing-search-label { display: grid; gap: .65rem; font-size: 1.1rem; font-weight: 800; color: var(--ink); }
.missing-search { min-height: 56px; }
.missing-category-label { display: grid; gap: .35rem; font-size: .8rem; color: var(--ink-3); margin-top: .85rem; }
.missing-count { margin: .9rem 0 .4rem; font-size: .8rem; }
.missing-grid { display: grid; grid-template-columns: minmax(0, 1fr); list-style: none; }
.missing-product { width: 100%; display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: .7rem; padding: .55rem 0; border-bottom: 1px solid var(--line); text-align: left; }
.missing-product:last-child { border-bottom: 0; }
.missing-product.is-selected .missing-name { font-weight: 800; }
.missing-product.is-selected .product-photo { box-shadow: inset 0 0 0 2.5px var(--ink); }
.product-photo { width: 56px; height: 56px; display: grid; place-items: center; background: var(--steel-0); border-radius: 12px; overflow: hidden; flex-shrink: 0; }
.product-photo img { width: 100%; height: 100%; object-fit: contain; }
.product-photo > span { font-size: .58rem; font-weight: 600; line-height: 1.15; color: var(--ink-3); text-align: center; padding: .2rem; }
.missing-name { font-size: .92rem; font-weight: 600; line-height: 1.25; min-width: 0; overflow-wrap: anywhere; }
.missing-more { margin-top: .8rem; }
.missing-selected:not(:empty) { margin-top: 1rem; padding: .85rem .95rem .35rem; background: var(--steel-0); border: 1.5px dashed var(--line-2); border-radius: 14px; }
.missing-selection-title { font-weight: 800; font-size: .9rem; color: var(--ink); }
.missing-selection-row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .5rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; font-weight: 600; }
.missing-selection-row:last-child { border-bottom: 0; }
.missing-selection-row > span { min-width: 0; overflow-wrap: anywhere; }
.quantity-controls { display: flex; align-items: center; gap: .25rem; flex-shrink: 0; }
.quantity-controls button { width: 44px; height: 44px; border: 1.5px solid var(--line-2); border-radius: 12px; background: #fff; color: var(--ink); font-size: 1.3rem; font-weight: 700; line-height: 1; }
.quantity-controls button[data-delta="1"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.quantity-controls button:disabled { color: var(--ink-4); background: var(--grey-soft); border-color: var(--grey-soft); }
.quantity-controls .qty-value { min-width: 1.5rem; text-align: center; font-family: var(--mono); font-weight: 700; }
.missing-product:not(.is-selected) [data-delta="-1"], .missing-product:not(.is-selected) .qty-value { visibility: hidden; }
.offer-list { list-style: none; display: grid; gap: .2rem; margin-top: .6rem; }
.offer-row { display: grid; grid-template-columns: 60px minmax(0, 1fr) auto; align-items: center; gap: .8rem; padding: .3rem 0; }
.offer-row .product-photo { width: 60px; height: 60px; }
.offer-name { font-size: 1.08rem; font-weight: 800; line-height: 1.2; min-width: 0; overflow-wrap: anywhere; }
.offer-qty { font-family: var(--mono); font-size: 1.15rem; font-weight: 700; }
.offer-note { margin-top: .6rem; color: var(--ink-2); font-size: .92rem; line-height: 1.4; }
.ticket-page .offer-row { grid-template-columns: 72px minmax(0, 1fr) auto; }
.ticket-page .offer-row .product-photo { width: 72px; height: 72px; }
@media (max-width: 380px) {
    .missing-product { grid-template-columns: 48px minmax(0, 1fr) auto; gap: .45rem; }
    .product-photo { width: 48px; height: 48px; }
    .quantity-controls button { width: 40px; height: 40px; }
}

/* Étapes du formulaire : trois barres */
.form-progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; list-style: none; margin-bottom: 1rem; scroll-margin-top: 90px; }
.form-progress li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-top: .55rem; border-top: 5px solid var(--steel-2); color: var(--ink-3); font-size: .8rem; font-weight: 700; }
.form-progress li[aria-current="step"], .form-progress li.done { border-color: var(--ink); color: var(--ink); }
.form-progress li[aria-current="step"] { font-weight: 900; }
#newForm { scroll-margin-top: 90px; }
#newForm section:focus { outline: none; }
.form-step-actions {
    position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 10;
    display: flex; gap: .6rem; padding: .9rem 0 .7rem;
    background: linear-gradient(180deg, rgba(232, 234, 235, 0), var(--bg) 28%);
}
.form-step-actions #createBtn { flex: 1; min-width: 0; padding-inline: .75rem; }
.optional-note { margin-top: 1rem; }
.optional-note summary, .product-filter summary { cursor: pointer; color: var(--ink); font-size: .9rem; font-weight: 800; padding: .75rem 0; min-height: 44px; text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--line-2); }
.optional-note label { display: block; font-size: .85rem; margin-bottom: .5rem; }
@media (min-width: 900px) { .form-step-actions { bottom: 0; } }
.problem-choice { margin-bottom: 1rem; }
.problem-choice > summary { min-height: 48px; padding: .7rem 0; color: var(--ink); font-size: .95rem; font-weight: 800; cursor: pointer; }
.problem-choice[open] > summary { margin-bottom: .5rem; }

/* Aperçu avant création */
.review-block { padding: .9rem 0; border-bottom: 1.5px dashed var(--line-2); }
.review-block:last-child { border-bottom: 0; padding-bottom: 0; }
.review-block:first-child { padding-top: 0; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.review-edit { background: none; border: 0; min-height: 40px; padding: 0 .2rem; font-weight: 800; font-size: .88rem; color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
.review-main { font-weight: 800; font-size: 1.05rem; }
.review-block .offer-list { margin-top: .3rem; }
@media (max-width: 380px) { .form-progress li { font-size: .72rem; } }

/* N° de commande et date sur une seule ligne */
.order-line { display: flex; gap: .5rem; align-items: stretch; margin: 1.4rem 0 .6rem; }
.order-line .input-lead { flex: 1; min-width: 0; min-height: 58px; font-size: 1.5rem; }
.order-line .input-lead::placeholder { font-family: var(--font); font-size: 1rem; font-weight: 600; letter-spacing: 0; }
.when-chip {
    flex-shrink: 0; display: inline-flex; align-items: center; gap: .4rem; padding: 0 .85rem;
    border-radius: var(--r); border: 1.5px solid var(--line-2); background: var(--card);
    font-family: var(--mono); font-size: .85rem; font-weight: 700; color: var(--ink); white-space: nowrap;
}
.when-chip svg.lucide { width: 17px; height: 17px; color: var(--ink-3); }
.when-chip[aria-expanded="true"] { border-color: var(--ink); }

/* ---------- Niveau client : 1-2 vert, 3-4 orange, 5+ rouge ----------
   Le nombre est toujours écrit à côté : la couleur n'est jamais seule. */
:root { --lvl-1: #1f8a4c; --lvl-2: #d9a300; --lvl-3: #e86a00; --lvl-4: #b3001b; }
.lvl {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 4px;
    font-size: .74rem; font-weight: 800; color: var(--ink); white-space: nowrap;
}
.lvl i, .lvl-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.lvl-1 i, .lvl-dot.lvl-1 { background: var(--lvl-1); }
.lvl-2 i, .lvl-dot.lvl-2 { background: var(--lvl-2); }
.lvl-3 i, .lvl-dot.lvl-3 { background: var(--lvl-3); }
.lvl-4 i, .lvl-dot.lvl-4 { background: var(--lvl-4); box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--lvl-4); }
.lvl-dot { margin-right: 7px; vertical-align: 1px; }
.lvl-n { font-family: var(--mono); font-size: .78rem; font-weight: 700; color: var(--ink-2); }
.lrow > .lvl { justify-self: end; margin-top: 0; }
.client-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 4px; font-size: .82rem; font-weight: 700; color: var(--ink); }
.client-link .lvl { margin-top: 0; }
.client-link span:last-child { text-decoration: underline; text-underline-offset: 3px; }
.known-client {
    display: flex; align-items: flex-start; gap: 10px; margin: -.2rem 0 .9rem; padding: .75rem .9rem;
    border-radius: 12px; background: var(--steel-0); border: 1.5px solid var(--line-2); font-size: .88rem; line-height: 1.35;
}
.known-client .lvl { margin-top: 1px; }

/* ---------- Stats ---------- */
.figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: hidden; }
.fig { padding: 1rem .9rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; }
.fig:nth-child(3n) { border-right: 0; }
.fig:nth-last-child(-n+3) { border-bottom: 0; }
.fig-value { font-size: 2.1rem; line-height: 1; font-weight: 900; font-variation-settings: "wdth" 62; font-variant-numeric: tabular-nums; }
.fig-value small { font-size: 1rem; font-weight: 800; }
.fig-label { font-size: .8rem; font-weight: 700; color: var(--ink-2); margin-top: .3rem; line-height: 1.2; }
.fig-sub { font-size: .72rem; color: var(--ink-3); margin-top: .15rem; }
@media (max-width: 380px) { .fig-value { font-size: 1.7rem; } .fig { padding: .85rem .7rem; } }

.bars { list-style: none; display: grid; gap: .55rem; }
.bars li { display: grid; grid-template-columns: minmax(0, 9.5rem) 1fr 2.4rem; align-items: center; gap: .6rem; font-size: .88rem; }
.bar-label { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 12px; background: var(--grey-soft); border-radius: 2px 4px 4px 2px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--ink); border-radius: 0 4px 4px 0; }
.bar-value { font-family: var(--mono); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.bars li:hover .bar-fill { background: var(--signal); }

.hours { display: grid; grid-template-columns: repeat(17, 1fr); gap: 2px; align-items: end; height: 120px; }
.hour { display: grid; grid-template-rows: 1fr auto; height: 100%; cursor: default; }
.hour-bar { align-self: end; display: block; background: var(--ink); border-radius: 4px 4px 0 0; min-height: 0; }
.hour.peak .hour-bar, .hour:hover .hour-bar { background: var(--signal); }
.hour-label { font-family: var(--mono); font-size: .66rem; color: var(--ink-3); text-align: center; height: 1rem; padding-top: 2px; }

.stat-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.stat-table th { text-align: left; font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: .8rem 1.1rem .5rem; }
.stat-table td { padding: .65rem 1.1rem; border-top: 1px solid var(--line); font-weight: 700; }
.stat-table th:not(:first-child), .stat-table td:not(:first-child) { text-align: right; font-family: var(--mono); }

/* Client rouge : pastille pleine, bandeau sur le bon et la fiche */
.lvl-alert { background: var(--lvl-4); color: #fff; padding: 3px 9px 3px 7px; border-radius: 999px; }
.lvl-alert svg.lucide { width: 14px; height: 14px; stroke-width: 2.6; animation: siren 1.6s ease-in-out infinite; }
@keyframes siren { 50% { transform: rotate(-12deg) scale(1.15); } }
.bon-warn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin: -26px -16px 14px; padding: 22px 10px 8px;
    background: var(--lvl-4); color: #fff; font-size: .72rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase;
}
.bon-warn svg.lucide { width: 15px; height: 15px; }
.red-alert {
    display: flex; gap: 12px; align-items: flex-start; margin: 0 0 6px; padding: 12px 14px;
    background: var(--lvl-4); color: #fff; border-radius: 14px; font-size: .9rem; line-height: 1.35;
}
.red-alert svg.lucide { width: 26px; height: 26px; flex-shrink: 0; animation: siren 1.6s ease-in-out infinite; }
.red-alert > div > strong { display: block; font-weight: 900; }
.red-alert > div > span { opacity: .9; }
.known-client.is-red { background: #fbe9ec; border-color: var(--lvl-4); color: #6b0010; font-weight: 600; }

/* Stats vivantes : photos, icônes, vedettes */
.bars-photo li { grid-template-columns: minmax(0, 11rem) 1fr 2.4rem; }
.bar-label { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.bar-label > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.bar-label .product-photo { width: 36px; height: 36px; border-radius: 9px; }
.bar-label svg.lucide { width: 18px; height: 18px; color: var(--ink-3); }
.stars { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin-top: .9rem; }
.star { position: relative; display: grid; justify-items: center; text-align: center; gap: .15rem; padding: 1rem .7rem .9rem; overflow: hidden; }
.star .star-photo { width: 92px; height: 92px; display: grid; place-items: center; margin-bottom: .3rem; }
.star .star-photo img { width: 100%; height: 100%; object-fit: contain; animation: float 3.2s ease-in-out infinite; }
.star .star-photo svg.lucide { width: 44px; height: 44px; color: var(--ink-3); }
.star:nth-child(2) .star-photo img { animation-delay: -1.6s; }
@keyframes float { 50% { transform: translateY(-5px) rotate(-2deg); } }
.star-name { font-weight: 800; font-size: .98rem; line-height: 1.2; }
.star-n { font-family: var(--mono); font-weight: 700; font-size: 1.3rem; color: var(--signal); }
.bars .bar-fill { transform-origin: left; animation: grow .8s var(--ease) both; }
.bars li:nth-child(2) .bar-fill { animation-delay: .05s; }
.bars li:nth-child(3) .bar-fill { animation-delay: .1s; }
.bars li:nth-child(4) .bar-fill { animation-delay: .15s; }
.bars li:nth-child(n+5) .bar-fill { animation-delay: .2s; }
@keyframes grow { from { transform: scaleX(0); } }
.hour-bar { transform-origin: bottom; animation: rise .7s var(--ease) both; }
@keyframes rise { from { transform: scaleY(0); } }

/* Pourquoi ces plaintes sont liées */
.known-client > div { min-width: 0; }
.known-client > svg.lucide { width: 20px; height: 20px; flex-shrink: 0; margin-top: 1px; }
.link-why { list-style: none; margin: .35rem 0 0; display: grid; gap: .2rem; font-weight: 500; }
.link-why li::before { content: "→ "; color: var(--ink-3); }
.link-why:empty { display: none; }
.link-warn { display: flex; align-items: flex-start; gap: 6px; margin-top: .45rem; font-weight: 800; color: var(--warn); }
.link-warn svg.lucide { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.known-client.is-red .link-warn { color: var(--lvl-4); }
.red-alert .link-why { margin-top: .5rem; }
.red-alert .link-why li::before { color: rgba(255, 255, 255, .7); }
.red-alert .link-warn { color: #fff; }
.link-why mark { background: #fff3c4; color: inherit; padding: 0 3px; border-radius: 3px; font-weight: 800; }
.red-alert .link-why mark { background: rgba(255, 255, 255, .25); color: #fff; }
.link-why li::before { content: none; }

/* Client connu : mise en page empilée, noms en pastilles */
.known-client.kc-stack { display: block; padding: .8rem .9rem .85rem; }
.kc-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; }
.kc-head .lvl { margin-top: 0; }
.kc-last { font-size: .8rem; color: var(--ink-3); font-weight: 600; }
.known-client .link-why { margin-top: .6rem; gap: .55rem; }
.link-why li { display: grid; gap: .3rem; }
.lw-how { font-size: .86rem; }
.lw-names { display: flex; flex-wrap: wrap; gap: .3rem; }
.who { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--card); border: 1px solid var(--line-2); font-size: .82rem; font-weight: 700; white-space: nowrap; }
.who-diff { background: #fff3c4; border-color: #e8cf6a; }
.red-alert .who { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .35); color: #fff; }
.red-alert .who-diff { background: #fff; color: var(--lvl-4); border-color: #fff; }
.known-client .link-warn { margin-top: .65rem; padding-top: .55rem; border-top: 1px dashed currentColor; font-size: .82rem; align-items: center; }
.known-client.is-red .lw-how, .known-client.is-red .kc-last { color: #6b0010; }

/* ---------- Écrans à hauteur exacte ---------- */
:root { --topbar-h: 50px; }
.main.fit {
    display: flex; flex-direction: column; overflow: hidden;
    height: calc(100dvh - var(--topbar-h));
    padding-bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom));
}
.main.fit .scan-box { flex: 1 1 auto; min-height: 160px; max-width: none; aspect-ratio: auto; }
.main.fit #codeForm { flex-shrink: 0; }
.main.fit .scan-or { margin: .9rem 0 .6rem; }
@media (min-width: 900px) { .main.fit { padding-bottom: 24px; } .main.fit .scan-box { max-width: 520px; width: 100%; } }

/* Compte : mot de passe replié */
.pw-fold > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.15rem; font-weight: 800; min-height: 56px; }
.pw-fold > summary::-webkit-details-marker { display: none; }
.pw-fold > summary::after { content: "+"; font-size: 1.4rem; font-weight: 700; color: var(--ink-3); }
.pw-fold[open] > summary::after { content: "−"; }
.pw-fold[open] > summary { border-bottom: 1.5px dashed var(--line-2); }

/* Formulaire plus compact : tient sur un petit écran */
#newForm .field { margin-bottom: .7rem; }
#newForm .input { min-height: 50px; }
#newForm .order-line { margin: .9rem 0 .4rem; }
#newForm .order-line .input-lead { min-height: 54px; }
#newForm .chip-main { min-height: 60px; }
#newForm .chips-rest .chip { min-height: 46px; }
#newForm .card-pad { padding: 1rem; }
.form-progress { margin-bottom: .7rem; }
.field > label .opt { font-weight: 500; color: var(--ink-3); }
.main { padding-bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .main { padding-bottom: 48px; } }
#newForm .field { margin-bottom: .55rem; }
#newForm .field > label { font-size: .82rem; }
#newForm .input { min-height: 48px; padding-block: .6rem; }
#newForm .card-pad { padding: .9rem; }
#newForm + * , #view:has(#newForm) .page-head { margin-bottom: .6rem; }
.form-step-actions { padding: .7rem 0 .4rem; }

/* Brouillon repris */
.draft-note { display: flex; align-items: center; gap: .55rem; margin-bottom: .6rem; padding: .55rem .5rem .55rem .8rem; border-radius: 12px; background: var(--signal-soft); color: var(--signal-press); font-size: .85rem; font-weight: 700; }
.draft-note svg.lucide { width: 18px; height: 18px; flex-shrink: 0; }
.draft-note span { flex: 1; }
.draft-note button { background: none; border: 0; min-height: 36px; padding: 0 .5rem; font-weight: 800; color: var(--danger); text-decoration: underline; text-underline-offset: 3px; }

/* Plainte déjà créée ? */
.dup-warn { display: flex; gap: .65rem; align-items: flex-start; margin-bottom: .7rem; padding: .75rem .85rem; border-radius: 14px; background: var(--warn-soft); border: 1.5px solid #e2c27a; color: var(--warn); font-size: .86rem; line-height: 1.35; }
.dup-warn svg.lucide { width: 22px; height: 22px; flex-shrink: 0; }
.dup-warn strong { display: block; font-weight: 900; margin-bottom: .25rem; }
.dup-item { display: block; padding: .45rem .6rem; margin: .3rem 0; border-radius: 10px; background: var(--card); color: var(--ink); font-weight: 700; text-decoration: none; }
.dup-hint { display: block; font-weight: 700; margin-top: .2rem; }

/* Doublon : produits de la plainte existante */
.dup-item { padding: .55rem .65rem; }
.dup-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.dup-same { font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: #fff; background: var(--warn); padding: 2px 7px; border-radius: 999px; }
.dup-when { display: block; font-weight: 500; color: var(--ink-3); font-size: .8rem; }
.dup-prods { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; }
.dup-prod { display: inline-flex; align-items: center; gap: .35rem; padding: 2px 8px 2px 2px; border-radius: 999px; background: var(--steel-0); border: 1px solid var(--line-2); font-size: .8rem; font-weight: 700; }
.dup-prod .product-photo { width: 24px; height: 24px; border-radius: 50%; }
.dup-prod.is-same { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.dup-open { display: inline-flex; align-items: center; gap: 4px; margin-top: .45rem; min-height: 32px; font-size: .82rem; font-weight: 800; color: var(--signal); text-decoration: underline; text-underline-offset: 3px; }
.dup-open svg.lucide { width: 15px; height: 15px; }

/* ---------- Lignes de la liste ---------- */
.lrow2 { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); text-decoration: none; }
.lrow2:last-child { border-bottom: 0; }
.lrow2:hover { background: var(--steel-0); }
.lrow2-pic { width: 44px; height: 44px; border-radius: 12px; background: var(--steel-0); display: grid; place-items: center; overflow: hidden; }
.lrow2-pic img { width: 40px; height: 40px; object-fit: contain; }
.lrow2-pic svg.lucide { width: 20px; height: 20px; color: var(--ink-3); }
.lrow2-main { display: grid; gap: 2px; min-width: 0; }
.lrow2-name { display: flex; align-items: center; gap: 7px; font-weight: 800; white-space: nowrap; overflow: hidden; }
.lrow2-sub { font-size: .82rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow2-side { display: grid; justify-items: end; gap: 3px; }
.lrow2-code { font-family: var(--mono); font-weight: 700; font-size: .8rem; letter-spacing: .04em; padding: 2px 6px; border-radius: 6px; background: var(--steel-0); }
.lrow2-when { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: .72rem; color: var(--ink-3); }
.cpill { flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center; font-family: var(--mono); font-size: .72rem; font-weight: 700; color: #fff; }
.cpill.lvl-1 { background: var(--lvl-1); }
.cpill.lvl-3 { background: var(--lvl-3); }
.cpill.lvl-4 { background: var(--lvl-4); }

/* ---------- Aperçu d'une plainte ---------- */
.peek { display: grid; gap: .2rem; }
.peek-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.peek-head h2 { margin: 0; }
.peek-head .icon-btn { margin: -6px -8px 0 0; }
.peek-status { display: flex; align-items: center; gap: 8px; margin: .7rem 0 .2rem; }
.peek-status .mono { font-weight: 700; font-size: .85rem; }
.peek-block { padding: .75rem 0; border-top: 1.5px dashed var(--line-2); }
.peek-block .label { margin-bottom: .2rem; }
.peek-block .offer-list { margin-top: .2rem; }
.peek .modal-actions { margin-top: .6rem; }
.modal-actions a.btn { text-decoration: none; }
.dup-open { background: none; border: 0; padding: 0; cursor: pointer; }

/* ---------- Glisser pour remettre : version fluide ---------- */
.slide { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06); }
.slide-fill { width: 100%; transform: scaleX(0); transform-origin: left center; will-change: transform; border-radius: inherit; transition: background .25s; }
.slide-knob { will-change: transform; transition: box-shadow .2s, background .2s, color .2s; }
.slide.animating .slide-knob, .slide.animating .slide-fill { transition: transform .5s cubic-bezier(.22, 1.3, .36, 1), background .25s; }
.slide.animating .slide-label { transition: opacity .3s; }
.slide.dragging .slide-knob { box-shadow: 0 6px 16px rgba(0, 0, 0, .35); cursor: grabbing; }
.slide.ready .slide-fill { background: var(--done); }
.slide.ready .slide-knob { color: var(--done); }
/* Reflet qui invite à glisser */
.slide-label {
    background: linear-gradient(100deg, rgba(255,255,255,.55) 30%, #fff 50%, rgba(255,255,255,.55) 70%) 0 0 / 220% 100%;
    -webkit-background-clip: text; background-clip: text; color: transparent;
    animation: shimmer 2.4s linear infinite;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -100% 0; } }
.slide.busy .slide-label, .slide.done .slide-label { animation: none; background: none; color: #fff; }
.slide.nudge .slide-knob { animation: nudge .5s cubic-bezier(.36, .07, .19, .97); }
@keyframes nudge { 20% { transform: translate3d(14px,0,0); } 45% { transform: translate3d(0,0,0); } 65% { transform: translate3d(7px,0,0); } 100% { transform: translate3d(0,0,0); } }
.slide.busy .slide-knob svg.lucide { animation: spin .9s linear infinite; }
.slide.done .slide-knob { color: var(--done); animation: pop .45s var(--ease); }
.slide.done .slide-label { padding-left: 14px; padding-right: 64px; font-size: 1.05rem; }

/* ---------- Écran de scan : bandeau d'état et transitions ---------- */
.scan-banner { display: flex; gap: .8rem; align-items: flex-start; padding: .95rem 1rem; margin-bottom: .2rem; border-radius: 16px; color: #fff; font-size: .9rem; line-height: 1.35; }
.scan-banner svg.lucide { width: 28px; height: 28px; flex-shrink: 0; }
.scan-banner strong { display: block; font-size: 1.05rem; font-weight: 900; margin-bottom: .15rem; }
.scan-banner span { display: block; opacity: .95; }
.scan-banner b { font-weight: 800; }
.scan-banner .scan-quote { margin-top: .35rem; font-style: italic; opacity: .9; }
.scan-banner.is-done { background: var(--done); }
.scan-banner.is-void { background: var(--danger); }
.scan-banner.is-warn { background: var(--warn); }
.scan-banner.is-new { animation: drop .55s var(--ease) both; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px) scale(.98); } }
.swap-in { animation: swapin .45s var(--ease) both; }
@keyframes swapin { from { opacity: 0; transform: translateY(6px); } }
#vForm { overflow: hidden; transition: height .45s var(--ease), opacity .3s, padding .45s var(--ease); }
#vForm.collapse { height: 0 !important; opacity: 0; padding-top: 0; padding-bottom: 0; }
.scan-actions { display: grid; gap: .6rem; margin-top: 1rem; }
.scan-actions[hidden] { display: none; }
.scan-actions .btn { text-decoration: none; }
@media (prefers-reduced-motion: reduce) { .slide-label { animation: none; background: none; color: #fff; } }

/* Installer GPM */
.install-card { display: flex; align-items: center; gap: .8rem; padding: .8rem .9rem; margin: 0 0 .9rem; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.install-card img { border-radius: 11px; flex-shrink: 0; }
.install-text { flex: 1; min-width: 0; display: grid; gap: 2px; font-size: .84rem; color: var(--ink-3); line-height: 1.3; }
.install-text strong { color: var(--ink); font-size: .95rem; }
.install-ios { color: var(--ink-2); margin-top: 2px; }
.install-ios svg.lucide { width: 15px; height: 15px; vertical-align: -2px; color: var(--signal); }
.install-later { width: 36px; height: 36px; margin-right: -6px; }
/* Lancée depuis l'écran d'accueil : on respecte l'encoche */
@media (display-mode: standalone) { .topbar { padding-top: calc(.6rem + env(safe-area-inset-top)); } }

/* La pastille de marque affiche l'icône de l'app */
.brand-mark:has(img) { background: none; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; display: block; }
