/* ============================================================
   MATRIX INDUSTRIE — Web Application Stylesheet v4.0
   Professional ERP dark-sidebar / white-content theme
   With dark mode, print styles, reduced motion, sticky headers
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* ---------- Typography ---------- */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;

    /* ---------- Brand palette (shades 50-900) ---------- */
    --brand-50:  #eef5ff;
    --brand-100: #d9e7ff;
    --brand-200: #bcd5ff;
    --brand-300: #8ebaff;
    --brand-400: #5a93ff;
    --brand-500: #3b76f6;  /* principal */
    --brand-600: #2558db;
    --brand-700: #1d46b2;
    --brand-800: #1c3d8c;
    --brand-900: #1d3770;

    /* ---------- Semantic (harmonisees) ---------- */
    --primary: var(--brand-500);
    --primary-hover: var(--brand-600);
    --primary-soft: var(--brand-50);

    --success: #16a34a;
    --success-hover: #15803d;
    --success-soft: #dcfce7;

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

    --warning: #f59e0b;
    --warning-hover: #d97706;
    --warning-soft: #fef3c7;

    --purple: #7c3aed;
    --orange: #ea580c;

    /* ---------- Neutrals ---------- */
    --dark: #0f172a;            /* slate-900 */
    --dark-hover: #1e293b;      /* slate-800 */
    --accent: #1e3a8a;          /* blue-900 */
    --bg: #f5f7fb;
    --white: #ffffff;
    --text: #0f172a;
    --text-light: #64748b;      /* slate-500 */
    --text-muted: #94a3b8;      /* slate-400 */
    --border: #e2e8f0;          /* slate-200 */
    --border-strong: #cbd5e1;   /* slate-300 */

    /* ---------- Elevation ---------- */
    --shadow-xs: 0 1px 2px rgba(15,23,42,0.05);
    --shadow:    0 2px 8px rgba(15,23,42,0.08);
    --shadow-md: 0 4px 12px rgba(15,23,42,0.10);
    --shadow-lg: 0 12px 32px rgba(15,23,42,0.14);
    --shadow-xl: 0 24px 48px rgba(15,23,42,0.18);

    /* ---------- Radii ---------- */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-pill: 999px;

    /* ---------- Spacing scale (4/8/12/16/24/32/48/64) ---------- */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;

    /* ---------- Layout ---------- */
    --sidebar-w: 240px;
    --header-h: 60px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* ---------- Surfaces ---------- */
    --modal-bg: #ffffff;
    --modal-text: #0f172a;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-border-focus: var(--brand-500);
    --table-stripe: #f8fafc;
    --table-hover: #eff6ff;
    --card-bg: #ffffff;

    /* ---------- Aliases retro-compat (anciennes variables) ---------- */
    --bg-primary: var(--bg);
    --bg-secondary: var(--card-bg);
    --text-primary: var(--text);
    --text-secondary: var(--text-light);
    --border-color: var(--border);
}

/* ============================================================
   DARK MODE
   ============================================================ */
[data-theme="dark"] {
    --bg: #0b1220;
    --white: #111827;
    --text: #f1f5f9;
    --text-light: #cbd5e1;
    --text-muted: #94a3b8;
    --border: #1f2937;
    --border-strong: #334155;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.35);
    --shadow:    0 2px 8px rgba(0,0,0,0.4);
    --shadow-md: 0 6px 16px rgba(0,0,0,0.45);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.55);
    --shadow-xl: 0 24px 56px rgba(0,0,0,0.6);
    --dark: #020617;
    --dark-hover: #0f172a;
    --accent: #1e3a8a;
    --primary-soft: rgba(59, 118, 246, 0.15);
    --success-soft: rgba(22, 163, 74, 0.18);
    --danger-soft: rgba(220, 38, 38, 0.18);
    --warning-soft: rgba(245, 158, 11, 0.18);
    --modal-bg: #111827;
    --modal-text: #f1f5f9;
    --input-bg: #0b1220;
    --input-border: #334155;
    --input-border-focus: var(--brand-400);
    --table-stripe: #111827;
    --table-hover: #1e293b;
    --card-bg: #111827;
}

/* Outline bouton dark : texte et bordure contrastes */
[data-theme="dark"] .btn-outline {
    border-color: #6e7681;
    color: var(--text);
}
[data-theme="dark"] .btn-outline:hover {
    background: #21262d;
    border-color: #8b949e;
}

/* Labels de formulaire dark : contraste renforce */
[data-theme="dark"] .form-group label {
    color: var(--text);
}

/* Placeholder dark visible */
[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
    color: #8b949e;
    opacity: 1;
}

/* Liens dark */
[data-theme="dark"] a {
    color: #58a6ff;
}
[data-theme="dark"] a:hover {
    color: #79c0ff;
}

/* Focus visible accessible : ring orange 2px */
[data-theme="dark"] *:focus-visible,
*:focus-visible {
    outline: 2px solid var(--danger);
    outline-offset: 2px;
}

[data-theme="dark"] .login-container {
    background: rgba(22, 27, 34, 0.85);
    border-color: rgba(255,255,255,0.08);
}

[data-theme="dark"] .search-dropdown {
    background: var(--white);
    color: var(--text);
}

[data-theme="dark"] .search-item:hover {
    background: var(--bg);
}

[data-theme="dark"] .status-badge.badge-success { background: #1a3a2a; color: #3fb950; }
[data-theme="dark"] .status-badge.badge-warning { background: #3a2a1a; color: #d29922; }
[data-theme="dark"] .status-badge.badge-danger  { background: #3a1a1a; color: #f85149; }
[data-theme="dark"] .status-badge.badge-info    { background: #1a2a3a; color: #58a6ff; }
[data-theme="dark"] .status-badge.badge-default { background: #21262d; color: #8b949e; }

[data-theme="dark"] .data-table thead {
    background: #010409;
}

[data-theme="dark"] .module-search input {
    background: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text);
}

[data-theme="dark"] .notif-panel {
    background: var(--white);
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

/* Typographie cohérente */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    color: var(--text);
}
h1 { font-size: 1.75rem; letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

code, kbd, samp, pre { font-family: var(--font-mono); }

a { color: inherit; text-decoration: none; cursor: pointer; }

/* ---------- Screen switching ---------- */
.screen {
    display: none;
    width: 100%;
    height: 100vh;
    height: 100dvh;
}
.screen.active {
    display: flex;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#login-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    animation: loginBgShift 12s ease-in-out infinite alternate;
}

@keyframes loginBgShift {
    0%   { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.login-container {
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 48px 40px 40px;
    width: 92%;
    max-width: 400px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.35);
    animation: loginSlideUp 0.6s ease-out;
}

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

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}
.logo-text {
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--danger);
    letter-spacing: 6px;
    line-height: 1;
}
.logo-sub {
    font-size: 1rem;
    color: rgba(255,255,255,0.7);
    letter-spacing: 10px;
    margin-top: 4px;
}

.input-group {
    margin-bottom: 20px;
}
.input-group label {
    display: block;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.input-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}
.input-group input:focus {
    border-color: var(--primary);
    background: rgba(255,255,255,0.12);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.25);
}
.input-group input::placeholder {
    color: rgba(255,255,255,0.3);
}

.error-msg {
    color: var(--danger);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 12px;
    min-height: 1.2em;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: #2980b9; box-shadow: 0 4px 12px rgba(52,152,219,0.35); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-full { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; min-height: 36px; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 6px;
    border-radius: 50%;
    transition: var(--transition);
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}
.btn-icon:hover { background: rgba(0,0,0,0.06); }

[data-theme="dark"] .btn-icon:hover { background: rgba(255,255,255,0.1); }

.btn-fab {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(52,152,219,0.35);
    transition: var(--transition);
    flex-shrink: 0;
}
.btn-fab:hover {
    background: #2980b9;
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(52,152,219,0.45);
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
#app-screen {
    flex-direction: column;
}

/* ---------- Header ---------- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    padding-top: var(--safe-top);
    background: var(--dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 16px;
    padding-right: 16px;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.menu-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    min-height: 44px;
    min-width: 44px;
    display: none;
}
.menu-toggle:hover { background: rgba(255,255,255,0.1); }

.brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    white-space: nowrap;
}

.header-center {
    flex: 1;
    max-width: 420px;
    margin: 0 24px;
}

.search-bar {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.1);
    border-radius: 24px;
    padding: 0 16px;
    transition: var(--transition);
}
.search-bar:focus-within {
    background: rgba(255,255,255,0.18);
    box-shadow: 0 0 0 2px rgba(52,152,219,0.3);
}
.search-icon { margin-right: 8px; font-size: 0.9rem; opacity: 0.7; }
.search-bar input {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.9rem;
    padding: 10px 0;
    outline: none;
}
.search-bar input::placeholder { color: rgba(255,255,255,0.4); }

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 360px;
    overflow-y: auto;
    z-index: 1100;
    color: var(--text);
}
.search-dropdown.hidden { display: none; }

.search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg); }
.search-icon-item { font-size: 1.3rem; }
.search-title { font-weight: 600; font-size: 0.9rem; }
.search-sub { font-size: 0.78rem; color: var(--text-light); }
.search-empty { padding: 20px; text-align: center; color: var(--text-light); }

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Mobile search toggle - hidden on desktop */
.mobile-search-toggle {
    display: none;
    color: #fff;
}

/* Dark mode toggle */
.dark-mode-toggle {
    color: #fff;
    font-size: 1.1rem;
}

/* Offline indicator */
.offline-badge {
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    white-space: nowrap;
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Mobile search bar */
.mobile-search-bar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--dark);
    padding: 8px 16px;
    z-index: 999;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.mobile-search-bar .search-bar {
    background: rgba(255,255,255,0.12);
}
.mobile-search-bar .search-bar input {
    color: #fff;
}
.mobile-search-bar .btn-icon {
    color: #fff;
    min-height: 36px;
    min-width: 36px;
    font-size: 0.9rem;
}
.mobile-search-bar .search-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 16px;
    right: 16px;
}

.notif-bell {
    position: relative;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notif-bell:hover { background: rgba(255,255,255,0.1); }

.badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--danger);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}
.badge.hidden { display: none; }

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}
#user-name {
    font-weight: 600;
    white-space: nowrap;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--dark);
    color: rgba(255,255,255,0.85);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 900;
    padding-bottom: var(--safe-bottom);
    transition: transform var(--transition);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-section {
    padding: 20px 20px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    font-size: 0.88rem;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
    min-height: 44px;
}
.sidebar-item:hover {
    background: var(--dark-hover);
    border-left-color: rgba(255,255,255,0.2);
}
.sidebar-item.active {
    background: var(--accent);
    border-left-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 850;
}

/* ---------- Content ---------- */
.content {
    margin-left: var(--sidebar-w);
    margin-top: var(--header-h);
    padding: 28px;
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    animation: fadeIn 0.3s ease-out;
}

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

/* ---------- Page header ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 24px;
}
.page-header .page-title { margin-bottom: 0; }

.page-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}
.record-count {
    font-size: 0.85rem;
    color: var(--text-light);
    background: var(--bg);
    padding: 6px 14px;
    border-radius: 20px;
}

/* ============================================================
   STATS CARDS (Dashboard)
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
    animation: cardPop 0.4s ease-out backwards;
}
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.10s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.20s; }
.stat-card:nth-child(5) { animation-delay: 0.25s; }
.stat-card:nth-child(6) { animation-delay: 0.30s; }
.stat-card:nth-child(7) { animation-delay: 0.35s; }
.stat-card:nth-child(8) { animation-delay: 0.40s; }

@keyframes cardPop {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.stat-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}
.stat-card.blue::before   { background: var(--primary); }
.stat-card.green::before  { background: var(--success); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.orange::before { background: var(--orange); }
.stat-card.red::before    { background: var(--danger); }

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
}
.stat-card.blue .stat-value   { color: var(--primary); }
.stat-card.green .stat-value  { color: var(--success); }
.stat-card.purple .stat-value { color: var(--purple); }
.stat-card.orange .stat-value { color: var(--orange); }
.stat-card.red .stat-value    { color: var(--danger); }

.stat-label {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-top: 6px;
}

/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}
.badge-success { background: #d5f5e3; color: #1e8449; }
.badge-warning { background: #fdebd0; color: #b9770e; }
.badge-danger  { background: #fadbd8; color: #c0392b; }
.badge-info    { background: #d6eaf8; color: #2471a3; }
.badge-default { background: #eaecee; color: #5d6d7e; }

/* ---------- Stat card icon ---------- */
.stat-icon {
    font-size: 1.6rem;
    margin-bottom: 6px;
    line-height: 1;
}

/* ---------- Module search bar ---------- */
.module-search {
    display: inline-block;
}
.module-search input {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    outline: none;
    width: 200px;
    transition: var(--transition);
    background: var(--input-bg);
    color: var(--text);
}
.module-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
    width: 260px;
}

@media (max-width: 768px) {
    .module-search input { width: 140px; }
    .module-search input:focus { width: 180px; }
}

/* ============================================================
   DATA TABLES
   ============================================================ */
.table-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-height: 70vh;
    position: relative;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    white-space: nowrap;
}

.data-table thead {
    background: var(--dark);
    color: #fff;
}
.data-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--dark);
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table tbody tr {
    transition: var(--transition);
    cursor: pointer;
}
.data-table tbody tr:nth-child(even) {
    background: var(--table-stripe);
}
.data-table tbody tr:hover {
    background: var(--table-hover);
    box-shadow: inset 0 0 0 1px var(--primary);
}

/* Sortable column headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 24px;
}
th.sortable:hover {
    background: rgba(255,255,255,0.1);
}
th.sort-asc::after {
    content: ' \25B2';
    font-size: 0.7em;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.9;
}
th.sort-desc::after {
    content: ' \25BC';
    font-size: 0.7em;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.9;
}

.data-table td.empty {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-style: italic;
    cursor: default;
}

/* Action buttons in table rows */
.row-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}
.row-actions .btn-sm {
    padding: 4px 10px;
    font-size: 0.78rem;
    min-height: 30px;
    min-width: 30px;
    border-radius: 4px;
}
.btn-edit {
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}
.btn-edit:hover { background: #2980b9; }
.btn-delete {
    background: var(--danger);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}
.btn-delete:hover { background: #c0392b; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    padding: 12px 0;
}
.pagination .btn {
    min-height: 38px;
    min-width: 38px;
    padding: 6px 14px;
    font-size: 0.85rem;
}
.pagination .page-info {
    font-size: 0.85rem;
    color: var(--text-light);
    padding: 0 12px;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeInOverlay 0.2s ease-out;
}
.modal-overlay.hidden {
    display: none;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--modal-bg);
    color: var(--modal-text);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.25s ease-out;
}
.modal.modal-sm {
    max-width: 420px;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

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

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* Modal form fields */
.form-group {
    margin-bottom: 16px;
}
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
    background: var(--input-bg);
    color: var(--text);
    font-family: inherit;
}
.form-group textarea {
    min-height: 80px;
    resize: vertical;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}
.form-group .field-error {
    color: var(--danger);
    font-size: 0.78rem;
    margin-top: 4px;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--white);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    max-width: 420px;
    animation: toastIn 0.3s ease-out;
    pointer-events: auto;
    border-left: 4px solid var(--primary);
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

.toast.toast-out {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

.toast-icon { font-size: 1.2rem; flex-shrink: 0; }
.toast-message { font-size: 0.88rem; flex: 1; }
.toast-close {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}
.toast-close:hover { background: var(--bg); }

/* ============================================================
   NOTIFICATIONS PANEL
   ============================================================ */
.notif-panel {
    position: fixed;
    top: var(--header-h);
    right: 0;
    bottom: 0;
    width: 360px;
    max-width: 100%;
    background: var(--white);
    box-shadow: -4px 0 20px rgba(0,0,0,0.12);
    z-index: 950;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform var(--transition);
}
.notif-panel.hidden {
    transform: translateX(100%);
    pointer-events: none;
}

.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.notif-header h3 {
    font-size: 1rem;
    font-weight: 700;
}
.notif-header button {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.notif-header button:hover { background: var(--bg); }

#notif-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.notif-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}
.notif-item:hover { background: var(--bg); }
.notif-title {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 4px;
}
.notif-msg {
    font-size: 0.82rem;
    color: var(--text-light);
    line-height: 1.4;
}
.notif-meta {
    font-size: 0.72rem;
    color: var(--text-light);
    margin-top: 6px;
    opacity: 0.7;
}
.notif-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-light);
}

/* ============================================================
   LOADING & ERROR
   ============================================================ */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    font-size: 1rem;
    color: var(--text-light);
}
.loading::before {
    content: '';
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

.error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    font-size: 1rem;
    color: var(--danger);
}

/* ---------- Hidden utility ---------- */
.hidden { display: none !important; }

/* ============================================================
   RESPONSIVE — Tablet (< 1024px)
   ============================================================ */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    .header-center {
        max-width: 280px;
        margin: 0 12px;
    }
}

/* ============================================================
   RESPONSIVE — Mobile (< 768px)
   ============================================================ */
@media (max-width: 768px) {
    :root {
        --sidebar-w: 260px;
    }

    .menu-toggle { display: flex; align-items: center; justify-content: center; }
    .mobile-search-toggle { display: inline-flex; }

    .brand { font-size: 0.95rem; letter-spacing: 1px; }

    .header-center { display: none; }

    #user-name { display: none; }

    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }
    .sidebar.open ~ .sidebar-overlay {
        display: block;
    }

    .content {
        margin-left: 0;
        padding: 18px 14px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 1.2rem; }

    .page-title { font-size: 1.15rem; }

    .data-table { font-size: 0.82rem; }
    .data-table th,
    .data-table td { padding: 10px 12px; }

    .notif-panel { width: 100%; }

    .modal {
        max-width: 100%;
        max-height: 95vh;
        margin: 10px;
    }

    .toast-container {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }
    .toast {
        min-width: auto;
        max-width: 100%;
    }

    /* Mobile table: card-like on very small */
    .page-actions {
        width: 100%;
        flex-wrap: wrap;
    }
}

/* ============================================================
   RESPONSIVE — Small mobile (< 480px)
   ============================================================ */
@media (max-width: 480px) {
    .login-container {
        padding: 32px 24px 28px;
    }
    .logo-text { font-size: 2rem; letter-spacing: 4px; }
    .logo-sub { font-size: 0.85rem; letter-spacing: 6px; }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 1.05rem; }
    .stat-label { font-size: 0.75rem; }
}

/* ============================================================
   DESKTOP: show sidebar, hide hamburger
   ============================================================ */
@media (min-width: 769px) {
    .sidebar-overlay { display: none !important; }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
    * {
        color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    body {
        overflow: visible;
        height: auto;
        background: #fff;
        color: #000;
    }

    .app-header,
    .sidebar,
    .sidebar-overlay,
    .notif-panel,
    .modal-overlay,
    #confirm-overlay,
    .toast-container,
    .mobile-search-bar,
    .btn-fab,
    .row-actions,
    .pagination,
    .page-actions,
    .mobile-search-toggle,
    .dark-mode-toggle,
    .offline-badge,
    #login-screen {
        display: none !important;
    }

    .screen { display: block !important; height: auto !important; }

    .content {
        margin: 0 !important;
        padding: 10px !important;
        height: auto !important;
        overflow: visible !important;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        break-inside: avoid;
    }

    .stat-card {
        box-shadow: none;
        border: 1px solid #ccc;
        padding: 10px;
        break-inside: avoid;
    }

    .table-container {
        box-shadow: none;
        border: 1px solid #ccc;
        overflow: visible;
        max-height: none;
    }

    .data-table {
        font-size: 0.75rem;
        white-space: normal;
    }

    .data-table thead {
        background: #333 !important;
    }
    .data-table th {
        position: static;
        color: #fff !important;
        background: #333 !important;
    }

    .data-table tbody tr {
        break-inside: avoid;
    }

    .page-title {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }

    a { text-decoration: none; }

    .bottom-nav { display: none !important; }
}

/* ============================================================
   SPLASH SCREEN
   ============================================================ */
.splash-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}
.splash-content { text-align: center; }
.splash-logo-img {
    height: 80px; width: auto; object-fit: contain;
    margin-bottom: 12px;
}
.login-logo-img {
    height: 90px; width: auto; object-fit: contain;
    margin-bottom: 16px;
}
.splash-logo {
    font-size: 3rem;
    font-weight: 800;
    color: var(--danger);
    letter-spacing: 8px;
    animation: splashPulse 1.5s ease-in-out infinite;
}
.splash-sub {
    font-size: 1rem;
    color: rgba(255,255,255,0.6);
    letter-spacing: 12px;
    margin-top: 8px;
}
.splash-spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 30px auto 0;
}
@keyframes splashPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============================================================
   LOGIN VERSION
   ============================================================ */
.login-version {
    text-align: center;
    color: rgba(255,255,255,0.3);
    font-size: 0.75rem;
    margin-top: 20px;
    letter-spacing: 1px;
}

/* ============================================================
   USER ROLE BADGE
   ============================================================ */
.user-role-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-admin { background: rgba(233,69,96,0.2); color: #e94560; }
.role-commercial { background: rgba(243,156,18,0.2); color: #f39c12; }
.role-user { background: rgba(52,152,219,0.2); color: #3498db; }

/* ============================================================
   BOTTOM NAVIGATION (Mobile)
   ============================================================ */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    padding-bottom: var(--safe-bottom);
    background: var(--white);
    border-top: 1px solid var(--border);
    z-index: 1000;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
}

/* Cacher la bottom nav quand le sidebar mobile est ouvert */
.sidebar.open ~ .bottom-nav {
    transform: translateY(100%);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 4px;
    color: var(--text-light);
    font-size: 0.68rem;
    transition: var(--transition);
    cursor: pointer;
    min-width: 0;
    border-radius: 8px;
    text-decoration: none;
}
.bottom-nav-item.active {
    color: var(--primary);
}
.bottom-nav-item:hover {
    color: var(--text);
}
.bottom-nav-icon { font-size: 1.3rem; line-height: 1; }
.bottom-nav-label { font-weight: 600; }

/* Dark mode bottom nav */
[data-theme="dark"] .bottom-nav {
    background: #161b22;
    border-top-color: #30363d;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.4);
}
[data-theme="dark"] .bottom-nav-item {
    color: #8b949e;
}
[data-theme="dark"] .bottom-nav-item.active {
    color: #58a6ff;
}
[data-theme="dark"] .bottom-nav-item:hover {
    color: #e6edf3;
}

@media (max-width: 768px) {
    .bottom-nav { display: grid; }
    .content {
        padding-bottom: 70px !important;
    }
}

/* ============================================================
   INSTALL BANNER (PWA)
   ============================================================ */
.install-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    background: linear-gradient(135deg, var(--dark), var(--accent));
    color: #fff;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    transform: translateY(-100%);
    animation: installSlideDown 0.4s ease forwards;
}
@keyframes installSlideDown {
    to { transform: translateY(0); }
}
.install-banner-text {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 600;
}
.install-banner .btn-install {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.2s;
}
.install-banner .btn-install:hover {
    background: #2980b9;
}
.install-banner .btn-close-banner {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}
.install-banner .btn-close-banner:hover {
    color: #fff;
}
.install-banner.hiding {
    animation: installSlideUp 0.3s ease forwards;
}
@keyframes installSlideUp {
    to { transform: translateY(-100%); }
}

/* ============================================================
   OFFLINE / ONLINE BANNERS
   ============================================================ */
.offline-banner {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    z-index: 1500;
    padding: 10px 20px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    animation: bannerSlideDown 0.3s ease;
}
@keyframes bannerSlideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}
.offline-banner.offline {
    background: var(--danger);
    color: #fff;
}
.offline-banner.online {
    background: var(--success);
    color: #fff;
    animation: bannerSlideDown 0.3s ease, bannerFadeOut 0.5s ease 2.5s forwards;
}
@keyframes bannerFadeOut {
    to { opacity: 0; transform: translateY(-100%); }
}

/* ============================================================
   CHARTS
   ============================================================ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}
.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.chart-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
}
@media (max-width: 768px) {
    .charts-grid { grid-template-columns: 1fr; gap: 14px; }
}

/* ============================================================
   TABS
   ============================================================ */
.tabs-container {
    margin-bottom: 24px;
}
.tabs-nav {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
    padding: 12px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    min-height: 44px;
}
.tab-btn:hover { color: var(--text); background: rgba(0,0,0,0.03); }
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
[data-theme="dark"] .tab-btn:hover { background: rgba(255,255,255,0.05); }

.tab-content.hidden { display: none; }

/* ============================================================
   KANBAN BOARD
   ============================================================ */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    min-height: 400px;
}
.kanban-column {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 300px;
}
[data-theme="dark"] .kanban-column { background: rgba(255,255,255,0.03); }

.kanban-col-header {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: var(--radius-sm);
    background: var(--white);
    box-shadow: var(--shadow);
    color: var(--text);
}
.kanban-count {
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
}
.kanban-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.kanban-card {
    background: var(--white);
    border-radius: var(--radius-sm);
    padding: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid var(--primary);
}
.kanban-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.kanban-card-urgent { border-left-color: var(--danger); }
.kanban-card-title {
    font-weight: 600;
    font-size: 0.88rem;
    margin-bottom: 6px;
    color: var(--text);
}
.kanban-card-meta {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-bottom: 6px;
}

@media (max-width: 1024px) {
    .kanban-board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .kanban-board { grid-template-columns: 1fr; }
}

/* ============================================================
   DETAIL VIEW
   ============================================================ */
.modal-lg { max-width: 720px; }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.detail-field {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.detail-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.detail-value {
    font-size: 0.9rem;
    color: var(--text);
    word-break: break-word;
}
@media (max-width: 480px) {
    .detail-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   APPROVE / REJECT BUTTONS
   ============================================================ */
.btn-approve {
    background: var(--success);
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    min-height: 28px;
}
.btn-approve:hover { background: #219a52; }
.btn-reject {
    background: var(--danger);
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    min-height: 28px;
}
.btn-reject:hover { background: #c0392b; }

/* View button */
.btn-view {
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}
.btn-view:hover { background: #1a2332; }

/* ============================================================
   PULL TO REFRESH
   ============================================================ */
.pull-indicator {
    position: fixed;
    top: calc(var(--header-h) + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: #fff;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease-out;
}
.pull-indicator.hidden { display: none; }
.pull-spinner {
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes slideDown {
    from { transform: translateX(-50%) translateY(-20px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ============================================================
   ERROR STATE
   ============================================================ */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    gap: 16px;
    text-align: center;
}
.error-icon { font-size: 3rem; }
.error-text { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.error-detail { font-size: 0.85rem; color: var(--text-light); }
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
    font-style: italic;
}

/* ============================================================
   SETTINGS / PROFILE
   ============================================================ */
.settings-section {
    max-width: 560px;
    margin: 0 auto;
    padding: 20px 0;
}
.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
}
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 26px;
    transition: var(--transition);
}
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* Profile card */
.profile-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 800;
    flex-shrink: 0;
}
.profile-name { font-size: 1.2rem; font-weight: 700; }
.profile-role { font-size: 0.85rem; color: var(--text-light); text-transform: capitalize; }
.profile-username { font-size: 0.8rem; color: var(--text-light); }

/* About */
.about-section { text-align: center; padding: 40px 0; }
.about-logo {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--danger);
    margin-bottom: 8px;
}
.about-version {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 16px;
}
.about-desc {
    font-size: 0.88rem;
    color: var(--text);
    line-height: 1.6;
    margin-bottom: 20px;
}
.about-copy {
    font-size: 0.78rem;
    color: var(--text-light);
}

/* ============================================================
   MOBILE TABLE CARD VIEW (< 600px)
   ============================================================ */
@media (max-width: 600px) {
    .data-table thead { display: none; }
    .data-table tbody tr {
        display: block;
        margin-bottom: 12px;
        background: var(--card-bg);
        border-radius: var(--radius-sm);
        box-shadow: var(--shadow);
        padding: 4px 0;
    }
    .data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 14px;
        border-bottom: 1px solid var(--border);
        max-width: none;
        white-space: normal;
    }
    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.78rem;
        color: var(--text-light);
        text-transform: uppercase;
        flex-shrink: 0;
        margin-right: 12px;
    }
    .data-table tbody td:last-child { border-bottom: none; }
    .data-table tbody td.empty {
        display: block;
        text-align: center;
    }
    .data-table tbody td.empty::before { display: none; }
    .row-actions-cell { justify-content: flex-end !important; }
    .table-container { max-height: none; }
}

/* ============================================================
   STATS GRID RESPONSIVE (12 cards on dashboard)
   ============================================================ */
@media (min-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 769px) and (max-width: 1199px) {
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   QUICK ACTIONS (Dashboard)
   ============================================================ */
.quick-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.quick-action-btn {
    padding: 10px 18px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}
.quick-action-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52,152,219,0.25);
}

/* ============================================================
   DASHBOARD BOTTOM (Alerts + Top Clients + Activity)
   ============================================================ */
.dashboard-bottom {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 24px;
}
.dashboard-col {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    max-height: 400px;
    overflow-y: auto;
}
@media (max-width: 1024px) {
    .dashboard-bottom { grid-template-columns: 1fr; }
}

/* Alert cards */
.alert-count {
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
}
.alert-card {
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid;
}
.alert-card:hover { transform: translateX(4px); }
.alert-danger { background: rgba(233,69,96,0.08); border-left-color: var(--danger); }
.alert-warning { background: rgba(243,156,18,0.08); border-left-color: var(--warning); }
.alert-info { background: rgba(52,152,219,0.08); border-left-color: var(--primary); }
[data-theme="dark"] .alert-danger { background: rgba(233,69,96,0.12); }
[data-theme="dark"] .alert-warning { background: rgba(243,156,18,0.12); }
[data-theme="dark"] .alert-info { background: rgba(52,152,219,0.12); }
.alert-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 4px; color: var(--text); }
.alert-msg { font-size: 0.78rem; color: var(--text-light); }

/* Top clients list */
.top-list { }
.top-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 30px 1fr auto;
    gap: 8px;
    align-items: center;
}
.top-rank { font-weight: 800; color: var(--primary); font-size: 0.85rem; }
.top-name { font-size: 0.88rem; font-weight: 600; }
.top-value { font-size: 0.82rem; color: var(--text-light); white-space: nowrap; }
.top-bar { grid-column: 1 / -1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.top-bar-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.5s ease; }

/* Activity timeline */
.activity-timeline { }
.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 6px;
    flex-shrink: 0;
}
.activity-text { font-size: 0.85rem; color: var(--text); }
.activity-meta { font-size: 0.75rem; color: var(--text-light); margin-top: 2px; }

/* ============================================================
   FILTER PILLS
   ============================================================ */
.filter-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.filter-pill {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card-bg);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}
.filter-pill:hover { border-color: var(--primary); color: var(--primary); }
.filter-pill.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.pill-count {
    background: rgba(0,0,0,0.1);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 0.72rem;
    margin-left: 4px;
}
.filter-pill.active .pill-count { background: rgba(255,255,255,0.25); }

/* ============================================================
   POINTAGE SPECIFIC
   ============================================================ */
.pointage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.pointage-header .page-title { margin-bottom: 0; }
.pointage-clock {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    font-family: 'Courier New', monospace;
    background: var(--card-bg);
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.pointage-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.pointage-nav input[type="date"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    background: var(--input-bg);
    color: var(--text);
}
.pointage-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.btn-pointage-arr {
    background: #27ae60; color: #fff; border: none; cursor: pointer;
    border-radius: 4px; transition: var(--transition);
}
.btn-pointage-arr:hover { background: #219a52; }
.btn-pointage-dep {
    background: #e74c3c; color: #fff; border: none; cursor: pointer;
    border-radius: 4px; transition: var(--transition);
}
.btn-pointage-dep:hover { background: #c0392b; }
.btn-pointage-abs {
    background: #95a5a6; color: #fff; border: none; cursor: pointer;
    border-radius: 4px; transition: var(--transition);
}
.btn-pointage-abs:hover { background: #7f8c8d; }

/* ============================================================
   CONVERT & PAY BUTTONS
   ============================================================ */
.btn-convert {
    background: #8e44ad;
    color: #fff;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}
.btn-convert:hover { background: #7d3c98; }

.btn-pay {
    background: #27ae60;
    color: #fff;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}
.btn-pay:hover { background: #219a52; }

.btn-pdf {
    background: #2c3e50;
    color: #fff;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}
.btn-pdf:hover { background: #1a252f; }

.btn-qr {
    background: #16a085;
    color: #fff;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}
.btn-qr:hover { background: #138d75; }

.btn-sig {
    background: #f39c12;
    color: #fff;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: var(--transition);
}
.btn-sig:hover { background: #d68910; }

.btn-excel {
    color: #27ae60 !important;
    border-color: #27ae60 !important;
}
.btn-excel:hover {
    background: #27ae60 !important;
    color: #fff !important;
}

/* ============================================================
   SCANNER
   ============================================================ */
.scanner-result {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 2px solid var(--success);
    font-size: 0.9rem;
}
#scanner-reader {
    border-radius: var(--radius-sm);
    overflow: hidden;
}

/* ============================================================
   SIGNATURE CANVAS
   ============================================================ */
.signature-canvas {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: crosshair;
    touch-action: none;
    max-width: 100%;
    background: #fff;
}

/* ============================================================
   IMPORT
   ============================================================ */
.import-preview {
    margin-top: 12px;
}
.import-info {
    padding: 14px;
    background: rgba(39,174,96,0.08);
    border: 1px solid rgba(39,174,96,0.2);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}
.import-info small {
    color: var(--text-light);
    word-break: break-all;
}

/* ============================================================
   QR PAYMENT
   ============================================================ */
.qr-modes {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}
#qr-image img {
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

/* ============================================================
   AMELIORATIONS PERFORMANCE & DYNAMISME v4.0
   ============================================================ */

/* Accelerer les interactions tactiles (supprime le delai 300ms) */
a, button, .sidebar-item, .bottom-nav-item, .stat-card, .btn, .btn-fab, .btn-icon {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* Animation de chargement du contenu */
.content {
    animation: contentFadeIn 0.2s ease-out;
}
@keyframes contentFadeIn {
    from { opacity: 0.6; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Stat cards : effet hover fluide */
.stat-card {
    transition: transform var(--transition), box-shadow var(--transition);
    will-change: transform;
}
.stat-card:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.stat-card:active {
    transform: translateY(0);
}

/* Tables : lignes avec animation au survol */
.data-table tbody tr {
    transition: background-color 0.15s ease;
}

/* FAB : animation pulse subtile */
.btn-fab {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-fab:hover {
    transform: scale(1.08);
}
.btn-fab:active {
    transform: scale(0.95);
}

/* Sidebar : slide-in plus fluide sur mobile */
@media (max-width: 767px) {
    .sidebar {
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
    }
    .sidebar-overlay {
        transition: opacity 0.28s ease;
    }
}

/* Pull-to-refresh : meilleur feedback visuel */
.pull-indicator {
    transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Skeleton loading pour le chargement */
.loading {
    position: relative;
    overflow: hidden;
}
.loading::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    from { transform: translateX(-100%); }
    to   { transform: translateX(100%); }
}

/* Bottom nav : feedback visuel actif */
.bottom-nav-item {
    transition: color 0.2s ease, transform 0.15s ease;
}
.bottom-nav-item:active {
    transform: scale(0.9);
}
.bottom-nav-item.active .bottom-nav-icon {
    transform: scale(1.15);
    transition: transform 0.2s ease;
}

/* GPU acceleration pour les elements animes */
.modal, .sidebar, .toast, .notif-panel, .splash-screen {
    will-change: transform, opacity;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* ═══ SKELETON LOADING v2.5.0 ═══ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-primary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
}
.skeleton-text { height: 14px; margin-bottom: 8px; width: 80%; }
.skeleton-text.short { width: 40%; }
.skeleton-title { height: 22px; margin-bottom: 12px; width: 60%; }
.skeleton-card {
  height: 100px; border-radius: 10px; margin-bottom: 12px;
}
.skeleton-row {
  display: flex; gap: 12px; margin-bottom: 10px;
}
.skeleton-row .skeleton { flex: 1; height: 40px; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.skeleton-table { width: 100%; }
.skeleton-table .skeleton-row { margin-bottom: 4px; }
.skeleton-table .skeleton-row .skeleton { height: 36px; }
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ═══ BUTTON MICRO-INTERACTIONS v2.5.0 ═══ */
.btn-loading {
  position: relative; pointer-events: none; opacity: 0.85;
}
.btn-loading::after {
  content: ''; position: absolute; right: 10px; top: 50%;
  width: 16px; height: 16px; margin-top: -8px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.btn-success-flash {
  animation: successFlash 0.6s ease;
}
@keyframes successFlash {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 0 4px rgba(39, 174, 96, 0.4); }
}
.input-error-shake {
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ═══ BULK ACTIONS BAR v2.5.0 ═══ */
.bulk-actions-bar {
  position: sticky; top: 0; z-index: 100;
  background: var(--primary); color: white;
  padding: 10px 20px; display: flex; align-items: center; gap: 12px;
  border-radius: 8px; margin-bottom: 10px;
  animation: slideDown 0.25s ease;
  box-shadow: var(--shadow-lg);
}
.bulk-actions-bar .bulk-count {
  font-weight: 700; font-size: 14px;
}
.bulk-actions-bar .bulk-btn {
  background: rgba(255,255,255,0.15); color: white; border: none;
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
  font-size: 13px; font-weight: 600;
  transition: background 0.2s;
}
.bulk-actions-bar .bulk-btn:hover {
  background: rgba(255,255,255,0.3);
}
.bulk-actions-bar .bulk-btn.danger { background: var(--danger); }
.bulk-actions-bar .bulk-btn.danger:hover { background: #c0392b; }
.bulk-actions-bar .bulk-close {
  margin-left: auto; background: none; border: none;
  color: white; font-size: 18px; cursor: pointer;
}

/* ═══ EMPTY STATES v2.5.0 ═══ */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-secondary);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state-title { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text-primary); }
.empty-state-desc { font-size: 14px; max-width: 400px; margin: 0 auto; }

/* ═══ BREADCRUMBS v2.5.0 ═══ */
.breadcrumbs {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; font-size: 13px; color: var(--text-secondary);
}
.breadcrumbs a { color: var(--primary); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .separator { color: var(--border-color); }

/* ═══ TOAST QUEUE v2.5.0 ═══ */
.toast-container { display: flex; flex-direction: column; gap: 8px; }
.toast { animation: toastIn 0.3s ease; }
.toast.hiding { animation: toastOut 0.3s ease forwards; }

/* ═══ PAGE TRANSITIONS v2.5.0 ═══ */
#content {
  transition: opacity 0.2s ease, transform 0.2s ease;
}
#content.page-exit {
  opacity: 0; transform: translateX(-20px);
}
#content.page-enter {
  opacity: 0; transform: translateX(20px);
}

/* ═══ DASHBOARD COMMERCIAL PERSO v3.7.0 ═══ */

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted, #95a5a6);
  margin-top: -8px;
  margin-bottom: 16px;
}

.commercial-objectif-card {
  background: linear-gradient(135deg, rgba(52, 152, 219, 0.08), rgba(39, 174, 96, 0.08));
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}
.objectif-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.objectif-title {
  font-size: 16px;
  font-weight: 600;
}
.objectif-pct {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
}
.objectif-bar-wrap {
  width: 100%;
  height: 16px;
  background: rgba(128,128,128,0.15);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.objectif-bar {
  height: 100%;
  border-radius: 8px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.objectif-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted, #95a5a6);
  flex-wrap: wrap;
  gap: 8px;
}

.commercial-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
@media (max-width: 768px) {
  .commercial-grid { grid-template-columns: 1fr; }
}

.commercial-leaderboard-card,
.commercial-topclients-card {
  background: var(--card-bg, rgba(255,255,255,0.02));
  border: 1px solid var(--border-color, rgba(255,255,255,0.1));
  border-radius: 12px;
  padding: 16px;
}

.badge-position {
  font-size: 12px;
  font-weight: normal;
  background: rgba(243, 156, 18, 0.2);
  color: #f39c12;
  padding: 4px 10px;
  border-radius: 12px;
  margin-left: 8px;
}

.leaderboard-list, .topclients-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.lb-row, .tc-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px;
  padding: 10px 12px;
  align-items: center;
  border-radius: 8px;
  transition: background 0.2s;
}
.lb-row:hover, .tc-row:hover {
  background: rgba(128, 128, 128, 0.08);
}
.lb-me {
  background: linear-gradient(90deg, rgba(243, 156, 18, 0.15), rgba(243, 156, 18, 0.03));
  border-left: 3px solid #f39c12;
}
.lb-rank, .tc-rank {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
}
.lb-name, .tc-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-you {
  color: #f39c12;
  font-size: 11px;
  font-weight: bold;
}
.lb-ca, .tc-ca {
  font-weight: 600;
  color: var(--primary, #3498db);
  white-space: nowrap;
}

.commercial-footer-info {
  margin-top: 20px;
  padding: 14px 18px;
  background: rgba(128, 128, 128, 0.05);
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted, #95a5a6);
  flex-wrap: wrap;
  gap: 12px;
}

/* ═══ CONTACT ACTIONS v3.7.0 ═══ */

/* Barre d'actions dans la vue detail */
.contact-actions-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  padding: 14px;
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.05), rgba(52, 152, 219, 0.05));
  border-radius: 10px;
  border: 1px dashed rgba(37, 211, 102, 0.3);
}

.contact-action-btn {
  flex: 1;
  min-width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: white;
  font-weight: 600;
  font-size: 13px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}
.contact-action-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.contact-action-btn:active { transform: translateY(0); }

.contact-action-btn .btn-icon-lg { font-size: 22px; line-height: 1; }
.contact-action-btn .btn-label { font-size: 12px; letter-spacing: 0.3px; }

.contact-action-btn.btn-whatsapp { background: #25d366; }
.contact-action-btn.btn-whatsapp:hover { background: #1faa55; }

.contact-action-btn.btn-call { background: #3498db; }
.contact-action-btn.btn-call:hover { background: #2980b9; }

.contact-action-btn.btn-email { background: #f39c12; }
.contact-action-btn.btn-email:hover { background: #d88109; }

.contact-action-btn.btn-maps { background: #8e44ad; }
.contact-action-btn.btn-maps:hover { background: #6c3483; }

/* Icones contact rapide dans les lignes de tableau */
.quick-contact-icons {
  display: inline-flex;
  gap: 4px;
  margin-right: 4px;
}

.quick-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.quick-icon:hover {
  transform: scale(1.12);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.quick-icon.wa { background: #25d366; color: white; }
.quick-icon.wa:hover { background: #1faa55; }
.quick-icon.call { background: #3498db; color: white; }
.quick-icon.call:hover { background: #2980b9; }
.quick-icon.email { background: #f39c12; color: white; }
.quick-icon.email:hover { background: #d88109; }

/* Responsive: bar simplifiee sur mobile */
@media (max-width: 480px) {
  .contact-action-btn .btn-label { font-size: 10px; }
  .contact-action-btn { padding: 10px 6px; min-width: 70px; }
  .quick-icon { width: 28px; height: 28px; font-size: 13px; }
}

/* ═══ WhatsApp button in devis actions ═══ */
.btn-sm.btn-wa {
  background: #25d366;
  color: white;
  border: none;
}
.btn-sm.btn-wa:hover { background: #1faa55; }

/* ═══ CHECK-IN VISITE v3.7.0 ═══ */

.contact-action-btn.btn-checkin {
  background: #e74c3c;
  cursor: pointer;
}
.contact-action-btn.btn-checkin:hover { background: #c0392b; }

.checkin-client-info {
  text-align: center;
  padding: 10px;
  margin-bottom: 12px;
  background: rgba(52, 152, 219, 0.08);
  border-radius: 8px;
}
.checkin-client-name {
  font-size: 17px;
  font-weight: 600;
}

.checkin-gps-status {
  padding: 12px 14px;
  margin-bottom: 14px;
  background: rgba(243, 156, 18, 0.1);
  border: 1px solid rgba(243, 156, 18, 0.3);
  border-radius: 8px;
  color: #f39c12;
  font-size: 13px;
  line-height: 1.5;
}
.checkin-gps-status.gps-ok {
  background: rgba(39, 174, 96, 0.1);
  border-color: rgba(39, 174, 96, 0.3);
  color: #27ae60;
}
.checkin-gps-status.gps-err {
  background: rgba(231, 76, 60, 0.1);
  border-color: rgba(231, 76, 60, 0.3);
  color: #e74c3c;
}


/* ============================================================
   UX v4.1 - COHERENCE ET PROFESSIONNALISME
   Icones SVG, toasts, skeletons, empty states, login/header polish
   ============================================================ */

/* ---------- Icons (wrapper SVG) ---------- */
.icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    line-height: 0;
    vertical-align: -0.125em;
}
.icon svg {
    width: 100%;
    height: 100%;
    display: block;
}
.icon-sm { font-size: 14px; }
.icon-md { font-size: 18px; }
.icon-lg { font-size: 22px; }
.icon-xl { font-size: 32px; }

.btn-icon .icon,
.menu-toggle .icon,
.notif-bell .icon { font-size: 20px; }

.search-bar .search-icon.icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 18px;
    z-index: 1;
}

/* ---------- Toast notifications ---------- */
.toast-container {
    position: fixed;
    top: calc(var(--header-h) + var(--space-4) + var(--safe-top));
    right: var(--space-4);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    pointer-events: none;
    max-width: 92vw;
}
.toast {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    min-width: 280px;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    pointer-events: auto;
    animation: toast-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    font-size: 0.92rem;
    line-height: 1.45;
}
.toast.hide { animation: toast-out 0.22s ease-in forwards; }
.toast-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; margin-bottom: 2px; }
.toast-msg { color: var(--text-light); font-size: 0.85rem; }
.toast-close {
    background: none; border: 0; cursor: pointer; color: var(--text-muted);
    padding: 2px; line-height: 0; transition: color var(--transition);
    display: inline-flex; align-items: center;
}
.toast-close:hover { color: var(--text); }
.toast-close .icon { font-size: 16px; }

.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { background: var(--success-soft); color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-error   .toast-icon { background: var(--danger-soft); color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { background: var(--warning-soft); color: var(--warning-hover); }
.toast-info    { border-left-color: var(--primary); }
.toast-info    .toast-icon { background: var(--primary-soft); color: var(--primary); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(24px) scale(0.98); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateX(24px) scale(0.98); }
}

/* ---------- Skeletons ---------- */
.skeleton {
    display: block;
    background: linear-gradient(90deg,
        var(--border) 0%,
        var(--border-strong) 50%,
        var(--border) 100%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg,
        #1e293b 0%,
        #334155 50%,
        #1e293b 100%);
    background-size: 200% 100%;
}
.skeleton-line { height: 14px; margin-bottom: var(--space-2); }
.skeleton-line.lg { height: 20px; }
.skeleton-line.sm { height: 10px; }
.skeleton-line.w-80 { width: 80%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.skeleton-card {
    padding: var(--space-4);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
}
.skeleton-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
}
.skeleton-row-body { flex: 1; }

@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---------- Empty state ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-7) var(--space-5);
    text-align: center;
    color: var(--text-light);
    min-height: 280px;
}
.empty-state-icon {
    width: 72px;
    height: 72px;
    border-radius: var(--radius-pill);
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
    font-size: 36px;
}
.empty-state-title {
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: var(--space-2);
}
.empty-state-msg {
    max-width: 360px;
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: var(--space-4);
}

/* ---------- Login polish ---------- */
#login-screen {
    background:
        radial-gradient(1200px 600px at 10% 0%, rgba(59,118,246,0.25), transparent 60%),
        radial-gradient(900px 500px at 90% 100%, rgba(124,58,237,0.22), transparent 60%),
        linear-gradient(135deg, #0b1220 0%, #0f172a 50%, #111827 100%);
    position: relative;
    overflow: hidden;
}
#login-screen::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(rgba(255,255,255,0.06) 1px, transparent 1px);
    background-size: 24px 24px;
    -webkit-mask-image: radial-gradient(ellipse at center, #000 40%, transparent 75%);
            mask-image: radial-gradient(ellipse at center, #000 40%, transparent 75%);
    pointer-events: none;
}

.login-container {
    background: rgba(17, 24, 39, 0.55);
    backdrop-filter: blur(24px) saturate(120%);
    -webkit-backdrop-filter: blur(24px) saturate(120%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-lg);
    padding: var(--space-7) var(--space-6) var(--space-6);
    box-shadow: var(--shadow-xl), inset 0 1px 0 rgba(255,255,255,0.08);
}
.login-logo { margin-bottom: var(--space-5); }
.login-logo-img { max-width: 180px; height: auto; filter: drop-shadow(0 8px 20px rgba(59,118,246,0.35)); }

.input-group input {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.12);
    color: #fff;
    font-family: var(--font-sans);
    padding: 14px 16px;
    border-radius: var(--radius);
    transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}
.input-group input:focus {
    border-color: var(--brand-400);
    background: rgba(255,255,255,0.08);
    box-shadow: 0 0 0 4px rgba(59,118,246,0.18);
}
.input-group label {
    color: rgba(255,255,255,0.72);
    font-weight: 500;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
}

#login-form .btn-primary {
    background: linear-gradient(135deg, var(--brand-500), var(--brand-600));
    box-shadow: 0 10px 24px rgba(59,118,246,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
    padding: 14px 24px;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-top: var(--space-2);
}
#login-form .btn-primary:hover {
    background: linear-gradient(135deg, var(--brand-400), var(--brand-500));
    box-shadow: 0 14px 32px rgba(59,118,246,0.45), inset 0 1px 0 rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.login-version {
    text-align: center;
    color: rgba(255,255,255,0.4);
    font-size: 0.72rem;
    margin-top: var(--space-5);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ---------- Header/Sidebar polish ---------- */
.app-header {
    background: var(--dark);
    box-shadow: var(--shadow-md);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.app-header .brand {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 2.5px;
    background: linear-gradient(135deg, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header .btn-icon { color: rgba(255,255,255,0.75); }
.app-header .btn-icon:hover { color: #fff; background: rgba(255,255,255,0.08); }

.notif-bell {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    color: rgba(255,255,255,0.75);
    transition: var(--transition);
}
.notif-bell:hover { color: #fff; background: rgba(255,255,255,0.08); }
.notif-bell .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    border-radius: var(--radius-pill);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-weight: 700;
    border: 2px solid var(--dark);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-left: var(--space-3);
    border-left: 1px solid rgba(255,255,255,0.08);
}
.user-info #user-name { color: #fff; font-weight: 500; font-size: 0.9rem; }
.user-role-badge {
    background: var(--brand-500);
    color: #fff;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.search-bar {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-pill);
    height: 40px;
    padding-left: 42px;
    padding-right: var(--space-3);
    transition: var(--transition);
}
.search-bar:focus-within {
    background: rgba(255,255,255,0.14);
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(59,118,246,0.2);
}
.search-bar input {
    background: transparent;
    border: 0;
    color: #fff;
    outline: none;
    width: 100%;
    font-family: var(--font-sans);
    font-size: 0.9rem;
}
.search-bar input::placeholder { color: rgba(255,255,255,0.5); }

/* Boutons unifies */
.btn {
    font-family: var(--font-sans);
    border-radius: var(--radius);
    gap: var(--space-2);
    letter-spacing: 0.1px;
}
.btn-primary {
    background: var(--primary);
    box-shadow: var(--shadow-xs);
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(59,118,246,0.3);
}
.btn-outline {
    background: var(--white);
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); border-color: var(--border-strong); }

/* Sidebar coherence */
.sidebar { background: var(--dark); box-shadow: var(--shadow-md); }
.sidebar-item {
    position: relative;
    padding: 11px 18px;
    font-weight: 500;
    letter-spacing: 0.2px;
    border-radius: var(--radius-sm);
    margin: 2px 8px;
    transition: var(--transition);
}
.sidebar-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 3px;
    background: var(--brand-400);
    opacity: 0;
    transform: translateX(-6px);
    transition: var(--transition);
}
.sidebar-item:hover { background: rgba(255,255,255,0.06); }
.sidebar-item.active {
    background: linear-gradient(90deg, rgba(59,118,246,0.18), transparent);
    color: #fff;
}
.sidebar-item.active::before { opacity: 1; transform: translateX(0); }

.sidebar-section-title {
    color: rgba(255,255,255,0.35);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: var(--space-4) var(--space-4) var(--space-2);
}

/* Status badges plus pros */
.status-badge {
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Inputs coherents */
.form-group input, .form-group select, .form-group textarea,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="date"],
select, textarea {
    font-family: var(--font-sans);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 3px rgba(59,118,246,0.15);
}

/* Mobile : gaps coherents dans le header */
@media (max-width: 768px) {
    .header-right { gap: 2px; }
    .user-info #user-name { display: none; }
    .user-role-badge { display: none; }
    .user-info { border-left: 0; padding-left: 0; }
}

/* ============================================================
   UX v4.1b — LOGIN PRO, PASSWORD TOGGLE, SHAKE, CONTACT CARDS
   ============================================================ */

/* Login : tagline */
.login-tagline {
    text-align: center;
    color: rgba(255,255,255,0.55);
    font-size: 0.82rem;
    font-weight: 500;
    margin-top: var(--space-2);
    letter-spacing: 0.5px;
}

/* Password wrapper avec toggle */
.password-wrapper {
    position: relative;
}
.password-wrapper input {
    padding-right: 46px;
}
.password-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(255,255,255,0.55);
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}
.password-toggle:hover {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.06);
}
.password-toggle .icon { font-size: 18px; }

/* Options login (remember + forgot) */
.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
    margin-top: -8px;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.75);
    font-size: 0.82rem;
    cursor: pointer;
    user-select: none;
}
.checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--brand-500);
}

.login-link {
    color: var(--brand-300);
    font-size: 0.82rem;
    font-weight: 500;
    text-decoration: none;
    transition: color var(--transition);
}
.login-link:hover {
    color: var(--brand-200);
    text-decoration: underline;
}

/* Bouton login avec spinner */
.btn-login {
    position: relative;
    overflow: hidden;
}
.btn-login .btn-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 18px;
    height: 18px;
    margin-left: -9px;
    margin-top: -9px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}
.btn-login.loading .btn-label { opacity: 0; }
.btn-login.loading .btn-spinner {
    opacity: 1;
    animation: spinner-rotate 0.7s linear infinite;
}
.btn-login.loading { cursor: wait; }
@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}

/* Aide login */
.login-help {
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-size: 0.82rem;
    margin-top: var(--space-4);
    line-height: 1.5;
}

/* Erreur avec animation */
.error-msg {
    color: #ff6b7a;
    font-size: 0.85rem;
    text-align: center;
    margin-top: 12px;
    min-height: 1.2em;
    font-weight: 500;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s, transform 0.2s;
}
.error-msg.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Shake container sur erreur login */
@keyframes shake-login {
    0%, 100% { transform: translateX(0); }
    15% { transform: translateX(-10px); }
    30% { transform: translateX(9px); }
    45% { transform: translateX(-7px); }
    60% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}
.login-container.shake {
    animation: shake-login 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* Contact admin cards (modal oublié) */
.contact-actions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-3);
}
@media (min-width: 480px) {
    .contact-actions-grid { grid-template-columns: 1fr; }
}
.contact-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: var(--transition);
    cursor: pointer;
}
.contact-card:hover {
    background: var(--white);
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.contact-card-icon {
    font-size: 24px;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-xs);
}
.contact-card-label {
    font-weight: 600;
    color: var(--text);
    font-size: 0.95rem;
    flex: 1;
}
.contact-card-value {
    color: var(--text-light);
    font-size: 0.82rem;
    font-family: var(--font-mono);
    margin-left: auto;
}
.contact-whatsapp:hover { border-color: #25d366; }
.contact-whatsapp .contact-card-icon { color: #25d366; }
.contact-call:hover { border-color: var(--brand-500); }
.contact-email:hover { border-color: var(--warning); }

/* Modal small */
.modal-sm { max-width: 480px; }

/* ============================================================
   UX v4.1c — SIDEBAR ICÔNES + SPLASH PRO + DASHBOARD CARDS
   ============================================================ */

/* Sidebar items avec icône */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: rgba(255,255,255,0.72);
    cursor: pointer;
    text-decoration: none;
}
.sidebar-item .icon {
    font-size: 18px;
    color: rgba(255,255,255,0.55);
    flex-shrink: 0;
    transition: color var(--transition);
}
.sidebar-item:hover .icon { color: rgba(255,255,255,0.9); }
.sidebar-item.active .icon { color: var(--brand-300); }
.sidebar-item.active { color: #fff; }
.sidebar-label {
    flex: 1;
    min-width: 0;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ancien .sidebar-section (majuscules plein-style) -> même style que .sidebar-section-title */
.sidebar-section {
    color: rgba(255,255,255,0.35);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: var(--space-4) var(--space-4) var(--space-2);
}

/* Splash screen pro */
.splash-screen {
    background: linear-gradient(135deg, #0b1220 0%, #0f172a 50%, #111827 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    z-index: 9999;
    transition: opacity 0.5s ease-out;
}
.splash-screen.hide {
    opacity: 0;
    pointer-events: none;
}
.splash-content {
    text-align: center;
    color: #fff;
}
.splash-logo-img {
    max-width: 200px;
    height: auto;
    margin-bottom: var(--space-4);
    filter: drop-shadow(0 10px 30px rgba(59,118,246,0.4));
    animation: splash-logo-pulse 2s ease-in-out infinite;
}
@keyframes splash-logo-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}
.splash-logo {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: 8px;
    background: linear-gradient(135deg, #fff, #93c5fd);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: var(--space-2);
}
.splash-sub {
    font-size: 1rem;
    color: rgba(255,255,255,0.5);
    letter-spacing: 8px;
    margin-bottom: var(--space-5);
}
.splash-spinner {
    width: 32px;
    height: 32px;
    border: 2.5px solid rgba(255,255,255,0.15);
    border-top-color: var(--brand-400);
    border-radius: 50%;
    animation: spinner-rotate 0.9s linear infinite;
    margin: 0 auto;
}

/* Dashboard cards (stats tiles) - standardisees */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    border-color: var(--brand-300);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.stat-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-400), var(--brand-600));
    opacity: 0;
    transition: opacity var(--transition);
}
.stat-card:hover::before { opacity: 1; }
.stat-card-label {
    color: var(--text-light);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
}
.stat-card-value {
    color: var(--text);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: var(--space-2);
}
.stat-card-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}
.stat-card-change.up { background: var(--success-soft); color: var(--success); }
.stat-card-change.down { background: var(--danger-soft); color: var(--danger); }

/* Module cards (dashboard quick-links) */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--space-4);
}
.module-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: var(--space-5);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}
.module-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.module-card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: var(--space-3);
}
.module-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 2px;
}
.module-card-desc {
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1.4;
}

/* Section titres */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Modal améliorations - fond + animation */
.modal-overlay {
    animation: modal-fade-in 0.15s ease-out;
}
.modal-overlay:not(.hidden) { display: flex; }
.modal {
    animation: modal-slide-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
}
.modal-header {
    border-bottom: 1px solid var(--border);
    padding: var(--space-4) var(--space-5);
}
.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
}
.modal-body { padding: var(--space-5); }
.modal-footer {
    border-top: 1px solid var(--border);
    padding: var(--space-3) var(--space-5);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}
@keyframes modal-fade-in {
    from { opacity: 0; background: rgba(0,0,0,0); }
    to { opacity: 1; background: rgba(15, 23, 42, 0.55); }
}
@keyframes modal-slide-in {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Mobile sidebar ajustements */
@media (max-width: 768px) {
    .sidebar-item { padding: 13px 18px; }
    .sidebar-label { font-size: 0.95rem; }
    .sidebar-item .icon { font-size: 20px; }
}

/* Accessibilité : outline propre */
*:focus-visible {
    outline: 2px solid var(--brand-400);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Selection text color */
::selection {
    background: var(--brand-100);
    color: var(--brand-900);
}
[data-theme="dark"] ::selection {
    background: var(--brand-800);
    color: #fff;
}

/* ============================================================
   UX v4.2 — MOBILE FINITIONS & ACCESSIBILITE
   ============================================================ */

/* iOS : inputs doivent avoir font-size >= 16px sinon zoom automatique sur focus */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    select, textarea {
        font-size: 16px;
    }
}

/* Touch targets - 44x44 min (Apple HIG / WCAG) */
button, .btn, .btn-icon, a.sidebar-item, a.contact-card, .password-toggle {
    -webkit-tap-highlight-color: transparent;
}

/* Scrollbars discretes */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 10px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* Print : cacher sidebar/header */
@media print {
    .app-header, .sidebar, .toast-container, .notif-panel, .modal-overlay, .btn-fab { display: none !important; }
    .content { padding: 0 !important; }
    body { background: #fff !important; color: #000 !important; }
}

/* Reduced transparency (accessibility) */
@media (prefers-reduced-transparency: reduce) {
    .login-container { background: rgba(17, 24, 39, 0.95); backdrop-filter: none; -webkit-backdrop-filter: none; }
    .toast { background: var(--card-bg); }
}

/* Cohérence avec le dark mode des contact cards */
[data-theme="dark"] .contact-card { background: var(--card-bg); }
[data-theme="dark"] .contact-card-icon { background: var(--bg); }
[data-theme="dark"] .contact-card:hover { background: var(--dark-hover); }

/* Empty state dark */
[data-theme="dark"] .empty-state-icon { background: rgba(59,118,246,0.15); }

/* Focus accessible : ring bleu Matrix */
.btn:focus-visible,
.btn-icon:focus-visible,
a.sidebar-item:focus-visible,
a.login-link:focus-visible,
.password-toggle:focus-visible,
.contact-card:focus-visible {
    outline: 2px solid var(--brand-400);
    outline-offset: 2px;
}

/* Cursor pointer cohérent */
button:not(:disabled), .btn:not(:disabled), .btn-icon, a { cursor: pointer; }
button:disabled, .btn:disabled { cursor: not-allowed; opacity: 0.6; }

/* Disable double-tap zoom on tap targets (évite délai 300ms) */
button, .btn, a { touch-action: manipulation; }

/* ============================================================
   UX v4.3 — MODULES PRO (page header, tables, row actions, pills)
   ============================================================ */

/* ---------- Module page header ---------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.page-header-main {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    flex-wrap: wrap;
    min-width: 0;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin: 0;
}
.record-count {
    font-size: 0.82rem;
    color: var(--text-light);
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-weight: 500;
    white-space: nowrap;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}
.page-actions-btns {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.page-actions .btn-sm {
    padding: 8px 12px;
    font-size: 0.82rem;
    min-height: 36px;
}
.page-actions .btn-sm .icon { font-size: 15px; }
.btn-label-text { white-space: nowrap; }

.btn-add {
    padding: 8px 16px !important;
    font-size: 0.88rem !important;
    min-height: 38px !important;
    font-weight: 600;
    box-shadow: var(--shadow-xs);
}
.btn-add .icon { font-size: 16px; }

/* Module search (sur la même ligne que les actions) */
.module-search {
    position: relative;
    min-width: 200px;
    flex: 1;
    max-width: 320px;
}
.module-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
    pointer-events: none;
}
.module-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: var(--radius);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    color: var(--text);
    outline: none;
    transition: var(--transition);
    height: 36px;
}
.module-search input:focus {
    border-color: var(--brand-400);
    box-shadow: 0 0 0 3px rgba(59,118,246,0.15);
}
.module-search input::placeholder { color: var(--text-muted); }

/* ---------- Data table pro ---------- */
.table-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    margin-bottom: var(--space-4);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.88rem;
}
.data-table thead {
    background: var(--bg);
}
.data-table thead th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 1;
}
.data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color var(--transition), background var(--transition);
}
.data-table thead th.sortable:hover {
    background: var(--table-hover);
    color: var(--text);
}
.data-table thead th .th-sort {
    display: inline-block;
    width: 8px;
    height: 8px;
    border: solid transparent;
    border-width: 0 0 1.5px 1.5px;
    transform: rotate(-45deg);
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0;
    transition: opacity var(--transition), transform var(--transition);
}
.data-table thead th.sort-asc .th-sort,
.data-table thead th.sort-desc .th-sort {
    opacity: 1;
    border-color: var(--primary);
}
.data-table thead th.sort-desc .th-sort { transform: rotate(135deg); }

.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}
.data-table tbody tr.data-row {
    transition: background var(--transition);
    cursor: pointer;
}
.data-table tbody tr.data-row:hover td {
    background: var(--table-hover);
}
.data-table tbody tr:last-child td { border-bottom: 0; }

.data-table .empty-cell {
    padding: 0 !important;
    border-bottom: 0 !important;
    background: transparent !important;
}
.data-table .empty-cell:hover { background: transparent !important; }

/* Row actions cohérentes */
.row-actions {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.btn-row {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}
.btn-row .icon { font-size: 15px; }
.btn-row:hover {
    border-color: var(--border-strong);
    background: var(--bg);
    color: var(--text);
}
.btn-row-view:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.btn-row-edit:hover { color: var(--warning-hover); border-color: var(--warning); background: var(--warning-soft); }
.btn-row-delete:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.btn-row-sig:hover { color: var(--brand-600); border-color: var(--brand-500); background: var(--primary-soft); }

.col-actions { width: 150px; }

/* ---------- Filter pills ---------- */
.filter-pills {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}
.filter-pill {
    background: var(--card-bg);
    color: var(--text-light);
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-sans);
}
.filter-pill:hover {
    border-color: var(--brand-300);
    color: var(--text);
}
.filter-pill.active,
.filter-pill.active-all:first-child { /* initial active du 1er */
    background: var(--brand-500);
    border-color: var(--brand-500);
    color: #fff;
    box-shadow: 0 4px 10px rgba(59,118,246,0.25);
}
.filter-pill .pill-count {
    background: rgba(0,0,0,0.08);
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
}
.filter-pill.active .pill-count,
.filter-pill.active-all:first-child .pill-count {
    background: rgba(255,255,255,0.22);
    color: #fff;
}
[data-theme="dark"] .filter-pill {
    background: var(--card-bg);
    border-color: var(--border);
}
[data-theme="dark"] .filter-pill .pill-count {
    background: rgba(255,255,255,0.08);
}

/* ---------- Status badges (refinés) ---------- */
.status-badge {
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.status-badge.badge-success,
.status-badge.badge-default {
    background: var(--success-soft);
    color: var(--success);
}
.status-badge.badge-warning {
    background: var(--warning-soft);
    color: var(--warning-hover);
}
.status-badge.badge-danger {
    background: var(--danger-soft);
    color: var(--danger);
}
.status-badge.badge-info {
    background: var(--primary-soft);
    color: var(--primary);
}
.status-badge.badge-default {
    background: var(--bg);
    color: var(--text-light);
    border: 1px solid var(--border);
}

/* ---------- Stat cards v2 (utilisées par modules) ---------- */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-5);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    cursor: default;
}
.stat-card:hover {
    border-color: var(--brand-300);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.stat-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--brand-500);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.stat-card:hover::before { transform: scaleX(1); }

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
    gap: var(--space-2);
}
.stat-card-label {
    color: var(--text-light);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.stat-card-ico {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.stat-card-value {
    color: var(--text);
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

/* Variantes couleur (chapeau coloré sur stat-card-ico) */
.stat-blue   .stat-card-ico { background: var(--primary-soft); color: var(--primary); }
.stat-green  .stat-card-ico { background: var(--success-soft); color: var(--success); }
.stat-orange .stat-card-ico { background: var(--warning-soft); color: var(--warning-hover); }
.stat-red    .stat-card-ico { background: var(--danger-soft); color: var(--danger); }
.stat-purple .stat-card-ico { background: rgba(124,58,237,0.15); color: var(--purple); }
.stat-cyan   .stat-card-ico { background: rgba(6,182,212,0.12); color: #0891b2; }
.stat-pink   .stat-card-ico { background: rgba(236,72,153,0.12); color: #db2777; }
.stat-teal   .stat-card-ico { background: rgba(20,184,166,0.12); color: #0d9488; }
.stat-brown  .stat-card-ico { background: rgba(168,85,104,0.12); color: #a16207; }
.stat-indigo .stat-card-ico { background: rgba(79,70,229,0.12); color: #4338ca; }

/* Barre couleur du top selon variante */
.stat-blue::before   { background: var(--primary); }
.stat-green::before  { background: var(--success); }
.stat-orange::before { background: var(--warning); }
.stat-red::before    { background: var(--danger); }
.stat-purple::before { background: var(--purple); }

/* ---------- Pagination pro ---------- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    margin-top: var(--space-4);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.btn-pagination {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 0.85rem;
    min-height: 34px;
}
.btn-pagination .icon { font-size: 14px; }
.page-info {
    color: var(--text-light);
    font-size: 0.88rem;
}
.page-info strong {
    color: var(--text);
    font-weight: 600;
}

/* ---------- Charts cards ---------- */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}
.chart-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-xs);
}
.chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 var(--space-3);
}

/* ---------- Responsive tables ---------- */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-3);
    }
    .page-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .module-search {
        max-width: none;
        min-width: 0;
    }
    .page-actions-btns {
        justify-content: flex-start;
    }
    .data-table thead {
        display: none;
    }
    .data-table, .data-table tbody, .data-table tr, .data-table td {
        display: block;
        width: 100%;
    }
    .data-table tr.data-row {
        margin-bottom: var(--space-3);
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--card-bg);
        padding: var(--space-3);
    }
    .data-table tbody td {
        padding: 6px 0;
        border-bottom: 1px dashed var(--border);
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: var(--space-3);
    }
    .data-table tbody td:last-child { border-bottom: 0; }
    .data-table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        text-transform: uppercase;
        color: var(--text-light);
        letter-spacing: 0.5px;
        flex-shrink: 0;
    }
    .data-table .row-actions-cell {
        justify-content: flex-end;
        padding-top: var(--space-2);
    }
    .data-table .row-actions-cell::before { display: none; }
}

/* Dark mode adjustments */
[data-theme="dark"] .table-container {
    background: var(--card-bg);
}
[data-theme="dark"] .data-table thead {
    background: var(--bg);
}
[data-theme="dark"] .data-table thead th {
    background: #0b1220;
    color: var(--text-light);
    border-bottom-color: var(--border-strong);
}
[data-theme="dark"] .btn-row:hover {
    background: var(--dark-hover);
}
[data-theme="dark"] .module-search input {
    background: var(--input-bg);
    color: var(--text);
}
[data-theme="dark"] .record-count {
    background: var(--dark-hover);
    color: var(--text-light);
    border-color: var(--border);
}

/* ---------- Content wrapper ---------- */
.content {
    padding: var(--space-5);
    padding-top: calc(var(--header-h) + var(--space-4) + var(--safe-top));
    padding-left: calc(var(--sidebar-w) + var(--space-5));
    padding-bottom: calc(var(--space-5) + var(--safe-bottom));
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
    overflow-y: auto;
}
@media (max-width: 768px) {
    .content {
        padding: var(--space-4);
        padding-top: calc(var(--header-h) + var(--space-3) + var(--safe-top));
        padding-bottom: calc(var(--space-7) + var(--safe-bottom));
    }
}

/* ---------- Sections / cards génériques ---------- */
.section-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-xs);
}
.section-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
    gap: var(--space-3);
}
.section-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

/* ---------- Form controls pro ---------- */
.form-group {
    margin-bottom: var(--space-4);
}
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: var(--space-2);
}
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-group .form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--text-light);
    line-height: 1.4;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--input-border-focus);
    box-shadow: 0 0 0 3px rgba(59,118,246,0.15);
}
.form-group input:disabled,
.form-group select:disabled,
.form-group textarea:disabled {
    background: var(--bg);
    color: var(--text-muted);
    cursor: not-allowed;
}
.form-group .error-text {
    color: var(--danger);
    font-size: 0.78rem;
    margin-top: 4px;
}
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-soft);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-3);
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-switch .toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border-strong);
    transition: var(--transition);
    border-radius: 24px;
}
.toggle-switch .toggle-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    transition: var(--transition);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider { background: var(--brand-500); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ============================================================
   UX v4.3b — DASHBOARD ENRICHI
   ============================================================ */

.page-subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
    font-weight: 400;
}

.section-title {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: var(--space-4);
}
.section-title .icon {
    color: var(--primary);
    font-size: 20px;
}

/* Quick actions grid */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}
.quick-action-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text);
    font-family: var(--font-sans);
    text-decoration: none;
    min-height: 96px;
    font-weight: 500;
    font-size: 0.85rem;
}
.quick-action-btn:hover {
    border-color: var(--brand-500);
    background: var(--primary-soft);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.quick-action-ico {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: var(--transition);
}
.quick-action-btn:hover .quick-action-ico {
    background: var(--primary);
    color: #fff;
}
.quick-action-label { text-align: center; }

/* Dashboard bottom (3 colonnes alertes/clients/activity) */
.dashboard-bottom {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-5);
}
.dashboard-col {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-xs);
}

/* Chart title avec icône */
.chart-title .icon {
    color: var(--primary);
    font-size: 18px;
    margin-right: 6px;
    vertical-align: -3px;
}

/* Dashboard stats-grid dans dashboard (padding ajusté) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

/* Loading placeholder (dashboards qui attendent data) */
.loading-placeholder {
    padding: 0;
}

/* Mobile : quick actions carrés compacts */
@media (max-width: 480px) {
    .quick-actions {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-2);
    }
    .quick-action-btn {
        padding: var(--space-3);
        min-height: 80px;
        font-size: 0.75rem;
    }
    .quick-action-ico {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}

/* Detail view modal */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-3);
}
.detail-field {
    padding: var(--space-3);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
.detail-value {
    font-size: 0.9rem;
    color: var(--text);
    word-break: break-word;
}

/* Notification panel */
.notif-panel {
    position: fixed;
    top: calc(var(--header-h) + var(--safe-top) + 8px);
    right: var(--space-3);
    width: 380px;
    max-width: calc(100vw - 24px);
    max-height: 70vh;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    z-index: 1500;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: toast-in 0.2s ease-out;
}
.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}
.notif-header h3 {
    margin: 0;
    font-size: 0.95rem;
}
.notif-header button {
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.notif-header button:hover {
    background: var(--border);
    color: var(--text);
}
#notif-list {
    overflow-y: auto;
    flex: 1;
}

/* ---------- Quick contact icons (dans les rangées) ---------- */
.quick-contact-icons {
    display: inline-flex;
    gap: 4px;
    margin-right: 4px;
}
.quick-contact-icons a, .quick-contact-icons button {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-light);
    border: 1px solid var(--border);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}
.quick-contact-icons a:hover, .quick-contact-icons button:hover {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: var(--primary);
}

/* ============================================================
   FIX v4.3.1 — Chart canvas constraints
   Sans ces règles + maintainAspectRatio=false en JS, les pies/donuts
   prennent toute la largeur disponible (cas employes par departement).
   ============================================================ */
.chart-card {
    display: flex;
    flex-direction: column;
    max-height: 380px;
    overflow: hidden;
}
.chart-card .chart-title {
    flex-shrink: 0;
}
.chart-card canvas {
    max-height: 320px !important;
    max-width: 100% !important;
    height: auto !important;
    width: 100% !important;
    flex: 1;
    min-height: 200px;
}

/* Wrapper si Chart.js veut un parent positionné */
.chart-canvas-wrapper {
    position: relative;
    height: 280px;
    width: 100%;
}

@media (max-width: 768px) {
    .chart-card { max-height: 320px; }
    .chart-card canvas { max-height: 240px !important; }
}

/* ============================================================
   FIX v4.3.2 — Quick contact + PDF row buttons + page header align
   ============================================================ */

/* Contact icons inline (WhatsApp / Phone / Email) - même style que .btn-row */
.quick-contact-icons {
    display: inline-flex;
    gap: 4px;
    margin-right: 4px;
}
.quick-contact-icons .btn-row {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--text-light);
}

/* WhatsApp - vert subtil au hover (pas de fond criard) */
.btn-row-wa { color: var(--text-light); }
.btn-row-wa:hover {
    color: #25d366;
    border-color: #25d366;
    background: rgba(37, 211, 102, 0.1);
}

/* Téléphone - bleu Matrix au hover */
.btn-row-call { color: var(--text-light); }
.btn-row-call:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* Mail - orange au hover */
.btn-row-mail { color: var(--text-light); }
.btn-row-mail:hover {
    color: var(--warning-hover);
    border-color: var(--warning);
    background: var(--warning-soft);
}

/* PDF row */
.btn-row-pdf { color: var(--text-light); }
.btn-row-pdf:hover {
    color: #dc2626;
    border-color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

/* Suppression de l'ancien style btn-pdf laid (gris sombre) */
.btn-pdf, .btn-sm.btn-pdf {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-left: 6px;
    cursor: pointer;
    transition: var(--transition);
}
.btn-pdf:hover, .btn-sm.btn-pdf:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
    color: var(--danger);
}
.btn-sm.btn-sig {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-light);
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-left: 4px;
    cursor: pointer;
    transition: var(--transition);
}
.btn-sm.btn-sig:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

/* Page header — aligner Ajouter avec les autres boutons */
.page-header {
    align-items: center;
}
.page-actions-btns {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.btn-add {
    margin-right: 0 !important;
}

/* Tel column - chiffres en tabular-nums + monospace léger */
.data-table td[data-label="Tél."],
.data-table td[data-label="Tel."] {
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum';
    color: var(--text);
}

/* Empty values dans les tables - placeholder discret */
.data-table td:empty::before {
    content: "—";
    color: var(--text-muted);
    opacity: 0.5;
}

/* Améliorer alignement vertical row-actions */
.row-actions-cell {
    text-align: right;
    white-space: nowrap;
}
.row-actions {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    flex-wrap: nowrap;
}

/* Mobile : boutons row plus petits */
@media (max-width: 768px) {
    .btn-row {
        width: 36px;
        height: 36px;
    }
    .row-actions-cell {
        text-align: left;
    }
}

/* ============================================================
   v4.3.3 — TABS, PAY PROGRESS, LEADERBOARD, NEW BTN ROW VARIANTS
   ============================================================ */

/* Tabs container */
.tabs-container {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}
.tabs-nav {
    display: flex;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 var(--space-3);
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs-nav::-webkit-scrollbar { display: none; }
.tab-btn {
    background: transparent;
    border: 0;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
}
.tab-btn:hover {
    color: var(--text);
    background: var(--card-bg);
}
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}
.tab-content {
    padding: var(--space-4);
    animation: tab-fade-in 0.2s ease-out;
}
.tab-content.hidden { display: none; }
@keyframes tab-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Pay progress (factures) */
.pay-progress {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 130px;
}
.pay-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: var(--radius-pill);
    overflow: hidden;
}
.pay-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--brand-500));
    border-radius: var(--radius-pill);
    transition: width 0.4s ease-out;
}
.pay-progress-text {
    font-size: 0.78rem;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
}
.pay-progress-text strong {
    color: var(--text);
}

/* Leaderboard rank emoji */
.lb-rank {
    display: inline-block;
    min-width: 22px;
    margin-right: 6px;
    font-size: 0.95em;
}

/* Btn-row variants supplémentaires */
.btn-row-pay { color: var(--text-light); }
.btn-row-pay:hover {
    color: var(--success);
    border-color: var(--success);
    background: var(--success-soft);
}
.btn-row-qr { color: var(--text-light); }
.btn-row-qr:hover {
    color: var(--brand-700);
    border-color: var(--brand-500);
    background: var(--primary-soft);
}
.btn-row-convert { color: var(--text-light); }
.btn-row-convert:hover {
    color: var(--purple);
    border-color: var(--purple);
    background: rgba(124,58,237,0.12);
}

/* Adapt tabs for dark mode */
[data-theme="dark"] .tabs-nav {
    background: var(--bg);
    border-bottom-color: var(--border-strong);
}
[data-theme="dark"] .tab-btn:hover {
    background: var(--card-bg);
}

/* Mobile : tabs scroll horizontal */
@media (max-width: 768px) {
    .tab-btn {
        font-size: 0.85rem;
        padding: var(--space-3);
    }
    .pay-progress { min-width: 100px; }
}

/* Page-subtitle dans header (sous le titre) */
.page-header .page-subtitle {
    color: var(--text-light);
    font-size: 0.88rem;
    font-weight: 400;
    margin-left: var(--space-3);
}

/* ============================================================
   v4.3.5 — POINTAGE & COMMERCIAL DASHBOARD POLISH
   ============================================================ */
.pointage-clock {
    color: var(--text-light);
    font-family: var(--font-mono);
    font-size: 1rem;
    background: var(--bg);
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
}
.pointage-nav {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-3);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.pointage-nav input[type="date"] {
    padding: 7px 12px;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.88rem;
}
.pointage-nav .btn-sm { min-height: 36px; }
.pointage-actions {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}
.pointage-actions .btn { font-weight: 600; }
.pointage-actions .btn-success {
    background: var(--success);
    color: #fff;
    border: 0;
}
.pointage-actions .btn-success:hover { background: var(--success-hover); }
.pointage-actions .btn-danger {
    background: var(--danger);
    color: #fff;
    border: 0;
}
.pointage-actions .btn-danger:hover { background: var(--danger-hover); }

/* Commercial dashboard */
.commercial-objectif-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow-xs);
}
.objectif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}
.objectif-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}
.objectif-title .icon { color: var(--primary); font-size: 18px; }
.objectif-pct {
    font-size: 1.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.objectif-bar-wrap {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: var(--radius-pill);
    overflow: hidden;
    margin-bottom: var(--space-3);
}
.objectif-bar {
    height: 100%;
    border-radius: var(--radius-pill);
    transition: width 0.6s ease-out;
}
.objectif-footer {
    display: flex;
    justify-content: space-between;
    color: var(--text-light);
    font-size: 0.88rem;
    flex-wrap: wrap;
    gap: var(--space-2);
}
.evo-up { color: var(--success); font-weight: 600; }
.evo-down { color: var(--danger); font-weight: 600; }
.evo-flat { color: var(--text-muted); }

/* Commercial grid */
.commercial-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}
@media (max-width: 768px) { .commercial-grid { grid-template-columns: 1fr; } }

.commercial-leaderboard-card,
.commercial-topclients-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-xs);
}

.leaderboard-list, .topclients-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.lb-row, .tc-row {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: var(--space-3);
    align-items: center;
    padding: var(--space-3);
    background: var(--bg);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.lb-row:hover, .tc-row:hover {
    background: var(--primary-soft);
}
.lb-row.lb-me {
    background: linear-gradient(90deg, var(--primary-soft), transparent);
    border: 1px solid var(--primary);
}
.lb-rank, .tc-rank {
    font-weight: 700;
    text-align: center;
    color: var(--text-light);
    font-size: 1rem;
}
.lb-row.lb-me .lb-rank { color: var(--primary); }
.lb-name, .tc-name {
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.lb-you {
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
}
.lb-ca, .tc-ca {
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.badge-position {
    display: inline-block;
    background: var(--primary-soft);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.78rem;
    font-weight: 500;
    margin-left: var(--space-2);
}
.badge-position strong { color: var(--primary); }

.commercial-footer-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-light);
    font-size: 0.85rem;
}
.commercial-footer-info .icon { color: var(--primary); font-size: 14px; vertical-align: -2px; }
.commercial-footer-info strong { color: var(--text); }

@media (max-width: 768px) {
    .objectif-pct { font-size: 1.4rem; }
    .pointage-actions .btn { width: 100%; justify-content: center; }
    .pointage-nav { gap: var(--space-2); }
}
