:root {
  --bg: #f6f5f2;
  --panel: #ffffff;
  --panel-2: #efede8;
  --text: #1d2125;
  --muted: #5d646c;
  --line: #dcd9d2;
  --accent: #1e6b52;
  --accent-soft: rgba(30, 107, 82, .12);
  --accent-text: #ffffff;
  --danger: #a3341f;
  --warn: #8a5a00;
  --c1: #1e6b52;
  --c2: #b4572a;
  --c3: #3b5ba5;
  --c4: #8a6d1d;
  --c5: #7c3f8c;
  --heat: 30, 107, 82;
  --code-bg: #f0eee9;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  /* Échelle typographique (ratio 1,25) et espacements (grille de 4 px) */
  --fs-sm: .875rem;   /* 14 px */
  --fs-md: 1rem;      /* 16 px */
  --fs-lg: 1.25rem;   /* 20 px */
  --fs-xl: 1.5625rem; /* 25 px */
  --fs-num: 2.25rem;  /* 36 px, chiffres des tuiles */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14171a; --panel: #1c2024; --panel-2: #23282d; --text: #e6e3dc; --muted: #a2a9b0;
    --line: #2f353b; --accent: #6cc3a0; --accent-soft: rgba(108, 195, 160, .14); --accent-text: #0d1a14;
    --danger: #ef8a73; --warn: #e2b35a;
    --c1: #6cc3a0; --c2: #ee9a6c; --c3: #8fa9ec; --c4: #d9bf6a; --c5: #c99ad6; --heat: 108, 195, 160;
    --code-bg: #23282d; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14171a; --panel: #1c2024; --panel-2: #23282d; --text: #e6e3dc; --muted: #a2a9b0;
  --line: #2f353b; --accent: #6cc3a0; --accent-soft: rgba(108, 195, 160, .14); --accent-text: #0d1a14;
  --danger: #ef8a73; --warn: #e2b35a;
  --c1: #6cc3a0; --c2: #ee9a6c; --c3: #8fa9ec; --c4: #d9bf6a; --c5: #c99ad6; --heat: 108, 195, 160;
  --code-bg: #23282d; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--fs-md)/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1 { font-size: var(--fs-xl); line-height: 1.25; margin: 0 0 var(--sp-2); font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: var(--fs-lg); line-height: 1.3; margin: 0 0 var(--sp-4); font-weight: 620; }
h3 { font-size: var(--fs-md); margin: 0 0 var(--sp-2); }
p { margin: 0 0 var(--sp-3); }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.pad { padding: var(--sp-5); }
[hidden] { display: none !important; }
code, pre, textarea.code { font-family: var(--mono); font-size: .9em; }

/* barre du haut */
.topbar { display: flex; align-items: center; gap: var(--sp-6); padding: 0 var(--sp-6); height: 60px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 1.0625rem; text-decoration: none; color: var(--text); white-space: nowrap; }
.brand span { color: var(--muted); font-weight: 500; }
.topbar nav { display: flex; gap: var(--sp-1); flex: 1; overflow-x: auto; scrollbar-width: none; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: var(--sp-2) var(--sp-3); border-radius: 8px;
  white-space: nowrap; font-weight: 500; display: inline-flex; align-items: center; gap: var(--sp-2); }
.icon { flex: none; display: block; }
.topbar nav a.active .icon { color: var(--accent); }
.topbar nav a:hover { color: var(--text); }
.topbar nav a.active { color: var(--text); background: var(--panel-2); }
.theme { min-width: 40px; min-height: 40px; justify-content: center; color: var(--muted); }
.theme:hover { color: var(--text); }

main { max-width: 1440px; margin: 0 auto; padding: var(--sp-6) var(--sp-6) var(--sp-7); outline: none; }

/* contrôles */
button, .button { font: inherit; font-size: var(--fs-md); border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: var(--sp-2) var(--sp-4); min-height: 40px; border-radius: 8px; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: var(--sp-2); }
button:hover, .button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel-2); }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; font-size: var(--fs-md); color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: var(--sp-2) var(--sp-3); min-height: 40px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: grid; gap: var(--sp-1); font-size: var(--fs-sm); color: var(--muted); }
.row { display: flex; gap: var(--sp-3); align-items: end; flex-wrap: wrap; }
.spacer { flex: 1; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--sp-5); }

/* en-tête de page et sélecteur de période */
.page-head { display: flex; justify-content: space-between; align-items: end; gap: var(--sp-5); flex-wrap: wrap;
  margin-bottom: var(--sp-5); }
.page-head h1 { margin-bottom: var(--sp-1); }
.period-label { color: var(--muted); margin: 0; }
.toolbar { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; }
.segmented { display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented .seg { white-space: nowrap; flex: none; border: 0; background: transparent; color: var(--muted); min-height: 36px; padding: var(--sp-1) var(--sp-3);
  border-radius: 8px; font-weight: 500; }
.segmented .seg:hover { color: var(--text); }
.segmented .seg.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .18); }
.custom-dates label { font-size: var(--fs-sm); }

/* tuiles */
.tiles { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: var(--sp-5); }
.tile { padding: var(--sp-4) var(--sp-5); min-width: 0; }
.tile-label { color: var(--muted); font-weight: 500; margin: 0 0 var(--sp-1); }
.tile .value { font-size: var(--fs-num); line-height: 1.15; font-weight: 650; font-variant-numeric: tabular-nums;
  letter-spacing: -.02em; margin: 0 0 var(--sp-2); }
.meta { color: var(--muted); font-size: var(--fs-sm); margin: var(--sp-3) 0 0; }
.meta code { font-size: .85em; background: var(--code-bg); padding: 1px 6px; border-radius: 4px; }
.tile .meta { margin-top: 0; }

/* panneaux de graphiques */
.grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(560px, 1fr)); }
.grid .wide { grid-column: 1 / -1; }
.grid > *, .catalog > *, .editor > *, .agent > * { min-width: 0; }
.panel { display: flex; flex-direction: column; min-width: 0; }
.panel-body { flex: 1; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.panel.is-unavailable { background: transparent; border-style: dashed; }
.unavailable { color: var(--muted); margin: var(--sp-2) 0; }
.error { color: var(--danger); }

/* graphiques */
.chart-box { position: relative; width: 100%; min-width: 0; }
.chart { display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .bar-name { fill: var(--text); font-size: 13px; }
.chart .bar-label { fill: var(--text); font-size: 13px; font-weight: 600; }
.chart .masked { fill: var(--muted); font-size: 13px; font-style: italic; }
.chart .axis { stroke: var(--line); }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .s0 { stroke: var(--c1); fill: var(--c1); }
.chart .s1 { stroke: var(--c2); fill: var(--c2); }
.chart .s2 { stroke: var(--c3); fill: var(--c3); }
.chart .s3 { stroke: var(--c4); fill: var(--c4); }
.chart .s4 { stroke: var(--c5); fill: var(--c5); }
.chart path.line { fill: none; stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--panel); stroke-width: 2; }
.chart .cursor { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .hit { fill: transparent; cursor: crosshair; }
.tooltip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
  min-width: 160px; max-width: 260px; z-index: 2; font-variant-numeric: tabular-nums; }
.tooltip strong { display: block; margin-bottom: 2px; font-weight: 600; }
.tooltip div { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.tooltip b { color: var(--text); margin-left: auto; padding-left: var(--sp-3); }
.tooltip i, .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend { display: flex; gap: var(--sp-2) var(--sp-4); flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); margin-top: var(--sp-3); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.s0 { background: var(--c1); } .s1 { background: var(--c2); } .s2 { background: var(--c3); }
.s3 { background: var(--c4); } .s4 { background: var(--c5); }
.chart .s0, .chart .s1, .chart .s2, .chart .s3, .chart .s4 { background: none; }
.masked-note { color: var(--muted); font-size: var(--fs-sm); font-style: italic; margin: var(--sp-2) 0 0; }
.cohort td { text-align: center; min-width: 3.5rem; }

/* tableaux */
.table-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .9375rem; font-variant-numeric: tabular-nums; }
th, td { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: var(--panel-2); position: sticky; top: 0; font-weight: 600; font-size: var(--fs-sm); }
th.num, td.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }

/* catalogue */
.catalog { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: var(--sp-5); align-items: start; }
.list { display: grid; gap: 2px; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.list button { text-align: left; border-color: transparent; background: transparent; padding: var(--sp-2) var(--sp-3);
  display: block; width: 100%; line-height: 1.35; }
.list button:hover { background: var(--panel-2); }
.list button.active { background: var(--panel); border-color: var(--line); }
.list button small { display: block; color: var(--muted); font-family: var(--mono); font-size: .8rem; margin-top: 2px; }

/* fiches */
.md { line-height: 1.65; max-width: 760px; font-size: 1.0625rem; }
.md h1 { font-size: var(--fs-xl); } .md h2 { font-size: var(--fs-lg); margin-top: var(--sp-5); }
.md img { max-width: 100%; border-radius: 8px; }
.md-chart { margin: var(--sp-4) 0; padding: var(--sp-4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.md-chart .chart-title { font-weight: 600; margin-bottom: var(--sp-3); }
.md-chart .chart-source { color: var(--muted); font-size: var(--fs-sm); margin: var(--sp-3) 0 0; }
.md-chart .chart-source.warn { color: var(--warn); }
.md-chart-error { color: var(--danger); border: 1px dashed var(--danger); border-radius: 8px; padding: var(--sp-3); margin: var(--sp-3) 0; }
.md pre { background: var(--code-bg); padding: var(--sp-3); border-radius: 8px; overflow: auto; }
.md code { background: var(--code-bg); padding: .1rem .35rem; border-radius: 4px; }
.md pre code { background: none; padding: 0; }
.md table { width: auto; margin: var(--sp-3) 0; }
.md blockquote { margin: 0; padding-left: var(--sp-4); border-left: 3px solid var(--line); color: var(--muted); }
.md a[data-host]::after { content: " (" attr(data-host) ")"; color: var(--muted); font-size: .8em; }
.editor { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.editor textarea { width: 100%; min-height: 62vh; resize: vertical; line-height: 1.6; }
.conflict { border-color: var(--warn); }
.fiche-list a { display: flex; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) var(--sp-1);
  border-bottom: 1px solid var(--line); text-decoration: none; color: var(--text); }
.fiche-list a:last-child { border-bottom: 0; }
.fiche-list small { color: var(--muted); white-space: nowrap; }
.fiche-list a[hidden] { display: none; }
.fiche-toolbar { align-items: center; }
.fiche-toolbar input[type="search"] { min-width: 240px; }
.fiche-action { margin-bottom: var(--sp-4); border-color: var(--muted); }
.fiche-action p:last-child { margin-bottom: 0; }
.fiche-action label { flex: 1; min-width: 240px; }
.fiche-action input { width: 100%; }
.deleted-fiches { margin-top: var(--sp-5); }
.deleted-fiches summary { cursor: pointer; font-weight: 600; }
.deleted-fiches ul { list-style: none; margin: var(--sp-3) 0 0; padding: 0; }
.deleted-fiches li { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
.deleted-fiches li:last-child { border-bottom: 0; }
.deleted-fiches small { color: var(--muted); }

/* agent */
/* La page Agent tient dans la fenêtre : barre du haut (60 px + filet) et marges de <main> déduites. */
.agent { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: var(--sp-4);
  height: calc(100dvh - 61px - var(--sp-6) - var(--sp-7)); min-height: 480px; }
.agent-side .convs { flex: 1; min-height: 0; }
.agent.with-panel { grid-template-columns: 240px minmax(0, 1fr) minmax(360px, 38%); }
.agent:not(.with-panel) .fiche-panel { display: none; }
.agent-side { display: flex; flex-direction: column; gap: var(--sp-3); min-height: 0; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.panel-toggle { white-space: nowrap; flex: none; }
.panel-toggle[aria-expanded="true"] { background: var(--panel-2); }
.fiche-panel { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--sp-4) var(--sp-5); }
.fiche-panel-head { display: flex; gap: var(--sp-2); align-items: center; }
.fiche-panel-head select { flex: 1; min-width: 0; }
.fiche-panel .meta { margin: var(--sp-2) 0 var(--sp-3); }
.fiche-body { flex: 1; overflow: auto; max-width: none; font-size: var(--fs-md); padding-right: var(--sp-2); }
.convs { overflow: auto; }
.convs button { width: 100%; text-align: left; border-color: transparent; background: transparent; margin-bottom: 2px;
  display: block; line-height: 1.35; }
.convs button:hover { background: var(--panel-2); }
.convs button.active { background: var(--panel); border-color: var(--line); }
.convs .busy::after { content: " ●"; color: var(--accent); }
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); }
.chat-head { padding: var(--sp-4) var(--sp-5) 0; }
.chat-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head h2 { margin: 0; }
.messages { flex: 1; overflow: auto; padding: var(--sp-4) var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-3); }
.msg-user { align-self: flex-end; background: var(--panel-2); padding: var(--sp-2) var(--sp-4); border-radius: 12px; max-width: 78%;
  white-space: pre-wrap; }
.msg-user .atts { font-size: var(--fs-sm); color: var(--muted); margin-top: var(--sp-1); }
.msg-agent { max-width: 100%; display: flex; flex-direction: column; gap: var(--sp-2); }
.msg-agent .md { max-width: 820px; font-size: var(--fs-md); }
.draft { white-space: pre-wrap; color: var(--text); }
details.tool { border: 1px solid var(--line); border-radius: 8px; font-size: var(--fs-sm); }
details.tool summary { cursor: pointer; padding: var(--sp-2) var(--sp-3); color: var(--muted); font-family: var(--mono); }
details.tool pre { margin: 0; padding: var(--sp-3); border-top: 1px solid var(--line); overflow: auto; max-height: 320px;
  white-space: pre-wrap; word-break: break-word; }
details.tool.err summary { color: var(--danger); }
.status-line { font-size: var(--fs-sm); color: var(--muted); }
.composer { border-top: 1px solid var(--line); padding: var(--sp-3); display: grid; gap: var(--sp-2); }
.queue { display: flex; flex-direction: column; gap: var(--sp-1); }
.queue .q { display: flex; align-items: center; gap: var(--sp-2); background: var(--panel-2); border-radius: 8px; padding: var(--sp-1) var(--sp-1) var(--sp-1) var(--sp-3); }
.queue .q button.text { flex: 1; text-align: left; background: none; border: 0; padding: 0; min-height: 32px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; color: var(--text); display: block; }
.queue .q button.x { padding: 0 var(--sp-2); min-height: 32px; }
.queue .label { font-size: var(--fs-sm); color: var(--muted); }
.composer textarea { width: 100%; min-height: 5rem; max-height: 40vh; resize: vertical; }
.composer .toolbar { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: var(--sp-1); flex-wrap: wrap; }
.chip { font-size: var(--fs-sm); background: var(--panel-2); border-radius: 999px; padding: 2px 4px 2px 10px; display: inline-flex; align-items: center; }
.chip button { padding: 0 6px; border: 0; background: none; min-height: 28px; }

/* campagnes ExoClick */
.camp > * { margin: 0 0 var(--sp-4); }
.camp > .tiles { margin-bottom: var(--sp-4); }
.crumb { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); }
.check { display: inline-flex; flex-direction: row; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); color: var(--text); min-height: 40px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.card-head h2 { margin: 0; }
.card-head p { margin: 0; }
.badge { display: inline-block; font-size: var(--fs-sm); font-weight: 550; line-height: 1.4; padding: 1px 8px; border-radius: 6px;
  background: var(--panel-2); color: var(--muted); vertical-align: middle; white-space: nowrap; }
.badge.on { background: var(--accent-soft); color: var(--accent); }
.badge.done { color: var(--text); }
.badge.gone { background: transparent; border: 1px dashed var(--line); }
h1 .badge { font-size: var(--fs-sm); margin-left: var(--sp-2); position: relative; top: -3px; }
th button.sort { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; }
th button.sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
th[aria-sort="descending"] button.sort::after { content: "▾"; color: var(--accent); }
th[aria-sort="ascending"] button.sort::after { content: "▴"; color: var(--accent); }
tr.link-row:hover td { background: var(--panel-2); }
.camp-name { display: inline-flex; flex-direction: column; min-width: 190px; max-width: 280px; white-space: normal; overflow-wrap: anywhere; font-weight: 550; }
.camp-name small { color: var(--muted); font-weight: 400; font-size: .8125rem; }
.campaigns-table .table-wrap { max-height: none; }
.budget { display: inline-grid; gap: 4px; min-width: 150px; }
.meter { display: block; height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.facts { display: grid; grid-template-columns: minmax(150px, max-content) 1fr; gap: var(--sp-2) var(--sp-5); margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.warn-list { color: var(--warn); margin: 0 0 var(--sp-4); padding-left: var(--sp-5); }
.stack { display: grid; gap: var(--sp-4); align-content: start; min-width: 0; }
.targeting { display: grid; gap: var(--sp-4); margin: 0; }
.targeting dt { font-weight: 600; }
.targeting dd { margin: var(--sp-1) 0 0; display: grid; gap: var(--sp-2); }
.tg-kind { color: var(--muted); font-size: var(--fs-sm); margin: 0 0 var(--sp-1); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: var(--fs-sm); padding: 2px 8px; border-radius: 6px; background: var(--panel-2); }
.tag.out { background: transparent; border: 1px solid var(--line); color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }
details.more { width: 100%; }
details.more summary { cursor: pointer; color: var(--accent); font-size: var(--fs-sm); margin: var(--sp-1) 0; }
.variations { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.variation { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.variation img, .variation .no-image { width: 100%; aspect-ratio: 6 / 5; object-fit: contain; background: var(--panel-2); display: block; }
.variation .no-image { display: grid; place-items: center; color: var(--muted); }
.variation-body { padding: var(--sp-3) var(--sp-4) var(--sp-4); display: grid; gap: var(--sp-1); }
.variation-body p { margin: 0; }
.variation-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); }
.landing { overflow-wrap: anywhere; }
.mini-stats { display: grid; grid-template-columns: repeat(4, auto); gap: 0 var(--sp-3); margin: var(--sp-2) 0 0; font-variant-numeric: tabular-nums; }
.mini-stats dt { color: var(--muted); font-size: .8125rem; grid-row: 1; }
.mini-stats dd { margin: 0; font-weight: 600; grid-row: 2; }
.segmented.scroll { max-width: 100%; overflow-x: auto; scrollbar-width: thin; margin-bottom: var(--sp-4); }
.breakdown-chart { margin-bottom: var(--sp-4); }
.breakdown-chart h3 { color: var(--muted); font-weight: 500; font-size: var(--fs-sm); }

/* connexion */
.auth { max-width: 420px; margin: 12vh auto; padding: 0 var(--sp-4); }
.auth .card { display: grid; gap: var(--sp-4); }
.auth form { display: grid; gap: var(--sp-4); }
.auth input { width: 100%; }

#toast { position: fixed; bottom: var(--sp-4); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: var(--sp-2) var(--sp-4); border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: .95; }

@media (max-width: 1180px) {
  .grid { grid-template-columns: 1fr; }
  .agent.with-panel { grid-template-columns: minmax(0, 1fr) minmax(320px, 42%); }
  .agent.with-panel .agent-side { display: none; }
}
@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; height: auto; gap: 0 var(--sp-3); padding: var(--sp-2) var(--sp-4) 0; }
  .topbar nav { order: 3; flex-basis: 100%; margin: 0 calc(-1 * var(--sp-2)); padding-bottom: var(--sp-1); }
  .topbar nav a { padding: var(--sp-2); gap: 6px; }
  .topbar nav { justify-content: space-between; }
  /* Mobile : icônes seules, libellé de la page active seulement (gardé pour les lecteurs d'écran). */
  .topbar nav a:not(.active) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .theme { margin-left: auto; }
  main { padding: var(--sp-4) var(--sp-4) var(--sp-6); }
  .card { padding: var(--sp-4); }
  .page-head { align-items: start; }
  .toolbar { width: 100%; }
  .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3); }
  .tile { padding: var(--sp-3) var(--sp-4); }
  .tile .value { font-size: 1.5rem; overflow-wrap: anywhere; }
  .tile-label { font-size: var(--fs-sm); }
  .catalog, .editor, .agent { grid-template-columns: 1fr; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dd { margin-bottom: var(--sp-2); }
  .variations { grid-template-columns: 1fr; }
  .card > table, .card > table tbody, .card > table tr, .card > table td { display: block; width: 100%; }
  .card > table tr { padding: var(--sp-2) 0; border-bottom: 1px solid var(--line); }
  .card > table td { border: 0; padding: var(--sp-1) 0; white-space: normal; }
  .list { position: static; max-height: 40vh; }
  .agent, .agent.with-panel { height: auto; grid-template-columns: 1fr; }
  .agent.with-panel .agent-side { display: flex; }
  .fiche-panel { max-height: 80vh; }
  .chat { height: 78vh; }
  .convs { max-height: 30vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
