/* ============================================
   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: 'General Sans', '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;

    --text-muted: #8A8A8A;
    --nav-hover: rgba(255,255,255,0.06);
    --success-rgb: 29, 185, 84;
    --danger-rgb: 227, 72, 80;
    --warning-rgb: 245, 166, 35;
    --info-rgb: 74, 158, 255;

    color-scheme: dark;
}

/* --- Mode Clair --- */
/* Contrastes vérifiés WCAG AA (>= 4.5:1 sur blanc pour tout texte) */
[data-theme="light"] {
    /* Vert de marque assombri : lisible en texte sur blanc (4.66)
       ET en fond de bouton avec texte blanc (4.66) ou noir (4.51) */
    --primary: #13863F;
    --primary-hover: #0F7535;
    --primary-dark: #0D6A30;
    --primary-rgb: 19, 134, 63;

    --bg-primary: #FFFFFF;
    --bg-secondary: #F4F6F5;
    --bg-tertiary: #E9EDEA;
    --bg-elevated: #FFFFFF;
    --bg-hover: #F1F4F2;
    --bg-active: #E4E9E6;

    --text-primary: #1F2421;    /* 15.8 */
    --text-secondary: #4A4F4C;  /* 8.4  */
    --text-tertiary: #6A706C;   /* 5.1  */
    --text-muted: #6A706C;
    --text-inverse: #FFFFFF;

    --border: #DCE1DE;
    --border-light: #E9EDEA;
    --divider: rgba(31,36,33,0.09);

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

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

    --sidebar-bg: #F7F8F7;
    --navbar-bg: rgba(255,255,255,0.96);
    --nav-hover: rgba(31,36,33,0.05);

    --success: #13863F;
    --danger: #C62828;          /* 5.6 */
    --warning: #A35F00;         /* 5.0 */
    --info: #1565C0;            /* 5.8 */
    --success-rgb: 19, 134, 63;
    --danger-rgb: 198, 40, 40;
    --warning-rgb: 163, 95, 0;
    --info-rgb: 21, 101, 192;

    --shadow-sm: 0 1px 2px rgba(31,36,33,0.06);
    --shadow: 0 2px 8px rgba(31,36,33,0.08);
    --shadow-lg: 0 8px 24px rgba(31,36,33,0.10);

    --scrollbar-bg: #F4F6F5;
    --scrollbar-thumb: #C5CCC8;

    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;
    min-width: 0; /* empêche le contenu (tableaux, grilles) d'élargir la page sur mobile */
    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;
    min-width: 0;
    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;
    flex-wrap: wrap;
    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;
    }
}

/* ============================================
   THÈME CLAIR — LISIBILITÉ (11/2026)
   Fond blanc, cartes délimitées par une bordure fine,
   hiérarchie de texte contrastée. Les règles ne touchent
   que [data-theme="light"] : le sombre reste inchangé.
   ============================================ */

/* Badges & alertes : teintes dérivées des tokens (plus de couleurs vives en dur) */
.badge-success { background: rgba(var(--success-rgb), 0.12); color: var(--success); }
.badge-danger  { background: rgba(var(--danger-rgb), 0.12);  color: var(--danger); }
.badge-warning { background: rgba(var(--warning-rgb), 0.14); color: var(--warning); }
.badge-info    { background: rgba(var(--info-rgb), 0.12);    color: var(--info); }
.alert-error   { background: rgba(var(--danger-rgb), 0.08);  border-color: rgba(var(--danger-rgb), 0.25); }
.alert-warning { background: rgba(var(--warning-rgb), 0.08); border-color: rgba(var(--warning-rgb), 0.25); }
.alert-info    { background: rgba(var(--info-rgb), 0.08);    border-color: rgba(var(--info-rgb), 0.25); }

[data-theme="light"] body { background: var(--bg-primary); }

/* Cartes : bordure fine + ombre légère pour se détacher du fond blanc */
[data-theme="light"] .card,
[data-theme="light"] .stat-card {
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-sm);
}
[data-theme="light"] .card:hover,
[data-theme="light"] .stat-card:hover {
    background: var(--card-bg);
    box-shadow: var(--shadow);
}
[data-theme="light"] .card-header { border-bottom-color: var(--border); }
[data-theme="light"] .stat-label { color: var(--text-secondary); }

/* Boutons : texte blanc sur le vert assombri */
[data-theme="light"] .btn-primary,
[data-theme="light"] .btn-primary:hover { color: #fff; }
[data-theme="light"] .btn-secondary {
    background: var(--bg-primary);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
}
[data-theme="light"] .btn-secondary:hover { background: var(--bg-hover); }
[data-theme="light"] .avatar,
[data-theme="light"] .pagination .active { color: #fff; }

/* Tableaux : en-tête lisible, lignes séparées */
[data-theme="light"] .table th {
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}
[data-theme="light"] .table td { border-bottom-color: var(--border-light); }
[data-theme="light"] .table tr:hover td { background: var(--bg-hover); }

/* Formulaires */
[data-theme="light"] .form-control { border-color: var(--input-border); }
[data-theme="light"] .form-control:hover { border-color: #AEB6B1; }
[data-theme="light"] .form-control::placeholder { color: #8A918C; }
[data-theme="light"] .form-label { color: var(--text-secondary); }

/* Navigation */
[data-theme="light"] .sidebar { border-right: 1px solid var(--border); }
[data-theme="light"] .navbar  { border-bottom: 1px solid var(--border); }
[data-theme="light"] .nav-sub.active,
[data-theme="light"] .nav-item-solo.active {
    background: rgba(var(--primary-rgb), 0.10);
    color: var(--primary);
}

/* Modales */
[data-theme="light"] .modal-overlay { background: rgba(31,36,33,0.45); }
[data-theme="light"] .modal { border: 1px solid var(--border); }

/* Couleurs codées en dur dans les vues (texte vert vif / ambre / rouge vif) :
   ramenées sur les tokens lisibles en thème clair */
[data-theme="light"] [style*="color:#1DB954"],
[data-theme="light"] [style*="color: #1DB954"],
[data-theme="light"] [style*="color:#1db954"] { color: var(--primary) !important; }
[data-theme="light"] [style*="color:#d97706"],
[data-theme="light"] [style*="color:#f59e0b"],
[data-theme="light"] [style*="color:#F5A623"] { color: var(--warning) !important; }
[data-theme="light"] [style*="color:#ef4444"] { color: var(--danger) !important; }
[data-theme="light"] [style*="color:#4A9EFF"],
[data-theme="light"] [style*="color:#3b82f6"] { color: var(--info) !important; }

/* Focus clavier visible partout */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ── Alias de tokens (vues récentes : import, archives, tableau de bord) ── */
:root {
    --border-color: var(--border);
    --bg-card: var(--card-bg);
    --shadow-md: var(--shadow);
}

/* ============================================================
   UI PRO (11/2026) : en-têtes, listes en cartes, formulaires,
   navigation mobile flottante (style diner)
   ============================================================ */

/* ── En-tête de page ── */
.ph { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:16px; }
.ph h1 { font-size:22px; font-weight:800; letter-spacing:-.5px; line-height:1.15; margin:0; }
.ph-sub { font-size:13px; color:var(--text-tertiary); margin-top:2px; font-variant-numeric:tabular-nums; }
.ph-act { display:flex; gap:8px; flex-wrap:wrap; }
.ph-back { display:inline-flex; align-items:center; gap:4px; font-size:13px; font-weight:600; color:var(--text-secondary); text-decoration:none; margin-bottom:6px; }
.ph-back:hover { color:var(--primary); }

/* ── Recherche + filtres ── */
.tools { display:flex; gap:8px; align-items:center; margin-bottom:12px; flex-wrap:wrap; }
.srch { position:relative; flex:1; min-width:200px; }
.srch svg { position:absolute; left:12px; top:50%; transform:translateY(-50%); color:var(--text-muted); pointer-events:none; }
.srch input { width:100%; padding-left:38px !important; }
.chips { display:flex; gap:6px; overflow-x:auto; scrollbar-width:none; margin-bottom:12px; -webkit-overflow-scrolling:touch; }
.chips::-webkit-scrollbar { display:none; }
.chips a { flex-shrink:0; padding:7px 14px; border-radius:99px; border:1px solid var(--border); font-size:13px; font-weight:600; color:var(--text-secondary); text-decoration:none; white-space:nowrap; background:var(--card-bg); }
.chips a[aria-current="true"] { background:rgba(var(--primary-rgb),.1); border-color:rgba(var(--primary-rgb),.4); color:var(--primary); }
.chips a b { font-weight:800; margin-left:4px; }

/* ── Liste en cartes ── */
.lst { background:var(--card-bg); border:1px solid var(--border); border-radius:14px; overflow:hidden; }
.li { display:grid; grid-template-columns:auto minmax(0,1fr) auto auto; align-items:center; gap:12px; padding:12px 16px; border-bottom:1px solid var(--border); color:inherit; text-decoration:none; transition:background .12s; }
.li:last-child { border-bottom:none; }
a.li:hover { background:rgba(var(--primary-rgb),.04); }
a.li:active { background:rgba(var(--primary-rgb),.08); }
.li-t { font-weight:700; font-size:14.5px; color:var(--text-primary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.li-m { font-size:12.5px; color:var(--text-tertiary); margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.li-e { text-align:right; font-weight:800; font-size:14px; font-variant-numeric:tabular-nums; white-space:nowrap; }
.li-e small { display:block; font-weight:500; font-size:11.5px; color:var(--text-tertiary); }
.li-chev { color:var(--text-muted); width:16px; height:16px; }
.av { width:40px; height:40px; border-radius:12px; background:rgba(var(--primary-rgb),.1); color:var(--primary); display:flex; align-items:center; justify-content:center; font-weight:800; font-size:14px; flex-shrink:0; letter-spacing:-.3px; }
.av.n { background:var(--bg-tertiary); color:var(--text-secondary); }
.av.r { background:rgba(var(--danger-rgb),.1); color:var(--danger); }
.lst-empty { padding:40px 16px; text-align:center; }
.lst-empty b { display:block; font-size:15px; margin-bottom:12px; }
.pill { display:inline-block; font-size:11px; font-weight:700; padding:2px 8px; border-radius:99px; background:var(--bg-tertiary); color:var(--text-secondary); white-space:nowrap; }
.pill.g { background:rgba(var(--primary-rgb),.1); color:var(--primary); }
.pill.r { background:rgba(var(--danger-rgb),.1); color:var(--danger); }
.pill.w { background:rgba(var(--warning-rgb),.12); color:var(--warning); }
.pager { display:flex; justify-content:center; gap:6px; margin-top:14px; flex-wrap:wrap; }
.pager a { min-width:38px; height:38px; display:inline-flex; align-items:center; justify-content:center; border-radius:10px; border:1px solid var(--border); color:var(--text-secondary); text-decoration:none; font-weight:600; font-size:13px; background:var(--card-bg); }
.pager a[aria-current="page"] { background:var(--primary); border-color:var(--primary); color:#fff; }

/* ── Formulaires ── */
.fm { max-width:760px; }
.fm-card { background:var(--card-bg); border:1px solid var(--border); border-radius:14px; padding:20px; margin-bottom:12px; }
.fm-h { font-size:11px; font-weight:800; letter-spacing:1px; text-transform:uppercase; color:var(--text-tertiary); margin:0 0 14px; }
.fm-grid { display:grid; grid-template-columns:1fr 1fr; gap:0 14px; }
.fm-grid .full { grid-column:1 / -1; }
.fm .form-group { margin-bottom:14px; }
.fm-more { border-top:1px solid var(--border); margin-top:4px; padding-top:12px; }
.fm-more > summary { cursor:pointer; list-style:none; font-size:13.5px; font-weight:700; color:var(--primary); display:flex; align-items:center; gap:8px; padding:4px 0; }
.fm-more > summary::-webkit-details-marker { display:none; }
.fm-more > summary::before { content:'+'; width:20px; height:20px; border-radius:6px; background:rgba(var(--primary-rgb),.1); display:inline-flex; align-items:center; justify-content:center; font-weight:800; }
.fm-more[open] > summary::before { content:'\2212'; }
.fm-more[open] > summary { margin-bottom:12px; }
.fm-bar { display:flex; gap:10px; justify-content:flex-end; margin-top:4px; }
.seg { display:flex; gap:6px; flex-wrap:wrap; }
.seg label { flex:1; min-width:90px; position:relative; margin:0; }
.seg input { position:absolute; opacity:0; pointer-events:none; }
.seg span { display:flex; align-items:center; justify-content:center; text-align:center; padding:10px 8px; border:1px solid var(--border); border-radius:10px; font-size:13px; font-weight:600; color:var(--text-secondary); cursor:pointer; background:var(--input-bg); min-height:44px; }
.seg input:checked + span { border-color:var(--primary); color:var(--primary); background:rgba(var(--primary-rgb),.07); box-shadow:inset 0 0 0 1px var(--primary); }
.seg input:focus-visible + span { outline:2px solid var(--primary); outline-offset:2px; }
.recap { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:12px 14px; border-radius:10px; background:rgba(var(--primary-rgb),.06); font-size:13px; color:var(--text-secondary); margin-bottom:14px; }
.recap b { font-size:16px; color:var(--text-primary); font-variant-numeric:tabular-nums; }

/* ── Navigation mobile flottante ── */
.bnav, .bsheet { display:none; }
@media (max-width:1024px) {
    .bottom-nav { display:none !important; }
    .bnav {
        position:fixed; z-index:500; left:50%; transform:translateX(-50%);
        bottom:calc(12px + env(safe-area-inset-bottom, 0px));
        display:flex; align-items:center; gap:4px; padding:6px;
        border-radius:999px; border:1px solid var(--border);
        background:color-mix(in srgb, var(--card-bg) 84%, transparent);
        -webkit-backdrop-filter:blur(20px) saturate(1.4); backdrop-filter:blur(20px) saturate(1.4);
        box-shadow:0 10px 30px rgba(0,0,0,.14), 0 2px 6px rgba(0,0,0,.06);
        max-width:calc(100vw - 24px);
    }
    .bnav-item {
        display:inline-flex; align-items:center; gap:7px; height:46px; padding:0 14px;
        border-radius:999px; border:none; background:transparent; cursor:pointer;
        color:var(--text-secondary); font:inherit; font-size:13px; font-weight:700; white-space:nowrap;
        text-decoration:none; -webkit-tap-highlight-color:transparent; transition:background .18s, color .18s;
    }
    .bnav-item svg { width:21px; height:21px; flex-shrink:0; }
    .bnav-item[aria-current="page"] { background:rgba(var(--primary-rgb),.12); color:var(--primary); }
    .bnav-item:active { transform:scale(.96); }
    .bnav-plus {
        width:50px; height:46px; border-radius:999px; border:none; cursor:pointer; margin:0 2px;
        background:var(--primary); color:#fff; display:flex; align-items:center; justify-content:center;
        box-shadow:0 4px 12px rgba(var(--primary-rgb),.35); -webkit-tap-highlight-color:transparent;
    }
    .bnav-plus svg { width:24px; height:24px; stroke-width:2.5; }
    .bnav-plus:active { transform:scale(.94); }
    .page-content { padding-bottom:calc(96px + env(safe-area-inset-bottom, 0px)) !important; }
    #pwa-banner { bottom:calc(80px + env(safe-area-inset-bottom, 0px)) !important; }

    .bsheet { display:block; position:fixed; inset:0; z-index:1100; background:rgba(10,14,12,0); transition:background .2s; }
    .bsheet[hidden] { display:none; }
    .bsheet.on { background:rgba(10,14,12,.45); }
    .bsheet-panel {
        position:absolute; left:0; right:0; bottom:0; background:var(--card-bg);
        border-radius:22px 22px 0 0; padding:10px 16px calc(20px + env(safe-area-inset-bottom, 0px));
        transform:translateY(100%); transition:transform .22s cubic-bezier(.2,.8,.2,1);
    }
    .bsheet.on .bsheet-panel { transform:translateY(0); }
    .bsheet-grip { width:40px; height:4px; border-radius:4px; background:var(--border); margin:0 auto 16px; }
    .bsheet-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
    .bsheet-grid a { display:flex; flex-direction:column; align-items:center; gap:8px; padding:14px 6px; border-radius:14px; border:1px solid var(--border); text-decoration:none; color:var(--text-primary); font-size:12.5px; font-weight:700; text-align:center; }
    .bsheet-grid a:active { background:rgba(var(--primary-rgb),.08); }
    .bsheet-grid a span { width:42px; height:42px; border-radius:12px; background:rgba(var(--primary-rgb),.1); color:var(--primary); display:flex; align-items:center; justify-content:center; }
    .bsheet-grid a svg { width:21px; height:21px; }
}
@media (max-width:420px) {
    .bnav-item { padding:0 13px; }
    .bnav-item:not([aria-current="page"]) span { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); }
}
@media (prefers-reduced-motion:reduce) { .bsheet, .bsheet-panel, .bnav-item { transition:none; } }

/* ── Ergonomie téléphone ── */
@media (max-width:768px) {
    .ph h1 { font-size:20px; }
    .ph-act .btn { flex:1; justify-content:center; }
    .form-control, select.form-control, textarea.form-control { font-size:16px !important; min-height:46px; }
    .btn { min-height:42px; }
    .btn-sm { min-height:36px; }
    .fm-card { padding:16px; border-radius:12px; }
    .fm-grid { grid-template-columns:1fr; }
    .fm-bar { position:sticky; bottom:calc(76px + env(safe-area-inset-bottom, 0px)); z-index:20; background:var(--bg-primary); padding:10px 0 4px; margin:0; }
    .fm-bar .btn { flex:1; justify-content:center; min-height:48px; }
    .li { padding:12px 14px; gap:10px; grid-template-columns:auto minmax(0,1fr) auto; }
    .li-chev { display:none; }
    .lst { border-radius:12px; }
    .modal { max-height:calc(100vh - 24px); overflow:auto; }
}

/* ── Ajustements mobiles (UI PRO, suite) ── */
.btn svg { flex-shrink:0; }
.navbar .btn-icon { padding:0; justify-content:center; }
.navbar .btn-icon svg { width:18px; height:18px; }
.seg label { flex:1 1 0; min-width:0; }
.seg span { padding:10px 4px; }
@media (max-width:768px) {
    .page-content { padding-left:16px !important; padding-right:16px !important; padding-top:14px !important; }
    /* Formulaire : la barre d'action remplace le menu du bas */
    body:has(.fm-bar) .bnav { display:none; }
    body:has(.fm-bar) .fm-bar { bottom:0; padding:10px 0 calc(10px + env(safe-area-inset-bottom, 0px)); border-top:1px solid var(--border); margin:0 -16px; padding-left:16px; padding-right:16px; }
    body:has(.fm-bar) .page-content { padding-bottom:16px !important; }
}

/* Titre de barre : une ligne ; masqué quand la page affiche déjà son titre */
.navbar-title { white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
@media (max-width:768px) { .navbar-left { min-width:0; flex:1; } body:has(.page-content h1) .navbar-title { visibility:hidden; } }

/* ── État vide (toutes les pages) ── */
.empty, .lst-empty { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:12px; text-align:center; padding:48px 20px; }
.empty { background:var(--card-bg); border:1px solid var(--border); border-radius:14px; }
.empty b, .lst-empty b { font-size:15.5px; font-weight:800; color:var(--text-primary); margin:0; }
.empty-ic { width:60px; height:60px; border-radius:18px; background:rgba(var(--primary-rgb),.1); color:var(--primary); display:flex; align-items:center; justify-content:center; }
.lst-empty::before { content:''; width:52px; height:52px; border-radius:16px; background:rgba(var(--primary-rgb),.1) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2313863F' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M3 7h18M3 12h18M3 17h10'/%3E%3C/svg%3E") center/24px no-repeat; }
.lst-empty .btn + .btn { margin-left:0; }

/* ============================================
   CHAMPS SOBRES (18/11/2026) — fins, carrés, discrets, partout
   ============================================ */
:root { --field-radius: 4px; --field-border: #404040; --field-border-hover: #5A5A5A; --field-bg: #1A1A1A; }
[data-theme="light"] { --field-border: #D6DBD8; --field-border-hover: #B5BCB8; --field-bg: #FFFFFF; }

.form-control,
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"],
input[type="search"], input[type="date"], input[type="month"], input[type="time"], input[type="datetime-local"],
input[type="url"], input:not([type]), select, textarea {
    border: 1px solid var(--field-border) !important;
    border-radius: var(--field-radius) !important;
    background-color: var(--field-bg);
    box-shadow: none !important;
    font-weight: 400;
    transition: border-color .12s;
}
.form-control:hover,
input[type="text"]:hover, input[type="email"]:hover, input[type="password"]:hover, input[type="tel"]:hover,
input[type="number"]:hover, input[type="search"]:hover, input[type="date"]:hover, input[type="month"]:hover,
select:hover, textarea:hover { border-color: var(--field-border-hover) !important; }
.form-control:focus,
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="tel"]:focus,
input[type="number"]:focus, input[type="search"]:focus, input[type="date"]:focus, input[type="month"]:focus,
input[type="time"]:focus, input[type="url"]:focus, input:not([type]):focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary) !important;
    box-shadow: none !important;
}
.form-control::placeholder, input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .7; }

/* Pas de fond bleu de remplissage automatique du navigateur */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus,
select:-webkit-autofill, textarea:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 1000px var(--field-bg) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary);
    transition: background-color 9999s;
}

/* Choix en boutons alignés sur les champs */
.seg span { border-radius: var(--field-radius) !important; }

/* ============================================
   TABLEAUX COMPACTS (19/11/2026) — moins de vide, lecture dense
   ============================================ */
.table th, .sa-table th, .db-own th {
    padding: 8px 12px !important;
    font-size: 11px !important;
    letter-spacing: .5px;
    line-height: 1.3;
    white-space: nowrap;
}
.table td, .sa-table td, .db-own td {
    padding: 7px 12px !important;
    font-size: 13.5px;
    line-height: 1.35;
}
.table td > div + div, .table td small, .table td .text-muted { font-size: 12px; line-height: 1.3; }
.table td .badge, .table td .pill, .table td [class*="badge-"] { padding: 2px 8px !important; font-size: 11.5px !important; line-height: 1.5; }
.table td .btn-sm, .table td .btn { padding-top: 4px; padding-bottom: 4px; min-height: 30px; }
.table-container, .table-responsive { margin: 0; }
.card > .table-container:first-child .table th, .card-body > .table-container:first-child .table th { border-top: 0; }
@media (max-width: 768px) {
    .table th { padding: 7px 10px !important; }
    .table td { padding: 7px 10px !important; font-size: 13px; }
}
