:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-strong: #eef3f8;

    --text: #111827;
    --text-soft: #374151;
    --muted: #6b7280;
    --muted-light: #9ca3af;

    --border: #e5e7eb;
    --border-strong: #d1d5db;

    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-soft: #eff6ff;

    --success: #15803d;
    --success-hover: #166534;
    --success-soft: #ecfdf3;

    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-soft: #fef2f2;

    --warning: #d97706;
    --warning-hover: #b45309;
    --warning-soft: #fffbeb;

    --dark: #111827;
    --dark-hover: #030712;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.12);

    --font-main: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

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

* {
    font-family: var(--font-main);
}

html {
    width: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    width: 100%;
    background:
        radial-gradient(circle at top left, rgba(29, 78, 216, 0.08), transparent 32%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 42%, #eef3f8 100%);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}

img,
canvas,
video {
    max-width: 100%;
}

.container {
    width: 100%;
    max-width: 1320px;
    min-width: 0;
    margin: 0 auto;
    padding: 24px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 10px;
    font-size: 34px;
    line-height: 1.1;
    letter-spacing: -0.04em;
    color: var(--text);
}

h2 {
    margin-bottom: 6px;
    font-size: 22px;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text);
}

h3 {
    margin-bottom: 4px;
    font-size: 17px;
    line-height: 1.2;
    color: var(--text);
}

p {
    color: var(--muted);
}

.subtitle {
    max-width: 760px;
    margin-bottom: 0;
    color: var(--text-soft);
    font-size: 15px;
}

.hidden {
    display: none !important;
}

.section-gap {
    margin-top: 14px;
}

/* Login */

.login-screen {
    min-height: calc(100vh - 48px);
    display: grid;
    place-items: center;
}

.login-card {
    width: 100%;
    max-width: 460px;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(209, 213, 219, 0.9);
    border-radius: var(--radius-xl);
    padding: 28px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(12px);
}

.login-brand,
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), #0f766e);
    color: #fff;
    font-weight: 900;
    font-size: 18px;
    box-shadow: 0 12px 24px rgba(29, 78, 216, 0.24);
}

.brand-title {
    font-weight: 800;
    font-size: 17px;
    color: var(--text);
    line-height: 1.1;
}

.brand-subtitle {
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.login-header {
    margin-top: 30px;
    margin-bottom: 20px;
}

.login-header h1 {
    font-size: 30px;
    margin-bottom: 8px;
}

.login-header p {
    margin-bottom: 0;
}

.form-stack {
    display: grid;
    gap: 14px;
}

.login-actions {
    margin-top: 18px;
}

/* App shell */

.app-shell {
    width: 100%;
    min-width: 0;
    display: grid;
    gap: 20px;
}

.topbar,
.auth-bar {
    position: static;
    z-index: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(209, 213, 219, 0.85);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(12px);
}

.topbar-session {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-user {
    color: var(--muted);
    font-size: 14px;
    white-space: nowrap;
}

.auth-user strong {
    color: var(--text);
    font-weight: 800;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 20px;
    align-items: stretch;
    padding: 28px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(248, 250, 252, 0.88)),
        radial-gradient(circle at top right, rgba(29, 78, 216, 0.12), transparent 38%);
    border: 1px solid rgba(209, 213, 219, 0.86);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

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

.hero-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;
    background: var(--dark);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    color: #fff;
}

.hero-panel-label {
    margin-bottom: 8px;
    color: #bfdbfe;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.hero-panel-title {
    font-size: 20px;
    font-weight: 850;
    line-height: 1.2;
}

.hero-panel-text {
    margin-top: 8px;
    color: #d1d5db;
    font-size: 14px;
}

/* Cards */

.card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.card-header > * {
    min-width: 0;
}

.card-header p {
    margin-bottom: 0;
    font-size: 14px;
}

.edit-alert {
    display: none;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: var(--warning-soft);
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    color: #92400e;
    font-size: 14px;
    font-weight: 600;
}

.edit-alert.active {
    display: block;
}

/* Barcode scanner */

.input-action-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-action-row input {
    min-width: 0;
}

.btn-scan {
    flex: 0 0 auto;
}

.barcode-scanner {
    margin-bottom: 18px;
    padding: 16px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.barcode-scanner-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.barcode-scanner-header h3 {
    margin-bottom: 4px;
}

.barcode-scanner-header p {
    margin-bottom: 0;
    font-size: 13px;
}

.barcode-video-box {
    position: relative;
    overflow: hidden;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    background: #020617;
    border-radius: var(--radius-lg);
    aspect-ratio: 4 / 3;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.barcode-video-box video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.barcode-scan-frame {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 34%;
    height: 28%;
    border: 2px solid rgba(255, 255, 255, 0.92);
    border-radius: 14px;
    box-shadow:
        0 0 0 999px rgba(2, 6, 23, 0.35),
        0 0 24px rgba(29, 78, 216, 0.35);
    pointer-events: none;
}

.barcode-scan-frame::after {
    content: "";
    position: absolute;
    left: 8%;
    right: 8%;
    top: 50%;
    height: 2px;
    background: #22c55e;
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.9);
}

.barcode-scanner-message {
    margin-top: 12px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.barcode-scanner-message.success {
    background: var(--success-soft);
    border-color: #bbf7d0;
    color: #166534;
}

.barcode-scanner-message.error {
    background: var(--danger-soft);
    border-color: #fecaca;
    color: #991b1b;
}

/* Forms */

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    align-items: end;
}

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

.field {
    min-width: 0;
}

label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 800;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="number"],
input[type="file"],
textarea,
select {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    padding: 11px 13px;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input[type="file"] {
    padding: 9px 12px;
    color: var(--muted);
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(29, 78, 216, 0.72);
    box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.11);
}

textarea {
    min-height: 112px;
    resize: vertical;
}

.form-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.checks {
    min-width: 0;
    flex: 1 1 480px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.check-inline {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 999px;
}

.check-inline input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    flex: 0 0 auto;
}

.check-inline label {
    margin: 0;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 800;
}

.product-status-group {
    min-width: 0;
    flex: 1 1 520px;
}

.status-group-label {
    margin-bottom: 8px;
    color: var(--text-soft);
    font-size: 13px;
    font-weight: 900;
}

.status-group-label span {
    color: var(--danger);
}

.field-hint {
    margin-top: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.product-status-pills {
    flex: none;
}

.product-status-pill {
    cursor: pointer;
    transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.product-status-pill input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.product-status-pill label {
    cursor: pointer;
}

.product-status-pill.active {
    background: var(--primary-soft);
    border-color: #bfdbfe;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.08);
}

.product-status-pill.active label {
    color: var(--primary);
}

.product-status-pill:focus-within {
    border-color: rgba(29, 78, 216, 0.72);
    box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.11);
}

.product-status-group.status-error .status-group-label,
.product-status-group.status-error .field-hint {
    color: var(--danger);
}

.product-status-group.status-error .product-status-pill {
    background: var(--danger-soft);
    border-color: #fecaca;
}

/* Buttons */

button {
    max-width: 100%;
    min-height: 42px;
    border: none;
    border-radius: var(--radius-md);
    padding: 11px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 850;
    line-height: 1.2;
    white-space: nowrap;
    transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, opacity 140ms ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

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

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

.btn-secondary:hover {
    background: var(--success-hover);
}

.btn-dark {
    background: #444;
    color: #fff;
}

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

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

.btn-danger:hover {
    background: var(--danger-hover);
}

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

.btn-warning:hover {
    background: var(--warning-hover);
}

.btn-light {
    background: var(--surface-strong);
    color: var(--text);
    border: 1px solid var(--border-strong);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

.message {
    display: none;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 650;
}

.message.success {
    display: block;
    background: var(--success-soft);
    color: #166534;
    border: 1px solid #bbf7d0;
}

.message.error {
    display: block;
    background: var(--danger-soft);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.meta {
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
}

/* Filters */

.filters {
    display: grid;
    grid-template-columns: 2fr 1fr auto auto auto auto;
    gap: 14px;
    align-items: end;
}

.filter-check {
    min-height: 44px;
    justify-content: center;
}

/* Stats */

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.stat-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--muted);
    font-size: 14px;
    font-weight: 750;
}

.stat-card strong {
    color: var(--primary);
    font-size: 22px;
    font-weight: 900;
}

/* Table */

.selection-bar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.selection-bar h2 {
    margin-bottom: 4px;
}

.table-subtitle {
    margin-bottom: 0;
    font-size: 14px;
}

.selection-tools {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.selection-info {
    flex: 0 0 auto;
    padding: 9px 12px;
    background: var(--primary-soft);
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 850;
    line-height: 1.35;
}

.table-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    min-width: 1230px;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 14px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--surface-soft);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

tbody tr {
    transition: background 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
}

tbody tr:hover {
    background: #f9fafb;
}

tbody tr:last-child td {
    border-bottom: none;
}

.product-table-spacer {
    width: 46px;
    min-width: 46px;
    text-align: center;
}

.product-image {
    width: 74px;
    height: 74px;
    object-fit: cover;
    display: block;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.empty {
    padding: 28px;
    text-align: center;
    color: var(--muted);
    font-style: italic;
}

.small-btn {
    min-height: 36px;
    margin-right: 6px;
    margin-bottom: 6px;
    padding: 8px 11px;
    font-size: 13px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.table-actions .small-btn {
    margin: 0;
}

.tag {
    display: inline-flex;
    align-items: center;
    margin-right: 6px;
    margin-bottom: 5px;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.tag-new {
    background: var(--primary-soft);
    color: var(--primary);
}

.tag-promo {
    background: var(--danger-soft);
    color: var(--danger);
}

.tag-classic {
    background: var(--surface-soft);
    color: var(--muted);
}

.price {
    color: var(--success);
    font-weight: 900;
    white-space: nowrap;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

/* Tablette : proche PC, seulement plus compact */

@media (max-width: 1100px) {
    .container {
        padding: 18px;
    }

    .hero {
        grid-template-columns: 1fr;
        padding: 24px;
    }

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

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

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

    .filters > div:last-child {
        grid-column: span 2;
    }

    .filters button {
        width: 100%;
    }

    table {
        min-width: 1040px;
    }
}

/* Petite tablette : adaptation légère, pas de transformation complète */

@media (max-width: 850px) {
    .container {
        padding: 14px;
    }

    h1 {
        font-size: 28px;
    }

    h2 {
        font-size: 21px;
    }

    .topbar,
    .auth-bar {
        position: static;
        align-items: center;
    }

    .topbar-session {
        flex-direction: row;
        align-items: center;
    }

    .hero {
        padding: 20px;
    }

    .card {
        padding: 18px;
    }

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

    .filters > div:first-child {
        grid-column: span 2;
    }

    .filters > div:last-child {
        grid-column: span 2;
    }

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

    .form-footer {
        align-items: center;
    }

    .actions {
        gap: 10px;
    }

    .selection-bar {
        align-items: flex-start;
    }

    table {
        min-width: 980px;
    }

    th,
    td {
        padding: 11px;
    }
}

/* Téléphone : même structure que PC, mais compacte */

@media (max-width: 700px) {
    body {
        background: var(--bg);
        font-size: 14px;
    }

    .container {
        padding: 10px;
    }

    .app-shell {
        gap: 12px;
    }

    h1 {
        font-size: 24px;
        line-height: 1.15;
        margin-bottom: 6px;
    }

    h2 {
        font-size: 19px;
        margin-bottom: 4px;
    }

    p,
    .subtitle,
    .card-header p,
    .table-subtitle,
    .meta {
        font-size: 13px;
        line-height: 1.4;
    }

    .login-screen {
        min-height: calc(100vh - 20px);
    }

    .login-card {
        max-width: 100%;
        padding: 18px;
        border-radius: 18px;
    }

    .login-header {
        margin-top: 20px;
        margin-bottom: 14px;
    }

    .login-header h1 {
        font-size: 24px;
    }

    .brand-mark {
        width: 38px;
        height: 38px;
        border-radius: 12px;
        font-size: 16px;
    }

    .brand-title {
        font-size: 15px;
    }

    .brand-subtitle {
        font-size: 12px;
    }

    .topbar,
    .auth-bar {
        padding: 12px;
        border-radius: 16px;
        gap: 10px;
        flex-direction: row;
        align-items: center;
    }

    .topbar-brand {
        min-width: 0;
    }

    .topbar-session {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .auth-user {
        font-size: 12px;
        white-space: normal;
    }

    .topbar .brand-subtitle {
        display: none;
    }

    .hero {
        display: block;
        padding: 16px;
        border-radius: 18px;
    }

    .hero-panel {
        display: none;
    }

    .eyebrow {
        font-size: 11px;
        margin-bottom: 6px;
    }

    .card {
        padding: 14px;
        border-radius: 18px;
    }

    .card-header {
        margin-bottom: 12px;
    }

    .grid-4,
    .grid-3,
    .grid-2,
    .filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .field {
        min-width: 0;
    }

    label {
        font-size: 12px;
        margin-bottom: 5px;
    }

    input[type="email"],
    input[type="password"],
    input[type="text"],
    input[type="number"],
    input[type="file"],
    textarea,
    select {
        min-height: 38px;
        padding: 8px 10px;
        border-radius: 10px;
        font-size: 13px;
    }

    input[type="file"] {
        padding: 7px 8px;
        font-size: 12px;
    }

    textarea {
        min-height: 76px;
    }

    .input-action-row {
        gap: 6px;
    }

    .btn-scan {
        padding-left: 10px;
        padding-right: 10px;
    }

    .barcode-scanner {
        padding: 12px;
        border-radius: 16px;
        margin-bottom: 14px;
    }

    .barcode-scanner-header {
        gap: 10px;
        margin-bottom: 10px;
    }

    .barcode-scanner-header p {
        font-size: 12px;
    }

    .barcode-video-box {
        max-width: 100%;
        border-radius: 14px;
    }

    .barcode-scanner-message {
        padding: 8px 10px;
        font-size: 12px;
    }

    .form-footer {
        margin-top: 12px;
        padding-top: 12px;
        gap: 10px;
        align-items: center;
        flex-direction: row;
    }

    .checks {
        gap: 8px;
    }

    .check-inline {
        min-height: 34px;
        padding: 6px 9px;
        border-radius: 10px;
    }

    .check-inline input {
        width: 14px;
        height: 14px;
    }

    .check-inline label {
        font-size: 12px;
    }

    .product-status-group {
        flex-basis: 100%;
    }

    .product-status-pills {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .field-hint {
        font-size: 11px;
    }

    button {
        min-height: 36px;
        padding: 8px 12px;
        border-radius: 10px;
        font-size: 13px;
        white-space: nowrap;
    }

    .form-footer button {
        flex: 0 0 auto;
    }

    .actions {
        gap: 8px;
        margin-top: 14px;
        display: flex;
        flex-wrap: wrap;
    }

    .actions button {
        flex: 1 1 150px;
        width: auto;
    }

    .message {
        margin-top: 10px;
        padding: 9px 10px;
        font-size: 13px;
    }

    .edit-alert {
        margin-bottom: 12px;
        padding: 9px 10px;
        font-size: 13px;
    }

    .filters > div:first-child,
    .filters > div:last-child {
        grid-column: span 2;
    }

    .filter-check {
        min-height: 34px;
    }

    .stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-top: 12px;
    }

    .stat-card {
        display: block;
        padding: 10px;
        border-radius: 12px;
        font-size: 11px;
        text-align: center;
    }

    .stat-card strong {
        display: block;
        margin-top: 3px;
        font-size: 18px;
    }

    .selection-bar {
        gap: 10px;
        margin-bottom: 12px;
        align-items: flex-start;
    }

    .selection-tools {
        gap: 8px;
    }

    .selection-info {
        padding: 7px 9px;
        font-size: 12px;
        border-radius: 12px;
        white-space: normal;
    }

    .table-wrap {
        overflow-x: auto;
        border-radius: 14px;
        border: 1px solid var(--border);
        background: #fff;
    }

    table {
        display: table;
        width: 100%;
        min-width: 940px;
        border-collapse: collapse;
        background: #fff;
    }

    thead {
        display: table-header-group;
    }

    tbody {
        display: table-row-group;
    }

    tr {
        display: table-row;
        padding: 0;
        margin: 0;
        border: none;
        box-shadow: none;
        background: transparent;
    }

    th,
    td {
        display: table-cell;
        padding: 9px;
        border-bottom: 1px solid var(--border);
        vertical-align: middle;
        word-break: normal;
    }

    td::before {
        content: none !important;
        display: none !important;
    }

    th {
        font-size: 10px;
    }

    td {
        font-size: 12px;
    }

    .product-table-spacer {
        width: 38px;
        min-width: 38px;
    }

    .product-image {
        width: 52px;
        height: 52px;
        border-radius: 10px;
    }

    .small-btn {
        width: auto;
        min-height: 30px;
        padding: 6px 8px;
        margin-right: 4px;
        margin-bottom: 4px;
        font-size: 11px;
        border-radius: 8px;
    }

    .table-actions {
        gap: 4px;
    }

    .tag {
        padding: 4px 7px;
        font-size: 10px;
    }

    .price {
        white-space: nowrap;
    }

    .empty {
        padding: 18px;
        text-align: center;
        font-size: 13px;
    }
}

/* Très petit téléphone : encore plus compact */

@media (max-width: 420px) {
    .container {
        padding: 8px;
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 18px;
    }

    .topbar,
    .auth-bar {
        padding: 10px;
    }

    .auth-user {
        font-size: 11px;
    }

    .btn-dark {
        padding-left: 9px;
        padding-right: 9px;
    }

    .hero,
    .card,
    .login-card {
        padding: 12px;
        border-radius: 16px;
    }

    .grid-4,
    .grid-3,
    .grid-2,
    .filters {
        gap: 8px;
    }

    input[type="email"],
    input[type="password"],
    input[type="text"],
    input[type="number"],
    input[type="file"],
    textarea,
    select {
        min-height: 36px;
        padding: 7px 9px;
        font-size: 12px;
    }

    label {
        font-size: 11px;
    }

    button {
        min-height: 34px;
        padding: 7px 10px;
        font-size: 12px;
    }

    .form-footer {
        align-items: stretch;
        flex-direction: column;
    }

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

    .form-footer button {
        width: 100%;
    }

    .actions button {
        flex-basis: 100%;
    }

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

    .stat-card {
        padding: 8px 6px;
    }

    .stat-card strong {
        font-size: 16px;
    }

    .input-action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-scan {
        width: 100%;
    }

    .barcode-scanner-header {
        flex-direction: column;
        align-items: stretch;
    }

    .barcode-scanner-header button {
        width: 100%;
    }

    table {
        min-width: 890px;
    }

    th,
    td {
        padding: 8px;
    }

    .product-image {
        width: 48px;
        height: 48px;
    }
}


/* Correctif urgent mobile après ajout scanner */
@media (max-width: 700px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
    }

    .container,
    .app-shell,
    .card,
    .hero,
    .grid-4,
    .grid-3,
    .grid-2,
    .filters,
    .field,
    .input-action-row {
        min-width: 0;
        max-width: 100%;
    }

    .container {
        padding: 10px;
    }

    .app-shell {
        gap: 12px;
    }

    .card {
        padding: 14px;
        border-radius: 18px;
    }

    .hero {
        display: block;
        padding: 16px;
        border-radius: 18px;
    }

    .hero-panel {
        display: none;
    }

    .grid-4,
    .grid-3,
    .grid-2,
    .filters {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .filters > div:first-child,
    .filters > div:last-child {
        grid-column: auto !important;
    }

    input[type="email"],
    input[type="password"],
    input[type="text"],
    input[type="number"],
    input[type="file"],
    textarea,
    select {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 38px;
        padding: 8px 10px;
        border-radius: 10px;
        font-size: 13px;
    }

    input[type="file"] {
        font-size: 12px;
        padding: 7px 8px;
    }

    .input-action-row {
        display: flex;
        width: 100%;
        gap: 6px;
        align-items: center;
    }

    .input-action-row input {
        flex: 1 1 auto;
        min-width: 0;
    }

    .btn-scan {
        flex: 0 0 auto;
        padding-left: 10px;
        padding-right: 10px;
    }

    button {
        min-height: 36px;
        padding: 8px 12px;
        border-radius: 10px;
        font-size: 13px;
        white-space: normal;
    }

    .form-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .form-footer button {
        width: 100%;
    }

    .checks {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .check-inline {
        min-height: 34px;
        padding: 6px 9px;
        border-radius: 10px;
        justify-content: center;
    }

    .actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 14px;
    }

    .actions button {
        width: 100%;
    }

    .topbar,
    .auth-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        border-radius: 16px;
    }

    .topbar-session {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .auth-user {
        white-space: normal;
        font-size: 12px;
    }

    .selection-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .selection-tools {
        width: 100%;
        align-items: stretch;
    }

    .barcode-scanner {
        padding: 12px;
        border-radius: 16px;
        margin-bottom: 14px;
    }

    .barcode-video-box {
        max-width: 100%;
        border-radius: 14px;
    }

    .table-wrap {
        overflow-x: auto;
        max-width: 100%;
        border-radius: 14px;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 900px;
    }
}

@media (max-width: 420px) {
    .container {
        padding: 8px;
    }

    .hero,
    .card,
    .login-card {
        padding: 12px;
        border-radius: 16px;
    }

    .input-action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-scan {
        width: 100%;
    }

    .barcode-scanner-header {
        flex-direction: column;
        align-items: stretch;
    }

    .barcode-scanner-header button {
        width: 100%;
    }

    table {
        min-width: 860px;
    }
}

/* Correctif layout responsive production
   Objectif : éviter tout dépassement horizontal global sans masquer le problème.
   La table conserve uniquement son scroll horizontal interne via .table-wrap. */
html,
body {
    max-width: 100%;
}

body {
    min-width: 0;
}

.container,
.app-shell,
.card,
.hero,
.topbar,
.auth-bar,
.grid-4,
.grid-3,
.grid-2,
.filters,
.stats,
.selection-bar,
.selection-tools,
.product-status-group,
.table-wrap,
.field,
.input-action-row,
textarea {
    min-width: 0;
    max-width: 100%;
}

.topbar,
.auth-bar {
    flex-wrap: wrap;
}

.login-brand,
.topbar-brand {
    min-width: 0;
}

.topbar-brand {
    flex: 1 1 260px;
}

.topbar-session {
    min-width: 0;
    flex: 0 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.auth-user {
    min-width: 0;
    overflow-wrap: anywhere;
}

.hero > *,
.card-header > *,
.selection-bar > * {
    min-width: 0;
}

.filters {
    display: flex !important;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    width: 100%;
}

.filters > .field {
    flex: 1 1 240px;
    min-width: min(240px, 100%);
}

.filters > .field:first-child {
    flex: 2 1 360px;
    min-width: min(320px, 100%);
}

.filters > .filter-check {
    flex: 0 1 auto;
    max-width: 100%;
}

.filters > div:last-child {
    flex: 0 1 auto;
    min-width: 0;
}

.filter-check,
.check-inline {
    max-width: 100%;
}

.check-inline label {
    white-space: nowrap;
}

.stats {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}

.stat-card {
    min-width: 0;
}

.stat-card strong {
    min-width: 0;
    text-align: right;
}

.selection-bar {
    flex-wrap: wrap;
}

.selection-bar > div:first-child {
    flex: 1 1 360px;
}

.selection-tools {
    flex: 1 1 320px;
}

.selection-info {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: right;
}

.actions button,
.form-footer button {
    flex: 0 1 auto;
}

textarea,
input,
select,
button {
    min-width: 0;
}

.table-actions {
    min-width: 0;
}

@media (max-width: 1100px) {
    .filters > .field:first-child,
    .filters > .field {
        flex-basis: calc(50% - 7px);
    }

    .filters > .filter-check,
    .filters > div:last-child {
        flex: 1 1 auto;
    }
}

@media (max-width: 850px) {
    .selection-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .selection-tools {
        width: 100%;
        align-items: stretch;
    }

    .selection-info {
        text-align: left;
    }

}

@media (max-width: 700px) {
    .container {
        width: 100%;
        padding: 10px;
    }

    .filters {
        flex-direction: column;
        align-items: stretch;
    }

    .filters > .field,
    .filters > .field:first-child,
    .filters > .filter-check,
    .filters > div:last-child {
        width: 100%;
        min-width: 0;
        flex: 1 1 auto;
    }

    .filter-check {
        justify-content: flex-start;
    }

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

    .stat-card {
        display: flex;
        text-align: left;
    }

    .selection-info {
        text-align: left;
    }

}

/* Phase 2A : structure compacte, dialog produit et filtres repliables */

body.product-dialog-open {
    overflow: hidden;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.page-heading-copy {
    min-width: 0;
}

.page-heading h1 {
    margin-bottom: 7px;
    font-size: 30px;
}

.page-heading .eyebrow {
    margin-bottom: 6px;
}

.page-heading-action {
    flex: 0 0 auto;
}

.page-message {
    margin-top: -8px;
}

.product-dialog {
    width: min(940px, calc(100vw - 32px));
    max-width: 940px;
    max-height: min(90vh, 880px);
    padding: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
    color: var(--text);
}

.product-dialog::backdrop {
    background: rgba(15, 23, 42, 0.58);
}

.product-dialog-shell {
    width: 100%;
    max-height: min(90vh, 880px);
    display: flex;
    flex-direction: column;
    margin: 0;
}

.product-dialog-header,
.product-dialog-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
    background: var(--surface);
}

.product-dialog-header {
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.product-dialog-header h2 {
    margin-bottom: 4px;
}

.product-dialog-header p {
    margin-bottom: 0;
    font-size: 13px;
}

.product-dialog-close {
    flex: 0 0 auto;
}

.product-dialog-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 20px;
}

.product-dialog-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 20px rgba(15, 23, 42, 0.04);
}

.product-dialog-message {
    margin-top: 0;
    margin-bottom: 16px;
}

.product-dialog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
}

.product-dialog-notes {
    grid-column: 1 / -1;
}

.product-dialog-status {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.product-dialog .barcode-scanner {
    margin-bottom: 18px;
}

.product-dialog button:focus-visible,
.page-heading button:focus-visible,
.filters-card button:focus-visible,
.products-card button:focus-visible {
    outline: 3px solid rgba(29, 78, 216, 0.32);
    outline-offset: 2px;
}

.filters-card {
    padding: 18px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.filters-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 14px;
}

.filters-heading {
    min-width: 0;
}

.filters-kicker {
    margin-bottom: 3px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.filters-heading h2 {
    margin-bottom: 3px;
    font-size: 19px;
}

.filters-heading p {
    margin-bottom: 0;
    font-size: 13px;
}

.filter-metrics {
    flex: 0 1 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
    min-height: 36px;
    padding: 7px 10px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.filter-metric {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
}

.filter-metric strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 900;
}

.filter-metric-separator {
    color: var(--border-strong);
}

.products-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 2px;
    color: var(--primary);
    white-space: nowrap;
}

.products-loading[hidden] {
    display: none !important;
}

.products-loading::before {
    content: "";
    width: 12px;
    height: 12px;
    border: 2px solid #bfdbfe;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: filters-loading-spin 700ms linear infinite;
}

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

.filters-toolbar {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(210px, 260px) auto auto;
    align-items: end;
    gap: 10px;
}

.filters-toolbar .field label {
    margin-bottom: 5px;
    font-size: 12px;
}

.filters-card input[type="text"],
.filters-card select {
    min-height: 42px;
    padding: 9px 12px;
    border-radius: 10px;
}

.filters-search,
.filters-brand {
    min-width: 0;
}

.filters-toggle,
.filters-clear {
    min-height: 42px;
    padding: 9px 13px;
}

.filters-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.filters-toggle.has-active-filters {
    background: var(--primary-soft);
    border-color: #bfdbfe;
    color: var(--primary);
}

.active-filter-count {
    min-width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    padding: 0 6px;
    background: var(--primary);
    border-radius: 999px;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    line-height: 1;
}

.filters-clear {
    background: #fff;
}

.filters-clear:disabled {
    opacity: 0.45;
    background: var(--surface-soft);
}

.filters-summary[hidden],
.filters-panel[hidden] {
    display: none !important;
}

.filters-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-top: 11px;
}

.filter-chip {
    max-width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 3px 4px 3px 10px;
    background: var(--primary-soft);
    border: 1px solid #bfdbfe;
    border-radius: 999px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
}

.filter-chip-label {
    min-width: 0;
    overflow-wrap: anywhere;
}

.filter-chip-remove {
    width: 24px;
    min-width: 24px;
    min-height: 24px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 50%;
    color: currentColor;
    font-size: 17px;
    line-height: 1;
}

.filter-chip-remove:hover {
    background: rgba(29, 78, 216, 0.1);
    box-shadow: none;
    transform: none;
}

.filters-panel {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.7fr);
    align-items: end;
    gap: 14px;
    margin-top: 13px;
    padding: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.filters-category {
    min-width: 0;
}

.status-filter-group {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.status-filter-group legend {
    margin-bottom: 5px;
    padding: 0;
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 800;
}

.status-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.filters-panel .filter-check {
    min-height: 40px;
    padding: 7px 10px;
    background: #fff;
    border-color: var(--border-strong);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.filters-panel .filter-check.active {
    background: var(--primary-soft);
    border-color: #93c5fd;
}

.filters-panel .filter-check.active label {
    color: var(--primary);
}

.filters-panel .filter-check:focus-within {
    border-color: rgba(29, 78, 216, 0.72);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.products-card .selection-bar {
    margin-bottom: 12px;
}

.list-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.list-meta {
    margin-top: 0;
    margin-bottom: 12px;
}

.danger-zone {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.danger-zone-action {
    background: #fff;
    border: 1px solid #fecaca;
    color: var(--danger);
}

.danger-zone-action:hover {
    background: var(--danger-soft);
}

@media (max-width: 850px) {
    .page-heading {
        align-items: flex-start;
    }

    .page-heading h1 {
        font-size: 27px;
    }

    .product-dialog {
        width: min(900px, calc(100vw - 24px));
    }

    .filters-card-header {
        flex-direction: column;
        gap: 11px;
    }

    .filter-metrics {
        width: 100%;
        justify-content: flex-start;
    }

    .filters-toolbar {
        grid-template-columns: minmax(0, 1fr) minmax(190px, 0.65fr) auto auto;
    }

    .filters-panel {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
}

@media (max-width: 700px) {
    .page-heading {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 16px;
        border-radius: 16px;
    }

    .page-heading h1 {
        font-size: 24px;
    }

    .page-heading-action {
        width: 100%;
    }

    .page-message {
        margin-top: -4px;
    }

    .product-dialog {
        width: calc(100vw - 16px);
        max-width: none;
        max-height: calc(100vh - 16px);
        border-radius: 16px;
    }

    .product-dialog-shell {
        max-height: calc(100vh - 16px);
    }

    .product-dialog-header,
    .product-dialog-body,
    .product-dialog-footer {
        padding: 14px;
    }

    .product-dialog-header {
        align-items: flex-start;
    }

    .product-dialog-grid {
        grid-template-columns: 1fr !important;
        gap: 10px;
    }

    .product-dialog-notes {
        grid-column: auto;
    }

    .product-dialog-footer {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .product-dialog-footer button {
        width: 100%;
    }

    .filters-card {
        padding: 14px;
        border-radius: 14px;
    }

    .filters-card-header {
        margin-bottom: 12px;
    }

    .filter-metrics {
        gap: 5px 7px;
        padding: 7px 9px;
    }

    .filter-metric-separator {
        display: none;
    }

    .products-loading {
        flex-basis: 100%;
        margin-left: 0;
    }

    .filters-toolbar {
        grid-template-columns: 1fr 1fr;
        gap: 9px;
    }

    .filters-search,
    .filters-brand {
        grid-column: 1 / -1;
    }

    .filters-toggle,
    .filters-clear {
        width: 100%;
    }

    .filters-summary {
        gap: 6px;
    }

    .filter-chip {
        min-height: 32px;
    }

    .filters-panel {
        grid-template-columns: 1fr;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }

    .status-filter-pills {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filters-panel .filter-check {
        width: 100%;
        min-height: 44px;
        justify-content: flex-start;
    }

    .list-actions {
        display: grid;
        grid-template-columns: 1fr;
        justify-content: stretch;
    }

    .list-actions button,
    .danger-zone-action {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .products-loading::before {
        animation: none;
    }
}

@media (max-width: 420px) {
    .product-dialog {
        width: calc(100vw - 12px);
        max-height: calc(100vh - 12px);
        border-radius: 14px;
    }

    .product-dialog-shell {
        max-height: calc(100vh - 12px);
    }

    .product-dialog-header {
        gap: 10px;
    }

    .product-dialog-close {
        padding-left: 10px;
        padding-right: 10px;
    }

    .product-dialog-footer {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .topbar-brand {
        flex: 0 1 auto;
    }

    .products-card .selection-bar > div:first-child,
    .products-card .selection-tools {
        flex: 0 1 auto;
    }
}


/* Premium products table — phase 3 */

.premium-table-wrap {
    position: relative;
    padding: 8px;
    background:
        linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(241, 245, 249, 0.96));
    border-color: #dbe3ee;
    border-radius: 18px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.92),
        0 8px 24px rgba(15, 23, 42, 0.045);
    scrollbar-color: #cbd5e1 transparent;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    max-height: min(74vh, 820px);
    overflow: auto;
}

.premium-table-wrap::-webkit-scrollbar {
    height: 10px;
}

.premium-table-wrap::-webkit-scrollbar-track {
    background: transparent;
}

.premium-table-wrap::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.premium-table-wrap:focus-visible {
    outline: 3px solid rgba(29, 78, 216, 0.22);
    outline-offset: 3px;
}

.products-table-caption {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.products-table {
    width: 100%;
    min-width: 1120px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0 8px;
    background: transparent;
}

.products-table .product-col-select {
    width: 52px;
}

.products-table .product-col-main {
    width: 340px;
}

.products-table .product-col-category {
    width: 145px;
}

.products-table .product-col-format {
    width: 105px;
}

.products-table .product-col-price {
    width: 105px;
}

.products-table .product-col-stock {
    width: 125px;
}

.products-table .product-col-barcode {
    width: 150px;
}

.products-table .product-col-status {
    width: 145px;
}

.products-table .product-col-actions {
    width: 178px;
}

.products-table thead th {
    position: sticky;
    top: 0;
    z-index: 6;
    padding: 12px 13px;
    background: linear-gradient(180deg, #182235 0%, #111827 100%);
    border: 0;
    color: #dbe5f3;
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.075em;
    line-height: 1.2;
    text-transform: uppercase;
    white-space: nowrap;
}

.products-table thead th:first-child {
    border-radius: 12px 0 0 12px;
}

.products-table thead th:last-child {
    border-radius: 0 12px 12px 0;
}

.products-table .select-column,
.products-table .select-cell {
    text-align: center;
}

.products-table .actions-column {
    position: sticky;
    right: 0;
    z-index: 8;
    text-align: right;
    box-shadow: -14px 0 22px -22px rgba(15, 23, 42, 0.8);
}

.products-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

.products-table input[type="checkbox"]:focus-visible {
    outline: 3px solid rgba(29, 78, 216, 0.2);
    outline-offset: 3px;
}

.products-table .brand-group-row td {
    padding: 13px 6px 1px;
    background: transparent;
    border: 0;
    color: inherit;
    font-size: inherit;
    letter-spacing: normal;
    text-transform: none;
}

.products-table .brand-group-row:first-child td {
    padding-top: 2px;
}

.brand-group-heading {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.brand-group-heading::before {
    content: "";
    width: 24px;
    height: 3px;
    flex: 0 0 auto;
    background: linear-gradient(90deg, var(--primary), #0f766e);
    border-radius: 999px;
}

.brand-group-name {
    min-width: 0;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.brand-group-count {
    flex: 0 0 auto;
    padding: 3px 7px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    line-height: 1.2;
}

.products-table .product-row td {
    padding: 11px 13px;
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    color: var(--text-soft);
    transition:
        background 150ms ease,
        border-color 150ms ease,
        box-shadow 150ms ease,
        transform 150ms ease;
}

.products-table .product-row td:first-child {
    border-left: 1px solid #e2e8f0;
    border-radius: 13px 0 0 13px;
}

.products-table .product-row td:last-child {
    border-right: 1px solid #e2e8f0;
    border-radius: 0 13px 13px 0;
}

.products-table .product-row:hover td {
    background: #f8fbff;
    border-color: #bfdbfe;
}

.products-table .product-row:hover td:first-child {
    box-shadow: inset 3px 0 0 #93c5fd;
}

.products-table .product-row:focus-within td {
    background: #f8fbff;
    border-color: #93c5fd;
}

.products-table .product-row.is-selected td {
    background: #eff6ff;
    border-color: #93c5fd;
}

.products-table .product-row.is-selected td:first-child {
    box-shadow: inset 4px 0 0 var(--primary);
}

.product-main-cell {
    min-width: 0;
}

.product-identity {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 11px;
    align-items: center;
    min-width: 0;
}

.product-image-shell {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        radial-gradient(circle at 35% 25%, #fff 0%, #f8fafc 52%, #eef2f7 100%);
    border: 1px solid #dbe3ee;
    border-radius: 14px;
    box-shadow: 0 5px 14px rgba(15, 23, 42, 0.08);
}

.products-table .product-image {
    width: 100%;
    height: 100%;
    padding: 4px;
    object-fit: contain;
    background: transparent;
    border: 0;
    border-radius: 12px;
}

.product-copy {
    min-width: 0;
}

.product-brand {
    margin-bottom: 3px;
    overflow: hidden;
    color: var(--primary);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.095em;
    line-height: 1.2;
    text-overflow: ellipsis;
    text-transform: uppercase;
    white-space: nowrap;
}

.product-name {
    overflow: hidden;
    color: var(--text);
    font-size: 14px;
    font-weight: 900;
    letter-spacing: -0.015em;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-notes {
    display: -webkit-box;
    margin-top: 4px;
    overflow: hidden;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.product-notes-empty {
    color: var(--muted-light);
    font-style: italic;
}

.category-pill,
.stock-pill,
.table-price {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    max-width: 100%;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 850;
    line-height: 1.2;
}

.category-pill {
    overflow: hidden;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #334155;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.table-secondary-value {
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 750;
}

.table-price {
    background: var(--success-soft);
    border: 1px solid #bbf7d0;
    color: var(--success);
    font-size: 12px;
    font-weight: 950;
    white-space: nowrap;
}

.stock-pill {
    background: #fff;
    border: 1px solid #dbe3ee;
    color: #334155;
    white-space: normal;
}

.barcode-value {
    display: block;
    overflow: hidden;
    color: #475569;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.025em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.status-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.products-table .tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 24px;
    margin: 0;
    padding: 4px 7px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.025em;
    line-height: 1;
    white-space: nowrap;
}

.products-table .tag::before {
    content: "";
    width: 5px;
    height: 5px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: currentColor;
}

.products-table .tag-new {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.products-table .tag-promo {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #be123c;
}

.products-table .tag-stock {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #047857;
}

.products-table .tag-selective {
    background: #f5f3ff;
    border-color: #ddd6fe;
    color: #6d28d9;
}

.status-empty {
    color: var(--muted-light);
    font-size: 12px;
}

.actions-cell {
    position: sticky;
    right: 0;
    z-index: 3;
    text-align: right;
    box-shadow: -14px 0 22px -22px rgba(15, 23, 42, 0.75);
}

.products-table .table-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
}

.table-action-button {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 9px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: #fff;
    font-size: 11px;
    font-weight: 850;
    line-height: 1;
    transform: none;
    box-shadow: none;
}

.table-action-button svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    fill: currentColor;
}

.table-action-edit {
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.table-action-edit:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    transform: none;
    box-shadow: none;
}

.table-action-delete {
    border-color: #fecaca;
    color: #b91c1c;
}

.table-action-delete:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    transform: none;
    box-shadow: none;
}

.table-action-button:focus-visible {
    outline: 3px solid rgba(29, 78, 216, 0.18);
    outline-offset: 2px;
}

.products-table .empty {
    padding: 34px;
    background: #fff;
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    font-style: normal;
}

.empty-state {
    display: grid;
    justify-items: center;
    gap: 5px;
    color: var(--muted);
    text-align: center;
}

.empty-state-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    margin-bottom: 3px;
    background: var(--primary-soft);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    color: var(--primary);
    font-size: 22px;
    font-style: normal;
}

.empty-state strong {
    color: var(--text);
    font-size: 14px;
}

.empty-state span {
    font-size: 12px;
}

@media (max-width: 1100px) {
    .products-table {
        min-width: 1020px;
    }

    .products-table .product-col-main {
        width: 300px;
    }

    .products-table .product-col-actions {
        width: 166px;
    }
}

@media (max-width: 700px) {
    .premium-table-wrap {
        max-height: none;
        padding: 0;
        overflow: visible;
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        scrollbar-gutter: auto;
    }

    .products-table {
        min-width: 0;
        display: block;
        border-spacing: 0;
        table-layout: auto;
    }

    .products-table colgroup,
    .products-table thead {
        display: none;
    }

    .products-table tbody {
        display: grid;
        gap: 12px;
    }

    .products-table .brand-group-row {
        display: block;
        margin: 10px 0 -4px;
    }

    .products-table .brand-group-row:first-child {
        margin-top: 0;
    }

    .products-table .brand-group-row td {
        display: block;
        width: 100%;
        padding: 5px 2px;
        background: transparent;
        border: 0;
    }

    .brand-group-heading::before {
        width: 20px;
    }

    .brand-group-name {
        font-size: 11px;
    }

    .products-table .product-row {
        display: grid;
        grid-template-columns: 44px minmax(0, 1fr);
        grid-template-areas:
            "select product"
            "category category"
            "format format"
            "price stock"
            "barcode barcode"
            "status status"
            "actions actions";
        overflow: hidden;
        background: #fff;
        border: 1px solid #dbe3ee;
        border-radius: 16px;
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.065);
    }

    .products-table .product-row:hover,
    .products-table .product-row:focus-within {
        background: #fff;
    }

    .products-table .product-row.is-selected {
        background: #eff6ff;
        border-color: #93c5fd;
        box-shadow:
            0 0 0 2px rgba(29, 78, 216, 0.08),
            0 8px 24px rgba(15, 23, 42, 0.065);
    }

    .products-table .product-row td {
        position: static;
        display: block;
        width: auto;
        min-width: 0;
        padding: 10px 12px;
        background: transparent;
        border: 0;
        border-bottom: 1px solid #edf1f6;
        border-radius: 0;
        box-shadow: none;
        transform: none;
    }

    .products-table .product-row:hover td,
    .products-table .product-row:focus-within td,
    .products-table .product-row.is-selected td {
        background: transparent;
        border-color: #edf1f6;
    }

    .products-table .select-cell {
        grid-area: select;
        display: grid;
        place-items: center;
        padding: 10px 5px;
        border-right: 1px solid #edf1f6;
    }

    .products-table .product-main-cell {
        grid-area: product;
        padding-left: 10px;
    }

    .product-identity {
        grid-template-columns: 50px minmax(0, 1fr);
        gap: 10px;
    }

    .product-image-shell {
        width: 50px;
        height: 50px;
        border-radius: 12px;
    }

    .product-name {
        font-size: 13px;
        white-space: normal;
    }

    .product-notes {
        font-size: 10px;
    }

    .category-cell {
        grid-area: category;
    }

    .format-cell {
        grid-area: format;
    }

    .price-cell {
        grid-area: price;
        border-right: 1px solid #edf1f6 !important;
    }

    .stock-cell {
        grid-area: stock;
    }

    .barcode-cell {
        grid-area: barcode;
    }

    .status-cell {
        grid-area: status;
    }

    .actions-cell {
        grid-area: actions;
        position: static;
        border-bottom: 0 !important;
        box-shadow: none;
    }

    .products-table .product-row td[data-label] {
        display: grid;
        grid-template-columns: minmax(84px, 0.4fr) minmax(0, 1fr);
        align-items: center;
        gap: 10px;
    }

    .products-table .product-row td[data-label]::before {
        content: attr(data-label) !important;
        display: block !important;
        color: #64748b;
        font-size: 10px;
        font-weight: 900;
        letter-spacing: 0.055em;
        text-transform: uppercase;
    }

    .products-table .product-row .price-cell,
    .products-table .product-row .stock-cell {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
    }

    .products-table .product-row .price-cell::before,
    .products-table .product-row .stock-cell::before {
        flex: 0 0 auto;
    }

    .category-pill,
    .table-secondary-value,
    .table-price,
    .stock-pill,
    .barcode-value,
    .status-list {
        justify-self: start;
    }

    .products-table .table-actions {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .table-action-button {
        min-height: 40px;
        font-size: 11px;
    }

    .products-table .empty {
        display: block;
        padding: 32px 14px;
        background: #fff;
        border: 1px dashed #cbd5e1;
        border-radius: 16px;
    }
}

@media (max-width: 420px) {
    .products-table .product-row {
        grid-template-columns: 40px minmax(0, 1fr);
        border-radius: 14px;
    }

    .products-table .product-row td {
        padding: 9px 10px;
    }

    .products-table .product-row td[data-label] {
        grid-template-columns: 76px minmax(0, 1fr);
        gap: 8px;
    }

    .product-identity {
        grid-template-columns: 46px minmax(0, 1fr);
    }

    .product-image-shell {
        width: 46px;
        height: 46px;
    }

    .brand-group-count {
        display: none;
    }

    .products-table .table-actions {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .products-table .product-row td,
    .table-action-button {
        transition: none;
    }
}
