
/* ==========================================================================
   KARIM MOTORS — DESIGN SYSTEM "EXECUTIVE LIGHT & ERGONOMIC"
   Thème Clair Lumineux par défaut + Support Mode Sombre
   ========================================================================== */

:root {
    /* Palette Claire (Défaut) — Élégante, Propre, Lumineuse */
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: #ffffff;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --border-highlight: #3b82f6;

    /* Couleurs de marque Karim Motors */
    --primary: #2563eb;
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    --primary-hover: #1d4ed8;
    --primary-glow: rgba(37, 99, 235, 0.2);
    --primary-soft: #eff6ff;

    /* Accents Métier */
    --accent-red: #e11d48;
    --accent-red-soft: #ffe4e6;
    --accent-blue: #2563eb;
    --accent-blue-soft: #dbeafe;
    --accent-indigo: #4f46e5;
    --accent-indigo-soft: #e0e7ff;
    --accent-emerald: #059669;
    --accent-emerald-soft: #dcfce7;
    --accent-amber: #d97706;
    --accent-amber-soft: #fef3c7;
    --accent-slate: #64748b;

    /* Typographie */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    /* Rayons & Arrondis */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Ombres Modernes & Subtiles */
    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    --font-heading: 'Plus Jakarta Sans', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* ==========================================================================
   SUPPORT DU MODE SOMBRE (TOGGLE OPTIONNEL)
   ========================================================================== */
[data-theme="dark"] {
    --bg-main: #0b0f19;
    --bg-surface: #131a29;
    --bg-card: #182234;
    --bg-card-hover: #1f2b42;
    --bg-input: #0e1524;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.05);
    --border-highlight: rgba(37, 99, 235, 0.4);

    --primary: #3b82f6;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --primary-hover: #60a5fa;
    --primary-glow: rgba(59, 130, 246, 0.35);
    --primary-soft: rgba(59, 130, 246, 0.15);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-red-soft: rgba(225, 29, 72, 0.15);
    --accent-blue-soft: rgba(59, 130, 246, 0.15);
    --accent-emerald-soft: rgba(16, 185, 129, 0.15);
    --accent-amber-soft: rgba(245, 158, 11, 0.15);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   RESET & STRUCTURE
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.25s ease, color 0.25s ease;
}

/* ==========================================================================
   NAVBAR & EN-TÊTE
   ========================================================================== */
.km-navbar {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-xs);
    transition: all 0.2s ease;
}

.km-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: var(--text-primary);
}

.km-brand-logo {
    width: 42px;
    height: 42px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.km-brand:hover .km-brand-logo {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 16px var(--primary-glow);
}

.km-brand-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.3rem;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: 1.1;
}

.km-brand-name span {
    color: var(--primary);
    margin-left: 2px;
}

.km-brand-tagline {
    font-size: 0.68rem;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 2px;
}

.km-nav-menu {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    list-style: none;
}

.km-nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.km-nav-link i {
    font-size: 1.05rem;
    color: var(--text-muted);
    transition: color 0.15s ease;
}

.km-nav-link:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.km-nav-link:hover i {
    color: var(--primary);
}

.km-nav-link.active {
    color: var(--primary);
    background: var(--primary-soft);
    font-weight: 700;
}

.km-nav-link.active i {
    color: var(--primary);
}

/* User pill & Action buttons */
.km-user-pill {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--bg-card);
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
}

.km-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.km-user-name {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.km-user-role-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-full);
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.km-logout-btn {
    color: var(--text-muted);
    font-size: 1.15rem;
    transition: all 0.2s ease;
    text-decoration: none;
    margin-left: 0.2rem;
    display: flex;
    align-items: center;
}

.km-logout-btn:hover {
    color: var(--accent-red);
    transform: scale(1.1);
}

/* Bouton bascule de thème (Clair / Sombre) */
.km-theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-xs);
}

.km-theme-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
    transform: rotate(15deg);
}

/* ==========================================================================
   ZONE PRINCIPALE (CONTAINER)
   ========================================================================== */
.km-main {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
    position: relative;
    z-index: 1;
}

/* ==========================================================================
   MESSAGES FLASH (ALERTS)
   ========================================================================== */
.message {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 0.92rem;
    box-shadow: var(--shadow-sm);
    animation: slideDown 0.3s ease;
}

.message.success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.message.error {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #9f1239;
}

.message.warning {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
}

.message.info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   EN-TÊTE DE PAGE (PAGE HEADER)
   ========================================================================== */
.km-page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.km-page-title {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.km-page-subtitle {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-top: 0.3rem;
    font-weight: 500;
}

/* ==========================================================================
   CARTES KPIs / STATISTIQUES
   ========================================================================== */
.km-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.km-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.35rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

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

.km-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
}

.km-stat-value {
    font-family: var(--font-heading);
    font-size: 1.85rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.km-stat-icon-wrapper {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.45rem;
    flex-shrink: 0;
}

.km-stat-icon-red {
    background: var(--accent-red-soft);
    color: var(--accent-red);
}

.km-stat-icon-blue {
    background: var(--accent-blue-soft);
    color: var(--accent-blue);
}

.km-stat-icon-emerald {
    background: var(--accent-emerald-soft);
    color: var(--accent-emerald);
}

.km-stat-icon-purple {
    background: var(--accent-indigo-soft);
    color: var(--accent-indigo);
}

/* ==========================================================================
   BOUTONS MODERNES
   ========================================================================== */
.km-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    font-family: var(--font-heading);
    font-size: 0.88rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.km-btn-primary {
    background: var(--primary-gradient);
    color: #fff !important;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.km-btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 6px 18px var(--primary-glow);
    transform: translateY(-1px);
}

.km-btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
}

.km-btn-secondary:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: #cbd5e1;
}

.km-btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

.km-btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    transition: all 0.15s ease;
    text-decoration: none;
    box-shadow: var(--shadow-xs);
}

.km-btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.km-btn-icon.view:hover {
    color: var(--accent-blue);
    border-color: var(--accent-blue);
    background: var(--accent-blue-soft);
}

.km-btn-icon.edit:hover {
    color: var(--accent-amber);
    border-color: var(--accent-amber);
    background: var(--accent-amber-soft);
}

.km-btn-icon.delete:hover {
    color: var(--accent-red);
    border-color: var(--accent-red);
    background: var(--accent-red-soft);
}

/* ==========================================================================
   FILTRES & FORMULAIRES DE RECHERCHE
   ========================================================================== */
.km-filter-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.km-filter-form {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.km-search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.km-search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
}

.km-input,
.km-select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.65rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.92rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-xs);
}

.km-search-box .km-input {
    padding-left: 2.75rem;
}

.km-input:focus,
.km-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.km-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ==========================================================================
   TABLEAUX DE DONNÉES (TABLES)
   ========================================================================== */
.km-table-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.km-table-responsive {
    overflow-x: auto;
    width: 100%;
}

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

.km-table th {
    background: var(--bg-main);
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.95rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.km-table th a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.km-table th a:hover {
    color: var(--primary);
}

.km-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    font-size: 0.92rem;
    color: var(--text-primary);
    transition: background-color 0.15s ease;
}

.km-table tr:hover td {
    background-color: var(--bg-card-hover);
}

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

/* ==========================================================================
   BADGES & PILULES D'ÉTAT
   ========================================================================== */
.km-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.28rem 0.7rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.km-badge-admin {
    background: #ffe4e6;
    color: #be123c;
    border: 1px solid #fecdd3;
}

.km-badge-manager {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.km-badge-commercial {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.km-badge-mechanic {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.km-badge-user {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
}

[data-theme="dark"] .km-badge-admin {
    background: rgba(225, 29, 72, 0.2);
    color: #fda4af;
    border-color: rgba(225, 29, 72, 0.35);
}

[data-theme="dark"] .km-badge-manager {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.35);
}

[data-theme="dark"] .km-badge-commercial {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.35);
}

[data-theme="dark"] .km-badge-mechanic {
    background: rgba(245, 158, 11, 0.2);
    color: #fde68a;
    border-color: rgba(245, 158, 11, 0.35);
}

[data-theme="dark"] .km-badge-user {
    background: rgba(148, 163, 184, 0.2);
    color: #cbd5e1;
    border-color: rgba(148, 163, 184, 0.35);
}

/* ==========================================================================
   PAGINATION
   ========================================================================== */
.km-pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.15rem 1.5rem;
    background: var(--bg-main);
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.km-pagination-counter {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.km-paginator-list {
    display: flex;
    list-style: none;
    gap: 0.4rem;
    align-items: center;
}

.km-paginator-list li a,
.km-paginator-list li span {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-decoration: none;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: all 0.15s ease;
    font-weight: 600;
}

.km-paginator-list li a:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary);
}

.km-paginator-list li.active a,
.km-paginator-list li.active span {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 700;
}

.km-paginator-list li.disabled span {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ==========================================================================
   CARTES DE FORMULAIRE & PAGES DE DÉTAIL
   ========================================================================== */
.km-form-container {
    max-width: 860px;
    margin: 0 auto;
}

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

.km-card-header {
    padding: 1.35rem 1.75rem;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.km-card-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.km-card-body {
    padding: 2rem;
}

.km-form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.35rem;
}

.km-form-col-full {
    grid-column: span 2;
}

.km-form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.km-form-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.km-form-label .required-star {
    color: var(--accent-red);
}

.km-form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.km-error-message {
    color: var(--accent-red);
    font-size: 0.78rem;
    margin-top: 0.25rem;
}

.km-form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* ==========================================================================
   PAGE DE CONNEXION MODERNE (LOGIN AUTH SPLIT-CARD & FULLSCREEN)
   ========================================================================== */
.km-body-auth {
    min-height: 100vh;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
}

.km-auth-fullscreen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.05) 0%, transparent 45%),
                radial-gradient(circle at 90% 80%, rgba(79, 70, 229, 0.05) 0%, transparent 45%),
                var(--bg-main);
    position: relative;
    width: 100%;
}
[data-theme="dark"] .km-auth-fullscreen {
    background: radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 50%),
                radial-gradient(circle at 90% 80%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
                #070b14;
}

.km-auth-topbar {
    padding: 1.25rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    z-index: 10;
}

.km-auth-topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.km-auth-topbar-title {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.km-auth-topbar-title span {
    color: var(--primary);
}

.km-auth-main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    z-index: 5;
}

.km-auth-footer {
    text-align: center;
    padding: 1.25rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
}

/* Split Card */
.km-auth-split-card {
    display: flex;
    width: 100%;
    max-width: 980px;
    min-height: 580px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.02);
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
}
[data-theme="dark"] .km-auth-split-card {
    background: #111827;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
}

/* Hero Branding Left */
.km-login-hero {
    flex: 1.15;
    padding: 3rem 2.5rem;
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 55%, #172554 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

.km-login-hero-glow {
    position: absolute;
    top: -120px;
    left: -120px;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.45) 0%, transparent 70%);
    border-radius: 50%;
    filter: blur(50px);
    pointer-events: none;
}

.km-login-hero-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 2;
}

.km-login-hero-logo {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.65rem;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.45);
    flex-shrink: 0;
}

.km-login-hero-title {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.km-login-hero-title span {
    color: #60a5fa;
}

.km-login-hero-sub {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 500;
    margin-top: 3px;
    letter-spacing: 0.02em;
}

.km-login-features {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    margin: 2rem 0;
    position: relative;
    z-index: 2;
}

.km-login-feature-item {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
}

.km-login-feat-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #60a5fa;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.km-login-feat-text {
    display: flex;
    flex-direction: column;
}

.km-login-feat-text strong {
    font-size: 0.88rem;
    color: #f8fafc;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.km-login-feat-text span {
    font-size: 0.77rem;
    color: #94a3b8;
    line-height: 1.35;
    margin-top: 2px;
}

.km-login-hero-footer {
    position: relative;
    z-index: 2;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.km-system-status {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.78rem;
    color: #cbd5e1;
    font-weight: 600;
}

.km-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: kmPulse 2s infinite;
}

@keyframes kmPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

/* Form Area Right */
.km-login-form-area {
    flex: 1;
    padding: 3.25rem 2.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: var(--bg-card);
}

.km-login-welcome-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-soft);
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    margin-bottom: 0.85rem;
    width: fit-content;
}

.km-login-form-title {
    font-family: var(--font-heading);
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.km-login-form-sub {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 0.4rem;
    margin-bottom: 1.85rem;
    line-height: 1.45;
}

.km-auth-form-fields {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.km-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.km-input-icon {
    position: absolute;
    inset-inline-start: 1.1rem;
    color: var(--text-muted);
    font-size: 1.15rem;
    pointer-events: none;
    z-index: 2;
    transition: color 0.2s ease;
}

.km-auth-input {
    padding-inline-start: 3rem !important;
    padding-inline-end: 3rem !important;
    height: 48px;
    font-size: 0.95rem;
    border-radius: 12px !important;
}

.km-input-wrapper:focus-within .km-input-icon {
    color: var(--primary);
}

.km-toggle-pwd-btn {
    position: absolute;
    inset-inline-end: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    font-size: 1.15rem;
    border-radius: 8px;
    transition: all 0.15s ease;
    z-index: 3;
}

.km-toggle-pwd-btn:hover {
    color: var(--primary);
    background: var(--primary-soft);
}

.km-input-highlight {
    animation: kmInputFlash 1.2s ease;
}

@keyframes kmInputFlash {
    0%, 100% { border-color: var(--border-color); }
    30%, 70% { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); background: var(--primary-soft); }
}

.km-auth-submit-btn {
    width: 100%;
    height: 48px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    margin-top: 0.5rem;
    box-shadow: 0 6px 18px var(--primary-glow);
    transition: all 0.25s ease;
}

.km-auth-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px var(--primary-glow);
}

.km-auth-quick-access {
    margin-top: 1.75rem;
    padding: 1rem 1.15rem;
    border-radius: 14px;
    background: var(--bg-main);
    border: 1px dashed var(--border-color);
}

.km-quick-access-title {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.55rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.km-quick-chips-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.km-quick-chip {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: var(--shadow-xs);
}

.km-quick-chip:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--primary-glow);
}

.km-auth-security-notice {
    margin-top: 1.35rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.45;
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
}

/* ==========================================================================
   IMPRESSION FORMELLE ET OFFICIELLE (PRINT STYLES)
   Masque systématiquement la barre d'en-tête, le profil utilisateur, la nav
   ========================================================================== */
/* ==========================================================================
   IMPRESSION FORMELLE ET OFFICIELLE (PRINT STYLES - ZERO CLIPPING PAYSAGE)
   Garantit que les côtés ne sont jamais coupés, avec largeur 100% fluide
   ========================================================================== */
@media print {
    @page {
        size: A4 landscape;
        margin: 8mm 10mm;
    }

    *, *::before, *::after {
        box-sizing: border-box !important;
        text-shadow: none !important;
    }

    /* 1. Masquage total de toute navigation, boutons et éléments d'interface web */
    .km-navbar,
    .km-navbar-brand,
    .km-navbar-menu,
    .km-navbar-actions,
    .km-header,
    .km-user-pill,
    .km-user-avatar,
    .km-user-name,
    .km-user-role-badge,
    .km-logout-btn,
    .km-actions,
    .km-company-switcher,
    .km-theme-toggle,
    .km-nav,
    .km-brand,
    .km-sidebar,
    .km-dropdown-menu,
    .no-print,
    .no-print-bar,
    .km-btn,
    .km-btn-icon,
    .km-btn-sm,
    .km-filter-card,
    .km-pagination,
    header,
    footer,
    nav {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 2. Élimination totale de tout débordement (overflow) et marges qui coupent les bords */
    html, body {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        color: #0f172a !important;
        font-family: 'Segoe UI', Arial, Helvetica, sans-serif !important;
        font-size: 10pt !important;
        line-height: 1.35 !important;
        overflow: visible !important;
        overflow-x: visible !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .km-main, .km-main-content {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        overflow-x: visible !important;
        background: #ffffff !important;
    }

        .km-card, .invoice-container {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 12px 18px !important;
        border: 1px solid #475569 !important;
        border-radius: 4px !important;
        box-shadow: none !important;
        background: #ffffff !important;
        overflow: visible !important;
    }

    .km-table-responsive {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        overflow-x: visible !important;
        display: block !important;
    }

    /* 3. Tableaux parfaitement bordés et lisibles */
    .km-table, table, .statement-table {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: auto !important;
        border-collapse: collapse !important;
        border: 1px solid #475569 !important;
        margin: 0 0 1rem 0 !important;
        color: #0f172a !important;
    }

    .km-table th, table th, .statement-table th {
        background: #f1f5f9 !important;
        color: #0f172a !important;
        border: 1px solid #475569 !important;
        font-weight: 700 !important;
        font-size: 8.5pt !important;
        text-transform: uppercase !important;
        padding: 6px 8px !important;
    }

    .km-table td, table td, .statement-table td {
        border: 1px solid #94a3b8 !important;
        color: #0f172a !important;
        font-size: 9pt !important;
        padding: 6px 8px !important;
        word-break: normal !important;
    }
}

/* ==========================================================================
   CHARTS & VISUAL DASHBOARD ANALYTICS
   ========================================================================== */
.km-charts-row-1 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
@media (min-width: 1024px) {
    .km-charts-row-1 {
        grid-template-columns: 1.65fr 1fr;
    }
}
.km-charts-row-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
@media (min-width: 1024px) {
    .km-charts-row-2 {
        grid-template-columns: 1fr 1fr;
    }
}
.km-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}
.km-chart-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.km-chart-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.km-chart-btn-group {
    display: inline-flex;
    background: var(--bg-card-hover);
    padding: 3px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    gap: 3px;
}
.km-chart-btn {
    border: none;
    background: transparent;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}
.km-chart-btn:hover {
    color: var(--text-primary);
}
.km-chart-btn.active {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 2px 6px var(--primary-glow);
}
.km-chart-container {
    position: relative;
    width: 100%;
}
.km-donut-center-stat {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}
.km-donut-center-val {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    font-family: var(--font-heading);
}
.km-donut-center-lbl {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}


/* ==========================================================================
   RAPPORT GENERAL DES DETTES & LIQUIDITES (BILAN FINANCIER)
   ========================================================================== */
.km-debts-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
@media (min-width: 1200px) {
    .km-debts-cards-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}
.km-debt-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.km-debt-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.print-only {
    display: none;
}

@media print {
    .print-only {
        display: block !important;
    }
    .km-debts-cards-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 6px !important;
    }
    .km-debt-card {
        border: 1px solid #94a3b8 !important;
        padding: 8px !important;
        page-break-inside: avoid;
    }
}


/* ==========================================================================
   SAYARATI / MTD ERP VERTICAL SIDEBAR & TOPBAR LAYOUT
   ========================================================================== */
.km-erp-container {
    display: flex;
    min-height: 100vh;
    background: #edf2f9;
    width: 100%;
}
[data-theme="dark"] .km-erp-container {
    background: #0b0f19;
}

/* Sidebar */
.km-erp-sidebar {
    width: 275px;
    min-width: 275px;
    background: #ffffff;
    border-inline-end: 1px solid #dce5f0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04);
}
[data-theme="dark"] .km-erp-sidebar {
    background: #131a29;
    border-inline-end: 1px solid rgba(255, 255, 255, 0.08);
}

.km-sidebar-brand-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
}
[data-theme="dark"] .km-sidebar-brand-wrapper {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.km-sidebar-brand-wrapper .km-sidebar-brand {
    border-bottom: none;
    flex: 1;
}
.km-sidebar-close-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: #64748b;
    padding: 0.75rem 1.15rem;
    cursor: pointer;
    transition: color 0.15s ease;
}
.km-sidebar-close-btn:hover {
    color: #e11d48;
}

.km-sidebar-brand {
    padding: 1.25rem 1.25rem 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}
[data-theme="dark"] .km-sidebar-brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.km-sidebar-brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    flex-shrink: 0;
}
.km-sidebar-brand-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.2;
}
[data-theme="dark"] .km-sidebar-brand-title {
    color: #f8fafc;
}
.km-sidebar-brand-title span {
    color: #2563eb;
}
.km-sidebar-brand-sub {
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 600;
    margin-top: 2px;
}

/* Scrollable Nav */
.km-sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem 0.6rem;
}
.km-sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.km-sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.68rem 0.95rem;
    border-radius: 12px;
    color: #475569;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s ease;
    position: relative;
}
[data-theme="dark"] .km-sidebar-link {
    color: #94a3b8;
}
.km-sidebar-link:hover {
    background: #f1f5f9;
    color: #2563eb;
}
[data-theme="dark"] .km-sidebar-link:hover {
    background: #1f2b42;
    color: #60a5fa;
}
.km-sidebar-link.active {
    background: #dbeafe !important;
    color: #1e40af !important;
    font-weight: 800 !important;
}
[data-theme="dark"] .km-sidebar-link.active {
    background: rgba(37, 99, 235, 0.25) !important;
    color: #93c5fd !important;
}
.km-sidebar-link.active::before {
    content: "";
    position: absolute;
    inset-inline-start: 0;
    top: 6px;
    bottom: 6px;
    width: 4px;
    background: #2563eb;
    border-radius: 4px;
}
.km-sidebar-icon {
    font-size: 1.2rem;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.km-sidebar-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}
.km-sidebar-subtext {
    font-size: 0.68rem;
    font-weight: 500;
    color: #64748b;
}
[data-theme="dark"] .km-sidebar-subtext {
    color: #94a3b8;
}
.km-sidebar-badge {
    background: #ef4444;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

/* Main Area */
.km-erp-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: hidden;
}

/* Topbar */
.km-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.km-mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #dce5f0;
    color: #0f172a;
    font-size: 1.35rem;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
    flex-shrink: 0;
}
[data-theme="dark"] .km-mobile-menu-btn {
    background: #182234;
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
}
.km-mobile-menu-btn:hover {
    background: #eff6ff;
    color: #2563eb;
    border-color: #93c5fd;
}
[data-theme="dark"] .km-mobile-menu-btn:hover {
    background: #1f2b42;
    color: #60a5fa;
}

.km-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1040;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.km-erp-topbar {
    height: 72px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #edf2f9;
    border-bottom: 1px solid #dce5f0;
    position: sticky;
    top: 0;
    z-index: 90;
    gap: 1rem;
}
[data-theme="dark"] .km-erp-topbar {
    background: #0b0f19;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.km-topbar-actions-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.km-topbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: #ffffff;
    border: 1px solid #dce5f0;
    padding: 0.45rem 1rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    color: #475569;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .km-topbar-btn {
    background: #182234;
    border-color: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
}
.km-topbar-btn:hover {
    background: #f8fafc;
    color: #2563eb;
    border-color: #93c5fd;
}
[data-theme="dark"] .km-topbar-btn:hover {
    background: #1f2b42;
    color: #60a5fa;
}
.km-topbar-logout {
    color: #e11d48 !important;
    background: rgba(225, 29, 72, 0.06) !important;
    border-color: rgba(225, 29, 72, 0.2) !important;
}
.km-topbar-logout:hover {
    background: rgba(225, 29, 72, 0.12) !important;
}

/* User Card in Topbar */
.km-erp-user-card {
    background: #ffffff;
    border: 1px solid #dce5f0;
    border-radius: 14px;
    padding: 0.35rem 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    position: relative;
}
[data-theme="dark"] .km-erp-user-card {
    background: #182234;
    border-color: rgba(255, 255, 255, 0.1);
}
.km-erp-user-card:hover {
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}
.km-erp-user-info {
    text-align: inherit;
    line-height: 1.25;
}
.km-erp-comp-name {
    font-weight: 800;
    font-size: 0.88rem;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
[data-theme="dark"] .km-erp-comp-name {
    color: #f8fafc;
}
.km-erp-user-role {
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 600;
}
[data-theme="dark"] .km-erp-user-role {
    color: #94a3b8;
}
.km-erp-avatar-box {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: #eff6ff;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    flex-shrink: 0;
}
[data-theme="dark"] .km-erp-avatar-box {
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
}

/* Content Body */
.km-erp-content {
    flex: 1;
    padding: 1.75rem 2rem;
    overflow-y: visible;
}

/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM (MOBILE, TABLETTE, DESKTOP)
   ========================================================================== */
@media (max-width: 1024px) {
    .km-erp-container {
        display: block;
        position: relative;
        width: 100%;
        min-height: 100vh;
    }

    .km-erp-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    }

    body.km-sidebar-open .km-erp-sidebar {
        transform: translateX(0);
    }

    body.km-sidebar-open .km-sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    body.km-sidebar-open {
        overflow: hidden;
    }

    .km-mobile-menu-btn {
        display: inline-flex;
    }

    .km-sidebar-close-btn {
        display: inline-flex;
    }

    .km-erp-main {
        width: 100%;
        min-width: 0;
        margin: 0;
    }

    .km-erp-topbar {
        padding: 0 1.25rem;
        height: 66px;
    }

    .km-erp-content {
        padding: 1.5rem 1.25rem;
    }

    /* Auth Responsive <= 1024px */
    .km-auth-split-card {
        flex-direction: column;
        max-width: 620px;
        min-height: auto;
    }

    .km-login-hero {
        padding: 2.25rem 2rem;
    }

    .km-login-features {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin: 1.5rem 0;
    }

    .km-login-form-area {
        padding: 2.25rem 2rem;
    }
}

@media (max-width: 768px) {
    .km-page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.85rem;
        margin-bottom: 1.25rem;
    }

    .km-page-title {
        font-size: 1.4rem;
    }

    .km-page-subtitle {
        font-size: 0.82rem;
    }

    .km-stats-grid {
        grid-template-columns: 1fr;
        gap: 0.85rem;
        margin-bottom: 1.25rem;
    }

    .km-stat-card {
        padding: 1rem 1.15rem;
    }

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

    .km-debts-cards-grid {
        grid-template-columns: 1fr;
    }

    .km-form-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
    }

    .km-form-col-full {
        grid-column: span 1 !important;
    }

    .km-card-header {
        padding: 1rem 1.25rem;
        flex-wrap: wrap;
        gap: 0.6rem;
    }

    .km-card-title {
        font-size: 1.1rem;
    }

    .km-card-body {
        padding: 1.25rem;
    }

    .km-form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 0.75rem;
        margin-top: 1.25rem;
        padding-top: 1rem;
    }

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

    .km-filter-card {
        padding: 1rem 1.15rem;
    }

    .km-filter-form {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .km-search-box {
        min-width: 100%;
        width: 100%;
    }

    .km-filter-form .km-select,
    .km-filter-form .km-btn {
        width: 100%;
    }

    .km-table-card {
        border-radius: var(--radius-md);
    }

    .km-table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }

    .km-table th, 
    .km-table td {
        padding: 0.75rem 0.85rem;
        font-size: 0.84rem;
    }

    .km-pagination-wrapper {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
        padding: 1rem;
    }

    .km-paginator-list {
        flex-wrap: wrap;
        justify-content: center;
    }

    .km-login-features {
        grid-template-columns: 1fr;
    }

    .km-auth-split-card {
        border-radius: 18px;
        margin: 0.5rem;
    }

    .km-login-hero {
        padding: 1.75rem 1.5rem;
    }

    .km-login-form-area {
        padding: 1.75rem 1.5rem;
    }
}

@media (max-width: 576px) {
    .km-topbar-btn span {
        display: none !important;
    }

    .km-topbar-btn {
        padding: 0;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        justify-content: center;
    }

    .km-user-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }

    .km-user-company-name {
        max-width: 130px;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
    }

    .km-user-name-row {
        display: none;
    }

    .km-erp-content {
        padding: 1rem 0.75rem;
    }

    .km-auth-topbar {
        padding: 1rem 1.25rem;
    }

    .km-auth-main-container {
        padding: 0.5rem;
    }

    .km-login-hero-title {
        font-size: 1.35rem;
    }

    .km-login-form-title {
        font-size: 1.3rem;
    }
}

/* RTL Specific adjustments */
[dir="rtl"] {
    font-family: "Cairo", "Tajawal", "Plus Jakarta Sans", sans-serif;
}
[dir="rtl"] .km-erp-sidebar {
    left: auto;
    right: 0;
    box-shadow: -2px 0 12px rgba(15, 23, 42, 0.03);
    border-inline-end: none;
    border-inline-start: 1px solid #dce5f0;
}
[dir="rtl"][data-theme="dark"] .km-erp-sidebar {
    border-inline-start: 1px solid rgba(255, 255, 255, 0.08);
}
@media (max-width: 1024px) {
    [dir="rtl"] .km-erp-sidebar {
        transform: translateX(100%);
    }
    [dir="rtl"] body.km-sidebar-open .km-erp-sidebar {
        transform: translateX(0);
    }
}
