:root {
    --primary: #2a4173;
    --primary-dark: #0f1c3f;
    --primary-light: #e8ecf6;
    --accent: #c9a04a;
    --danger: #c0392b;
    --warning: #c9a04a;
    --success: #1d6f5c;
    --bg: #f3f5f9;
    --card-bg: #ffffff;
    --text: #202537;
    --text-muted: #6b7280;
    --border: #e2e5ee;
    --radius: 10px;
    --sidebar-width: 250px;
}

[data-theme="dark"] {
    --primary: #4a68a8;
    --primary-dark: #1a2b52;
    --primary-light: #1c2743;
    --accent: #d9b46a;
    --danger: #e0685a;
    --warning: #d9b46a;
    --success: #35a085;
    --bg: #0e1220;
    --card-bg: #171d30;
    --text: #e7eaf3;
    --text-muted: #94a0bd;
    --border: #2a3350;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    transition: background-color .2s ease, color .2s ease;
}

a { color: inherit; text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-dark);
    color: #eef4f1;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
}
.sidebar .brand {
    padding: 20px 22px;
    font-size: 19px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex; align-items: center; gap: 10px;
}
.sidebar .brand small { display:block; font-size: 11px; font-weight: 400; opacity: .7; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar a.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 22px;
    color: #cfe0da;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.sidebar a.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar a.nav-link.active {
    background: rgba(255,255,255,.09);
    border-left-color: var(--accent);
    color: #fff;
    font-weight: 600;
}
.sidebar .icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar .brand .icon { width: 22px; height: 22px; }
.sidebar-footer { padding: 16px 22px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12.5px; opacity:.75; }

/* --- Main --- */
.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 30;
    box-shadow: 0 1px 3px rgba(15,28,63,.04);
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; }
.topbar-actions { display:flex; align-items:center; gap:12px; }

/* --- Bouton mode sombre --- */
.theme-toggle {
    display:flex; align-items:center; justify-content:center;
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--bg); border: 1px solid var(--border);
    color: var(--text-muted); cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* --- Cloche de notifications --- */
.notif-menu { position: relative; }
.notif-btn {
    position:relative; display:flex; align-items:center; justify-content:center;
    width: 38px; height: 38px; border-radius: 10px;
    background: var(--bg); border: 1px solid var(--border);
    color: var(--text-muted); cursor: pointer;
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.notif-btn:hover { color: var(--primary); border-color: var(--primary); }
.notif-btn .icon { width: 18px; height: 18px; }
.notif-badge {
    position:absolute; top:-4px; right:-4px; background: var(--danger); color:#fff;
    font-size:10px; font-weight:800; min-width:16px; height:16px; padding:0 4px;
    border-radius:20px; display:flex; align-items:center; justify-content:center;
    border:2px solid var(--card-bg);
}
.notif-dropdown {
    position:absolute; top: calc(100% + 8px); right:0; width:320px; max-height:400px; overflow-y:auto;
    background: var(--card-bg); border:1px solid var(--border); border-radius:12px;
    box-shadow: 0 12px 30px rgba(15,28,63,.16); opacity:0; visibility:hidden; transform: translateY(-6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s; z-index:40;
}
.notif-menu.open .notif-dropdown { opacity:1; visibility:visible; transform: translateY(0); }
.notif-dropdown-header { display:flex; align-items:center; justify-content:space-between; padding:12px 14px; border-bottom:1px solid var(--border); font-size:14px; }
.notif-empty { padding:24px 14px; text-align:center; color:var(--text-muted); font-size:13px; }
.notif-item { display:block; padding:10px 14px; border-bottom:1px solid var(--border); }
.notif-item:last-child { border-bottom:none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--primary-light); }
.notif-item-title { font-weight:700; font-size:13px; color:var(--text); }
.notif-type-danger .notif-item-title::before { content:'🔴 '; }
.notif-type-attention .notif-item-title::before { content:'🟠 '; }
.notif-type-succes .notif-item-title::before { content:'🟢 '; }
.notif-type-info .notif-item-title::before { content:'🔵 '; }
.notif-item-msg { font-size:12.5px; color:var(--text-muted); margin-top:2px; line-height:1.4; }
.notif-item-date { font-size:11px; color:var(--text-muted); margin-top:4px; }

/* --- Menu utilisateur déroulant --- */
.user-menu { position: relative; }
.user-chip {
    display:flex; align-items:center; gap:10px;
    background: var(--bg); border: 1px solid var(--border);
    padding: 6px 12px 6px 6px; border-radius: 30px;
    cursor: pointer; font: inherit; color: inherit;
    transition: border-color .15s ease, background-color .15s ease;
}
.user-chip:hover { border-color: var(--primary); }
.user-chip .avatar {
    width: 32px; height:32px; border-radius: 50%;
    background: var(--primary); color:#fff; display:flex;
    align-items:center; justify-content:center; font-weight:700; font-size:13.5px;
    flex-shrink: 0;
}
.user-chip .avatar.avatar-lg { width: 42px; height: 42px; font-size: 16px; }
.user-chip .role-badge {
    font-size: 11px; padding: 2px 8px; border-radius: 20px;
    background: var(--primary-light); color: var(--primary-dark); font-weight:600;
}
.user-chip-name { text-align: left; line-height: 1.25; }
.user-chip-name .name { font-weight: 600; font-size: 13.5px; }
.user-chip-name .sub { font-size: 11.5px; }
.user-chip .chevron { width: 15px; height: 15px; color: var(--text-muted); transition: transform .15s ease; }
.user-menu.open .user-chip .chevron { transform: rotate(180deg); }

.user-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 250px; background: var(--card-bg); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: 0 12px 30px rgba(15,28,63,.16);
    padding: 8px; opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity .15s ease, transform .15s ease, visibility .15s;
    z-index: 40;
}
.user-menu.open .user-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.user-dropdown-header { display:flex; align-items:center; gap:10px; padding: 8px 8px 10px; }
.user-dropdown-header .name { font-weight:700; font-size:14px; }
.user-dropdown-divider { height:1px; background: var(--border); margin: 6px 4px; }
.user-dropdown-item {
    display:flex; align-items:center; gap:10px;
    padding: 9px 10px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
    color: var(--text);
}
.user-dropdown-item .icon { width: 17px; height: 17px; color: var(--text-muted); flex-shrink:0; }
.user-dropdown-item:hover { background: var(--bg); }
.user-dropdown-item.danger { color: var(--danger); }
.user-dropdown-item.danger .icon { color: var(--danger); }

.content { padding: 26px 28px; flex:1; }

/* --- Cards / stats --- */
.stats-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 24px; }
.stat-card {
    background: var(--card-bg); border-radius: var(--radius);
    padding: 18px 20px; border: 1px solid var(--border);
    display:flex; flex-direction:column; gap:6px;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.stat-card .label { font-size:12.5px; color:var(--text-muted); font-weight:600; text-transform:uppercase; letter-spacing:.04em; }
.stat-card .value { font-size: 26px; font-weight: 800; color: var(--primary-dark); }
.stat-card.alert .value { color: var(--danger); }
.stat-card.warn .value { color: var(--warning); }

.card {
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; margin-bottom: 20px;
}
.card-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.card-header h2 { font-size:16px; margin:0; font-weight:700; }

.grid-2 { display:grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

.grid-charts { display:grid; grid-template-columns: 1.5fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 980px) { .grid-charts { grid-template-columns: 1fr; } }
.chart-card .card-header { margin-bottom: 4px; }
.chart-highlight { font-size:28px; font-weight:800; color:var(--primary-dark); margin: 6px 0 2px; }
.chart-highlight span { font-size:13px; font-weight:600; color:var(--text-muted); margin-left:6px; }
.chart-wrap { position:relative; height: 220px; margin-top: 10px; }
.chart-wrap-donut { display:flex; align-items:center; justify-content:center; }

/* --- Table --- */
table.data-table { width:100%; border-collapse: collapse; font-size: 13.8px; }
table.data-table th {
    text-align:left; padding: 10px 12px; background: var(--primary-light);
    color: var(--primary-dark); font-weight:700; font-size: 12.5px; text-transform:uppercase; letter-spacing:.03em;
}
table.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:hover td { background: #fafcfb; }
.table-actions a { margin-right: 10px; font-size: 13px; }
.table-actions a.danger { color: var(--danger); }
.table-actions a.edit { color: var(--primary); }
.whatsapp-link {
    display:inline-flex; align-items:center; gap:5px; color:#1d6f5c !important; font-weight:600;
}
.whatsapp-link:hover { text-decoration:underline; }

/* --- Badges --- */
.badge { display:inline-block; padding: 3px 10px; border-radius: 20px; font-size:11.5px; font-weight:700; }
.badge-green  { background:#e3f3ee; color:#1d6f5c; }
.badge-red    { background:#fbe6e3; color:#c0392b; }
.badge-orange { background:#fbeed9; color:#b9791f; }
.badge-gray   { background:#eceeed; color:#5c6b66; }
.badge-blue   { background:#e5eefb; color:#2560ac; }

/* --- Forms --- */
.form-grid { display:grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid.single { grid-template-columns: 1fr; }
@media (max-width:760px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { display:flex; flex-direction:column; gap:6px; }
.form-group label { font-size:13px; font-weight:600; color: var(--text); }
.form-group .hint { font-size:11.5px; color:var(--text-muted); }
input, select, textarea {
    padding: 9px 12px; border:1px solid var(--border); border-radius:8px;
    font-size: 14px; font-family:inherit; background:#fff; color:var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
.checkbox-row { display:flex; align-items:center; gap:8px; }
.checkbox-row input { width:auto; }

/* --- Buttons --- */
.btn {
    display:inline-flex; align-items:center; gap:8px;
    padding: 9px 18px; border-radius: 8px; border:none; cursor:pointer;
    font-size: 14px; font-weight: 600; text-decoration:none;
}
.btn-primary { background: var(--primary); color:#fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background:#fff; border:1px solid var(--border); color:var(--text); }
.btn-outline:hover { border-color: var(--primary); color:var(--primary); }
.btn-danger { background: var(--danger); color:#fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.form-actions { margin-top: 20px; display:flex; gap:10px; }

/* --- Login (ancien style, conservé pour compat) --- */
.login-page {
    min-height:100vh; display:flex; align-items:center; justify-content:center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}
.login-card {
    background:#fff; padding: 40px 36px; border-radius: 14px; width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h1 { font-size:22px; margin: 0 0 4px; color:var(--primary-dark); }
.login-card p.subtitle { color:var(--text-muted); margin: 0 0 24px; font-size:13.5px; }
.login-card .form-group { margin-bottom:16px; }
.login-card .btn { width:100%; justify-content:center; padding:11px; }

/* --- Auth (écran de connexion moderne) --- */
.auth-page {
    margin:0; min-height:100vh; font-family:'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--primary-dark);
}
.auth-shell { display:flex; min-height:100vh; }

.auth-brand {
    flex: 1.1; position:relative; overflow:hidden; display:flex; align-items:center; justify-content:center;
    background: linear-gradient(155deg, var(--primary-dark) 0%, var(--primary) 60%, #16305c 100%);
    padding: 60px 50px; color:#eef2fb;
}
.auth-brand-glow {
    position:absolute; width:520px; height:520px; border-radius:50%;
    background: radial-gradient(circle, rgba(201,160,74,.35), transparent 70%);
    top:-140px; right:-140px; pointer-events:none;
}
.auth-brand-glow::after {
    content:''; position:absolute; width:380px; height:380px; border-radius:50%;
    background: radial-gradient(circle, rgba(255,255,255,.08), transparent 70%);
    bottom:-460px; left:-260px;
}
.auth-brand-content { position:relative; max-width:440px; }
.auth-logo { font-size:44px; margin-bottom:18px; filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)); }
.auth-brand-content h1 { font-size:30px; margin:0 0 14px; font-weight:800; letter-spacing:.01em; }
.auth-brand-content p { font-size:14.5px; line-height:1.7; color:#c9d3ea; margin:0 0 26px; }
.auth-feature-list { list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:12px; }
.auth-feature-list li { display:flex; align-items:center; gap:10px; font-size:13.8px; color:#e4e9f7; }
.auth-feature-ico {
    width:22px; height:22px; flex-shrink:0; border-radius:50%; background: rgba(201,160,74,.9);
    color:#1a2340; display:flex; align-items:center; justify-content:center; font-size:12px; font-weight:800;
}

.auth-form-side {
    flex:1; background: var(--bg); display:flex; flex-direction:column; align-items:center; justify-content:center;
    padding: 40px 24px;
}
.auth-card {
    background: var(--card-bg); width:100%; max-width:380px; padding: 38px 34px;
    border-radius: 18px; box-shadow: 0 24px 60px rgba(15,20,40,.14);
    border: 1px solid var(--border);
}
.auth-card-header { text-align:center; margin-bottom: 26px; }
.auth-logo-sm { font-size:26px; margin-bottom:6px; }
.auth-card-header h2 { font-size:20px; margin:0 0 4px; color:var(--primary-dark); font-weight:800; }
.auth-card-header .subtitle { color:var(--text-muted); font-size:13px; margin:0; }

.auth-field { margin-bottom:16px; }
.auth-field label { display:block; font-size:12.5px; font-weight:600; margin-bottom:6px; color:var(--text-muted); }
.auth-input-wrap {
    display:flex; align-items:center; gap:9px; border:1.5px solid var(--border); border-radius:10px;
    padding: 0 12px; background: var(--bg); transition: border-color .15s ease, box-shadow .15s ease;
}
.auth-input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.auth-input-wrap .icon { width:18px; height:18px; color: var(--text-muted); flex-shrink:0; }
.auth-input-wrap input {
    border:none; background:transparent; outline:none; padding:11px 0; font-size:14px; flex:1; color:var(--text);
    min-width:0;
}
.auth-toggle-pass { background:none; border:none; cursor:pointer; padding:4px; color:var(--text-muted); display:flex; }
.auth-toggle-pass.is-visible { color: var(--primary); }
.auth-toggle-pass .icon { width:18px; height:18px; }

.auth-submit { width:100%; justify-content:center; padding:12px; font-size:14.5px; margin-top:6px; }
.auth-submit:disabled { opacity:.55; cursor:not-allowed; }
.auth-alert { display:flex; align-items:flex-start; gap:9px; }
.auth-alert .icon { width:18px; height:18px; flex-shrink:0; margin-top:1px; }

.auth-lock-box {
    display:flex; align-items:center; gap:8px; background: var(--primary-light); color:var(--primary-dark);
    border-radius:10px; padding:10px 12px; font-size:13px; font-weight:600; margin-bottom:14px;
}
.auth-lock-box .icon { width:17px; height:17px; }
.auth-lock-box strong { font-size:14px; }

.auth-security-note { margin-top:20px; font-size:11.8px; color:var(--text-muted); text-align:center; line-height:1.5; }
.auth-footer { text-align:center; margin-top:18px; font-size:12px; color:#8791ab; }

@media (max-width: 860px) {
    .auth-brand { display:none; }
    .auth-form-side { padding: 24px 16px; }
}

/* --- Alerts --- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom:16px; font-size:13.8px; }
.alert-success { background:#e3f3ee; color:#1d6f5c; }
.alert-danger  { background:#fbe6e3; color:#c0392b; }
.alert-warning { background:#fbeed9; color:#b9791f; }

.empty-state { text-align:center; padding: 40px 20px; color: var(--text-muted); }
.muted { color: var(--text-muted); }
.text-right { text-align:right; }
.mb-0 { margin-bottom:0; }
.filters { display:flex; gap:10px; margin-bottom: 18px; flex-wrap:wrap; }
.filters select, .filters input { min-width: 180px; }

.bien-thumb {
    width: 100%; height: 130px; object-fit: cover; border-radius: 8px; background:#eee;
    display:block; margin-bottom: 10px;
}
.bien-card-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap:16px; }
.bien-card { border:1px solid var(--border); border-radius: var(--radius); padding:12px; background:#fff; }
.bien-card h3 { font-size:14.5px; margin: 4px 0; }
.bien-card .price { font-weight:800; color: var(--primary-dark); }

.error-page {
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    height:100vh; text-align:center; padding:20px; background: var(--bg, #f6f7f9);
}
.error-code { font-size: 72px; font-weight:800; color: var(--primary, #1d7a5c); line-height:1; }
.error-page h1 { font-size: 20px; margin: 10px 0; }
.error-page p { color: var(--text-muted, #666); margin-bottom: 20px; }

.detail-grid { display:grid; grid-template-columns: 2fr 1fr; gap: 18px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.info-row { display:flex; justify-content:space-between; padding:8px 0; border-bottom:1px solid var(--border); font-size:13.8px; }
.info-row:last-child { border-bottom:none; }
.info-row .label { color: var(--text-muted); }
.timeline-list { list-style:none; padding:0; margin:0; }
.timeline-list li { padding:10px 0; border-bottom:1px solid var(--border); font-size:13.5px; }
.timeline-list li:last-child { border-bottom:none; }
.progress-bar-outer { background:#eee; border-radius:20px; height:8px; overflow:hidden; margin-top:6px; }
.progress-bar-inner { background: var(--primary, #1d7a5c); height:100%; }
