:root {
    --bg-dark: #0a0d14;
    --bg-card: #121824;
    --bg-card-hover: #172030;
    --bg-input: #1a2233;
    --border: #232d42;
    --border-focus: #3b82f6;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gold: #d4af37;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Plus Jakarta Sans', sans-serif; }
body { background: var(--bg-dark); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; }

/* LOGIN */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(circle at top, #1e293b 0%, #0a0d14 70%); }
.login-card { background: var(--bg-card); border: 1px solid var(--border); padding: 40px; border-radius: var(--radius-lg); width: 100%; max-width: 420px; box-shadow: 0 20px 40px rgba(0,0,0,0.5); text-align: center; }
.brand-badge { width: 64px; height: 64px; margin: 0 auto 20px; background: rgba(59, 130, 246, 0.1); border: 1px solid var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; color: var(--primary); }
.login-card h1 { font-size: 1.5rem; letter-spacing: 2px; margin-bottom: 5px; }
.login-card .subtitle { color: var(--text-secondary); font-size: 0.85rem; margin-bottom: 30px; }
.input-group { text-align: left; margin-bottom: 20px; }
.input-group label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 8px; font-weight: 500; }
.input-group input, .form-control { width: 100%; padding: 12px 14px; background: var(--bg-input); border: 1px solid var(--border); color: white; border-radius: var(--radius-sm); outline: none; transition: 0.2s; font-size: 0.95rem; }
.input-group input:focus, .form-control:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
.btn { padding: 12px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.9rem; cursor: pointer; border: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: 0.2s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; }
.alert-error { margin-top: 15px; padding: 10px; border-radius: var(--radius-sm); background: rgba(239, 68, 68, 0.15); border: 1px solid var(--danger); color: #fca5a5; font-size: 0.85rem; }
.login-footer { margin-top: 25px; font-size: 0.75rem; color: var(--text-muted); }

/* APP LAYOUT */
.app-container { display: flex; min-height: 100vh; }
.sidebar { width: 280px; background: #0e131d; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 25px 20px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.logo-box { width: 40px; height: 40px; background: linear-gradient(135deg, var(--primary), var(--gold)); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: white; }
.logo-text h2 { font-size: 1rem; letter-spacing: 1px; line-height: 1; }
.logo-text span { font-size: 0.65rem; color: var(--gold); letter-spacing: 2px; font-weight: 700; }
.sidebar-nav { padding: 20px 12px; flex: 1; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.nav-section-title { font-size: 0.65rem; color: var(--text-muted); letter-spacing: 1.5px; padding: 10px 12px 5px; font-weight: 700; }
.nav-item { width: 100%; padding: 12px 14px; background: transparent; border: none; color: var(--text-secondary); border-radius: var(--radius-sm); display: flex; align-items: center; gap: 12px; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: 0.2s; position: relative; }
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: rgba(59, 130, 246, 0.15); color: var(--primary); font-weight: 600; }
.badge-count { margin-left: auto; background: var(--danger); color: white; font-size: 0.7rem; padding: 2px 7px; border-radius: 10px; font-weight: 700; }
.sidebar-footer { padding: 15px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.user-chip { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; }
.user-name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.user-role { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.btn-logout { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem; transition: 0.2s; padding: 5px; }
.btn-logout:hover { color: var(--danger); }

/* MAIN CONTENT */
.main-content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; background: var(--bg-dark); }
.topbar { padding: 25px 35px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; background: rgba(14, 19, 29, 0.8); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 10; }
.page-title h1 { font-size: 1.5rem; font-weight: 700; }
.page-title span { font-size: 0.85rem; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.live-clock { font-family: monospace; font-size: 1.1rem; color: var(--gold); font-weight: 700; background: var(--bg-card); padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.content-body { padding: 30px 35px; flex: 1; }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* FILTERS & TABS */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 25px; }
.segmented-control { display: inline-flex; background: var(--bg-card); padding: 4px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.seg-btn { background: none; border: none; color: var(--text-secondary); padding: 8px 16px; border-radius: 4px; font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: 0.2s; }
.seg-btn.active { background: var(--primary); color: white; }
.subtabs { display: flex; gap: 8px; }
.subtab-btn { background: var(--bg-card); border: 1px solid var(--border); color: var(--text-secondary); padding: 8px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: 0.2s; }
.subtab-btn.active { border-color: var(--primary); color: var(--primary); background: rgba(59, 130, 246, 0.08); }
.search-box { position: relative; min-width: 260px; }
.search-box i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-box input { width: 100%; padding: 10px 14px 10px 38px; background: var(--bg-card); border: 1px solid var(--border); color: white; border-radius: var(--radius-sm); outline: none; }

/* KPIS */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.kpi-card { background: var(--bg-card); border: 1px solid var(--border); padding: 22px; border-radius: var(--radius-md); display: flex; align-items: center; gap: 18px; }
.kpi-icon { width: 50px; height: 50px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; }
.accent-green .kpi-icon { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.accent-red .kpi-icon { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.accent-blue .kpi-icon { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.accent-gold .kpi-icon { background: rgba(212, 175, 55, 0.15); color: var(--gold); }
.kpi-meta span { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }
.kpi-meta h3 { font-size: 1.4rem; font-weight: 700; margin-top: 4px; }

/* TABLES */
.table-container { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { background: #0e131d; padding: 14px 18px; font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.data-table td { padding: 14px 18px; font-size: 0.85rem; border-bottom: 1px solid var(--border); color: var(--text-primary); }
.data-table tbody tr:hover { background: var(--bg-card-hover); }

/* CARDS LIST */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.dossier-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px; transition: 0.2s; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; }
.dossier-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 10px 20px rgba(0,0,0,0.3); }
.dossier-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; }
.badge-afaire { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-encours { background: rgba(59, 130, 246, 0.15); color: var(--primary); }
.badge-termine { background: rgba(16, 185, 129, 0.15); color: var(--success); }
.dossier-body h3 { font-size: 1.1rem; margin-bottom: 4px; }
.dossier-body p { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 15px; }
.dossier-finances { background: rgba(0,0,0,0.25); padding: 12px; border-radius: var(--radius-sm); display: flex; justify-content: space-between; font-size: 0.8rem; }
.dossier-finances strong { display: block; font-size: 0.95rem; margin-top: 2px; }

/* MODALS */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(5px); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px; }
.modal-card { background: var(--bg-card); border: 1px solid var(--border); width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto; border-radius: var(--radius-lg); box-shadow: 0 25px 50px rgba(0,0,0,0.5); }
.modal-header { padding: 20px 25px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 1.2rem; }
.btn-close-modal { background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer; }
.btn-close-modal:hover { color: white; }
.modal-body { padding: 25px; }

.mt-4 { margin-top: 1.5rem; }
.gap-3 { gap: 1rem; }
.flex-align-center { display: flex; align-items: center; }

/* ===== AJOUTS (version corrigée) ===== */
.input-group select, .input-group textarea { width: 100%; padding: 12px 14px; background: var(--bg-input); border: 1px solid var(--border); color: white; border-radius: var(--radius-sm); outline: none; font-size: 0.95rem; }
.input-group textarea { resize: vertical; }
.input-group input[type=file] { padding: 9px; font-size: 0.85rem; }
.input-group input[type=date] { color-scheme: dark; }
.input-group select:focus, .input-group textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.button-group { display: flex; flex-wrap: wrap; gap: 10px; }
.table-container { overflow-x: auto; }
.data-table { min-width: 720px; }
.btn-xs { padding: 5px 10px; font-size: 0.75rem; border-radius: 5px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-danger:hover { filter: brightness(1.1); }
.badge-rejete { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.footer-actions { display: flex; gap: 2px; }
.mono { font-family: monospace; font-size: 0.8rem; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.small { font-size: 0.85rem; }
.bold { font-weight: 700; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.c-success { color: var(--success); } .c-danger { color: var(--danger); } .c-primary { color: var(--primary); }
.c-warning { color: var(--warning); } .c-gold { color: var(--gold); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mb { margin-bottom: 20px; } .mb-s { margin-bottom: 10px; } .mt-2 { margin-top: 12px; }
.h-lg { font-size: 1.3rem; } .h-sm { font-size: 0.95rem; }
.panel { background: var(--bg-input); padding: 14px; border-radius: var(--radius-sm); }
.panel p { margin-bottom: 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.line { padding: 8px 0; border-bottom: 1px solid var(--border); }
.line:last-child { border-bottom: none; }
.done { text-decoration: line-through; opacity: 0.6; }
.small-line { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 6px; }
.actions-end { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.mini-select, .mini-input { background: var(--bg-card); color: white; border: 1px solid var(--border); padding: 5px 8px; border-radius: 4px; font-size: 0.78rem; }
.mini-input { width: 110px; }
.notice { background: rgba(245, 158, 11, 0.12); border: 1px solid var(--warning); color: #fcd34d; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 0.85rem; margin-bottom: 16px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state { grid-column: 1 / -1; text-align: center; padding: 40px; color: var(--text-muted); }
.empty-state i { font-size: 2.5rem; margin-bottom: 10px; display: block; }
.empty-cell { text-align: center; color: var(--text-muted); padding: 30px !important; }
.row-late { background: rgba(239, 68, 68, 0.08); }
.content-body, .modal-card { min-width: 0; }

/* ===== MOBILE ===== */
@media (max-width: 900px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; align-items: center; border-right: none; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
    .sidebar-header { padding: 10px 12px; border-bottom: none; }
    .logo-text { display: none; }
    .sidebar-nav { flex-direction: row; padding: 6px; overflow-x: auto; overflow-y: hidden; gap: 4px; flex: 1; }
    .nav-section-title { display: none; }
    .nav-item { width: auto; flex-shrink: 0; padding: 10px 12px; }
    .nav-item span:not(.badge-count) { display: none; }
    .nav-item.active span:not(.badge-count) { display: inline; }
    .badge-count { margin-left: 4px; }
    .sidebar-footer { border-top: none; padding: 6px 10px; gap: 6px; }
    .user-meta { display: none; }
    .topbar { position: static; padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
    .page-title h1 { font-size: 1.15rem; }
    .live-clock { display: none; }
    .content-body { padding: 16px; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .search-box { min-width: 0; width: 100%; }
    .subtabs { overflow-x: auto; }
    .cards-grid { grid-template-columns: 1fr; }
    .form-row, .stat-grid { grid-template-columns: 1fr; }
    .modal-overlay { padding: 8px; align-items: flex-end; }
    .modal-card { max-height: 94vh; }
    .modal-body { padding: 16px; }
}
