/* ============================================
   IMMO360 — Thème Spotify Vert
   Mode sombre (défaut) + Mode clair
   ============================================ */

/* --- CSS Custom Properties (Thème) --- */
:root {
    /* Couleurs de marque */
    --primary: #1DB954;
    --primary-hover: #1ed760;
    --primary-dark: #17a248;
    --primary-rgb: 29, 185, 84;

    /* Transitions globales */
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 0.15s ease;

    /* Rayons */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Ombres */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.2);
    --shadow-xl: 0 16px 50px rgba(0,0,0,0.25);

    /* Tailles */
    --sidebar-width: 260px;
    --navbar-height: 64px;

    /* Typographie */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* --- Mode Sombre (défaut) --- */
[data-theme="dark"] {
    --bg-primary: #121212;
    --bg-secondary: #1E1E1E;
    --bg-tertiary: #282828;
    --bg-elevated: #2A2A2A;
    --bg-hover: #333333;
    --bg-active: #3E3E3E;

    --text-primary: #FFFFFF;
    --text-secondary: #B3B3B3;
    --text-tertiary: #727272;
    --text-inverse: #121212;

    --border: #333333;
    --border-light: #404040;
    --divider: rgba(255,255,255,0.1);

    --input-bg: #2A2A2A;
    --input-border: #404040;
    --input-focus: var(--primary);

    --card-bg: #1E1E1E;
    --card-hover: #252525;

    --sidebar-bg: #000000;
    --navbar-bg: rgba(18,18,18,0.95);

    --success: #1DB954;
    --danger: #E34850;
    --warning: #F5A623;
    --info: #4A9EFF;

    --scrollbar-bg: #1E1E1E;
    --scrollbar-thumb: #404040;

    color-scheme: dark;
}

/* --- Mode Clair --- */
[data-theme="light"] {
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --bg-tertiary: #EBEBEB;
    --bg-elevated: #FFFFFF;
    --bg-hover: #F0F0F0;
    --bg-active: #E5E5E5;

    --text-primary: #191414;
    --text-secondary: #535353;
    --text-tertiary: #878787;
    --text-inverse: #FFFFFF;

    --border: #E0E0E0;
    --border-light: #EBEBEB;
    --divider: rgba(0,0,0,0.08);

    --input-bg: #FFFFFF;
    --input-border: #D0D0D0;
    --input-focus: var(--primary);

    --card-bg: #FFFFFF;
    --card-hover: #FAFAFA;

    --sidebar-bg: #F5F5F5;
    --navbar-bg: rgba(255,255,255,0.95);

    --success: #17a248;
    --danger: #D32F2F;
    --warning: #E8A000;
    --info: #1976D2;

    --scrollbar-bg: #F5F5F5;
    --scrollbar-thumb: #C0C0C0;

    color-scheme: light;
}

/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: background var(--transition), color var(--transition);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

img {
    max-width: 100%;
    height: auto;
}

/* Scrollbar personnalisé */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition);
    overflow-y: auto;
    border-right: 1px solid var(--divider);
}

.sidebar-header {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--divider);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: #000;
    flex-shrink: 0;
}

.sidebar-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.sidebar-brand span {
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-section {
    margin-top: 16px;
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-tertiary);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-active);
    color: var(--text-primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: var(--radius-full);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
    opacity: 1;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--divider);
}

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

/* --- Navbar --- */
.navbar {
    position: sticky;
    top: 0;
    height: var(--navbar-height);
    background: var(--navbar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 90;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius);
}

.menu-toggle:hover {
    background: var(--bg-hover);
}

/* --- Page content --- */
.page-content {
    flex: 1;
    padding: 28px;
    max-width: 1400px;
    width: 100%;
}

/* ============================================
   COMPOSANTS
   ============================================ */

/* --- Boutons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

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

.btn-primary {
    background: var(--primary);
    color: #000;
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: #000;
    transform: scale(1.02);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

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

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

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

.btn-danger:hover {
    opacity: 0.9;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-full);
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* --- Cards --- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: none !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    transition: box-shadow var(--transition), background var(--transition);
    overflow: hidden;
}

.card:hover {
    background: rgba(29, 185, 84, 0.04);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--divider);
}

/* --- Stats Cards --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* Variante : force 3 colonnes minimum sur mobile */
.stats-grid-3 {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

@media (max-width: 768px) {
    .stats-grid-3 {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .stats-grid-3 .stat-card {
        padding: 10px 8px;
    }
    .stats-grid-3 .stat-value {
        font-size: 14px;
        letter-spacing: -0.3px;
    }
    .stats-grid-3 .stat-label {
        font-size: 9px;
    }
}

@media (max-width: 360px) {
    .stats-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    background: var(--card-bg);
    border: none !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    background: rgba(29, 185, 84, 0.04);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
    padding: 3px 8px;
    border-radius: var(--radius-full);
}

.stat-change.up {
    color: var(--success);
    background: rgba(var(--primary-rgb), 0.1);
}

.stat-change.down {
    color: var(--danger);
    background: rgba(227, 72, 80, 0.1);
}

/* --- Formulaires --- */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius);
    transition: all var(--transition-fast);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.2);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23727272' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

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

.form-error {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

.form-hint {
    color: var(--text-tertiary);
    font-size: 12px;
    margin-top: 4px;
}

/* --- Tables --- */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

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

.table th {
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 14px 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--divider);
    vertical-align: middle;
}

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

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

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-success {
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--success);
}

.badge-danger {
    background: rgba(227, 72, 80, 0.15);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 166, 35, 0.15);
    color: var(--warning);
}

.badge-info {
    background: rgba(74, 158, 255, 0.15);
    color: var(--info);
}

.badge-neutral {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* --- Alertes / Flash --- */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideDown 0.3s ease;
}

.alert-success {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--success);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
}

.alert-error {
    background: rgba(227, 72, 80, 0.1);
    color: var(--danger);
    border: 1px solid rgba(227, 72, 80, 0.2);
}

.alert-warning {
    background: rgba(245, 166, 35, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 166, 35, 0.2);
}

.alert-info {
    background: rgba(74, 158, 255, 0.1);
    color: var(--info);
    border: 1px solid rgba(74, 158, 255, 0.2);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.95) translateY(10px);
    transition: transform var(--transition);
    box-shadow: var(--shadow-xl);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 0 24px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* --- Toggle thème --- */
.theme-toggle {
    width: 52px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    cursor: pointer;
    position: relative;
    transition: background var(--transition);
    flex-shrink: 0;
}

.theme-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    transition: transform var(--transition);
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .theme-toggle::after {
    transform: translateX(24px);
}

/* --- Avatar --- */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 18px; }

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 24px;
    justify-content: center;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.pagination a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--primary);
    color: #000;
    font-weight: 700;
}

/* --- Empty state --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-text {
    color: var(--text-tertiary);
    max-width: 400px;
    margin: 0 auto 20px;
}

/* --- Kanban (Pipeline CRM) --- */
.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
}

.kanban-column {
    min-width: 280px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.kanban-column-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.kanban-column-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.kanban-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    cursor: grab;
    transition: all var(--transition-fast);
}

.kanban-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.kanban-card:active {
    cursor: grabbing;
}

/* ============================================
   UTILITAIRES
   ============================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }

.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 18px; }
.font-bold { font-weight: 700; }
.text-muted { color: var(--text-tertiary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4 { padding: 16px; }
.p-6 { padding: 24px; }

.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.animate-fade-in {
    animation: fadeIn 0.4s ease;
}

.animate-slide-down {
    animation: slideDown 0.3s ease;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-hover) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius);
}

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

/* ============================================
   RESPONSIVE
   ============================================ */
/* --- Bottom Nav Mobile --- */
.bottom-nav {
    display: none; /* Affiché uniquement sur mobile via media query */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: var(--sidebar-bg);
    border-top: 1px solid var(--divider);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    /* Support safe area iPhone X+ */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -1px 0 var(--divider), 0 -4px 20px rgba(0,0,0,0.15);
}

.bottom-nav-items {
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    height: 62px;
    padding: 0;
    width: 100%;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    min-width: 0;
    max-width: none;
    padding: 6px 2px;
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: color var(--transition-fast);
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item svg {
    width: 24px;
    height: 24px;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

/* Indicateur actif : point vert sous l'icône */
.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item.active svg {
    transform: scale(1.1);
}

.bottom-nav-item.active::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--primary);
    border-radius: 50%;
}

.bottom-nav-item:active {
    opacity: 0.7;
}

.bottom-nav-badge {
    position: absolute;
    top: 5px;
    right: calc(50% - 18px);
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--sidebar-bg);
}

/* --- Progress bar (pour paiements mois) --- */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

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

.progress-bar-fill.danger { background: var(--danger); }
.progress-bar-fill.warning { background: var(--warning); }

/* --- Month status grid --- */
.month-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.month-cell {
    padding: 10px 8px;
    border-radius: var(--radius);
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    transition: all var(--transition-fast);
}

.month-cell.paid {
    background: rgba(var(--primary-rgb), 0.15);
    color: var(--success);
    border-color: rgba(var(--primary-rgb), 0.3);
}

.month-cell.partial {
    background: rgba(245, 166, 35, 0.1);
    color: var(--warning);
    border-color: rgba(245, 166, 35, 0.3);
}

.month-cell.unpaid {
    background: rgba(227, 72, 80, 0.1);
    color: var(--danger);
    border-color: rgba(227, 72, 80, 0.3);
}

.month-cell.future {
    opacity: 0.4;
}

/* --- Document grid --- */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.doc-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    transition: all var(--transition-fast);
}

.doc-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

/* --- Photo thumb --- */
.photo-thumb {
    width: 60px;
    height: 60px;
    border-radius: var(--radius);
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--border);
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-tertiary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all var(--transition-fast);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab:hover {
    color: var(--text-primary);
}

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

.tab-content, .tab-pane {
    display: none;
}

.tab-content.active, .tab-pane.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

/* --- Inline editable --- */
.editable-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.editable-field:hover {
    background: var(--bg-hover);
}

.editable-field svg {
    width: 14px;
    height: 14px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.editable-field:hover svg {
    opacity: 0.5;
}

.editable-field .editable-input {
    display: none;
}

.editable-field.editing .editable-display {
    display: none;
}

.editable-field.editing .editable-input {
    display: inline-block;
}

/* --- Utilities responsive (actives via media queries ci-dessous) --- */
/* .hide-mobile et .hide-desktop sont définis dans les media queries */

/* Hide sur desktop (>1024) */
@media (min-width: 1025px) {
    .hide-desktop { display: none !important; }
}

/* ── Dashboard 2 colonnes → 1 col mobile ── */
.dash-2col {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 900px) {
    .dash-2col {
        grid-template-columns: 1fr !important;
    }
}

/* ============================================
   RESPONSIVE — TABLETTE (≤1024px)
   ============================================ */
@media (max-width: 1024px) {
    /* Sidebar masquée, slide depuis la gauche */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 300;
        transform: translateX(-100%);
        transition: transform var(--transition);
        box-shadow: var(--shadow-xl);
    }

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

    .main-content {
        margin-left: 0 !important;
    }

    .menu-toggle {
        display: flex !important;
    }

    /* Bottom nav visible */
    .bottom-nav {
        display: flex !important;
    }

    /* Espace pour le bottom nav */
    .page-content {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   RESPONSIVE — MOBILE (≤768px)
   ============================================ */
@media (max-width: 768px) {
    /* Afficher/Masquer selon écran */
    .hide-mobile { display: none !important; }
    .hide-desktop { display: block !important; }

    /* Navbar compacte */
    .navbar {
        padding: 0 12px;
        height: 52px;
    }

    .navbar-title {
        font-size: 15px;
        font-weight: 700;
    }

    /* Bouton Quitter : garder l'icône, masquer le texte */
    .navbar-right .btn-outline {
        padding: 6px 8px;
        min-width: 0;
    }

    /* Page content */
    .page-content {
        padding: 12px;
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }

    /* Stats grid — 2 colonnes compactes */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px 12px;
        border-radius: var(--radius);
    }

    .stat-value {
        font-size: 18px;
        letter-spacing: -0.5px;
    }

    .stat-label {
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
    }

    /* Cards */
    .card {
        border-radius: var(--radius);
        margin-bottom: 12px;
    }

    .card-header {
        padding: 12px 14px;
    }

    .card-body {
        padding: 14px;
    }

    .card-title {
        font-size: 14px;
    }

    /* Formulaires */
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-control {
        font-size: 16px; /* Évite le zoom iOS */
        padding: 10px 12px;
    }

    .form-label {
        font-size: 12px;
    }

    /* Tableaux — scroll horizontal */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 0;
    }

    .table td, .table th {
        padding: 10px 12px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* Boutons */
    .btn {
        padding: 9px 16px;
        font-size: 13px;
    }

    .btn-sm {
        padding: 6px 12px;
        font-size: 12px;
    }

    /* Modals — slide depuis le bas (sheet native) */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal {
        max-width: 100%;
        width: 100%;
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        max-height: 92vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        margin-top: auto;
    }

    .modal::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--border-light);
        border-radius: var(--radius-full);
        margin: 12px auto 4px;
    }

    .modal-header {
        padding: 8px 16px 12px;
    }

    /* Tabs scroll horizontal */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0;
        border-radius: 0;
    }

    .tabs::-webkit-scrollbar { display: none; }

    .tab {
        padding: 10px 16px;
        font-size: 13px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Month grid — 3 colonnes sur mobile */
    .month-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .month-cell {
        padding: 8px 6px;
        font-size: 11px;
    }

    /* Badges */
    .badge {
        font-size: 10px;
        padding: 3px 7px;
    }

    /* Kanban vertical */
    .kanban-board {
        flex-direction: column;
    }

    .kanban-column {
        min-width: 100%;
    }

    /* Header pages */
    .flex.items-center.justify-between {
        gap: 10px;
    }

    /* Avatar */
    .avatar-lg {
        width: 40px;
        height: 40px;
        font-size: 16px;
        flex-shrink: 0;
    }

    /* Doc grid */
    .doc-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   RESPONSIVE — PETIT MOBILE (≤480px)
   ============================================ */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .stat-card {
        padding: 12px 10px;
    }

    .stat-value {
        font-size: 16px;
    }

    .page-content {
        padding: 10px;
        padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    }

    .navbar {
        height: 48px;
    }

    .card-header {
        padding: 10px 12px;
    }

    .card-body {
        padding: 12px;
    }

    .month-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Typographie */
    h2 { font-size: 18px !important; }
    .font-bold { font-size: 13px; }

    /* Dashboard admin — boutons d'action en-tête */
    .dash-header-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }
    .dash-header-actions .btn {
        text-align: center;
        justify-content: center;
        font-size: 12px;
        padding: 8px 10px;
    }

    /* Grilles financières inline → 1 col */
    .fin-grid {
        grid-template-columns: 1fr !important;
    }

    /* Commercial actions → 3 col compact */
    .comm-actions-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
    .comm-action-btn {
        padding: 10px 6px !important;
        border-radius: 10px !important;
    }
    .comm-action-btn .icon-wrap {
        width: 32px !important;
        height: 32px !important;
    }
    .comm-action-btn .label {
        font-size: 10px !important;
    }

    /* KPIs commercial → 2 col */
    .stats-grid[style*="auto-fit"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* ============================================
   PAGE AUTH (login/register)
   ============================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 440px;
    animation: fadeIn 0.5s ease;
}

.auth-header {
    text-align: center;
    margin-bottom: 36px;
}

.auth-logo {
    width: 56px;
    height: 56px;
    background: var(--primary);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 22px;
    color: #000;
    margin: 0 auto 16px;
}

.auth-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--text-tertiary);
    font-size: 14px;
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 36px;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    color: var(--text-tertiary);
    font-size: 14px;
}

.auth-footer a {
    font-weight: 600;
}

/* ============================================
   PRINT
   ============================================ */
@media print {
    .sidebar, .navbar, .btn, .menu-toggle {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
    }
    .page-content {
        padding: 0 !important;
    }
    body {
        background: #fff;
        color: #000;
    }
}
