@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --pf-primary: #4f46e5;
    --pf-primary-strong: #4338ca;
    --pf-success: #10b981;
    --pf-success-strong: #047857;
    --pf-danger: #ef4444;
    --pf-danger-strong: #b91c1c;
    --pf-warning: #f59e0b;
    --pf-bg: #f6f8fc;
    --pf-surface: #ffffff;
    --pf-surface-soft: #f8fafc;
    --pf-border: #dbe2ea;
    --pf-border-strong: #c4d0dc;
    --pf-text: #0f172a;
    --pf-text-soft: #475569;
    --pf-muted: #7b8796;
    --pf-shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
    --pf-shadow-md: 0 8px 20px rgba(15, 23, 42, 0.10);
    --pf-shadow-lg: 0 18px 42px rgba(15, 23, 42, 0.16);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--pf-text);
    background:
        radial-gradient(1000px 480px at 0% -10%, rgba(14, 165, 233, 0.12), transparent 55%),
        radial-gradient(900px 420px at 100% 0%, rgba(99, 102, 241, 0.10), transparent 50%),
        var(--pf-bg);
}

.content,
.table-container {
    max-width: 96%;
    margin: 16px auto;
}

h1,
h2,
h3 {
    color: var(--pf-text);
}

h1 {
    text-align: center;
    margin: 14px 0 12px;
    font-size: 1.9rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

h2 {
    margin-bottom: 12px;
    font-size: 1.35rem;
    font-weight: 700;
}

/* User bar */
.user-container {
    max-width: 1300px;
    margin: 16px auto;
    padding: 0 12px;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: linear-gradient(135deg, #ffffff, #f4f7ff 65%, #eef2ff);
    border: 1px solid var(--pf-border);
    border-radius: 12px;
    box-shadow: var(--pf-shadow-sm);
    font-weight: 600;
}

.online-indicator {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45);
    animation: onlinePulse 1.8s infinite;
}

@keyframes onlinePulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.45); }
    70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.role-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    color: #fff;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.role-Entreprise, .role-entreprise { background: linear-gradient(135deg, #dc2626, #991b1b); }
.role-Dirigeant, .role-dirigeant { background: linear-gradient(135deg, #ea580c, #c2410c); }
.role-Lieutenant, .role-lieutenant { background: linear-gradient(135deg, #7c3aed, #5b21b6); }
.role-Responsable, .role-responsable { background: linear-gradient(135deg, #0ea5e9, #0369a1); }
.role-Vendeur, .role-vendeur { background: linear-gradient(135deg, #2563eb, #1e3a8a); }
.role-Livreur, .role-livreur { background: linear-gradient(135deg, #16a34a, #166534); }
.role-Guetteur, .role-guetteur { background: linear-gradient(135deg, #f59e0b, #b45309); }
.role-Préparateur, .role-préparateur, .role-Preparateur, .role-preparateur { background: linear-gradient(135deg, #6366f1, #4338ca); }
.role-Ravitailleur, .role-ravitailleur { background: linear-gradient(135deg, #d946ef, #a21caf); }
.role-Standartdiste, .role-standartdiste { background: linear-gradient(135deg, #475569, #334155); }

.logout-link {
    text-decoration: none;
    color: #b91c1c;
    border: 1px solid #fecaca;
    background: #fff5f5;
    border-radius: 8px;
    padding: 5px 10px;
    font-weight: 700;
}

.logout-link:hover {
    background: #fee2e2;
}

/* Info messages */
.success-message,
.error-message,
.solde-info,
.count-info {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
    border: 1px solid var(--pf-border);
    box-shadow: var(--pf-shadow-sm);
    font-weight: 600;
}

.success-message {
    background: #ecfdf5;
    color: #166534;
    border-color: #bbf7d0;
}

.error-message {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.solde-info {
    background: #eff6ff;
    color: #1e3a8a;
    border-color: #bfdbfe;
}

.count-info {
    background: #f8fafc;
    color: #334155;
}

/* Top filter */
.filtre-container {
    margin: 8px auto 18px;
    max-width: 370px;
    padding: 12px 14px;
    border: 1px solid var(--pf-border);
    border-radius: 12px;
    background: linear-gradient(135deg, #ffffff, #f8fafc 65%, #eef2ff);
    box-shadow: var(--pf-shadow-sm);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.filtre-container form,
.filtre-container .filtre-form {
    margin: 0;
}

.filtre-container::before {
    content: "Filtre";
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: #334155;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e2e8f0;
}

.filtre-container select#type_produit,
.filtre-container select[name="type_produit"] {
    appearance: none;
    min-width: 170px;
    padding: 9px 34px 9px 12px;
    border: 1px solid var(--pf-border-strong);
    border-radius: 9px;
    background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%23475569' d='M6 8L0 0h12z'/></svg>") no-repeat right 10px center;
    color: var(--pf-text);
    font-weight: 700;
}

.filtre-container select#type_produit:focus,
.filtre-container select[name="type_produit"]:focus {
    outline: none;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

/* Card table wrapper */
.table-container {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    padding: 12px;
    overflow-x: auto;
}

.table-container > h2 {
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    border-radius: 10px;
    color: #0f172a;
    font-size: 19px;
    font-weight: 700;
}

/* Filter bar inside sales tables */
.table-filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}

.table-filter-group {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.table-filter-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 700;
    color: var(--pf-muted);
}

.table-filter-matiere-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    background: #ffffff;
}

.table-filter-matiere-form .table-filter-label {
    color: #1e3a8a;
    font-weight: 800;
}

.table-filter-search,
.table-filter-from,
.table-filter-to,
.table-filter-sort,
.table-filter-matiere {
    border: 1px solid var(--pf-border-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--pf-text);
    padding: 8px 10px;
    font-size: 13px;
}

.table-filter-matiere {
    min-width: 280px;
    max-width: min(52vw, 420px);
    font-weight: 700;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23334155' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.table-filter-matiere:hover {
    border-color: #93c5fd;
    background-color: #f8fbff;
}

.table-filter-matiere option {
    font-weight: 600;
}

.table-filter-matiere.table-filter-native-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    pointer-events: none !important;
}

.matiere-dropdown {
    position: relative;
    min-width: 280px;
    max-width: min(52vw, 420px);
}

.matiere-dropdown-trigger {
    width: 100%;
    border: 1px solid var(--pf-border-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--pf-text);
    padding: 9px 34px 9px 10px;
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    position: relative;
}

.matiere-dropdown-trigger::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid #334155;
    border-bottom: 2px solid #334155;
    transform: translateY(-60%) rotate(45deg);
    transition: transform .15s ease;
}

.matiere-dropdown.open .matiere-dropdown-trigger {
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
}

.matiere-dropdown.open .matiere-dropdown-trigger::after {
    transform: translateY(-35%) rotate(-135deg);
}

.matiere-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 1200;
    background: #fff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    display: none;
}

.matiere-dropdown.open .matiere-dropdown-menu {
    display: block;
}

.matiere-dropdown-option {
    width: 100%;
    border: none;
    background: transparent;
    border-radius: 8px;
    padding: 9px 10px;
    text-align: left;
    font-size: 13px;
    color: #0f172a;
    cursor: pointer;
}

.matiere-dropdown-option:hover {
    background: #eff6ff;
}

.matiere-dropdown-option.is-active {
    background: #dbeafe;
    color: #1e3a8a;
    font-weight: 800;
}

.table-filter-search {
    min-width: 230px;
}

.table-filter-search:focus,
.table-filter-from:focus,
.table-filter-to:focus,
.table-filter-sort:focus,
.table-filter-matiere:focus {
    outline: none;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
}

.table-filter-sep {
    font-weight: 700;
    color: var(--pf-muted);
}

.table-filter-clear {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #0f172a;
    border-radius: 9px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
}

.table-filter-clear:hover {
    background: #f1f5f9;
}

.table-filter-count {
    margin-left: auto;
    padding: 6px 10px;
    border-radius: 999px;
    background: #e0e7ff;
    color: #312e81;
    font-size: 12px;
    font-weight: 800;
}

/* Base table */
.table-container table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-container thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.table-container th,
.table-container td {
    padding: 13px 16px;
    min-width: 140px;
    vertical-align: middle;
    text-align: center;
}

.table-container th {
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%) !important;
    color: #0f172a;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.45px;
    font-weight: 700;
}

.table-container td {
    color: #1e293b;
    border-bottom: 1px solid #edf2f7;
}

.table-container tbody tr:nth-child(even) {
    background: #fbfcfe;
}

.table-container tbody tr:hover {
    background: #f2f6ff;
}

.table-container tbody tr.produit-vendu {
    background: #f5fcf7 !important;
}

.table-container tbody tr.produit-vendu:hover {
    background: #ecf9f1 !important;
}

.table-container tbody tr.produit-credit {
    background: #fffdf5 !important;
}

.table-container tbody tr.produit-credit:hover {
    background: #fff8e6 !important;
}

.table-container tbody tr.produit-non-vendu {
    background: #fdf7f8 !important;
}

.table-container tbody tr.produit-non-vendu:hover {
    background: #fbeff1 !important;
}

/* Keep required column lengths */
.table-container th.col-id,
.table-container td.col-id {
    width: 56px !important;
    min-width: 56px !important;
    max-width: 72px !important;
    padding: 4px 6px !important;
    white-space: nowrap;
}

.table-container th.col-id.id-sortable,
.table-container th.col-categorie.cat-sortable,
.table-container th.col-reference.ref-sortable,
.table-container th.col-proprietaire.owner-sortable,
.table-container th.col-date-ajout.date-sortable,
.table-container th.col-heure-ajout.heure-sortable {
    cursor: pointer;
    user-select: none;
}

.table-container th .sort-arrow {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    color: #64748b;
    transition: color .15s ease;
}

.table-container th.col-id.id-sortable.sort-asc .sort-arrow,
.table-container th.col-id.id-sortable.sort-desc .sort-arrow,
.table-container th.col-categorie.cat-sortable.sort-asc .sort-arrow,
.table-container th.col-categorie.cat-sortable.sort-desc .sort-arrow,
.table-container th.col-reference.ref-sortable.sort-asc .sort-arrow,
.table-container th.col-reference.ref-sortable.sort-desc .sort-arrow,
.table-container th.col-proprietaire.owner-sortable.sort-asc .sort-arrow,
.table-container th.col-proprietaire.owner-sortable.sort-desc .sort-arrow,
.table-container th.col-date-ajout.date-sortable.sort-asc .sort-arrow,
.table-container th.col-date-ajout.date-sortable.sort-desc .sort-arrow,
.table-container th.col-heure-ajout.heure-sortable.sort-asc .sort-arrow,
.table-container th.col-heure-ajout.heure-sortable.sort-desc .sort-arrow {
    color: #1e3a8a;
}

.table-container table td:first-child:not(.matiere-side-cell) {
    width: 72px !important;
    min-width: 72px !important;
    max-width: 72px !important;
    padding: 4px 8px !important;
    white-space: nowrap !important;
}

.table-container table th:first-child:not(.matiere-side-heading) {
    width: 190px !important;
    min-width: 190px !important;
    max-width: 220px !important;
    padding: 8px 10px !important;
    white-space: nowrap !important;
    text-align: left !important;
    font-size: 12px;
    letter-spacing: 0.2px;
}

.table-container table th:first-child input[type="checkbox"] {
    margin-right: 8px;
    vertical-align: middle;
}

.table-container td.client-column {
    min-width: 220px;
    max-width: 400px;
    font-weight: 700;
}

.table-container td.lieu-column {
    min-width: 200px;
    max-width: 350px;
}

.table-container td.produit-column,
.table-container th.produit-column {
    min-width: 320px !important;
    max-width: 600px;
}

.table-container td.produit-column {
    text-align: left;
}

.table-container td.description-column,
.table-container th.description-column,
.table-container table td:nth-child(14),
.table-container table th:nth-child(14) {
    min-width: 400px !important;
    max-width: 700px !important;
    white-space: normal !important;
    word-break: break-word !important;
}

.table-container th.col-categorie-produit,
.table-container td.col-categorie-produit {
    min-width: 480px !important;
    max-width: 1200px !important;
    white-space: normal !important;
    word-break: break-word !important;
    text-align: left !important;
}

.table-container th.col-reference-produit,
.table-container td.col-reference-produit {
    min-width: 380px !important;
    max-width: 900px !important;
    white-space: nowrap !important;
}

.table-container th.col-proprietaire-produit,
.table-container td.col-proprietaire-produit {
    min-width: 360px !important;
    max-width: 900px !important;
    white-space: normal !important;
    word-break: break-word !important;
    text-align: left !important;
}

.table-container th.commentaire-livraison,
.table-container td.commentaire-livraison {
    min-width: 160px !important;
    max-width: 260px !important;
    width: 200px !important;
    white-space: normal !important;
}

.table-container th.type-produit,
.table-container td.type-produit {
    min-width: 80px !important;
    max-width: 120px !important;
    width: 100px !important;
    white-space: nowrap !important;
}

.table-container th.moyenne-note-client,
.table-container td.moyenne-note-client {
    min-width: 60px !important;
    max-width: 90px !important;
    width: 70px !important;
    white-space: nowrap !important;
}

/* keep hidden vente columns in produit table */
.table-produit .client-column,
.table-produit .lieu-column,
.table-produit .date-livraison,
.table-produit .prix-vente-livraison,
.table-produit .kilometre-livraison,
.table-produit .note-client-livraison,
.table-produit .note-livraison,
.table-produit .commentaire-livraison {
    display: none !important;
}

.client-link,
.lieu-link {
    text-decoration: none;
    font-weight: 700;
}

.client-link {
    color: #1d4ed8;
}

.lieu-link {
    color: #0f766e;
}

.client-link:hover,
.lieu-link:hover {
    text-decoration: underline;
}

/* Truncated cell controls */
.cell-with-truncated-text {
    text-align: left;
}

.cell-text-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.cell-text-truncated {
    word-break: break-word;
}

.cell-toggle-btn {
    flex-shrink: 0;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    border-radius: 7px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.cell-toggle-btn:hover {
    background: #eef2ff;
    border-color: #a5b4fc;
}

/* Stars in table */
.table-star {
    color: #cbd5e1;
    font-size: 16px;
}

.table-star.filled {
    color: #f59e0b;
}

/* action column */
.table-container th.actions-cell,
.table-container td.actions-cell {
    min-width: 500px;
    max-width: 500px;
    width: 500px;
    white-space: nowrap;
    overflow: visible;
    position: relative;
    z-index: 20;
}

.action-btns,
.action-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 8px;
}

.edit-buttons {
    display: none;
    gap: 8px;
    margin-top: 6px;
    justify-content: center;
}

tr.edit-mode {
    background: #fff7ed !important;
    box-shadow: inset 0 0 0 2px #fdba74;
}

tr.edit-mode .action-buttons {
    display: none;
}

tr.edit-mode .edit-buttons {
    display: flex;
}

.btn-action,
.btn-modal,
.btn-primary,
.btn-danger,
.btn-secondary,
.btn-confirm,
.btn-cancel,
.btn-vendre,
.btn-credit,
.btn-delete-bulk,
.btn-transfer-bulk,
.btn-credit-validate,
.btn-annuler-credit,
.btn-annuler-vente,
.btn-show-all-products,
.btn-sort,
.dropdown-toggle,
.transfer-option,
.table-filter-clear {
    transition: all 0.18s ease;
}

.btn-action {
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
}

.btn-edit { background: linear-gradient(135deg, #f59e0b, #d97706); }
.btn-delete { background: linear-gradient(135deg, #ef4444, #dc2626); }
.btn-save-edit { background: linear-gradient(135deg, #10b981, #059669); }
.btn-cancel-edit { background: linear-gradient(135deg, #64748b, #475569); }

.btn-edit:hover,
.btn-delete:hover,
.btn-save-edit:hover,
.btn-cancel-edit:hover,
.btn-vendre:hover,
.btn-credit:hover,
.btn-delete-bulk:hover,
.btn-transfer-bulk:hover,
.btn-credit-validate:hover,
.btn-annuler-credit:hover,
.btn-annuler-vente:hover,
.btn-danger:hover,
.btn-primary:hover,
.btn-confirm:hover {
    transform: translateY(-1px);
    filter: brightness(0.95);
}

.btn-danger {
    border: 1px solid #ef4444;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: #ffffff;
    font-weight: 800;
    border-radius: 8px;
    padding: 9px 14px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.28);
}

.btn-danger:hover {
    box-shadow: 0 10px 22px rgba(220, 38, 38, 0.34);
}

.btn-danger:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.22), 0 6px 16px rgba(220, 38, 38, 0.28);
}

.btn-annuler-vente {
    border: 1px solid #fca5a5;
    background: #fff1f2;
    color: #b91c1c;
    font-weight: 800;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
}

.btn-credit-validate {
    border: 1px solid #86efac;
    background: #ecfdf5;
    color: #166534;
    font-weight: 800;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
}

.btn-annuler-credit {
    border: 1px solid #fed7aa;
    background: #fff7ed;
    color: #9a3412;
    font-weight: 800;
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
}

.btn-show-all-products {
    margin: 10px auto 0;
    border: 1px solid var(--pf-border-strong);
    background: #fff;
    color: var(--pf-text);
    border-radius: 9px;
    font-weight: 700;
    padding: 8px 12px;
    cursor: pointer;
}

.btn-show-all-products:hover {
    background: #f1f5f9;
}

.table-row-hidden {
    display: none !important;
}

/* Transfer dropdown */
.transfer-dropdown {
    position: relative;
    z-index: 9;
}

.transfer-row-open {
    position: relative;
    z-index: 1200 !important;
}

.transfer-cell-open {
    position: relative;
    z-index: 1300 !important;
}

.btn-transfer {
    border: 1px solid #ddd6fe;
    border-radius: 10px;
    padding: 8px 12px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.2px;
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(91, 33, 182, 0.26);
}

.btn-transfer::after {
    content: ' ▾';
    font-size: 12px;
    display: inline-block;
    transition: transform 0.18s ease;
}

.transfer-dropdown.active .btn-transfer::after {
    transform: rotate(180deg);
}

.transfer-menu {
    display: block;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 260px;
    max-width: 320px;
    max-height: 330px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border: 1px solid #ddd6fe;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff 0%, #faf8ff 100%);
    box-shadow: 0 16px 40px rgba(76, 29, 149, 0.24), 0 4px 12px rgba(15, 23, 42, 0.12);
    padding: 8px;
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
}

.transfer-dropdown.active .transfer-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.transfer-dropdown.align-left .transfer-menu {
    left: 0;
    right: auto;
    transform-origin: top left;
}

.transfer-menu::before {
    content: 'Nouveau propriétaire';
    display: block;
    margin: 2px 2px 8px;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid #e9d5ff;
    background: #f5f3ff;
    color: #5b21b6;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.transfer-option {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    border: 1px solid #ede9fe;
    background: #ffffff;
    color: #312e81;
    border-radius: 9px;
    text-align: left;
    padding: 10px 11px;
    margin: 0;
    cursor: pointer;
    font-weight: 700;
    position: relative;
    padding-right: 28px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.transfer-option::after {
    content: '→';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%) translateX(4px);
    opacity: 0;
    transition: all 0.16s ease;
}

.transfer-option:hover {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    color: #4c1d95;
    border-color: #c4b5fd;
    transform: translateX(2px);
}

.transfer-option:hover::after,
.transfer-option:focus-visible::after {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

.transfer-option:focus-visible {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.18);
}

.transfer-menu::-webkit-scrollbar {
    width: 8px;
}

.transfer-menu::-webkit-scrollbar-thumb {
    background: #c4b5fd;
    border-radius: 999px;
}

.transfer-menu::-webkit-scrollbar-track {
    background: #f5f3ff;
}

/* Bulk section */
.bulk-action-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding: 12px;
    border-radius: 11px;
    border: 1px solid var(--pf-border);
    background: #f8fafc;
    position: relative;
    z-index: 20;
    overflow: visible;
}

.client-select-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: visible;
}

.select-lieu-client,
.client-filter-input {
    border: 1px solid var(--pf-border-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--pf-text);
    padding: 8px 10px;
    font-size: 14px;
}

.select-lieu-client {
    min-width: 230px;
}

.select-lieu-client:focus,
.client-filter-input:focus {
    outline: none;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
}

.btn-vendre,
.btn-credit,
.btn-delete-bulk,
.btn-transfer-bulk,
.btn-primary,
.btn-confirm {
    border: none;
    border-radius: 9px;
    color: #fff;
    font-weight: 800;
    padding: 9px 13px;
    cursor: pointer;
}

.btn-vendre,
.btn-primary {
    background: linear-gradient(135deg, var(--pf-primary), #6366f1);
}

.btn-credit {
    background: linear-gradient(135deg, #10b981, #059669);
}

.btn-delete-bulk,
.btn-confirm {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn-transfer-bulk {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.btn-secondary,
.btn-cancel {
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #fff;
    color: #334155;
    font-weight: 700;
    padding: 9px 13px;
    cursor: pointer;
}

.btn-secondary:hover,
.btn-cancel:hover,
.btn-sort:hover {
    background: #f1f5f9;
}

.btn-sort {
    border: 1px solid var(--pf-border);
    background: #fff;
    color: #475569;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    padding: 7px 10px;
    cursor: pointer;
}

/* Custom dropdown widget */
.custom-client-dropdown {
    position: relative;
    display: inline-block;
    min-width: 320px;
    z-index: 50;
}

.custom-client-dropdown .dropdown-toggle {
    width: 100%;
    text-align: left;
    border: 1px solid var(--pf-border-strong);
    background: #fff;
    border-radius: 8px;
    padding: 9px 12px;
    font-weight: 700;
    color: var(--pf-text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.custom-client-dropdown .caret {
    color: var(--pf-muted);
    flex: 0 0 auto;
    font-size: 11px;
}

.custom-client-dropdown .dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    border: 1px solid var(--pf-border);
    background: #fff;
    border-radius: 10px;
    box-shadow: var(--pf-shadow-lg);
    z-index: 500;
    overflow: hidden;
}

.custom-client-dropdown .panel-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #eef2f7;
}

.custom-client-dropdown .client-panel-search {
    flex: 1;
}

.custom-client-dropdown .dropdown-list {
    list-style: none;
    margin: 0;
    padding: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.custom-client-dropdown .dropdown-item {
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    color: #334155;
}

.custom-client-dropdown .dropdown-item:hover {
    background: #eef2ff;
    color: #312e81;
}

.custom-client-dropdown .selected {
    background: #ecfeff;
    color: #155e75;
}

/* Toggle columns */
.cout-achat-toggle,
.nom-mp-toggle,
.quantite-toggle,
.prix-vente-mp-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    border-radius: 7px;
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.cout-achat-toggle:hover,
.nom-mp-toggle:hover,
.quantite-toggle:hover,
.prix-vente-mp-toggle:hover,
.cout-achat-toggle.expanded,
.nom-mp-toggle.expanded,
.quantite-toggle.expanded,
.prix-vente-mp-toggle.expanded {
    background: #dbeafe;
}

.cout-achat-column,
.nom-mp-column,
.quantite-column,
.prix-vente-mp-column {
    display: none !important;
    white-space: normal !important;
}

.cout-achat-column.visible,
.nom-mp-column.visible,
.quantite-column.visible,
.prix-vente-mp-column.visible {
    display: table-cell !important;
}

th.cout-achat-column.visible,
th.nom-mp-column.visible,
th.quantite-column.visible,
th.prix-vente-mp-column.visible {
    background: #e0f2fe !important;
}

/* Image */
.product-image-thumbnail,
.image-preview {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #dbe2ea;
    box-shadow: var(--pf-shadow-sm);
}

.image-preview:hover,
.product-image-thumbnail:hover {
    transform: scale(1.06);
}

/* Group row */
.table-container .matiere-group-row td {
    background: linear-gradient(90deg, rgba(14, 165, 233, 0.10), rgba(99, 102, 241, 0.10));
    border-top: 1px solid #c7d2fe;
    border-bottom: 1px solid #cbd5e1;
    padding: 12px 14px;
}

.table-container .matiere-group-title {
    font-weight: 800;
    color: #1e3a8a;
    margin-bottom: 6px;
}

.table-container .matiere-group-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.table-container .matiere-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 999px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 700;
    color: #334155;
}

.table-container th.matiere-side-heading,
.table-container td.matiere-side-cell {
    width: 14px !important;
    min-width: 14px !important;
    max-width: 14px !important;
    padding: 0 !important;
    text-align: center;
    vertical-align: middle;
    overflow: hidden;
}

.table-container th.matiere-side-heading {
    background: #dbeafe !important;
    border-right: 2px solid #bfdbfe;
}

.table-container th.matiere-side-heading span {
    display: inline-block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 9px;
    line-height: 1;
    letter-spacing: 0;
    font-weight: 800;
    color: #1e3a8a;
}

.table-container td.matiere-side-cell {
    background: linear-gradient(180deg, #eff6ff 0%, #eef2ff 100%);
    border-right: 2px solid #c7d2fe;
}

.table-container .matiere-side-stack {
    height: 100%;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.table-container .matiere-side-name {
    display: inline-block;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    text-align: center;
    font-size: 12px;
    line-height: 1;
    font-weight: 800;
    color: #1e3a8a;
    letter-spacing: 0;
}

/* Generic modals */
.modal,
.modal-detail,
.modal-modifier,
.cm-modal {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.58);
    backdrop-filter: blur(4px);
    z-index: 10000;
}

.modal-content,
.modal-detail-content,
.modal-modifier-content,
.cm-modal-content {
    position: relative;
    margin: 3.5% auto;
    width: min(95%, 980px);
    max-height: 88vh;
    overflow-y: auto;
    padding: 24px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--pf-border);
    box-shadow: var(--pf-shadow-lg);
}

.modal-modifier {
    align-items: center;
    justify-content: center;
}

.modal-modifier-content {
    width: min(92%, 740px);
    margin: 0 auto;
}

.modal-content h3,
.modal-detail-content h2,
.modifier-header-modal h2,
.cm-modal-content h3 {
    margin-bottom: 12px;
    color: var(--pf-text);
}

.close,
.close-detail,
.close-modifier,
.modal-content .close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.close:hover,
.close-detail:hover,
.close-modifier:hover,
.modal-content .close:hover {
    color: #b91c1c;
    background: #fee2e2;
}

.modal-buttons,
.form-actions-modal,
.cm-modal-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
}

.detail-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    padding: 10px;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-item strong {
    display: block;
    margin-bottom: 5px;
    color: #475569;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-item input[type="text"],
.detail-item textarea,
.form-group-modal textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 14px;
    background: #fff;
}

.detail-item input[type="text"]:focus,
.detail-item textarea:focus,
.form-group-modal textarea:focus {
    outline: none;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
}

.detail-item img,
.image-preview-modal,
.detail-image {
    max-width: 220px;
    max-height: 220px;
    border-radius: 10px;
    border: 1px solid #dbe2ea;
}

.message-modal {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-weight: 600;
}

.success-modal { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; }
.error-modal { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.info-badge-modal {
    display: inline-flex;
    align-items: center;
    padding: 5px 9px;
    border-radius: 999px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e3a8a;
    font-size: 12px;
    font-weight: 700;
}

.file-input-wrapper-modal input[type="file"] {
    display: none;
}

.file-label-modal {
    display: inline-flex;
    align-items: center;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--pf-primary), #6366f1);
    color: #fff;
    font-weight: 700;
    padding: 9px 12px;
    cursor: pointer;
}

.file-label-modal:hover {
    filter: brightness(0.95);
}

/* image modal */
#imageModal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10100;
    background: rgba(0, 0, 0, 0.86);
}

.modal-image {
    display: block;
    margin: 50px auto;
    max-width: 92%;
    max-height: 84vh;
    border-radius: 10px;
    box-shadow: var(--pf-shadow-lg);
}

/* Livraison / crédit modal */
.livraison-title {
    text-align: center;
    font-size: 1.65rem;
    font-weight: 800;
    color: #334155;
    margin-bottom: 18px;
}

.livraison-title::after {
    content: "";
    display: block;
    margin: 10px auto 0;
    width: 70px;
    height: 2px;
    border-radius: 999px;
    background: #cbd5e1;
}

.form-livraison {
    max-width: 720px;
    margin: 0 auto;
    padding: 28px;
    border-radius: 14px;
    border: 1px solid var(--pf-border);
    background: #fff;
    box-shadow: var(--pf-shadow-md);
}

.form-livraison .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 16px;
}

.form-livraison label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #334155;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.form-livraison > label {
    margin-top: 16px;
}

.form-livraison input,
.form-livraison select,
.form-livraison textarea {
    width: 100%;
    border: 1px solid var(--pf-border-strong);
    border-radius: 9px;
    background: #fff;
    color: var(--pf-text);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 12px;
}

.form-livraison textarea {
    min-height: 92px;
    resize: vertical;
}

.form-livraison input:focus,
.form-livraison select:focus,
.form-livraison textarea:focus,
.form-livraison .prix-vente-input:focus {
    outline: none;
    border-color: var(--pf-primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
}

.form-livraison .star-rating {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--pf-border-strong);
    border-radius: 9px;
    background: #fff;
}

.form-livraison .star {
    font-size: 1.25rem;
    color: #cbd5e1;
    user-select: none;
}

.form-livraison .star.filled {
    color: #f59e0b;
}

.form-livraison .prix-vente-wrapper {
    margin: 16px 0;
}

.form-livraison .prix-vente-title {
    margin-bottom: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #334155;
    font-weight: 800;
}

.form-livraison .prix-vente-box {
    border: 1px solid var(--pf-border-strong);
    border-radius: 10px;
    background: #fff;
    padding: 10px;
}

.form-livraison .prix-vente-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 5px 0;
    border-bottom: 1px dashed #e2e8f0;
}

.form-livraison .prix-vente-item:last-child {
    border-bottom: none;
}

.form-livraison .prix-vente-label {
    font-weight: 700;
    color: #334155;
}

.form-livraison .prix-vente-value {
    position: relative;
    width: 136px;
    text-align: right;
}

.form-livraison .prix-vente-input {
    width: 100%;
    padding: 6px 26px 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    text-align: right;
    font-weight: 700;
}

.form-livraison .prix-vente-euro {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: #475569;
    font-weight: 700;
    pointer-events: none;
}

.form-livraison button {
    width: 100%;
    border: none;
    border-radius: 9px;
    padding: 12px 14px;
    margin-top: 10px;
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    background: linear-gradient(135deg, var(--pf-primary), #6366f1);
}

.form-livraison .btn-secondary {
    color: #334155;
    background: #fff;
    border: 1px solid #cbd5e1;
}

/* Transfer modal fine tune */
#transferModal .cm-modal-content {
    max-width: 520px;
}

#transferModal #transferModalMsg {
    color: var(--pf-text-soft);
}

/* Responsive */
@media (max-width: 1024px) {
    th,
    td {
        padding: 11px 12px;
        min-width: 120px;
    }

    .table-container th.actions-cell,
    .table-container td.actions-cell {
        min-width: 430px;
        max-width: 430px;
        width: 430px;
    }
}

@media (max-width: 860px) {
    .table-filter-count {
        margin-left: 0;
    }

    .table-filter-search {
        min-width: 180px;
        width: 100%;
    }

    .custom-client-dropdown {
        min-width: 240px;
    }

    .form-livraison .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    body {
        font-size: 14px;
    }

    .content,
    .table-container {
        max-width: 98%;
        margin: 12px auto;
    }

    .user-info {
        justify-content: flex-start;
    }

    .bulk-action-bar,
    .table-filter-bar,
    .filtre-container {
        flex-direction: column;
        align-items: stretch;
    }

    .filtre-container::before {
        display: none;
    }

    .custom-client-dropdown,
    .select-lieu-client,
    .client-filter-input,
    .filtre-container select#type_produit,
    .filtre-container select[name="type_produit"] {
        min-width: 100%;
        width: 100%;
    }

    .table-container th.actions-cell,
    .table-container td.actions-cell {
        min-width: 360px;
        max-width: 360px;
        width: 360px;
    }

    .action-btns {
        flex-wrap: wrap;
    }

    .modal-content,
    .modal-detail-content,
    .modal-modifier-content,
    .cm-modal-content,
    .form-livraison {
        width: 95%;
        padding: 16px;
    }

    .modal-buttons,
    .form-actions-modal,
    .cm-modal-actions {
        flex-direction: column;
    }

    .btn-primary,
    .btn-secondary,
    .btn-confirm,
    .btn-cancel {
        width: 100%;
    }
}

.transfer-dropdown.active {
    z-index: 1400;
}
