:root {
    --navy: #0c2340;
    --navy-2: #143056;
    --teal: #0f8a6b;
    --teal-2: #12a57e;
    --teal-soft: #e6f6f0;
    --gold: #c9a227;
    --bg: #f3f6f9;
    --card: #ffffff;
    --text: #1c2b3a;
    --muted: #6b7c8d;
    --line: #e3eaf1;
    --danger: #c0392b;
    --warn: #d68910;
    --info: #1a7aad;
    --ok: #1e8a5a;
    --shadow: 0 10px 30px rgba(12, 35, 64, .08);
    --radius: 16px;
    --sidebar: 268px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "DM Sans", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-2); }

.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar);
    background: linear-gradient(180deg, var(--navy) 0%, #0a1b33 100%);
    color: #fff;
    position: fixed;
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--teal), #1fd1a0);
    display: grid; place-items: center;
    font-weight: 800; letter-spacing: .5px;
    color: #fff;
}
.brand h1 { font-size: 16px; margin: 0; font-weight: 700; }
.brand p { margin: 2px 0 0; font-size: 11px; color: #9bb0c7; }

.nav { padding: 14px 12px; overflow: auto; flex: 1; }
.nav a {
    display: flex; align-items: center; gap: 10px;
    color: #c5d4e4; padding: 10px 12px; border-radius: 10px;
    margin-bottom: 4px; font-size: 14px; font-weight: 500;
}
.nav a svg { width: 18px; height: 18px; opacity: .9; flex-shrink: 0; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(18, 165, 126, .18); color: #8ef0d0; }
.nav .section { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #7e93ab; padding: 14px 12px 6px; }

.sidebar-user {
    padding: 14px 16px 18px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; gap: 10px;
}
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--teal); display: grid; place-items: center;
    font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user strong { display: block; font-size: 13px; }
.sidebar-user span { font-size: 11px; color: #9bb0c7; }

.main { margin-left: var(--sidebar); flex: 1; min-width: 0; }
.topbar {
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: 16px 28px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 20px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.content { padding: 24px 28px 48px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 0; border-radius: 10px; padding: 9px 14px;
    font-weight: 600; font-size: 13px; cursor: pointer;
    background: var(--teal); color: #fff; text-decoration: none;
}
.btn:hover { background: var(--teal-2); color: #fff; }
.btn-outline { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn-outline:hover { background: #f7fafc; color: var(--navy); }
.btn-danger { background: var(--danger); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-h { padding: 16px 18px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-h h3 { margin: 0; font-size: 15px; }
.card-b { padding: 16px 18px 18px; }

.kpi {
    padding: 18px;
    display: flex; flex-direction: column; gap: 8px;
}
.kpi .label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 28px; font-weight: 700; color: var(--navy); }
.kpi .hint { font-size: 12px; color: var(--muted); }
.kpi.accent { background: linear-gradient(135deg, var(--navy), #1a4a7a); color: #fff; }
.kpi.accent .label, .kpi.accent .hint { color: #b7cce0; }
.kpi.accent .value { color: #fff; }
a.kpi { color: inherit; text-decoration: none; transition: transform .12s ease, box-shadow .12s ease; }
a.kpi:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(12, 35, 64, .12); color: inherit; }

.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
    text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafcfe;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:hover td { background: #f8fbfa; }

.badge {
    display: inline-flex; align-items: center;
    padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
}
.badge-ok { background: #e5f7ee; color: var(--ok); }
.badge-warn { background: #fdf3e1; color: var(--warn); }
.badge-danger { background: #fdecea; color: var(--danger); }
.badge-info { background: #e8f4fb; color: var(--info); }
.badge-muted { background: #eef2f6; color: var(--muted); }

.form { display: grid; gap: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: #445566; }
input, select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
    font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15,138,107,.25); border-color: var(--teal); }

.filters {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: end;
    margin-bottom: 16px;
}
.filters .field { min-width: 180px; }

.alert {
    padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-size: 14px;
}
.alert-success { background: #e5f7ee; color: #146c43; }
.alert-error { background: #fdecea; color: #922b21; }
.alert-info { background: #e8f4fb; color: #1a5276; }

.progress { height: 8px; background: #e8eef4; border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--teal), #1fd1a0); }

.calendar {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px;
}
.cal-day {
    background: #fff; border: 1px solid var(--line); border-radius: 12px; min-height: 150px; padding: 10px;
}
.cal-day h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); }
.cal-day.today { border-color: var(--teal); box-shadow: 0 0 0 2px rgba(15,138,107,.12); }
.event {
    display: block; font-size: 11px; padding: 6px 8px; border-radius: 8px; margin-bottom: 6px;
    background: var(--teal-soft); color: #0b5c48; font-weight: 600;
}
.event.visite { background: #e8f4fb; color: #1a5276; }
.event.recouvrement { background: #fdf3e1; color: #7d5a0f; }
.event.autre { background: #eef2f6; color: #445566; }
.event.annule { opacity: .55; text-decoration: line-through; }

.modal {
    position: fixed; inset: 0; background: rgba(12,35,64,.45);
    display: none; align-items: flex-start; justify-content: center;
    padding: 40px 16px; z-index: 80; overflow: auto;
}
.modal.open { display: flex; }
.modal-card { width: min(720px, 100%); background: #fff; border-radius: 18px; box-shadow: var(--shadow); }
.modal-h { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-b { padding: 18px; }

.login-page {
    min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr;
    background: var(--navy);
}
.login-hero {
    padding: 56px;
    color: #fff;
    background:
        radial-gradient(circle at 20% 20%, rgba(18,165,126,.35), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(201,162,39,.18), transparent 35%),
        linear-gradient(180deg, #0c2340, #071627);
    display: flex; flex-direction: column; justify-content: space-between;
}
.login-hero h2 { font-size: 38px; line-height: 1.15; margin: 12px 0 10px; }
.login-hero p { color: #b7cce0; max-width: 460px; }
.login-panel { background: #fff; display: grid; place-items: center; padding: 40px 28px; }
.login-box { width: min(420px, 100%); }
.login-box h3 { margin: 0 0 6px; font-size: 24px; }
.login-box .muted { color: var(--muted); margin-bottom: 22px; }
.obj-list { list-style: none; padding: 0; margin: 24px 0 0; }
.obj-list li {
    background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
    border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; font-size: 13px;
}

.empty { text-align: center; color: var(--muted); padding: 28px 8px; }
.menu-toggle { display: none; }
.sub, .hint { color: var(--muted); font-size: 12px; }

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .calendar { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
    .login-page { grid-template-columns: 1fr; }
    .login-hero { display: none; }
    .sidebar { transform: translateX(-110%); transition: .2s; }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .grid-4, .grid-3, .grid-2, .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .content, .topbar { padding-left: 16px; padding-right: 16px; }
}
