:root {
    --sidebar-top: #2CACE3;
    --sidebar-bottom: #1E8FC2;
    --accent: #FEB942;
    --blue: #23A2CD;
    --red: #EF5B5B;
    --yellow: #FEB942;
    --dark: #2E3A46;
    --bg: #ECEEF1;
    --card: #FFFFFF;
    --ink: #33414D;
    --muted: #8A97A2;
    --line: #E7EAEE;
    --danger: #EF5B5B;
    --danger-bg: #FCE9E9;
    --ok-bg: #EAF6EF;
    --ok: #2FAE6A;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 230px;
    background: linear-gradient(180deg, var(--sidebar-top) 0%, var(--sidebar-bottom) 100%);
    display: flex;
    flex-direction: column;
    padding: 26px 0;
    z-index: 10;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    padding: 0 24px 26px;
    border-bottom: 1px solid rgba(255,255,255,0.18);
    margin-bottom: 18px;
}
.sidebar .brand .logo-badge {
    width: 34px; height: 34px;
    background: rgba(255,255,255,0.18);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.sidebar .brand span { line-height: 1.2; }

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

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 500;
}
.sidebar nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.9; }
.sidebar nav a:hover { background: rgba(255,255,255,0.10); color: #fff; }
.sidebar nav a.active {
    background: rgba(255,255,255,0.16);
    color: var(--accent);
}
.sidebar nav a.active svg { opacity: 1; color: var(--accent); }

/* ---------- Layout ---------- */
.topbar {
    position: sticky;
    top: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 32px 6px;
    margin-left: 230px;
    z-index: 5;
}
.topbar .page-title { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
.topbar .spacer { flex: 1; }

.container {
    margin-left: 230px;
    padding: 18px 32px 60px;
    max-width: 1320px;
}

@media (max-width: 900px) {
    .sidebar { width: 64px; }
    .sidebar .brand span, .sidebar nav a span.label { display: none; }
    .sidebar .brand { justify-content: center; padding: 0 0 20px; }
    .sidebar nav a { justify-content: center; }
    .topbar, .container { margin-left: 64px; }
}

h1 {
    font-size: 1.5rem;
    margin: 4px 0 4px;
    color: var(--ink);
    font-weight: 700;
}
.subtitle { color: var(--muted); margin: 0 0 22px; font-size: 0.92rem; }

.flash {
    padding: 11px 16px;
    border-radius: var(--radius);
    margin-bottom: 18px;
    font-size: 0.9rem;
    font-weight: 500;
}
.flash-success { background: var(--ok-bg); color: #1F7A4C; border: 1px solid #cdeedd; }
.flash-error { background: var(--danger-bg); color: #B23B3B; border: 1px solid #f4cccc; }

.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 860px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Stat cards (style tableau de bord de la maquette) ---------- */
.stat-card {
    background: var(--card);
    border-radius: 14px;
    padding: 20px 22px;
    box-shadow: 0 2px 10px rgba(30,50,70,0.06);
    position: relative;
    overflow: hidden;
}
.stat-card .label { color: var(--muted); font-size: 0.82rem; margin-bottom: 6px; }
.stat-card .num { font-size: 2.1rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--blue); }
.stat-card.alert .num { color: var(--red); }
.stat-card.c-yellow .num { color: var(--yellow); }
.stat-card a { color: inherit; text-decoration: none; }

/* ---------- Panels ---------- */
.panel {
    background: var(--card);
    border-radius: 14px;
    padding: 22px 24px;
    margin-bottom: 22px;
    box-shadow: 0 2px 10px rgba(30,50,70,0.06);
}
.panel h2 {
    font-size: 1.02rem;
    margin: 0 0 16px;
    color: var(--ink);
    font-weight: 700;
}

table { width: 100%; border-collapse: collapse; font-size: 0.89rem; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }
tbody tr:hover { background: #F7F9FB; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    color: #fff;
}
.badge-ok { background: var(--blue); }
.badge-alert { background: var(--red); }

form.stacked label { display: block; margin-bottom: 14px; font-size: 0.9rem; }
form.stacked label span { display: block; margin-bottom: 5px; color: var(--ink); font-weight: 600; font-size: 0.85rem; }
input, select, textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #DDE2E7;
    border-radius: 8px;
    font-size: 0.94rem;
    font-family: inherit;
    background: #FBFCFD;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

.btn {
    display: inline-block;
    background: var(--blue);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: #1C88AC; }
.btn.secondary { background: #EEF2F5; color: var(--ink); }
.btn.secondary:hover { background: #E2E7EC; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #D74A4A; }
.btn.small { padding: 5px 12px; font-size: 0.8rem; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; align-items: flex-end; }
.filters label { font-size: 0.85rem; }
.filters label span { display:block; margin-bottom: 4px; color: var(--muted); }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }

.muted { color: var(--muted); font-size: 0.85rem; }
.actions-cell { display: flex; gap: 6px; }

a { color: var(--blue); }

.pagination { display: flex; gap: 6px; margin-top: 16px; }
.pagination a, .pagination span {
    padding: 5px 11px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--ink); font-size: 0.85rem;
}
.pagination .current { background: var(--blue); color: #fff; border-color: var(--blue); }
