/* ===========================================================================
   Utopia Outils - feuille de style unique.

   Aucune dependance externe : le fichier est servi depuis le domaine de
   l'application, ce qui permet une politique CSP stricte (style-src 'self').
   Organisation : jetons -> base -> mise en page -> composants -> utilitaires.
   =========================================================================== */

/* ---------------------------------------------------------------- Jetons -- */
:root {
    --bg: #f5f7fa;
    --bg-soft: #eef2f7;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-soft: #475569;
    --text-muted: #7c8ba1;

    --accent: #0284c7;
    --accent-soft: rgba(2, 132, 199, 0.1);
    --accent-contrast: #ffffff;

    --success: #059669;
    --success-soft: rgba(5, 150, 105, 0.12);
    --warning: #d97706;
    --warning-soft: rgba(217, 119, 6, 0.14);
    --danger: #e11d48;
    --danger-soft: rgba(225, 29, 72, 0.12);
    --info: #6366f1;
    --info-soft: rgba(99, 102, 241, 0.12);
    --violet: #7c3aed;
    --neutral: #64748b;
    --neutral-soft: rgba(100, 116, 139, 0.12);

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px -12px rgba(15, 23, 42, 0.18);
    --shadow-lg: 0 24px 48px -24px rgba(15, 23, 42, 0.35);

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;

    --sidebar-width: 248px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
    --bg: #070b14;
    --bg-soft: #0b1220;
    --surface: #0f1626;
    --surface-2: #131c2e;
    --border: #1e293b;
    --border-strong: #2b3a52;
    --text: #e6edf7;
    --text-soft: #a8b7cd;
    --text-muted: #7c8ba1;

    --accent: #38bdf8;
    --accent-soft: rgba(56, 189, 248, 0.14);
    --accent-contrast: #06121f;

    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.14);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.14);
    --danger: #fb7185;
    --danger-soft: rgba(251, 113, 133, 0.14);
    --info: #818cf8;
    --info-soft: rgba(129, 140, 248, 0.16);
    --violet: #a78bfa;
    --neutral: #94a3b8;
    --neutral-soft: rgba(148, 163, 184, 0.14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 12px 32px -16px rgba(0, 0, 0, 0.7);
    --shadow-lg: 0 32px 64px -32px rgba(0, 0, 0, 0.8);
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    margin: 0;
    font-weight: 650;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

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

a:hover { text-decoration: underline; }

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 18px 0;
}

svg { display: block; }

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

::selection {
    background: var(--accent-soft);
}

/* ------------------------------------------------------------ Mise en page */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex: 0 0 var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), var(--violet));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: -0.02em;
    flex: none;
}

.brand-text { min-width: 0; }
.brand-name {
    font-weight: 650;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand-sub {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

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

.nav-section {
    padding: 14px 8px 6px;
    font-size: 10.5px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-weight: 500;
    font-size: 13.5px;
    transition: background 0.12s ease, color 0.12s ease;
}

.nav-item:hover {
    background: var(--bg-soft);
    color: var(--text);
    text-decoration: none;
}

.nav-item.is-active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.nav-item svg {
    width: 17px;
    height: 17px;
    flex: none;
    stroke: currentColor;
    stroke-width: 1.7;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--danger);
    color: #fff;
    font-size: 11px;
    font-weight: 650;
    display: grid;
    place-items: center;
}

.sidebar-foot {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    display: grid;
    place-items: center;
    flex: none;
}

.user-meta { min-width: 0; flex: 1; }
.user-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 11px;
    color: var(--text-muted);
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 24px;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
}

.topbar h1 { font-size: 17px; }
.topbar-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.content {
    padding: 22px 24px 48px;
    max-width: 1560px;
    width: 100%;
}

/* --------------------------------------------------------------- Cartes -- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 16px; }

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 { font-size: 14.5px; }

.card-header .card-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 12.5px;
    color: var(--text-muted);
}

/* ------------------------------------------------------- Statistiques ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--accent);
    opacity: 0.85;
}

.stat.is-success::after { background: var(--success); }
.stat.is-warning::after { background: var(--warning); }
.stat.is-danger::after { background: var(--danger); }
.stat.is-neutral::after { background: var(--neutral); }

.stat-label {
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 26px;
    font-weight: 660;
    letter-spacing: -0.02em;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

.stat-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ------------------------------------------------------- Grille d'outils - */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.tool-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    color: inherit;
    transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
    min-height: 190px;
}

.tool-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 4px;
}

.tool-card:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: var(--border-strong);
}

.tool-card.is-soon {
    opacity: 0.62;
    pointer-events: none;
}

.tool-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
}

.tool-icon svg {
    width: 21px;
    height: 21px;
    stroke: currentColor;
    stroke-width: 1.7;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tool-icon.accent-violet { background: rgba(124, 58, 237, 0.12); color: var(--violet); }
.tool-icon.accent-amber { background: var(--warning-soft); color: var(--warning); }
.tool-icon.accent-emerald { background: var(--success-soft); color: var(--success); }
.tool-icon.accent-slate { background: var(--neutral-soft); color: var(--neutral); }

.tool-name {
    font-weight: 650;
    font-size: 17px;
    letter-spacing: -0.01em;
}

.tool-tagline {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.tool-summary {
    font-size: 13px;
    color: var(--text-muted);
    flex: 1;
    margin-top: 4px;
}

.tool-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.tool-metric {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    font-weight: 550;
}

.tool-metric .muted {
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-arrow svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-muted);
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.14s ease;
}

.tool-card:hover .tool-arrow svg {
    stroke: var(--accent);
    transform: translateX(3px);
}

/* -------------------------------------------------------------- Tableaux - */
.table-wrap {
    overflow-x: auto;
    border-radius: 0 0 var(--radius) var(--radius);
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.data th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 650;
    padding: 10px 14px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

table.data td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data tbody tr:last-child td { border-bottom: 0; }

table.data tbody tr:hover {
    background: var(--surface-2);
}

table.data td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

table.data .cell-main {
    font-weight: 590;
    color: var(--text);
}

table.data .cell-sub {
    font-size: 11.5px;
    color: var(--text-muted);
}

.row-critical { box-shadow: inset 3px 0 0 var(--danger); }
.row-warning { box-shadow: inset 3px 0 0 var(--warning); }

/* --------------------------------------------------------------- Badges -- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
    background: var(--neutral-soft);
    color: var(--neutral);
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neutral);
    flex: none;
    display: inline-block;
}

.dot-success { background: var(--success); }
.dot-warning { background: var(--warning); }
.dot-danger { background: var(--danger); }
.dot-info { background: var(--info); }

.dot-pulse {
    box-shadow: 0 0 0 0 currentColor;
    animation: pulse 2.2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 var(--danger-soft); }
    70% { box-shadow: 0 0 0 7px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
    .dot-pulse { animation: none; }
    .tool-card { transition: none; }
}

/* -------------------------------------------------------------- Boutons -- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 570;
    cursor: pointer;
    transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    stroke-width: 1.8;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-contrast);
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--accent) 88%, #000);
}

.btn-danger {
    background: transparent;
    border-color: color-mix(in srgb, var(--danger) 45%, transparent);
    color: var(--danger);
}

.btn-danger:hover { background: var(--danger-soft); }

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-soft);
}

.btn-ghost:hover { background: var(--bg-soft); color: var(--text); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.btn-icon {
    padding: 7px;
    width: 32px;
    height: 32px;
}

/* ----------------------------------------------------------- Formulaires - */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--text-soft);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 13.5px;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder { color: var(--text-muted); }

.textarea { min-height: 76px; resize: vertical; }

.select {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                      linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}

.hint {
    font-size: 11.8px;
    color: var(--text-muted);
    margin-top: 5px;
}

.field-error {
    font-size: 12px;
    color: var(--danger);
    margin-top: 5px;
}

.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }

.code-input {
    font-family: var(--mono);
    font-size: 22px;
    letter-spacing: 0.4em;
    text-align: center;
    padding: 12px;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

/* --------------------------------------------------- Messages / bandeaux - */
.flash-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.flash {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    border: 1px solid transparent;
}

.flash-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.flash-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.flash-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 25%, transparent); }

.callout {
    padding: 13px 15px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-soft);
}

.callout-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.callout-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); color: var(--warning); }

.empty-state {
    padding: 42px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

.empty-state svg {
    width: 34px;
    height: 34px;
    margin: 0 auto 10px;
    stroke: currentColor;
    stroke-width: 1.4;
    fill: none;
    opacity: 0.5;
}

/* ----------------------------------------------------------- Connexion --- */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    background:
        radial-gradient(1000px 620px at 12% -10%, var(--accent-soft), transparent 60%),
        radial-gradient(760px 520px at 92% 110%, rgba(124, 58, 237, 0.12), transparent 60%),
        var(--bg);
    padding: 24px;
    align-items: center;
    justify-items: center;
}

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

.auth-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-bottom: 22px;
}

.auth-title {
    font-size: 19px;
    font-weight: 650;
    margin-bottom: 4px;
}

.auth-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 22px;
}

.auth-foot {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* ------------------------------------------------------------------ 2FA -- */
.qr-frame {
    display: inline-block;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.secret-box {
    font-family: var(--mono);
    font-size: 15px;
    letter-spacing: 0.12em;
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 11px 13px;
    word-break: break-all;
}

.recovery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.recovery-code {
    font-family: var(--mono);
    font-size: 14px;
    letter-spacing: 0.06em;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 10px;
    text-align: center;
}

.steps {
    counter-reset: step;
    list-style: none;
    padding: 0;
    margin: 0;
}

.steps li {
    counter-increment: step;
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.steps li:last-child { border-bottom: 0; }

.steps li::before {
    content: counter(step);
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 11.5px;
    font-weight: 700;
    display: grid;
    place-items: center;
}

/* ------------------------------------------------------------- Graphes --- */
.chart {
    color: var(--text-soft);
    display: block;
    width: 100%;
}

.spark { display: inline-block; vertical-align: middle; }
.spark-empty { color: var(--text-muted); font-size: 12px; }

.progress {
    height: 6px;
    border-radius: 999px;
    background: var(--neutral-soft);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
}

.progress-bar.is-warning { background: var(--warning); }
.progress-bar.is-danger { background: var(--danger); }

/* ------------------------------------------------------------ Utilitaires */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.toolbar .input,
.toolbar .select { width: auto; min-width: 170px; }

.filter-pills {
    display: inline-flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 2px;
    gap: 2px;
}

.filter-pill {
    padding: 5px 11px;
    border-radius: 5px;
    font-size: 12.5px;
    font-weight: 570;
    color: var(--text-soft);
}

.filter-pill:hover { background: var(--bg-soft); text-decoration: none; }
.filter-pill.is-active { background: var(--accent-soft); color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }

.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 4px; }

.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.text-right { text-align: right; }
.tabular { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 18px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 18px; }
.w-full { width: 100%; }
.flex-1 { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.code-block {
    font-family: var(--mono);
    font-size: 12.2px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    overflow-x: auto;
    white-space: pre;
    color: var(--text-soft);
    line-height: 1.6;
}

.kbd {
    font-family: var(--mono);
    font-size: 11.5px;
    background: var(--surface-2);
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 5px;
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

.inline-form { display: inline; }

/* ------------------------------------------------------------ Responsive - */
@media (max-width: 1000px) {
    .app-shell { flex-direction: column; }

    .sidebar {
        width: 100%;
        flex: none;
        height: auto;
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: 8px 10px;
    }

    .nav-section { display: none; }
    .nav-item { white-space: nowrap; }
    .sidebar-foot { display: none; }
    .content { padding: 16px 14px 40px; }
    .topbar { padding: 12px 14px; }
}

@media (max-width: 620px) {
    .stat-value { font-size: 22px; }
    .tool-grid { grid-template-columns: 1fr; }
    .toolbar .input, .toolbar .select { width: 100%; min-width: 0; }
}

@media print {
    .sidebar, .topbar-actions, .btn { display: none !important; }
    body { background: #fff; }
}

/* --------------------------------------------------- Largeurs discretes ---
   La CSP interdit les attributs style="" : les barres de progression
   utilisent donc des classes par paliers de 5 %.                            */
.w-0 { width: 0; }
.w-5 { width: 5%; }
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-50 { width: 50%; }
.w-55 { width: 55%; }
.w-60 { width: 60%; }
.w-65 { width: 65%; }
.w-70 { width: 70%; }
.w-75 { width: 75%; }
.w-80 { width: 80%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }

/* ===========================================================================
   Accueil : bienvenue, bandeaux, titres de section
   =========================================================================== */
.welcome {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 20px 22px;
    margin-bottom: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.welcome-text { flex: 1; min-width: 240px; }
.welcome-text h2 { font-size: 21px; margin-bottom: 2px; }
.welcome-text p { font-size: 13px; }

.welcome-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.welcome-name { font-weight: 620; font-size: 13.5px; }
.welcome-actions { margin-left: 6px; }

.avatar-lg {
    width: 42px;
    height: 42px;
    font-size: 15px;
}

.section-title {
    font-size: 11.5px;
    font-weight: 680;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin: 22px 0 12px;
}

.banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    margin-bottom: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: inherit;
}

.banner:hover { text-decoration: none; }

.banner svg {
    width: 20px;
    height: 20px;
    flex: none;
    stroke: currentColor;
    stroke-width: 1.7;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.banner-warning {
    background: var(--warning-soft);
    border-color: color-mix(in srgb, var(--warning) 28%, transparent);
    color: var(--warning);
}

.banner-danger {
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--danger);
}

.banner .text-sm { color: var(--text-soft); }

/* ===========================================================================
   Barre de synthese : des compteurs qui servent aussi de filtres
   =========================================================================== */
.statusbar {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.stat-chip {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 9px 15px;
    min-width: 104px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: inherit;
    position: relative;
    overflow: hidden;
    transition: border-color 0.12s ease, background 0.12s ease;
}

.stat-chip::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--neutral);
    opacity: 0.55;
}

.stat-chip.tone-success::before { background: var(--success); }
.stat-chip.tone-warning::before { background: var(--warning); }
.stat-chip.tone-danger::before  { background: var(--danger); }

.stat-chip:hover {
    text-decoration: none;
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.stat-chip.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-soft);
}

.stat-chip.is-static { pointer-events: none; }
.stat-chip.is-static::before { opacity: 0.2; }

.stat-chip-value {
    font-size: 19px;
    font-weight: 660;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat-chip-label {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.statusbar-sep { flex: 1; min-width: 0; }

.search-input { min-width: 260px; flex: 1; }

/* ===========================================================================
   Panneaux repliables (details/summary natifs : aucun JS requis)
   =========================================================================== */
.chevron {
    width: 16px;
    height: 16px;
    flex: none;
    position: relative;
    transition: transform 0.16s ease;
}

.chevron::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 7px;
    height: 7px;
    border-right: 1.8px solid var(--text-muted);
    border-bottom: 1.8px solid var(--text-muted);
    transform: rotate(45deg);
}

details[open] > summary .chevron { transform: rotate(180deg); }

summary { cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::marker { content: ""; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
}

.panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
}

.panel-head:hover { background: var(--surface-2); }

.panel-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 620;
    font-size: 14px;
    flex: 1;
}

.panel-title svg {
    width: 17px;
    height: 17px;
    stroke: var(--text-muted);
    stroke-width: 1.7;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.panel-meta { display: flex; gap: 5px; align-items: center; }

.panel-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.panel-body.tight { padding: 0; }
.panel-more { padding: 10px 16px; border-top: 1px solid var(--border); }

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

.alert-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.alert-item:last-child { border-bottom: 0; }
.alert-item .cell-sub { display: block; }

/* ===========================================================================
   Liste unifiee des elements supervises
   =========================================================================== */
.entity-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.entity-head,
.entity-summary {
    display: grid;
    grid-template-columns: 126px minmax(0, 1fr) 150px 128px 118px 20px;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
}

.entity-head {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 660;
    color: var(--text-muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.entity {
    border-bottom: 1px solid var(--border);
    position: relative;
}

.entity:last-of-type { border-bottom: 0; }

.entity::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: transparent;
    z-index: 1;
}

.entity.tone-danger::before  { background: var(--danger); }
.entity.tone-warning::before { background: var(--warning); }
.entity.tone-success::before { background: var(--success); opacity: 0.4; }
.entity.tone-muted::before   { background: var(--neutral); opacity: 0.35; }

.entity-summary { transition: background 0.1s ease; }
.entity-summary:hover { background: var(--surface-2); }
.entity[open] > .entity-summary { background: var(--surface-2); }

.entity-main { min-width: 0; }

.entity-name {
    display: block;
    font-weight: 600;
    font-size: 13.5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entity-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
}

.kind-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: var(--neutral-soft);
    color: var(--neutral);
}

.kind-job { background: var(--accent-soft); color: var(--accent); }
.kind-repository { background: rgba(124, 58, 237, 0.13); color: var(--violet); }

.entity-client {
    font-size: 12.5px;
    color: var(--text-soft);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entity-when,
.entity-volume {
    display: flex;
    flex-direction: column;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.entity-volume { text-align: right; }

.entity-when small,
.entity-volume small {
    font-size: 11px;
    color: var(--text-muted);
}

/* --- Contenu deplie ------------------------------------------------------ */
.entity-body {
    padding: 4px 16px 16px 19px;
    background: var(--surface-2);
    border-top: 1px solid var(--border);
}

.entity-alerts {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 12px 0;
}

.alert-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 13px;
}

.alert-row.tone-danger  { border-left: 3px solid var(--danger); }
.alert-row.tone-warning { border-left: 3px solid var(--warning); }

.entity-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 20px;
    align-items: start;
    margin-top: 12px;
}

.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 12px 20px;
    margin: 0;
}

.fact dt {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 640;
    margin-bottom: 2px;
}

.fact dd {
    margin: 0;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.entity-chart {
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.entity-message {
    margin-top: 12px;
    padding: 9px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-soft);
}

.entity-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.empty-state.small { padding: 22px 16px; }

.dot-neutral { background: var(--neutral); }
.dot-muted { background: var(--neutral); opacity: 0.5; }

/* --- Adaptation aux petits ecrans --------------------------------------- */
@media (max-width: 1100px) {
    .entity-head { display: none; }

    .entity-summary {
        grid-template-columns: minmax(0, 1fr) auto 20px;
        grid-template-areas:
            "state    when   chevron"
            "main     main   main"
            "client   volume volume";
        gap: 6px 12px;
    }

    .entity-state  { grid-area: state; }
    .entity-main   { grid-area: main; }
    .entity-client { grid-area: client; }
    .entity-when   { grid-area: when; align-items: flex-end; }
    .entity-volume {
        grid-area: volume;
        flex-direction: row;
        gap: 5px;
        align-items: baseline;
        justify-content: flex-end;
    }
    .entity-summary .chevron { grid-area: chevron; }

    .entity-detail { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 620px) {
    .welcome-profile { width: 100%; }
    .stat-chip { flex: 1; min-width: 88px; padding: 8px 12px; }
    .search-input { min-width: 0; }
}
