/* DM Support — console de pilotage.
   Direction : un poste de dispatch calme. Un seul geste fort : le scénario dessiné comme un
   itinéraire (ligne de route, points de passage, repères d'arrivée). Le reste est sobre :
   surfaces blanches à filet fin, typographie DM Sans, le jaune réservé à ce qui est actif. */

:root {
  --ink: #0A1330;
  --ink-2: #3A4C86;
  --muted: #5C688A;
  --faint: #8A95B0;
  --line: #E4E8F2;
  --line-2: #EDF0F7;
  --page: #F5F7FB;
  --surface: #FFFFFF;
  --wash: #EEF2FB;
  --route: #C6D4F0;
  --accent: #F5C21B;
  --accent-ink: #6E5500;
  --accent-wash: #FDF4DC;
  --go: #17794F;
  --go-wash: #E7F6EF;
  --stop: #C4342C;
  --stop-wash: #FBEAE8;
  --font: "DM Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 14px;
  --r-s: 9px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink);
  background: var(--page); -webkit-font-smoothing: antialiased; font-optical-sizing: auto; }
a { color: var(--ink); text-decoration-color: var(--route); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.tnum, td.n, .stat .v { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ── Barre latérale ─────────────────────────────────────────────────────
   Bleu nuit, le jaune ne marque que l'entrée active (et les envois actifs). */
:root { --side-w: 236px; --side-bg: #0B1431; --side-ink: #E8ECF7; --side-muted: #8E9AC0; --side-hover: #16214A; }
.side { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side-bg); color: var(--side-ink);
  display: flex; flex-direction: column; padding: 18px 12px 16px; z-index: 20; overflow-y: auto; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; text-decoration: none; color: inherit;
  font-weight: 800; font-size: 17px; letter-spacing: -.015em; }
.side-brand img { width: 30px; height: 30px; display: block; background: #fff; border-radius: 9px; padding: 3px; }
.side-nav { display: grid; gap: 2px; }
.side-group { margin: 16px 10px 6px; font-size: 12px; font-weight: 600; color: var(--side-muted); }
.side-group:first-child { margin-top: 0; }
.side-link { position: relative; display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 10px; border-radius: 9px;
  color: var(--side-ink); text-decoration: none; font-weight: 600; font-size: 14.5px; opacity: .82; }
.side-link svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.side-link:hover { background: var(--side-hover); opacity: 1; }
.side-link.on { background: var(--side-hover); opacity: 1; }
.side-link.on::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.side-link.on svg { color: var(--accent); }
.side-link:focus-visible { outline-color: var(--accent); }
.side-end { margin-top: auto; display: grid; gap: 10px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side .sends { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; margin: 0 4px; border-radius: 999px;
  font-size: 13px; font-weight: 700; text-decoration: none; justify-self: start; }
.sends .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.side .sends.off { color: var(--side-muted); background: rgba(255, 255, 255, .06); }
.side .sends.on { color: var(--ink); background: var(--accent); }
.sends.on .dot { animation: pulse 1.8s steps(2, jump-none) infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.side .who { font-size: 12.5px; color: var(--side-muted); text-decoration: none; padding: 0 14px; }
.mobile-bar, .side-scrim { display: none; }

body.has-side { padding-left: var(--side-w); }
.main { max-width: 1200px; margin: 0 auto; padding: 40px 40px 80px; }

@media (max-width: 900px) {
  body.has-side { padding-left: 0; }
  .side { transform: translateX(-100%); transition: transform .22s ease-out; box-shadow: 0 0 40px rgba(0, 0, 0, .25); }
  body.menu-open .side { transform: none; }
  .mobile-bar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
    height: 56px; padding: 0 16px; background: var(--side-bg); color: var(--side-ink); }
  .mobile-bar .side-brand { padding: 0; font-size: 16px; }
  .menu-btn { font: inherit; font-weight: 600; font-size: 14px; color: var(--side-ink); background: rgba(255, 255, 255, .08);
    border: 0; border-radius: 8px; height: 34px; padding: 0 14px; cursor: pointer; }
  body.menu-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(10, 19, 48, .45); z-index: 15; }
  .main { padding: 24px 16px 64px; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }

/* ── Titres de page ────────────────────────────────────────────────────── */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
.top h1, .mh-top h1 { margin: 0; font-size: 32px; line-height: 1.1; font-weight: 800; letter-spacing: -.022em; text-wrap: balance; }
.sub { color: var(--muted); margin-top: 8px; max-width: 68ch; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 6px; }
.back::before { content: ""; width: 6px; height: 6px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-right: 3px; }
.back:hover { color: var(--ink); }

.section { margin-top: 40px; display: grid; gap: 14px; }
.section > h2 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.section > h2 small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 8px; }
.section > p { margin: 0; max-width: 72ch; }
.section > *, .grid > * { min-width: 0; }  /* un tableau large défile dans son cadre au lieu d'élargir la page */

/* ── Surfaces ──────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; min-width: 0; }
.card h2 { margin: 0 0 14px; font-size: 16px; font-weight: 700; }
.card h2 small { color: var(--muted); font-weight: 500; margin-left: 6px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.moteur-card { margin-bottom: 16px; }
.politique ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.card.empty, .empty { color: var(--muted); }
.card.empty { padding: 20px 22px; }
.empty-cta { display: grid; gap: 12px; justify-items: start; padding: 36px; background-color: var(--surface);
  background-image: radial-gradient(var(--line) 1.2px, transparent 1.4px); background-size: 22px 22px; }
.empty-cta h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.empty-cta p { margin: 0; max-width: 58ch; }
.note { margin: 0 0 16px; color: var(--accent-ink); background: var(--accent-wash); padding: 10px 14px; border-radius: var(--r-s); }
.alert { border-color: #F2C9C5; background: #FFFBFA; }
.alert h2 { color: var(--stop); }

/* Chiffres clés : une rangée, séparée par des filets verticaux */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); }
.stat { padding: 20px 24px; display: grid; gap: 6px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .v { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat .k { color: var(--muted); font-size: 14px; }

/* Barres horizontales */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 140px 40px; gap: 12px; align-items: center; }
.bar-row .l { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.track span { display: block; height: 100%; border-radius: 3px; background: var(--ink); }
.track.acc span { background: var(--accent); }
.bar-row .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── Étiquettes d'état : un point coloré et un mot, sans boîte ─────────── */
.pill { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; white-space: nowrap; color: var(--muted); }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.p-reponse, .p-publiee, .p-bon, .p-autonome { color: var(--go); }
.p-passation, .p-brouillon-v, .p-a_retoucher, .p-brouillon { color: var(--accent-ink); }
.p-passation::before, .p-brouillon-v::before, .p-a_retoucher::before, .p-brouillon::before { background: var(--accent); }
.p-faux, .p-erreur { color: var(--stop); }
.p-souffleur { color: var(--ink-2); }
.p-observateur, .p-neutre, .p-retiree { color: var(--muted); }
.p-observateur::before, .p-neutre::before, .p-retiree::before { background: transparent; box-shadow: inset 0 0 0 2px var(--faint); }
.code { font-family: var(--mono); font-size: 12.5px; background: var(--wash); border-radius: 6px; padding: 1px 6px; }

/* ── Tableaux ──────────────────────────────────────────────────────────── */
.tw { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 12px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.n { text-align: right; }
td { padding: 14px 18px; border-top: 1px solid var(--line-2); vertical-align: middle; }
tr:first-child td { border-top: 0; }
td.n { text-align: right; white-space: nowrap; font-weight: 600; }
td.k { font-size: 13px; color: var(--muted); width: 90px; }
tbody tr:hover td { background: #FAFBFE; }
tr.link { cursor: pointer; }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }

/* ── Contrôles ─────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px;
  border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { background: #1B2751; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn.accent:hover { background: #E8B60F; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
select, input[type=text], input[type=number], input[type=date], textarea {
  font: inherit; font-size: 14px; color: var(--ink); background-color: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-s); padding: 8px 12px; }
select { padding-right: 32px; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 15px center, right 10px center; background-size: 5px 5px; background-repeat: no-repeat; }
select:hover, input:hover, textarea:hover { border-color: var(--route); }
.seg { display: inline-flex; gap: 2px; background: var(--line-2); padding: 3px; border-radius: 11px; }
.seg a, .seg button { display: inline-flex; gap: 6px; align-items: center; padding: 6px 14px; border-radius: 8px; border: 0; background: none;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: none; cursor: pointer; }
.seg a.on, .seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(10, 19, 48, .08); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .clear { font-size: 14px; color: var(--muted); margin-left: 6px; }
.launch { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.launch label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.launch input[type=number] { width: 96px; }

/* ── Liste des motifs ──────────────────────────────────────────────────── */
.todo { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(400px, 100%), 1fr)); gap: 0 28px; }
.todo-item { display: grid; grid-template-columns: minmax(0, 1fr) auto 92px; gap: 10px; align-items: baseline;
  padding: 11px 2px; border-bottom: 1px solid var(--line); text-decoration: none; }
.todo-item b { font-weight: 600; min-width: 0; }
.todo-item .tnum { text-align: right; }
.todo-item:hover b { text-decoration: underline; text-decoration-color: var(--route); }

/* ── En-tête d'un motif ────────────────────────────────────────────────── */
.motif-head { margin-bottom: 28px; border-bottom: 1px solid var(--line); }
.mh-top { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-end; }
.meta { display: flex; gap: 20px; flex-wrap: wrap; align-items: center; margin-top: 10px; color: var(--muted); }
.mh-actions { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.modes { display: flex; gap: 10px; }
.modes label { display: grid; gap: 5px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tabs { display: flex; margin-top: 22px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 2px; margin-right: 22px; text-decoration: none; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); }
.edit-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: -10px 0 16px; }

/* ── Le scénario comme itinéraire ──────────────────────────────────────── */
.steps { list-style: none; margin: 0; padding: 4px 0; }
.step { --x: calc(var(--lvl, 0) * 30px); position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr);
  gap: 6px; align-items: baseline; padding: 7px 0 7px calc(var(--x) + 34px); }
/* La route : une voie verticale par niveau, de la voie principale jusqu'à celle de l'étape,
   pour que le trajet reste continu quand on entre dans une branche. */
.step::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--x) + 13px);
  background: repeating-linear-gradient(to right, transparent 0 11px, var(--route) 11px 13px, transparent 13px 30px); }
.steps .step:first-child::before { top: 18px; }
.steps .step:last-child::before { bottom: calc(100% - 18px); }
.step::after { content: ""; position: absolute; left: calc(var(--x) + 6px); top: 14px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 2px #9FB2DC; }
.step .num { color: var(--faint); font-size: 13px; font-variant-numeric: tabular-nums; }
.step .txt { min-width: 0; overflow-wrap: anywhere; }
.g-ia::after { box-shadow: inset 0 0 0 2px var(--ink-2); }
.g-si .txt, .g-sinon .txt { font-weight: 700; }
.g-si::after, .g-sinon::after { border-radius: 2px; transform: rotate(45deg) scale(.85); background: var(--ink); box-shadow: none; }
.g-reponse::after, .g-humain::after, .g-action::after, .g-bascule::after { width: 14px; height: 14px; left: calc(var(--x) + 5px); top: 13px; }
.g-reponse::after { background: var(--go); box-shadow: 0 0 0 4px var(--go-wash); }
.g-humain::after, .g-action::after { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-wash); }
.g-bascule::after { background: var(--surface); box-shadow: inset 0 0 0 3px var(--ink-2); }
.g-reponse .txt { color: var(--go); font-weight: 600; }
.g-humain .txt, .g-action .txt { color: var(--accent-ink); font-weight: 600; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin: 0 0 12px; }
.diagram { overflow-x: auto; }
.diagram svg { height: auto; }
.diagram.big { max-height: 78vh; overflow: auto; border-radius: var(--r-s); padding: 14px; background-color: var(--page);
  background-image: radial-gradient(var(--line) 1.2px, transparent 1.4px); background-size: 22px 22px; }
.tpl { display: grid; gap: 8px; }
.tpl p { white-space: pre-wrap; margin: 0; }
.ph { color: var(--accent-ink); background: var(--accent-wash); border-radius: 4px; padding: 0 3px; }

/* ── Éditeur ───────────────────────────────────────────────────────────── */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.editor-card { padding: 0; overflow: hidden; }
.editor-card .CodeMirror { font-family: var(--mono); font-size: 13px; line-height: 1.6; border-bottom: 1px solid var(--line); }
.editor-card .CodeMirror-gutters { background: var(--page); border-right: 1px solid var(--line); }
.cm-error-line { background: var(--stop-wash); }
.side-panel { display: grid; gap: 16px; align-content: start; position: sticky; top: 76px; }
#diagram { max-height: 50vh; overflow: auto; }
.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.issues li { overflow-wrap: anywhere; padding: 8px 12px; border-radius: var(--r-s); background: var(--page); }
.issues li.err { background: var(--stop-wash); color: var(--stop); cursor: pointer; }
.issues li.warn { background: var(--accent-wash); color: var(--accent-ink); }
.issues li.ok { background: var(--go-wash); color: var(--go); }
.help { padding: 14px 18px; }
.help summary { cursor: pointer; font-weight: 700; }
.help table td { padding: 7px 8px; font-size: 13px; }
pre.diff { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6; overflow-x: auto; }
pre.diff .add { background: var(--go-wash); color: var(--go); }
pre.diff .del { background: var(--stop-wash); color: var(--stop); }

/* ── Rejeux ────────────────────────────────────────────────────────────── */
.filters { display: inline-flex; gap: 2px; background: var(--line-2); padding: 3px; border-radius: 11px; flex-wrap: wrap; margin: 0 0 18px; }
.chip { border: 0; background: none; border-radius: 8px; padding: 6px 14px; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip span { color: var(--faint); margin-left: 4px; }
.chip.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(10, 19, 48, .08); }
.cases { display: grid; gap: 12px; }
.case { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; display: grid; gap: 12px; }
.case-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.case-head .verdict { margin-left: auto; display: flex; gap: 2px; background: var(--line-2); padding: 3px; border-radius: 10px; }
.vbtn { border: 0; background: none; border-radius: 7px; padding: 5px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.vbtn:hover { color: var(--ink); }
.vbtn.on { background: var(--surface); box-shadow: 0 1px 2px rgba(10, 19, 48, .08); }
.vbtn.on.v-bon { color: var(--go); }
.vbtn.on.v-a_retoucher { color: var(--accent-ink); }
.vbtn.on.v-faux { color: var(--stop); }
.msg { margin: 0; white-space: pre-wrap; }
.msg.clamp { max-height: 4.7em; overflow: hidden; cursor: pointer; color: var(--muted); white-space: normal;
  -webkit-mask-image: linear-gradient(#000 50%, transparent); mask-image: linear-gradient(#000 50%, transparent); }
.msg.clamp.open { max-height: none; color: var(--ink); -webkit-mask-image: none; mask-image: none; }
.msg.clamp:not(.open) .msg-form-top, .msg.clamp:not(.open) .msg-who { display: none; }
.msg.clamp:not(.open) .msg-form { border: 0; padding: 0; margin: 0 0 2px; }

/* Message d'un chauffeur mis en forme */
.msg-form { display: grid; gap: 2px; margin: 4px 0 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.msg-form-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.msg-ref { font-weight: 500; overflow-wrap: anywhere; }
.msg-motif { font-size: 15px; font-weight: 650; color: var(--ink); }
.msg-who { display: flex; flex-wrap: wrap; gap: 0 12px; font-size: 13px; color: var(--muted); }
.msg-who span { overflow-wrap: anywhere; }
.msg-p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-p + .msg-p { margin-top: 8px; }
.msg-quote { margin-top: 10px; font-size: 13px; color: var(--muted); }
.msg-quote summary { cursor: pointer; font-weight: 600; width: fit-content; }
.msg-quote .msg-p { margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--line); }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; border-top: 1px solid var(--line-2); padding-top: 14px; }
.compare { min-width: 0; padding-left: 14px; border-left: 3px solid var(--go); }
.compare.human { border-left-color: var(--line); }
.compare p { white-space: pre-wrap; margin: 6px 0 0; overflow-wrap: anywhere; }

/* ── Dossiers ──────────────────────────────────────────────────────────── */
.state { font-size: 14px; font-weight: 600; }
.st-attente_chauffeur { color: var(--ink-2); }
.st-attente_humain { color: var(--accent-ink); }
.st-pause, .st-clos { color: var(--muted); }
.dossier-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 18px; align-items: start; }
.thread { display: grid; gap: 10px; }
.bubble { border-radius: 16px 16px 16px 6px; padding: 10px 14px; background: var(--line-2); max-width: 88%; }
.bubble p { margin: 4px 0 0; white-space: pre-wrap; }
.bubble .meta { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0; }
.bubble.a-coeur, .bubble.a-agent { margin-left: auto; border-radius: 16px 16px 6px 16px; }
.bubble.a-coeur { background: var(--ink); color: #fff; }
.bubble.a-coeur .meta { color: rgba(255, 255, 255, .7); }
.bubble.a-agent { background: var(--wash); }
.bubble.a-systeme { margin: 0 auto; background: none; text-align: center; font-size: 13px; color: var(--muted); }
.decisions { display: grid; gap: 16px; align-content: start; }
.trace { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 8px; }
.trace pre, .decisions pre { margin: 6px 0 0; background: var(--page); border-radius: 8px; padding: 10px 12px;
  font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 260px; overflow: auto; }
details > summary { cursor: pointer; }

/* ── Connexion ─────────────────────────────────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; background-color: var(--page);
  background-image: radial-gradient(var(--line) 1.2px, transparent 1.4px); background-size: 22px 22px; }
.login .card { width: min(420px, 92vw); padding: 36px; display: grid; gap: 16px; }

@media (max-width: 1000px) {
  .editor-grid, .dossier-grid { grid-template-columns: 1fr; }
  .side-panel { position: static; }
}
@media (max-width: 760px) {
  .main { padding: 24px 16px 60px; }
  .top h1, .mh-top h1 { font-size: 26px; }
  .stat { border-left: 0; border-top: 1px solid var(--line); }
  .stat:first-child { border-top: 0; }
  .compare-grid { grid-template-columns: 1fr; gap: 12px; }
  .case-head .verdict { margin-left: 0; }
  .bar-row { grid-template-columns: minmax(0, 1fr) 80px 36px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.values { margin-top: 4px; line-height: 1.9; }
.values .code { white-space: nowrap; }

/* Code de type de demande : un repère discret, jamais le titre */
.tag { display: inline-block; font-size: 11px; font-weight: 600; line-height: 1.5; color: var(--muted);
  background: var(--wash); border-radius: 5px; padding: 0 6px; vertical-align: 1px;
  font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.sub a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

.state { white-space: nowrap; }


/* ── Page Scénarios : actions de ligne, colonnes compactes ─────────────── */
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
th small { display: block; font-size: 12px; font-weight: 500; color: var(--faint); }
td.act { text-align: right; white-space: nowrap; }
td.act .btn + .btn { margin-left: 6px; }
.cell-sub { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; }

/* ── Schéma : zoom et plein écran ──────────────────────────────────────── */
.diagram-tools { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; flex-wrap: wrap; }
.diagram-tools [data-zoom-level] { min-width: 48px; text-align: center; }
.diagram-tools [data-zoom="full"] { margin-left: auto; }
.diagram.big .mermaid { margin: 0; background: none; }
.diagram-frame:fullscreen { background: var(--page); padding: 20px; display: flex; flex-direction: column; }
.diagram-frame:fullscreen .diagram.big { max-height: none; flex: 1; }
table.scen { table-layout: fixed; min-width: 1100px; }
tr.idle td:nth-child(2) b { font-weight: 600; color: var(--ink-2); }

/* ── Fiche de connaissance : ce que lit l'IA, puis les notes de l'équipe ─── */
.ia-card { border-left: 4px solid var(--accent); }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.doc-head h2 { margin: 0 0 2px; font-size: 19px; }
.ia-card .doc-head h2 { font-size: 16px; }
.doc-head p { margin: 0; max-width: 72ch; }
.doc-foot { margin-top: 12px; }
.md-edit { width: 100%; font-family: var(--mono); font-size: 13px; line-height: 1.55; }
.form-actions { margin-top: 10px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ia-empty { margin: 0; padding: 12px 14px; border-radius: var(--r-s); background: var(--accent-wash); color: var(--accent-ink); }
.prose { max-width: 78ch; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table { margin: 0 0 10px; }
.prose ul, .prose ol { padding-left: 20px; }
.prose li + li { margin-top: 6px; }
.prose code { font-family: var(--mono); font-size: 12.5px; background: var(--wash); border-radius: 5px; padding: 1px 5px; overflow-wrap: anywhere; }
.prose blockquote { border-left: 3px solid var(--route); padding: 2px 0 2px 12px; color: var(--muted); }
.prose table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 13.5px; }
.prose th, .prose td { border-bottom: 1px solid var(--line); padding: 6px 10px 6px 0; text-align: left; vertical-align: top; }
.ia-card .prose { font-size: 15.5px; }
.notes { display: grid; gap: 8px; }
.fiche-note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-s); }
.fiche-note > summary { padding: 11px 16px; font-weight: 600; list-style-position: inside; }
.fiche-note[open] > summary { border-bottom: 1px solid var(--line-2); }
.fiche-note > .prose { padding: 12px 16px 14px; font-size: 14px; max-width: none; }
.fiche-intro { font-size: 13px; color: var(--muted); }
.fiche-intro code { font-family: inherit; font-size: inherit; background: none; padding: 0; }

/* ── Réglages : accès à la base sitesf ───────────────────────────────── */
table.kv td:first-child { color: var(--muted); width: 210px; }
.access-form { margin-top: 16px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.access-form > summary { font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 12px 0; }
.form-grid label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.form-grid input { font: inherit; font-size: 14px; color: var(--ink); padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--surface); min-width: 0; }
.form-grid .form-actions { grid-column: 1 / -1; margin-top: 0; }

/* ── Tableau de bord : flux par règle et par branche ─────────────────── */
.top-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.flux-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 14px; }
.fs-cell { padding: 16px 20px; display: grid; gap: 2px; border-left: 1px solid var(--line-2); }
.fs-cell:first-child { border-left: 0; }
.fs-v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.fs-k { font-size: 13px; color: var(--muted); }
.fs-cell.go .fs-v { color: var(--go); }
.fs-cell.hu .fs-v { color: var(--accent-ink); }
.flux-note { margin: 0 0 18px; font-size: 13px; color: var(--muted); max-width: 90ch; }
.flux { display: grid; gap: 16px; }
.flux-rule { display: grid; gap: 14px; padding: 20px 22px 16px; }
.flux-rule.empty { padding-bottom: 18px; }
.fr-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.fr-name > a { font-size: 17px; font-weight: 700; text-decoration: none; letter-spacing: -.01em; }
.fr-name > a:hover { text-decoration: underline; text-decoration-color: var(--route); }
.fr-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 2px; font-size: 13px; color: var(--muted); }
.fr-meta a { color: var(--muted); }
.fr-count { text-align: right; line-height: 1.1; white-space: nowrap; }
.fr-count > span { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.fr-count small { display: block; font-size: 12.5px; color: var(--muted); }
.trend { font-weight: 600; }
.trend.up { color: var(--stop); }
.trend.down { color: var(--go); }
.fr-stack { display: flex; gap: 2px; height: 10px; border-radius: 5px; overflow: hidden; }
.fr-stack > span { flex-basis: 0; min-width: 3px; }
.seg-go { background: var(--go); }
.seg-go:nth-child(2n) { background: #3E9A70; }
.seg-hu { background: var(--accent); }
.seg-hu:nth-child(2n) { background: #F8D35E; }
.fr-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 28px; }
.fr-group h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; padding-bottom: 6px; border-bottom: 1px solid var(--line-2); }
.fr-group h3.go { color: var(--go); }
.fr-group h3.hu { color: var(--accent-ink); }
.fb-list { list-style: none; margin: 0; padding: 0; }
.fb { border-bottom: 1px solid var(--line-2); }
.fb:last-child { border-bottom: 0; }
.fb-link { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto 10px; gap: 10px; align-items: baseline; padding: 8px 0; text-decoration: none; color: var(--ink); }
.fb-pct { font-weight: 700; font-size: 15px; }
.fb.go .fb-pct { color: var(--go); }
.fb.hu .fb-pct { color: var(--accent-ink); }
.fb-title { font-size: 14px; line-height: 1.35; }
.fb-n { font-size: 13px; color: var(--muted); }
.fb-go { color: var(--faint); font-size: 16px; }
.fb-link:hover .fb-title { text-decoration: underline; text-decoration-color: var(--route); text-underline-offset: 3px; }
.fb-link:hover .fb-go { color: var(--ink); }
.fb-details { display: flex; gap: 6px; flex-wrap: wrap; margin: -2px 0 10px 56px; }
.fb-none { margin: 4px 0; font-size: 13px; color: var(--faint); }
.b-details { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-s { font-size: 12.5px; background: var(--wash); border-radius: 6px; padding: 2px 8px; color: var(--ink-2); }
.chip-s b { font-weight: 600; color: var(--ink); margin-left: 4px; }
.flux-rest { display: grid; gap: 10px; padding: 14px 22px; border: 1px dashed var(--line); border-radius: var(--r); font-size: 14px; color: var(--muted); }
.fr-rest-head { display: flex; gap: 8px 18px; flex-wrap: wrap; align-items: baseline; }
.flux-rest b { color: var(--ink); }
.fr-rest-head a { margin-left: auto; }
@media (max-width: 860px) {
  .fr-groups { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .flux-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fs-cell:nth-child(3) { border-left: 0; }
  .fs-cell:nth-child(n+3) { border-top: 1px solid var(--line-2); }
  .fs-v { font-size: 22px; }
  .fb-details { margin-left: 0; }
  .fr-rest-head a { margin-left: 0; }
}

/* ── Règles : regroupement par famille (parcours du chauffeur) ───────── */
table.scen tbody.fam + tbody.fam .fam-row th { border-top: 10px solid var(--page); }
.fam-row th { background: var(--wash); padding: 10px 14px; text-align: left; font-weight: 400; }
.fam-head { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.fam-code { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 700; }
.fam-name { font-size: 15px; font-weight: 700; color: var(--ink); }
.fam-stats { font-size: 13px; color: var(--muted); }
.fam-stats b { color: var(--go); }
.fam-bar { flex: 0 0 120px; height: 6px; background: var(--surface); border-radius: 3px; overflow: hidden; margin-left: auto; }
.fam-bar > span { display: block; height: 100%; background: var(--go); }
tbody.hors .fam-code { background: var(--faint); }
tbody.hors .fam-row th { background: var(--line-2); }
tbody.hors td { opacity: .75; }

/* ── Page publique d'avis (chauffeur, téléphone d'abord) ─────────────── */
body.avis-page { background: var(--page); min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.avis { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 28px 24px; text-align: center; }
.avis h1 { font-size: 22px; line-height: 1.25; letter-spacing: -.01em; margin: 6px 0 20px; }
.avis-brand { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.avis-choices { display: grid; gap: 10px; margin-bottom: 16px; }
.avis-btn { font: inherit; font-size: 16px; font-weight: 600; padding: 14px 16px; border-radius: var(--r-s); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; width: 100%; }
.avis-btn.yes { background: var(--go); border-color: var(--go); color: #fff; }
.avis-btn:hover { filter: brightness(.97); }
.avis-comment { display: grid; gap: 10px; text-align: left; }
.avis-comment label { font-weight: 600; font-size: 14px; }
.avis-comment textarea { font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-s); resize: vertical; }
.fb-avis { color: var(--go); white-space: nowrap; }

/* ── Retouches de lisibilité ─────────────────────────────────────────── */
.grid table.kv td:first-child { width: 40%; }
table.kv td { vertical-align: top; }
.tw table td.muted:last-child { white-space: nowrap; }

/* ── Agents : listes groupées, fiche, sources (simplicité, divulgation progressive) ── */
.btn:active, .list-row:active, .pick-row:active, .seg button:active { transform: scale(.985); }
.btn, .list-row, .pick-row { transition: transform .1s ease-out, background-color .15s ease-out; }
.page-tabs { margin: -8px 0 22px; }
.page-tabs a { text-decoration: none; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.list-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto 16px; gap: 14px; align-items: center;
  padding: 14px 18px; color: var(--ink); text-decoration: none; }
.list-row + .list-row { border-top: 1px solid var(--line-2); }
.list-row:hover { background: var(--page); }
.list-row.off { color: var(--muted); }
.list-row.off .row-icon { filter: grayscale(1); opacity: .6; }
.row-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--wash); padding: 5px; }
.row-main { display: grid; gap: 2px; min-width: 0; }
.row-title { font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; }
.row-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-state { display: flex; align-items: center; gap: 10px; }
.row-chevron { width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.state { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.state.fantome { background: var(--wash); color: var(--ink-2); }
.state.actif { background: var(--accent); color: var(--ink); }
.state.off { background: var(--line-2); color: var(--muted); }
.state.ok { background: var(--go-wash); color: var(--go); }
.listen { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.listen::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--go); }
.listen.muted::before { background: var(--faint); }
.listen.err { color: var(--stop); }
.listen.err::before { background: var(--stop); }

/* Fenêtre « Nouvel agent » */
dialog.sheet { width: min(560px, calc(100vw - 32px)); max-height: min(720px, calc(100vh - 64px)); padding: 0; border: 0;
  border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgba(10, 19, 48, .28); }
dialog.sheet[open] { animation: sheet-in .22s ease-out; }
dialog.sheet::backdrop { background: rgba(10, 19, 48, .4); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.sheet-in { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; max-height: inherit; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.sheet-head h2 { margin: 0; font-size: 19px; letter-spacing: -.01em; }
.sheet-lead { margin: 0; padding: 0 20px 12px; }
.sheet-note { margin: 0; padding: 12px 20px 22px; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--line-2); color: var(--muted); cursor: pointer; }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.search { margin: 0 20px 10px; font: inherit; font-size: 15px; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--page); }
.search:focus { outline: 2px solid var(--ink); outline-offset: 1px; background: var(--surface); }
.pick { overflow-y: auto; padding: 0 12px 8px; min-height: 160px; }
.pick-row { display: grid; grid-template-columns: 18px 24px minmax(0, 1fr); gap: 10px; align-items: center;
  padding: 9px 8px; border-radius: 10px; cursor: pointer; }
.pick-row:hover { background: var(--page); }
.pick-row:has(input:checked) { background: var(--wash); }
.pick-row input { accent-color: var(--ink); margin: 0; }
.pick-flag { font-size: 16px; text-align: center; }
.pick-text { display: grid; min-width: 0; }
.pick-name { font-weight: 600; font-size: 14.5px; }
.pick-sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-empty { margin: 12px 8px; color: var(--muted); font-size: 14px; }
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px;
  border-top: 1px solid var(--line-2); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* Fiche d'un agent, onglet Sources : blocs façon réglages */
.settings { display: grid; gap: 26px; max-width: 720px; }
.group { display: grid; gap: 8px; }
.group-title { margin: 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.group-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.group-card.rows { padding: 0; }
.group-help { margin: 12px 2px 0; font-size: 14px; color: var(--ink-2); }
.group-foot { margin: 0 4px; font-size: 12.5px; color: var(--muted); }
.rows .row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px;
  padding: 10px 18px; color: var(--ink); text-decoration: none; }
.rows .row + .row, .rows .row + .row-actions { border-top: 1px solid var(--line-2); }
.rows .row > span:first-child { display: grid; gap: 2px; min-width: 0; }
.rows .row small { color: var(--muted); font-size: 12.5px; }
.rows label.row > span { font-weight: 600; flex: none; }
.rows .row input, .rows .row select { font: inherit; font-size: 14.5px; border: 1px solid transparent; background: transparent;
  text-align: right; padding: 6px 8px; border-radius: 8px; min-width: 0; max-width: 60%; color: var(--ink); }
.rows .row input:hover, .rows .row select:hover { background: var(--page); }
.rows .row input:focus, .rows .row select:focus { outline: none; border-color: var(--line); background: var(--surface); }
.rows .link-row:hover { background: var(--page); }
.row-actions { display: flex; justify-content: flex-end; padding: 10px 18px; }
.muted-card { border-style: dashed; color: var(--muted); }
.muted-card b { color: var(--muted); }
.disclose { margin-top: 10px; }
.disclose > summary { cursor: pointer; font-weight: 600; }
.disclose[open] > summary { margin-bottom: 12px; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; justify-content: center; font: inherit; font-weight: 600; }
.btn.danger-text { background: none; border-color: transparent; color: var(--stop); padding-left: 0; }
.btn.danger-text:hover { text-decoration: underline; }

/* Interrupteur */
.switch { position: relative; width: 46px; height: 28px; flex: none; border: 0; border-radius: 999px; background: var(--line);
  cursor: pointer; transition: background-color .2s ease-out; }
.switch span { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(10, 19, 48, .25); transition: transform .2s ease-out; }
.switch[aria-checked="true"] { background: var(--go); }
.switch[aria-checked="true"] span { transform: translateX(18px); }

@media (max-width: 640px) {
  .list-row { grid-template-columns: 32px minmax(0, 1fr) 14px; gap: 12px; padding: 12px 14px; }
  .list-row .row-state { grid-column: 2; grid-row: 2; }
  .list-row .row-chevron { grid-column: 3; grid-row: 1 / span 2; }
  .row-sub { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
  dialog.sheet[open] { animation: none; }
  .btn:active, .list-row:active, .pick-row:active, .seg button:active { transform: none; }
}

/* ── Réglages et listes de l'application ─────────────────────────────── */
.state.err { background: var(--stop-wash); color: var(--stop); }
.switch.accent[aria-checked="true"] { background: var(--accent); }
.warn-text { color: var(--accent-ink) !important; }
.row-end { display: inline-flex; align-items: center; gap: 10px; }
.rows .row > .code { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60%; }
.ticket-row { grid-template-columns: 12px minmax(0, 1fr) auto 16px; }
.ticket-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--faint); }
.ticket-dot.st-ouvert { background: var(--ink-2); }
.ticket-dot.st-attente_chauffeur { background: var(--accent); }
.ticket-dot.st-attente_humain { background: var(--stop); }
.ticket-dot.st-pause { background: var(--muted); }
.listen-plain { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
@media (max-width: 640px) {
  .ticket-row { grid-template-columns: 10px minmax(0, 1fr) 14px; }
  .ticket-row .row-state { grid-column: 2; grid-row: 2; }
  .ticket-row .row-chevron { grid-column: 3; grid-row: 1 / span 2; }
}

/* Fiche d'un ticket */
.thread { display: grid; gap: 10px; }
.decision { display: grid; gap: 12px; }
.decision-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bubble.proposal { margin: 0; max-width: none; }
.handoff { background: var(--accent-wash); color: var(--accent-ink); border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.handoff p { margin: 4px 0 0; color: var(--ink-2); }
.decision-rows { border: 1px solid var(--line-2); border-radius: 12px; }
.decision-rows:empty { display: none; }
.disclose.tech { border-top: 1px solid var(--line-2); padding-top: 10px; }
.disclose.tech > summary { font-size: 13px; color: var(--muted); }
.run-row { grid-template-columns: minmax(0, 1fr) auto 16px; }
.run-figs { font-size: 13px; color: var(--muted); white-space: nowrap; }
.run-figs b { color: var(--ink); }
.run-judge { display: inline-flex; gap: 4px; }
.run-judge span { min-width: 24px; height: 22px; padding: 0 6px; border-radius: 6px; display: inline-grid; place-items: center;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.j-bon { background: var(--go-wash); color: var(--go); }
.j-ret { background: var(--accent-wash); color: var(--accent-ink); }
.j-faux { background: var(--stop-wash); color: var(--stop); }
@media (max-width: 640px) {
  .run-row { grid-template-columns: minmax(0, 1fr) 14px; }
  .run-row .row-state { grid-column: 1; grid-row: 2; }
  .run-row .row-chevron { grid-column: 2; grid-row: 1 / span 2; }
}
.version-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px 18px; }
.version-row + .version-row { border-top: 1px solid var(--line-2); }
.version-row .row-title { display: flex; align-items: center; gap: 10px; }
.version-row .row-title a { color: var(--ink); text-decoration: none; }
.version-row .row-title a:hover { text-decoration: underline; text-decoration-color: var(--route); }
.version-note { font-size: 12.5px; color: var(--muted); }
.version-note.ok { color: var(--go); }
.version-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.version-actions form { margin: 0; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); }
.settings > *, .group, .group-card { min-width: 0; }
.rows .row > .code { min-width: 0; }
.launch label { min-width: 0; max-width: 100%; }
.launch select { min-width: 0; max-width: 100%; }

/* Tableau de bord : une bande de chiffres, puis une ligne par règle qui s'ouvre sur ses branches */
.dash-mode { margin: 0 0 16px; font-size: 14px; color: var(--ink-2); background: var(--wash); padding: 10px 14px; border-radius: var(--r-s); }
.dash-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.ds-cell { padding: 14px 18px; display: grid; align-content: start; gap: 1px; border-left: 1px solid var(--line-2); }
.ds-cell:first-child { border-left: 0; }
.ds-v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.ds-k { font-size: 14px; font-weight: 600; }
.ds-s { font-size: 12.5px; color: var(--muted); }
.ds-cell.go .ds-v { color: var(--go); }
.ds-cell.hu .ds-v { color: var(--accent-ink); }
.dash-alert { margin: 14px 0 0; }
.dash-rules { padding: 0; overflow: hidden; }
.dash-rule + .dash-rule { border-top: 1px solid var(--line-2); }
.dash-rule > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(70px, 1fr) auto 48px 14px; align-items: center; gap: 18px; padding: 14px 18px; }
.dash-rule > summary::-webkit-details-marker { display: none; }
.dash-rule > summary:hover { background: var(--page); }
.dr-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dr-bar { height: 8px; }
.dr-split { display: flex; gap: 10px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.dr-split .go { color: var(--go); }
.dr-split .hu { color: var(--accent-ink); }
.dr-n { font-size: 18px; font-weight: 700; text-align: right; line-height: 1.1; }
.dr-n small { display: block; font-size: 11.5px; }
.dr-chev { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; transition: transform .2s ease; }
.dash-rule[open] .dr-chev { transform: rotate(90deg); }
.dr-body { padding: 0 18px 14px; }
.dr-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; padding-top: 10px; }
.dr-foot a { margin-left: auto; }
.dr-idle { margin: 0; padding: 12px 18px; font-size: 13px; color: var(--muted); }
.dash-rule ~ .dr-idle { border-top: 1px solid var(--line-2); }
.dr-idle a { color: var(--muted); }
.dr-rate { width: 120px; }
.dash-foot { margin: 24px 0 0; }
@media (max-width: 640px) {
  .dash-rule > summary { grid-template-columns: minmax(0, 1fr) 48px 14px; gap: 8px 12px; }
  .dr-n { grid-row: 1; grid-column: 2; }
  .dr-chev { grid-row: 1; grid-column: 3; }
  .dr-bar, .dr-split { grid-column: 1 / -1; }
  .dr-rate { width: 64px; }
}
@media (prefers-reduced-motion: reduce) { .dr-chev { transition: none; } }
.tag.tag-h { font-size: 13px; padding: 1px 8px; vertical-align: 7px; letter-spacing: 0; }

/* Jugement d'une décision sur un vrai ticket */
.judge { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line-2); }
.judge-q { margin: 0 0 8px; font-weight: 600; }
.judge-forms { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.judge-bad { display: flex; gap: 8px; flex: 1 1 100%; }
.judge-bad input[type=text] { flex: 1; min-width: 0; }
.btn.j-correct { color: var(--go); }
.btn.j-pas_bon { color: var(--stop); }
.judge-done { padding: 8px 12px; border-radius: var(--r-s); }
.judge-done p { margin: 4px 0 0; }
.judge-done.j-correct { background: var(--go-wash); }
.judge-done.j-correct b { color: var(--go); }
.judge-done.j-pas_bon { background: var(--stop-wash); }
.judge-done.j-pas_bon b { color: var(--stop); }
.judge-change { margin-top: 8px; }
.judge-change summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.judge-change .judge-forms { margin-top: 8px; }
.state.j-correct { background: var(--go-wash); color: var(--go); }
.state.j-pas_bon { background: var(--stop-wash); color: var(--stop); }

/* Script et proposition de l'IA encadrée côte à côte (moteur « les_deux ») */
.duo { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.duo-col { display: grid; gap: 10px; align-content: start; min-width: 0; }
.duo-col .judge { margin-top: 0; }
.gardes { display: flex; flex-wrap: wrap; gap: 6px; }
.garde { font-size: 12.5px; background: var(--stop-wash); color: var(--stop); border-radius: 6px; padding: 3px 8px; }
.prefer { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--line-2); }
.prefer .judge-q { margin: 0; }
.seg { display: inline-flex; gap: 2px; background: var(--line-2); padding: 3px; border-radius: 10px; }
.seg .vbtn.on { color: var(--ink); }
/* Tickets de test jugés comme les vrais */
.judge-bar { align-items: center; }
.judge-progress { margin-left: auto; font-size: 13px; color: var(--muted); }
.judge-progress b { color: var(--ink); }
.case-judge { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.judge-line { margin: 0; font-size: 14px; padding: 6px 10px; border-radius: var(--r-s); }
.judge-line.j-pas_bon { background: var(--stop-wash); }
.compare-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.compare.ia { border-left-color: var(--accent); }
@media (max-width: 900px) {
  .duo, .compare-grid.three { grid-template-columns: 1fr; }
  .case-judge, .judge-progress { margin-left: 0; }
}

/* ── Juger vite : deux versions côte à côte, « Correct » d'un clic, « Pas correct » + pourquoi ── */
.case-tools { margin-left: auto; display: inline-flex; gap: 12px; align-items: center; }
.vs { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .8fr); gap: 20px;
  border-top: 1px solid var(--line-2); padding-top: 16px; align-items: start; }
.vs.trio { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, .75fr); }
.vs-col { min-width: 0; display: grid; gap: 10px; align-content: start; }
.vs-title { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.vs-col.ia .vs-title { color: var(--accent-ink); }
.vs-col .bubble { max-width: none; margin: 0; border-radius: 14px; }
.vs-col .bubble.ia { box-shadow: inset 3px 0 0 var(--accent); }
.vs-col .bubble p { margin: 0; overflow-wrap: anywhere; }
.vs-col .handoff { margin: 0; }
.vs-col.human .human-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font-size: 14px; }
.vs-col .garde { margin: 0; font-size: 13px; color: var(--stop); }

.jz { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.jz form { margin: 0; }
.th { display: inline-grid; place-items: center; width: 40px; height: 34px; padding: 0; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; list-style: none;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .1s ease; }
.th::-webkit-details-marker { display: none; }
.th svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.th.up:hover { color: var(--go); border-color: color-mix(in srgb, var(--go) 35%, transparent); background: var(--go-wash); }
.th.down:hover, .jz-bad[open] > .th.down { color: var(--stop); border-color: color-mix(in srgb, var(--stop) 35%, transparent); background: var(--stop-wash); }
.th.up.on { color: #138A55; background: #DDF5E8; border-color: #7FD3A8; }
.th.down.on { color: #D23C30; background: #FDE4E1; border-color: #F2A39B; }
.th.on svg { fill: currentColor; fill-opacity: .18; }
.th:active { transform: scale(.92); }
.th:focus-visible { outline: 3px solid var(--route); outline-offset: 2px; }
.jz-hint { font-size: 13px; color: var(--faint); margin-left: 4px; }
.jz-status { font-size: 13px; font-weight: 600; margin-left: 4px; }
.jz.is-correct .jz-status { color: var(--go); }
.jz.is-pas_bon .jz-status { color: var(--stop); }
.jz-bad { display: contents; }
.jz-why { flex: 1 1 100%; display: grid; gap: 6px; margin-top: 4px; padding: 10px 12px; border-radius: 12px; background: var(--stop-wash); }
.jz-label { font-size: 13px; font-weight: 700; color: var(--stop); }
.jz-why textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid color-mix(in srgb, var(--stop) 25%, transparent); border-radius: 9px; resize: vertical; background: var(--surface); }
.jz-why textarea:focus { outline: none; border-color: var(--stop); }
.jz-why .btn { justify-self: start; }
.jz-note { margin: 2px 0 0; padding-left: 10px; border-left: 2px solid var(--stop); font-size: 14px; white-space: pre-wrap; }
@media (prefers-reduced-motion: reduce) { .th { transition: none; } .th:active { transform: none; } }
.jz-pref { display: grid; gap: 6px; margin: 6px 0 0; padding-top: 12px; border-top: 1px dashed var(--line); }
.jz-pref-q { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.jz-pref .seg { flex-wrap: wrap; }
@media (max-width: 1100px) { .vs.trio { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .vs.trio .vs-col.human { grid-column: 1 / -1; } }
@media (max-width: 760px) { .vs, .vs.trio { grid-template-columns: 1fr; } }
.vs-col .bubble.blocked { opacity: .72; }
.blocked-tag { display: inline-block; font-size: 12px; font-weight: 700; color: #FFD6D2; margin-bottom: 6px; }
.vs-title.ia { color: var(--accent-ink); }

/* ── Ce qui n'est pas une réponse : passage à un humain (neutre) et blocage par le contrôle (rouge) ── */
.hand { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 14px; }
.hand-ico, .ctrl-ico { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; }
.hand-ico { background: var(--wash); color: var(--ink); }
.hand-ico svg, .ctrl-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hand-body { display: grid; gap: 2px; min-width: 0; padding-top: 4px; }
.hand-body b { font-weight: 700; }
.hand-why { color: var(--muted); font-size: 13px; }
.hand-note > summary { font-size: 13px; color: var(--muted); cursor: pointer; margin-top: 4px; }
.hand-note p { margin: 6px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); font-size: 13px; }
.ctrl { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px 12px; border-radius: 12px; background: var(--stop-wash); font-size: 14px; }
.ctrl-ico { background: color-mix(in srgb, var(--stop) 14%, transparent); color: var(--stop); }
.ctrl-body { display: grid; gap: 2px; min-width: 0; padding-top: 4px; }
.ctrl-body b { color: var(--stop); font-weight: 700; }
.ctrl-body p { margin: 0; color: var(--ink-2); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.vs-col .bubble.blocked .blocked-tag { color: #FFD6D2; }

/* ── Listes : ce que l'agent a fait (étiquette sobre) et le jugement (pouce) ── */
.it { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.it svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.it-hum { color: var(--muted); }
.it-err { color: var(--stop); }
.pbs { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.pb { display: inline-flex; align-items: center; justify-content: center; gap: 3px; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 999px; font-size: 10px; white-space: nowrap; }
.pb svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pb b { font-weight: 800; letter-spacing: .02em; }
.pb-correct { background: #DDF5E8; color: #138A55; }
.pb-pas_bon { background: #FDE4E1; color: #D23C30; }
.pb-vide { border: 1px dashed #C9D1E3; color: #A3AEC6; }
.ticket-dot.dot-rep { background: #22A06B; }
.ticket-dot.dot-hum { background: #B8C1D6; }
.ticket-dot.dot-err { background: var(--stop); }
.ticket-dot.dot-none { background: transparent; border: 1.5px solid #C9D1E3; }
.row-family { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }

/* ── Tableau de bord par famille ─────────────────────────────────────────────────────────────
   Encre sobre partout ; la couleur ne sert qu'à lire : bleu nuit = l'agent traite, gris = humain,
   vert / corail = jugé correct / pas correct, et la santé en un point (rouge, ambre, vert, gris). */
:root { --db-rep: #7D93C9; --db-hum: #E1E6F0; --db-err: #E5A39A; --db-ok: #8CCBAA; --db-ko: #EFA99C;
  --db-alerte: #E07B6E; --db-attention: #E8B65A; --db-bon: #6DBB93; --db-gris: #CDD3E1; }
.db-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 8px; }
.db-kpi { display: grid; gap: 4px; padding: 16px 18px; border-left: 1px solid var(--line-2); color: inherit; text-decoration: none; }
.db-kpi:first-child { border-left: 0; }
.db-kpi .k { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.db-kpi .v { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.db-kpi .s { font-size: 13px; color: var(--muted); }
.db-kpi .err { color: #C0574B; font-weight: 600; }
.db-kpi.link:hover { background: var(--wash); }
.trend { font-weight: 700; color: var(--muted); }
.trend.up { color: var(--db-rep); }
.trend.down { color: var(--muted); }

.db-watch { display: grid; gap: 6px; }
.db-watch-row { display: grid; grid-template-columns: 10px minmax(0, 1.3fr) minmax(0, 2fr) auto; gap: 14px; align-items: center;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: inherit; text-decoration: none; }
.db-watch-row:hover { border-color: var(--route); }
.db-watch-row.s-alerte { box-shadow: inset 3px 0 0 var(--db-alerte); }
.db-watch-row.s-attention { box-shadow: inset 3px 0 0 var(--db-attention); }
.w-main { display: grid; min-width: 0; }
.w-fam { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--faint); }
.w-why { color: var(--muted); font-size: 14px; }
.w-state { font-size: 12px; font-weight: 700; }
.s-alerte .w-state { color: #C0574B; }
.s-attention .w-state { color: #A8740E; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--db-gris); flex: none; }
.s-alerte > .dot, .s-alerte .db-name > .dot, .db-row.s-alerte .dot { background: var(--db-alerte); }
.s-attention > .dot, .s-attention .db-name > .dot, .db-row.s-attention .dot { background: var(--db-attention); }
.s-ok > .dot, .s-ok .db-name > .dot, .db-row.s-ok .dot { background: var(--db-bon); }
.s-vide .db-name > .dot { background: transparent; border: 1.5px solid var(--db-gris); }

.db-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.db-head, .db-row { display: grid; grid-template-columns: minmax(260px, 2fr) minmax(80px, .6fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(120px, 1fr) 60px;
  gap: 18px; align-items: center; padding: 0 18px; }
.db-head { padding-top: 12px; padding-bottom: 12px; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); background: var(--page); border-bottom: 1px solid var(--line); }
.db-head span:last-child, .db-todo { text-align: right; }
.db-fam { border-top: 1px solid var(--line-2); }
.db-fam:first-of-type { border-top: 0; }
.db-fam > summary { list-style: none; cursor: pointer; padding-top: 14px; padding-bottom: 14px; }
.db-fam > summary::-webkit-details-marker { display: none; }
.db-fam > summary:hover { background: var(--page); }
.db-fam.empty > summary { color: var(--faint); }
.db-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.db-name b { font-weight: 700; }
.db-name small { font-size: 12px; color: var(--faint); font-weight: 600; }
.db-name .chev { width: 14px; height: 14px; margin-left: 2px; fill: none; stroke: var(--faint); stroke-width: 2; transition: transform .15s ease; }
.db-fam[open] .chev { transform: rotate(90deg); }
.db-cats { border-top: 1px dashed var(--line-2); background: color-mix(in srgb, var(--page) 55%, var(--surface)); padding: 4px 0 8px; }
.db-row.cat { padding-top: 9px; padding-bottom: 9px; color: inherit; text-decoration: none; font-size: 14px; }
.db-row.cat .db-name { padding-left: 19px; }
.db-row.cat .c-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-row.cat:hover { background: var(--wash); }
.db-empty { margin: 6px 18px 6px 37px; font-size: 13px; color: var(--faint); }

.db-vol { display: grid; gap: 5px; }
.db-vol .v-top { display: flex; align-items: baseline; gap: 6px; }
.db-vol b { font-size: 15px; }
.db-vol .trend { font-size: 12px; }
.db-vbar { height: 3px; border-radius: 2px; background: var(--line-2); overflow: hidden; }
.db-vbar span { display: block; height: 100%; background: var(--ink); opacity: .55; border-radius: 2px; }
.db-ratio { display: grid; grid-template-columns: minmax(40px, 1fr) 54px; gap: 10px; align-items: center; min-width: 0; }
.db-meter { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: var(--line-2); gap: 1px; }
.db-meter.empty { background: var(--line-2); opacity: .6; }
.db-meter span { min-width: 0; }
.m-ok { background: var(--db-ok); } .m-ko { background: var(--db-ko); }
.m-rep { background: var(--db-rep); } .m-hum { background: var(--db-hum); } .m-err { background: var(--db-err); }
.db-num { display: grid; justify-items: end; line-height: 1.15; }
.db-num b { font-size: 14px; }
.db-num small { font-size: 11px; color: var(--faint); }
.db-none { font-size: 13px; color: var(--faint); }
.db-todo b { font-size: 14px; }

.db-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 2px 0; font-size: 12px; color: var(--muted); }
.db-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { display: inline-block; width: 14px; height: 6px; border-radius: 3px; }
.lg-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--db-gris); margin-left: 6px; }
.lg-dot.s-alerte { background: var(--db-alerte); } .lg-dot.s-attention { background: var(--db-attention); } .lg-dot.s-ok { background: var(--db-bon); }

@media (max-width: 1100px) {
  .db-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .db-kpi:nth-child(4) { border-left: 0; }
  .db-kpi:nth-child(n+4) { border-top: 1px solid var(--line-2); }
  .db-head { display: none; }
  .db-head, .db-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 18px; }
  .db-name { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { .db-name .chev { transition: none; } }
