:root {
    --surface-1:      #fcfcfb;
    --surface-2:      #ffffff;
    --page-plane:     #f4f4f1;
    --text-primary:   #0b0b0b;
    --text-secondary: #52514e;
    --text-muted:     #898781;
    --gridline:       #e1e0d9;
    --baseline:       #c3c2b7;
    --border:         rgba(11,11,11,0.08);
    --shadow:         0 1px 2px rgba(11,11,11,0.04), 0 4px 16px rgba(11,11,11,0.05);
    --shadow-hover:    0 2px 4px rgba(11,11,11,0.06), 0 10px 28px rgba(11,11,11,0.09);

    --series-1: #2a78d6; /* blue */
    --series-2: #1baf7a; /* aqua */
    --series-3: #eda100; /* yellow */
    --series-4: #008300; /* green */
    --series-5: #4a3aa7; /* violet */
    --series-6: #e34948; /* red */
    --series-7: #e87ba4; /* magenta */
    --series-8: #eb6834; /* orange */

    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-serious: #ec835a;
    --status-critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
    :root {
        /* Teinte navy (inspirée hexagone-scp.fr) plutôt qu'un gris neutre pur */
        --surface-1:      #161a23;
        --surface-2:      #1c212c;
        --page-plane:     #0c0e14;
        --text-primary:   #ffffff;
        --text-secondary: #b7bdc9;
        --text-muted:     #7d8494;
        --gridline:       #262c3a;
        --baseline:       #3a4152;
        --border:         rgba(255,255,255,0.08);
        --shadow:         0 1px 2px rgba(0,0,0,0.2), 0 4px 20px rgba(0,0,0,0.28);
        --shadow-hover:    0 2px 4px rgba(0,0,0,0.24), 0 12px 32px rgba(0,0,0,0.36);

        --series-1: #3987e5;
        --series-2: #199e70;
        --series-3: #c98500;
        --series-4: #008300;
        --series-5: #9085e9;
        --series-6: #e66767;
        --series-7: #d55181;
        --series-8: #d95926;

        --status-good: #0ca30c;
        --status-warning: #fab219;
        --status-serious: #ec835a;
        --status-critical: #d03b3b;
    }
}

* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--page-plane);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

nav {
    display: flex;
    gap: 2px;
    padding: 0 24px;
    height: 56px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--border);
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: saturate(1.4) blur(6px);
}
nav .brand {
    font-weight: 800;
    margin-right: 28px;
    font-size: 15px;
    letter-spacing: -0.01em;
    background: linear-gradient(135deg, var(--series-1), var(--series-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 7px;
    font-size: 13.5px;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}
nav a:hover { background: var(--page-plane); color: var(--text-primary); }
nav a.active { background: var(--page-plane); color: var(--text-primary); font-weight: 600; }

main { padding: 28px 24px 60px; max-width: 1240px; margin: 0 auto; }

h1 { font-size: 23px; margin: 0 0 22px; letter-spacing: -0.01em; }
h2 { font-size: 14px; margin: 0 0 14px; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
h2.plain { text-transform: none; letter-spacing: normal; font-size: 16px; }

.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover { box-shadow: var(--shadow-hover); }
.grid { display: grid; gap: 16px; }
.grid-cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

section + section, .section { margin-top: 28px; }

.stat-tile { text-align: left; position: relative; padding-left: 20px; overflow: hidden; }
.stat-tile::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--accent, var(--series-1)); border-radius: 4px 0 0 4px;
}
.stat-tile .value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; line-height: 1.15; }
.stat-tile .label { font-size: 12.5px; color: var(--text-secondary); margin-top: 5px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 10px; border-bottom: 1px solid var(--gridline); }
td { padding: 10px; border-bottom: 1px solid var(--gridline); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; transition: background-color 0.1s ease; }
tr.clickable:hover { background: var(--page-plane); }

.name { font-size: 16px; font-weight: 600; display: inline-flex; align-items: center; }
.name:hover { color: var(--series-1); }

.avatar { width: 30px; height: 30px; border-radius: 50%; vertical-align: middle; margin-right: 9px; box-shadow: 0 0 0 2px var(--surface-1); }
.avatar-lg { width: 76px; height: 76px; border-radius: 50%; box-shadow: 0 0 0 3px var(--surface-1), var(--shadow); }
.avatar-fallback {
    width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
    vertical-align: middle; margin-right: 9px; font-size: 12px; font-weight: 700; color: #fff;
    background: var(--text-muted); box-shadow: 0 0 0 2px var(--surface-1);
}

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 100px; font-size: 11.5px; font-weight: 600;
    letter-spacing: 0.01em;
}
.badge-good { background: color-mix(in srgb, var(--status-good) 15%, transparent); color: var(--status-good); }
.badge-warning { background: color-mix(in srgb, var(--status-warning) 22%, transparent); color: #93650a; }
.badge-critical { background: color-mix(in srgb, var(--status-critical) 15%, transparent); color: var(--status-critical); }
.badge-neutral { background: var(--page-plane); color: var(--text-secondary); }

.badge-cat-cheat { background: color-mix(in srgb, var(--series-6) 18%, transparent); color: var(--series-6); }
.badge-cat-multicompte { background: color-mix(in srgb, var(--series-5) 18%, transparent); color: var(--series-5); }
.badge-cat-comportement { background: color-mix(in srgb, var(--series-3) 25%, transparent); color: #8a6400; }
.badge-cat-autre { background: color-mix(in srgb, var(--series-1) 18%, transparent); color: var(--series-1); }

a.link { color: var(--series-1); text-decoration: none; font-weight: 500; }
a.link:hover { text-decoration: underline; }

.muted { color: var(--text-muted); font-size: 13px; }

.log-box {
    background: var(--page-plane);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    max-height: 320px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-secondary);
}

.back-link { display: inline-block; margin-bottom: 18px; }

/* Contrôles (select, input) */
.control {
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.15s ease;
}
.control:focus { outline: none; border-color: var(--series-1); }
.controls-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.controls-row .muted { margin-right: 2px; }

/* Chips (sélection multi-staff) */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px 5px 8px; border-radius: 100px; font-size: 12.5px; font-weight: 500;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text-secondary);
    cursor: pointer; user-select: none; transition: all 0.15s ease;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.chip.selected { color: #fff; border-color: transparent; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--baseline); border-radius: 10px; }
::-webkit-scrollbar-track { background: transparent; }

.spinner {
    width: 13px; height: 13px; border-radius: 50%; display: inline-block;
    border: 2px solid var(--gridline); border-top-color: var(--series-1);
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card.is-loading { opacity: 0.45; pointer-events: none; }

/* Inspiré hexagone-scp.fr : petit label "eyebrow" avec tiret, et bouton inversé */
.eyebrow {
    display: flex; align-items: center; gap: 8px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--series-1); margin-bottom: 8px;
}
.eyebrow::before { content: ''; width: 18px; height: 2px; background: var(--series-1); border-radius: 2px; }

.btn-inverse {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: 100px; border: none;
    background: var(--text-primary); color: var(--page-plane);
    font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer;
    transition: transform 0.1s ease, opacity 0.1s ease;
}
.btn-inverse:hover { opacity: 0.85; }

.toggle {
    position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track {
    position: absolute; inset: 0; background: var(--baseline); border-radius: 100px;
    transition: background-color 0.15s ease; cursor: pointer;
}
.toggle .track::before {
    content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform 0.15s ease;
}
.toggle input:checked + .track { background: var(--series-1); }
.toggle input:checked + .track::before { transform: translateX(18px); }

.status-page { max-width: 480px; margin: 14vh auto; text-align: center; padding: 0 16px; }
.status-emoji { font-size: 64px; display: inline-block; animation: statusBounce 1.8s ease-in-out infinite; }
@keyframes statusBounce { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-12px) rotate(-6deg); } }
