/* Sentinelle — 1/3 : tokens, base, coque (barre latérale + contenu).
   Découpage en 3 feuilles < 16 Ko (limite FTP) : app.css (socle) · ui.css (composants) · pages.css (écrans).
   Thème : suit le système ; html[data-theme] force clair/sombre (bouton de la barre latérale).
   Les couleurs de sévérité arrivent en ligne via --c (Severity::COLOR côté PHP). */
:root {
    --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f9fafb; --surface-3: #f0f2f5;
    --border: #e3e6eb; --border-strong: #cfd4dc;
    --text: #111827; --text-2: #4b5563; --text-3: #6b7280;
    --accent: #2563eb; --accent-hover: #1d4ed8; --accent-text: #1d4ed8; --accent-soft: #eef3ff; --on-accent: #fff;
    --success: #0f8a4a; --warning: #b45309; --danger: #c8302c; --info: #2563eb;
    --sidebar-bg: #ffffff; --sidebar-w: 248px;
    --focus: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18);
    --r-sm: 6px; --r: 8px; --r-lg: 12px;
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0c0e12; --surface: #14171c; --surface-2: #191c22; --surface-3: #20242b;
        --border: #272b33; --border-strong: #363b45;
        --text: #eceef2; --text-2: #b3b9c4; --text-3: #868e9b;
        --accent: #4f86f7; --accent-hover: #6b9bff; --accent-text: #8ab0ff; --accent-soft: #172440; --on-accent: #fff;
        --success: #3fbf7a; --warning: #f0a33a; --danger: #f06b67; --info: #6b9bff;
        --sidebar-bg: #111317;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 3px rgba(0, 0, 0, .5);
        --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .7);
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #0c0e12; --surface: #14171c; --surface-2: #191c22; --surface-3: #20242b;
    --border: #272b33; --border-strong: #363b45;
    --text: #eceef2; --text-2: #b3b9c4; --text-3: #868e9b;
    --accent: #4f86f7; --accent-hover: #6b9bff; --accent-text: #8ab0ff; --accent-soft: #172440; --on-accent: #fff;
    --success: #3fbf7a; --warning: #f0a33a; --danger: #f06b67; --info: #6b9bff;
    --sidebar-bg: #111317;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .7);
    color-scheme: dark;
}

/* ---- base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 14px/1.55 var(--font); font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent-text); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
h1, h2, h3 { color: var(--text); letter-spacing: -.015em; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 650; margin: 0; }
h2 { font-size: 1.05rem; font-weight: 600; margin: var(--s8) 0 var(--s3); }
h3 { font-size: .92rem; font-weight: 600; margin: var(--s5) 0 var(--s2); }
p { margin: 0 0 var(--s3); }
code { font-family: var(--mono); font-size: .86em; background: var(--surface-3); padding: .1em .35em; border-radius: 4px; color: var(--text); }
strong, b { font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s6) 0; }
.muted { color: var(--text-3); }
.small { font-size: .82rem; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

/* ---- coque ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100vh; width: var(--sidebar-w); flex: none;
    display: flex; flex-direction: column; background: var(--sidebar-bg);
    border-right: 1px solid var(--border); z-index: 40;
}
.brand {
    display: flex; align-items: center; gap: var(--s3); padding: var(--s5) var(--s5) var(--s4);
    color: var(--text); text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r);
    background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow);
}
img.brand-mark { display: block; flex: none; border-radius: 23.5%; background: none; }
.brand-name { display: block; font-weight: 700; font-size: 1rem; letter-spacing: -.02em; line-height: 1.2; }
.brand-sub { display: block; font-size: .74rem; color: var(--text-3); line-height: 1.3; }

.nav { flex: 1; overflow-y: auto; padding: var(--s2) var(--s3) var(--s4); }
.nav-group + .nav-group { margin-top: var(--s5); }
.nav-title {
    margin: 0 0 var(--s1); padding: 0 var(--s3); font-size: .68rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
}
.nav a {
    display: flex; align-items: center; gap: var(--s3); padding: 7px var(--s3); margin: 1px 0;
    border-radius: var(--r); color: var(--text-2); font-weight: 500; text-decoration: none;
    transition: background-color .12s ease, color .12s ease;
}
.nav a .icon { color: var(--text-3); transition: color .12s ease; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a:hover .icon { color: var(--text-2); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav a[aria-current="page"] .icon { color: var(--accent-text); }

.sidebar-foot {
    display: flex; gap: var(--s2); align-items: center; padding: var(--s3);
    border-top: 1px solid var(--border);
}
.sidebar-foot form { flex: 1; margin: 0; }
.side-btn {
    display: flex; align-items: center; gap: var(--s2); width: 100%; padding: 7px var(--s3);
    min-height: 0; border: 0; border-radius: var(--r); background: none; box-shadow: none; color: var(--text-2);
    font: inherit; font-weight: 500; cursor: pointer; text-align: left; justify-content: flex-start;
}
.side-btn:hover { background: var(--surface-3); color: var(--text); }
.side-btn.square { width: auto; flex: none; padding: 7px; }
.theme-toggle .when-dark { display: none; }
:root[data-theme="dark"] .theme-toggle .when-dark { display: inline; }
:root[data-theme="dark"] .theme-toggle .when-light { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .when-dark { display: inline; }
    :root:not([data-theme="light"]) .theme-toggle .when-light { display: none; }
}

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { width: 100%; max-width: 1360px; margin: 0 auto; padding: var(--s8) clamp(var(--s4), 3vw, var(--s10)) var(--s10); flex: 1; }
.foot { padding: var(--s5) var(--s6); color: var(--text-3); font-size: .76rem; text-align: center; }

/* barre mobile + panneau coulissant */
.mobile-bar { display: none; }
.backdrop { display: none; }
@media (max-width: 1100px) {
    .mobile-bar {
        display: flex; align-items: center; gap: var(--s3); position: sticky; top: 0; z-index: 30;
        padding: var(--s2) var(--s4); background: color-mix(in srgb, var(--surface) 92%, transparent);
        backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
    }
    .mobile-bar .brand { padding: 0; }
    .mobile-bar .brand-mark { width: 30px; height: 30px; }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; transform: translateX(-100%);
        transition: transform .2s ease; box-shadow: var(--shadow-lg);
    }
    .nav-open .sidebar { transform: none; }
    .nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(10, 12, 16, .45); }
    .content { padding-top: var(--s5); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---- page sans session (connexion) : panneau de marque + formulaire ---- */
.auth { display: grid; grid-template-columns: minmax(0, 1fr); min-height: 100vh; }
.auth-aside { display: none; }
.auth-main { display: grid; place-items: center; padding: var(--s10) var(--s4); }
.auth-box { width: 100%; max-width: 380px; }
.auth-brand-mobile { justify-content: center; padding: 0 0 var(--s8); }
.auth-box .card { padding: var(--s8); box-shadow: var(--shadow-lg); }
.auth-head h1 { font-size: 1.6rem; letter-spacing: -.02em; }
.auth-head p { margin: var(--s2) 0 var(--s6); }
.auth-form label { margin: 0 0 6px; }
.field { position: relative; margin: 0 0 var(--s4); }
.field > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.field input { margin: 0; min-height: 44px; padding-left: 38px; }
.field input:not([type=text]) { padding-right: 46px; }
.field-btn {
    position: absolute; right: 5px; top: 50%; transform: translateY(-50%); width: 34px; min-height: 34px; padding: 0;
    border: 0; background: none; box-shadow: none; color: var(--text-3);
}
.field-btn:hover { background: var(--surface-3); color: var(--text); }
.field-btn:active { transform: translateY(-50%); }
.field-btn .when-shown, .field-btn[aria-pressed="true"] .when-hidden { display: none; }
.field-btn[aria-pressed="true"] .when-shown { display: inline-flex; }
.caps-warn { display: flex; align-items: center; gap: 6px; margin: calc(-1 * var(--s2)) 0 var(--s4); font-size: .8rem; font-weight: 500; color: var(--warning); }
.auth-form button[type=submit] { width: 100%; min-height: 44px; margin-top: var(--s2); }
.auth-note { margin: var(--s8) 0 0; font-size: .78rem; color: var(--text-3); text-align: center; }
.auth-alt { margin: var(--s5) 0 0; text-align: center; font-size: .9rem; }
.auth-alt a { display: inline-flex; align-items: center; gap: 6px; }
.auth-alt .icon { width: 14px; height: 14px; }
@media (min-width: 960px) {
    .auth { grid-template-columns: minmax(400px, 5fr) 6fr; }
    .auth-brand-mobile { display: none; }
    .auth-aside {
        display: flex; flex-direction: column; justify-content: space-between; gap: var(--s10);
        padding: var(--s10) clamp(var(--s10), 4vw, 64px); color: #c9d3e8;
        background-color: #0b1430;
        background-image: radial-gradient(60% 50% at 0% 0%, rgba(79, 134, 247, .28), transparent 70%),
            linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
        background-size: auto, 32px 32px, 32px 32px;
    }
    .auth-aside .brand { padding: 0; color: #fff; }
    .auth-aside .brand-sub { color: #93a3c4; }
    .auth-pitch h2 { margin: 0 0 var(--s8); max-width: 20ch; font-size: clamp(1.6rem, 2.4vw, 2.1rem); line-height: 1.2; color: #fff; letter-spacing: -.025em; }
    .auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s5); max-width: 42ch; }
    .auth-points li { display: flex; gap: var(--s4); align-items: flex-start; font-size: .9rem; line-height: 1.5; }
    .auth-points strong { display: block; color: #fff; font-weight: 600; margin-bottom: 2px; }
    .auth-ico {
        display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: var(--r);
        background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); color: #8ab0ff;
    }
    .auth-aside-foot { margin: 0; font-size: .78rem; color: #6f7fa3; }
}

/* ---- en-tête de page ---- */
.page-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4);
    flex-wrap: wrap; margin-bottom: var(--s5);
}
.page-head h1 .muted { font-weight: 500; }
.page-head p { margin: var(--s1) 0 0; }
.page-head > a.muted { display: inline-flex; align-items: center; gap: var(--s1); font-weight: 500; }
.head-actions, .page-head .form-actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin: 0 !important; }
.page-head + p.muted, .page-head + p.muted + p.muted, .lead {
    max-width: 82ch; color: var(--text-2); font-size: .9rem; margin-bottom: var(--s5);
}
.page-head + p.muted + p.muted.small { font-size: .8rem; color: var(--text-3); }
.back {
    display: inline-flex; align-items: center; gap: var(--s1); color: var(--text-3);
    font-size: .82rem; font-weight: 500; margin-bottom: var(--s2);
}
.back:hover { color: var(--text); text-decoration: none; }
.section-head { display: flex; align-items: center; gap: var(--s2); margin: var(--s8) 0 var(--s3); }
.section-head h2, h2.section-head { margin: 0; }
h2.section-head { margin: var(--s8) 0 var(--s3); }
