/*
 * Triumvirat — feuille de style commune (maquettes + application).
 *
 * Reprend la grammaire visuelle de Janus (core/res/style) : graines --lodge-*,
 * jetons sémantiques dérivés par color-mix(), menu latéral clair à liens bordés
 * à gauche, cartes blanches à ombre douce, boutons arrondis à 10px, police système.
 *
 * Disposition : menu latéral fixe (280px) + contenu à largeur de lecture (80rem),
 * qui se replie en une colonne sous 768px.
 */

:root {
    /* Graines (mêmes valeurs par défaut que Janus) */
    --lodge-light: #f5f7fa;
    --lodge-dark: #1f475b;
    --lodge-very-dark: #102a36;

    /* Typographie (pile système de Janus) */
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-family-mono: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --font-small: 0.875rem;
    --font-medium: 1rem;
    --font-large: 1.25rem;

    --sidebar-width: 280px;
    --content-readable-max-width: 80rem;
    --radius: 8px;
    --radius-button: 10px;

    /* Jetons sémantiques (clair) */
    --color-border: color-mix(in srgb, var(--lodge-dark) 15%, transparent);
    --color-border-focus: var(--lodge-dark);
    --color-surface: color-mix(in srgb, var(--lodge-light) 60%, #ffffff);
    --color-surface-raised: #ffffff;
    --color-surface-sunken: color-mix(in srgb, var(--lodge-light) 85%, var(--lodge-dark) 4%);
    --color-brand-surface: color-mix(in srgb, var(--lodge-light) 80%, #ffffff);
    --color-brand-text: var(--lodge-very-dark);
    --color-text: var(--lodge-dark);
    --color-text-strong: var(--lodge-very-dark);
    --color-text-muted: color-mix(in srgb, var(--lodge-dark) 60%, transparent);
    --color-accent: var(--lodge-dark);
    --color-on-accent: #ffffff;
    --color-accent-soft: color-mix(in srgb, var(--lodge-dark) 12%, transparent);
    --color-shadow: rgb(0 0 0 / 6%);
    --color-overlay: rgb(0 0 0 / 45%);

    --color-success-bg: #d1fae5;
    --color-success-text: #065f46;
    --color-error-bg: #fee2e2;
    --color-error-text: #991b1b;
    --color-warning-bg: #fef3c7;
    --color-warning-text: #92400e;
    --color-info-bg: #dbeafe;
    --color-info-text: #1e40af;

    --sidebar-bg: var(--color-brand-surface);
    --sidebar-text: var(--color-brand-text);
    --sidebar-hover: rgb(0 0 0 / 5%);
    --sidebar-active: var(--color-accent);
    --sidebar-active-text: var(--color-on-accent);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-surface: color-mix(in srgb, var(--lodge-very-dark) 55%, #000000);
        --color-surface-raised: color-mix(in srgb, var(--lodge-very-dark) 80%, #2a3038);
        --color-surface-sunken: color-mix(in srgb, var(--lodge-very-dark) 90%, #000000);
        --color-brand-surface: color-mix(in srgb, var(--lodge-very-dark) 70%, #1e1e27);
        --color-brand-text: #ffffff;
        --color-text: #e8eaed;
        --color-text-strong: #f4f6f8;
        --color-text-muted: color-mix(in srgb, #ffffff 68%, transparent);
        --color-border: color-mix(in srgb, #ffffff 14%, transparent);
        --color-border-focus: color-mix(in srgb, var(--lodge-dark) 60%, #ffffff);
        --color-accent: color-mix(in srgb, var(--lodge-dark) 55%, #ffffff);
        --color-on-accent: #0b1d26;
        --color-accent-soft: color-mix(in srgb, var(--lodge-dark) 45%, transparent);
        --color-shadow: rgb(0 0 0 / 35%);
        --color-overlay: rgb(0 0 0 / 60%);
        --color-success-bg: #14352a;
        --color-success-text: #6ee7b7;
        --color-error-bg: #3a1d1d;
        --color-error-text: #fca5a5;
        --color-warning-bg: #3a2f12;
        --color-warning-text: #fcd34d;
        --color-info-bg: #16263f;
        --color-info-text: #93c5fd;
        --sidebar-bg: color-mix(in srgb, var(--lodge-very-dark) 70%, #1e1e27);
        --sidebar-text: #d8dce2;
        --sidebar-hover: color-mix(in srgb, #ffffff 6%, transparent);
        --sidebar-active: color-mix(in srgb, var(--lodge-very-dark) 55%, #3a3a48);
        --sidebar-active-text: #e8eaed;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --color-surface: color-mix(in srgb, var(--lodge-very-dark) 55%, #000000);
    --color-surface-raised: color-mix(in srgb, var(--lodge-very-dark) 80%, #2a3038);
    --color-surface-sunken: color-mix(in srgb, var(--lodge-very-dark) 90%, #000000);
    --color-brand-surface: color-mix(in srgb, var(--lodge-very-dark) 70%, #1e1e27);
    --color-brand-text: #ffffff;
    --color-text: #e8eaed;
    --color-text-strong: #f4f6f8;
    --color-text-muted: color-mix(in srgb, #ffffff 68%, transparent);
    --color-border: color-mix(in srgb, #ffffff 14%, transparent);
    --color-border-focus: color-mix(in srgb, var(--lodge-dark) 60%, #ffffff);
    --color-accent: color-mix(in srgb, var(--lodge-dark) 55%, #ffffff);
    --color-on-accent: #0b1d26;
    --color-accent-soft: color-mix(in srgb, var(--lodge-dark) 45%, transparent);
    --color-shadow: rgb(0 0 0 / 35%);
    --color-overlay: rgb(0 0 0 / 60%);
    --color-success-bg: #14352a;
    --color-success-text: #6ee7b7;
    --color-error-bg: #3a1d1d;
    --color-error-text: #fca5a5;
    --color-warning-bg: #3a2f12;
    --color-warning-text: #fcd34d;
    --color-info-bg: #16263f;
    --color-info-text: #93c5fd;
    --sidebar-bg: color-mix(in srgb, var(--lodge-very-dark) 70%, #1e1e27);
    --sidebar-text: #d8dce2;
    --sidebar-hover: color-mix(in srgb, #ffffff 6%, transparent);
    --sidebar-active: color-mix(in srgb, var(--lodge-very-dark) 55%, #3a3a48);
    --sidebar-active-text: #e8eaed;
    color-scheme: dark;
}

/* ---------- Base ---------- */

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

html, body { margin: 0; }

body {
    font-family: var(--font-family);
    font-size: var(--font-medium);
    line-height: 1.5;
    background: var(--color-surface);
    color: var(--color-text);
    overflow-x: hidden;
}

h1, h2, h3, h4 { color: var(--color-text-strong); text-wrap: balance; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; line-height: 1.25; }
h2 { font-size: 1.15rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--color-text-strong); }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-family-mono); font-size: 0.85em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--color-text-muted); }
.small { font-size: var(--font-small); }

:focus-visible { outline: 2px solid var(--color-border-focus); outline-offset: 2px; }

::selection { background: var(--color-accent); color: var(--color-on-accent); }

.icon { width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.125em; }

/* ---------- Menu latéral (copie de components/sidebar.css de Janus) ---------- */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--color-border);
    box-shadow: 0 2px 10px var(--color-shadow);
    overflow: hidden auto;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    background: linear-gradient(135deg, var(--color-surface) 0%, var(--sidebar-bg) 100%);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--sidebar-text);
    text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand small { display: block; font-size: 0.7rem; font-weight: 500; opacity: 0.6; letter-spacing: 0.04em; }

.brand-mark { width: 30px; height: 30px; color: var(--color-accent); }

.sidebar-nav { padding: 6px 0; flex: 1; }

.sidebar-section-title {
    padding: 10px 14px 5px;
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--sidebar-text);
    opacity: 0.45;
    border-top: 1px solid var(--color-border);
    margin-top: 4px;
}
.sidebar-section:first-child .sidebar-section-title { border-top: none; }

.sidebar-menu { list-style: none; margin: 0; padding: 0; }

.sidebar-menu-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    border-left: 3px solid transparent;
}
.sidebar-menu-link:hover { background: var(--sidebar-hover); border-left-color: var(--sidebar-text); text-decoration: none; }
.sidebar-menu-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-active-text);
    border-left-color: var(--sidebar-active-text);
    font-weight: 600;
}
.sidebar-menu-link .icon { width: 18px; height: 18px; }
.sidebar-menu-link .menu-text { flex: 1; }
.menu-badge {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 999px;
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.sidebar-footer {
    border-top: 1px solid var(--color-border);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    color: var(--sidebar-text);
}
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: grid; place-items: center;
    background: var(--color-accent);
    color: var(--color-on-accent);
    font-weight: 700;
    font-size: 0.8rem;
}
.sidebar-footer .who { flex: 1; min-width: 0; line-height: 1.25; }
.sidebar-footer .who small { display: block; opacity: 0.65; }

/* ---------- Contenu ---------- */

.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px 28px 40px;
    min-height: 100vh;
}
.main-inner {
    max-width: var(--content-readable-max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.mock-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 14px;
    border-radius: var(--radius);
    background: var(--color-info-bg);
    color: var(--color-info-text);
    font-size: var(--font-small);
}
.mock-banner select { margin-left: auto; }

/* Fil d'Ariane (components/breadcrumb.css) */
.breadcrumb-header { border-bottom: 1px solid var(--color-border); padding-bottom: 8px; }
.breadcrumb-list {
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0;
    list-style: none; margin: 0; padding: 0;
    font-size: var(--font-small); color: var(--color-text-muted);
}
.breadcrumb-sep { margin: 0 6px; font-size: 0.7rem; }
.breadcrumb-link { color: var(--color-text-strong); text-decoration: none; }
.breadcrumb-current { color: var(--color-text-muted); }

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 20px;
}
.page-header .subtitle { color: var(--color-text-muted); font-size: var(--font-small); margin-top: 4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Boutons (components/buttons.css) ---------- */

.button, .button-outline, .button-danger, .button-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-button);
    padding: 9px 16px;
    font: inherit;
    font-size: var(--font-small);
    font-weight: 600;
    line-height: 1.1;
    cursor: pointer;
    text-decoration: none;
    border: 2px solid transparent;
    transition: filter 0.2s, background-color 0.2s;
    white-space: nowrap;
}
.button { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
.button:hover { filter: brightness(1.1); text-decoration: none; }
.button-outline { background: transparent; border-color: var(--color-border-focus); color: var(--color-text-strong); }
.button-outline:hover { background: var(--color-surface-sunken); text-decoration: none; }
.button-danger { background: var(--color-error-text); border-color: var(--color-error-text); color: var(--color-surface-raised); }
.button-danger:hover { filter: brightness(0.9); text-decoration: none; }
.button-danger[disabled], .button[disabled] { opacity: 0.4; cursor: not-allowed; filter: none; }
.button-ghost { background: transparent; color: var(--color-text-strong); padding: 6px 10px; }
.button-ghost:hover { background: var(--color-surface-sunken); text-decoration: none; }
.button-sm { padding: 6px 11px; font-size: 0.8rem; }

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

.card {
    background: var(--color-surface-raised);
    border-radius: var(--radius);
    box-shadow: 0 2px 10px var(--color-shadow);
    padding: 18px 20px 20px;
    min-width: 0;
}
.card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.card-head .hint { font-size: 0.8rem; color: var(--color-text-muted); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 16px 20px 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* Bandeau d'indicateurs (reporting_dashboard.php de Janus) */
.kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi-card {
    background: var(--color-surface-raised);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: 0 2px 10px var(--color-shadow);
    border-left: 4px solid var(--color-border);
}
.kpi-card.kpi-ok { border-left-color: var(--color-success-text); }
.kpi-card.kpi-warn { border-left-color: var(--color-warning-text); }
.kpi-card.kpi-crit { border-left-color: var(--color-error-text); }
.kpi-card.kpi-info { border-left-color: var(--color-info-text); }
.kpi-card.kpi-accent { border-left-color: var(--color-accent); }
.kpi-label { font-size: 0.8rem; color: var(--color-text-muted); }
.kpi-value { font-size: 1.9rem; font-weight: 700; color: var(--color-text-strong); font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-sub { font-size: 0.78rem; color: var(--color-text-muted); }

/* ---------- Pastilles d'état (icône + libellé, jamais la couleur seule) ---------- */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    background: var(--color-surface-sunken);
    color: var(--color-text);
}
.pill .icon { width: 0.9em; height: 0.9em; }
.pill-ok { background: var(--color-success-bg); color: var(--color-success-text); }
.pill-warn { background: var(--color-warning-bg); color: var(--color-warning-text); }
.pill-crit { background: var(--color-error-bg); color: var(--color-error-text); }
.pill-info { background: var(--color-info-bg); color: var(--color-info-text); }
.pill-neutral { background: var(--color-surface-sunken); color: var(--color-text-muted); }

.tag {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

/* ---------- Tableaux (components/tables.css) ---------- */

.table-wrap { overflow-x: auto; position: relative; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-small);
}
table.data th {
    text-align: left;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    font-weight: 700;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
table.data td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
table.data tbody tr:hover { background: var(--color-surface-sunken); }
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 600; color: var(--color-text-strong); }
.cell-sub { display: block; font-size: 0.75rem; color: var(--color-text-muted); }

/* Jauge horizontale */
.meter { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.meter-track { flex: 1; height: 6px; border-radius: 3px; background: var(--color-surface-sunken); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 3px; background: var(--color-accent); }
.meter-fill.warn { background: var(--color-warning-text); }
.meter-fill.crit { background: var(--color-error-text); }
.meter-label { font-size: 0.78rem; font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }

/* ---------- Barre de filtres ---------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.filters .search { flex: 1 1 220px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"], select, textarea {
    font: inherit;
    font-size: var(--font-small);
    color: var(--color-text);
    background: var(--color-surface-raised);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 8px 11px;
    width: 100%;
}
select { width: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-border-focus); box-shadow: 0 0 0 3px var(--color-accent-soft); }

.segmented { display: inline-flex; border: 1px solid var(--color-border); border-radius: 8px; overflow: hidden; }
.segmented button {
    font: inherit; font-size: 0.8rem; font-weight: 600;
    background: var(--color-surface-raised); color: var(--color-text);
    border: 0; padding: 6px 12px; cursor: pointer;
}
.segmented button + button { border-left: 1px solid var(--color-border); }
.segmented button.active { background: var(--color-accent); color: var(--color-on-accent); }

/* ---------- Formulaires ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 0.8rem; font-weight: 600; color: var(--color-text-strong); }
.field .help { font-size: 0.75rem; color: var(--color-text-muted); }
.input-affix { display: flex; align-items: stretch; }
.input-affix input { border-radius: 8px 0 0 8px; }
.input-affix span {
    display: flex; align-items: center; padding: 0 10px;
    border: 1px solid var(--color-border); border-left: 0; border-radius: 0 8px 8px 0;
    background: var(--color-surface-sunken); font-size: var(--font-small); color: var(--color-text-muted);
}

.form-section { display: flex; flex-direction: column; gap: 14px; }
.form-section + .form-section { border-top: 1px solid var(--color-border); padding-top: 18px; margin-top: 18px; }

/* Interrupteur */
.switch-row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--color-border);
}
.switch-row:last-child { border-bottom: 0; }
.switch-row .label { font-weight: 600; font-size: var(--font-small); color: var(--color-text-strong); }
.switch-row .desc { display: block; font-weight: 400; font-size: 0.75rem; color: var(--color-text-muted); }
.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch .track {
    position: absolute; inset: 0; border-radius: 999px;
    background: var(--color-surface-sunken); border: 1px solid var(--color-border);
    transition: background 0.2s;
}
.switch .track::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
    background: var(--color-surface-raised); box-shadow: 0 1px 3px var(--color-shadow); transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--color-accent); border-color: var(--color-accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--color-border-focus); outline-offset: 2px; }

/* ---------- Onglets (components/tabs.css) ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-border); overflow-x: auto; }
.tab {
    font: inherit; font-size: var(--font-small); font-weight: 600;
    background: none; border: 0; border-bottom: 3px solid transparent;
    padding: 9px 14px; color: var(--color-text-muted); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--color-text-strong); }
.tab.active { color: var(--color-text-strong); border-bottom-color: var(--color-accent); }

/* ---------- Encadrés ---------- */

.callout {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 16px; border-radius: var(--radius);
    font-size: var(--font-small);
}
.callout .icon { width: 18px; height: 18px; margin-top: 1px; }
.callout strong { display: block; margin-bottom: 2px; }
.callout-warn { background: var(--color-warning-bg); color: var(--color-warning-text); }
.callout-crit { background: var(--color-error-bg); color: var(--color-error-text); }
.callout-info { background: var(--color-info-bg); color: var(--color-info-text); }
.callout-ok { background: var(--color-success-bg); color: var(--color-success-text); }

/* ---------- Listes clé / valeur ---------- */

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; font-size: var(--font-small); margin: 0; }
.kv dt { color: var(--color-text-muted); }
.kv dd { margin: 0; color: var(--color-text-strong); font-weight: 500; overflow-wrap: anywhere; }

/* ---------- Assistant (étapes) ---------- */

.stepper { display: flex; gap: 0; list-style: none; margin: 0; padding: 0; counter-reset: step; flex-wrap: wrap; }
.stepper li {
    flex: 1 1 140px;
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    font-size: var(--font-small);
    color: var(--color-text-muted);
    border-bottom: 3px solid var(--color-border);
}
.stepper li .dot {
    width: 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center;
    font-size: 0.78rem; font-weight: 700;
    background: var(--color-surface-sunken); color: var(--color-text-muted);
}
.stepper li.done { color: var(--color-text); border-bottom-color: var(--color-accent); }
.stepper li.done .dot { background: var(--color-accent-soft); color: var(--color-text-strong); }
.stepper li.current { color: var(--color-text-strong); font-weight: 600; border-bottom-color: var(--color-accent); }
.stepper li.current .dot { background: var(--color-accent); color: var(--color-on-accent); }

/* ---------- Journal de tâche ---------- */

.log {
    font-family: var(--font-family-mono);
    font-size: 0.78rem;
    line-height: 1.6;
    background: var(--color-surface-sunken);
    border-radius: var(--radius);
    padding: 12px 14px;
    overflow-x: auto;
    white-space: pre;
    color: var(--color-text);
    margin: 0;
}
.log .ok { color: var(--color-success-text); }
.log .warn { color: var(--color-warning-text); }
.log .dim { color: var(--color-text-muted); }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li {
    display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: start;
    padding: 9px 0; border-bottom: 1px solid var(--color-border); font-size: var(--font-small);
}
.timeline li:last-child { border-bottom: 0; }
.timeline .when { font-size: 0.75rem; color: var(--color-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.timeline .icon { width: 16px; height: 16px; margin-top: 2px; }
.ic-ok { color: var(--color-success-text); }
.ic-warn { color: var(--color-warning-text); }
.ic-crit { color: var(--color-error-text); }
.ic-info { color: var(--color-info-text); }
.ic-muted { color: var(--color-text-muted); }

/* ---------- Graphiques ---------- */

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--color-border); stroke-width: 1; }
.chart .axis-label { fill: var(--color-text-muted); font-size: 11px; font-family: var(--font-family); font-variant-numeric: tabular-nums; }
.chart .series-line { fill: none; stroke: var(--color-accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-area { fill: var(--color-accent); fill-opacity: 0.12; stroke: none; }
.chart .series-bar { fill: var(--color-accent); }
.chart .series-bar:hover, .chart .series-bar.hl { fill-opacity: 0.75; }
.chart .threshold { stroke: var(--color-warning-text); stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; }
.chart .threshold-label { fill: var(--color-warning-text); font-size: 11px; font-weight: 600; font-family: var(--font-family); }
.chart .end-dot { fill: var(--color-accent); stroke: var(--color-surface-raised); stroke-width: 2; }
.chart .crosshair { stroke: var(--color-text-muted); stroke-width: 1; }
.chart .hover-dot { fill: var(--color-accent); stroke: var(--color-surface-raised); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart-tooltip {
    position: absolute;
    pointer-events: none;
    background: var(--color-surface-raised);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    box-shadow: 0 4px 14px var(--color-shadow);
    border-radius: 6px;
    padding: 5px 9px;
    font-size: 0.75rem;
    white-space: nowrap;
    transform: translate(-50%, calc(-100% - 10px));
    z-index: 5;
}
.chart-tooltip strong { color: var(--color-text-strong); font-variant-numeric: tabular-nums; }
.chart-caption { display: flex; justify-content: space-between; gap: 10px; font-size: 0.78rem; color: var(--color-text-muted); margin-top: 6px; flex-wrap: wrap; }

.spark { width: 90px; height: 24px; display: block; }
.spark path.l { fill: none; stroke: var(--color-accent); stroke-width: 1.5; }
.spark path.a { fill: var(--color-accent); fill-opacity: 0.12; }

.big-stat { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.big-stat .value { font-size: 2.2rem; font-weight: 700; color: var(--color-text-strong); font-variant-numeric: tabular-nums; line-height: 1.1; }
.big-stat .delta { font-size: 0.8rem; font-weight: 600; }

/* ---------- Carte d'hôte ---------- */

.host-card { display: flex; flex-direction: column; gap: 14px; }
.host-card .host-title { display: flex; align-items: center; gap: 10px; }
.host-card .host-title .icon { width: 22px; height: 22px; color: var(--color-text-muted); }
.host-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; }
.host-metrics .m-label { font-size: 0.75rem; color: var(--color-text-muted); margin-bottom: 3px; }

/* ---------- Connexion ---------- */

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background:
        radial-gradient(circle at 20% 15%, var(--color-accent-soft), transparent 45%),
        var(--color-surface);
}
.auth-card {
    width: min(100%, 400px);
    background: var(--color-surface-raised);
    border-radius: 14px;
    box-shadow: 0 10px 40px var(--color-shadow);
    padding: 30px 28px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.auth-brand .brand-mark { width: 52px; height: 52px; }
.auth-brand h1 { font-size: 1.5rem; }
.auth-brand p { font-size: var(--font-small); color: var(--color-text-muted); }
.auth-step { display: flex; flex-direction: column; gap: 12px; }
.auth-step .button { justify-content: center; }
.auth-divider { display: flex; align-items: center; gap: 10px; font-size: 0.75rem; color: var(--color-text-muted); }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--color-border); }
.passkey {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 18px; border: 1px dashed var(--color-border-focus); border-radius: 10px; text-align: center;
    font-size: var(--font-small);
}
.passkey .icon { width: 34px; height: 34px; color: var(--color-accent); }
.otp { display: flex; gap: 8px; justify-content: center; }
.otp input { width: 42px; text-align: center; font-size: 1.2rem; font-weight: 600; padding: 8px 0; }

/* ---------- Modale ---------- */

.modal-backdrop {
    position: fixed; inset: 0; background: var(--color-overlay);
    display: grid; place-items: center; padding: 16px; z-index: 2000;
}
.modal {
    width: min(100%, 520px);
    background: var(--color-surface-raised);
    border-radius: 12px;
    box-shadow: 0 20px 60px var(--color-shadow);
    padding: 22px 24px;
    display: flex; flex-direction: column; gap: 14px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---------- Divers ---------- */

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.divider { border: 0; border-top: 1px solid var(--color-border); margin: 4px 0; width: 100%; }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: var(--font-small); }
.check-list li { display: flex; gap: 8px; align-items: flex-start; }
.check-list .icon { width: 16px; height: 16px; margin-top: 2px; }

.diff { font-family: var(--font-family-mono); font-size: 0.78rem; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--color-border); }
.diff div { padding: 4px 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.diff .del { background: var(--color-error-bg); color: var(--color-error-text); }
.diff .add { background: var(--color-success-bg); color: var(--color-success-text); }
.diff .ctx { color: var(--color-text-muted); }

.swatch { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--color-border); display: inline-block; vertical-align: middle; }

.empty { text-align: center; color: var(--color-text-muted); padding: 30px 10px; font-size: var(--font-small); }

[data-view] { display: none; }
[data-view].is-active { display: flex; }
.auth-page[data-view].is-active { display: grid; }

.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;
}
body.is-auth .sidebar, body.is-auth .main-content > .main-inner > .mock-banner { display: none; }
body.is-auth .main-content { margin-left: 0; padding: 0; }
body.is-auth .main-inner { max-width: none; }

/* ---------- Responsive ---------- */

.menu-toggle { display: none; }
.menu-toggle-row { display: none; }

@media (width <= 1100px) {
    .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (width <= 900px) {
    .grid-2, .grid-main-side { grid-template-columns: minmax(0, 1fr); }
}

@media (width <= 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
    body.menu-open .sidebar { transform: none; }
    .main-content { margin-left: 0; padding: 14px 16px 32px; }
    .menu-toggle { display: inline-flex; }
    .menu-toggle-row { display: flex; }
    .form-grid, .grid-3, .host-metrics { grid-template-columns: minmax(0, 1fr); }
    .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
    .kv dd { margin-bottom: 8px; }
}

@media (width <= 480px) {
    .kpi-strip { grid-template-columns: minmax(0, 1fr); }
    .kpi-value { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Application (hors maquettes) ---------- */

/* Entrées de menu des modules pas encore livrés */
.sidebar-menu-link.is-soon { opacity: 0.5; cursor: default; }
.sidebar-menu-link.is-soon:hover { background: none; border-left-color: transparent; }
.soon-tag {
    font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
    padding: 1px 6px; border-radius: 999px; border: 1px solid var(--color-border);
}

.inline-form { display: inline; margin: 0; }

/* Jauge en SVG : la CSP interdit les styles en ligne */
.meter-svg { flex: 1; height: 6px; display: block; }
.meter-svg .bg { fill: var(--color-surface-sunken); }
.meter-svg .val { fill: var(--color-accent); }
.meter-svg .val.warn { fill: var(--color-warning-text); }
.meter-svg .val.crit { fill: var(--color-error-text); }

.flash { margin: 0; }
.alert-error { padding: 10px 14px; border-radius: var(--radius); background: var(--color-error-bg); color: var(--color-error-text); font-size: var(--font-small); }
.setup-steps { margin: 0; padding-left: 18px; font-size: var(--font-small); display: flex; flex-direction: column; gap: 6px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.gap-sm { gap: 6px; }
.text-center { text-align: center; }
.mt-sm { margin-top: 10px; }
.hint-block { padding: 10px 20px 16px; }
a.cell-main { text-decoration: none; }
a.cell-main:hover { text-decoration: underline; }

/* ---------- Double authentification ---------- */

.auth-card-wide { width: min(100%, 480px); }
.qr-block { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.qr-block .field { width: 100%; }
/* Le QR reste noir sur blanc dans les deux thèmes : les applications le lisent mal inversé. */
.qr { width: 220px; height: 220px; max-width: 100%; background: #ffffff; padding: 8px; border-radius: 8px; border: 1px solid var(--color-border); }
.code-input { font-size: 1.25rem; letter-spacing: 0.2em; text-align: center; font-variant-numeric: tabular-nums; }
.recovery-codes {
    list-style: none; margin: 0; padding: 0;
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
}
.recovery-codes code {
    display: block; text-align: center; padding: 8px; border-radius: 6px;
    background: var(--color-surface-sunken); font-size: 0.95rem; letter-spacing: 0.05em; user-select: all;
}
.auth-card > .button, .auth-step .button, .auth-step .button-ghost { justify-content: center; }

/* ---------- Enrôlement d'un agent ---------- */
.enroll-card { border-left: 4px solid var(--color-info-text); }
.enroll-command { white-space: pre-wrap; word-break: break-all; user-select: all; }

/* ---------- Monitoring ---------- */
/* Sélecteurs de période et onglets en liens : la page se recharge, sans JavaScript. */
.segmented a {
    font-size: 0.8rem; font-weight: 600; text-decoration: none;
    background: var(--color-surface-raised); color: var(--color-text);
    padding: 6px 12px;
}
.segmented a + a { border-left: 1px solid var(--color-border); }
.segmented a.active { background: var(--color-accent); color: var(--color-on-accent); }
a.tab { text-decoration: none; }
.alert-card { display: flex; flex-direction: column; gap: 8px; }
.alert-card.is-crit { border-left: 4px solid var(--color-error-text); }
.alert-card.is-warn { border-left: 4px solid var(--color-warning-text); }
.container-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.storage-split { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.storage-split .kpi-value { font-size: 1.1rem; }
@media (max-width: 640px) { .storage-split { grid-template-columns: minmax(0, 1fr); } }
