/*
 * Patcom — styles du back-office.
 * Feuille écrite à la main, sans étape de compilation.
 * Les pages publiques des tunnels auront leur propre feuille (funnel.css), séparée de celle-ci.
 */

@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Inter-Regular.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/Inter-Medium.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/Inter-SemiBold.woff") format("woff"); }
@font-face { font-family: "Inter Display"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/InterDisplay-SemiBold.woff") format("woff"); }

:root {
    /* Couleurs Patcom */
    --ink: #13204A;            /* encre : menu, titres, bouton principal */
    --ink-soft: #2A3866;       /* survol dans le menu */
    --ink-line: #2C3A66;       /* séparateurs dans le menu */
    --orange: #FF6B3D;         /* conversion : repère actif, éléments décoratifs */
    --orange-strong: #D94A1E;  /* anneau de focus (contraste ≥ 3:1 sur blanc) */
    --paper: #F6F7FB;          /* fond de page */
    --surface: #FFFFFF;
    --line: #DCE0EA;           /* bordures de panneaux */
    --control-line: #7D869C;   /* bordures de champs (contraste ≥ 3:1) */
    --text: #13204A;
    --text-muted: #5B6478;
    --menu-text: #C9CFE0;
    --success: #18693F;
    --success-bg: #E8F5EE;
    --warning: #8A5300;
    --warning-bg: #FFF4E0;
    --danger: #B42318;
    --danger-bg: #FDECEA;

    /* Typographie : échelle modulaire (rapport ~1.2) */
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Inter Display", "Inter", system-ui, sans-serif;
    --fs-xs: 0.8125rem;
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-lg: 1.1875rem;
    --fs-xl: 1.5rem;
    --fs-2xl: 1.875rem;

    --radius-sm: 6px;
    --radius: 10px;
    --sidebar: 256px;
    --focus: 0 0 0 2px var(--surface), 0 0 0 4px var(--orange-strong);
}

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

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

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.55;
    color: var(--text);
    background: var(--paper);
    font-feature-settings: "cv11", "ss01";
}

img, svg { max-width: 100%; height: auto; }

a { color: var(--ink); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--radius-sm); }

h1, h2, h3 { margin: 0; line-height: 1.2; color: var(--ink); }
h1 { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: var(--fs-base); font-weight: 600; }
p { margin: 0 0 1em; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: 1rem; top: -4rem; z-index: 100;
    background: var(--surface); padding: .6rem 1rem; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 1rem; }

/* ---------- Structure du back-office ---------- */

.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }

.sidebar {
    background: var(--ink);
    color: var(--menu-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.5rem 0 1rem;
}

.sidebar__brand { display: block; padding: 0 1.5rem 1.75rem; }
.sidebar__brand img { display: block; height: 30px; width: auto; }

.nav { flex: 1; overflow-y: auto; }
.nav__group + .nav__group { margin-top: 1.5rem; }
.nav__title {
    margin: 0 0 .35rem; padding: 0 1.5rem;
    font-size: var(--fs-xs); font-weight: 500; color: #AEB6CC;
}
.nav__list { list-style: none; margin: 0; padding: 0; }
.nav__link {
    position: relative;
    display: flex; align-items: center; gap: .75rem;
    padding: .55rem 1.5rem .55rem 2.25rem;
    color: var(--menu-text); text-decoration: none; font-size: var(--fs-sm); font-weight: 500;
}
.nav__link:hover { background: var(--ink-soft); color: #fff; }
/* Repère actif : le point orange du logo, l'étape où l'on se trouve dans le tunnel. */
.nav__link[aria-current="page"] { color: #fff; }
.nav__link[aria-current="page"]::before {
    content: ""; position: absolute; left: 1.25rem; top: 50%;
    width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--orange);
}
.nav__link:focus-visible { box-shadow: inset 0 0 0 2px var(--orange); border-radius: 0; }

.sidebar__user { border-top: 1px solid var(--ink-line); margin-top: 1rem; padding: 1rem 1.5rem 0; }
.user-chip { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; }
.avatar {
    flex: none; width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center;
    background: #fff; color: var(--ink); font-size: var(--fs-xs); font-weight: 600;
}
.user-chip__name { color: #fff; font-size: var(--fs-sm); font-weight: 500; line-height: 1.3; }
.user-chip__role { font-size: var(--fs-xs); color: #AEB6CC; }
.sidebar__actions { display: flex; gap: 1rem; font-size: var(--fs-sm); }
.sidebar__actions a, .linklike {
    color: var(--menu-text); background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
    text-decoration: underline; text-underline-offset: 3px;
}
.sidebar__actions a:hover, .sidebar .linklike:hover { color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; }
.content { width: 100%; max-width: 1120px; padding: 2.5rem 2.5rem 4rem; }

/* ---------- En-tête de page ---------- */

.page-header {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem 2rem;
    margin-bottom: 2rem;
}
.page-header__text { max-width: 62ch; }
.page-header__text p { margin: .5rem 0 0; color: var(--text-muted); }
.page-header__actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.back-link { display: inline-block; margin-bottom: .75rem; font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------- Panneaux ---------- */

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel + .panel { margin-top: 1.5rem; }
.panel__header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--line); }
.panel__header p { margin: .35rem 0 0; color: var(--text-muted); font-size: var(--fs-sm); }
.panel__body { padding: 1.5rem; }
.panel__footer {
    padding: 1rem 1.5rem; border-top: 1px solid var(--line); background: var(--paper);
    border-radius: 0 0 var(--radius) var(--radius);
    display: flex; flex-wrap: wrap; gap: .75rem; justify-content: flex-end;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }

/* ---------- Boutons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: 42px; padding: .55rem 1.1rem;
    font: inherit; font-size: var(--fs-sm); font-weight: 600; line-height: 1.2;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: var(--ink-soft); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--control-line); }
.btn--secondary:hover { background: var(--paper); }
.btn--danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn--danger:hover { background: var(--danger-bg); }
.btn--block { width: 100%; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: progress; }

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

.form-stack > * + * { margin-top: 1.25rem; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }

.field label, .field legend { display: block; margin-bottom: .4rem; font-size: var(--fs-sm); font-weight: 600; }
.field .optional { font-weight: 400; color: var(--text-muted); }
.field input[type="text"], .field input[type="email"], .field input[type="password"],
.field input[type="tel"], .field input[type="search"], .field select, .field textarea {
    width: 100%; min-height: 44px; padding: .6rem .8rem;
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--control-line); border-radius: var(--radius-sm);
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { border-color: var(--ink); }
.field__help { margin: .4rem 0 0; font-size: var(--fs-sm); color: var(--text-muted); }
.field__error { margin: .4rem 0 0; font-size: var(--fs-sm); font-weight: 500; color: var(--danger); }
.field--invalid input, .field--invalid select { border-color: var(--danger); border-width: 2px; }

.checkbox { display: flex; align-items: center; gap: .6rem; font-size: var(--fs-sm); }
.checkbox input { width: 18px; height: 18px; accent-color: var(--ink); }

.radio-cards { display: grid; gap: .75rem; border: 0; padding: 0; margin: 0; }
.radio-card {
    display: grid; grid-template-columns: auto 1fr; gap: .25rem .75rem; align-items: start;
    padding: .9rem 1rem; border: 1px solid var(--control-line); border-radius: var(--radius-sm); cursor: pointer;
}
.radio-card input { margin-top: .2rem; width: 18px; height: 18px; accent-color: var(--ink); }
.radio-card strong { font-size: var(--fs-sm); }
.radio-card span { grid-column: 2; font-size: var(--fs-sm); color: var(--text-muted); }
.radio-card:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }

/* ---------- Messages ---------- */

.notice {
    display: flex; gap: .75rem; padding: .9rem 1rem; margin-bottom: 1.5rem;
    border-radius: var(--radius-sm); border-left: 4px solid; font-size: var(--fs-sm);
}
.notice p { margin: 0; }
.notice ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.notice--success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.notice--error { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.notice--warning { background: var(--warning-bg); border-color: var(--warning); color: var(--warning); }
.notice strong { font-weight: 600; }

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

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
    text-align: left; font-weight: 600; color: var(--text-muted);
    padding: .75rem 1.5rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: .9rem 1.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .muted, .muted { color: var(--text-muted); }

.person { display: flex; align-items: center; gap: .75rem; }
.person .avatar { background: var(--paper); border: 1px solid var(--line); }
.person__name { font-weight: 600; }
.person__email { color: var(--text-muted); }

/* Statuts : forme + texte, jamais la couleur seule */
.status { display: inline-flex; align-items: center; gap: .4rem; font-size: var(--fs-xs); font-weight: 600; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status--ok { color: var(--success); }
.status--warning { color: var(--warning); }
.status--error { color: var(--danger); }
.status--off { color: var(--text-muted); }
.status--off::before { background: transparent; border: 2px solid currentColor; width: 9px; height: 9px; }

.toolbar { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; padding: 1rem 1.5rem; border-bottom: 1px solid var(--line); }
.toolbar .field { flex: 1 1 260px; }
.toolbar .field label { margin-bottom: .3rem; }

/* ---------- Tableau de bord ---------- */

.welcome { padding: 2rem; }
.welcome h2 { font-family: var(--font-display); font-size: var(--fs-xl); }
.welcome > p { color: var(--text-muted); max-width: 60ch; margin-top: .5rem; }

/* Le parcours de mise en route est une vraie séquence : il est numéroté. */
.steps { list-style: none; counter-reset: step; margin: 1.5rem 0 0; padding: 0; display: grid; gap: 1rem; }
.steps li {
    counter-increment: step; position: relative;
    padding: 1rem 1rem 1rem 3.5rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.steps li::before {
    content: counter(step); position: absolute; left: 1rem; top: 1rem;
    width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
    font-size: var(--fs-xs); font-weight: 600; background: var(--paper); border: 1px solid var(--line);
}
.steps li.is-done::before { content: "✓"; background: var(--success); border-color: var(--success); color: #fff; }
.steps li.is-next { border-color: var(--ink); }
.steps h3 { margin-bottom: .25rem; }
.steps p { margin: 0; font-size: var(--fs-sm); color: var(--text-muted); }

.empty { padding: 2.5rem 1.5rem; text-align: left; }
.empty h3 { margin-bottom: .35rem; }
.empty p { color: var(--text-muted); max-width: 55ch; }

/* ---------- Diagnostic ---------- */

.summary { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: center; }
.check-list { list-style: none; margin: 0; padding: 0; }
.check { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) auto; gap: .25rem 1.5rem; padding: .9rem 1.5rem; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.check:last-child { border-bottom: 0; }
.check__label { font-weight: 600; }
.check__detail { color: var(--text-muted); overflow-wrap: anywhere; }
.check__fix { grid-column: 1 / -1; margin: .25rem 0 0; padding: .6rem .8rem; background: var(--paper); border-radius: var(--radius-sm); }

/* ---------- Définitions (fiche) ---------- */

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .6rem 1.5rem; margin: 0; font-size: var(--fs-sm); }
.facts dt { color: var(--text-muted); }
.facts dd { margin: 0; font-weight: 500; }

/* ---------- Pagination ---------- */

.pagination { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; padding: 1rem 1.5rem; border-top: 1px solid var(--line); font-size: var(--fs-sm); }
.pagination__links { display: flex; gap: .5rem; }

/* ---------- Pages d'accès (connexion…) ---------- */

.auth {
    min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem;
    background: var(--paper);
}
.auth__inner { width: 100%; max-width: 420px; }
.auth__brand { display: block; width: 180px; margin: 0 0 2rem; }
.auth__panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; }
.auth__panel h1 { font-size: var(--fs-xl); margin-bottom: .5rem; }
.auth__lead { color: var(--text-muted); margin-bottom: 1.5rem; }
.auth__links { margin-top: 1.5rem; font-size: var(--fs-sm); }
.auth__foot { margin-top: 1.5rem; font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------- Boîte de confirmation ---------- */

dialog.confirm {
    width: min(440px, calc(100vw - 2rem)); padding: 0; border: 1px solid var(--line);
    border-radius: var(--radius); color: var(--text);
}
dialog.confirm::backdrop { background: rgba(19, 32, 74, .45); }
.confirm__body { padding: 1.5rem; }
.confirm__body p { margin: .5rem 0 0; color: var(--text-muted); }
.confirm__actions { display: flex; justify-content: flex-end; gap: .75rem; padding: 1rem 1.5rem; background: var(--paper); border-top: 1px solid var(--line); }

/* ---------- Pages d'erreur ---------- */

.error-page { min-height: 100vh; display: grid; place-items: center; padding: 2rem 1rem; }
.error-page__inner { max-width: 520px; }
.error-page__inner .error-page__code { font-family: var(--font-display); font-size: 4.5rem; line-height: 1; color: var(--orange-strong); margin: 0 0 1rem; font-weight: 600; letter-spacing: -0.03em; }
.error-page__inner p { color: var(--text-muted); }

/* ---------- Petits écrans ---------- */

@media (max-width: 960px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: min(300px, 85vw); z-index: 50;
        transform: translateX(-100%); transition: transform .2s ease;
    }
    .shell.is-menu-open .sidebar { transform: translateX(0); }
    .shell.is-menu-open::after {
        content: ""; position: fixed; inset: 0; z-index: 40; background: rgba(19, 32, 74, .45);
    }
    .topbar {
        display: flex; align-items: center; justify-content: space-between;
        padding: .75rem 1rem; background: var(--ink); position: sticky; top: 0; z-index: 30;
    }
    .topbar img { height: 26px; width: auto; display: block; }
    .menu-button {
        min-height: 44px; padding: .5rem .9rem; border: 1px solid var(--ink-line); border-radius: var(--radius-sm);
        background: transparent; color: #fff; font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
    }
    .menu-button:focus-visible { box-shadow: 0 0 0 2px var(--orange); }
    .content { padding: 1.5rem 1rem 3rem; }
    .grid-2, .form-row { grid-template-columns: minmax(0, 1fr); }
    .check { grid-template-columns: minmax(0, 1fr) auto; }
    .check__detail { grid-column: 1 / -1; grid-row: 2; }
    .table th, .table td { padding-left: 1rem; padding-right: 1rem; }
    .panel__header, .panel__body { padding-left: 1rem; padding-right: 1rem; }
}

@media (max-width: 560px) {
    h1 { font-size: var(--fs-xl); }
    .auth__panel { padding: 1.5rem 1.25rem; }
    .page-header__actions, .page-header__actions .btn { width: 100%; }
    .table--stack thead { display: none; }
    .table--stack tr { display: block; padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
    .table--stack td { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border: 0; }
    .table--stack td[data-label]::before { content: attr(data-label); color: var(--text-muted); font-weight: 500; }
    .table--stack td.num { text-align: right; }
}

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

.error-page__logo { display: block; margin-bottom: 2.5rem; }
.error-page__inner .error-page__message { margin-top: .75rem; }

/* Les cartes de choix gardent leur grille même à l'intérieur d'un .field */
.field .radio-card { display: grid; margin: 0; font-weight: 400; }
.field .radio-card strong { font-weight: 600; }

/* Fond du menu latéral prolongé sur toute la hauteur des pages longues */
@media (min-width: 961px) {
    .shell { background: linear-gradient(to right, var(--ink) var(--sidebar), var(--paper) var(--sidebar)); }
}
.form-stack > .radio-cards { margin-top: 1.5rem; }
.radio-cards legend { margin-bottom: .6rem; }

/* ---------- Lot 2 : tunnels ---------- */

.layout-2-1 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.5rem; align-items: start; margin-top: 1.5rem; }
.layout-2-1 > .panel + .panel { margin-top: 0; }
.stack > * + * { margin-top: 1.5rem; }
.stack > .panel + .panel { margin-top: 1.5rem; }

.row-title { font-weight: 600; text-decoration: none; }
.row-title:hover { text-decoration: underline; }
.mono-ish { font-size: var(--fs-xs); overflow-wrap: anywhere; }
.toolbar .field--narrow { flex: 0 1 220px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .75rem; }

.url-panel .panel__body { padding-top: 1.1rem; padding-bottom: 1.1rem; }
.url-panel__title { font-size: var(--fs-sm); margin-bottom: .5rem; }
.copy-field { display: flex; gap: .75rem; }
.copy-field input {
    flex: 1; min-width: 0; min-height: 44px; padding: .6rem .8rem; font: inherit; font-size: var(--fs-sm);
    color: var(--text); background: var(--paper); border: 1px solid var(--control-line); border-radius: var(--radius-sm);
}

.radio-cards--grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.mini-steps { grid-column: 2; margin: .5rem 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: .35rem; }
.mini-steps li { font-size: var(--fs-xs); padding: .1rem .5rem; border: 1px solid var(--line); border-radius: 999px; color: var(--text-muted); }

/* Liste des étapes : chaque étape est numérotée car l'ordre est celui du parcours */
.step-list { list-style: none; margin: 0; padding: 0; }
.step { border-bottom: 1px solid var(--line); background: var(--surface); }
.step__row { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.5rem .9rem 1rem; }
.step__handle {
    flex: none; width: 14px; height: 22px; cursor: grab; opacity: .55;
    background-image: radial-gradient(circle, var(--text-muted) 1.4px, transparent 1.6px);
    background-size: 7px 7px;
}
.step__number {
    flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
    font-size: var(--fs-xs); font-weight: 600; background: var(--ink); color: #fff;
}
.step:first-child .step__number { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--orange); }
.step__main { flex: 1; min-width: 0; }
.step__name { font-weight: 600; }
.step__meta { font-size: var(--fs-xs); color: var(--text-muted); display: flex; flex-wrap: wrap; gap: .25rem .5rem; align-items: center; }
.step__actions { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
.step--inactive .step__name { color: var(--text-muted); }
.step--inactive .step__number { background: var(--paper); color: var(--text-muted); border: 1px dashed var(--control-line); }
.step.is-dragging { opacity: .5; }
.step.is-drop-target { box-shadow: inset 0 3px 0 var(--orange); }

.icon-btn {
    min-height: 36px; padding: .35rem .6rem; font: inherit; font-size: var(--fs-xs); font-weight: 600;
    color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
    cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.icon-btn:hover { background: var(--paper); }
.icon-btn[disabled] { opacity: .35; cursor: default; }

.step__edit { padding: 0 1.5rem 1rem 3.6rem; }
.step__edit summary { cursor: pointer; font-size: var(--fs-sm); font-weight: 600; color: var(--ink); padding: .25rem 0; }
.step__edit[open] summary { margin-bottom: 1rem; }
.step__delete { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); }

.add-step { padding: 1.25rem 1.5rem 1.5rem; border-top: 1px solid var(--line); background: var(--paper); border-radius: 0 0 var(--radius) var(--radius); }
.add-step h3 { margin-bottom: 1rem; }
.add-step .form-row { margin-bottom: 1rem; }
.field textarea { width: 100%; padding: .6rem .8rem; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--control-line); border-radius: var(--radius-sm); resize: vertical; }

.panel--danger { border-color: #E9B4AE; }
.panel--danger .panel__header h2 { color: var(--danger); }

/* Tableau de bord */
.stats { padding: 1.5rem; }
.stats__list { display: flex; flex-wrap: wrap; margin: 0; }
.stats__item { flex: 1 1 140px; padding: 0 1.5rem; border-left: 1px solid var(--line); }
.stats__item:first-child { padding-left: 0; border-left: 0; }
.stats__item dt { font-size: var(--fs-sm); color: var(--text-muted); }
.stats__item dd { margin: .25rem 0 0; font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.stats__note { margin: 1rem 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.panel + .welcome, .stats + .panel { margin-top: 1.5rem; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .8rem 1.5rem; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.link-list li:last-child { border-bottom: 0; }
.link-list a { font-weight: 600; }

@media (max-width: 960px) {
    .layout-2-1 { grid-template-columns: minmax(0, 1fr); }
    .step__row { flex-wrap: wrap; padding-right: 1rem; }
    .step__actions { width: 100%; justify-content: flex-start; padding-left: 3.4rem; }
    .step__edit { padding-left: 1rem; padding-right: 1rem; }
    .copy-field { flex-direction: column; }
    .stats__item { padding: 0 1rem; }
}

@media (max-width: 560px) {
    .stats__list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stats__item { padding: 0 .75rem; }
    .stats__item dd { font-size: var(--fs-xl); }
}

/* ---------- Lot 3 : accès à l'éditeur depuis la liste des étapes ---------- */
.icon-btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.icon-btn--primary:hover { background: var(--ink-soft); }

/* ---------- Lot 3 (partie 2) : bibliothèque de médias ---------- */
.media-upload input[type="file"] { font: inherit; font-size: var(--fs-sm); max-width: 100%; padding: .4rem 0; }
.media-grid { list-style: none; margin: 0; padding: 1rem 1.5rem 1.5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.media-card { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.media-card > img { width: 100%; height: 150px; object-fit: cover; background: var(--paper); display: block; }
.media-card__body { padding: .75rem; display: grid; gap: .25rem; font-size: var(--fs-sm); }
.media-card__body p { margin: 0; }
.media-card__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-card details { margin-top: .5rem; }
.media-card summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.media-card details[open] summary { margin-bottom: .75rem; }
.media-card__delete { margin-top: .75rem; padding-top: .75rem; border-top: 1px dashed var(--line); }

/* ---------- Lot 4 : bibliothèque de modèles ---------- */
.template-grid { list-style: none; margin: 0; padding: 1rem 1.5rem 1.5rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.template-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.template-card__thumb { position: relative; height: 220px; overflow: hidden; background: var(--paper); border-bottom: 1px solid var(--line); }
.template-card__thumb iframe { position: absolute; top: 0; left: 0; width: 400%; height: 400%; border: 0; transform: scale(.25); transform-origin: 0 0; pointer-events: none; }
.template-card__body { padding: 1rem; display: grid; gap: .5rem; font-size: var(--fs-sm); }
.template-card__body p { margin: 0; }
.template-card__name { margin: 0; font-size: var(--fs-base); }
.template-card__meta { display: flex; flex-wrap: wrap; gap: .4rem .75rem; align-items: center; }
.template-card details { margin-top: .25rem; }
.template-card summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.template-card details[open] summary { margin-bottom: .75rem; }
.template-card__delete { margin-top: .75rem; padding-top: .75rem; border-top: 1px dashed var(--line); }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; background: var(--paper); color: var(--ink); border: 1px solid var(--line); }
.badge--team { background: #FFF1EB; border-color: #F5C2AE; color: #8A3412; }

/* ---------- Lot 5 : prospects ---------- */
.toolbar__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.panel__note { margin: 0; padding: .75rem 1.5rem 0; font-size: var(--fs-sm); }
.panel--narrow { max-width: 760px; }
.submission { padding: 1rem 1.5rem; border-top: 1px solid var(--line); }
.submission__head { margin: 0 0 .5rem; font-size: var(--fs-sm); }
.note-form { display: grid; gap: .75rem; justify-items: start; border-bottom: 1px solid var(--line); }
.note-form .field { width: 100%; }
.timeline { list-style: none; margin: 0; padding: .5rem 1.5rem 1.25rem; }
.timeline li { position: relative; padding: .6rem 0 .6rem 1.25rem; border-left: 2px solid var(--line); margin-left: .35rem; font-size: var(--fs-sm); }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 1rem; width: 10px; height: 10px; border-radius: 50%; background: var(--orange); }
.timeline p { margin: 0; }
.timeline__data { color: var(--text-muted); white-space: pre-line; margin-top: .2rem !important; }
.chips { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .25rem; padding: .2rem .35rem .2rem .7rem; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); font-size: var(--fs-xs); font-weight: 600; }
.chip form { display: inline; }
.chip__remove { border: 0; background: none; cursor: pointer; font-size: 1rem; line-height: 1; padding: .1rem .3rem; border-radius: 50%; color: var(--text-muted); min-width: 24px; min-height: 24px; }
.chip__remove:hover { background: var(--danger-bg); color: var(--danger); }
.inline-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1 1 180px; margin: 0; }
.inline-form input[type="text"] { width: 100%; min-height: 40px; padding: .5rem .7rem; font: inherit; border: 1px solid var(--control-line); border-radius: var(--radius-sm); }
.consent { padding: .6rem 0; border-bottom: 1px dashed var(--line); font-size: var(--fs-sm); }
.consent p { margin: 0; }
.consent--withdrawn strong { color: var(--danger); }
.consent details { margin-top: .25rem; }
.consent summary { cursor: pointer; color: var(--ink); font-size: var(--fs-xs); font-weight: 600; }
.consent__action { margin-top: 1rem; }
.notice--info { background: #EEF2FF; border-color: #3B4BA8; color: #23306E; }

/* ---------- E-mails (lot 7) ---------- */
.subnav { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0 0 1.5rem; border-bottom: 1px solid var(--line); }
.subnav a { padding: .6rem 1rem; color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: var(--fs-sm); border-bottom: 3px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--ink); }
.subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent, var(--ink)); }
.mt { margin-top: 1rem; }
.email-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.email-editor textarea { font-family: inherit; }
.email-preview { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #F4F5F8; position: sticky; top: 1rem; }
.email-preview__bar { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .6rem 1rem; background: var(--paper); border-bottom: 1px solid var(--line); font-size: var(--fs-xs); color: var(--text-muted); }
.email-preview iframe { display: block; width: 100%; height: 640px; border: 0; background: #F4F5F8; }
.var-list { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 0; padding: 0; list-style: none; }
.var-list button { font: inherit; font-size: var(--fs-xs); padding: .2rem .5rem; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); cursor: pointer; }
.var-list button:hover, .var-list button:focus-visible { border-color: var(--ink); }
.cell-error { font-size: var(--fs-xs); color: var(--danger); max-width: 36ch; overflow-wrap: anywhere; }
@media (max-width: 1100px) { .email-editor { grid-template-columns: minmax(0, 1fr); } .email-preview { position: static; } }
.btn--small { padding: .35rem .75rem; font-size: var(--fs-xs); }
.field__label { margin: 0 0 .4rem; font-size: var(--fs-sm); font-weight: 600; }
.panel + .grid-2, .grid-2 + .panel, .email-editor + .panel { margin-top: 1.5rem; }
.grid-2 > .panel + .panel { margin-top: 0; }

/* ---------- Statistiques (lot 8) ---------- */
.segmented { display: inline-flex; flex-wrap: wrap; gap: .25rem; padding: .25rem; margin: 0 0 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.segmented a { padding: .4rem .85rem; border-radius: 7px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
.segmented a:hover { color: var(--ink); background: var(--paper); }
.segmented a[aria-current] { background: var(--ink); color: #fff; }
.panel--pad { padding: 1.25rem 1.5rem; }
.kpis { padding: 1.5rem; }
.kpis__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1.25rem 1.5rem; margin: 0; }
.kpi dt { font-size: var(--fs-sm); color: var(--text-muted); }
.kpi dd { margin: .25rem 0 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: .25rem .6rem; }
.kpi__value { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); }
.kpi__change { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.kpi__change.is-up { color: var(--success); }
.kpi__change.is-down { color: var(--danger); }
.kpi__change span[aria-hidden] { font-size: .7em; }
.kpi__hint { margin: .2rem 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.chart { margin: 0; }
.chart__title { font-weight: 600; margin: 0 0 .75rem; }
.chart__svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart__grid { stroke: var(--line); stroke-width: 1; }
.chart__baseline { stroke: var(--control-line, #9AA3B5); stroke-width: 1; }
.chart__axis { font-size: 11px; fill: var(--text-muted); font-family: inherit; }
.chart__mark { fill: #3B4BA8; }
.chart__hit { fill: transparent; }
.chart__bar:hover .chart__mark { fill: var(--ink); }
.chart__empty { margin: 0; padding: 2rem 0; color: var(--text-muted); text-align: center; }
.chart__table { margin-top: .75rem; font-size: var(--fs-sm); }
.chart__table summary, .definitions summary { cursor: pointer; font-weight: 600; }
.chart__table .table-wrap { max-height: 320px; overflow-y: auto; margin-top: .5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.5rem; }
.panel + .grid-3, .grid-3 + .panel, .grid-3 + details.panel, .panel + details.panel { margin-top: 1.5rem; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: .25rem 1rem; padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.bar-row:last-child { border-bottom: 0; }
.bar-row strong { font-variant-numeric: tabular-nums; }
.meter { grid-column: 1 / -1; width: 100%; height: 6px; display: block; }
.meter__track { fill: var(--paper); }
.meter__fill { fill: #3B4BA8; }
tr.is-muted td { color: var(--text-muted); }
.definitions .facts { grid-template-columns: minmax(140px, max-content) 1fr; }
@media (max-width: 1000px) { .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.grid-2--wide { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.kpis + .grid-2, .grid-2 + .stats, .segmented + .kpis { margin-top: 1.5rem; }
.segmented + .kpis { margin-top: 0; }
@media (max-width: 1000px) { .grid-2--wide { grid-template-columns: minmax(0, 1fr); } }
.grid-2 { align-items: start; }
.panel + .grid-2 > .panel { margin-top: 0; }
.chart__scroll { overflow-x: auto; }
@media (max-width: 640px) {
    .kpis__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
    .kpi__value { font-size: var(--fs-xl, 1.4rem); }
    .chart__svg { min-width: 560px; }
}

/* ---------- Administration (lot 9) ---------- */
.panel__footer--split { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form input[type="password"] { max-width: 220px; padding: .45rem .6rem; border: 1px solid var(--control-line); border-radius: 6px; font: inherit; }
.inline-confirm summary { cursor: pointer; }
.inline-confirm[open] .inline-form { margin-top: .5rem; }
.plain-list { margin: 0; padding-left: 1.1rem; font-size: var(--fs-sm); }
.log-list { list-style: none; margin: 0; padding: 0; }
.log-entry { padding: .85rem 1.5rem; border-bottom: 1px solid var(--line); border-left: 4px solid var(--line); }
.log-entry--error { border-left-color: var(--danger); }
.log-entry--warning { border-left-color: var(--warning); }
.log-entry__head { margin: 0 0 .25rem; font-size: var(--fs-xs); }
.log-entry__msg { margin: 0; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.log-entry pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-xs); max-height: 320px; overflow: auto; background: var(--paper); padding: .75rem; border-radius: 6px; }
.grid-2 + .panel { margin-top: 1.5rem; }
.grid-2 { row-gap: 1.5rem; }
/* Cibles tactiles (lot 10) : 44 px de haut pour les boutons principaux, 32 px pour les petits boutons. */
.btn { min-height: 44px; }
.btn--small { min-height: 32px; }
