/* ========== RESET & BASE ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1E3A5F;
    --primary-light: #2C5282;
    --secondary: #2196F3;
    --accent: #00BCD4;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --bg: #F5F7FA;
    --card: #FFFFFF;
    --text: #1A1A2E;
    --text-secondary: #6B7280;
    --border: #E5E7EB;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --bottomnav-height: 60px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ========== LOGIN PAGE ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: url('https://mgx-backend-cdn.metadl.com/generate/images/361428/2026-03-03/00e33f03-9cc0-4019-83f1-3982e983b5f2.png') center/cover no-repeat;
    position: relative;
    padding: 16px;
}

.login-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 20, 40, 0.75);
    backdrop-filter: blur(4px);
}

.login-container {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.6s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 28px;
    color: var(--primary);
    font-weight: 700;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.login-form label i {
    color: var(--secondary);
    margin-right: 6px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.3s;
    outline: none;
}

.login-form input:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.error-msg {
    background: #FEE2E2;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.login-footer p {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    white-space: nowrap;
    touch-action: manipulation;
}

.btn i { font-size: 14px; }

.btn-primary {
    background: var(--secondary);
    color: #fff;
}
.btn-primary:hover { background: #1976D2; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3); }

.btn-secondary {
    background: #E5E7EB;
    color: var(--text);
}
.btn-secondary:hover { background: #D1D5DB; }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #388E3C; }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: #D32F2F; }

.btn-warning {
    background: var(--warning);
    color: #fff;
}
.btn-warning:hover { background: #F57C00; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }

.btn-icon {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text);
    padding: 8px;
    border-radius: 8px;
    transition: background 0.3s;
    touch-action: manipulation;
}
.btn-icon:hover { background: rgba(0,0,0,0.05); }

.btn-logout {
    background: rgba(255,255,255,0.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    width: 100%;
    justify-content: center;
    padding: 10px;
    font-size: 13px;
}
.btn-logout:hover { background: rgba(255,255,255,0.2); }

.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* ========== APP LAYOUT ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ========== SIDEBAR OVERLAY ========== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--primary) 0%, #0F2440 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
}

.btn-close-sidebar {
    display: none;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.3s;
}
.btn-close-sidebar:hover { color: #fff; background: rgba(255,255,255,0.1); }

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 10px;
    margin-bottom: 4px;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 500;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-item.active {
    background: var(--secondary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.nav-item i { width: 20px; text-align: center; font-size: 16px; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 12px;
}

.user-info i { font-size: 32px; margin-bottom: 6px; color: var(--accent); }
.user-info span { font-size: 14px; font-weight: 600; }
.user-info small { font-size: 11px; color: rgba(255,255,255,0.6); text-transform: capitalize; }

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s;
    min-width: 0;
}

.sidebar.collapsed + .main-content { margin-left: 0; }

.top-bar {
    height: var(--topbar-height);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.top-bar h2 { font-size: 18px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.user-badge {
    background: var(--bg);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.content-area {
    padding: 24px;
}

/* ========== PAGES ========== */
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 12px;
}

.page-header h3 { font-size: 20px; font-weight: 700; }

/* ========== TABLE RESPONSIVE ========== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
    border: 1.5px solid #D6E4F0;
    background: #fff;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.04);
}

.table-responsive .table {
    margin-bottom: 0;
}

/* When table-responsive is directly inside card-body, blend seamlessly */
.card-body > .table-responsive {
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

/* When DataTables wrapper is inside card-body */
.card-body > .dataTables_wrapper .table-responsive {
    border: 1.5px solid #D6E4F0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.04);
}

/* ========== STATS CARDS ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card);
    border-radius: 14px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: transform 0.3s, box-shadow 0.3s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    flex-shrink: 0;
}

.stat-blue .stat-icon { background: linear-gradient(135deg, var(--secondary), #1565C0); }
.stat-green .stat-icon { background: linear-gradient(135deg, var(--success), #2E7D32); }
.stat-cyan .stat-icon { background: linear-gradient(135deg, var(--accent), #00838F); }
.stat-orange .stat-icon { background: linear-gradient(135deg, var(--warning), #E65100); }

.stat-info h3 { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-info p { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }

/* ========== CARDS ========== */
.card {
    background: var(--card);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 i { color: var(--secondary); }

.card-body { padding: 24px; }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

/* ========== TABLES ========== */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 600px;
}

.table thead th {
    background: linear-gradient(180deg, #EBF2FA 0%, #DDE8F3 100%);
    padding: 14px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--primary);
    border-bottom: 3px solid var(--secondary);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table thead th:first-child {
    border-radius: 8px 0 0 0;
}

.table thead th:last-child {
    border-radius: 0 8px 0 0;
}

.table tbody td {
    padding: 13px 16px;
    font-size: 14px;
    border-bottom: 1px solid #EBF2FA;
    vertical-align: middle;
    transition: all 0.2s ease;
}

.table tbody td:first-child {
    font-weight: 600;
    color: var(--primary);
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background: #EDF5FD;
    box-shadow: inset 4px 0 0 var(--secondary);
}

.table tbody tr:nth-child(odd) {
    background: #F6F9FD;
}

.table tbody tr:nth-child(odd):hover {
    background: #EDF5FD;
    box-shadow: inset 4px 0 0 var(--secondary);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:last-child td:first-child {
    border-radius: 0 0 0 8px;
}

.table tbody tr:last-child td:last-child {
    border-radius: 0 0 8px 0;
}

/* ========== FORMS ========== */
.form-group {
    margin-bottom: 18px;
    flex: 1;
    min-width: 0;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    outline: none;
    font-family: inherit;
    background: #fff;
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

textarea.form-control { resize: vertical; }

select.form-control { cursor: pointer; }

.form-row {
    display: flex;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.form-actions-inline {
    display: flex;
    align-items: flex-end;
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group .form-control { flex: 1; }

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar .form-control {
    max-width: 200px;
    border-color: #D6E4F0;
    background: #F8FAFC;
}

.filter-bar .form-control:focus {
    border-color: var(--secondary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(33, 150, 243, 0.12);
}

/* ========== TABS ========== */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--card);
    border-radius: 10px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
    color: var(--text-secondary);
    touch-action: manipulation;
}

.tab-btn.active {
    background: var(--secondary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.demande-tabs {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.demande-tab-btn {
    flex: 1;
    padding: 16px 24px;
    border: 2px solid var(--border);
    background: var(--card);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    touch-action: manipulation;
}

.demande-tab-btn.active {
    border-color: var(--secondary);
    color: var(--secondary);
    background: rgba(33, 150, 243, 0.05);
}

.demande-tab-content { display: none; }
.demande-tab-content.active { display: block; }

/* ========== QR SECTION ========== */
.qr-section {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.qr-scan-area {
    flex: 1;
    min-width: 250px;
}

.qr-reader-box {
    border: 3px dashed var(--border);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

.qr-reader-box:hover { border-color: var(--secondary); }

.qr-reader-box i { color: var(--secondary); margin-bottom: 12px; }
.qr-reader-box p { margin-bottom: 16px; font-size: 14px; }

#qrVideoEl {
    width: 100%;
    max-width: 300px;
    border-radius: 12px;
}

#qrVideo {
    text-align: center;
    margin-bottom: 16px;
}

#qrVideo video {
    border: 3px solid var(--secondary);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.2);
}

#qrCanvas {
    display: none;
}

.qr-manual { margin-top: 16px; }
.qr-manual label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }

.client-info-card {
    flex: 1;
    min-width: 250px;
    background: rgba(33, 150, 243, 0.05);
    border: 2px solid var(--secondary);
    border-radius: 14px;
    padding: 24px;
}

.client-info-card h4 {
    color: var(--secondary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========== MODAL ========== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s;
    padding: 16px;
}

.modal-content {
    background: var(--card);
    border-radius: 16px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

.modal-lg { max-width: 700px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 18px; font-weight: 700; }

.btn-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
    flex-shrink: 0;
}

.btn-close:hover { background: #E5E7EB; }

.modal-body { padding: 24px; }

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.2px;
    line-height: 1.3;
}

.badge-success { background: #E8F5E9; color: #2E7D32; border: 1px solid rgba(46, 125, 50, 0.15); }
.badge-warning { background: #FFF3E0; color: #E65100; border: 1px solid rgba(230, 81, 0, 0.15); }
.badge-danger { background: #FFEBEE; color: #C62828; border: 1px solid rgba(198, 40, 40, 0.15); }
.badge-info { background: #E3F2FD; color: #1565C0; border: 1px solid rgba(21, 101, 192, 0.15); }
.badge-primary { background: #E3F2FD; color: var(--secondary); border: 1px solid rgba(33, 150, 243, 0.15); }

/* ========== FIDELITE CARD ========== */
.carte-preview {
    margin-top: 24px;
    text-align: center;
}

.fidelite-card {
    width: 340px;
    max-width: 100%;
    margin: 0 auto 24px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.fidelite-card-front {
    background: linear-gradient(160deg, #1E3A5F 0%, #0F2440 60%, #0a1a30 100%);
    padding: 32px 28px;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.fidelite-card-front::before {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;
    width: 140px;
    height: 140px;
    background: rgba(33, 150, 243, 0.08);
    border-radius: 50%;
}

.fidelite-card-front::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: -30px;
    width: 100px;
    height: 100px;
    background: rgba(0, 188, 212, 0.06);
    border-radius: 50%;
}

.fidelite-card-front > * { position: relative; z-index: 1; }

.fidelite-header-centered {
    margin-bottom: 16px;
}

.fidelite-logo-large {
    width: 72px;
    height: 72px;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3));
}

.fidelite-id-centered {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.95);
    margin-bottom: 20px;
    padding: 6px 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.15);
}

.fidelite-qr-large {
    background: #fff;
    padding: 14px;
    border-radius: 14px;
    margin-bottom: 20px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    display: inline-block;
}

.fidelite-qr-large canvas {
    display: block;
}

.fidelite-slogan {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.15);
    width: 100%;
}

.fidelite-slogan p {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #FFD54F;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.carte-actions { margin-top: 16px; }

/* ========== TICKET PRINT ========== */
.ticket-print {
    display: none;
}

@media print {
    body * { visibility: hidden; }
    .ticket-print, .ticket-print * { visibility: visible; }
    .ticket-print {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 80mm;
        background: #fff;
        padding: 8px;
        font-size: 12px;
    }
}

.ticket-content {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
}

.ticket-content .ticket-header {
    text-align: center;
    border-bottom: 1px dashed #000;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.ticket-content .ticket-body { margin-bottom: 8px; }

.ticket-content .ticket-row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

.ticket-content .ticket-footer {
    text-align: center;
    border-top: 1px dashed #000;
    padding-top: 8px;
    margin-top: 8px;
}

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: calc(100vw - 40px);
}

.toast {
    padding: 14px 20px;
    border-radius: 10px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 250px;
    max-width: 100%;
    word-break: break-word;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--secondary); }
.toast-warning { background: var(--warning); }

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ========== TOP CLIENTS ========== */
.top-clients-list .client-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    gap: 8px;
}

.top-clients-list .client-item:last-child { border-bottom: none; }

.client-item-info { display: flex; align-items: center; gap: 12px; min-width: 0; }
.client-item-info .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

.client-item-name { font-weight: 600; font-size: 14px; }
.client-item-id { font-size: 12px; color: var(--text-secondary); }
.client-item-count { font-weight: 700; color: var(--secondary); font-size: 14px; white-space: nowrap; }

/* ========== PROFIL CLIENT DETAIL ========== */
.profil-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.profil-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary), var(--accent));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
    flex-shrink: 0;
}

.profil-info h3 { font-size: 20px; margin-bottom: 4px; }
.profil-info p { color: var(--text-secondary); font-size: 14px; }

.profil-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.profil-stat {
    text-align: center;
    padding: 16px;
    background: var(--bg);
    border-radius: 12px;
}

.profil-stat h4 { font-size: 24px; color: var(--secondary); }
.profil-stat p { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

/* ========== CHART ========== */
canvas { max-width: 100%; }

/* ========== WHATSAPP SECTION ========== */
.wa-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
}

.wa-status-ok {
    background: #E8F5E9;
    color: #2E7D32;
}

.wa-status-warning {
    background: #FFF3E0;
    color: #E65100;
}

.wa-status-error {
    background: #FFEBEE;
    color: #C62828;
}

.wa-filter-row {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.wa-filter-row .form-control {
    max-width: 250px;
}

.wa-select-all-label {
    font-size: 14px;
    white-space: nowrap;
}

.wa-selected-count {
    display: block;
    font-size: 13px;
    color: var(--secondary);
    font-weight: 600;
    margin-bottom: 12px;
}

.wa-clients-list {
    max-height: 300px;
    overflow-y: auto;
    border: 2px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}

.wa-client-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.wa-client-item:hover {
    background: rgba(33, 150, 243, 0.05);
}

.wa-client-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.wa-client-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.wa-client-name {
    font-weight: 600;
    font-size: 14px;
}

.wa-client-phone {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========== WHATSAPP ATTACHMENT ========== */
.wa-attachment-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    transition: border-color 0.3s, background 0.3s;
    overflow: hidden;
}

.wa-attachment-zone.dragover {
    border-color: var(--secondary);
    background: rgba(33, 150, 243, 0.05);
}

.wa-attachment-empty {
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    position: relative;
    color: var(--text-secondary);
}

.wa-attachment-empty i {
    font-size: 32px;
    color: var(--secondary);
    margin-bottom: 10px;
    display: block;
}

.wa-attachment-empty p {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
}

.wa-attachment-empty small {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

.wa-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.wa-attachment-preview {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.wa-attachment-info {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
}

.wa-attachment-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
    background: #E3F2FD;
    color: var(--secondary);
}

.wa-attachment-icon.icon-image { background: #E8F5E9; color: #2E7D32; }
.wa-attachment-icon.icon-pdf { background: #FFEBEE; color: #C62828; }
.wa-attachment-icon.icon-doc { background: #E3F2FD; color: #1565C0; }
.wa-attachment-icon.icon-excel { background: #E8F5E9; color: #2E7D32; }

.wa-attachment-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.wa-attachment-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wa-attachment-size {
    font-size: 12px;
    color: var(--text-secondary);
}

.wa-attachment-img-preview {
    width: 100%;
    max-width: 200px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.wa-attachment-img-preview img {
    width: 100%;
    height: auto;
    display: block;
}

/* ========== BOTTOM NAVIGATION (Mobile) ========== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottomnav-height);
    background: var(--card);
    border-top: 1px solid var(--border);
    z-index: 90;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    padding: 6px 8px;
    border-radius: 8px;
    transition: all 0.2s;
    gap: 2px;
    min-width: 56px;
    touch-action: manipulation;
}

.bottom-nav-item i {
    font-size: 18px;
}

.bottom-nav-item.active {
    color: var(--secondary);
}

.bottom-nav-item:active {
    background: rgba(33, 150, 243, 0.1);
}

/* ========== ACTION BUTTONS IN TABLE ========== */
.action-btns {
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
}

.action-btns .btn {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(30, 58, 95, 0.1);
    transition: all 0.25s ease;
}

.action-btns .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.15);
}

.action-btns .btn-primary {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-light) 100%);
    border: none;
}

.action-btns .btn-danger {
    background: linear-gradient(135deg, #F44336 0%, #D32F2F 100%);
    border: none;
}

.action-btns .btn-success {
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
    border: none;
}

.action-btns .btn-warning {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    border: none;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state i { font-size: 48px; margin-bottom: 16px; color: var(--border); }
.empty-state p { font-size: 15px; }

/* ========== SIDEBAR NAV DIVIDER ========== */
.sidebar-nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 12px 8px;
}

/* ========== ACCESS MANAGEMENT ========== */
.am-section-title {
    margin-bottom: 16px;
}

.am-section-title h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 10px;
}

.am-section-title h4 i {
    color: var(--secondary);
}

.am-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
    padding: 12px 16px;
    background: rgba(33, 150, 243, 0.04);
    border-left: 3px solid var(--secondary);
    border-radius: 0 8px 8px 0;
}

/* Roles Grid */
.am-roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.am-role-card {
    background: var(--card);
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.am-role-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.am-role-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.am-role-icon-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}

.am-role-icon-administrateur { background: linear-gradient(135deg, #F44336, #D32F2F); }
.am-role-icon-comptable { background: linear-gradient(135deg, #4CAF50, #2E7D32); }
.am-role-icon-laveur { background: linear-gradient(135deg, #2196F3, #1565C0); }
.am-role-icon-wrapper:not(.am-role-icon-administrateur):not(.am-role-icon-comptable):not(.am-role-icon-laveur) {
    background: linear-gradient(135deg, #9C27B0, #7B1FA2);
}

.am-role-info {
    flex: 1;
    min-width: 0;
}

.am-role-info h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.am-role-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

.am-role-stats {
    display: flex;
    padding: 14px 20px;
    gap: 16px;
}

.am-role-stat {
    flex: 1;
    text-align: center;
    padding: 10px;
    background: var(--bg);
    border-radius: 10px;
}

.am-role-stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: var(--secondary);
}

.am-role-stat-label {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Access Management Table */
.am-table {
    min-width: auto;
}

.am-table thead th {
    text-align: center;
    padding: 12px 14px;
}

.am-page-label-th,
.am-action-label-th {
    text-align: left !important;
    min-width: 180px;
}

.am-role-th {
    min-width: 120px;
    text-align: center !important;
}

.am-page-cell {
    padding: 10px 16px !important;
}

.am-page-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.am-page-icon {
    width: 20px;
    text-align: center;
    color: var(--secondary);
    font-size: 14px;
}

.am-toggle-cell {
    text-align: center !important;
    padding: 8px 12px !important;
}

.am-action-label-cell {
    padding: 10px 16px !important;
}

.am-action-badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

/* Toggle Switch */
.am-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.am-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.am-toggle-slider {
    position: absolute;
    inset: 0;
    background: #D1D5DB;
    border-radius: 24px;
    transition: all 0.3s;
}

.am-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.am-toggle input:checked + .am-toggle-slider {
    background: var(--success);
}

.am-toggle input:checked + .am-toggle-slider::before {
    transform: translateX(20px);
}

.am-toggle input:disabled + .am-toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Module Cards */
.am-module-card {
    background: var(--bg);
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
}

.am-module-header {
    padding: 14px 20px;
    background: rgba(33, 150, 243, 0.06);
    border-bottom: 1px solid var(--border);
}

.am-module-header h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.am-module-header h4 i {
    color: var(--secondary);
    font-size: 13px;
}

.am-module-card .table {
    min-width: auto;
    margin: 0;
}

.am-module-card .table thead th {
    background: transparent;
    border-bottom: 1px solid var(--border);
}

.am-module-card .table tbody td {
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.am-module-card .table tbody tr:last-child td {
    border-bottom: none;
}

/* ========== PAYMENT METHOD BADGES ========== */
.badge-espece { background: #E8F5E9; color: #2E7D32; }
.badge-wave { background: #E3F2FD; color: #1565C0; }
.badge-orange { background: #FFF3E0; color: #E65100; }
.badge-mtn { background: #FFFDE7; color: #F57F17; }

.payment-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.payment-badge-espece { background: #E8F5E9; color: #2E7D32; }
.payment-badge-wave { background: #E0F7FA; color: #00838F; }
.payment-badge-orange { background: #FFF3E0; color: #E65100; }
.payment-badge-mtn { background: #FFFDE7; color: #F57F17; }

/* ========== COUT PREVIEW ========== */
.cout-preview {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.08), rgba(0, 188, 212, 0.08));
    border: 2px solid var(--secondary);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease;
}

.cout-preview-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.cout-preview-amount {
    font-size: 22px;
    font-weight: 700;
    color: var(--secondary);
}

/* ========== VALIDATION SUMMARY ========== */
.validation-summary {
    background: var(--bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.validation-summary .val-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.validation-summary .val-row:last-child {
    border-bottom: none;
    padding-top: 12px;
    font-size: 18px;
    font-weight: 700;
    color: var(--secondary);
}

.validation-summary .val-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.validation-summary .val-value {
    font-weight: 600;
    color: var(--text);
}

/* ========== PRINT CARTE ========== */
@media print {
    .fidelite-card {
        box-shadow: none;
        border: 2px solid #1E3A5F;
    }
    .fidelite-card-front::before,
    .fidelite-card-front::after {
        display: none;
    }
}

/* ========== GESTION DES LAVEURS ========== */
.laveur-commission-amount {
    color: var(--warning);
    font-weight: 700;
    font-size: 14px;
}

.laveur-commission-total {
    color: #fff;
    font-weight: 700;
    font-size: 16px;
}

.laveur-total-row {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 60%, var(--secondary) 100%);
    color: #fff;
}

.laveur-total-row td {
    color: #fff !important;
    padding: 14px 16px !important;
    font-size: 15px;
    border-bottom: none !important;
}

.laveur-detail-total {
    margin-top: 24px;
    background: var(--bg);
    border-radius: 12px;
    padding: 20px;
}

.laveur-detail-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 15px;
    border-bottom: 1px solid var(--border);
}

.laveur-detail-total-row:last-child {
    border-bottom: none;
    padding-top: 14px;
}

.laveur-detail-total-commission {
    font-size: 18px;
    color: var(--warning);
}

.laveur-detail-total-commission strong {
    color: var(--warning);
    font-size: 20px;
}

/* ================================================================ */
/* ==================== RESPONSIVE DESIGN ========================= */
/* ================================================================ */

/* ========== LARGE TABLET (max-width: 1024px) ========== */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ========== TABLET & MOBILE (max-width: 768px) ========== */
@media (max-width: 768px) {
    /* --- Sidebar --- */
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .btn-close-sidebar {
        display: flex;
    }

    /* --- Main content --- */
    .main-content {
        margin-left: 0;
        padding-bottom: var(--bottomnav-height);
    }

    /* --- Bottom nav --- */
    .bottom-nav {
        display: flex;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    /* --- Content area --- */
    .content-area {
        padding: 16px;
    }

    /* --- Top bar --- */
    .top-bar {
        padding: 0 12px;
        gap: 8px;
        height: 56px;
    }

    .top-bar h2 {
        font-size: 15px;
    }

    .top-bar-right #currentDate { display: none; }

    .user-badge {
        padding: 4px 10px;
        font-size: 12px;
    }

    /* --- Form rows stack on mobile --- */
    .form-row { 
        flex-direction: column; 
        gap: 0; 
    }

    /* --- Stats grid --- */
    .stats-grid { 
        grid-template-columns: repeat(2, 1fr); 
        gap: 10px; 
    }

    .stat-card {
        padding: 14px;
        gap: 12px;
    }

    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 18px;
        border-radius: 10px;
    }

    .stat-info h3 { font-size: 18px; }
    .stat-info p { font-size: 11px; }

    /* --- Filter bars --- */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-bar .form-control { max-width: 100%; }

    /* --- Demande tabs --- */
    .demande-tabs { 
        flex-direction: column; 
        gap: 8px; 
    }
    .demande-tab-btn { 
        padding: 14px 16px; 
        font-size: 14px; 
    }

    /* --- QR section --- */
    .qr-section { flex-direction: column; }
    .qr-scan-area { min-width: 0; }
    .client-info-card { min-width: 0; }

    /* --- Fidelite card --- */
    .fidelite-card { width: 100%; max-width: 340px; }

    /* --- Profil stats --- */
    .profil-stats { grid-template-columns: 1fr; }
    .profil-header { 
        flex-direction: column; 
        text-align: center; 
    }

    /* --- Page header --- */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .page-header h3 { font-size: 17px; }

    .btn-group {
        width: 100%;
    }
    .btn-group .btn {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
        font-size: 13px;
    }

    /* --- Cards --- */
    .card-body { padding: 16px; }
    .card-header { padding: 14px 16px; }
    .card-header h3 { font-size: 14px; }

    /* --- Modal: bottom sheet style --- */
    .modal {
        padding: 0;
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 20px 20px 0 0;
        animation: slideUpModal 0.3s ease;
    }

    @keyframes slideUpModal {
        from { transform: translateY(100%); }
        to { transform: translateY(0); }
    }

    .modal-lg { max-width: 100%; }

    .modal-header {
        padding: 16px 20px;
        position: sticky;
        top: 0;
        background: var(--card);
        z-index: 1;
    }

    .modal-header h3 { font-size: 16px; }

    .modal-body { padding: 16px 20px; }

    /* --- Dashboard grid --- */
    .dashboard-grid { grid-template-columns: 1fr; gap: 12px; }

    /* --- Tabs --- */
    .tabs { gap: 2px; padding: 3px; }
    .tab-btn { padding: 10px 12px; font-size: 13px; }

    /* --- WhatsApp --- */
    .wa-filter-row { flex-direction: column; align-items: stretch; }
    .wa-filter-row .form-control { max-width: 100%; }
    .wa-clients-list { max-height: 200px; }

    /* --- QR reader --- */
    .qr-reader-box { padding: 24px; }

    /* --- Hide button text on small screens --- */
    .btn-text { display: none; }

    /* --- Buttons: bigger touch targets --- */
    .btn {
        padding: 12px 16px;
        min-height: 44px;
    }
    .btn-sm { 
        padding: 8px 12px; 
        min-height: 36px; 
    }

    /* --- Form controls: bigger touch targets --- */
    .form-control {
        padding: 12px 14px;
        font-size: 16px; /* Prevents iOS zoom on focus */
        min-height: 44px;
    }

    /* --- Table adjustments --- */
    .table thead th {
        padding: 10px 12px;
        font-size: 11px;
        letter-spacing: 0.4px;
    }
    .table tbody td {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .table-responsive {
        border-radius: 8px;
    }

    /* --- Action buttons in table --- */
    .action-btns {
        flex-wrap: wrap;
        gap: 4px;
    }
    .action-btns .btn {
        padding: 8px 10px;
        min-height: 36px;
    }

    /* --- Toast on mobile --- */
    .toast-container {
        top: auto;
        bottom: calc(var(--bottomnav-height) + 12px);
        right: 12px;
        left: 12px;
        max-width: 100%;
    }

    .toast {
        min-width: 0;
        width: 100%;
        font-size: 13px;
        padding: 12px 16px;
    }

    /* --- Cout preview --- */
    .cout-preview {
        flex-direction: column;
        text-align: center;
        gap: 8px;
        padding: 14px 16px;
    }
    .cout-preview-amount { font-size: 20px; }

    /* --- Validation summary --- */
    .validation-summary { padding: 14px; }
    .validation-summary .val-row { 
        font-size: 13px; 
        flex-wrap: wrap;
        gap: 4px;
    }
    .validation-summary .val-row:last-child { font-size: 16px; }

    /* --- Form actions --- */
    .form-actions {
        flex-direction: column;
    }
    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    /* --- Access management --- */
    .am-roles-grid {
        grid-template-columns: 1fr;
    }

    .am-page-label-th,
    .am-action-label-th {
        min-width: 130px;
    }

    .am-role-th {
        min-width: 90px;
        font-size: 11px;
    }

    .am-toggle {
        width: 38px;
        height: 22px;
    }

    .am-toggle-slider::before {
        width: 16px;
        height: 16px;
    }

    .am-toggle input:checked + .am-toggle-slider::before {
        transform: translateX(16px);
    }

    .am-description {
        font-size: 12px;
        padding: 10px 12px;
    }

    /* --- Laveur detail --- */
    .laveur-detail-total { padding: 14px; }
    .laveur-detail-total-row { 
        font-size: 13px; 
        flex-wrap: wrap;
        gap: 4px;
    }
    .laveur-detail-total-commission { font-size: 15px; }
    .laveur-detail-total-commission strong { font-size: 17px; }

    /* --- Login adjustments --- */
    .login-container {
        padding: 32px 24px;
        border-radius: 16px;
    }

    .login-logo .logo-img {
        width: 64px;
        height: 64px;
    }

    .login-logo h1 { font-size: 22px; }
    .login-logo p { font-size: 12px; }

    .login-footer p { font-size: 10px; }

    /* --- Fidelite card mobile --- */
    .fidelite-card-front { padding: 24px 20px; }
    .fidelite-logo-large { width: 60px; height: 60px; }
    .fidelite-id-centered { font-size: 14px; }
    .fidelite-slogan p { font-size: 13px; }

    /* --- Input group --- */
    .input-group {
        flex-direction: row;
    }
    .input-group .btn {
        min-width: 44px;
        padding: 10px 14px;
    }

    /* --- Profil client --- */
    .profil-avatar {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }
    .profil-info h3 { font-size: 18px; }

    .profil-stat h4 { font-size: 20px; }
    .profil-stat p { font-size: 11px; }

    /* --- Empty state --- */
    .empty-state {
        padding: 32px 16px;
    }
    .empty-state i { font-size: 36px; }
    .empty-state p { font-size: 13px; }
}

/* ========== SMALL PHONES (max-width: 480px) ========== */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }

    .content-area { padding: 10px; }

    .top-bar { 
        padding: 0 10px; 
        height: 52px;
    }
    .top-bar h2 { font-size: 14px; }

    /* --- Stat cards compact --- */
    .stat-card {
        padding: 12px;
        gap: 10px;
    }

    .stat-icon {
        width: 38px;
        height: 38px;
        font-size: 16px;
        border-radius: 8px;
    }

    .stat-info h3 { font-size: 16px; }
    .stat-info p { font-size: 10px; }

    /* --- Cards --- */
    .card { border-radius: 12px; margin-bottom: 12px; }
    .card-body { padding: 12px; }
    .card-header { padding: 12px; }
    .card-header h3 { font-size: 13px; gap: 8px; }

    /* --- Page header --- */
    .page-header { margin-bottom: 16px; }
    .page-header h3 { font-size: 16px; }

    /* --- Buttons --- */
    .btn-group .btn {
        font-size: 12px;
        padding: 10px 8px;
    }

    /* --- Bottom nav compact --- */
    .bottom-nav-item {
        font-size: 9px;
        min-width: 48px;
        padding: 4px 6px;
    }
    .bottom-nav-item i { font-size: 16px; }

    /* --- Table compact --- */
    .table thead th {
        padding: 8px 8px;
        font-size: 10px;
    }
    .table tbody td {
        padding: 8px 8px;
        font-size: 12px;
    }

    /* --- Badge compact --- */
    .badge { padding: 3px 8px; font-size: 10px; }
    .payment-badge { padding: 3px 8px; font-size: 10px; }

    /* --- Demande tabs compact --- */
    .demande-tab-btn {
        padding: 12px;
        font-size: 13px;
        gap: 8px;
    }
    .demande-tab-btn i { font-size: 16px; }

    /* --- QR reader compact --- */
    .qr-reader-box {
        padding: 20px;
    }
    .qr-reader-box i { font-size: 2em; }
    .qr-reader-box p { font-size: 13px; margin-bottom: 12px; }

    /* --- Client info card compact --- */
    .client-info-card { padding: 16px; }

    /* --- Modal compact --- */
    .modal-content {
        max-height: 95vh;
    }
    .modal-header { padding: 14px 16px; }
    .modal-header h3 { font-size: 15px; }
    .modal-body { padding: 14px 16px; }

    /* --- Form group compact --- */
    .form-group { margin-bottom: 14px; }
    .form-group label { font-size: 12px; margin-bottom: 4px; }

    /* --- Cout preview compact --- */
    .cout-preview { padding: 12px; }
    .cout-preview-label { font-size: 13px; }
    .cout-preview-amount { font-size: 18px; }

    /* --- WhatsApp compact --- */
    .wa-clients-list { max-height: 180px; padding: 6px; }
    .wa-client-item { padding: 8px 10px; gap: 10px; }
    .wa-client-name { font-size: 13px; }
    .wa-client-phone { font-size: 11px; }

    /* --- Access management compact --- */
    .am-role-card-header { padding: 14px 16px; gap: 10px; }
    .am-role-icon-wrapper { width: 38px; height: 38px; font-size: 16px; }
    .am-role-info h4 { font-size: 14px; }
    .am-role-stats { padding: 10px 16px; gap: 10px; }
    .am-role-stat { padding: 8px; }
    .am-role-stat-value { font-size: 16px; }
    .am-role-stat-label { font-size: 10px; }

    /* --- Top clients compact --- */
    .client-item-info .avatar {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }
    .client-item-name { font-size: 13px; }
    .client-item-id { font-size: 11px; }
    .client-item-count { font-size: 13px; }

    /* --- Laveur tables compact --- */
    .laveur-total-row td {
        padding: 10px 8px !important;
        font-size: 13px;
    }
}

/* ========== VERY SMALL PHONES (max-width: 360px) ========== */
@media (max-width: 360px) {
    .content-area { padding: 8px; }

    .top-bar {
        height: 48px;
        padding: 0 8px;
    }
    .top-bar h2 { font-size: 13px; }

    .user-badge { 
        padding: 3px 8px; 
        font-size: 11px; 
    }

    .stat-card {
        padding: 10px;
        gap: 8px;
    }
    .stat-icon {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }
    .stat-info h3 { font-size: 14px; }
    .stat-info p { font-size: 9px; }

    .card-body { padding: 10px; }
    .card-header { padding: 10px; }

    .bottom-nav-item {
        font-size: 8px;
        min-width: 44px;
    }
    .bottom-nav-item i { font-size: 15px; }

    .page-header h3 { font-size: 15px; }

    .btn {
        padding: 10px 12px;
        font-size: 13px;
    }

    .form-control {
        padding: 10px 12px;
        font-size: 16px;
    }

    .demande-tab-btn {
        padding: 10px;
        font-size: 12px;
    }

    .login-container {
        padding: 24px 16px;
    }
    .login-logo h1 { font-size: 20px; }
    .login-logo .logo-img { width: 50px; height: 50px; }
}

/* ========== SAFE AREA SUPPORT (iPhone notch) ========== */
@supports (padding: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--bottomnav-height) + env(safe-area-inset-bottom));
    }

    @media (max-width: 768px) {
        .main-content {
            padding-bottom: calc(var(--bottomnav-height) + env(safe-area-inset-bottom));
        }

        .toast-container {
            bottom: calc(var(--bottomnav-height) + env(safe-area-inset-bottom) + 12px);
        }
    }
}

/* ========== LANDSCAPE MOBILE ========== */
@media (max-width: 768px) and (orientation: landscape) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .modal-content {
        max-height: 95vh;
    }

    .login-container {
        padding: 24px 32px;
    }

    .login-logo { margin-bottom: 16px; }
    .login-logo .logo-img { width: 48px; height: 48px; }
    .login-logo h1 { font-size: 20px; }

    .bottom-nav {
        height: 50px;
    }
    .bottom-nav-item i { font-size: 16px; }
    .bottom-nav-item { font-size: 9px; }
}

/* ========== HOVER STATES ONLY ON NON-TOUCH DEVICES ========== */
@media (hover: hover) and (pointer: fine) {
    .stat-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    }

    .am-role-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    }
}

/* Disable hover effects on touch devices */
@media (hover: none) {
    .stat-card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }

    .am-role-card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }

    .btn-primary:hover {
        transform: none;
        box-shadow: none;
    }
}

/* ========== SCROLLBAR STYLING ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.25);
}

/* Hide scrollbar on mobile for cleaner look */
@media (max-width: 768px) {
    .sidebar-nav::-webkit-scrollbar,
    .wa-clients-list::-webkit-scrollbar {
        width: 3px;
    }
}