:root {
    --color-primary: #2FA5A9;
    --color-secondary: #1B3A5C;

    --bg: #ffffff;
    --bg-subtle: #F6F8F9;
    --bg-card: #ffffff;
    --border: #E4E9EC;
    --text: #16222B;
    --text-muted: #5B6B76;
    --danger: #C0392B;
    --danger-bg: #FBEAE8;
    --success: #1F8A5F;
    --success-bg: #E7F5EE;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 32, 0.06);
    --shadow-md: 0 8px 24px rgba(16, 24, 32, 0.08);

    --sidebar-width: 264px;

    /* Palette de data-viz — validée (contraste + séparation daltonisme) via
       scripts/validate_palette.js du skill dataviz, contre nos propres
       surfaces claires/sombres. Ordre fixe, jamais permuté ni cyclé. */
    --viz-cat-1: #2a78d6;
    --viz-cat-2: #1baf7a;
    --viz-cat-3: #eda100;
    --viz-cat-4: #008300;
    --viz-sequential: #2a78d6;
    /* Séries des courbes : teal marque (assombri pour >= 3:1 sur blanc) + violet.
       Validées clair ET sombre via validate_palette.js (ΔE daltonisme ~50). */
    --viz-line-1: #1d9ea3;
    --viz-line-3: #eda100;
    --viz-line-2: #4a3aa7;
    --viz-spark: #c3c2b7;
    --viz-good: #0ca30c;
    --viz-warning: #fab219;
    --viz-serious: #ec835a;
    --viz-critical: #d03b3b;
    --viz-grid: #e1e0d9;
    --viz-axis: #c3c2b7;

    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0F1720;
    --bg-subtle: #16212B;
    --bg-card: #16212B;
    --border: #26333E;
    --text: #EAF0F3;
    --text-muted: #8C9BA6;
    --danger-bg: #3A1E1C;
    --success-bg: #14342A;
    --viz-cat-1: #3987e5;
    --viz-cat-2: #199e70;
    --viz-cat-3: #c98500;
    --viz-cat-4: #1fae1f;
    --viz-sequential: #3987e5;
    --viz-line-1: #2FA5A9;
    --viz-line-3: #c98500;
    --viz-line-2: #9085e9;
    --viz-spark: #4a5761;
    --viz-grid: #26333E;
    --viz-axis: #3a4854;
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0F1720;
        --bg-subtle: #16212B;
        --bg-card: #16212B;
        --border: #26333E;
        --text: #EAF0F3;
        --text-muted: #8C9BA6;
        --danger-bg: #3A1E1C;
        --success-bg: #14342A;
        --viz-cat-1: #3987e5;
        --viz-cat-2: #199e70;
        --viz-cat-3: #c98500;
        --viz-cat-4: #1fae1f;
        --viz-sequential: #3987e5;
        --viz-line-1: #2FA5A9;
    --viz-line-3: #c98500;
        --viz-line-2: #9085e9;
        --viz-spark: #4a5761;
        --viz-grid: #26333E;
        --viz-axis: #3a4854;
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-subtle);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

.icon {
    width: 1.1em;
    height: 1.1em;
    stroke: currentColor;
    vertical-align: -0.15em;
}

/* Layout général : barre latérale + contenu */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    background: linear-gradient(190deg, var(--color-secondary) 0%, color-mix(in srgb, var(--color-secondary) 72%, black) 100%);
    color: rgba(255, 255, 255, 0.85);
    transition: transform 0.25s ease;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 20px 18px;
}

.sidebar__brand-link {
    display: block;
    line-height: 0;
}

.sidebar__logo {
    height: 42px;
    width: auto;
    display: block;
}

.sidebar__close {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 4px;
}

.sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.75);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.sidebar__link .icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar__link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    text-decoration: none;
}

.sidebar__link.is-active {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--color-primary);
}

.sidebar__divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.12);
    margin: 10px 12px;
}

.sidebar__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

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

.sidebar__user-name {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar__user-role {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.sidebar__logout {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid transparent;
    color: #fff;
    flex-shrink: 0;
}

.sidebar__logout:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6, 12, 20, 0.5);
    z-index: 30;
}

.sidebar-backdrop.is-visible {
    display: block;
}

.app-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar__toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
}

.topbar__toggle:hover {
    background: var(--bg-subtle);
}

.topbar__spacer {
    flex: 1;
}

.notif-bell {
    position: relative;
}

.notif-bell__count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.app-main {
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 24px 48px;
}

@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-md);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar__close {
        display: inline-flex;
    }

    .app-content {
        margin-left: 0;
    }

    .topbar__toggle {
        display: inline-flex;
    }
}

@media (max-width: 640px) {
    .app-main {
        padding: 18px 16px 40px;
    }

    .topbar {
        padding: 10px 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card {
        padding: 18px;
    }

    .step-row {
        flex-wrap: wrap;
    }

    .step-row__actions {
        margin-left: auto;
    }
}

/* Une carte contenant un tableau devient scrollable horizontalement plutôt
   que de casser la mise en page sur petit écran. */
.card:has(.table) {
    overflow-x: auto;
}

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-subtle);
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 28px;
}

.card--auth {
    width: 100%;
    max-width: 400px;
}

/* Forms */
.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.input-group {
    position: relative;
}

.input-group .icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
}

.input-group input {
    padding-left: 38px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn--primary {
    background: var(--color-secondary);
    color: #fff;
    width: 100%;
}

.btn--primary:hover {
    background: color-mix(in srgb, var(--color-secondary) 88%, black);
    text-decoration: none;
}

.btn--icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 8px;
    border-radius: var(--radius-sm);
}

.btn--icon:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Alerts */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}

.alert--error {
    background: var(--danger-bg);
    color: var(--danger);
}

.alert--success {
    background: var(--success-bg);
    color: var(--success);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header__logo {
    height: 64px;
    width: auto;
    margin: 0 auto 14px;
    display: block;
}

.auth-header h1 {
    font-size: 18px;
    margin: 0 0 4px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
}

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

/* Tableau de bord : tuiles de synthèse */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stat-tile {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.stat-tile__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.stat-tile__icon .icon {
    width: 20px;
    height: 20px;
}

.stat-tile__icon--neutral {
    background: color-mix(in srgb, var(--color-primary) 14%, transparent);
    color: var(--color-primary);
}

.stat-tile__icon--warning {
    background: color-mix(in srgb, var(--viz-warning) 20%, transparent);
    color: color-mix(in srgb, var(--viz-warning) 65%, black);
}

.stat-tile__icon--critical {
    background: color-mix(in srgb, var(--viz-critical) 16%, transparent);
    color: var(--viz-critical);
}

.stat-tile__value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: proportional-nums;
}

.stat-tile--critical .stat-tile__value {
    color: var(--viz-critical);
}

.stat-tile--warning .stat-tile__value {
    color: color-mix(in srgb, var(--viz-warning) 65%, black);
}

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

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.list-row:last-child {
    border-bottom: none;
}

/* Graphiques du tableau de bord */
.viz-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 20px;
}

@media (max-width: 900px) {
    .viz-grid {
        grid-template-columns: 1fr;
    }
}

.viz-title {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 600;
}

.viz-stackbar {
    display: flex;
    gap: 2px;
    height: 28px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-subtle);
}

.viz-stackbar__seg {
    flex-grow: var(--grow, 1);
    flex-shrink: 0;
    flex-basis: 0;
    min-width: 3px;
}

.viz-legend {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.viz-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.viz-legend .icon {
    width: 14px;
    height: 14px;
}

.viz-legend strong {
    margin-left: auto;
    color: var(--text);
    font-variant-numeric: proportional-nums;
}

.viz-legend__swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.viz-hbars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.viz-hbar-row {
    display: grid;
    grid-template-columns: 90px 1fr 42px;
    align-items: center;
    gap: 12px;
}

.viz-hbar-row__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viz-hbar-row__track {
    height: 10px;
    border-radius: 999px;
    background: var(--bg-subtle);
    overflow: hidden;
}

.viz-hbar-row__fill {
    height: 100%;
    border-radius: 999px;
    background: var(--viz-sequential);
}

.viz-hbar-row__value {
    font-size: 13px;
    color: var(--text-muted);
    text-align: right;
    font-variant-numeric: proportional-nums;
}

@media (max-width: 480px) {
    .viz-hbar-row {
        grid-template-columns: 70px 1fr 36px;
    }
}

/* Pages avec titre + action */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-header h1 {
    margin: 0;
    font-size: 20px;
}

.btn--sm {
    padding: 6px;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-weight: 600;
}

.table tr:last-child td {
    border-bottom: none;
}

/* Étapes d'un parcours */
.step-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.step-row__order {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.step-row__body {
    flex: 1;
    min-width: 0;
}

.step-row__actions {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.step-row__actions select {
    width: auto;
    min-width: 130px;
}

.step-row__actions details {
    position: relative;
}

.step-row__actions summary {
    list-style: none;
    cursor: pointer;
}

.step-row__actions summary::-webkit-details-marker {
    display: none;
}

.step-row__actions .step-edit-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 16px;
    z-index: 10;
}

.step-add-panel {
    margin-top: 14px;
    max-width: 420px;
}

details[open] > summary {
    color: var(--color-primary);
}

/* Barre de progression d'un dossier */
.progress {
    width: 100%;
    max-width: 140px;
    height: 6px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.progress__bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 999px;
}

/* Badges de statut */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge--ouvert {
    background: var(--success-bg);
    color: var(--success);
}

.badge--cloture {
    background: var(--bg-subtle);
    color: var(--text-muted);
}

.badge--a_faire {
    background: var(--bg-subtle);
    color: var(--text-muted);
}

.badge--en_cours {
    background: color-mix(in srgb, var(--color-primary) 16%, transparent);
    color: var(--color-primary);
}

.badge--fait {
    background: var(--success-bg);
    color: var(--success);
}

.badge--visa-attente {
    background: var(--bg-subtle);
    color: var(--text-muted);
}

.badge--visa-approuve {
    background: var(--success-bg);
    color: var(--success);
}

.badge--visa-rejete {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge--retard {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge .icon {
    width: 0.95em;
    height: 0.95em;
    margin-right: 3px;
}

/* Bascule clair/sombre : on affiche l'icône correspondant au thème actif */
[data-theme-toggle] .icon-moon {
    display: none;
}

:root[data-theme="dark"] [data-theme-toggle] .icon-sun {
    display: none;
}

:root[data-theme="dark"] [data-theme-toggle] .icon-moon {
    display: inline;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) [data-theme-toggle] .icon-sun {
        display: none;
    }

    :root:not([data-theme="light"]) [data-theme-toggle] .icon-moon {
        display: inline;
    }
}

/* ================================================================
   Tableau de bord v2 — structure type "Ads Manager"
   ================================================================ */

/* Barre d'outils : titre + sélecteur de période (contrôle segmenté) */
.dash-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.segmented {
    display: inline-flex;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.segmented__item {
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.segmented__item:hover {
    color: var(--text);
    text-decoration: none;
}

.segmented__item.is-active {
    background: var(--color-secondary);
    color: #fff;
}

/* Bande de KPI : cartes-scores avec delta + sparkline */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.kpi-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

a.kpi-card {
    color: inherit;
}

a.kpi-card:hover {
    text-decoration: none;
    border-color: var(--color-primary);
}

.kpi-card--alert {
    border-color: color-mix(in srgb, var(--viz-critical) 45%, var(--border));
}

.kpi-card__label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-muted);
    text-transform: uppercase;
    line-height: 1.5;
}

.kpi-card__label .icon {
    width: 14px;
    height: 14px;
    margin-right: 4px;
    vertical-align: -0.2em;
}

.kpi-card__value {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.kpi-card__value small {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-left: 2px;
}

.kpi-card--alert .kpi-card__value {
    color: var(--viz-critical);
}

.kpi-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 28px;
}

.kpi-card__delta {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.kpi-card__delta .icon {
    width: 11px;
    height: 11px;
}

.kpi-card__delta--up {
    background: var(--success-bg);
    color: var(--success);
}

.kpi-card__delta--down {
    background: var(--danger-bg);
    color: var(--danger);
}

.kpi-card__delta--flat {
    background: var(--bg-subtle);
    color: var(--text-muted);
}

.kpi-card__hint {
    font-size: 12px;
    color: var(--text-muted);
}

.kpi-card__spark {
    width: 96px;
    height: 28px;
    flex-shrink: 0;
}

/* Zone principale : grand graphique + file d'action */
.dash-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    margin-top: 20px;
    align-items: stretch;
}

@media (max-width: 1080px) {
    .dash-main {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    display: flex;
    flex-direction: column;
    padding: 22px 24px 16px;
}

.chart-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.chart-card__title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
}

.chart-card__subtitle {
    margin: 2px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.chart-toggle {
    display: inline-flex;
    gap: 4px;
    background: var(--bg-subtle);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.chart-toggle button {
    border: none;
    background: transparent;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 5px 12px;
    border-radius: 5px;
    cursor: pointer;
}

.chart-toggle button.is-active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.chart-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin: 4px 0 2px;
    min-height: 18px;
}

.chart-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.chart-legend__key {
    width: 14px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

.chart-area {
    flex: 1;
    min-height: 260px;
    height: 260px;
}

.chart-tooltip {
    position: absolute;
    visibility: hidden;
    pointer-events: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 10px 12px;
    font-size: 12.5px;
    z-index: 15;
    min-width: 150px;
}

.chart-tooltip__label {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11.5px;
    margin-bottom: 6px;
}

.chart-tooltip__row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 0;
}

.chart-tooltip__row strong {
    font-variant-numeric: tabular-nums;
}

.chart-tooltip__key {
    width: 12px;
    height: 3px;
    border-radius: 2px;
    flex-shrink: 0;
}

.chart-tooltip__name {
    color: var(--text-muted);
    margin-left: auto;
    padding-left: 10px;
    white-space: nowrap;
}

/* File d'action (rail droit) */
.action-rail {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.action-rail__head {
    padding: 18px 20px 10px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.action-rail__head h2 {
    margin: 0;
    font-size: 15px;
}

.action-rail__count {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

.action-rail__body {
    overflow-y: auto;
    flex: 1;
    max-height: 340px;
}

.action-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    color: inherit;
}

a.action-item:hover {
    background: var(--bg-subtle);
    text-decoration: none;
}

.action-item__icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.action-item__icon .icon {
    width: 15px;
    height: 15px;
}

.action-item__icon--critical {
    background: var(--danger-bg);
    color: var(--danger);
}

.action-item__icon--warning {
    background: color-mix(in srgb, var(--viz-warning) 18%, transparent);
    color: color-mix(in srgb, var(--viz-warning) 60%, black);
}

:root[data-theme="dark"] .action-item__icon--warning {
    color: var(--viz-warning);
}

.action-item__icon--neutral {
    background: color-mix(in srgb, var(--color-primary) 14%, transparent);
    color: var(--color-primary);
}

.action-item__body {
    min-width: 0;
    flex: 1;
}

.action-item__title {
    display: block;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.35;
}

.action-item__meta {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.action-item__cta {
    align-self: center;
    color: var(--text-muted);
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
}

.action-rail__empty {
    padding: 28px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
}

.action-rail__empty .icon {
    width: 22px;
    height: 22px;
    color: var(--success);
    display: block;
    margin: 0 auto 8px;
}

/* Ligne du bas : répartition + avancement */
.dash-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-top: 16px;
}

@media (max-width: 900px) {
    .dash-row {
        grid-template-columns: 1fr;
    }
}

/* Table : ligne cliquable */
.table--hover tbody tr:hover td {
    background: var(--bg-subtle);
}

/* ================================================================
   Animations discrètes (désactivées si « réduire le mouvement »)
   ================================================================ */
@keyframes fade-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes grow-x {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@media (prefers-reduced-motion: no-preference) {
    .anim-page .card,
    .anim-page .mini-stat,
    .anim-page .folder {
        animation: fade-up 0.35s ease-out backwards;
    }

    .anim-page .mini-stat:nth-child(2) { animation-delay: 0.04s; }
    .anim-page .mini-stat:nth-child(3) { animation-delay: 0.08s; }
    .anim-page .mini-stat:nth-child(4) { animation-delay: 0.12s; }
    .anim-page .mini-stat:nth-child(5) { animation-delay: 0.16s; }
    .anim-page .mini-stat:nth-child(6) { animation-delay: 0.2s; }
    .anim-page .mini-stat:nth-child(7) { animation-delay: 0.24s; }

    .progress__bar,
    .viz-hbar-row__fill {
        transform-origin: left center;
        animation: grow-x 0.7s ease-out backwards;
    }
}

/* ================================================================
   Archives : vue « meuble à dossiers » classée par client
   ================================================================ */
.folders-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
}

.folder {
    position: relative;
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px 12px 12px 12px;
    padding: 40px 16px 14px;
    color: inherit;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.folder::before {
    /* Languette du dossier suspendu */
    content: "";
    position: absolute;
    top: -9px;
    left: -1px;
    width: 42%;
    min-width: 74px;
    height: 18px;
    background: var(--color-primary);
    border-radius: 6px 10px 0 0;
    opacity: 0.9;
}

.folder::after {
    /* Tranche colorée sous la languette */
    content: "";
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    height: 22px;
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
    border-bottom: 1px solid var(--border);
}

.folder:hover {
    text-decoration: none;
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.folder--interne::before {
    background: var(--text-muted);
}

.folder__name {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.35;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.folder__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Visionneuse intégrée (images, PDF, vidéos, audio) */
.viewer {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(8, 14, 22, 0.82);
    display: flex;
    flex-direction: column;
    animation: fade-up 0.18s ease-out;
}

.viewer__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    color: #fff;
}

.viewer__title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewer__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.viewer__btn {
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.viewer__btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    text-decoration: none;
}

.viewer__body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 18px 18px;
    min-height: 0;
}

.viewer__media {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    background: #fff;
}

.viewer__media--image {
    object-fit: contain;
    background: transparent;
}

.viewer__media--pdf {
    width: min(960px, 100%);
    height: 100%;
    border: none;
}

.viewer__media--video {
    background: #000;
    max-height: 100%;
}

.viewer__media--audio {
    background: transparent;
    width: min(480px, 100%);
}

/* Journal des mouvements financiers */
.mouvement-montant--entree {
    color: var(--success);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.mouvement-montant--sortie {
    color: var(--danger);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ================================================================
   Composants transverses des pages métier
   ================================================================ */

/* Actions rapides (dashboard) */
.quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 18px 0 0;
}

.quick-actions .btn {
    width: auto;
    padding: 8px 14px;
    font-size: 13px;
    background: var(--bg-card);
}

.quick-actions .btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    text-decoration: none;
}

/* Barre de recherche + filtres au-dessus des listes */
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.filter-bar .field {
    margin: 0;
}

.filter-bar .field--grow {
    flex: 1;
    min-width: 200px;
}

.filter-bar label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.filter-bar input,
.filter-bar select {
    padding: 8px 11px;
    font-size: 13.5px;
}

.filter-bar .btn {
    width: auto;
    padding: 8px 16px;
    font-size: 13px;
}

.filter-bar__reset {
    font-size: 12.5px;
    color: var(--text-muted);
    align-self: center;
    padding-bottom: 2px;
}

/* En-tête d'une fiche (dossier, client, prestataire) */
.entity-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.entity-header h1 {
    margin: 0;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.entity-header__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.entity-header__actions .btn {
    width: auto;
    padding: 8px 14px;
    font-size: 13px;
}

.chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 12.5px;
    color: var(--text-muted);
}

.chip .icon {
    width: 13px;
    height: 13px;
}

.chip a {
    color: inherit;
    font-weight: 600;
}

.chip strong {
    color: var(--text);
    font-weight: 600;
}

/* Rangée de mini-statistiques en tête de fiche */
.mini-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.mini-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    min-width: 0;
}

.mini-stat__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-stat__value {
    font-size: 17px;
    font-weight: 700;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-stat__value small {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

.mini-stat--danger .mini-stat__value {
    color: var(--viz-critical);
}

.mini-stat--success .mini-stat__value {
    color: var(--success);
}

/* Fiche en deux colonnes : contenu principal + rail latéral */
.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 16px;
    align-items: start;
}

@media (max-width: 1080px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

.detail-grid__main,
.detail-grid__side {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.detail-grid__side .card {
    padding: 18px 20px;
}

.section-card__title {
    margin: 0 0 2px;
    font-size: 15px;
    font-weight: 600;
}

.section-card__subtitle {
    margin: 0 0 12px;
    font-size: 12.5px;
    color: var(--text-muted);
}

/* Timeline des étapes d'un dossier : statut lisible par la couleur */
.steps-timeline {
    padding: 4px 22px 14px;
}

.step-item {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.step-item__rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 16px;
    flex-shrink: 0;
}

.step-item__dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 4px;
    border: 3px solid var(--border);
    background: var(--bg-card);
    box-sizing: border-box;
}

.step-item--en_cours .step-item__dot {
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 25%, var(--bg-card));
}

.step-item--fait .step-item__dot {
    border-color: var(--success);
    background: var(--success);
}

.step-item__line {
    flex: 1;
    width: 2px;
    background: var(--border);
    min-height: 10px;
}

.step-item--fait .step-item__line {
    background: color-mix(in srgb, var(--success) 45%, var(--border));
}

.step-item:last-child .step-item__line {
    display: none;
}

.step-item__body {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 14px;
}

.step-item__name {
    font-weight: 600;
    font-size: 13.5px;
    line-height: 1.4;
}

.step-item--fait .step-item__name {
    color: var(--text-muted);
}

.step-item__meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.step-item select {
    width: auto;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 26px 4px 9px;
    border-radius: 999px;
    flex-shrink: 0;
}

.step-item--fait select {
    color: var(--success);
    border-color: color-mix(in srgb, var(--success) 40%, var(--border));
    background-color: var(--success-bg);
}

.step-item--en_cours select {
    color: var(--color-primary);
    border-color: color-mix(in srgb, var(--color-primary) 45%, var(--border));
    background-color: color-mix(in srgb, var(--color-primary) 12%, var(--bg-card));
}

/* Densité des fiches : cartes et rangées plus serrées dans la grille détail */
.detail-grid .card {
    padding: 18px 20px;
}

.detail-grid .card[style*="padding:0"] {
    padding: 0 !important;
}

.detail-grid .step-row {
    padding: 11px 22px;
    gap: 12px;
}

.detail-grid .section-card__subtitle {
    margin-bottom: 8px;
}

/* Historique inline (prestataires, etc.) */
.inline-history {
    margin-top: 6px;
    padding-left: 10px;
    border-left: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.inline-history__item {
    font-size: 12px;
    color: var(--text-muted);
}

.inline-history__item strong {
    color: var(--text);
    font-weight: 600;
}

/* Onglets (rail latéral d'une fiche) : une ligne de boutons, un panneau visible */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
}

.tabs__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 11px;
    border-radius: 999px;
    cursor: pointer;
}

.tabs__btn .icon {
    width: 13px;
    height: 13px;
}

.tabs__btn:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

.tabs__btn.is-active {
    background: var(--color-secondary);
    border-color: var(--color-secondary);
    color: #fff;
}

.tabs__btn.is-active .tabs__count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
}

.tabs__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 10.5px;
    font-weight: 700;
}

.tab-panel {
    display: none;
    padding: 16px 18px;
}

.tab-panel.is-active {
    display: block;
}

/* Compteur discret dans les titres de section */
.count-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 11.5px;
    font-weight: 700;
    vertical-align: 1px;
}
