/* =====================================================================
   Cookie Rush — feuille de style unique
   Pensée pour l'iPad en priorité, entièrement responsive (téléphone → écran)
   ===================================================================== */

:root {
    --bg: #fdf3e7;
    --bg-2: #f7e6d2;
    --surface: #ffffff;
    --surface-2: #fffaf4;
    --line: #ecd9c4;
    --line-strong: #ddc0a2;
    --ink: #35211a;
    --ink-soft: #6d5347;
    --muted: #93796a;
    --brand: #b35f22;
    --brand-strong: #8a4a22;
    --brand-soft: #fbe6d2;
    --accent: #c98a2e;
    --ok: #2f8f5b;
    --ok-soft: #e2f4e9;
    --danger: #c33c25;
    --danger-soft: #fbe4df;
    --shadow-sm: 0 1px 2px rgba(83, 47, 22, .08), 0 2px 8px rgba(83, 47, 22, .06);
    --shadow-md: 0 6px 24px rgba(83, 47, 22, .12);
    --shadow-lg: 0 24px 60px rgba(50, 26, 10, .28);
    --radius: 18px;
    --radius-sm: 12px;
    --tap: 56px;
    --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #1b1310;
        --bg-2: #241a15;
        --surface: #2a1e19;
        --surface-2: #32241d;
        --line: #43312a;
        --line-strong: #58423a;
        --ink: #f6e9dd;
        --ink-soft: #d6bfae;
        --muted: #ac9182;
        --brand: #e08a45;
        --brand-strong: #f0a464;
        --brand-soft: #43291a;
        --accent: #e5b45f;
        --ok: #52c489;
        --ok-soft: #1e3a2b;
        --danger: #f0705a;
        --danger-soft: #43211c;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
        --shadow-md: 0 6px 24px rgba(0, 0, 0, .45);
        --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
    }
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
a { color: var(--brand); }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 100;
    background: var(--surface); padding: .8rem 1rem; border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* ------------------------------------------------------------------ */
/* Barre supérieure                                                    */
/* ------------------------------------------------------------------ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem max(.75rem, env(safe-area-inset-left)) .55rem max(.75rem, env(safe-area-inset-right));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    color: var(--ink);
    font-weight: 800;
    font-size: 1.05rem;
    flex: 0 0 auto;
}
.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: block;
    flex: 0 0 auto;
    box-shadow: 0 1px 3px rgba(83, 47, 22, .25);
}
.brand-text { white-space: nowrap; }

.mainnav {
    display: flex;
    gap: .25rem;
    flex: 1 1 auto;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px;
}
.mainnav::-webkit-scrollbar { display: none; }

.navlink {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem .85rem;
    border-radius: 999px;
    text-decoration: none;
    color: var(--ink-soft);
    font-weight: 600;
    font-size: .95rem;
    white-space: nowrap;
    min-height: 44px;
    transition: background .15s ease, color .15s ease;
}
.navlink:hover { background: var(--bg-2); }
.navlink.is-active { background: var(--brand); color: #fff; }
.navlink-icon { font-size: 1.05rem; }
.navlink-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 .3rem;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: .72rem;
    font-weight: 800;
    display: inline-grid;
    place-items: center;
}
.navlink.is-active .navlink-badge { background: #fff; color: var(--brand); }

/* Place limitée : seul l'onglet actif garde son libellé. */
@media (max-width: 1200px) {
    .navlink-label { display: none; }
    .navlink.is-active .navlink-label { display: inline; }
    .navlink-icon { font-size: 1.25rem; }
    .navlink { padding: .5rem .7rem; }
}

.usermenu { display: flex; align-items: center; gap: .4rem; flex: 0 0 auto; }
.usermenu-btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .3rem .6rem .3rem .3rem;
    border-radius: 999px; text-decoration: none; color: var(--ink);
    font-weight: 600; font-size: .9rem;
}
.usermenu-btn:hover { background: var(--bg-2); }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--brand); color: #fff;
    display: grid; place-items: center; font-weight: 800; font-size: .95rem;
}

@media (max-width: 860px) {
    .brand-text, .usermenu-name, .navlink-label,
    .navlink.is-active .navlink-label { display: none; }
    .navlink { padding: .55rem .7rem; }
    .navlink-icon { font-size: 1.3rem; }
    .topbar { gap: .4rem; }
}

/* Sur téléphone, « Quitter » devient une icône pour laisser la place à la navigation. */
.only-small { display: none; }
@media (max-width: 620px) {
    .hide-small { display: none; }
    .only-small { display: inline; font-size: 1.15rem; }
    .usermenu-btn { padding: .3rem; }
    .topbar { padding-left: .4rem; padding-right: .4rem; }
}

/* ------------------------------------------------------------------ */
/* Structure de page                                                   */
/* ------------------------------------------------------------------ */

.page {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 1rem max(1rem, env(safe-area-inset-left)) 3rem max(1rem, env(safe-area-inset-right));
}
.page-caisse { width: 100%; max-width: 1500px; padding-bottom: 0; }

.pagefoot {
    padding: 1.5rem 1rem calc(1.5rem + var(--safe-b));
    text-align: center;
    color: var(--muted);
    font-size: .8rem;
}
.page-caisse ~ .pagefoot { display: none; }

.pagehead {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1rem;
}
.pagehead h1 { margin: 0; }
.pagehead .sub { color: var(--muted); font-size: .95rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.1rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

/* Sous-onglets de la section Réglages */
.subnav {
    display: flex;
    gap: .35rem;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: .2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}
.subnav::-webkit-scrollbar { display: none; }
.subnav-link {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .6rem .9rem;
    min-height: 48px;
    border-radius: 12px 12px 0 0;
    text-decoration: none;
    color: var(--ink-soft);
    font-weight: 700;
    font-size: .95rem;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
}
.subnav-link:hover { background: var(--bg-2); }
.subnav-link.is-active { color: var(--brand); border-bottom-color: var(--brand); background: var(--bg-2); }

/* Zone dangereuse : réinitialisation */
.danger-zone { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.danger-zone .card-head h2 { color: var(--danger); }
.danger-zone .checkline:has(input:checked) { border-color: var(--danger); background: var(--danger-soft); }

/* Saisie des heures */
.time-fields { display: flex; align-items: center; gap: .3rem; flex: 0 0 auto; }
.time-fields input[type="number"] { width: 68px; text-align: center; font-weight: 800; }
.time-fields select { width: 78px; padding-right: 1.8rem; font-weight: 700; }
.time-fields .unit { font-weight: 800; color: var(--muted); }
.card-centered { max-width: 460px; margin: 3rem auto; text-align: center; }
.card h2 { margin-top: 0; }
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; flex-wrap: wrap; margin-bottom: .8rem;
}
.card-head h2 { margin: 0; }

.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }

/* ------------------------------------------------------------------ */
/* Boutons et formulaires                                              */
/* ------------------------------------------------------------------ */

.btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: var(--tap);
    padding: .7rem 1.2rem;
    border-radius: 14px;
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform .08s ease, filter .15s ease, background .15s ease;
    user-select: none;
    touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-soft { background: var(--bg-2); color: var(--ink); border-color: var(--line); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-soft); }
.btn-small { min-height: 40px; padding: .35rem .75rem; font-size: .88rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-xl { min-height: 68px; font-size: 1.15rem; border-radius: 18px; }

.field { margin-bottom: .9rem; }
.field label, .field > .label {
    display: block; font-weight: 700; font-size: .9rem; margin-bottom: .35rem; color: var(--ink-soft);
}
.field .hint { font-size: .82rem; color: var(--muted); margin-top: .3rem; }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="search"], select, textarea {
    width: 100%;
    min-height: var(--tap);
    padding: .7rem .85rem;
    font: inherit;
    color: var(--ink);
    background: var(--surface-2);
    border: 1.5px solid var(--line-strong);
    border-radius: 14px;
    -webkit-appearance: none;
    appearance: none;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select, textarea:focus { outline: none; }
input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}
select {
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 20px) calc(50% + 2px), calc(100% - 14px) calc(50% + 2px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 2.5rem;
}

.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; }
.inline-form .grow { flex: 1 1 180px; }

.checkline {
    display: flex; align-items: flex-start; gap: .7rem;
    padding: .7rem .8rem; border: 1.5px solid var(--line); border-radius: 14px;
    background: var(--surface-2); margin-bottom: .5rem; cursor: pointer;
}
.checkline:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.checkline input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--brand); flex: 0 0 auto; }
.checkline > span { display: block; }
.checkline .t { display: block; font-weight: 700; }
.checkline .d { display: block; font-size: .82rem; color: var(--muted); }

.flash {
    padding: .85rem 1rem;
    border-radius: 14px;
    margin-bottom: 1rem;
    font-weight: 600;
    border: 1px solid transparent;
}
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.flash-info { background: var(--brand-soft); color: var(--brand-strong); border-color: color-mix(in srgb, var(--brand) 30%, transparent); }

.pill {
    display: inline-block; padding: .2rem .6rem; border-radius: 999px;
    font-size: .75rem; font-weight: 800; letter-spacing: .02em;
    background: var(--bg-2); color: var(--ink-soft);
}
.pill-admin { background: var(--brand); color: #fff; }
.pill-off { background: var(--danger-soft); color: var(--danger); }
.pill-ok { background: var(--ok-soft); color: var(--ok); }

/* ------------------------------------------------------------------ */
/* Connexion                                                           */
/* ------------------------------------------------------------------ */

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem calc(2rem + var(--safe-b));
    background:
        radial-gradient(1200px 500px at 50% -10%, var(--brand-soft), transparent 70%),
        var(--bg);
}
.login-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 1.8rem 1.5rem;
    box-shadow: var(--shadow-md);
}
.login-logo { text-align: center; margin-bottom: .4rem; }
.login-logo img {
    display: block;
    width: min(270px, 84%);
    height: auto;
    margin: 0 auto;
}
/* En mode sombre, le logo est posé sur une pastille claire pour rester lisible. */
@media (prefers-color-scheme: dark) {
    .login-logo {
        background: #fcf1e2;
        border-radius: 20px;
        padding: .5rem 0;
    }
}
.login-card h1 { text-align: center; font-size: 1.5rem; margin: .4rem 0 .2rem; }
.login-card .tagline { text-align: center; color: var(--muted); margin-bottom: 1.4rem; }

/* ------------------------------------------------------------------ */
/* Caisse                                                              */
/* ------------------------------------------------------------------ */

.register {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    align-items: start;
}

@media (min-width: 900px) {
    .register { grid-template-columns: minmax(0, 1fr) 370px; }
}
@media (min-width: 1300px) {
    .register { grid-template-columns: minmax(0, 1fr) 420px; }
}

.products-panel { min-width: 0; }

.panel-title {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: .5rem; margin: .2rem .2rem .7rem;
}
.panel-title h1 { font-size: 1.25rem; margin: 0; }
.panel-title .sub { color: var(--muted); font-size: .9rem; }

@media (max-width: 620px) {
    .panel-title { display: block; }
    .panel-title .nowrap { display: block; margin-top: .3rem; }
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .7rem;
    padding-bottom: 1rem;
}
@media (min-width: 700px) { .product-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .85rem; } }

.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    min-height: 132px;
    padding: .9rem .6rem;
    background: var(--surface);
    border: 1.5px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    text-align: center;
    font: inherit;
    color: var(--ink);
    transition: transform .08s ease, border-color .15s ease, background .15s ease;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}
.tile:active { transform: scale(.96); }
.tile.is-picked { border-color: var(--brand); background: var(--brand-soft); }
.tile-face { display: grid; place-items: center; }
.tile-emoji { font-size: 2.4rem; line-height: 1; }
.tile-face img {
    width: 76px;
    height: 76px;
    border-radius: 16px;
    object-fit: cover;
    display: block;
    box-shadow: var(--shadow-sm);
}
.tile-name { font-weight: 700; font-size: .98rem; }

.tile-stock {
    font-size: .78rem;
    font-weight: 700;
    color: var(--muted);
    background: var(--bg-2);
    padding: .1rem .5rem;
    border-radius: 999px;
}
.tile.is-out { opacity: .55; }
.tile.is-out .tile-stock { background: var(--danger-soft); color: var(--danger); }

/* Bandeau d'une commande en cours de remise */
.order-banner {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .9rem;
    margin-bottom: .8rem;
    border-radius: 14px;
    background: var(--brand-soft);
    border: 1.5px solid var(--brand);
    color: var(--brand-strong);
}
.order-banner-icon { font-size: 1.4rem; }
.order-banner .grow { flex: 1 1 auto; }

/* Rattrapage rapide après une vente */
.undo-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .8rem;
    margin-bottom: .8rem;
    border-radius: 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-size: .9rem;
    color: var(--ink-soft);
}
.undo-bar .grow { flex: 1 1 auto; }

.tile-qty {
    position: absolute;
    top: 8px;
    right: 8px;
    min-width: 34px;
    height: 34px;
    padding: 0 .4rem;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-weight: 800;
    display: none;
    place-items: center;
    box-shadow: var(--shadow-sm);
    animation: pop .18s ease;
}
.tile.is-picked .tile-qty { display: grid; }

.tile-minus {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1.5px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1;
    display: none;
    place-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}
.tile.is-picked .tile-minus { display: grid; }

@keyframes pop {
    from { transform: scale(.5); }
    60%  { transform: scale(1.15); }
    to   { transform: scale(1); }
}

/* Panneau ticket (colonne de droite sur grand écran) */
.ticket {
    position: sticky;
    top: 74px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 92px);
    overflow: hidden;
}
.ticket-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .9rem 1rem; border-bottom: 1px solid var(--line);
}
.ticket-head h2 { margin: 0; font-size: 1.05rem; }
.ticket-list { list-style: none; margin: 0; padding: .4rem .5rem; overflow-y: auto; flex: 1 1 auto; -webkit-overflow-scrolling: touch; }
.ticket-empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.ticket-empty .empty-icon { font-size: 2.4rem; }

.ticket-row {
    display: grid;
    grid-template-columns: 2rem 1fr auto;
    align-items: center;
    gap: .6rem;
    padding: .45rem .5rem;
    border-radius: 12px;
}
.ticket-row + .ticket-row { border-top: 1px solid var(--line); }
.ticket-row .em { font-size: 1.4rem; text-align: center; }
.ticket-row .nm { font-weight: 600; }
.stepper { display: flex; align-items: center; gap: .15rem; }
.stepper button {
    width: 40px; height: 40px; border-radius: 12px;
    border: 1.5px solid var(--line-strong); background: var(--surface-2);
    color: var(--ink); font-size: 1.2rem; font-weight: 800; line-height: 1;
    cursor: pointer; touch-action: manipulation;
}
.stepper button:active { transform: scale(.94); }
.stepper .n { min-width: 2.1rem; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }

.ticket-foot { padding: .8rem 1rem calc(.8rem + var(--safe-b)); border-top: 1px solid var(--line); background: var(--surface-2); }
.ticket-total { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: .7rem; }
.ticket-total .lbl { color: var(--muted); font-weight: 600; }
.ticket-total .val { font-size: 1.5rem; font-weight: 800; }
.ticket-actions { display: grid; gap: .5rem; }

/* Barre d'encaissement fixe (téléphone / iPad portrait) */
.cashbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: none;
    gap: .6rem;
    align-items: center;
    padding: .6rem max(.8rem, env(safe-area-inset-left)) calc(.6rem + var(--safe-b)) max(.8rem, env(safe-area-inset-right));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 24px rgba(83, 47, 22, .1);
}
.cashbar .count {
    display: flex; flex-direction: column; line-height: 1.15; flex: 0 0 auto;
    padding-left: .3rem;
}
.cashbar .count b { font-size: 1.2rem; }
.cashbar .count span { font-size: .78rem; color: var(--muted); }
.cashbar .btn { flex: 1 1 auto; }

@media (max-width: 899px) {
    .ticket { display: none; }
    .ticket.is-open {
        display: flex;
        position: fixed;
        inset: auto 0 0 0;
        z-index: 60;
        max-height: 82vh;
        border-radius: 24px 24px 0 0;
        border-bottom: none;
        box-shadow: var(--shadow-lg);
        animation: slideup .22s ease;
    }
    .cashbar { display: flex; }
    .products-panel { padding-bottom: 100px; }
}

@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ------------------------------------------------------------------ */
/* Fenêtre d'encaissement                                              */
/* ------------------------------------------------------------------ */

.backdrop {
    position: fixed; inset: 0; z-index: 55;
    background: rgba(40, 20, 8, .5);
    backdrop-filter: blur(2px);
    animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
[hidden] { display: none !important; }

.modal {
    position: fixed;
    z-index: 60;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: slideup .22s ease;
    inset: auto 0 0 0;
    max-height: 94vh;
    border-radius: 26px 26px 0 0;
}
@media (min-width: 700px) {
    .modal {
        inset: 50% auto auto 50%;
        transform: translate(-50%, -50%);
        width: min(480px, 92vw);
        border-radius: 26px;
        animation: pop-in .2s ease;
    }
    @keyframes pop-in {
        from { opacity: 0; transform: translate(-50%, -46%) scale(.97); }
        to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    }
}

.modal-head {
    display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: 1rem 1rem .6rem;
}
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal-body { padding: 0 1rem; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { padding: .8rem 1rem calc(1rem + var(--safe-b)); display: grid; gap: .5rem; }
.icon-btn {
    width: 44px; height: 44px; border-radius: 12px; border: none;
    background: var(--bg-2); color: var(--ink-soft); font-size: 1.2rem; cursor: pointer;
}

.recap {
    display: flex; flex-wrap: wrap; gap: .35rem;
    padding: .1rem 0 .8rem;
}
.recap .chip {
    background: var(--bg-2); border-radius: 999px; padding: .3rem .7rem;
    font-size: .85rem; font-weight: 600;
}

.amount-display {
    text-align: center;
    padding: .6rem 0 .9rem;
}
.amount-display .lbl { color: var(--muted); font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.amount-display .val {
    font-size: clamp(2.6rem, 11vw, 3.4rem);
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.02em;
    line-height: 1.1;
}
.amount-display .val.is-zero { color: var(--muted); }

.quick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; margin-bottom: .7rem; }
.quick-row .btn { min-height: 48px; font-size: 1rem; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.keypad button {
    min-height: 60px;
    border-radius: 16px;
    border: 1.5px solid var(--line);
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
}
.keypad button:active { transform: scale(.96); background: var(--brand-soft); }
.keypad .k-wide { grid-column: span 1; }

.seg { display: grid; grid-auto-flow: column; gap: .35rem; margin: .8rem 0 .2rem; }
.seg button {
    min-height: 46px; border-radius: 12px; border: 1.5px solid var(--line);
    background: var(--surface-2); color: var(--ink-soft); font: inherit; font-weight: 700;
    font-size: .9rem; cursor: pointer;
}
.seg button.is-on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* Confirmation après vente */
.done-card { text-align: center; padding: 2rem 1.2rem 1.2rem; }
.done-card .big { font-size: 3.2rem; line-height: 1; }
.done-card .amt { font-size: 2.2rem; font-weight: 800; margin: .4rem 0 .1rem; }

/* Bandeau hors-ligne */
.offline-note {
    margin: 0 0 .8rem;
    padding: .6rem .9rem;
    border-radius: 12px;
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 700;
    font-size: .9rem;
}

/* Toast */
.toast-zone {
    position: fixed;
    left: 50%;
    bottom: calc(1rem + var(--safe-b));
    transform: translateX(-50%);
    z-index: 80;
    display: grid;
    gap: .4rem;
    width: min(420px, calc(100% - 2rem));
    pointer-events: none;
}
.toast {
    background: var(--ink);
    color: var(--bg);
    padding: .8rem 1rem;
    border-radius: 14px;
    font-weight: 700;
    box-shadow: var(--shadow-md);
    animation: fade .15s ease;
    text-align: center;
}
.toast-ok { background: var(--ok); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------------ */
/* Listes (ventes, produits, comptes)                                  */
/* ------------------------------------------------------------------ */

.list { list-style: none; margin: 0; padding: 0; }
.list > li {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .75rem .25rem;
    border-bottom: 1px solid var(--line);
}
.list > li:last-child { border-bottom: none; }
.list .grow { flex: 1 1 auto; min-width: 0; }
.list .title { font-weight: 700; }
.list .sub { color: var(--muted); font-size: .85rem; }
.list .actions { display: flex; gap: .35rem; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; }

.daygroup { margin-bottom: 1.2rem; }
.dayhead {
    display: flex; align-items: baseline; justify-content: space-between; gap: .5rem;
    padding: .5rem .2rem; margin-bottom: .2rem;
    border-bottom: 2px solid var(--line-strong);
}
.dayhead .d { font-weight: 800; }
.dayhead .t { font-weight: 800; color: var(--brand); }

.sale-row { display: flex; align-items: center; gap: .8rem; padding: .7rem .3rem; border-bottom: 1px solid var(--line); }
.sale-row:last-child { border-bottom: none; }
.sale-row .grow { flex: 1 1 auto; min-width: 0; }
.sale-row form { flex: 0 0 auto; }
.sale-amount { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 5.2rem; }
.sale-items { color: var(--ink-soft); font-size: .92rem; }
.sale-meta { color: var(--muted); font-size: .8rem; }
.sale-row.is-void { opacity: .55; }
.sale-row.is-void .sale-amount { text-decoration: line-through; }

/* Sur téléphone : montant + bouton sur une ligne, détail en dessous. */
@media (max-width: 620px) {
    .sale-row { flex-wrap: wrap; gap: .3rem .6rem; }
    .sale-amount { min-width: 0; }
    .sale-row .grow { flex: 1 1 100%; order: 3; }
    .sale-row form { order: 2; margin-left: auto; }
    .dayhead { flex-wrap: wrap; }
}

.emoji-drag { cursor: grab; font-size: 1.6rem; }

/* ------------------------------------------------------------------ */
/* Stock : fournées et pastilles                                       */
/* ------------------------------------------------------------------ */

.batch-grid {
    display: grid;
    gap: .5rem;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.batch-row {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .5rem .6rem;
    border: 1.5px solid var(--line);
    border-radius: 14px;
    background: var(--surface-2);
}
.batch-face {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--bg-2);
    overflow: hidden;
}
.batch-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.batch-emoji { font-size: 1.6rem; line-height: 1; }
.batch-name { flex: 1 1 auto; font-weight: 700; min-width: 0; }
.batch-stock { display: block; font-weight: 500; font-size: .8rem; color: var(--muted); }
.batch-stock.is-empty { color: var(--danger); }
.batch-row input[type="number"] { width: 84px; flex: 0 0 auto; text-align: center; font-weight: 800; }

.stock-pill {
    flex: 0 0 auto;
    padding: .25rem .7rem;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 800;
    background: var(--ok-soft);
    color: var(--ok);
    white-space: nowrap;
}
.stock-pill.is-low { background: #fdf0dd; color: #a86a12; }
.stock-pill.is-empty { background: var(--danger-soft); color: var(--danger); }

@media (prefers-color-scheme: dark) {
    .stock-pill.is-low { background: #46320f; color: var(--accent); }
}

/* ------------------------------------------------------------------ */
/* Commandes                                                           */
/* ------------------------------------------------------------------ */

.order {
    border: 1.5px solid var(--line);
    border-left: 5px solid var(--brand);
    border-radius: 14px;
    padding: .8rem .9rem;
    margin-bottom: .7rem;
    background: var(--surface-2);
}
.order.is-ready { border-left-color: var(--ok); }
.order.is-late { border-left-color: var(--danger); }
.order-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .6rem;
    margin-bottom: .4rem;
}
.order-who { font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.order-when { color: var(--muted); font-size: .85rem; font-weight: 600; }
.order-count {
    flex: 0 0 auto;
    background: var(--bg-2);
    border-radius: 999px;
    padding: .2rem .6rem;
    font-weight: 800;
    font-size: .82rem;
    color: var(--ink-soft);
}
.order-items { font-size: .95rem; color: var(--ink-soft); }
.order-note { font-size: .88rem; color: var(--muted); margin-top: .2rem; }
.order-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .7rem; }
.order-actions .btn { min-height: 46px; }

input[type="file"] {
    width: 100%;
    padding: .6rem .7rem;
    font: inherit;
    font-size: .9rem;
    background: var(--surface-2);
    border: 1.5px dashed var(--line-strong);
    border-radius: 14px;
    color: var(--ink-soft);
}
input[type="file"]::file-selector-button {
    font: inherit;
    font-weight: 700;
    margin-right: .6rem;
    padding: .4rem .8rem;
    border: none;
    border-radius: 10px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
}

.empty {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--muted);
}
.empty-icon { font-size: 2.8rem; line-height: 1; margin-bottom: .4rem; }

/* ------------------------------------------------------------------ */
/* Statistiques                                                        */
/* ------------------------------------------------------------------ */

.stat-grid {
    display: grid;
    gap: .8rem;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    margin-bottom: 1rem;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}
.stat .k { color: var(--muted); font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: .82rem; }
.stat-hero { background: linear-gradient(140deg, var(--brand), var(--brand-strong)); border-color: transparent; color: #fff; }
.stat-hero .k, .stat-hero .s { color: rgba(255, 255, 255, .82); }
.stat-profit { background: linear-gradient(140deg, var(--ok), #1f6f45); border-color: transparent; color: #fff; }
.stat-profit .k, .stat-profit .s { color: rgba(255, 255, 255, .85); }
.stat-loss { background: linear-gradient(140deg, var(--danger), #8f2a19); border-color: transparent; color: #fff; }
.stat-loss .k, .stat-loss .s { color: rgba(255, 255, 255, .85); }

.bars { display: grid; gap: .5rem; }
.bar-row { display: grid; grid-template-columns: 9.5rem 1fr 5rem; align-items: center; gap: .6rem; }
.bar-row .lbl { font-size: .88rem; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { display: block; background: var(--bg-2); border-radius: 999px; height: 20px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--brand)); min-width: 3px; }
.bar-row .val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: .9rem; }

@media (max-width: 520px) {
    .bar-row { grid-template-columns: 5.5rem 1fr 4.2rem; gap: .4rem; }
}

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.data th, table.data td { padding: .6rem .5rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ */
/* Installation                                                        */
/* ------------------------------------------------------------------ */

.install-wrap {
    width: min(640px, 100%);
    margin: 0 auto;
    padding: 2rem 1rem calc(3rem + var(--safe-b));
}
.steps { display: flex; gap: .4rem; margin-bottom: 1.2rem; }
.steps .step {
    flex: 1 1 0; text-align: center; font-size: .8rem; font-weight: 700; color: var(--muted);
    padding: .45rem .2rem; border-radius: 999px; background: var(--bg-2);
}
.steps .step.is-on { background: var(--brand); color: #fff; }
.steps .step.is-done { background: var(--ok-soft); color: var(--ok); }
pre.code {
    background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
    padding: .9rem; overflow-x: auto; font-size: .82rem; line-height: 1.5;
}

@media print {
    .topbar, .cashbar, .ticket-actions, .pagefoot { display: none !important; }
}
