/* ============================================================
   Caisse — feuille de style principale
   Design tactile, responsive et sans dépendance externe.
   ============================================================ */

:root {
    --bg: #f4f5fb;
    --surface: #ffffff;
    --surface-2: #f8f9fd;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-soft: #eef2ff;
    --success: #059669;
    --success-soft: #ecfdf5;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 14px -8px rgba(15, 23, 42, .12);
    --shadow-md: 0 18px 40px -22px rgba(15, 23, 42, .35);
    --nav-height: 64px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", system-ui, -apple-system, "Inter", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(900px 480px at 12% -8%, rgba(99, 102, 241, .10), transparent 62%),
        radial-gradient(760px 420px at 100% 0%, rgba(16, 185, 129, .07), transparent 58%);
}

h1, h2, h3, h4, p {
    margin: 0;
}

h1 {
    font-size: clamp(1.7rem, 3vw, 2.2rem);
    line-height: 1.1;
    letter-spacing: -.03em;
}

h2 {
    font-size: 1.15rem;
    letter-spacing: -.02em;
}

a {
    color: var(--primary);
}

svg {
    display: block;
}

::selection {
    background: rgba(79, 70, 229, .18);
}

/* ------------------------------------------------------------
   Barre de navigation
   ------------------------------------------------------------ */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .84);
    border-bottom: 1px solid var(--border);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-decoration: none;
    flex: none;
}

.brand-logo {
    display: block;
    flex: none;
    width: auto;
    height: 40px;
    object-fit: contain;
}

.brand-text {
    display: flex;
    flex-direction: column;
    font-size: 1.02rem;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.02em;
}

.brand-text small {
    margin-top: 3px;
    font-size: .6rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-links {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 14px;
    border-radius: 10px;
    color: var(--muted);
    font-size: .9rem;
    font-weight: 650;
    text-decoration: none;
    transition: background .18s, color .18s, box-shadow .18s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex: none;
}

.nav-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, .75);
}

.nav-link.active {
    color: var(--primary);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* ------------------------------------------------------------
   Messages flash
   ------------------------------------------------------------ */

.flash {
    display: flex;
    align-items: center;
    gap: 10px;
    width: calc(100% - 48px);
    max-width: 1280px;
    margin: 16px auto 0;
    padding: 12px 16px;
    border: 1px solid transparent;
    border-radius: 12px;
    font-size: .9rem;
    font-weight: 600;
    transition: opacity .22s, transform .22s;
}

.flash-success {
    color: #047857;
    background: var(--success-soft);
    border-color: rgba(5, 150, 105, .18);
}

.flash-error {
    color: #b91c1c;
    background: var(--danger-soft);
    border-color: rgba(220, 38, 38, .18);
}

.flash.is-out {
    opacity: 0;
    transform: translateY(-6px);
}

.flash-close {
    margin-left: auto;
    padding: 2px 6px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    opacity: .55;
}

.flash-close:hover {
    opacity: 1;
}

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

.page {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.eyebrow {
    margin-bottom: 5px;
    color: var(--primary);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.page-sub {
    margin-top: 7px;
    color: var(--muted);
    font-size: .95rem;
}

.live {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    padding: 8px 12px;
    border: 1px solid rgba(5, 150, 105, .16);
    border-radius: 999px;
    background: var(--success-soft);
    color: #047857;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .02em;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(5, 150, 105, .45);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    70%  { box-shadow: 0 0 0 8px rgba(5, 150, 105, 0); }
    100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

/* ------------------------------------------------------------
   Boutons
   ------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .18s, border-color .18s, box-shadow .18s, transform .12s, opacity .18s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn:active:not(:disabled) {
    transform: scale(.97);
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
}

.btn:focus-visible {
    outline: 3px solid rgba(79, 70, 229, .45);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 10px 20px -12px rgba(79, 70, 229, .85);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-ghost {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--surface-2);
    border-color: #cbd5e1;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-danger-ghost {
    background: var(--danger-soft);
    border-color: rgba(220, 38, 38, .16);
    color: var(--danger);
}

.btn-danger-ghost:hover:not(:disabled) {
    background: #fee2e2;
    border-color: rgba(220, 38, 38, .3);
}

.btn-sm {
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: .82rem;
}

.btn-icon {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 10px;
}

.btn-icon svg {
    width: 18px;
    height: 18px;
}

/* ------------------------------------------------------------
   Cartes de statistiques
   ------------------------------------------------------------ */

.stats-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 20px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.stat-card > * {
    position: relative;
    z-index: 1;
}

.stat-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.stat-value {
    display: block;
    font-size: clamp(1.6rem, 3.2vw, 2.35rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -.035em;
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: .8rem;
}

.stat-primary {
    color: #fff;
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 58%, #3730a3 100%);
    border-color: transparent;
    box-shadow: 0 18px 40px -20px rgba(67, 56, 202, .75);
}

.stat-primary .stat-label,
.stat-primary .stat-sub {
    color: rgba(255, 255, 255, .74);
}

.stat-primary::before,
.stat-primary::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, .07);
    pointer-events: none;
}

.stat-primary::before {
    top: -70px;
    right: -30px;
    width: 190px;
    height: 190px;
}

.stat-primary::after {
    right: 40px;
    bottom: -80px;
    width: 150px;
    height: 150px;
}

.bump {
    animation: bump .45s cubic-bezier(.34, 1.56, .64, 1);
}

@keyframes bump {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.055); }
    100% { transform: scale(1); }
}

/* ------------------------------------------------------------
   Barre "dernière vente" / annulation
   ------------------------------------------------------------ */

.sale-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
    padding: 12px 14px 12px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.last-sale {
    min-width: 0;
    overflow: hidden;
    color: var(--muted);
    font-size: .87rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.last-sale strong {
    color: var(--text);
    font-weight: 750;
}

/* ------------------------------------------------------------
   Moyen de paiement (caisse)
   ------------------------------------------------------------ */

.payment-card {
    margin-bottom: 24px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.payment-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 18px;
}

.payment-head h2 {
    font-size: 1rem;
    letter-spacing: -.01em;
}

.payment-hint {
    margin-top: 3px;
    color: var(--muted);
    font-size: .82rem;
}

.payment-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.payment-btn {
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.payment-btn:hover {
    background: var(--surface-2);
    border-color: #cbd5e1;
}

.payment-btn:focus-visible {
    outline: 3px solid rgba(79, 70, 229, .45);
    outline-offset: 2px;
}

.payment-btn.is-active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 10px 20px -12px rgba(79, 70, 229, .85);
}

/* ------------------------------------------------------------
   Grille de produits (caisse)
   ------------------------------------------------------------ */

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.section-head .hint {
    color: var(--muted);
    font-size: .84rem;
}

.count-pill {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    margin-left: 6px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: .75rem;
    font-weight: 800;
    vertical-align: 2px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.product-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    width: 100%;
    min-height: 136px;
    padding: 18px 18px 16px;
    overflow: hidden;
    border: 0;
    border-radius: 20px;
    background-color: var(--btn-color, var(--primary));
    color: var(--btn-text, #fff);
    text-align: left;
    cursor: pointer;
    box-shadow:
        0 14px 28px -16px rgba(15, 23, 42, .55),
        inset 0 1px 0 rgba(255, 255, 255, .18);
    transition: transform .14s ease, box-shadow .2s ease, filter .2s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.product-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(150deg, rgba(255, 255, 255, .20), rgba(255, 255, 255, 0) 55%);
    pointer-events: none;
}

.product-btn::after {
    content: "+";
    position: absolute;
    top: 13px;
    right: 13px;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1;
    transition: background .18s, transform .18s;
}

@media (hover: hover) {
    .product-btn:hover {
        transform: translateY(-3px);
        box-shadow:
            0 22px 36px -16px rgba(15, 23, 42, .6),
            inset 0 1px 0 rgba(255, 255, 255, .2);
    }

    .product-btn:hover::after {
        transform: rotate(90deg);
        background: rgba(255, 255, 255, .28);
    }
}

.product-btn:active:not(:disabled) {
    transform: scale(.965);
}

.product-btn:focus-visible {
    outline: 3px solid rgba(79, 70, 229, .55);
    outline-offset: 3px;
}

.product-btn:disabled {
    cursor: wait;
}

.product-btn.is-loading {
    filter: saturate(.65);
}

.product-btn.is-loading::after {
    content: "";
    background: transparent;
    border: 2.5px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    opacity: .85;
    animation: spin .7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.product-name {
    position: relative;
    z-index: 1;
    max-width: calc(100% - 20px);
    font-size: 1.08rem;
    font-weight: 750;
    line-height: 1.25;
    letter-spacing: -.01em;
    overflow-wrap: anywhere;
}

.product-price {
    position: relative;
    z-index: 1;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -.025em;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .08);
}

.float-plus {
    position: absolute;
    right: 18px;
    bottom: 14px;
    z-index: 2;
    font-size: 1rem;
    font-weight: 800;
    pointer-events: none;
    animation: floatUp .85s ease forwards;
}

@keyframes floatUp {
    0%   { opacity: 0; transform: translateY(4px) scale(.7); }
    25%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-52px) scale(1.15); }
}

/* État vide */
.empty-state {
    grid-column: 1 / -1;
    padding: 48px 24px;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    text-align: center;
}

.empty-icon {
    display: grid;
    place-items: center;
    width: 54px;
    height: 54px;
    margin: 0 auto 12px;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 1.4rem;
    font-weight: 800;
}

.empty-state h3 {
    margin-bottom: 6px;
    color: var(--text);
    font-size: 1.05rem;
}

.empty-state p {
    margin-bottom: 16px;
    font-size: .9rem;
}

/* ------------------------------------------------------------
   Notifications (toasts)
   ------------------------------------------------------------ */

.toast-container {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 14px;
    background: #0f172a;
    color: #fff;
    box-shadow: 0 20px 40px -18px rgba(15, 23, 42, .75);
    cursor: pointer;
    pointer-events: auto;
    animation: toastIn .3s cubic-bezier(.34, 1.56, .64, 1);
}

.toast-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: .8rem;
    font-weight: 800;
}

.toast-success .toast-icon {
    background: var(--success);
}

.toast-error .toast-icon {
    background: var(--danger);
}

.toast-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.toast-body strong {
    font-size: .88rem;
}

.toast-body span {
    color: rgba(255, 255, 255, .74);
    font-size: .82rem;
    overflow-wrap: anywhere;
}

.toast.is-out {
    animation: toastOut .25s ease forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(14px) scale(.96); }
    to   { opacity: 1; transform: none; }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateY(8px) scale(.97); }
}

/* ------------------------------------------------------------
   Modale de confirmation
   ------------------------------------------------------------ */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity .18s ease;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-backdrop.is-open {
    opacity: 1;
}

.modal {
    width: min(430px, 100%);
    padding: 24px;
    border-radius: 20px;
    background: var(--surface);
    box-shadow: 0 30px 80px -20px rgba(15, 23, 42, .65);
    transform: translateY(10px) scale(.98);
    transition: transform .2s cubic-bezier(.34, 1.56, .64, 1);
}

.modal-backdrop.is-open .modal {
    transform: none;
}

.modal h3 {
    margin-bottom: 8px;
    font-size: 1.2rem;
    letter-spacing: -.02em;
}

.modal p {
    color: var(--muted);
    font-size: .92rem;
    overflow-wrap: anywhere;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

/* ------------------------------------------------------------
   Cartes et formulaires
   ------------------------------------------------------------ */

.card {
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.form-card {
    margin-bottom: 24px;
}

.card-head {
    margin-bottom: 18px;
}

.card-head p {
    margin-top: 4px;
    color: var(--muted);
    font-size: .87rem;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 96px 96px auto;
    gap: 14px;
    align-items: end;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.field label {
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.field input,
.field select {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .95rem;
    transition: border-color .15s, box-shadow .15s;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .14);
}

.field input::placeholder {
    color: #a8b3c5;
}

.field input[type="color"] {
    padding: 4px;
    cursor: pointer;
}

.field input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.field input[type="color"]::-webkit-color-swatch {
    border: 0;
    border-radius: 7px;
}

.field input[type="color"]::-moz-color-swatch {
    border: 0;
    border-radius: 7px;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-hint {
    margin-top: 12px;
    color: var(--muted);
    font-size: .78rem;
}

/* ------------------------------------------------------------
   Liste d'édition des produits
   ------------------------------------------------------------ */

.product-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-row {
    display: grid;
    grid-template-columns: 6px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}

.product-row:hover {
    border-color: #cbd5e1;
    box-shadow: 0 6px 20px -14px rgba(15, 23, 42, .3);
}

.row-accent {
    align-self: stretch;
    width: 6px;
    min-height: 44px;
    border-radius: 999px;
    background: var(--row-color, var(--primary));
}

.row-form {
    display: grid;
    grid-template-columns: minmax(0, 2fr) 108px 70px 80px auto;
    gap: 12px;
    align-items: end;
    min-width: 0;
}

.row-form .field input {
    height: 40px;
    font-size: .9rem;
}

.row-form .field label {
    font-size: .66rem;
}

.row-form .field input[type="color"] {
    height: 40px;
}

.row-save .btn {
    min-height: 40px;
}

.delete-form {
    display: flex;
    align-items: flex-end;
    align-self: end;
}

.delete-form .btn {
    height: 40px;
    min-height: 40px;
}

/* ------------------------------------------------------------
   Bilan — filtres, résumé et tableau
   ------------------------------------------------------------ */

.filter-card {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 20px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.filter-card .field {
    flex: 0 1 190px;
}

.filter-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-left: auto;
}

.quick-ranges a {
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted);
    font-size: .77rem;
    font-weight: 700;
    text-decoration: none;
    transition: color .15s, border-color .15s, background .15s;
}

.quick-ranges a:hover {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: rgba(79, 70, 229, .25);
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .85rem;
    font-weight: 600;
}

.pagination a {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.pagination a:hover {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: rgba(79, 70, 229, .25);
}

.pagination .is-disabled {
    padding: 8px 14px;
    opacity: .45;
}

.inline-form {
    display: inline-block;
    margin: 0;
}

.stats-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-4 .stat-value {
    font-size: clamp(1.4rem, 2.5vw, 2rem);
}

.period-label {
    margin-top: 6px;
    color: var(--muted);
    font-size: .92rem;
}

.table-card {
    padding: 0;
    overflow: hidden;
}

.table-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.table-head p {
    color: var(--muted);
    font-size: .82rem;
}

.table-wrap {
    overflow-x: auto;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

.data thead th {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-size: .7rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data td {
    padding: 14px 20px;
    border-bottom: 1px solid #eef1f7;
    vertical-align: middle;
}

.data tbody tr:last-child td {
    border-bottom: 0;
}

.data tbody tr:hover {
    background: #fafbff;
}

.data .num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.data .strong {
    font-weight: 750;
}

.data tfoot td {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    font-weight: 800;
}

.product-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.product-dot {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--dot-color, var(--primary));
    box-shadow: 0 0 0 3px rgba(15, 23, 42, .04);
}

.share-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 150px;
}

.share-bar {
    flex: 1;
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #eef1f7;
}

.share-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #6366f1, #4338ca);
}

.share-cell small {
    width: 44px;
    color: var(--muted);
    font-size: .74rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.table-footnote {
    padding: 14px 20px;
    color: var(--muted);
    font-size: .78rem;
}

.notice {
    margin-bottom: 18px;
    padding: 12px 16px;
    border: 1px solid rgba(217, 119, 6, .2);
    border-radius: 12px;
    background: var(--warning-soft);
    color: #92400e;
    font-size: .87rem;
    font-weight: 600;
}

.empty-state--flush {
    border: 0;
    border-radius: 0;
}

/* ------------------------------------------------------------
   Page d'erreur
   ------------------------------------------------------------ */

.error-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.error-card {
    width: min(580px, 100%);
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.error-icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 16px;
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 1.5rem;
    font-weight: 800;
}

.error-card h1 {
    margin-bottom: 10px;
    font-size: 1.45rem;
}

.error-card p {
    color: var(--muted);
    font-size: .92rem;
}

.error-card pre {
    margin: 16px 0;
    padding: 14px;
    overflow: auto;
    border-radius: 10px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: .76rem;
    text-align: left;
    white-space: pre-wrap;
}

.error-help {
    margin: 14px 0 20px !important;
    font-size: .84rem !important;
}

.error-card code {
    padding: 2px 5px;
    border-radius: 5px;
    background: var(--surface-2);
    color: var(--text);
    font-size: .82em;
}

/* ------------------------------------------------------------
   Adaptations tablette / mobile
   ------------------------------------------------------------ */

@media (max-width: 960px) {
    .product-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .stats-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid {
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) 96px 96px;
    }

    .form-grid .form-actions {
        grid-column: 1 / -1;
    }

    .row-form {
        grid-template-columns: minmax(0, 1.6fr) 100px 64px 76px;
    }

    .row-form .row-save {
        grid-column: 1 / -1;
        justify-self: start;
    }
}

/* Sous 880px, l'en-tête passe sur deux lignes : la marque et le bouton
   « Quitter » en haut, la navigation en pleine largeur en dessous. Cela
   évite tout débordement horizontal des quatre onglets. */
@media (max-width: 880px) {
    .nav-inner {
        flex-wrap: wrap;
    }

    .nav-links {
        order: 3;
        width: 100%;
        justify-content: space-between;
    }

    .nav-logout {
        margin-left: auto;
    }
}

@media (max-width: 600px) {
    .nav-inner {
        padding: 8px 12px;
        gap: 8px;
    }

    .brand-text small {
        display: none;
    }

    .brand-text {
        font-size: .95rem;
    }

    .brand-logo {
        height: 34px;
    }

    /* Zone tactile confortable pour le retour à l'accueil. */
    .brand {
        min-height: 44px;
    }

    /* Onglets de navigation : quatre cases égales, icône au-dessus du libellé. */
    .nav-links {
        gap: 2px;
        padding: 3px;
    }

    .nav-link {
        flex: 1 1 0;
        flex-direction: column;
        justify-content: center;
        gap: 3px;
        min-width: 0;
        min-height: 48px;
        padding: 6px 4px;
        font-size: .72rem;
        line-height: 1.2;
        text-align: center;
    }

    .nav-link svg {
        width: 17px;
        height: 17px;
    }

    /* Sur téléphone, l'en-tête sur deux rangées ne reste pas collé :
       il occuperait une place trop importante en permanence. */
    .topbar {
        position: static;
    }

    /* iOS agrandit la page au focus des champs dont la police fait
       moins de 16px : on force 1rem sur les champs de saisie. */
    .field input,
    .field select {
        font-size: 1rem;
    }

    /* Zones tactiles d'au moins 40px pour les filtres rapides
       et la pagination. */
    .quick-ranges a,
    .pagination a,
    .pagination .is-disabled {
        display: inline-flex;
        align-items: center;
        min-height: 40px;
    }

    .flash-close {
        min-width: 32px;
        min-height: 32px;
    }

    .flash {
        width: calc(100% - 24px);
        margin-top: 12px;
    }

    .page {
        padding: 20px 16px 48px;
    }

    .page-head {
        align-items: flex-start;
        margin-bottom: 18px;
    }

    .page-sub {
        font-size: .88rem;
    }

    .live {
        padding: 6px 10px;
        font-size: .7rem;
    }

    /* 2 colonnes strictement sur smartphone */
    .product-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .product-btn {
        min-height: 118px;
        padding: 15px 14px 13px;
        border-radius: 16px;
    }

    .product-name {
        font-size: .98rem;
    }

    .product-price {
        font-size: 1.18rem;
    }

    .product-btn::after {
        top: 10px;
        right: 10px;
        width: 24px;
        height: 24px;
        font-size: .95rem;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .stat-primary {
        grid-column: 1 / -1;
    }

    .stat-card {
        padding: 16px 16px;
    }

    .stat-value {
        font-size: 1.65rem;
    }

    .stat-label {
        font-size: .68rem;
    }

    .sale-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }

    .last-sale {
        white-space: normal;
    }

    .sale-toolbar .btn {
        width: 100%;
    }

    .payment-options {
        width: 100%;
    }

    .payment-btn {
        flex: 1 1 0;
        padding: 10px 12px;
    }

    .section-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .toast-container {
        right: 12px;
        bottom: 12px;
        left: 12px;
        width: auto;
    }

    .modal-actions {
        flex-direction: column-reverse;
    }

    .modal-actions .btn {
        width: 100%;
    }

    .form-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-grid .field-name {
        grid-column: 1 / -1;
    }

    .form-grid .form-actions {
        grid-column: 1 / -1;
    }

    .form-grid .form-actions .btn {
        width: 100%;
    }

    .product-row {
        grid-template-columns: 5px minmax(0, 1fr);
        gap: 10px;
        padding: 12px;
    }

    .row-accent {
        width: 5px;
    }

    .row-form {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .row-form .field-name {
        grid-column: 1 / -1;
    }

    .row-form .row-save {
        grid-column: 1 / -1;
    }

    .row-form .row-save .btn {
        width: 100%;
    }

    .delete-form {
        grid-column: 2;
    }

    .delete-form .btn {
        width: 100%;
    }

    .filter-card {
        padding: 14px;
        gap: 12px;
    }

    .filter-card .field {
        flex: 1 1 100%;
    }

    .filter-actions {
        width: 100%;
    }

    .filter-actions .btn {
        flex: 1;
    }

    .quick-ranges {
        width: 100%;
        margin-left: 0;
    }

    .stats-4 {
        grid-template-columns: 1fr 1fr;
    }

    .table-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
        padding: 16px;
    }

    .data thead th,
    .data td,
    .data tfoot td {
        padding: 12px;
    }

    .hide-sm {
        display: none !important;
    }

    .share-cell {
        min-width: 90px;
    }

    .share-bar {
        min-width: 40px;
    }

    .error-card {
        padding: 24px 20px;
    }
}

@media (max-width: 420px) {
    .brand-text {
        display: none;
    }

    .nav-link {
        padding: 8px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .product-btn {
        min-height: 108px;
    }
}

/* ------------------------------------------------------------
   Impression (bilan)
   ------------------------------------------------------------ */

@media print {
    body {
        background: #fff;
    }

    .topbar,
    .flash,
    .filter-card,
    .no-print,
    .quick-ranges,
    .toast-container {
        display: none !important;
    }

    .page {
        max-width: none;
        padding: 0;
    }

    .stat-card,
    .table-card {
        box-shadow: none;
        border-color: #ddd;
        break-inside: avoid;
    }

    .stat-primary {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #ddd;
    }

    .stat-primary .stat-label,
    .stat-primary .stat-sub {
        color: #555;
    }

    .stat-primary::before,
    .stat-primary::after {
        display: none;
    }

    .data thead th {
        background: #f2f2f2;
    }
}

/* ------------------------------------------------------------
   Bouton « Quitter » de la barre de navigation
   ------------------------------------------------------------ */

.nav-logout {
    display: flex;
    flex: none;
    margin: 0;
}

.nav-logout-btn {
    border: 1px solid transparent;
    background: none;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 650;
    color: var(--muted);
    cursor: pointer;
}

.nav-logout-btn:hover {
    color: #b91c1c;
    background: var(--danger-soft);
}

/* ------------------------------------------------------------
   Écran de connexion
   ------------------------------------------------------------ */

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    /* dvh : évite le saut de mise en page quand la barre d'URL mobile se replie. */
    min-height: 100dvh;
    padding: 24px;
}

.auth-card {
    width: min(430px, 100%);
    padding: 30px 28px 24px;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 22px;
}

.auth-card h1 {
    font-size: 1.5rem;
}

.auth-sub {
    margin-top: 6px;
    color: var(--muted);
    font-size: .92rem;
}

.auth-alert {
    margin-top: 18px;
    padding: 12px 14px;
    border: 1px solid rgba(220, 38, 38, .18);
    border-radius: 12px;
    background: var(--danger-soft);
    color: #b91c1c;
    font-size: .86rem;
    font-weight: 600;
    line-height: 1.45;
}

.auth-alert strong {
    display: block;
}

.auth-alert span {
    display: block;
    margin-top: 3px;
    font-weight: 500;
}

.auth-alert code {
    padding: 1px 5px;
    border-radius: 5px;
    background: rgba(220, 38, 38, .1);
    font-size: .95em;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.auth-input {
    position: relative;
}

.auth-input input {
    padding-right: 92px;
}

.auth-reveal {
    position: absolute;
    top: 50%;
    right: 6px;
    padding: 6px 10px;
    border: 0;
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--muted);
    font-family: inherit;
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .02em;
    cursor: pointer;
    transform: translateY(-50%);
    transition: background .15s, color .15s;
}

.auth-reveal:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.auth-submit {
    width: 100%;
    margin-top: 2px;
}

.auth-note {
    margin-top: 14px;
    color: var(--muted);
    font-size: .78rem;
    text-align: center;
}

@media (max-width: 600px) {
    .nav-logout-btn {
        padding: 8px 10px;
    }

    /* Libellé masqué visuellement mais conservé pour les lecteurs d'écran. */
    .nav-logout-btn span {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
        border: 0;
    }

    .auth-card {
        padding: 24px 20px 20px;
        border-radius: 18px;
    }
}
