/* ==========================================================================
   EVOC AIR - STYLES GLOBAUX & THEME ERGONOMIQUE APAISANT (ANTI-REFLETS)
   Design soigné, contrasté, conçu pour un usage prolongé sans fatigue oculaire.
   ========================================================================== */

:root {
    /* Fond général légèrement teinté pour casser le blanc agressif */
    --bg-main: #eef2f6;
    --bg-surface: #ffffff;
    --bg-surface-hover: #e2e8f0;
    --bg-surface-alt: #f1f5f9;
    --bg-surface-subtle: #f8fafc;

    --border-color: #cbd5e1;
    --border-light: #e2e8f0;
    --border-focus: #4f46e5;

    --text-main: #0f172a;
    --text-body: #1e293b;
    --text-muted: #475569;
    --text-light: #64748b;

    --primary: #4338ca;
    --primary-light: #4f46e5;
    --primary-dark: #3730a3;
    --primary-bg: #e0e7ff;
    --primary-border: #c7d2fe;

    --success: #059669;
    --success-bg: #d1fae5;
    --success-text: #064e3b;

    --warning: #d97706;
    --warning-bg: #fef3c7;
    --warning-text: #78350f;

    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --danger-text: #7f1d1d;

    --info: #0284c7;
    --info-bg: #e0f2fe;
    --info-text: #075985;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 24px -3px rgba(15, 23, 42, 0.1), 0 4px 8px -2px rgba(15, 23, 42, 0.05);
    --shadow-xl: 0 20px 32px -4px rgba(15, 23, 42, 0.15);

    --sidebar-width: 260px;
    --header-height: 68px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-body);
    line-height: 1.5;
    font-size: 13.5px;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* ==========================================================================
   STRUCTURE SPA & NAVIGATION
   ========================================================================== */

#app-root {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: #f8fafc;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.brand-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 22px;
    border-bottom: 1px solid var(--border-color);
    background: #ffffff;
    gap: 12px;
}

.brand-logo-icon {
    width: 38px;
    height: 38px;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand-info h1 {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.3px;
}

.brand-info span {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.nav-menu {
    flex: 1;
    padding: 14px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section {
    display: flex;
    flex-direction: column;
    margin-bottom: 2px;
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 800;
    color: var(--text-light);
    padding: 9px 12px 7px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    border-radius: var(--radius-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-section-title:hover {
    color: var(--primary);
    background: #e2e8f0;
}

.nav-section-chevron {
    font-size: 10px;
    color: var(--text-light);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}

.nav-section-title:hover .nav-section-chevron {
    color: var(--primary);
}

.nav-section.collapsed .nav-section-chevron {
    transform: rotate(-90deg);
}

[dir="rtl"] .nav-section.collapsed .nav-section-chevron {
    transform: rotate(90deg);
}

.nav-section-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    max-height: 500px;
    opacity: 1;
}

.nav-section.collapsed .nav-section-items {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 14px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    transition: var(--transition);
    position: relative;
    cursor: pointer;
}

.nav-item:hover {
    color: var(--primary);
    background: #e2e8f0;
    transform: translateX(2px);
}

.nav-item.active {
    color: var(--primary-dark);
    background: var(--primary-bg);
    font-weight: 700;
    border: 1px solid var(--primary-border);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 6px;
    bottom: 6px;
    width: 4px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.badge-counter {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    background: #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: #cbd5e1;
    color: var(--text-main);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.user-details {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-weight: 700;
    font-size: 13.5px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-badge {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    background: #cbd5e1;
    color: var(--text-muted);
    text-transform: uppercase;
}

.user-role-badge.admin {
    background: var(--warning-bg);
    color: var(--warning-text);
}

/* MAIN WRAPPER */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-navbar {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 90;
    box-shadow: var(--shadow-sm);
}

.pos-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f1f5f9;
    padding: 7px 16px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-main);
}

.pos-dot {
    width: 9px;
    height: 9px;
    background: var(--success);
    border-radius: var(--radius-full);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.2);
}

.content-container {
    flex: 1;
    padding: 24px 28px;
}

/* ==========================================================================
   CARTES & COMPOSANTS
   ========================================================================== */

.card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body {
    padding: 20px;
}

/* BOUTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(67, 56, 202, 0.25);
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(67, 56, 202, 0.35);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f1f5f9;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #e2e8f0;
    border-color: var(--text-muted);
}

.btn-success {
    background: #059669;
    color: white;
}

.btn-danger {
    background: #dc2626;
    color: white;
}

.btn-warning {
    background: #d97706;
    color: white;
}

.btn-sm {
    padding: 5px 11px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 11px 22px;
    font-size: 14.5px;
    border-radius: var(--radius-md);
}

/* FORMULAIRES */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.form-control, .form-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-main);
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

/* TABLEAUX DE DONNEES */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    background: #f1f5f9;
    padding: 11px 16px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    vertical-align: middle;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: #f1f5f9;
}

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius-full);
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-secondary { background: #e2e8f0; color: #334155; }
.badge-primary { background: var(--primary-bg); color: var(--primary-dark); }

/* KPIS */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.kpi-icon.indigo { background: #e0e7ff; color: #4338ca; }
.kpi-icon.emerald { background: #d1fae5; color: #059669; }
.kpi-icon.amber { background: #fef3c7; color: #d97706; }
.kpi-icon.sky { background: #e0f2fe; color: #0284c7; }
.kpi-icon.rose { background: #fee2e2; color: #dc2626; }

.kpi-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.kpi-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ==========================================================================
   ONGLETS (TABS) DANS LES PARAMETRES
   ========================================================================== */

.settings-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
    padding-bottom: 2px;
}

.tab-btn {
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: var(--primary);
    background: #f1f5f9;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ==========================================================================
   MODALES & NOTIFICATIONS
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.96);
    transition: transform 0.2s ease;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.modal-backdrop.active .modal-content {
    transform: scale(1);
}

.modal-content.modal-lg { max-width: 850px; }
.modal-content.modal-xl { max-width: 1200px; }
.modal-content.modal-xxl { max-width: 1380px; width: 96vw; }

.modal-header {
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-light);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-body {
    padding: 22px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border-light);
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

/* TOASTS */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    min-width: 300px;
    max-width: 420px;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastSlideIn 0.25s ease-out;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

@keyframes toastSlideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.view-enter {
    animation: viewFadeIn 0.2s ease-out;
}

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

/* ==========================================================================
   POSTE DE VENTE & FACTURATION COMMERCIALE (ELECTROMENAGER)
   ========================================================================== */

.sales-desk-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.doc-type-selector-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.doc-type-pill {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: #ffffff;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.doc-type-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-surface-alt);
}

.doc-type-pill.active {
    background: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary-dark);
    box-shadow: 0 0 0 2px var(--primary-border);
}

.doc-type-pill i {
    font-size: 14px;
}

.commercial-table {
    width: 100%;
    border-collapse: collapse;
}

.commercial-table th {
    background: #f1f5f9;
    padding: 12px 14px;
    font-size: 11.5px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
}

.commercial-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    vertical-align: middle;
}

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

.line-qty-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: #ffffff;
    overflow: hidden;
}

.line-qty-stepper button {
    border: none;
    background: #f1f5f9;
    padding: 4px 9px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-main);
    transition: var(--transition);
}

.line-qty-stepper button:hover {
    background: #e2e8f0;
}

.line-qty-stepper span {
    min-width: 32px;
    text-align: center;
    font-weight: 800;
    font-size: 13px;
}

.sales-summary-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.sales-grand-total {
    font-size: 26px;
    font-weight: 900;
    color: var(--primary);
    letter-spacing: -0.5px;
}

/* RECHERCHE INSTANTANEE D'APPAREIL ELECTROMENAGER */
.product-search-wrapper {
    position: relative;
}

.product-search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 2500;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 15px 35px -5px rgba(15, 23, 42, 0.32);
    max-height: 290px;
    overflow-y: auto;
    display: none;
}

.card-overflow-visible {
    overflow: visible !important;
}

.product-search-dropdown.active {
    display: block;
}

.product-search-item {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.product-search-item:last-child {
    border-bottom: none;
}

.product-search-item:hover,
.product-search-item.highlighted {
    background: var(--bg-surface-alt);
}

/* ==========================================================================
   ETIQUETTES (PREVIEW)
   ========================================================================== */

.labels-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px;
    background: #cbd5e1;
    border-radius: var(--radius-lg);
    justify-content: center;
}

.product-label-card {
    background: #ffffff;
    border: 1px dashed #94a3b8;
    border-radius: 6px;
    padding: 10px;
    width: 250px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.label-company-name {
    font-size: 10px;
    font-weight: 800;
    color: #475569;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.label-product-name {
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    margin: 4px 0;
    height: 28px;
    overflow: hidden;
}

.label-cash-price {
    font-size: 15px;
    font-weight: 900;
    color: var(--primary);
    background: #f1f5f9;
    padding: 3px 6px;
    border-radius: 4px;
    margin-bottom: 6px;
    display: inline-block;
}

.label-facilities-box {
    border-top: 1px solid #e2e8f0;
    padding-top: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 10.5px;
    font-weight: 600;
    color: #334155;
}

.label-barcode-box {
    margin-top: 6px;
}

/* ==========================================================================
   SELECTEUR DE LANGUE (LANGUAGE SWITCHER)
   ========================================================================== */
.lang-switcher {
    display: inline-flex;
    align-items: center;
    background: #e2e8f0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 2px;
    gap: 2px;
}

.lang-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 3px 10px;
    font-size: 11.5px;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1.2;
}

.lang-btn:hover {
    color: var(--text-main);
}

.lang-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   SUPPORT MULTILINGUE ARABE & RTL (RIGHT-TO-LEFT)
   ========================================================================== */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] body,
[dir="rtl"] button,
[dir="rtl"] input,
[dir="rtl"] select,
[dir="rtl"] textarea {
    font-family: 'Cairo', 'Plus Jakarta Sans', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Sidebar en mode RTL (ancrée à droite) */
[dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--border-color);
}

/* Contenu principal en mode RTL (décalage à gauche) */
[dir="rtl"] .main-wrapper {
    margin-left: 0;
    margin-right: var(--sidebar-width);
}

/* Indicateur actif des liens de la navigation */
[dir="rtl"] .nav-item:hover {
    transform: translateX(-2px);
}

[dir="rtl"] .nav-item.active::before {
    left: auto;
    right: -12px;
    border-radius: 4px 0 0 4px;
}

/* Badge de compteur (ex: réceptions en attente) */
[dir="rtl"] .badge-counter {
    margin-left: 0;
    margin-right: auto;
}

/* Notifications Toast en mode RTL */
[dir="rtl"] #toast-container {
    right: auto;
    left: 20px;
}

[dir="rtl"] .toast {
    border-left: 1px solid var(--border-color);
    border-right: 4px solid var(--primary);
    animation: toastSlideInRtl 0.25s ease-out;
}

[dir="rtl"] .toast.toast-success { border-right-color: var(--success); }
[dir="rtl"] .toast.toast-error { border-right-color: var(--danger); }
[dir="rtl"] .toast.toast-warning { border-right-color: var(--warning); }

@keyframes toastSlideInRtl {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Sélecteur de contexte POS dans la barre supérieure */
[dir="rtl"] #pos-context-selector {
    margin-left: 0 !important;
    margin-right: 8px !important;
}

/* Isolation directionnelle stricte pour les montants, dates, téléphones et chiffres en RTL */
[dir="rtl"] [dir="ltr"],
[dir="rtl"] bdi,
[dir="rtl"] .amount-ltr,
[dir="rtl"] .money-ltr,
[dir="rtl"] .kpi-number-ltr {
    direction: ltr !important;
    unicode-bidi: isolate !important;
    display: inline-block;
    white-space: nowrap;
}

/* Alignement des tableaux */
[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right;
}

[dir="rtl"] .table th[style*="text-align:right"],
[dir="rtl"] .table td[style*="text-align:right"],
[dir="rtl"] .table th.text-end,
[dir="rtl"] .table td.text-end {
    text-align: left !important;
}

/* Formulaires & icônes */
[dir="rtl"] .form-label i {
    margin-right: 0 !important;
    margin-left: 6px !important;
}

@media (max-width: 992px) {
    .versement-grid-layout {
        grid-template-columns: 1fr !important;
    }
}

/* ==========================================================================
   MODULES DE GESTION & COMPOSANTS GENERIQUES (STYLE ENTERPRISE / DESKTOP)
   Factorisation générique réutilisable pour Bordereaux, Balayage, etc.
   ========================================================================== */

/* Conteneur principal de module */
.module-desktop-container,
.bordereau-page-container,
.balayage-page-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Barre d'onglets supérieurs moderne */
.module-tab-strip,
.bordereau-tab-strip,
.balayage-tab-strip {
    display: flex;
    gap: 6px;
    padding: 0;
    margin-bottom: 12px;
    border-bottom: 2px solid var(--border-light, #e2e8f0);
}

.module-tab-btn,
.bordereau-tab-btn,
.balayage-tab-btn {
    background: transparent;
    color: var(--text-muted, #64748b);
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 8px 8px 0 0;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.module-tab-btn:hover,
.bordereau-tab-btn:hover,
.balayage-tab-btn:hover {
    background: #eef2ff;
    color: var(--primary, #4338ca);
}

.module-tab-btn.active,
.bordereau-tab-btn.active,
.balayage-tab-btn.active {
    background: #ffffff;
    color: var(--primary, #4338ca);
    border-bottom: 3px solid var(--primary, #4338ca);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

/* Carte de contenu du module */
.module-content-card,
.bordereau-content-card,
.balayage-content-card {
    background: #ffffff;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: var(--radius-lg, 12px);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    min-height: 72vh;
    overflow: hidden;
}

/* Barres d'outils et de filtres */
.module-toolbar,
.bordereau-toolbar,
.balayage-toolbar,
.balayage-details-top-bar {
    background: #f8fafc;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-light, #e2e8f0);
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.module-filter-group,
.bordereau-filter-group,
.balayage-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.module-label,
.bord-label,
.bal-label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-muted, #475569);
    margin: 0;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.module-input-date,
.module-input-text,
.module-select,
.bord-input-date,
.bord-input-text,
.bord-select,
.bal-input-date,
.bal-input-text {
    height: 34px;
    padding: 4px 10px;
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: var(--radius-md, 8px);
    font-size: 12.5px;
    font-weight: 600;
    background: #ffffff;
    color: #0f172a;
    outline: none;
    transition: var(--transition);
}

.module-input-date:focus,
.module-input-text:focus,
.module-select:focus,
.bord-input-date:focus,
.bord-input-text:focus,
.bord-select:focus,
.bal-input-date:focus,
.bal-input-text:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 56, 202, 0.15);
}

/* Boutons personnalisés des modules (fallback) */
.bord-btn-primary,
.bord-btn-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 700;
    border-radius: var(--radius-md, 8px);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.bord-btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: #ffffff;
    box-shadow: 0 2px 5px rgba(67, 56, 202, 0.25);
}

.bord-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(67, 56, 202, 0.35);
}

.bord-btn-action {
    background: #f1f5f9;
    border-color: var(--border-color, #cbd5e1);
    color: var(--text-main, #0f172a);
}

.bord-btn-action:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

/* Grilles de données (Data Grids) */
.module-grid-wrapper,
.bordereau-grid-wrapper,
.balayage-grid-wrapper,
.balayage-details-grid-wrapper {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    min-height: 400px;
    max-height: calc(100vh - 280px);
    background: #ffffff;
}

.module-grid-table,
.bordereau-grid-table,
.balayage-grid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.module-grid-table thead th,
.bordereau-grid-table thead th,
.balayage-grid-table thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 800;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 10px 12px;
    border-top: none;
    border-left: none;
    border-right: none;
    border-bottom: 2px solid #e2e8f0;
    text-align: left;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 5;
    user-select: none;
}

.module-grid-table thead th .grid-icons,
.bordereau-grid-table thead th .grid-icons,
.balayage-grid-table thead th .grid-icons {
    font-size: 10px;
    opacity: 0.6;
    margin-left: 4px;
    color: #64748b;
}

.module-grid-table tbody td,
.bordereau-grid-table tbody td,
.balayage-grid-table tbody td {
    padding: 8px 12px;
    border-top: none;
    border-left: none;
    border-right: none;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    white-space: nowrap;
}

.module-grid-table tbody tr:nth-child(even),
.bordereau-grid-table tbody tr:nth-child(even),
.balayage-grid-table tbody tr:nth-child(even) {
    background-color: #fafbfc;
}

.module-grid-table tbody tr.empty-grid-row td,
.bordereau-grid-table tbody tr.empty-grid-row td,
.balayage-grid-table tbody tr.empty-grid-row td {
    height: 28px;
    border-bottom-color: #f8fafc;
}

.module-grid-table tbody tr:hover:not(.empty-grid-row),
.bordereau-grid-table tbody tr:hover:not(.empty-grid-row),
.balayage-grid-table tbody tr:hover:not(.empty-grid-row) {
    background-color: #f1f5f9;
}

/* Alerte CCP répété (> 5 fois même date début) */
.bordereau-grid-table tbody tr.bord-row-highlight-red td,
tr.bord-row-highlight-red td {
    background-color: #fee2e2 !important;
    border-bottom-color: #fecaca !important;
}

.bordereau-grid-table tbody tr.bord-row-highlight-red:hover td,
tr.bord-row-highlight-red:hover td {
    background-color: #fecaca !important;
}

.module-grid-table tfoot .balayage-table-summary-row td {
    background: #f1f5f9;
    border-top: 2px solid #cbd5e1 !important;
    border-bottom: 2px solid #cbd5e1 !important;
}

/* Barre d'action inférieure */
.module-bottom-bar,
.bordereau-bottom-bar,
.balayage-bottom-bar {
    background: #f8fafc;
    padding: 12px 18px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

/* Disposition Split / Master-Detail à deux panneaux */
.module-split-container,
.balayage-details-split-container {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 290px);
    overflow: hidden;
}

.module-sidebar,
.balayage-files-sidebar {
    width: 320px;
    min-width: 280px;
    max-width: 360px;
    border-right: 1.5px solid #cbd5e1;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
}

.module-sidebar-header,
.balayage-files-header {
    padding: 10px 12px;
    background: #e2e8f0;
    border-bottom: 1px solid #cbd5e1;
}

.module-sidebar-list,
.balayage-files-list {
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 350px);
    background: #ffffff;
}

.module-sidebar-item,
.balayage-file-item {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    font-size: 11.5px;
    font-weight: 600;
    font-family: monospace;
    color: #334155;
    transition: background 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.module-sidebar-item:hover,
.balayage-file-item:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.module-sidebar-item.selected,
.balayage-file-item.selected {
    background: #e0e7ff;
    color: var(--primary);
    font-weight: 700;
    border-left: 3px solid var(--primary);
}

.module-split-content,
.balayage-details-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    min-width: 0;
}

/* Pastilles / Chips Radios de statut */
.chips-filter-bar,
.balayage-status-chips-bar {
    padding: 6px 14px;
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.chip-radio-label,
.bal-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 700;
    color: #475569;
    cursor: pointer;
    padding: 3px 10px;
    border-radius: 6px;
    transition: all 0.15s ease;
    user-select: none;
}

.chip-radio-label input[type="radio"],
.bal-radio-label input[type="radio"] {
    cursor: pointer;
    accent-color: var(--primary);
}

.chip-radio-label.active,
.bal-radio-label.active {
    background: #f1f5f9;
    color: #0f172a;
}

.chip-radio-label.active-success,
.bal-radio-label.active-success { background: var(--success-bg); color: var(--success-text); }
.chip-radio-label.active-danger,
.bal-radio-label.active-danger { background: var(--danger-bg); color: var(--danger-text); }
.chip-radio-label.active-warning,
.bal-radio-label.active-warning { background: var(--warning-bg); color: var(--warning-text); }
.chip-radio-label.active-dark,
.bal-radio-label.active-dark { background: #334155; color: #ffffff; }

/* Badges / Pilules KPI du pied de page */
.kpi-pills-container,
.balayage-kpi-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kpi-pill,
.balayage-kpi-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.2px;
}

.kpi-pill .kpi-label,
.balayage-kpi-pill .kpi-label {
    font-size: 12.5px;
    font-weight: 700;
    color: #334155;
}

.kpi-pill.kpi-total,
.balayage-kpi-pill.kpi-total {
    background: #f1f5f9;
    border: 1.5px solid #94a3b8;
}

.kpi-pill.kpi-total .kpi-value,
.balayage-kpi-pill.kpi-total .kpi-value {
    background: linear-gradient(90deg, #1d4ed8, #2563eb);
    color: #ffffff;
    padding: 2px 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
}

.kpi-pill.kpi-payes,
.balayage-kpi-pill.kpi-payes {
    background: #f1f5f9;
    border: 1.5px solid #86efac;
}

.kpi-pill.kpi-payes .kpi-value,
.balayage-kpi-pill.kpi-payes .kpi-value {
    background: linear-gradient(90deg, #15803d, #22c55e);
    color: #ffffff;
    padding: 2px 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
}

.kpi-pill.kpi-impayes,
.balayage-kpi-pill.kpi-impayes {
    background: #f1f5f9;
    border: 1.5px solid #fca5a5;
}

.kpi-pill.kpi-impayes .kpi-value,
.balayage-kpi-pill.kpi-impayes .kpi-value {
    background: linear-gradient(90deg, #b91c1c, #ef4444);
    color: #ffffff;
    padding: 2px 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
}

.kpi-pill.kpi-ttaxes,
.balayage-kpi-pill.kpi-ttaxes {
    background: #f1f5f9;
    border: 1.5px solid #fed7aa;
}

.kpi-pill.kpi-ttaxes .kpi-value,
.balayage-kpi-pill.kpi-ttaxes .kpi-value {
    background: linear-gradient(90deg, #c2410c, #ea580c);
    color: #ffffff;
    padding: 2px 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 14px;
}

.kpi-pill.kpi-taux,
.balayage-kpi-pill.kpi-taux {
    background: #f0fdfa;
    border: 1.5px solid #5eead4;
    color: #0f766e;
    font-size: 14px;
    font-weight: 900;
}

/* ==========================================================================
   MODULE ÉTIQUETTES DE PRIX PERSONNALISABLES (A4 ET THERMIQUE)
   ========================================================================== */
.labels-page-container {
    padding: 0;
}

.labels-toolbar-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.labels-settings-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.labels-toggles-strip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.labels-toggle-item {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}

.labels-toggle-item input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Planche A4 Visual Preview */
.labels-a4-preview-wrapper {
    background: #475569;
    padding: 30px 20px;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    overflow-x: auto;
}

.labels-a4-sheet {
    background: #ffffff;
    width: 210mm;
    min-height: 297mm;
    box-shadow: 0 10px 25px rgba(0,0,0,0.35), 0 2px 6px rgba(0,0,0,0.2);
    box-sizing: border-box;
    padding: 10mm;
    position: relative;
    page-break-after: always;
}

/* Grilles */
.labels-a4-sheet.grid-2x2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 132mm;
    gap: 10mm;
}

.labels-a4-sheet.grid-2x3 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 86mm;
    gap: 8mm;
}

.labels-a4-sheet.grid-2x4 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 64mm;
    gap: 6mm;
}

.labels-a4-sheet.grid-3x4 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 64mm;
    gap: 6mm;
}

.labels-a4-sheet.grid-3x7 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 36mm;
    gap: 4mm;
}

/* Carte Étiquette de Prix */
.price-tag-card {
    border: 1.5px solid #1e293b;
    border-radius: 14px;
    padding: 14px 16px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    box-sizing: border-box;
    position: relative;
    transition: transform 0.15s, box-shadow 0.15s;
    height: 100%;
    color: #0f172a;
}

.price-tag-card:hover .tag-hover-actions {
    opacity: 1;
    visibility: visible;
}

.tag-hover-actions {
    position: absolute;
    top: 6px;
    right: 6px;
    display: flex;
    gap: 4px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    background: rgba(255,255,255,0.95);
    padding: 3px 6px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 10;
}

.tag-header-title {
    font-size: 18px;
    font-weight: 900;
    font-style: italic;
    text-transform: uppercase;
    color: #000000;
    text-align: center;
    line-height: 1.25;
    margin-bottom: 8px;
}

.tag-header-divider {
    height: 1.5px;
    background: #94a3b8;
    margin-bottom: 12px;
    width: 100%;
}

.tag-facility-row {
    display: flex;
    align-items: baseline;
    margin-bottom: 8px;
    line-height: 1.2;
}

.tag-facility-label {
    font-size: 13px;
    font-style: italic;
    font-weight: 700;
    color: #000000;
    min-width: 50px;
    white-space: nowrap;
    flex-shrink: 0;
}

.tag-facility-value {
    font-size: 18px;
    font-weight: 900;
    color: #000000;
    margin-left: 12px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.tag-facility-value .tag-multiplier {
    font-size: 16px;
    font-weight: 700;
}

.tag-facility-value .tag-duration {
    font-size: 17px;
    font-weight: 800;
}

.tag-cash-box {
    margin: 8px 0;
    padding: 6px 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tag-barcode-box {
    text-align: center;
    margin-top: auto;
    padding-top: 6px;
}

.tag-barcode-box svg {
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   MODULE TABLEAU DE BORD COMMERCIAL MODERNE & LEGER
   ========================================================================== */

.dash-container {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding-bottom: 30px;
}

/* 1. Header Banner & Quick Context */
.dash-hero-banner {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 16px;
}

.dash-hero-title-group h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.4px;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dash-hero-title-group p {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

.dash-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    color: #065f46;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

.dash-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
    animation: dashPulse 2s infinite;
}

@keyframes dashPulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.dash-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* 2. Quick Actions Ribbon */
.dash-quick-ribbon {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 2px;
}

.dash-quick-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-body);
    font-size: 12.5px;
    font-weight: 700;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.dash-quick-btn:hover {
    border-color: var(--primary-border);
    background: var(--bg-surface-subtle);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dash-quick-btn i {
    font-size: 14px;
}

.dash-quick-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.dash-quick-btn.primary:hover {
    background: var(--primary-light);
    color: #ffffff;
}

/* 3. Modern KPI Cards Grid */
.dash-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 1200px) {
    .dash-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .dash-kpi-grid {
        grid-template-columns: 1fr;
    }
}

.dash-kpi-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.dash-kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.dash-kpi-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.dash-kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.dash-kpi-icon.emerald { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.dash-kpi-icon.indigo { background: #eef2ff; color: #4f46e5; border: 1px solid #c7d2fe; }
.dash-kpi-icon.sky { background: #f0f9ff; color: #0284c7; border: 1px solid #bae6fd; }
.dash-kpi-icon.amber { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.dash-kpi-icon.rose { background: #fff1f2; color: #e11d48; border: 1px solid #fecdd3; }

.dash-kpi-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.dash-kpi-badge.neutral { background: #f1f5f9; color: #475569; }
.dash-kpi-badge.success { background: #dcfce7; color: #15803d; }
.dash-kpi-badge.warning { background: #fef3c7; color: #b45309; }
.dash-kpi-badge.danger { background: #ffe4e6; color: #be123c; }

.dash-kpi-main {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.dash-kpi-value {
    font-size: 21px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.5px;
    line-height: 1.2;
}

.dash-kpi-label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
}

.dash-kpi-footer {
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
    font-size: 11.5px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 4. Analytics Section (Chart & Donut) */
.dash-analytics-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .dash-analytics-grid {
        grid-template-columns: 1fr;
    }
}

.dash-chart-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dash-chart-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.dash-chart-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dash-chart-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

.dash-toggle-group {
    display: inline-flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
    gap: 2px;
}

.dash-toggle-btn {
    border: none;
    background: transparent;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.dash-toggle-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.dash-chart-body {
    padding: 16px 20px;
    position: relative;
    height: 290px;
    width: 100%;
}

.dash-breakdown-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dash-breakdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dash-breakdown-header h4 {
    font-size: 14.5px;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
}

.dash-progress-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dash-progress-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
}

.dash-progress-bar-wrap {
    height: 8px;
    background: #f1f5f9;
    border-radius: var(--radius-full);
    overflow: hidden;
    display: flex;
}

.dash-progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.dash-progress-fill.indigo { background: #4f46e5; }
.dash-progress-fill.emerald { background: #10b981; }
.dash-progress-fill.sky { background: #0284c7; }

/* 5. Operations Two-Column Grid */
.dash-ops-grid {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 20px;
}

@media (max-width: 900px) {
    .dash-ops-grid {
        grid-template-columns: 1fr;
    }
}

.dash-table-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dash-table-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
}

.dash-table-title {
    font-size: 14.5px;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.dash-table th {
    padding: 10px 16px;
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}

.dash-table td {
    padding: 11px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-body);
    vertical-align: middle;
}

.dash-table tr:last-child td {
    border-bottom: none;
}

.dash-table tr:hover td {
    background: #f8fafc;
}

.dash-client-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dash-avatar-mini {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #475569;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}

.dash-table-footer {
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.dash-stock-badge-critique {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dash-stock-badge-low {
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fde68a;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 800;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* RTL Directional Isolation & Layout for Dashboard */
[dir="rtl"] .dash-container {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .dash-hero-title-group h2,
[dir="rtl"] .dash-chart-title,
[dir="rtl"] .dash-table-title,
[dir="rtl"] .dash-breakdown-header h4 {
    direction: rtl;
}

[dir="rtl"] .dash-kpi-value bdi,
[dir="rtl"] .dash-kpi-main bdi,
[dir="rtl"] .dash-kpi-footer bdi,
[dir="rtl"] .dash-progress-labels bdi,
[dir="rtl"] .dash-table td bdi,
[dir="rtl"] .dash-stock-badge-critique bdi,
[dir="rtl"] .dash-stock-badge-low bdi,
[dir="rtl"] .kpi-number-ltr,
[dir="rtl"] bdi {
    direction: ltr !important;
    unicode-bidi: isolate !important;
    display: inline-block;
    white-space: nowrap;
}

[dir="rtl"] .dash-table th {
    text-align: right;
}

[dir="rtl"] .dash-table th.text-end,
[dir="rtl"] .dash-table td.text-end,
[dir="rtl"] .dash-table th[style*="text-align:right"],
[dir="rtl"] .dash-table td[style*="text-align:right"] {
    text-align: left !important;
}

[dir="rtl"] .dash-table th.text-center,
[dir="rtl"] .dash-table td.text-center,
[dir="rtl"] .dash-table th[style*="text-align:center"],
[dir="rtl"] .dash-table td[style*="text-align:center"] {
    text-align: center !important;
}

[dir="rtl"] .dash-kpi-footer {
    display: flex;
    justify-content: space-between;
}

[dir="rtl"] .dash-kpi-card-top {
    display: flex;
    justify-content: space-between;
}

/* RTL Isolation for Cashier & Facility Sale */
[dir="rtl"] .commercial-table th,
[dir="rtl"] .fac-table th {
    text-align: right;
}

[dir="rtl"] .commercial-table th[style*="text-align:right"],
[dir="rtl"] .commercial-table td[style*="text-align:right"],
[dir="rtl"] .fac-table th[style*="text-align:right"],
[dir="rtl"] .fac-table td[style*="text-align:right"] {
    text-align: left !important;
}

[dir="rtl"] .commercial-table th[style*="text-align:center"],
[dir="rtl"] .commercial-table td[style*="text-align:center"],
[dir="rtl"] .fac-table th[style*="text-align:center"],
[dir="rtl"] .fac-table td[style*="text-align:center"] {
    text-align: center !important;
}

[dir="rtl"] .sales-summary-card .total-row,
[dir="rtl"] #cash-change-box {
    display: flex;
    justify-content: space-between;
}

[dir="rtl"] .fac-box-header,
[dir="rtl"] .fac-action-bar {
    display: flex;
    justify-content: space-between;
}








