/* =====================================================
   Application Rapports Régionaux - Styles CSS
   Palette: Bleu #2563EB / Violet #7C3AED
   ===================================================== */

:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --primary-light: #DBEAFE;
    --secondary: #7C3AED;
    --secondary-dark: #6D28D9;
    --secondary-light: #EDE9FE;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --neutral: #6B7280;
    --bg-light: #F9FAFB;
    --text-dark: #111827;
    --text-muted: #6B7280;
    --white: #FFFFFF;
    --gradient: linear-gradient(135deg, #2563EB 0%, #7C3AED 100%);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --sidebar-width: 260px;
    /* WCAG 2.5.8 Touch targets - minimum 44px */
    --touch-target-min: 44px;
    --touch-target-spacing: 8px;
    /* Safe area for notched devices */
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--secondary);
}

/* =====================================================
   Header / Navbar
   ===================================================== */
.navbar-main {
    background: var(--gradient);
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow-md);
}

.navbar-brand {
    color: var(--white) !important;
    font-weight: 700;
    font-size: 1.25rem;
}

.navbar-brand:hover {
    color: var(--white) !important;
}

.nav-icon {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.25rem;
    margin-left: 1rem;
    position: relative;
}

.nav-icon:hover {
    color: var(--white);
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background-color: var(--danger);
    color: white;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 50%;
}

.user-dropdown .dropdown-toggle {
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background-color: var(--secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

/* =====================================================
   Sidebar
   ===================================================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 60px;
    width: var(--sidebar-width);
    height: calc(100vh - 60px);
    background-color: var(--white);
    border-right: 1px solid #E5E7EB;
    padding: 1.5rem 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav .nav-item {
    margin-bottom: 0.25rem;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-dark);
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link i {
    width: 24px;
    margin-right: 0.75rem;
    color: var(--secondary);
}

.sidebar-nav .nav-link:hover {
    background-color: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
}

.sidebar-nav .nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
    border-left-color: var(--primary);
}

.sidebar-section {
    padding: 0.5rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 1rem;
}

/* =====================================================
   Main Content
   ===================================================== */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: calc(100vh - 60px);
    margin-top: 60px;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--text-muted);
}

/* =====================================================
   Cards
   ===================================================== */
.card {
    background: var(--white);
    border: none;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid #E5E7EB;
    padding: 1rem 1.5rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.stat-card {
    border-left: 4px solid var(--primary);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card.secondary {
    border-left-color: var(--secondary);
}

.stat-card.success {
    border-left-color: var(--success);
}

.stat-card.warning {
    border-left-color: var(--warning);
}

.stat-card.danger {
    border-left-color: var(--danger);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.stat-icon {
    font-size: 2.5rem;
    color: var(--primary-light);
}

/* =====================================================
   Buttons
   ===================================================== */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--secondary);
    border-color: var(--secondary);
}

.btn-secondary:hover {
    background-color: var(--secondary-dark);
    border-color: var(--secondary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-secondary {
    color: var(--secondary);
    border-color: var(--secondary);
}

.btn-outline-secondary:hover {
    background-color: var(--secondary);
    border-color: var(--secondary);
}

/* =====================================================
   Forms
   ===================================================== */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

.form-label {
    font-weight: 500;
    color: var(--text-dark);
}

/* =====================================================
   Tables
   ===================================================== */
.table {
    margin-bottom: 0;
}

.table thead th {
    background-color: var(--primary);
    color: var(--white);
    font-weight: 600;
    border: none;
    padding: 1rem;
}

.table tbody tr:nth-child(even) {
    background-color: var(--primary-light);
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
}

/* =====================================================
   Statistics Table
   ===================================================== */
#statsTable {
    font-size: 0.85rem;
}

#statsTable thead th {
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

#statsTable tbody td {
    padding: 0.25rem;
}

#statsTable .stat-input {
    width: 45px;
    padding: 0.25rem;
    text-align: center;
    font-size: 0.8rem;
}

#statsTable .stat-total {
    background-color: var(--primary-light);
    font-weight: 600;
}

.table-primary th {
    background-color: var(--primary) !important;
    color: white;
}

/* =====================================================
   Badges
   ===================================================== */
.badge {
    font-weight: 500;
    padding: 0.4em 0.8em;
}

/* =====================================================
   Login Page
   ===================================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--white);
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    padding: 2.5rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* =====================================================
   Alerts
   ===================================================== */
.alert {
    border: none;
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
}

.alert-success {
    background-color: #D1FAE5;
    color: #065F46;
}

.alert-danger {
    background-color: #FEE2E2;
    color: #991B1B;
}

.alert-warning {
    background-color: #FEF3C7;
    color: #92400E;
}

.alert-info {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

/* =====================================================
   Progress Bar
   ===================================================== */
.progress {
    height: 0.75rem;
    border-radius: 0.5rem;
    background-color: #E5E7EB;
}

.progress-bar {
    background: var(--gradient);
    border-radius: 0.5rem;
}

/* =====================================================
   MOBILE FIRST - Base styles (mobile default)
   ===================================================== */

/* Mobile: Sidebar hidden by default */
.sidebar {
    transform: translateX(-100%);
}

.sidebar.show {
    transform: translateX(0);
}

/* Mobile: Main content full width */
.main-content {
    margin-left: 0;
    padding: 1rem;
}

/* Mobile: Compact typography */
.page-title {
    font-size: 1.25rem;
}

.stat-number {
    font-size: 1.25rem;
}

/* Mobile: Compact cards */
.card-header {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
}

.card-body {
    padding: 1rem;
}

/* Mobile: Sidebar toggle visible */
.sidebar-toggle {
    display: flex !important;
}

/* =====================================================
   TABLEAUX RESPONSIVE - MOBILE FIRST
   ===================================================== */

/* Base: Table wrapper avec scroll horizontal */
.stats-table-wrapper,
.denom-table-wrapper,
.table-responsive-custom {
    position: relative;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    padding: 0;
    background: linear-gradient(90deg, #fff 30%, transparent),
                linear-gradient(90deg, transparent, #fff 70%) 100% 0,
                linear-gradient(90deg, rgba(0,0,0,0.08), transparent),
                linear-gradient(90deg, transparent, rgba(0,0,0,0.08)) 100% 0;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-repeat: no-repeat;
    background-attachment: local, local, scroll, scroll;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #f0f0f0;
    border-radius: 0 0 8px 8px;
}

.stats-table-wrapper::-webkit-scrollbar,
.denom-table-wrapper::-webkit-scrollbar,
.table-responsive-custom::-webkit-scrollbar {
    height: 8px;
}

.stats-table-wrapper::-webkit-scrollbar-track,
.denom-table-wrapper::-webkit-scrollbar-track,
.table-responsive-custom::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.stats-table-wrapper::-webkit-scrollbar-thumb,
.denom-table-wrapper::-webkit-scrollbar-thumb,
.table-responsive-custom::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 4px;
}

/* Base: Table générique */
.table-app {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.75rem;
    background: #fff;
}

/* Stats Table - Mobile */
.stats-table {
    font-size: 0.7rem;
    min-width: 850px;
    border-collapse: separate;
    border-spacing: 0;
}

.stats-table thead th {
    padding: 0.4rem 0.15rem;
    font-size: 0.6rem;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #4361ee 0%, #3a56d4 100%);
    color: white;
    border: 1px solid #3651d4;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.stats-table thead th:first-child {
    border-radius: 8px 0 0 0;
}

.stats-table thead th:last-child {
    border-radius: 0 8px 0 0;
}

.stats-table tbody td {
    padding: 0.25rem 0.15rem;
    vertical-align: middle;
    border: 1px solid #e5e7eb;
    transition: background-color 0.15s;
}

.stats-table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

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

.stats-table .stat-input,
.stats-table .stat-input-annexe {
    width: 36px;
    min-width: 36px;
    padding: 0.25rem 0.1rem;
    font-size: 0.7rem;
    text-align: center;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    transition: all 0.15s;
    background: #fff;
}

.stats-table .stat-input:focus,
.stats-table .stat-input-annexe:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
    background: #f0f9ff;
}

.stats-table .stat-input.stat-total,
.stats-table .stat-input-annexe.stat-total {
    background: #dcfce7;
    border-color: #86efac;
    font-weight: 600;
    color: #166534;
}

/* Colonnes sticky pour la première colonne */
.stats-table tbody td:first-child,
.stats-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #f1f5f9;
    font-weight: 600;
    min-width: 100px;
    max-width: 120px;
    font-size: 0.65rem;
}

.stats-table thead th:first-child {
    z-index: 15;
    background: linear-gradient(135deg, #4361ee 0%, #3a56d4 100%);
}

/* Synthesis table - Mobile */
.synth-table {
    font-size: 0.7rem;
    min-width: 500px;
}

.synth-table th,
.synth-table td {
    padding: 0.35rem 0.25rem;
    border: 1px solid #e5e7eb;
}

.synth-table thead th {
    background: linear-gradient(135deg, #4361ee 0%, #3a56d4 100%);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.65rem;
}

.synth-table tbody td {
    text-align: center;
}

.synth-table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

/* Swipe hint amélioré */
.swipe-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, var(--primary-light) 0%, #ddd6fe 100%);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.swipe-hint i {
    font-size: 1rem;
    animation: swipeHint 2s ease-in-out infinite;
}

@keyframes swipeHint {
    0%, 100% { transform: translateX(0); opacity: 1; }
    50% { transform: translateX(8px); opacity: 0.7; }
}

/* Mobile: Bottom navigation - WCAG 2.5.8 compliant touch targets */
.mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid #E5E7EB;
    padding: 0.25rem 0;
    padding-bottom: calc(0.25rem + var(--safe-area-inset-bottom));
    z-index: 1000;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
}

.mobile-bottom-nav .nav-item {
    flex: 1;
    text-align: center;
}

.mobile-bottom-nav .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-target-min);
    padding: 0.5rem 0.25rem;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s, transform 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-bottom-nav .nav-link:active {
    transform: scale(0.95);
}

.mobile-bottom-nav .nav-link i {
    font-size: 1.35rem;
    margin-bottom: 0.2rem;
    transition: transform 0.2s;
}

.mobile-bottom-nav .nav-link.active {
    color: var(--primary);
}

.mobile-bottom-nav .nav-link.active i {
    transform: scale(1.1);
}

/* Mobile: Add padding bottom for bottom nav */
body.has-bottom-nav {
    padding-bottom: calc(60px + var(--safe-area-inset-bottom));
}

/* Mobile: Floating action button */
.fab {
    position: fixed;
    bottom: 80px;
    right: 1rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    z-index: 999;
    border: none;
    font-size: 1.5rem;
}

/* Mobile: Swipe indicator for tables */
.swipe-hint {
    display: block;
    text-align: center;
    padding: 0.5rem;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
}

.swipe-hint i {
    animation: swipe 1.5s infinite;
}

@keyframes swipe {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(10px); }
}

/* Mobile: Compact buttons with WCAG touch targets */
.btn-mobile-full {
    width: 100%;
    margin-bottom: 0.5rem;
}

/* Mobile: All buttons meet WCAG 2.5.8 touch target size */
.btn {
    min-height: var(--touch-target-min);
    padding: 0.625rem 1rem;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-sm {
    min-height: 36px;
}

.btn-lg {
    min-height: 52px;
}

/* Mobile: Form optimizations */
.form-control, .form-select {
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: var(--touch-target-min);
    padding: 0.625rem 0.875rem;
}

.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Mobile: Checkbox and radio buttons with larger touch area */
.form-check {
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    padding-left: 2rem;
}

.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0;
}

.form-check-label {
    padding-left: 0.5rem;
    cursor: pointer;
}

/* Mobile: Links with sufficient touch area */
.nav-link, .dropdown-item, .list-group-item-action {
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
}

/* Mobile: Card actions */
.card-link {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch-target-min);
    padding: 0.5rem;
}

/* Mobile: Overlay for sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.sidebar-overlay.show {
    display: block;
}

/* =====================================================
   TABLET (min-width: 576px)
   ===================================================== */
@media (min-width: 576px) {
    .main-content {
        padding: 1.25rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .stat-number {
        font-size: 1.5rem;
    }
    
    /* Tables - Tablet small */
    .stats-table {
        font-size: 0.72rem;
        min-width: 820px;
    }
    
    .stats-table thead th {
        padding: 0.45rem 0.2rem;
        font-size: 0.62rem;
    }
    
    .stats-table .stat-input,
    .stats-table .stat-input-annexe {
        width: 40px;
        min-width: 40px;
        font-size: 0.72rem;
        padding: 0.3rem 0.15rem;
    }
    
    .synth-table {
        font-size: 0.75rem;
    }
    
    .denom-table {
        font-size: 0.75rem;
    }
    
    .denom-table .denom-input,
    .denom-table .ouvrier-input {
        width: 48px;
        min-width: 48px;
    }
    
    .fab {
        bottom: 85px;
        right: 1.5rem;
    }
}

/* =====================================================
   TABLET LANDSCAPE (min-width: 768px)
   ===================================================== */
@media (min-width: 768px) {
    .main-content {
        padding: 1.5rem;
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .card-header {
        padding: 1rem 1.25rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
    
    /* Tables - Tablet landscape */
    .stats-table {
        font-size: 0.78rem;
        min-width: 780px;
    }
    
    .stats-table thead th {
        padding: 0.5rem 0.25rem;
        font-size: 0.68rem;
    }
    
    .stats-table tbody td {
        padding: 0.3rem 0.2rem;
    }
    
    .stats-table .stat-input,
    .stats-table .stat-input-annexe {
        width: 44px;
        min-width: 44px;
        font-size: 0.78rem;
        padding: 0.35rem 0.2rem;
    }
    
    .stats-table tbody td:first-child,
    .stats-table thead th:first-child {
        min-width: 110px;
        max-width: 130px;
        font-size: 0.7rem;
    }
    
    .synth-table {
        font-size: 0.8rem;
        min-width: 450px;
    }
    
    .synth-table th,
    .synth-table td {
        padding: 0.45rem 0.35rem;
    }
    
    .denom-table {
        font-size: 0.78rem;
        min-width: 850px;
    }
    
    .denom-table thead th {
        padding: 0.55rem 0.4rem;
        font-size: 0.72rem;
    }
    
    .denom-table .denom-input,
    .denom-table .ouvrier-input {
        width: 52px;
        min-width: 52px;
        font-size: 0.78rem;
    }
    
    .swipe-hint {
        display: none;
    }
}

/* =====================================================
   DESKTOP (min-width: 992px)
   ===================================================== */
@media (min-width: 992px) {
    /* Desktop: Show sidebar */
    .sidebar {
        transform: translateX(0);
    }
    
    /* Desktop: Main content with sidebar margin */
    .main-content {
        margin-left: var(--sidebar-width);
        padding: 2rem;
    }
    
    .page-title {
        font-size: 1.75rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }
    
    .card-header {
        padding: 1rem 1.5rem;
    }
    
    .card-body {
        padding: 1.5rem;
    }
    
    /* Desktop: Hide mobile navigation */
    .mobile-bottom-nav {
        display: none;
    }
    
    .fab {
        display: none;
    }
    
    body.has-bottom-nav {
        padding-bottom: 0;
    }
    
    /* Desktop: Hide sidebar toggle */
    .sidebar-toggle {
        display: none !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    /* Desktop: Stats table */
    .stats-table-wrapper,
    .denom-table-wrapper {
        margin: 0;
        padding: 0;
        background: none;
    }
    
    .stats-table {
        font-size: 0.82rem;
        min-width: auto;
    }
    
    .stats-table thead th {
        padding: 0.55rem 0.3rem;
        font-size: 0.72rem;
    }
    
    .stats-table tbody td {
        padding: 0.35rem 0.25rem;
    }
    
    .stats-table .stat-input,
    .stats-table .stat-input-annexe {
        width: 48px;
        min-width: 48px;
        font-size: 0.8rem;
        padding: 0.4rem 0.25rem;
    }
    
    .stats-table tbody td:first-child,
    .stats-table thead th:first-child {
        position: static;
        min-width: auto;
        max-width: none;
        font-size: 0.78rem;
    }
    
    .synth-table {
        font-size: 0.85rem;
        min-width: auto;
    }
    
    .synth-table th,
    .synth-table td {
        padding: 0.5rem 0.4rem;
    }
    
    .denom-table {
        font-size: 0.82rem;
        min-width: auto;
    }
    
    .denom-table thead th {
        padding: 0.6rem 0.45rem;
        font-size: 0.75rem;
    }
    
    .denom-table tbody td {
        padding: 0.45rem 0.35rem;
    }
    
    .denom-table .denom-input,
    .denom-table .ouvrier-input {
        width: 56px;
        min-width: 56px;
        font-size: 0.82rem;
        padding: 0.4rem 0.3rem;
    }
    
    /* Remove sticky on desktop - tables fit */
    .denom-table tbody td:first-child,
    .denom-table thead th:first-child {
        position: static;
    }
}

/* =====================================================
   LARGE DESKTOP (min-width: 1200px)
   ===================================================== */
@media (min-width: 1200px) {
    .stats-table {
        font-size: 0.85rem;
    }
    
    .stats-table thead th {
        padding: 0.6rem 0.35rem;
        font-size: 0.75rem;
    }
    
    .stats-table .stat-input,
    .stats-table .stat-input-annexe {
        width: 52px;
        min-width: 52px;
        font-size: 0.82rem;
    }
    
    .denom-table {
        font-size: 0.85rem;
    }
    
    .denom-table thead th {
        padding: 0.65rem 0.5rem;
        font-size: 0.78rem;
    }
    
    .denom-table .denom-input,
    .denom-table .ouvrier-input {
        width: 60px;
        min-width: 60px;
        font-size: 0.85rem;
    }
}

/* =====================================================
   EXTRA LARGE DESKTOP (min-width: 1400px)
   ===================================================== */
@media (min-width: 1400px) {
    .stats-table {
        font-size: 0.88rem;
    }
    
    .stats-table thead th {
        padding: 0.65rem 0.4rem;
        font-size: 0.78rem;
    }
    
    .stats-table .stat-input,
    .stats-table .stat-input-annexe {
        width: 56px;
        min-width: 56px;
        font-size: 0.85rem;
        padding: 0.45rem 0.3rem;
    }
    
    .denom-table {
        font-size: 0.88rem;
    }
    
    .denom-table thead th {
        padding: 0.7rem 0.55rem;
        font-size: 0.8rem;
    }
    
    .denom-table .denom-input,
    .denom-table .ouvrier-input {
        width: 65px;
        min-width: 65px;
        font-size: 0.88rem;
        padding: 0.45rem 0.35rem;
    }
}

/* =====================================================
   Utilities
   ===================================================== */
.text-primary {
    color: var(--primary) !important;
}

.text-secondary {
    color: var(--secondary) !important;
}

.bg-primary-light {
    background-color: var(--primary-light) !important;
}

.bg-secondary-light {
    background-color: var(--secondary-light) !important;
}

.border-primary {
    border-color: var(--primary) !important;
}

.border-secondary {
    border-color: var(--secondary) !important;
}

/* =====================================================
   ACCESSIBILITY & UX ENHANCEMENTS
   Based on WCAG 2.5.8 and Smashing Magazine best practices
   ===================================================== */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .swipe-hint i {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary: #0047AB;
        --secondary: #5B21B6;
    }
    
    .btn, .form-control, .form-select {
        border-width: 2px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-light: #1F2937;
        --white: #111827;
        --text-dark: #F9FAFB;
        --text-muted: #9CA3AF;
    }
}

/* =====================================================
   MOBILE-SPECIFIC IMPROVEMENTS
   ===================================================== */

/* Prevent text selection on interactive elements */
.btn, .nav-link, .mobile-bottom-nav {
    -webkit-user-select: none;
    user-select: none;
}

/* Smooth scrolling for the whole page */
html {
    scroll-behavior: smooth;
}

/* Better scroll snap for horizontal tables */
.stats-table-wrapper,
.denom-table-wrapper {
    scroll-snap-type: x proximity;
}

/* Pull-to-refresh visual indicator area */
.main-content {
    overscroll-behavior-y: contain;
}

/* Better tap states for cards */
.card {
    transition: transform 0.15s, box-shadow 0.15s;
}

@media (hover: none) and (pointer: coarse) {
    .card:active {
        transform: scale(0.99);
    }
    
    .stat-card:hover {
        transform: none;
    }
}

/* Action buttons spacing for touch */
.btn + .btn {
    margin-left: var(--touch-target-spacing);
}

/* Responsive button groups */
.btn-group-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 576px) {
    .btn-group-mobile {
        flex-direction: row;
    }
    
    .btn-group-mobile .btn {
        flex: 1;
    }
}

/* Loading state for async actions */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty state styling */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.25rem;
}

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

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: calc(70px + var(--safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    width: calc(100% - 2rem);
    max-width: 400px;
}

@media (min-width: 992px) {
    .toast-container {
        bottom: 1.5rem;
        right: 1.5rem;
        left: auto;
        transform: none;
    }
}

/* =====================================================
   DÉNOMBREMENT TABLES - Mobile First
   ===================================================== */

/* Base Mobile styles */
.denom-table {
    font-size: 0.72rem;
    min-width: 750px;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
}

.denom-table thead th {
    padding: 0.45rem 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    vertical-align: middle;
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, #4361ee 0%, #3a56d4 100%);
    color: white;
    border: 1px solid #3651d4;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.denom-table thead th:first-child {
    border-radius: 8px 0 0 0;
}

.denom-table thead th:last-child {
    border-radius: 0 8px 0 0;
}

.denom-table tbody td {
    padding: 0.35rem 0.2rem;
    vertical-align: middle;
    border: 1px solid #e5e7eb;
    transition: background-color 0.15s;
}

.denom-table .denom-input,
.denom-table .ouvrier-input {
    width: 42px;
    min-width: 42px;
    padding: 0.3rem 0.15rem;
    font-size: 0.72rem;
    text-align: center;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    transition: all 0.15s;
    background: #fff;
}

.denom-table .denom-input:focus,
.denom-table .ouvrier-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
    background: #f0f9ff;
}

/* Sticky first column on mobile */
.denom-table tbody td:first-child,
.denom-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 5;
    background: #f1f5f9;
    font-weight: 600;
    min-width: 90px;
    font-size: 0.65rem;
}

.denom-table thead th:first-child {
    z-index: 15;
    background: linear-gradient(135deg, #4361ee 0%, #3a56d4 100%);
}

/* Total columns highlighting */
.denom-table .total-cell {
    background: #dcfce7 !important;
    font-weight: 600;
    color: #166534;
}

.denom-table .grand-total-cell {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white;
    font-weight: 700;
}

/* Row highlighting */
.denom-table tbody tr:nth-child(even) {
    background-color: #f8fafc;
}

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

.denom-table tbody tr.total-row {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important;
    font-weight: 600;
}

.denom-table tbody tr.total-row:hover {
    background: linear-gradient(135deg, #fde68a 0%, #fcd34d 100%) !important;
}

/* Ouvriers table specific */
.ouvriers-table {
    min-width: 1300px;
}

.ouvriers-table thead th {
    min-width: 45px;
    font-size: 0.6rem;
    padding: 0.4rem 0.2rem;
}

/* Finance inputs - taille uniforme */
.fin-input.fin-money {
    font-size: 0.82rem !important;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    padding: 0.35rem 0.4rem !important;
    min-width: 75px;
}

@media (min-width: 768px) {
    .fin-input.fin-money {
        font-size: 0.85rem !important;
        min-width: 80px;
    }
}

@media (min-width: 992px) {
    .fin-input.fin-money {
        font-size: 0.88rem !important;
        min-width: 85px;
    }
}

/* =====================================================
   UNIFORMISATION TAILLE POLICE - Données numériques
   ===================================================== */

/* Tous les inputs numériques dans les tableaux */
.denom-table input[type="number"],
.stats-table input[type="number"],
.ev-input,
.nc-input,
.df-input,
.ai-input,
.del-input,
.semus-input,
.stat-exam-input,
.emj-input {
    font-size: 0.85rem !important;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    padding: 0.35rem 0.25rem !important;
}

/* Cellules Total uniformes */
.total-cell,
.grand-total-cell {
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    font-variant-numeric: tabular-nums;
    vertical-align: middle !important;
}

/* Ligne Total */
.total-row td {
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    font-variant-numeric: tabular-nums;
}

@media (min-width: 768px) {
    .denom-table input[type="number"],
    .stats-table input[type="number"],
    .ev-input,
    .nc-input,
    .df-input,
    .ai-input,
    .del-input,
    .semus-input,
    .stat-exam-input,
    .emj-input {
        font-size: 0.88rem !important;
    }
    
    .total-cell,
    .grand-total-cell,
    .total-row td {
        font-size: 0.88rem !important;
    }
}

@media (min-width: 992px) {
    .denom-table input[type="number"],
    .stats-table input[type="number"],
    .ev-input,
    .nc-input,
    .df-input,
    .ai-input,
    .del-input,
    .semus-input,
    .stat-exam-input,
    .emj-input {
        font-size: 0.9rem !important;
    }
    
    .total-cell,
    .grand-total-cell,
    .total-row td {
        font-size: 0.9rem !important;
    }
}

/* =====================================================
   WIZARD / STEPPER - Formulaire Multi-étapes
   ===================================================== */

.wizard-container {
    position: relative;
}

/* Progress Stepper */
.wizard-progress {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding: 0;
    position: relative;
    counter-reset: step;
}

.wizard-progress::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 3px;
    background: #e5e7eb;
    z-index: 0;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
    cursor: pointer;
    transition: all 0.3s ease;
}

.wizard-step-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e5e7eb;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: 3px solid #fff;
    box-shadow: var(--shadow);
}

.wizard-step.active .wizard-step-icon {
    background: var(--gradient);
    color: #fff;
    transform: scale(1.1);
}

.wizard-step.completed .wizard-step-icon {
    background: var(--success);
    color: #fff;
}

.wizard-step.completed .wizard-step-icon::after {
    content: '\2713';
    font-size: 1.1rem;
}

.wizard-step-label {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    max-width: 80px;
    line-height: 1.2;
    transition: all 0.3s ease;
}

.wizard-step.active .wizard-step-label {
    color: var(--primary);
    font-weight: 600;
}

.wizard-step.completed .wizard-step-label {
    color: var(--success);
}

/* Wizard Content */
.wizard-content {
    min-height: 400px;
}

.wizard-page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.wizard-page.active {
    display: block;
}

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

/* Wizard Navigation */
.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    margin-top: 1rem;
    border-top: 1px solid #e5e7eb;
    gap: 1rem;
}

.wizard-nav-left,
.wizard-nav-right {
    display: flex;
    gap: 0.5rem;
}

.wizard-nav-center {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.btn-wizard {
    min-width: 120px;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn-wizard-prev {
    background: #f3f4f6;
    color: var(--text-dark);
    border: 1px solid #d1d5db;
}

.btn-wizard-prev:hover {
    background: #e5e7eb;
    color: var(--text-dark);
}

.btn-wizard-next {
    background: var(--gradient);
    color: #fff;
    border: none;
}

.btn-wizard-next:hover {
    opacity: 0.9;
    color: #fff;
    transform: translateY(-1px);
}

.btn-wizard-submit {
    background: var(--success);
    color: #fff;
    border: none;
}

.btn-wizard-submit:hover {
    background: #059669;
    color: #fff;
}

/* Page Summary Card */
.wizard-page-header {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid #e2e8f0;
}

.wizard-page-header h4 {
    color: var(--primary);
    margin-bottom: 0.25rem;
    font-size: 1.1rem;
}

.wizard-page-header p {
    color: var(--text-muted);
    margin: 0;
    font-size: 0.875rem;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .wizard-progress {
        overflow-x: auto;
        padding-bottom: 0.5rem;
        margin: 0 -1rem 1.5rem;
        padding: 0 1rem 0.5rem;
        scrollbar-width: none;
    }
    
    .wizard-progress::-webkit-scrollbar {
        display: none;
    }
    
    .wizard-step {
        min-width: 60px;
    }
    
    .wizard-step-icon {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }
    
    .wizard-step-label {
        font-size: 0.65rem;
        max-width: 60px;
    }
    
    .wizard-nav {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .wizard-nav-center {
        order: -1;
        width: 100%;
        justify-content: center;
    }
    
    .btn-wizard {
        min-width: 100px;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 576px) {
    .wizard-progress::before {
        top: 18px;
        height: 2px;
    }
    
    .wizard-step-icon {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
        border-width: 2px;
    }
    
    .wizard-step-label {
        display: none;
    }
    
    .wizard-step.active .wizard-step-label {
        display: block;
        position: absolute;
        top: 100%;
        white-space: nowrap;
        max-width: none;
    }
    
    .wizard-nav-left,
    .wizard-nav-right {
        flex: 1;
    }
    
    .btn-wizard {
        flex: 1;
        min-width: auto;
    }
}

/* Wizard Cards - Plus compact */
.wizard-page .card {
    margin-bottom: 1.25rem;
    border-radius: 10px;
    overflow: hidden;
}

.wizard-page .card-header {
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
}

/* Auto-save indicator */
.wizard-autosave {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.wizard-autosave.saving {
    color: var(--warning);
}

.wizard-autosave.saved {
    color: var(--success);
}

.wizard-autosave i {
    font-size: 1rem;
}
