/*
 * Feuille de style unique et autonome : aucune police ni ressource externe,
 * pour que l'interface fonctionne hors ligne et ne divulgue rien a personne.
 */

:root {
    --bg: #f7f7f6;
    --surface: #ffffff;
    --surface-2: #fafaf9;
    --border: #e4e4e2;
    --border-strong: #d2d2ce;
    --text: #1c1a17;
    --text-2: #57534e;
    --text-3: #8a857e;
    --accent: #3352cc;
    --accent-soft: #eaeeff;
    --critical: #b8253a;
    --critical-soft: #fdeced;
    --warning: #8a5a00;
    --warning-soft: #fdf3e0;
    --ok: #17693f;
    --ok-soft: #e8f5ed;
    --radius: 10px;
    --shadow: 0 1px 2px rgb(28 26 23 / 6%), 0 1px 3px rgb(28 26 23 / 4%);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16151a;
        --surface: #1e1d23;
        --surface-2: #24232a;
        --border: #302f38;
        --border-strong: #403f4a;
        --text: #eceaf0;
        --text-2: #a8a4b3;
        --text-3: #77738233;
        --text-3: #7a7686;
        --accent: #93a8ff;
        --accent-soft: #23253c;
        --critical: #ff9099;
        --critical-soft: #38222a;
        --warning: #f0c07a;
        --warning-soft: #33291c;
        --ok: #7fd8a4;
        --ok-soft: #1c2d24;
        --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    }
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: .875em;
}

/* --- Ossature ---------------------------------------------------------- */

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

/*
 * La barre laterale s'etire sur toute la hauteur de la page (comportement
 * par defaut d'un enfant flex), et c'est son contenu qui reste colle en haut
 * au defilement. Avec une hauteur de 100vh sur la barre elle-meme, son fond
 * s'arreterait net au premier ecran sur les pages longues.
 */
.sidebar {
    width: 232px;
    flex: 0 0 232px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 14px;
}

.sidebar-inner { position: sticky; top: 20px; }

.brand { display: block; padding: 0 10px 18px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.brand span { font-size: 12px; color: var(--text-3); }

.nav { display: flex; flex-direction: column; gap: 1px; }

.nav a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 7px;
    color: var(--text-2);
    font-size: 14px;
}

.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .count { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav a.active .count { color: var(--accent); }

.nav-group {
    margin: 18px 0 6px;
    padding: 0 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-3);
}

.main { flex: 1; min-width: 0; padding: 28px 32px 64px; max-width: 1280px; }

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

h1 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 16px; letter-spacing: -.01em; margin: 0 0 14px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.subtitle { color: var(--text-2); font-size: 14px; margin: 0; }

/* --- Selecteur de scan -------------------------------------------------- */

.scan-picker { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }

.scan-picker select {
    font: inherit;
    /* Sans min-width: 0, le contenu du select impose sa largeur et pousse le
       bouton hors de la barre laterale. */
    flex: 1 1 130px;
    min-width: 0;
    padding: 6px 10px;
    border-radius: 7px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
}

.scan-picker button {
    font: inherit;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 7px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

.scan-picker button:hover { background: var(--surface-2); }

/* --- Cartes ------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
    margin-bottom: 20px;
}

.card > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }

/*
 * Un enfant de grille ou de flexbox garde min-width: auto et se laisse
 * elargir par son contenu : un tableau large deborderait alors sa colonne, et
 * la page entiere defilerait lateralement au lieu du seul tableau.
 */
.grid > *, .table-wrap, .actions, .actions li { min-width: 0; }

.kpi { display: block; color: inherit; }
.kpi:hover { text-decoration: none; border-color: var(--border-strong); }
.kpi .value { font-size: 30px; font-weight: 650; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .label { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.kpi .hint { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.kpi.is-critical .value { color: var(--critical); }
.kpi.is-warning .value { color: var(--warning); }
.kpi.is-ok .value { color: var(--ok); }

/* --- Tableaux ----------------------------------------------------------- */

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }

th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 0 12px 8px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
td.muted, .muted { color: var(--text-3); }

/* --- Pastilles ---------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.critical { background: var(--critical-soft); color: var(--critical); }
.badge.neutral { background: var(--surface-2); color: var(--text-2); border-color: var(--border); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.app-tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    white-space: nowrap;
}

.app-mark {
    display: inline-grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 5px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    color: var(--text-2);
    flex: 0 0 20px;
}

/* --- Constats ----------------------------------------------------------- */

.finding {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.finding:last-child { border-bottom: 0; padding-bottom: 0; }
.finding:first-child { padding-top: 0; }
.finding .stripe { width: 3px; border-radius: 2px; flex: 0 0 3px; background: var(--border-strong); }
.finding.critical .stripe { background: var(--critical); }
.finding.warning .stripe { background: var(--warning); }
.finding.info .stripe { background: var(--accent); }
.finding .body { min-width: 0; flex: 1; }
.finding .title { font-weight: 600; margin-bottom: 3px; }
.finding .detail { color: var(--text-2); font-size: 14px; }
.finding .meta { display: flex; gap: 8px; align-items: center; margin-bottom: 5px; flex-wrap: wrap; }

.actions { margin: 10px 0 0; padding: 0; list-style: none; }

.actions li {
    position: relative;
    padding-left: 18px;
    margin-top: 5px;
    font-size: 14px;
    color: var(--text-2);
}

.actions li::before { content: "→"; position: absolute; left: 0; color: var(--text-3); }

/* --- Blocs de commande -------------------------------------------------- */

.command {
    display: block;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 9px 12px;
    margin: 8px 0;
    overflow-x: auto;
    white-space: pre;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    color: var(--text);
}

/* --- Encarts ------------------------------------------------------------ */

.notice {
    border-left: 3px solid var(--accent);
    background: var(--accent-soft);
    padding: 12px 16px;
    border-radius: 0 7px 7px 0;
    font-size: 14px;
    margin-bottom: 20px;
}

.notice.warning { border-color: var(--warning); background: var(--warning-soft); }
.notice.critical { border-color: var(--critical); background: var(--critical-soft); }
.notice strong { display: block; margin-bottom: 2px; }

/* --- Listes de paires --------------------------------------------------- */

.pairs { display: grid; grid-template-columns: max-content 1fr; gap: 7px 20px; font-size: 14px; margin: 0; }
.pairs dt { color: var(--text-3); }
.pairs dd { margin: 0; }

/* --- Filtres ------------------------------------------------------------ */

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }

.filters a {
    padding: 4px 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 13px;
    color: var(--text-2);
}

.filters a:hover { background: var(--surface-2); text-decoration: none; }
.filters a.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }

@media (prefers-color-scheme: dark) {
    .filters a.active { color: #16151a; }
}

/* --- Barre de proportion ------------------------------------------------ */

.bar { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; min-width: 48px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.is-orphan > span { background: var(--warning); }

/*
 * Largeurs en classes plutot qu'en style="width:…". La politique de securite
 * de la page interdit le style en ligne : c'est ce qui garantit qu'un nom de
 * base ou de domaine mal intentionne ne puisse rien injecter dans la page.
 */
.w0   { width: 0; }
.w5   { width: 5%; }
.w10  { width: 10%; }
.w15  { width: 15%; }
.w20  { width: 20%; }
.w25  { width: 25%; }
.w30  { width: 30%; }
.w35  { width: 35%; }
.w40  { width: 40%; }
.w45  { width: 45%; }
.w50  { width: 50%; }
.w55  { width: 55%; }
.w60  { width: 60%; }
.w65  { width: 65%; }
.w70  { width: 70%; }
.w75  { width: 75%; }
.w80  { width: 80%; }
.w85  { width: 85%; }
.w90  { width: 90%; }
.w95  { width: 95%; }
.w100 { width: 100%; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty-state h2 { color: var(--text); }

/* --- Pages de garde (connexion, protection requise) --------------------- */

.gate {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
}

.gate-card {
    width: 100%;
    max-width: 27rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 30px;
}

.gate-card--wide { max-width: 42rem; }
.gate-card h1 { font-size: 20px; margin-bottom: 4px; }
.gate-card .subtitle { margin-bottom: 20px; }
.gate-card p { margin: 14px 0; }
.gate-card > :last-child { margin-bottom: 0; }

.gate-form { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.gate-form label { font-size: 13px; color: var(--text-2); }

.gate-form input {
    font: inherit;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
}

.gate-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.gate-form button {
    font: inherit;
    font-weight: 600;
    margin-top: 6px;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

.gate-form button:hover { filter: brightness(1.08); }

@media (prefers-color-scheme: dark) {
    .gate-form button { color: #16151a; }
}

/* --- Petits ecrans ------------------------------------------------------ */

@media (max-width: 860px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--border); }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav-group { width: 100%; margin: 12px 0 2px; }
    .main { padding: 20px 16px 48px; }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
}
