/*
 * UWEZO UI alignment layer.
 * Pure presentation: grids, spacing, filters, tables, buttons and dropdowns.
 */

:root {
    --erp-ui-border: #e5e7eb;
    --erp-ui-muted: #64748b;
    --erp-ui-bg: #f8fafc;
    --erp-ui-radius: 14px;
    --erp-ui-field-height: 42px;
    --erp-ui-gap-x: 20px;
    --erp-ui-gap-y: 16px;
    --erp-premium-primary: #2563eb;
    --erp-premium-primary-dark: #1d4ed8;
    --erp-premium-success: #16a34a;
    --erp-premium-warning: #f97316;
    --erp-premium-danger: #dc2626;
    --erp-premium-surface: rgba(255, 255, 255, .88);
    --erp-premium-shadow: 0 18px 45px rgba(15, 23, 42, .08);
}

/* Export suite - professional ERP controls */
.erp-export-panel {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px;
    border: 1px solid color-mix(in srgb, var(--border-soft, #d8e1ef) 86%, transparent);
    border-radius: 13px;
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    box-shadow: 0 14px 30px rgba(15, 23, 42, .07);
}

.erp-export-panel__title {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 0 10px;
    border-radius: 9px;
    color: var(--text-main, #0f172a);
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .02em;
    text-transform: uppercase;
    white-space: nowrap;
}

.erp-export-panel__title i {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: color-mix(in srgb, var(--blue-600, #2563eb) 12%, #fff);
    color: var(--blue-600, #2563eb);
    font-size: .9rem;
}

.erp-export-suite {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    box-shadow: none;
}

.erp-export-btn,
.erp-toolbar-btn {
    --export-accent: var(--blue-600, #2563eb);
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 13px;
    border: 1px solid color-mix(in srgb, var(--export-accent) 24%, var(--border-soft, #dbe4f0));
    border-radius: 9px;
    background: linear-gradient(180deg, #ffffff, color-mix(in srgb, var(--export-accent) 5%, #f8fafc));
    color: color-mix(in srgb, var(--text-main, #0f172a) 88%, var(--export-accent));
    font-size: .84rem;
    font-weight: 850;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .06);
    transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}

.erp-export-btn i,
.erp-toolbar-btn i {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--export-accent);
    font-size: 1rem;
    line-height: 1;
}

.erp-export-btn:hover,
.erp-export-btn:focus,
.erp-toolbar-btn:hover,
.erp-toolbar-btn:focus {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--export-accent) 44%, var(--border-soft, #dbe4f0));
    background: linear-gradient(180deg, #ffffff, color-mix(in srgb, var(--export-accent) 10%, #f8fafc));
    color: color-mix(in srgb, var(--text-main, #0f172a) 72%, var(--export-accent));
    box-shadow: 0 14px 28px rgba(15, 23, 42, .11);
}

.erp-export-btn:active,
.erp-toolbar-btn:active {
    transform: translateY(0);
    box-shadow: inset 0 2px 8px rgba(15, 23, 42, .08);
}

.erp-export-excel,
.erp-export-btn[href*="excel"],
.ventes-export-excel {
    --export-accent: #138a54;
}

.erp-export-csv {
    --export-accent: #0f766e;
}

.erp-export-pdf,
.erp-export-btn[href*="pdf"],
.ventes-export-pdf {
    --export-accent: #be123c;
}

.erp-print-page {
    --export-accent: #475569;
}

.erp-toolbar-command-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.erp-toolbar-btn {
    --export-accent: #64748b;
}

.erp-toolbar-btn-primary {
    --export-accent: var(--blue-600, #2563eb);
    border-color: color-mix(in srgb, var(--export-accent) 55%, #ffffff);
    background: linear-gradient(135deg, var(--blue-600, #2563eb), color-mix(in srgb, var(--blue-500, #3b82f6) 72%, #22c55e));
    color: #fff;
    box-shadow: 0 14px 28px rgba(37, 99, 235, .22);
}

.erp-toolbar-btn-primary i,
.erp-toolbar-btn-primary:hover,
.erp-toolbar-btn-primary:focus {
    color: #fff;
}

.erp-toolbar-btn-primary:hover,
.erp-toolbar-btn-primary:focus {
    background: linear-gradient(135deg, color-mix(in srgb, var(--blue-600, #2563eb) 92%, #111827), var(--blue-500, #3b82f6));
}

.erp-list-toolbar-buttons,
.erp-auto-table-tools > div:last-child {
    align-items: center;
}

.erp-list-toolbar-buttons > .erp-export-suite,
.erp-list-toolbar-buttons > .erp-export-panel {
    margin-right: 2px;
}

.erp-auto-table-tools {
    gap: 12px;
}

@media (max-width: 767.98px) {
    .erp-export-panel {
        width: 100%;
        justify-content: flex-start;
    }

    .erp-export-panel__title {
        width: 100%;
    }

    .erp-export-suite,
    .erp-toolbar-command-row {
        width: 100%;
        justify-content: stretch;
    }

    .erp-export-btn,
    .erp-toolbar-btn {
        flex: 1 1 calc(50% - 6px);
        min-width: 120px;
    }
}

@media print {
    .erp-export-panel,
    .erp-export-suite,
    .erp-toolbar-command-row,
    .erp-auto-table-tools,
    .erp-list-toolbar-buttons {
        display: none !important;
    }
}

html[data-theme="blue_corporate"],
html:not([data-theme]) {
    --navy-950: #07111f;
    --navy-900: #0f172a;
    --blue-600: #2563eb;
    --blue-500: #3b82f6;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-muted: #eef2f7;
    --border-soft: #dbe3ef;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --premium-gradient: linear-gradient(135deg, #2563eb, #1d4ed8);
    --premium-navy-gradient: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

html[data-theme="emerald_business"] {
    --navy-950: #052e2b;
    --navy-900: #064e3b;
    --blue-600: #059669;
    --blue-500: #10b981;
    --surface: #ffffff;
    --surface-soft: #f0fdf4;
    --surface-muted: #dcfce7;
    --border-soft: #bbf7d0;
    --text-main: #052e2b;
    --text-muted: #4b6358;
    --premium-gradient: linear-gradient(135deg, #059669, #047857);
    --premium-navy-gradient: linear-gradient(180deg, #052e2b 0%, #064e3b 100%);
}

html[data-theme="odoo_enterprise"] {
    --navy-950: #241424;
    --navy-900: #3f2a3f;
    --blue-600: #875a7b;
    --blue-500: #a46a92;
    --surface: #ffffff;
    --surface-soft: #f8f5f8;
    --surface-muted: #efe7ef;
    --border-soft: #ded2dc;
    --text-main: #241424;
    --text-muted: #6f5b6c;
    --premium-gradient: linear-gradient(135deg, #875a7b, #5f3f57);
    --premium-navy-gradient: linear-gradient(180deg, #241424 0%, #3f2a3f 100%);
}

html[data-theme="sap_fiori"] {
    --navy-950: #0a1f33;
    --navy-900: #12344d;
    --blue-600: #0a6ed1;
    --blue-500: #2684dc;
    --surface: #ffffff;
    --surface-soft: #f7f9fb;
    --surface-muted: #edf4fb;
    --border-soft: #cfe3f6;
    --text-main: #0a1f33;
    --text-muted: #5b6f82;
    --premium-gradient: linear-gradient(135deg, #0a6ed1, #085caf);
    --premium-navy-gradient: linear-gradient(180deg, #0a1f33 0%, #12344d 100%);
}

html[data-theme="oracle_cloud"] {
    --navy-950: #21100d;
    --navy-900: #3b1d18;
    --blue-600: #c74634;
    --blue-500: #d95c4b;
    --surface: #ffffff;
    --surface-soft: #fbf7f5;
    --surface-muted: #f4e5e1;
    --border-soft: #e7c9c2;
    --text-main: #21100d;
    --text-muted: #765f59;
    --premium-gradient: linear-gradient(135deg, #c74634, #8f2f24);
    --premium-navy-gradient: linear-gradient(180deg, #21100d 0%, #3b1d18 100%);
}

html[data-theme="zoho_modern"] {
    --navy-950: #101827;
    --navy-900: #1e293b;
    --blue-600: #2563eb;
    --blue-500: #f59e0b;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-muted: #eef2ff;
    --border-soft: #dbe4ff;
    --text-main: #101827;
    --text-muted: #64748b;
    --premium-gradient: linear-gradient(135deg, #2563eb, #f59e0b);
    --premium-navy-gradient: linear-gradient(180deg, #101827 0%, #1e293b 100%);
}

html[data-theme="sage_professional"] {
    --navy-950: #06211f;
    --navy-900: #0f3d3a;
    --blue-600: #00a376;
    --blue-500: #00c896;
    --surface: #ffffff;
    --surface-soft: #f4fbf8;
    --surface-muted: #e3f6ef;
    --border-soft: #c5eadb;
    --text-main: #06211f;
    --text-muted: #55706a;
    --premium-gradient: linear-gradient(135deg, #00a376, #007a5e);
    --premium-navy-gradient: linear-gradient(180deg, #06211f 0%, #0f3d3a 100%);
}

html[data-theme] {
    --erp-primary: var(--blue-600);
    --erp-dark: var(--navy-900);
    --erp-bg: var(--surface-soft);
    --erp-card: var(--surface);
    --erp-ui-border: var(--border-soft);
    --erp-ui-muted: var(--text-muted);
    --erp-premium-primary: var(--blue-600);
    --erp-premium-primary-dark: var(--navy-900);
    --erp-premium-surface: var(--surface);
    --erp-premium-shadow: 0 18px 45px rgba(15, 23, 42, .10);
}

body.erp-body {
    background:
        radial-gradient(circle at top left, color-mix(in srgb, var(--blue-600) 16%, transparent), transparent 28rem),
        radial-gradient(circle at top right, rgba(22, 163, 74, .08), transparent 24rem),
        var(--surface-soft);
    color: var(--text-main);
}

html[data-theme] .erp-sidebar {
    background: var(--premium-navy-gradient);
}

html[data-theme] .erp-sidebar-brand-icon,
html[data-theme] .erp-user-avatar,
html[data-theme] .erp-nav-link.active,
html[data-theme] .erp-nav-module-toggle.active {
    background: var(--premium-gradient);
}

html[data-theme] .erp-topbar,
html[data-theme] .erp-card,
html[data-theme] .card,
html[data-theme] .dropdown-menu,
html[data-theme] .modal-content,
html[data-theme] .erp-list-toolbar,
html[data-theme] .erp-filter-card,
html[data-theme] .erp-card-header:has(> form[method="GET"]),
html[data-theme] .erp-card-header:has(.collapse form[method="GET"]) {
    background: var(--surface);
    border-color: var(--border-soft);
    color: var(--text-main);
}

html[data-theme] .erp-card-header,
html[data-theme] .card-header,
html[data-theme] .erp-table th,
html[data-theme] .erp-table thead th,
html[data-theme] .erp-auto-table-tools,
html[data-theme] .erp-topbar-badge,
html[data-theme] .form-control,
html[data-theme] .form-select,
html[data-theme] .ts-control {
    background: var(--surface-soft);
    border-color: var(--border-soft);
    color: var(--text-main);
}

html[data-theme] .erp-page-title,
html[data-theme] .erp-stat-value,
html[data-theme] .erp-topbar-title,
html[data-theme] .dropdown-item,
html[data-theme] .modal-title,
html[data-theme] .form-label,
html[data-theme] .erp-table td {
    color: var(--text-main);
}

html[data-theme] .erp-page-subtitle,
html[data-theme] .erp-stat-label,
html[data-theme] .text-muted,
html[data-theme] .form-text,
html[data-theme] .dropdown-header,
html[data-theme] .erp-table th {
    color: var(--text-muted) !important;
}

html[data-theme] .btn-primary,
html[data-theme] .page-item.active .page-link {
    background: var(--premium-gradient);
    border-color: var(--blue-600);
}

html[data-theme] .page-link,
html[data-theme] .btn-outline-secondary,
html[data-theme] .btn-light {
    background: var(--surface);
    border-color: var(--border-soft);
    color: var(--text-main);
}

html[data-theme] .dropdown-item:hover,
html[data-theme] .dropdown-item.active,
html[data-theme] .erp-table tbody tr:hover,
html[data-theme] .erp-nav-sublink.active,
html[data-theme] .erp-nav-sublink:hover {
    background: color-mix(in srgb, var(--blue-600) 14%, transparent);
    color: var(--text-main);
}

.erp-theme-menu {
    min-width: 240px;
}

.erp-theme-option {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.erp-theme-swatch {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 1px solid var(--border-soft);
    border-radius: 999px;
    background: var(--premium-gradient);
}

.erp-theme-swatch[data-theme-swatch="emerald_business"] { background: linear-gradient(135deg, #064e3b, #10b981); }
.erp-theme-swatch[data-theme-swatch="blue_corporate"] { background: linear-gradient(135deg, #0f172a, #2563eb); }
.erp-theme-swatch[data-theme-swatch="odoo_enterprise"] { background: linear-gradient(135deg, #241424, #875a7b); }
.erp-theme-swatch[data-theme-swatch="sap_fiori"] { background: linear-gradient(135deg, #0a1f33, #0a6ed1); }
.erp-theme-swatch[data-theme-swatch="oracle_cloud"] { background: linear-gradient(135deg, #21100d, #c74634); }
.erp-theme-swatch[data-theme-swatch="zoho_modern"] { background: linear-gradient(135deg, #2563eb, #f59e0b); }
.erp-theme-swatch[data-theme-swatch="sage_professional"] { background: linear-gradient(135deg, #06211f, #00a376); }

.erp-auto-pagination {
    align-items: center;
    background: var(--surface, #fff);
    border-top: 1px solid var(--border-soft, #e5e7eb);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: space-between;
    padding: 12px 16px;
}

.erp-auto-pagination-count {
    color: var(--text-muted, #64748b);
    font-size: .86rem;
    font-weight: 600;
}

.erp-auto-pagination-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.erp-auto-pagination-nav .btn {
    align-items: center;
    display: inline-flex;
    height: 32px;
    justify-content: center;
    min-width: 34px;
    padding-inline: 10px;
}

.finance-budget-filter-grid {
    align-items: end;
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(130px, 1fr));
}

.finance-budget-filter-grid :is(.form-control, .form-select, .input-group) {
    min-width: 0;
    width: 100%;
}

.finance-budget-filter-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.finance-budget-table {
    table-layout: fixed;
}

.finance-budget-table th,
.finance-budget-table td {
    max-width: none !important;
    vertical-align: middle;
}

.finance-budget-progress {
    height: 8px;
    min-width: 130px;
}

@media (max-width: 1199.98px) {
    .finance-budget-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .finance-budget-filter-grid > .input-group,
    .finance-budget-filter-actions {
        grid-column: 1 / -1;
    }
}

@media (max-width: 767.98px) {
    .finance-budget-filter-grid {
        grid-template-columns: 1fr;
    }

    .finance-budget-filter-actions {
        justify-content: stretch;
    }

    .finance-budget-filter-actions .btn {
        flex: 1 1 0;
    }
}

.erp-content {
    animation: erpFadeUp .28s ease both;
}

@keyframes erpFadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.erp-page-header-icon {
    width: 46px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 46px;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--erp-premium-primary), var(--erp-premium-primary-dark));
    box-shadow: 0 14px 28px rgba(37, 99, 235, .18);
}

.erp-page-header > :last-child:is(.btn, .d-flex, .btn-group),
.erp-page-header .erp-page-actions {
    margin-left: auto;
    justify-content: flex-end;
}

.erp-card,
.card {
    background: var(--erp-premium-surface);
    border: 1px solid var(--erp-ui-border);
    border-radius: var(--erp-ui-radius);
    margin-bottom: 18px;
    box-shadow: var(--erp-premium-shadow);
    backdrop-filter: blur(10px);
}

.erp-card:not(.erp-card--flush),
.card:not(.erp-card--flush) {
    padding: 0;
}

.erp-card-header,
.card-header {
    padding: 14px 18px;
    background: linear-gradient(180deg, #fff, #f8fafc);
    border-bottom: 1px solid var(--erp-ui-border);
    border-radius: var(--erp-ui-radius) var(--erp-ui-radius) 0 0 !important;
}

.erp-card-body,
.card-body {
    padding: 18px;
}

.erp-section-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 14px;
    color: #0f172a;
}

.erp-page-title {
    letter-spacing: -.03em;
}

.erp-page-subtitle,
.form-text,
.text-muted {
    color: #64748b !important;
}

.btn {
    border-radius: 10px;
    font-weight: 600;
    transition: transform .16s ease, box-shadow .16s ease, background-color .16s ease, border-color .16s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--erp-premium-primary), var(--erp-premium-primary-dark));
    border-color: var(--erp-premium-primary);
    box-shadow: 0 10px 20px rgba(37, 99, 235, .18);
}

.btn-success {
    background: linear-gradient(135deg, var(--erp-premium-success), #15803d);
    border-color: var(--erp-premium-success);
}

.btn-warning {
    background: linear-gradient(135deg, var(--erp-premium-warning), #ea580c);
    border-color: var(--erp-premium-warning);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, var(--erp-premium-danger), #b91c1c);
    border-color: var(--erp-premium-danger);
}

.btn-outline-secondary,
.btn-light {
    border-color: #dbe3ef;
    background: #fff;
}

.erp-confirm-icon {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    align-items: center;
    justify-content: center;
    flex: 0 0 2.25rem;
    border-radius: 999px;
    background: #fff7ed;
    font-size: 1.1rem;
}

.erp-form-grid,
.vente-create .vente-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(220px, 1fr)) !important;
    gap: var(--erp-ui-gap-y) var(--erp-ui-gap-x) !important;
    align-items: start;
}

form .row.g-3:not(.erp-keep-row),
form .row.g-2:not(.erp-keep-row) {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: var(--erp-ui-gap-y) var(--erp-ui-gap-x) !important;
    align-items: start !important;
}

form .row.g-3:not(.erp-keep-row) > [class*="col-"],
form .row.g-2:not(.erp-keep-row) > [class*="col-"] {
    width: 100% !important;
    max-width: none !important;
    flex: initial !important;
    min-width: 0;
}

form .row.g-3:not(.erp-keep-row) > [class*="col-"] > label,
form .row.g-2:not(.erp-keep-row) > [class*="col-"] > label {
    display: block;
}

.erp-form-grid-2,
.vente-create .vente-grid-2 {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(260px, 1fr)) !important;
    gap: var(--erp-ui-gap-y) var(--erp-ui-gap-x) !important;
    align-items: start;
}

.erp-field,
.erp-form-grid > *,
.erp-form-grid-2 > *,
.vente-create .vente-grid > *,
.vente-create .vente-grid-2 > * {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.erp-field label,
.erp-form-grid label,
.erp-form-grid-2 label,
.vente-create label,
.erp-filter-card label {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.25;
    color: #334155;
}

.erp-field input,
.erp-field select,
.erp-field textarea,
.erp-form-grid input,
.erp-form-grid select,
.erp-form-grid textarea,
.erp-form-grid-2 input,
.erp-form-grid-2 select,
.erp-form-grid-2 textarea,
.vente-create input,
.vente-create select,
.vente-create textarea {
    width: 100%;
    min-height: var(--erp-ui-field-height);
}

.form-control,
.form-select,
.ts-control {
    border-color: #dbe3ef;
    border-radius: 10px;
    box-shadow: none !important;
}

.form-control:focus,
.form-select:focus,
.ts-wrapper.focus .ts-control {
    border-color: var(--erp-premium-primary);
    box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .12) !important;
}

.form-label {
    font-weight: 650;
    color: #334155;
}

.form-control-sm,
.form-select-sm,
.input-group-sm > .form-control,
.input-group-sm > .form-select,
.input-group-sm > .input-group-text,
.btn-sm {
    min-height: 36px;
}

.erp-filter-card,
.erp-list-toolbar,
.erp-card-header:has(> form[method="GET"]),
.erp-card-header:has(.collapse form[method="GET"]) {
    padding: 16px;
    border-radius: var(--erp-ui-radius);
    background: #fff;
    border: 1px solid var(--erp-ui-border);
    margin-bottom: 18px;
}

.erp-card > .erp-card-header:has(> form[method="GET"]),
.erp-card > .erp-card-header:has(.collapse form[method="GET"]) {
    border: 0;
    border-bottom: 1px solid var(--erp-ui-border);
    border-radius: var(--erp-ui-radius) var(--erp-ui-radius) 0 0;
    margin-bottom: 0;
}

.erp-filter-grid,
.erp-list-toolbar-form,
.erp-card-header form[method="GET"] > .row,
.erp-card-header form[method="GET"].d-flex,
.erp-card-header form[method="GET"].row {
    display: grid !important;
    grid-template-columns: minmax(240px, 1.5fr) repeat(4, minmax(160px, 1fr));
    gap: 12px !important;
    align-items: end !important;
    width: 100%;
}

.erp-filter-grid > *,
.erp-list-toolbar-form > *,
.erp-card-header form[method="GET"] > .row > *,
.erp-card-header form[method="GET"].d-flex > *,
.erp-card-header form[method="GET"].row > * {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
    flex: initial !important;
}

.erp-list-toolbar-search,
.erp-card-header form[method="GET"] .input-group {
    width: 100% !important;
    max-width: none !important;
}

.erp-list-toolbar-actions {
    display: contents !important;
}

.erp-filter-actions,
.erp-card-header form[method="GET"] .col-lg-auto,
.erp-card-header form[method="GET"] .ms-lg-auto {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    justify-content: flex-end !important;
    align-items: end !important;
}

.erp-filter-actions .btn,
.erp-card-header form[method="GET"] .col-lg-auto .btn,
.erp-card-header form[method="GET"] .ms-lg-auto .btn {
    min-height: 36px;
    white-space: nowrap;
}

.erp-table-wrap,
.table-responsive {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
    border-radius: 0 0 var(--erp-ui-radius) var(--erp-ui-radius);
}

.erp-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.erp-table-wrap {
    background: #fff;
}

.erp-table th {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--erp-ui-muted);
    background: var(--erp-ui-bg);
    white-space: nowrap;
    position: relative;
    user-select: none;
}

.erp-table th.erp-sortable {
    cursor: pointer;
    padding-right: 28px;
}

.erp-table th.erp-sortable::after {
    content: "↕";
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 11px;
}

.erp-table th.erp-sort-asc::after {
    content: "↑";
    color: var(--erp-premium-primary);
}

.erp-table th.erp-sort-desc::after {
    content: "↓";
    color: var(--erp-premium-primary);
}

.erp-table td {
    vertical-align: middle;
    font-size: 14px;
    white-space: nowrap;
    padding-top: 10px;
    padding-bottom: 10px;
}

.erp-table tbody tr {
    transition: background-color .16s ease, transform .16s ease;
}

.erp-table tbody tr:hover {
    background: #f8fbff;
}

.badge {
    border-radius: 999px;
    padding: .42em .7em;
    font-weight: 650;
}

.erp-stat-card {
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 104px;
    padding: 18px;
}

.erp-stat-card::after {
    content: "";
    position: absolute;
    inset: auto -20px -45px auto;
    width: 120px;
    height: 120px;
    background: rgba(37, 99, 235, .08);
    border-radius: 999px;
}

.erp-stat-value {
    letter-spacing: -.04em;
    font-size: clamp(1.35rem, 2vw, 1.9rem);
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}

.erp-stat-label {
    margin-top: 4px;
    color: #64748b;
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.erp-stat-trend {
    margin-top: 6px;
    color: #475569;
    font-size: .78rem;
}

.erp-empty-state {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 34px 18px;
    color: #64748b;
    text-align: center;
}

.erp-empty-state-icon {
    width: 54px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    background: #eff6ff;
    color: var(--erp-premium-primary);
    font-size: 1.45rem;
}

.erp-empty-state-title {
    color: #0f172a;
    font-size: .98rem;
    font-weight: 800;
}

.erp-empty-state-message {
    max-width: 420px;
    font-size: .86rem;
}

.erp-filter-w-sm { max-width: 160px; }
.erp-filter-w-md { max-width: 220px; }
.erp-filter-w-lg { max-width: 320px; }
.erp-filter-w-xl { max-width: 420px; }

.erp-action-primary { --bs-btn-bg: var(--erp-premium-primary); --bs-btn-border-color: var(--erp-premium-primary); }
.erp-action-validate { --bs-btn-bg: var(--erp-premium-success); --bs-btn-border-color: var(--erp-premium-success); }
.erp-action-edit { --bs-btn-bg: var(--erp-premium-warning); --bs-btn-border-color: var(--erp-premium-warning); color: #fff; }
.erp-action-delete { --bs-btn-bg: var(--erp-premium-danger); --bs-btn-border-color: var(--erp-premium-danger); }
.erp-action-cancel { --bs-btn-bg: #64748b; --bs-btn-border-color: #64748b; }

.erp-module-badge--finance {
    background: rgba(37, 99, 235, .12);
    color: #1d4ed8;
    border-color: rgba(37, 99, 235, .18);
}

.erp-module-badge--commercial {
    background: rgba(22, 163, 74, .12);
    color: #15803d;
    border-color: rgba(22, 163, 74, .18);
}

.erp-module-badge--achats {
    background: rgba(249, 115, 22, .12);
    color: #c2410c;
    border-color: rgba(249, 115, 22, .18);
}
}

.erp-list-toolbar {
    box-shadow: var(--erp-premium-shadow);
}

.erp-auto-table-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.erp-auto-table-search {
    position: relative;
    width: min(360px, 100%);
}

.erp-auto-table-search i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}

.erp-auto-table-search .form-control {
    padding-left: 34px;
}

.erp-list-action {
    color: #334155 !important;
    text-decoration: none;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    padding-inline: 10px;
}

.erp-list-action:hover {
    color: var(--erp-premium-primary) !important;
    background: #eff6ff;
}

.erp-form-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .05);
}

.erp-form-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .86rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #0f172a;
    font-weight: 800;
    margin-bottom: 16px;
}

.erp-form-section-title::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--erp-premium-primary);
    box-shadow: 0 0 0 5px rgba(37, 99, 235, .12);
}

@media (max-width: 991.98px) {
    .erp-page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .erp-page-header .btn,
    .erp-page-header .d-flex {
        width: 100%;
    }

    .erp-filter-grid,
    .erp-list-toolbar-form,
    .erp-card-header form[method="GET"] > .row,
    .erp-card-header form[method="GET"].d-flex,
    .erp-card-header form[method="GET"].row {
        grid-template-columns: 1fr 1fr !important;
    }
}

@media (max-width: 767.98px) {
    form .row.g-3:not(.erp-keep-row),
    form .row.g-2:not(.erp-keep-row),
    .erp-form-grid,
    .erp-form-grid-2,
    .vente-create .vente-grid,
    .vente-create .vente-grid-2,
    .erp-filter-grid,
    .erp-list-toolbar-form,
    .erp-card-header form[method="GET"] > .row,
    .erp-card-header form[method="GET"].d-flex,
    .erp-card-header form[method="GET"].row {
        grid-template-columns: 1fr !important;
    }

    .erp-table-wrap table.erp-table thead {
        display: none;
    }

    .erp-table-wrap table.erp-table,
    .erp-table-wrap table.erp-table tbody,
    .erp-table-wrap table.erp-table tr,
    .erp-table-wrap table.erp-table td {
        display: block;
        width: 100%;
    }

    .erp-table-wrap table.erp-table tr {
        margin: 12px;
        border: 1px solid #e5e7eb;
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 10px 25px rgba(15, 23, 42, .06);
        overflow: hidden;
    }

    .erp-table-wrap table.erp-table td {
        white-space: normal;
        display: flex;
        justify-content: space-between;
        gap: 16px;
        padding: 10px 14px;
        border-bottom: 1px solid #f1f5f9;
    }

    .erp-table-wrap table.erp-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #64748b;
        flex: 0 0 42%;
    }
}

@media print {
    .erp-sidebar,
    .erp-topbar,
    .erp-sidebar-overlay,
    .erp-page-header .btn,
    .erp-list-toolbar,
    .erp-table-footer,
    .btn,
    .dropdown {
        display: none !important;
    }

    .erp-main {
        margin-left: 0 !important;
    }

    .erp-card,
    .card {
        box-shadow: none !important;
        border-color: #cbd5e1 !important;
    }
}

.erp-table td:first-child,
.erp-table th:first-child {
    padding-left: 16px;
}

.erp-table td:last-child,
.erp-table th:last-child {
    padding-right: 16px;
}

.erp-table .amount,
.erp-table td.text-end,
.erp-table th.text-end {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.erp-table .actions,
.erp-table td:last-child:has(.dropdown),
.erp-table td:last-child:has(.btn-group),
.erp-table th:last-child {
    text-align: right;
    width: 80px;
}

.erp-table td.text-truncate,
.erp-table .text-truncate {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.erp-table tbody tr {
    height: 48px;
}

.erp-table tbody tr:hover {
    background: #f8fafc;
}

.erp-card-footer,
.erp-table-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--erp-ui-border);
    background: #fff;
    border-radius: 0 0 var(--erp-ui-radius) var(--erp-ui-radius);
}

.erp-actions-btn,
.erp-table .btn-light,
.erp-table .btn-outline-secondary {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.erp-table .btn-group {
    justify-content: flex-end;
}

.erp-page-header .btn,
.erp-card-header .btn,
.erp-submit-bar .btn,
.vente-submit-bar .btn {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.vente-create {
    max-width: 1180px !important;
}

.vente-create .erp-card {
    margin-bottom: 16px !important;
}

.vente-create .erp-card-header {
    padding: 12px 16px !important;
}

.vente-create .erp-card-body {
    padding: 16px !important;
}

.vente-create .vente-summary {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(130px, 1fr)) !important;
    gap: 12px !important;
}

.vente-submit-bar {
    justify-content: space-between;
    align-items: center;
}

.pos-page {
    max-width: 1680px;
    margin: 0 auto;
}

.pos-header,
.pos-controls,
.pos-layout {
    margin-bottom: 12px !important;
}

.pos-controls {
    grid-template-columns: minmax(280px, 1.2fr) minmax(280px, 1fr) minmax(120px, .45fr) !important;
    align-items: end;
}

.pos-layout {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 400px) !important;
    gap: 12px !important;
}

.dropdown-menu,
.erp-action-menu-list,
.ts-dropdown {
    z-index: 1100 !important;
}

.dropdown-menu {
    max-width: min(320px, calc(100vw - 24px));
}

.ts-dropdown {
    max-height: min(320px, 48vh);
    overflow-y: auto;
}

#erpQuickAddModal,
#erpConfirmModal {
    z-index: 1120 !important;
    pointer-events: auto;
}

#erpQuickAddModal .modal-dialog,
#erpQuickAddModal .modal-content,
#erpQuickAddModal input,
#erpQuickAddModal select,
#erpQuickAddModal textarea,
#erpQuickAddModal button,
#erpConfirmModal .modal-dialog,
#erpConfirmModal .modal-content,
#erpConfirmModal button {
    pointer-events: auto;
}

.erp-card,
.erp-card-body,
.erp-card-header,
.table-responsive,
.erp-table-wrap,
.erp-list-toolbar,
.erp-list-toolbar-form {
    overflow: visible;
}

.erp-table-wrap,
.table-responsive {
    overflow-x: auto;
}

@media (max-width: 1200px) {
    .erp-form-grid,
    .vente-create .vente-grid,
    form .row.g-3:not(.erp-keep-row),
    form .row.g-2:not(.erp-keep-row) {
        grid-template-columns: repeat(2, minmax(220px, 1fr)) !important;
    }

    .erp-filter-grid,
    .erp-list-toolbar-form,
    .erp-card-header form[method="GET"] > .row,
    .erp-card-header form[method="GET"].d-flex,
    .erp-card-header form[method="GET"].row {
        grid-template-columns: repeat(3, minmax(180px, 1fr));
    }

    .pos-layout {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    .erp-page-header {
        align-items: stretch;
    }

    .erp-page-header,
    .erp-page-header > :last-child:is(.btn, .d-flex, .btn-group) {
        flex-direction: column;
    }

    .erp-page-header > :last-child:is(.btn, .d-flex, .btn-group),
    .erp-page-header .btn {
        width: 100%;
    }

    .erp-form-grid,
    .erp-form-grid-2,
    .erp-filter-grid,
    .erp-list-toolbar-form,
    .vente-create .vente-grid,
    .vente-create .vente-grid-2,
    form .row.g-3:not(.erp-keep-row),
    form .row.g-2:not(.erp-keep-row),
    .erp-card-header form[method="GET"] > .row,
    .erp-card-header form[method="GET"].d-flex,
    .erp-card-header form[method="GET"].row {
        grid-template-columns: 1fr !important;
    }

    .erp-filter-actions,
    .erp-card-header form[method="GET"] .col-lg-auto,
    .erp-card-header form[method="GET"] .ms-lg-auto {
        flex-direction: column !important;
    }

    .erp-filter-actions .btn,
    .erp-card-header form[method="GET"] .btn {
        width: 100%;
    }

    .erp-table-wrap,
    .table-responsive {
        overflow-x: auto !important;
    }

    .erp-table {
        min-width: 760px;
    }

    .erp-table thead {
        display: table-header-group !important;
    }

    .erp-table tbody tr {
        display: table-row !important;
        height: auto;
        padding: 0 !important;
        border: 0 !important;
        box-shadow: none !important;
    }

    .erp-table tbody td {
        display: table-cell !important;
        text-align: inherit !important;
        padding: 10px 8px !important;
        border-bottom: 1px solid #eef2f7 !important;
    }

    .erp-table tbody td::before {
        display: none !important;
    }

    .vente-create .vente-summary {
        grid-template-columns: 1fr !important;
    }

    .pos-controls,
    .pos-layout {
        grid-template-columns: 1fr !important;
    }
}

/* Compact ERP tables: presentation only, no business behavior. */
@media (min-width: 768px) {
    .erp-table-wrap,
    .table-responsive {
        overflow-x: visible !important;
    }

    .erp-table {
        table-layout: auto;
    }

    .erp-table th,
    .erp-table td {
        padding: .68rem .78rem;
        max-width: 260px;
    }

    .erp-table td {
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .erp-table th {
        white-space: nowrap;
    }

    .erp-table td.text-end,
    .erp-table th.text-end,
    .erp-table .amount {
        text-align: right !important;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    .erp-table td:last-child,
    .erp-table th:last-child,
    .erp-table .actions {
        width: 72px;
        min-width: 72px;
        max-width: 88px;
        text-align: right !important;
        white-space: nowrap;
    }

    .erp-table .badge {
        white-space: nowrap;
    }

    .erp-table .text-truncate {
        max-width: min(240px, 28vw);
    }
}

.erp-action-menu {
    display: inline-flex;
    justify-content: flex-end;
}

.erp-actions-btn {
    width: 36px;
    min-width: 36px;
    padding-inline: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.erp-action-menu-list {
    min-width: 190px;
}

.erp-table-footer,
.erp-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 767.98px) {
    .erp-table-wrap,
    .table-responsive {
        overflow: visible !important;
        background: transparent;
    }

    .erp-table thead {
        display: none;
    }

    .erp-table,
    .erp-table tbody,
    .erp-table tr,
    .erp-table td {
        display: block;
        width: 100%;
    }

    .erp-table tbody tr {
        background: #fff;
        border: 1px solid var(--erp-ui-border);
        border-radius: 10px;
        box-shadow: 0 8px 24px rgba(15, 23, 42, .06);
        margin: 0 0 12px;
        padding: 10px 12px;
    }

    .erp-table tbody td {
        border: 0;
        padding: 8px 0;
        display: flex;
        justify-content: space-between;
        gap: 16px;
        white-space: normal;
        text-align: right;
    }

    .erp-table tbody td::before {
        content: attr(data-label);
        color: var(--erp-ui-muted);
        font-size: .76rem;
        font-weight: 700;
        text-transform: uppercase;
        text-align: left;
        flex: 0 0 42%;
    }

    .erp-table tbody td[data-label=""],
    .erp-table tbody td:not([data-label]) {
        display: block;
        text-align: left;
    }

    .erp-table tbody td[data-label=""]::before,
    .erp-table tbody td:not([data-label])::before {
        display: none;
    }

    .erp-table tbody td:last-child {
        justify-content: flex-end;
        border-top: 1px solid #eef2f7;
        margin-top: 6px;
        padding-top: 10px;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Ergonomie ERP type Cargo  largeur, grilles, alignements
   Cette couche reste structurelle : pas de logique, pas de routes.
   ═══════════════════════════════════════════════════════════════ */

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.erp-wrapper,
.erp-main {
    min-width: 0;
}

.container-erp,
.erp-content.container-erp {
    width: 100%;
    max-width: 1680px;
    margin-inline: auto;
    padding: clamp(16px, 1.25vw, 24px);
}

.erp-page-header {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    gap: 12px 18px;
}

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

.erp-page-header > :last-child:is(.btn, .d-flex, .btn-group),
.erp-page-header .erp-page-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    margin-left: 0;
}

.erp-card,
.card,
.erp-list-toolbar,
.erp-filter-card {
    border-radius: 12px;
    border: 1px solid var(--erp-ui-border);
    box-shadow: 0 6px 18px rgba(15, 23, 42, .045);
    margin-bottom: 16px;
}

.erp-card-header,
.card-header,
.erp-card-body,
.card-body {
    padding: 16px;
}

.erp-form-grid,
.erp-form-grid-2,
.vente-create .vente-grid,
.vente-create .vente-grid-2,
form .row.g-3:not(.erp-keep-row),
form .row.g-2:not(.erp-keep-row) {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 14px 16px !important;
    align-items: start !important;
}

.erp-field,
.erp-form-grid > *,
.erp-form-grid-2 > *,
.vente-create .vente-grid > *,
.vente-create .vente-grid-2 > *,
form .row.g-3:not(.erp-keep-row) > [class*="col-"],
form .row.g-2:not(.erp-keep-row) > [class*="col-"] {
    min-width: 0 !important;
    width: 100% !important;
    max-width: none !important;
    flex: initial !important;
}

.erp-field label,
.erp-form-grid label,
.erp-form-grid-2 label,
.vente-create label,
.erp-filter-grid label,
.erp-card-header form[method="GET"] label {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.25;
    color: #334155;
    margin-bottom: 6px;
}

.erp-field :is(input, select, textarea),
.erp-form-grid :is(input, select, textarea),
.erp-form-grid-2 :is(input, select, textarea),
.vente-create :is(input, select, textarea),
.erp-filter-grid :is(input, select, textarea),
.erp-card-header form[method="GET"] :is(input, select, textarea),
.ts-control {
    width: 100%;
    min-height: 40px;
}

.erp-filter-card,
.erp-list-toolbar,
.erp-card-header:has(> form[method="GET"]),
.erp-card-header:has(.collapse form[method="GET"]) {
    padding: 14px;
}

.erp-filter-grid,
.erp-list-toolbar-form,
.erp-card-header form[method="GET"] > .row,
.erp-card-header form[method="GET"].d-flex,
.erp-card-header form[method="GET"].row {
    display: grid !important;
    grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(145px, 1fr)) auto;
    gap: 10px !important;
    align-items: end !important;
    width: 100%;
}

.erp-filter-grid > *,
.erp-list-toolbar-form > *,
.erp-card-header form[method="GET"] > .row > *,
.erp-card-header form[method="GET"].d-flex > *,
.erp-card-header form[method="GET"].row > * {
    min-width: 0 !important;
    width: 100% !important;
    max-width: none !important;
}

.erp-filter-actions,
.erp-card-header form[method="GET"] .col-lg-auto,
.erp-card-header form[method="GET"] .ms-lg-auto {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    align-items: end !important;
    justify-content: flex-end !important;
}

.btn,
.erp-card-header .btn,
.erp-page-header .btn,
.erp-filter-actions .btn,
.erp-list-toolbar .btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
}

.btn-sm,
.form-control-sm,
.form-select-sm,
.input-group-sm > .form-control,
.input-group-sm > .form-select,
.input-group-sm > .input-group-text {
    min-height: 36px;
}

.erp-table-wrap,
.table-responsive {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: visible;
}

.erp-table {
    width: 100%;
    table-layout: auto;
}

.erp-table th,
.erp-table td {
    vertical-align: middle;
}

.erp-table-wrap .erp-inventaire-form-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.erp-table-wrap .erp-inventaire-form-table th,
.erp-table-wrap .erp-inventaire-form-table td {
    max-width: none !important;
}

.erp-table-wrap .erp-inventaire-form-table .form-control,
.erp-table-wrap .erp-inventaire-form-table .form-select {
    max-width: 100% !important;
    min-width: 0 !important;
    width: 100% !important;
}

.erp-table-wrap .erp-inventaire-show-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.erp-table-wrap .erp-inventaire-show-table th,
.erp-table-wrap .erp-inventaire-show-table td {
    max-width: none !important;
}

.erp-table-wrap .erp-fiche-stock-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.erp-table-wrap .erp-fiche-stock-table th,
.erp-table-wrap .erp-fiche-stock-table td {
    max-width: none !important;
}

.erp-table-wrap .erp-stock-dashboard-movements {
    table-layout: fixed !important;
    width: 100% !important;
}

.erp-table-wrap .erp-stock-dashboard-movements th,
.erp-table-wrap .erp-stock-dashboard-movements td {
    max-width: none !important;
}

.erp-table-wrap .erp-reception-fournisseur-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.erp-table-wrap .erp-reception-fournisseur-table th,
.erp-table-wrap .erp-reception-fournisseur-table td {
    max-width: none !important;
    vertical-align: middle;
}

.erp-table-wrap .erp-reception-fournisseur-table .form-control,
.erp-table-wrap .erp-reception-fournisseur-table .form-select {
    max-width: 100% !important;
    min-width: 0 !important;
    width: 100% !important;
}

.erp-table-wrap .erp-commande-form-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.erp-table-wrap .erp-commande-form-table th,
.erp-table-wrap .erp-commande-form-table td {
    max-width: none !important;
    vertical-align: middle;
}

.erp-table-wrap .erp-commande-form-table .form-control,
.erp-table-wrap .erp-commande-form-table .form-select {
    max-width: 100% !important;
    min-width: 0 !important;
    width: 100% !important;
}

.erp-table-wrap .erp-commande-show-table {
    table-layout: fixed !important;
    min-width: 900px;
    width: 100% !important;
}

.erp-table-wrap .erp-commande-show-table th,
.erp-table-wrap .erp-commande-show-table td {
    max-width: none !important;
    vertical-align: middle;
}

.erp-table-wrap .erp-commande-show-table .currency-cell {
    font-variant-numeric: tabular-nums;
    overflow: visible;
    white-space: nowrap;
}

.erp-ecarts-list-card .erp-list-toolbar-form {
    align-items: end;
    display: grid !important;
    gap: 10px;
    grid-template-columns: minmax(260px, 1fr) minmax(480px, 1.8fr) auto;
}

.erp-ecarts-list-card .erp-list-toolbar-filters {
    display: flex !important;
    flex-wrap: wrap;
    gap: 10px;
}

.erp-ecarts-list-card .erp-list-toolbar-filters :is(select, input[type="date"]) {
    max-width: none !important;
    width: 150px;
}

.erp-ecarts-list-card .erp-list-toolbar-actions,
.erp-ecarts-list-card .erp-list-toolbar-buttons {
    align-items: end;
    display: flex !important;
    justify-content: flex-end;
}

.erp-ecarts-list-card .erp-export-panel,
.erp-ecarts-list-card .erp-export-suite {
    display: inline-flex !important;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 360px;
}

.erp-table-wrap .erp-ecarts-list-table {
    table-layout: fixed !important;
    min-width: 1576px;
    width: 100% !important;
}

.erp-table-wrap .erp-ecarts-list-table th,
.erp-table-wrap .erp-ecarts-list-table td {
    max-width: none !important;
    vertical-align: middle;
}

.erp-table-wrap .erp-ecarts-list-table td.text-end {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.erp-receptions-list-card .erp-list-toolbar-form {
    align-items: stretch;
    display: grid !important;
    gap: 10px;
    grid-template-columns: minmax(260px, 1fr) auto;
}

.erp-receptions-list-card .erp-list-toolbar-actions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.erp-receptions-list-card .erp-list-toolbar-filters {
    display: grid !important;
    gap: 8px;
    grid-template-columns: 170px 145px 145px;
}

.erp-receptions-list-card .erp-list-toolbar-buttons {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.erp-receptions-list-card .erp-list-toolbar-filters :is(select, input[type="date"]) {
    max-width: none !important;
    width: 100% !important;
}

.erp-table-wrap .erp-receptions-list-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.erp-table-wrap .erp-receptions-list-table th,
.erp-table-wrap .erp-receptions-list-table td {
    max-width: none !important;
    vertical-align: middle;
}

.erp-receptions-list-table .badge {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

.erp-commandes-list-card .erp-list-toolbar-form {
    align-items: stretch;
    display: grid !important;
    gap: 10px;
    grid-template-columns: minmax(260px, 1fr) auto;
}

.erp-commandes-list-card .erp-list-toolbar-actions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.erp-commandes-list-card .erp-list-toolbar-filters {
    display: grid !important;
    gap: 8px;
    grid-template-columns: 170px 145px 145px;
}

.erp-commandes-list-card .erp-list-toolbar-buttons {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.erp-commandes-list-card .erp-list-toolbar-filters :is(select, input[type="date"]) {
    max-width: none !important;
    width: 100% !important;
}

.erp-table-wrap .erp-commandes-list-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.erp-table-wrap .erp-commandes-list-table th,
.erp-table-wrap .erp-commandes-list-table td {
    max-width: none !important;
    vertical-align: middle;
}

.erp-commandes-list-table .badge {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

.fournisseur-dettes-filters {
    align-items: stretch;
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
}

.fournisseur-dettes-filters :is(.form-control, .form-select, .input-group) {
    max-width: none !important;
    min-width: 0;
    width: 100%;
}

.fournisseur-dettes-filters > .input-group {
    grid-column: 1 / -1;
}

.fournisseur-dettes-filters > select[name="fournisseur_id"] {
    grid-column: span 2;
}

.fournisseur-dettes-late-filter {
    min-width: 0;
}

.fournisseur-dettes-late-filter .btn {
    align-items: center;
    display: inline-flex;
    gap: 6px;
    justify-content: center;
    min-height: 38px;
    width: 100%;
}

.erp-table-wrap .erp-fournisseur-dettes-table {
    table-layout: fixed !important;
    width: 100% !important;
}

.erp-table-wrap .erp-fournisseur-dettes-table th,
.erp-table-wrap .erp-fournisseur-dettes-table td {
    max-width: none !important;
    vertical-align: middle;
}

.erp-fournisseur-dettes-table .badge {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

@media (max-width: 991.98px) {
    .erp-receptions-list-card .erp-list-toolbar-form {
        grid-template-columns: 1fr;
    }

    .erp-receptions-list-card .erp-list-toolbar-actions,
    .erp-receptions-list-card .erp-list-toolbar-buttons,
    .erp-commandes-list-card .erp-list-toolbar-actions,
    .erp-commandes-list-card .erp-list-toolbar-buttons {
        justify-content: flex-start;
    }

    .erp-commandes-list-card .erp-list-toolbar-form {
        grid-template-columns: 1fr;
    }

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

    .fournisseur-dettes-filters > select[name="fournisseur_id"] {
        grid-column: 1 / -1;
    }
}

@media (max-width: 767.98px) {
    .erp-receptions-list-card .erp-list-toolbar-filters,
    .erp-commandes-list-card .erp-list-toolbar-filters {
        grid-template-columns: 1fr;
    }

    .erp-receptions-list-table,
    .erp-commandes-list-table {
        min-width: 760px;
    }

    .fournisseur-dettes-filters {
        grid-template-columns: 1fr;
    }

    .erp-fournisseur-dettes-table {
        min-width: 760px;
    }
}

.rcf-lot-fields {
    display: grid;
    gap: 6px;
    grid-template-columns: minmax(0, 1fr) 132px;
}

@media (max-width: 991.98px) {
    .erp-reception-fournisseur-table {
        min-width: 720px;
    }

    .rcf-lot-fields {
        grid-template-columns: 1fr;
    }
}

.erp-chauffeur-history-table {
    width: 100%;
    min-width: 820px;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
}

.erp-chauffeur-history-table th {
    padding: 10px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    color: #475569;
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.erp-chauffeur-history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f7;
    color: #0f172a;
    font-size: .88rem;
    vertical-align: top;
    white-space: normal;
}

.erp-chauffeur-history-table tbody tr:hover {
    background: #f8fbff;
}

.erp-chauffeur-history-table .erp-col-ref {
    width: 18%;
}

.erp-chauffeur-history-table .erp-col-date {
    width: 12%;
    white-space: nowrap;
}

.erp-chauffeur-history-table .erp-col-route {
    width: 25%;
    min-width: 0;
}

.erp-chauffeur-history-table .erp-col-products {
    width: 45%;
    min-width: 0;
}

.erp-chauffeur-history-table .erp-table-link,
.erp-chauffeur-history-table .erp-route-cell {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.erp-chauffeur-history-table .erp-table-link {
    display: block;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.erp-chauffeur-history-table .erp-route-point {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.erp-chauffeur-history-table .erp-route-cell {
    display: flex;
    align-items: center;
    gap: 4px;
}

.erp-line-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    min-width: 0;
}

.erp-line-item {
    display: flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: 4px 7px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
    color: #334155;
    font-size: .8rem;
    line-height: 1.25;
}

.erp-line-item--danger {
    border-color: #fecaca;
    background: #fff5f5;
    color: #b91c1c;
}

.erp-line-item-label {
    min-width: 0;
    flex: 0 1 auto;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.erp-line-item-value,
.erp-line-item-meta {
    flex: 0 0 auto;
    white-space: nowrap;
    font-weight: 700;
}

.erp-line-item-meta {
    color: #64748b;
    font-weight: 600;
}

.erp-table th {
    text-align: left;
}

.erp-table td {
    text-align: left;
    white-space: nowrap;
}

.erp-table td:has(.badge) {
    text-align: center;
}

.erp-table td.text-end,
.erp-table th.text-end,
.erp-table .amount {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.erp-table td:last-child,
.erp-table th:last-child,
.erp-table .actions {
    text-align: right !important;
    width: 1%;
    white-space: nowrap;
}

.erp-table .text-truncate,
.erp-table td.text-truncate {
    max-width: clamp(130px, 12vw, 240px);
}

.dropdown-menu,
.ts-dropdown {
    max-width: min(340px, calc(100vw - 32px));
}

.filter-panel {
    background: var(--erp-ui-card, #ffffff);
    border: 1px solid var(--erp-ui-border, #e2e8f0);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.filter-label,
.cargo-currency-filter__label {
    display: inline-block;
    margin-bottom: 0.35rem;
    color: var(--erp-ui-muted, #64748b);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.cargo-form-control,
.cargo-form-select,
.filter-panel .form-control,
.cargo-currency-filter select.form-control {
    min-height: 38px;
    border: 1px solid #94a3b8;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
}

.cargo-form-control:focus,
.cargo-form-select:focus,
.filter-panel .form-control:focus,
.cargo-currency-filter select.form-control:focus {
    border-color: var(--erp-ui-primary, #2563eb);
    box-shadow: 0 0 0 0.18rem rgba(37, 99, 235, 0.14);
}

.cargo-currency-filter {
    margin-bottom: 1.25rem;
    border: 1px solid var(--erp-ui-border, #e2e8f0);
    border-radius: 14px;
    background: var(--erp-ui-card, #ffffff);
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.cargo-currency-filter--compact {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.cargo-currency-filter--compact .cargo-currency-filter__label {
    margin-bottom: 0;
    white-space: nowrap;
}

.cargo-currency-filter--compact .cargo-currency-filter__select {
    width: auto;
    min-width: 118px;
    min-height: 34px;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.erp-page-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.erp-page-toolbar__breadcrumb {
    margin-bottom: 0;
    flex: 1 1 auto;
    min-width: 0;
}

.cargo-currency-filter form {
    padding: 1rem;
}

.cargo-currency-filter__grid {
    display: grid;
    grid-template-columns: minmax(180px, 260px) minmax(150px, 190px) 1fr;
    gap: 0.85rem;
    align-items: end;
}

.cargo-currency-filter__alert {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 10px;
    color: var(--erp-ui-primary, #2563eb);
    background: rgba(37, 99, 235, 0.08);
    font-weight: 700;
}

.cargo-currency-filter__alert span {
    color: var(--erp-ui-muted, #64748b);
    font-size: 0.78rem;
    font-weight: 600;
}

.amount,
.money,
.currency-amount,
.currency-cell {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 1600px) {
    .container-erp,
    .erp-content.container-erp {
        max-width: 1440px;
    }
}

@media (max-width: 1366px) {
    .container-erp,
    .erp-content.container-erp {
        max-width: 1240px;
        padding: 16px;
    }

    .erp-filter-grid,
    .erp-list-toolbar-form,
    .erp-card-header form[method="GET"] > .row,
    .erp-card-header form[method="GET"].d-flex,
    .erp-card-header form[method="GET"].row {
        grid-template-columns: repeat(4, minmax(150px, 1fr));
    }

    .erp-form-grid,
    .erp-form-grid-2,
    .vente-create .vente-grid,
    .vente-create .vente-grid-2,
    form .row.g-3:not(.erp-keep-row),
    form .row.g-2:not(.erp-keep-row) {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 1280px) {
    .container-erp,
    .erp-content.container-erp {
        max-width: calc(100vw - 32px);
    }

    .erp-filter-grid,
    .erp-list-toolbar-form,
    .erp-card-header form[method="GET"] > .row,
    .erp-card-header form[method="GET"].d-flex,
    .erp-card-header form[method="GET"].row {
        grid-template-columns: repeat(3, minmax(160px, 1fr));
    }
}

@media (max-width: 992px) {
    .container-erp,
    .erp-content.container-erp {
        max-width: none;
        padding: 14px;
    }

    .erp-page-header {
        grid-template-columns: 1fr;
    }

    .erp-page-header > :last-child:is(.btn, .d-flex, .btn-group),
    .erp-page-header .erp-page-actions {
        justify-content: flex-start;
    }

    .erp-form-grid,
    .erp-form-grid-2,
    .vente-create .vente-grid,
    .vente-create .vente-grid-2,
    form .row.g-3:not(.erp-keep-row),
    form .row.g-2:not(.erp-keep-row),
    .erp-filter-grid,
    .erp-list-toolbar-form,
    .erp-card-header form[method="GET"] > .row,
    .erp-card-header form[method="GET"].d-flex,
    .erp-card-header form[method="GET"].row {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    .container-erp,
    .erp-content.container-erp {
        padding: 12px;
    }

    .erp-form-grid,
    .erp-form-grid-2,
    .vente-create .vente-grid,
    .vente-create .vente-grid-2,
    form .row.g-3:not(.erp-keep-row),
    form .row.g-2:not(.erp-keep-row),
    .erp-filter-grid,
    .erp-list-toolbar-form,
    .erp-card-header form[method="GET"] > .row,
    .erp-card-header form[method="GET"].d-flex,
    .erp-card-header form[method="GET"].row {
        grid-template-columns: 1fr !important;
    }

    .erp-filter-actions,
    .erp-card-header form[method="GET"] .col-lg-auto,
    .erp-card-header form[method="GET"] .ms-lg-auto {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .erp-filter-actions .btn,
    .erp-card-header form[method="GET"] .btn {
        width: 100%;
    }

    .cargo-currency-filter__grid {
        grid-template-columns: 1fr;
    }
}

/* Final export polish: keeps export controls consistent after module overrides. */
.erp-list-toolbar .erp-export-panel,
.erp-auto-table-tools .erp-export-panel,
.erp-page-header .erp-export-panel,
.stock-actuel-tools .erp-export-panel,
.direction-actions .erp-export-panel {
    display: inline-flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.erp-list-toolbar .erp-export-suite,
.erp-auto-table-tools .erp-export-suite,
.erp-page-header .erp-export-suite,
.stock-actuel-tools .erp-export-suite,
.direction-actions .erp-export-suite {
    display: inline-flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.erp-list-toolbar .erp-export-btn,
.erp-auto-table-tools .erp-export-btn,
.erp-page-header .erp-export-btn,
.stock-actuel-tools .erp-export-btn,
.direction-actions .erp-export-btn,
a.erp-export-btn,
button.erp-export-btn {
    min-height: 38px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 0 13px !important;
    border-radius: 9px !important;
    font-size: .84rem !important;
    font-weight: 850 !important;
    text-decoration: none !important;
    white-space: nowrap !important;
}

.erp-list-toolbar .erp-export-btn i,
.erp-auto-table-tools .erp-export-btn i,
.erp-page-header .erp-export-btn i,
.stock-actuel-tools .erp-export-btn i,
.direction-actions .erp-export-btn i,
a.erp-export-btn i,
button.erp-export-btn i {
    margin: 0 !important;
}
