/* =====================================================================
   Suivi CRT 78/5 — design system
   Jetons → base → coque (sidebar, topbar) → composants → vues → responsive
   ===================================================================== */

:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --bg-sunken: #eef1f5;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --ink: #0f1a2a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e3e8ef;
  --line-strong: #cfd7e2;
  --brand: #1f3a68;
  --brand-2: #284b85;
  --brand-ink: #ffffff;
  --brand-soft: #e8eef8;
  --accent: #2563eb;
  --accent-soft: #e8f0fe;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fdf3e2;
  --bad: #c62828;
  --bad-soft: #fdecec;
  --info: #0369a1;
  --info-soft: #e5f3fb;
  --soft: #f1f4f8;
  --hover: #f3f6fa;
  --sidebar-bg: #0f1f3a;
  --sidebar-ink: #c9d4e6;
  --sidebar-ink-strong: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, .07);
  --sidebar-active: rgba(255, 255, 255, .12);
  --shadow-xs: 0 1px 2px rgba(15, 26, 42, .05);
  --shadow: 0 1px 3px rgba(15, 26, 42, .06), 0 1px 2px rgba(15, 26, 42, .04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 26, 42, .22), 0 4px 10px -4px rgba(15, 26, 42, .1);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --sidebar-w: 248px;
  --topbar-h: 58px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1220; --bg-sunken: #080e1a; --panel: #111a2b; --panel-2: #0f1727;
    --ink: #e6ecf5; --ink-2: #c3cddc; --muted: #8b9ab0; --faint: #5f6e86;
    --line: #1f2a3e; --line-strong: #2b3953;
    --brand: #5b8bd9; --brand-2: #6f9be0; --brand-ink: #0b1220; --brand-soft: #16233b;
    --accent: #6ea0ff; --accent-soft: #15284a;
    --ok: #4ade80; --ok-soft: #0f2a1b; --warn: #f5b04a; --warn-soft: #2d2210;
    --bad: #f87171; --bad-soft: #321517; --info: #5cc2f2; --info-soft: #0e2638;
    --soft: #162135; --hover: #152033;
    --sidebar-bg: #070d18; --sidebar-ink: #a8b6cc; --sidebar-hover: rgba(255,255,255,.05); --sidebar-active: rgba(110,160,255,.14);
    --shadow-xs: none; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 40px -8px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220; --bg-sunken: #080e1a; --panel: #111a2b; --panel-2: #0f1727;
  --ink: #e6ecf5; --ink-2: #c3cddc; --muted: #8b9ab0; --faint: #5f6e86;
  --line: #1f2a3e; --line-strong: #2b3953;
  --brand: #5b8bd9; --brand-2: #6f9be0; --brand-ink: #0b1220; --brand-soft: #16233b;
  --accent: #6ea0ff; --accent-soft: #15284a;
  --ok: #4ade80; --ok-soft: #0f2a1b; --warn: #f5b04a; --warn-soft: #2d2210;
  --bad: #f87171; --bad-soft: #321517; --info: #5cc2f2; --info-soft: #0e2638;
  --soft: #162135; --hover: #152033;
  --sidebar-bg: #070d18; --sidebar-ink: #a8b6cc; --sidebar-hover: rgba(255,255,255,.05); --sidebar-active: rgba(110,160,255,.14);
  --shadow-xs: none; --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 40px -8px rgba(0,0,0,.6);
}

/* ---------- Base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font: 14px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; color: var(--ink); letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
h4 { font-size: .9rem; font-weight: 600; color: var(--ink-2); }
p { margin: 0 0 .5rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, kbd { font-family: var(--mono); font-size: .85em; }
kbd { border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 .3rem; background: var(--panel); color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
::selection { background: var(--accent-soft); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .82rem; }
.tiny { font-size: .74rem; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.error { color: var(--bad); min-height: 1.2em; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Icônes */
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 22px; height: 22px; }

/* ---------- Boutons */
button, input, select, textarea { font: inherit; color: inherit; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--panel); color: var(--ink-2);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: .42rem .8rem; min-height: 34px;
  font-weight: 500; font-size: .88rem; line-height: 1.2;
  cursor: pointer; box-shadow: var(--shadow-xs);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
  white-space: nowrap; text-decoration: none;
}
button:hover, .btn:hover { background: var(--hover); border-color: var(--faint); color: var(--ink); text-decoration: none; }
button:active { transform: translateY(1px); }
button.primary, .btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 1px 2px rgba(31, 58, 104, .25); }
button.primary:hover, .btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
:root[data-theme="dark"] button.primary, :root[data-theme="dark"] .btn.primary { color: var(--brand-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button.primary { color: var(--brand-ink); } }
button.quiet, .btn.quiet { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
button.quiet:hover { background: var(--hover); color: var(--ink); border-color: transparent; }
button.danger { color: var(--bad); }
button.danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
button.danger.primary { background: var(--bad); border-color: var(--bad); color: #fff; }
button.mini { padding: .15rem .5rem; min-height: 26px; font-size: .78rem; border-radius: 5px; }
button.icon-btn { padding: .35rem; min-height: 34px; min-width: 34px; }
button:disabled, button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn-group { display: inline-flex; }
.btn-group > button { border-radius: 0; margin-left: -1px; }
.btn-group > button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group > button:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ---------- Formulaires */
input, select, textarea {
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: .45rem .65rem; max-width: 100%; min-height: 34px; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 1rem; height: 1rem; accent-color: var(--accent); padding: 0; box-shadow: none; }
input[type="search"] { padding-left: 2.1rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: .65rem center; background-size: 16px; }
select { padding-right: 2rem; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .55rem center; background-size: 16px; }
textarea { width: 100%; min-height: 5rem; resize: vertical; line-height: 1.5; }
label { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; font-weight: 500; color: var(--ink-2); }
label input, label select, label textarea { font-weight: 400; font-size: .9rem; }
.check { display: flex; flex-direction: row; gap: .55rem; align-items: center; color: var(--ink); font-size: .9rem; font-weight: 400; cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .85rem 1rem; }
.form .full { grid-column: 1 / -1; }
.hint { font-size: .76rem; color: var(--muted); font-weight: 400; }
fieldset.options { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem 1rem; margin: 0; background: var(--panel-2); }
fieldset.options legend { font-size: .78rem; font-weight: 600; color: var(--muted); padding: 0 .35rem; text-transform: uppercase; letter-spacing: .04em; }

/* Interrupteur */
.switch { position: relative; display: inline-flex; align-items: center; gap: .55rem; flex-direction: row; cursor: pointer; font-size: .9rem; color: var(--ink); font-weight: 400; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 99px; background: var(--line-strong); border: 0; position: relative; transition: background .15s; cursor: pointer; min-height: 0; padding: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s var(--ease); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }

/* ---------- Mise en page générique */
.panel, .card-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.panel > h3:first-child, .panel > h4:first-child { margin-bottom: .75rem; }
.panel.flush { padding: 0; overflow: hidden; }
.panel.tight { padding: .75rem .9rem; }
.panel-head { display: flex; align-items: center; gap: .75rem; justify-content: space-between; margin: -.1rem 0 .85rem; flex-wrap: wrap; }
.panel-head h3 { margin: 0; }
.panel.flush > .panel-head { padding: .9rem 1.1rem; margin: 0; border-bottom: 1px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack.sm { gap: .5rem; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.tools { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: .9rem; }
.tools label { min-width: 150px; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.sidebar-right { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

/* ---------- En-tête de page */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .25rem; }
.page-head .titles { min-width: 0; }
.page-head h2 { margin: 0; font-size: 1.45rem; }
.page-head .subtitle { color: var(--muted); margin: .2rem 0 0; font-size: .9rem; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { display: flex; gap: .35rem; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--ink); }

/* ---------- KPI */
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.tiles { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.kpi { display: flex; flex-direction: column; gap: .25rem; cursor: default; position: relative; overflow: hidden; }
.kpi > span:first-child, .kpi .kpi-label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.kpi strong { font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .kpi-foot { font-size: .78rem; color: var(--muted); }
.kpi.link { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s var(--ease); }
.kpi.link:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.kpi.bad { box-shadow: inset 3px 0 0 var(--bad), var(--shadow); }
.kpi.bad strong { color: var(--bad); }
.kpi.warn { box-shadow: inset 3px 0 0 var(--warn), var(--shadow); }
.kpi.warn strong { color: var(--warn); }
.kpi.good { box-shadow: inset 3px 0 0 var(--ok), var(--shadow); }
.kpi .kpi-icon { position: absolute; right: .9rem; top: .9rem; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }

/* ---------- Pastilles */
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  border-radius: 99px; padding: .1rem .55rem; font-size: .74rem; font-weight: 550;
  background: var(--soft); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap; line-height: 1.5;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; display: none; }
.chip.ok, .chip.bon, .chip.termine, .chip.repondu, .chip.publie, .chip.applique, .chip.envoye, .chip.disponible, .chip.piece_recue, .chip.good { color: var(--ok); background: var(--ok-soft); }
.chip.nok, .chip.critique, .chip.urgente, .chip.late, .chip.echec, .chip.erreur, .chip.depart, .chip.indisponible, .chip.bad { color: var(--bad); background: var(--bad-soft); }
.chip.a_renouveler, .chip.attention, .chip.haute, .chip.attente, .chip.attente_agent, .chip.attente_srj, .chip.attente_cdu, .chip.en_attente, .chip.planifie, .chip.sas, .chip.apercu, .chip.warn { color: var(--warn); background: var(--warn-soft); }
.chip.origin, .chip.info, .chip.en_cours, .chip.envoi, .chip.ouvert, .chip.arrivee, .chip.esr, .chip.vmp, .chip.mas, .chip.nouveau { color: var(--accent); background: var(--accent-soft); }
.chip.ok::before, .chip.bad::before, .chip.warn::before, .chip.dot::before { display: inline-block; }
.chip.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
button.chip { cursor: pointer; min-height: 0; padding: .2rem .65rem; box-shadow: none; border: 1px solid var(--line-strong); background: var(--panel); }
button.chip:hover { border-color: var(--accent); color: var(--accent); }
button.chip.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
.count { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem; border-radius: 99px; background: var(--bad); color: #fff; font-size: .7rem; font-weight: 700; line-height: 1; }

/* ---------- Avatar */
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); font-weight: 650; font-size: .78rem; letter-spacing: .02em; }
.avatar.sm { width: 24px; height: 24px; font-size: .65rem; }
.avatar.lg { width: 48px; height: 48px; font-size: 1rem; }

/* ---------- Tables */
.tablewrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); max-width: 100%; }
.panel .tablewrap { box-shadow: none; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .87rem; }
th, td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: var(--panel-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--hover); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
tr.click { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.matrix td, .matrix th { text-align: center; padding: .35rem .45rem; white-space: nowrap; }
.matrix td:first-child, .matrix th:first-child { text-align: left; }

/* ---------- Listes */
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list > li { padding: .7rem .5rem; border-bottom: 1px solid var(--line); display: flex; gap: .7rem; align-items: flex-start; flex-wrap: wrap; border-radius: 0; }
.list > li:last-child { border-bottom: 0; }
.list > li.click { cursor: pointer; transition: background .1s; }
.list > li.click:hover { background: var(--hover); }
.list > li.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.list .grow { flex: 1 1 160px; min-width: 140px; }
.list input[type="checkbox"] { width: 1.05rem; height: 1.05rem; margin-top: .15rem; }

/* ---------- Onglets */
.tabs { display: flex; gap: .15rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: .25rem; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; box-shadow: none; color: var(--muted); padding: .55rem .85rem; margin-bottom: -1px; font-weight: 550; }
.tabs button:hover { color: var(--ink); background: none; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--accent); color: var(--ink); }
.segmented { display: inline-flex; background: var(--soft); padding: 3px; border-radius: 8px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented > button { flex-shrink: 0; white-space: nowrap; }
.segmented button { border: 0; background: transparent; box-shadow: none; min-height: 28px; padding: .25rem .7rem; color: var(--muted); }
.segmented button[aria-pressed="true"], .segmented button.sel { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }

/* ---------- États vides & chargement */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .4rem; padding: 2.5rem 1rem; color: var(--muted); }
.empty .empty-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--soft); color: var(--faint); margin-bottom: .35rem; }
.empty h4 { margin: 0; color: var(--ink); font-size: .95rem; }
.empty p { margin: 0; max-width: 42ch; font-size: .86rem; }
.empty .row { margin-top: .6rem; justify-content: center; }
.skeleton { display: block; border-radius: 6px; background: linear-gradient(90deg, var(--soft) 25%, var(--hover) 37%, var(--soft) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; min-height: 14px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Callouts */
.notice, .callout { padding: .75rem 1rem; border-radius: var(--radius); background: var(--info-soft); border: 1px solid transparent; color: var(--ink-2); display: flex; gap: .6rem; align-items: flex-start; }
.notice { margin: 1rem 1.75rem 0; }
.notice.err, .callout.bad { background: var(--bad-soft); color: var(--bad); }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.callout.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- Progression & graphiques */
.progress { height: 6px; background: var(--soft); border-radius: 99px; overflow: hidden; min-width: 70px; flex: 1; }
.progress > i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width .4s var(--ease); }
.bar { display: grid; grid-template-columns: 160px 1fr 48px; gap: .65rem; align-items: center; margin: .3rem 0; font-size: .84rem; }
.bar .track { height: 10px; background: var(--soft); border-radius: 99px; overflow: hidden; }
.bar .track > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar .num { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.chart { width: 100%; height: auto; }
.chart .a { fill: var(--accent); } .chart .b { fill: var(--ok); }
.chart .axis { stroke: var(--line); } .chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--muted); }
.dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }
.dot.a { background: var(--accent); } .dot.b { background: var(--ok); }

/* ---------- Frise */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--line); }
.timeline li { padding: .45rem 0 .45rem .7rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -1.53rem; top: .85rem; width: .65rem; height: .65rem; border-radius: 50%; background: var(--panel); border: 2px solid var(--accent); }

/* ---------- Kanban */
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: .9rem; align-items: start; }
.col { background: var(--bg-sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem; display: flex; flex-direction: column; gap: .55rem; min-height: 140px; }
.col > h3, .col > h4 { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: .15rem .2rem .2rem; display: flex; justify-content: space-between; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .65rem .75rem; display: flex; flex-direction: column; gap: .35rem; box-shadow: var(--shadow-xs); transition: box-shadow .15s, border-color .15s; }
.card:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.col.over { outline: 2px dashed var(--accent); outline-offset: -4px; }
.card[draggable="true"] { cursor: grab; }
.card.dragging { opacity: .4; }
.done { text-decoration: line-through; color: var(--muted); }

/* ---------- Matrice d'aptitudes */
.cell { display: inline-block; min-width: 1.7rem; border-radius: 5px; padding: .05rem .35rem; font-size: .75rem; border: 1px solid var(--line); cursor: pointer; background: none; min-height: 0; box-shadow: none; }
.cell.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.cell.nok { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.cell.a_renouveler { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.cell.has { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Courrier */
.mailgrid { grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); align-items: stretch; height: calc(100dvh - var(--topbar-h) - 9.5rem); min-height: 520px; }
.mailgrid > * { min-width: 0; min-height: 0; }
.mx-list, .mx-detail { display: flex; flex-direction: column; overflow: hidden; }
.mx-list-head { padding: 1rem 1rem .8rem; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: .7rem; }
.mx-title { display: flex; align-items: center; gap: .5rem; }
.mx-title h3 { margin: 0; font-size: 1rem; }
.mx-title .grow, .mx-listbar .grow, .mx-bulk .grow, .mx-adv-tools .grow { flex: 1; }
.mx-count { display: inline-grid; place-items: center; min-width: 22px; font-size: .72rem; font-weight: 600; color: var(--muted); background: var(--soft); border-radius: 99px; padding: .05rem .45rem; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.mx-filter-toggle { gap: .35rem; }
.mx-filter-toggle[aria-expanded="true"], .mx-filter-toggle[aria-expanded="true"]:hover { background: var(--accent-soft); color: var(--accent); }
.mx-badge { min-width: 17px; height: 17px; border-radius: 99px; background: var(--accent); color: #fff; font-size: .66rem; font-weight: 650; display: inline-grid; place-items: center; padding: 0 .3rem; }
.mx-badge[hidden] { display: none; }
.mx-scope { width: 100%; }
.mx-scope button { flex: 1; font-size: .82rem; }
.mx-search { position: relative; }
.mx-search .icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.mx-search input { width: 100%; padding-left: 2.1rem; }
.mx-bal .mx-search { display: flex; gap: .5rem; }
.mx-bal .mx-search input { flex: 1; min-width: 0; width: 0; }
.mx-bal .mx-search button { flex: none; }
.mx-pills { display: flex; flex-wrap: wrap; gap: .35rem; }
button.mx-pill { min-height: 26px; padding: .15rem .65rem; font-size: .76rem; font-weight: 500; border-radius: 99px; background: var(--panel); border: 1px solid var(--line-strong); box-shadow: none; color: var(--ink-2); }
button.mx-pill:hover { background: var(--panel); border-color: var(--accent); color: var(--accent); }
button.mx-pill[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.mx-advanced { display: flex; flex-direction: column; gap: .6rem; padding: .75rem; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.mx-advanced[hidden] { display: none; }
.mx-adv-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; }
.mx-adv-grid label { font-size: .72rem; }
.mx-adv-grid select { width: 100%; min-width: 0; font-size: .82rem; }
.mx-adv-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; }
.mx-adv-tools > .row { flex: 1 1 auto; flex-wrap: nowrap; gap: .15rem; }
.mx-adv-tools > .row:first-child > button > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mx-adv-tools > .row:last-child { flex: none; margin-left: auto; }
.mx-adv-tools button { background: transparent; border-color: transparent; box-shadow: none; }
.mx-adv-tools button:hover { background: var(--hover); }
.mx-adv-tools select { font-size: .8rem; max-width: 150px; }
.mx-adv-tools button { min-height: 28px; white-space: nowrap; padding: .15rem .5rem; font-size: .78rem; }
.mx-listbar { display: flex; align-items: center; gap: .6rem; padding: .45rem 1rem; border-bottom: 1px solid var(--line); font-size: .78rem; color: var(--muted); }
.mx-listbar input { width: 1rem; height: 1rem; }
.mx-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: .6rem .75rem .1rem; padding: .45rem .6rem; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-sm); font-size: .8rem; color: var(--ink); }
.mx-bulk[hidden] { display: none; }
.mx-bulk-assign { display: inline-flex; gap: .3rem; align-items: center; }
.mx-bulk select { font-size: .78rem; min-height: 26px; padding: .1rem 1.6rem .1rem .45rem; max-width: 140px; }
.mx-scroll { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.mx-items { list-style: none; margin: 0; padding: 0; }
.mx-item { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: .7rem; align-items: start; padding: .75rem 1rem; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .1s; outline: none; }
.mx-item.mx-bal-item { grid-template-columns: auto minmax(0, 1fr); }
.mx-bal-item .mx-meta { flex-wrap: wrap; }
.mx-item:hover { background: var(--hover); }
.mx-item:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.mx-item.sel { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.mx-item input[type="checkbox"] { width: 1rem; height: 1rem; margin: .5rem 0 0; }
.mx-avatar { position: relative; display: inline-flex; }
.mx-dot { position: absolute; left: -3px; top: -2px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--panel); }
.mx-main { min-width: 0; display: flex; flex-direction: column; gap: .12rem; }
.mx-line { display: flex; align-items: baseline; gap: .5rem; }
.mx-who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; font-weight: 500; color: var(--ink-2); }
.mx-date { flex: none; font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mx-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; color: var(--ink-2); }
.mx-item.pending .mx-who { font-weight: 650; color: var(--ink); }
.mx-item.pending .mx-subject { font-weight: 550; color: var(--ink); }
.mx-item.pending .mx-date { color: var(--accent); font-weight: 600; }
.mx-item.treated .mx-who, .mx-item.treated .mx-subject { color: var(--muted); }
.mx-meta { display: flex; align-items: center; gap: .35rem; min-width: 0; margin-top: .25rem; }
.mx-meta .chip { flex: none; font-size: .68rem; padding: .05rem .45rem; }
.mx-agents { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .74rem; color: var(--muted); }
.mx-agents.none { color: var(--faint); font-style: italic; }
.mx-assignee { flex: none; }
.mx-none { list-style: none; }
.mx-foot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem .75rem .45rem 1rem; border-top: 1px solid var(--line); background: var(--panel-2); }
.mx-foot .row { gap: .25rem; }
.flip-icon .icon { transform: scaleX(-1); }
.mx-detail-head { padding: .85rem 1.25rem 1rem; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: .65rem; }
.mx-head-top { display: flex; align-items: center; gap: .5rem; min-height: 34px; }
.mx-states { flex: 1; display: flex; flex-wrap: wrap; gap: .35rem; }
.mx-detail-head h3 { margin: 0; font-size: 1.15rem; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; }
.mx-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.mx-back { display: none; }
.mx-detail-body { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 0 1.25rem 1rem; }
.mx-loading { display: flex; flex-direction: column; gap: .8rem; padding-top: 1.25rem; }
.mx-section { display: flex; flex-direction: column; gap: .6rem; padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.mx-section:last-child { border-bottom: 0; }
.mx-section-title { display: flex; align-items: center; gap: .45rem; margin: 0; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.mx-section > .list > li { padding-left: 0; padding-right: 0; }
.mx-from { display: flex; align-items: center; gap: .7rem; }
.mx-from-id { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mx-from-id > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-spoof { color: var(--bad); }
.mx-to { font-size: .84rem; color: var(--ink-2); overflow-wrap: anywhere; }
.mx-to.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mx-more { align-self: flex-start; }
.mx-meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.mx-meta-grid select { width: 100%; }
.mx-detail .mailbody { max-height: none; font-size: .92rem; line-height: 1.6; }
.mx-detail details summary { cursor: pointer; font-size: .85rem; color: var(--ink-2); margin-bottom: .5rem; }
.mx-files { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .5rem; }
.mx-files li { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); font-size: .82rem; }
.mx-files .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mx-files .grow strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.mx-add { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.mx-add input { width: 180px; }
.mx-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem; padding: 2rem; }
.mx-keys { margin: 0; font-size: .8rem; color: var(--muted); }
.mailbody { white-space: pre-wrap; word-break: break-word; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; max-height: 420px; overflow: auto; font-size: .87rem; line-height: 1.6; }
.drawer-close { display: none; }

/* ---------- Calendrier */
.calendar { table-layout: fixed; }
.calendar td { vertical-align: top; height: 104px; min-width: 110px; border: 1px solid var(--line); padding: .35rem; }
.calendar td.today { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.calendar .chip { font-size: .68rem; padding: 0 .4rem; overflow: hidden; text-overflow: ellipsis; max-width: 100%; display: block; margin-top: 2px; }

/* ---------- Modales */
.modal-back { position: fixed; inset: 0; background: rgba(8, 14, 26, .5); backdrop-filter: blur(2px); display: grid; place-items: center; padding: 1rem; z-index: 50; animation: fade .15s ease; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.3rem 1.4rem; width: min(600px, 100%); max-height: 90vh; overflow: auto; display: flex; flex-direction: column; gap: .9rem; box-shadow: var(--shadow-lg); animation: pop .18s var(--ease); }
.modal.wide { width: min(900px, 100%); }
.modal > h3:first-child { font-size: 1.1rem; margin: 0; }
.modal > .row:last-child { justify-content: flex-end; padding-top: .5rem; border-top: 1px solid var(--line); margin-top: .25rem; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.985); } }

/* ---------- Notifications (toasts) */
#toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; display: flex; flex-direction: column; gap: .55rem; z-index: 60; max-width: min(400px, calc(100vw - 2rem)); }
.toast { display: flex; gap: .6rem; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .8rem .65rem .9rem; box-shadow: var(--shadow-lg); animation: pop .2s var(--ease); position: relative; overflow: hidden; }
.toast::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--ok); }
.toast.err::before { background: var(--bad); }
.toast.err { color: var(--bad); }

/* ---------- Connexion */
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, 1fr); background: var(--panel); }
#password-required, #totp-required { grid-template-columns: 1fr; }
.totp-qr { width: 200px; height: 200px; padding: 8px; background: #fff; border-radius: 8px; image-rendering: pixelated; align-self: center; }
.totp-secret { font-family: ui-monospace, monospace; word-break: break-all; user-select: all; }
.recovery-codes { font-family: ui-monospace, monospace; columns: 2; gap: 1.5rem; margin: 0; padding-left: 1.2rem; }
.login-aside { background: radial-gradient(120% 90% at 0% 0%, #2b5296 0%, #142a4f 45%, #0b1730 100%); color: #dbe5f5; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-aside::after { content: ""; position: absolute; inset: auto -20% -35% auto; width: 520px; height: 520px; border-radius: 50%; border: 1px solid rgba(255,255,255,.08); box-shadow: 0 0 0 60px rgba(255,255,255,.025), 0 0 0 120px rgba(255,255,255,.02); }
.login-aside h1 { color: #fff; font-size: 2rem; max-width: 18ch; margin-top: 2rem; }
.login-aside p { color: #b6c6e0; max-width: 42ch; font-size: .95rem; }
.login-aside ul { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .65rem; color: #c9d6ec; font-size: .9rem; }
.login-aside li { display: flex; gap: .6rem; align-items: center; }
.login-main { display: grid; place-items: center; padding: 2rem 1.25rem; background: var(--bg); }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: .9rem; padding: 2rem; }
.login-card h2 { margin: 0; }
.login-card button.primary { min-height: 40px; margin-top: .3rem; }
.brand-mark { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: linear-gradient(135deg, #3a69b8, #1f3a68); color: #fff; font-weight: 800; font-size: .8rem; letter-spacing: .02em; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); flex: none; }

/* ---------- Coque de l'application */
#application { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
#sidebar { background: var(--sidebar-bg); color: var(--sidebar-ink); padding: .9rem .7rem; display: flex; flex-direction: column; gap: .75rem; position: sticky; top: 0; height: 100vh; overflow: hidden; z-index: 40; }
#sidebar .muted { color: rgba(201, 212, 230, .6); }
.brand { display: flex; align-items: center; gap: .7rem; padding: .35rem .45rem .7rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand strong { color: var(--sidebar-ink-strong); font-size: .98rem; display: block; line-height: 1.2; }
.brand span { font-size: .75rem; }
#nav { display: flex; flex-direction: column; gap: .1rem; overflow-y: auto; flex: 1; margin: 0 -.3rem; padding: 0 .3rem; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.12) transparent; }
.nav-section { display: flex; flex-direction: column; margin-bottom: .5rem; }
.nav-links { display: flex; flex-direction: column; gap: 1px; }
#nav a { color: var(--sidebar-ink); text-decoration: none; padding: .45rem .6rem; border-radius: 7px; display: flex; align-items: center; gap: .65rem; font-size: .875rem; font-weight: 500; transition: background .12s, color .12s; position: relative; }
#nav a .icon { opacity: .75; }
#nav a .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-ink-strong); }
#nav a[aria-current="page"] { background: var(--sidebar-active); color: var(--sidebar-ink-strong); }
#nav a[aria-current="page"]::before { content: ""; position: absolute; left: -.7rem; top: 22%; bottom: 22%; width: 3px; border-radius: 0 3px 3px 0; background: #7aa7ff; }
#nav a[aria-current="page"] .icon { opacity: 1; }
#nav .count { font-size: .68rem; }
button.nav-group { background: none; border: 0; box-shadow: none; color: rgba(201, 212, 230, .5); justify-content: space-between; text-transform: uppercase; letter-spacing: .08em; font-size: .67rem; font-weight: 650; padding: .55rem .6rem .3rem; min-height: 0; width: 100%; }
button.nav-group:hover { background: none; color: var(--sidebar-ink); }
button.nav-group::after { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); transition: transform .15s; margin-right: .2rem; }
button.nav-group[aria-expanded="false"]::after { transform: rotate(-45deg); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: .6rem; padding: .7rem .45rem .2rem; border-top: 1px solid rgba(255,255,255,.07); }
.side-foot .avatar { background: rgba(122, 167, 255, .16); color: #cfe0ff; }
.side-foot .who { flex: 1; min-width: 0; font-size: .8rem; line-height: 1.3; }
.side-foot .who strong { color: var(--sidebar-ink-strong); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.side-foot .who span { color: rgba(201, 212, 230, .6); font-size: .72rem; }
.side-foot button { color: var(--sidebar-ink); border: 0; background: transparent; box-shadow: none; padding: .35rem; min-height: 0; }
.side-foot button:hover { background: var(--sidebar-hover); color: #fff; }

#content { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; gap: .6rem; align-items: center; padding: 0 1.75rem; height: var(--topbar-h); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.6) blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar #global-search { max-width: 520px; }
.topbar input[type="search"] { width: 100%; background-color: var(--panel); border-color: var(--line); min-height: 36px; }
.topbar .chip { cursor: pointer; }
.topbar button.quiet { color: var(--muted); }
#view { padding: 1.5rem 1.75rem 3rem; display: flex; flex-direction: column; gap: 1.15rem; outline: none; max-width: 1500px; width: 100%; margin: 0 auto; animation: viewin .22s var(--ease); }
@keyframes viewin { from { opacity: 0; transform: translateY(4px); } }
#view.loading { opacity: .6; transition: opacity .2s; pointer-events: none; }
#view.loading::before { content: ""; position: fixed; top: 0; left: 0; right: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: slide 1s linear infinite; z-index: 70; }
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* Panneau de notifications */
#notifications { position: relative; }
#notifications-bell { position: relative; }
#notifications-bell .count { position: absolute; top: 1px; right: 0; transform: scale(.85); }
#notifications-panel { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, 88vw); max-height: 65vh; overflow-y: auto; z-index: 45; box-shadow: var(--shadow-lg); padding: .9rem; animation: pop .15s var(--ease); }
.palette { max-height: 52vh; overflow: auto; }
.palette li.sel, .palette li:focus { background: var(--accent-soft); }

/* ---------- Organigramme */
.org-tree { display: flex; flex-direction: column; gap: .75rem; }
.org-unit { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow-xs); }
.org-unit > header { display: flex; align-items: center; gap: .65rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); background: var(--panel-2); border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
.org-unit > header h3 { margin: 0; font-size: .95rem; }
.org-unit > .org-body { padding: .75rem .9rem; display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.org-children { margin: 0 0 .75rem 1.4rem; padding-left: 1rem; border-left: 2px dashed var(--line-strong); display: flex; flex-direction: column; gap: .75rem; }
.org-children:empty { display: none; }
.post { display: flex; gap: .65rem; align-items: center; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); transition: border-color .15s, box-shadow .15s; }
.post:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.post .post-title { font-size: .74rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.post .post-holder { font-weight: 600; font-size: .9rem; }
.post.vacant { border-style: dashed; background: var(--warn-soft); }
.post.vacant .post-holder { color: var(--warn); }
.post.chef { box-shadow: inset 3px 0 0 var(--brand); }

/* ---------- Constructeur de formulaires */
.q-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .65rem; box-shadow: var(--shadow-xs); position: relative; }
.q-card.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.q-card .q-num { font-size: .72rem; font-weight: 700; color: var(--muted); }
.q-opts { display: flex; flex-direction: column; gap: .35rem; }
.q-opts .row input[type="text"], .q-opts .row input:not([type]) { flex: 1; }
.form-preview { background: var(--bg-sunken); border-radius: var(--radius); padding: 1rem; }
.form-preview .q-card { box-shadow: none; }
.signature-preview { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 1rem 1.1rem; background: #fff; color: #222; }

/* ---------- Divers */
.only-mobile { display: none !important; }
.kbd-hint { display: inline-flex; gap: .2rem; align-items: center; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .88rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.today-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.rule-editor h4 { margin-top: .5rem; }

/* ---------- Responsive */
@media (max-width: 1100px) {
  .grid.sidebar-right { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  #application { grid-template-columns: 1fr; }
  #sidebar { position: fixed; inset: 0 auto 0 0; width: 272px; transform: translateX(-105%); transition: transform .2s var(--ease); box-shadow: var(--shadow-lg); z-index: 55; }
  #sidebar.open { transform: none; }
  .only-mobile { display: inline-flex !important; }
  .topbar { padding: 0 .85rem; }
  .topbar .hide-mobile { display: none; }
  #view { padding: 1rem .85rem 2.5rem; }
  .notice { margin: .75rem .85rem 0; }
  .mailgrid { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .mailgrid.has-detail > .list-pane, .mailgrid:not(.has-detail) > .mx-detail { display: none; }
  .mx-scroll, .mx-detail-body { overflow: visible; }
  .mx-back { display: inline-flex; }
  .mx-close { display: none; }
  .mx-meta-grid, .mx-adv-grid { grid-template-columns: 1fr; }
  .drawer-close { display: inline-flex; }
  .bar { grid-template-columns: 110px 1fr 40px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .split { grid-template-columns: 1fr; }
  #toasts { left: .85rem; right: .85rem; bottom: .85rem; max-width: none; }
  .page-head h2 { font-size: 1.25rem; }
  .org-children { margin-left: .5rem; padding-left: .6rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print {
  #sidebar, .topbar, button, #toasts { display: none !important; }
  #application { display: block; }
  body { background: #fff; }
  .panel { box-shadow: none; break-inside: avoid; }
  th { position: static; }
  tr { break-inside: avoid; }
}

/* Organigramme, formulaires et relances */
.dot.brand { background: var(--brand); } .dot.warn { background: var(--warn); }
.row.wrap { flex-wrap: wrap; }
.left { text-align: left; display: flex; flex-direction: column; align-items: flex-start; gap: .1rem; min-width: 0; }
button.post { width: 100%; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.picker { max-height: 260px; overflow: auto; }
.picker li { padding: 0; }
.picker li > button { width: 100%; display: flex; flex-direction: row; align-items: center; gap: .6rem; justify-content: flex-start; }
.signature-preview .sig-first { font-weight: 700; color: #1f3a68; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: .35rem; text-align: left; cursor: pointer; padding: 1rem; }
.tile.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.icon-btn.up .icon { transform: rotate(-90deg); } .icon-btn.down .icon { transform: rotate(90deg); }
.stack.tight { gap: .3rem; }
a.btn { display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; }
details > summary { cursor: pointer; padding: .4rem 0; }
@media print {
  #sidebar, .topbar, .page-head .actions, .tabs, .org-unit .tools, input[type="search"], .legend { display: none !important; }
  .org-unit, .post { break-inside: avoid; box-shadow: none; }
  button.post { display: flex !important; }
}
.grow > input[type="search"], .grow > input:not([type="checkbox"]) { width: 100%; }
.signature-preview { font-family: Arial, sans-serif; font-size: 13px; line-height: 1.45; }
.signature-preview .sig-nom, .signature-preview .sig-grade { font-size: 15px; font-weight: 700; color: #111; }
.signature-preview .sig-grade { margin-bottom: 6px; }
.signature-preview .sig-fonction { font-weight: 700; color: #1f3a68; }
.signature-preview .sig-italique { font-style: italic; margin-bottom: 6px; }
.signature-preview .sig-contact { font-size: 12px; }
.signature-preview .sig-logos { display: block; margin-top: 10px; max-width: 100%; height: auto; }

/* Vue compagnie (trombinoscope) */
.face { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; background: var(--soft); display: inline-flex; align-items: center; justify-content: center; font-size: .68rem; font-weight: 600; color: var(--muted); }
.cie-command header, .cie-peloton header { display: flex; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.cie-command h3, .cie-peloton h3 { margin: 0; font-size: 1rem; }
.cie-command-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .25rem .6rem; }
.cie-pelotons { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; align-items: start; }
.cie-peloton { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); }
.cie-peloton header { border-bottom: 2px solid var(--brand); padding-bottom: .5rem; }
.cie-group { margin-top: .7rem; border: 1px solid var(--line); border-radius: calc(var(--radius) - 2px); overflow: hidden; }
.cie-group-head { display: flex; gap: .4rem; align-items: center; padding: .25rem .4rem .25rem .6rem; background: var(--soft); font-size: .85rem; min-height: 2rem; }
.cie-person { display: flex; align-items: center; gap: .25rem; padding: 0 .3rem 0 0; border-radius: 6px; min-width: 0; }
.cie-person:hover { background: var(--hover); }
.cie-group .cie-person { border-radius: 0; }
.cie-main { display: flex; align-items: center; gap: .5rem; padding: .2rem .6rem; color: inherit; text-decoration: none; flex: 1; min-width: 0; }
.cie-person.chef .cie-name { font-weight: 600; }
.cie-person.chef .face { box-shadow: 0 0 0 2px var(--brand); }
.cie-person.vacant .face { box-shadow: 0 0 0 2px var(--warn); }
.cie-person.hit { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.cie-person .left { min-width: 0; }
.cie-tools { display: inline-flex; gap: .1rem; opacity: 0; transition: opacity .12s; }
.cie-person:hover .cie-tools, .cie-person:focus-within .cie-tools { opacity: 1; }
@media (hover: none) { .cie-tools { opacity: 1; } }
.cie-name { font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cie-fn { font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.cie-empty { padding: .4rem .6rem; margin: 0; }
.cie-others summary { cursor: pointer; font-weight: 600; margin-bottom: .4rem; }
#trombi-print, #trombi-toolbar { display: none; }

/* Document d'export (aperçu écran et PDF) — A4 paysage, marges gérées par la page */
#trombi-print { font-family: "Helvetica Neue", Arial, sans-serif; color: #18202f; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.tp-page { width: 297mm; height: 210mm; box-sizing: border-box; padding: 9mm 12mm 7mm; display: flex; flex-direction: column; overflow: hidden; background: #fff; position: relative; }
.tp-page::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2.2mm; background: linear-gradient(90deg, #0b2a5b 0 33.3%, #ffffff 33.3% 66.6%, #c8102e 66.6%); }
.tp-head { display: flex; align-items: center; gap: 8mm; padding-bottom: 4mm; border-bottom: .35mm solid #d7deea; }
.tp-logo { height: 21mm; width: auto; }
.tp-title { flex: 1; text-align: center; }
.tp-kicker { font-size: 9pt; letter-spacing: .14em; text-transform: uppercase; color: #5b6b86; font-weight: 600; }
.tp-title h1 { margin: 1mm 0 0; font-size: 24pt; line-height: 1.1; color: #0b2a5b; font-weight: 800; }
.tp-aside { display: flex; flex-direction: column; align-items: center; gap: 1.5mm; }
.tp-badge { background: #0b2a5b; color: #fff; font-size: 8pt; font-weight: 700; padding: 1mm 3mm; border-radius: 10mm; white-space: nowrap; }
.tp-body { flex: 1; display: flex; flex-direction: column; align-items: stretch; padding-top: 5mm; min-height: 0; }
.tp-lead { display: flex; justify-content: center; gap: 8mm; }
.tp-card { width: 54mm; box-sizing: border-box; text-align: center; padding: 3.5mm 3mm 3mm; border: .3mm solid #ccd5e4; border-top: 1.4mm solid #0b2a5b; border-radius: 2.5mm; background: #fff; }
.tp-card.main { border-color: #0b2a5b; box-shadow: 0 .6mm 0 #e3e9f4; }
.tp-card .face { width: 22mm; height: 22mm; font-size: 14pt; box-shadow: 0 0 0 .6mm #fff, 0 0 0 1mm #0b2a5b; }
.tp-card.vacant { border-style: dashed; border-top-style: solid; color: #8892a6; }
.tp-fn { margin-top: 2.6mm; font-size: 6.8pt; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #0b2a5b; }
.tp-name { margin-top: .8mm; font-size: 10pt; font-weight: 700; }
.tp-link { width: .45mm; height: 6mm; margin: 0 auto; background: #0b2a5b; }
.tp-columns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4.5mm; align-items: start; border-top: .45mm solid #0b2a5b; padding-top: 4mm; }
.tp-box { border: .3mm solid #ccd5e4; border-radius: 2.5mm; overflow: hidden; break-inside: avoid; background: #fff; }
.tp-box-head { display: flex; justify-content: space-between; align-items: center; background: #0b2a5b; color: #fff; padding: 1.8mm 3mm; font-size: 8pt; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.tp-count { background: rgba(255, 255, 255, .18); border-radius: 10mm; padding: .2mm 2mm; font-size: 7pt; }
.tp-row { display: flex; align-items: center; gap: 2.6mm; padding: 1.5mm 3mm; border-top: .2mm solid #e7ebf2; min-height: 11mm; box-sizing: border-box; }
.tp-row:first-of-type { border-top: 0; }
.tp-row .face { width: 9mm; height: 9mm; font-size: 6.5pt; }
.tp-row.chef { background: #eef2f9; }
.tp-row.chef .tp-row-name { font-weight: 800; }
.tp-row.chef .face { box-shadow: 0 0 0 .5mm #0b2a5b; }
.tp-row-text { min-width: 0; }
.tp-row-fn { font-size: 6.2pt; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #0b2a5b; }
.tp-row-name { font-size: 8.6pt; line-height: 1.2; }
.tp-foot { display: flex; justify-content: space-between; gap: 6mm; padding-top: 2.5mm; border-top: .2mm solid #d7deea; font-size: 6.8pt; color: #6b7689; }
#trombi-print .face.none { background: #e8edf5; color: #0b2a5b; }

/* Aperçu à l'écran (#/organigramme-pdf) */
@media screen {
  body.trombi-preview > :not(#trombi-print):not(#trombi-toolbar):not(#toasts) { display: none !important; }
  body.trombi-preview { background: #dfe4ec; }
  body.trombi-preview #trombi-print { display: flex; flex-direction: column; align-items: center; gap: 8mm; padding: 22mm 0 12mm; }
  body.trombi-preview .tp-page { box-shadow: 0 2mm 8mm rgba(15, 26, 42, .18); }
  body.trombi-preview #trombi-toolbar { display: flex; position: fixed; top: 0; left: 0; right: 0; z-index: 5; gap: .6rem; align-items: center; padding: .6rem 1rem; background: #0b2a5b; color: #fff; }
  body.trombi-preview #trombi-toolbar .grow { flex: 1; }
}

@media print {
  @page { size: A4 landscape; margin: 0; }
  body.print-trombi > :not(#trombi-print), body.trombi-preview > :not(#trombi-print) { display: none !important; }
  body.print-trombi #trombi-print, body.trombi-preview #trombi-print { display: block; }
  html, body { background: #fff !important; }
  .tp-page { break-after: page; page-break-after: always; }
  .tp-page:last-child { break-after: auto; page-break-after: auto; }
}
.tp-columns.cols-1 { grid-template-columns: minmax(0, 70mm); justify-content: center; }
.tp-columns.cols-2 { grid-template-columns: repeat(2, minmax(0, 80mm)); justify-content: center; }
.tp-columns.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tp-columns.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tp-columns.cols-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

/* Analyses (BI) */
.bi-layout { display: grid; grid-template-columns: minmax(260px, 320px) 1fr; gap: 1rem; align-items: start; }
@media (max-width: 900px) { .bi-layout { grid-template-columns: 1fr; } }
.bi-layout > aside { position: sticky; top: 4.5rem; }
.bi-filters label { display: flex; flex-direction: column; gap: .3rem; font-size: .82rem; font-weight: 500; }
.bi-filters .row label { flex: 1; }
.bi-label { font-size: .82rem; font-weight: 500; }
.stack-tight { display: flex; flex-direction: column; gap: .35rem; }
.segmented.wrap { flex-wrap: wrap; }
.bi-toggles { display: flex; flex-wrap: wrap; gap: .3rem; }
.bi-toggle { min-height: 26px; padding: .15rem .55rem; font-size: .78rem; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); box-shadow: none; color: var(--ink-2); }
.bi-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.bi-questions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: 1rem; }
.chip-btn { min-height: 28px; padding: .2rem .75rem; font-size: .8rem; border-radius: 99px; background: var(--accent-soft); color: var(--accent); border: 1px solid transparent; box-shadow: none; }
.chip-btn:hover { border-color: var(--accent); }
.bi-headline { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.bi-number { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 3.5rem; text-align: center; }
.bars .bar { grid-template-columns: minmax(120px, 220px) 1fr 48px; }
.face.xl { width: 48px; height: 48px; }
ol.chain { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; }
ol.chain li { position: relative; padding-left: 18px; }
ol.chain li::before { content: ""; position: absolute; left: 4px; top: .55em; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); }
ol.chain li + li::after { content: ""; position: absolute; left: 7px; top: -.6em; height: .9em; border-left: 1px solid var(--line); }
.bi-delta { font-size: .8rem; font-weight: 600; color: var(--muted); }
.bi-delta.up { color: var(--accent); } .bi-delta.down { color: var(--warn); }
.resil-check { gap: .6rem; align-items: center; cursor: pointer; }
.resil-check input { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
.agent-photo { width: 44px; height: 56px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.wf-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 36rem; overflow: auto; font: inherit; }
.wf-steps { padding: 0; list-style: none; }
