/* Agent Vault — système de design (docs/DESIGN.md).
   Jetons sur :root, composants ensuite. Aucun style en ligne : la CSP l'interdit. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-wght.8e433c0592f7.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url("../fonts/inter-latin-ext-wght.ad4eb06671be.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* --- Jetons ------------------------------------------------------------------------- */

:root {
  color-scheme: light;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --bg: #fbfbfc;
  --surface: #ffffff;
  --surface-2: #f4f4f6;
  --surface-3: #ececf0;
  --line: #e4e4e9;
  --line-strong: #d4d4db;
  --fg: #1b1b1f;
  --fg-2: #4a4a55;
  --muted: #6e6e7a;
  --faint: #9a9aa5;

  --accent: #5b5bd6;
  --accent-hover: #4b4bc4;
  --accent-fg: #ffffff;
  --accent-soft: #ededfc;
  --accent-text: #4545b8;

  --success: #18794e;
  --success-soft: #e6f6ee;
  --warning: #a35200;
  --warning-soft: #fff1e0;
  --danger: #cd2b31;
  --danger-hover: #b5242a;
  --danger-soft: #fdeceb;
  --info: #0b68cb;
  --info-soft: #e8f2fd;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgb(16 16 24 / 0.05);
  --shadow: 0 1px 3px rgb(16 16 24 / 0.07), 0 1px 2px rgb(16 16 24 / 0.04);
  --shadow-lg: 0 12px 32px -6px rgb(16 16 24 / 0.18), 0 4px 10px -4px rgb(16 16 24 / 0.08);
  --ring: 0 0 0 3px rgb(91 91 214 / 0.28);

  --sidebar-w: 248px;
  --content-w: 1120px;
  --header-h: 56px;
  --tabbar-h: 60px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111114;
    --surface: #18181c;
    --surface-2: #1f1f24;
    --surface-3: #2a2a31;
    --line: #2a2a31;
    --line-strong: #3a3a43;
    --fg: #ededf0;
    --fg-2: #c4c4cc;
    --muted: #9696a2;
    --faint: #6c6c78;
    --accent: #7c7cf0;
    --accent-hover: #8f8ff5;
    --accent-fg: #0f0f1f;
    --accent-soft: #23234a;
    --accent-text: #a5a5ff;
    --success: #3dd68c;
    --success-soft: #11291e;
    --warning: #f5a524;
    --warning-soft: #2e2210;
    --danger: #ff6369;
    --danger-hover: #ff7b80;
    --danger-soft: #331618;
    --info: #52a9ff;
    --info-soft: #10243a;
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow: 0 1px 3px rgb(0 0 0 / 0.5);
    --shadow-lg: 0 16px 40px -8px rgb(0 0 0 / 0.7);
    --ring: 0 0 0 3px rgb(124 124 240 / 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111114;
  --surface: #18181c;
  --surface-2: #1f1f24;
  --surface-3: #2a2a31;
  --line: #2a2a31;
  --line-strong: #3a3a43;
  --fg: #ededf0;
  --fg-2: #c4c4cc;
  --muted: #9696a2;
  --faint: #6c6c78;
  --accent: #7c7cf0;
  --accent-hover: #8f8ff5;
  --accent-fg: #0f0f1f;
  --accent-soft: #23234a;
  --accent-text: #a5a5ff;
  --success: #3dd68c;
  --success-soft: #11291e;
  --warning: #f5a524;
  --warning-soft: #2e2210;
  --danger: #ff6369;
  --danger-hover: #ff7b80;
  --danger-soft: #331618;
  --info: #52a9ff;
  --info-soft: #10243a;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow: 0 1px 3px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 16px 40px -8px rgb(0 0 0 / 0.7);
  --ring: 0 0 0 3px rgb(124 124 240 / 0.4);
}

/* --- Base --------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  overflow-x: hidden;
  font: 14px/1.55 var(--font);
  font-feature-settings: "cv11", "ss01";
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 600; letter-spacing: -0.011em; }
h1 { font-size: 20px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, kbd, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
pre { white-space: pre-wrap; word-break: break-word; margin: 0; }
kbd {
  display: inline-block; min-width: 18px; padding: 0 5px; border: 1px solid var(--line-strong);
  border-bottom-width: 2px; border-radius: 4px; font-size: 11px; line-height: 16px;
  color: var(--muted); background: var(--surface); text-align: center;
}
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
small { font-size: 12px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }

.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

/* --- Cadre de l'application ---------------------------------------------------------- */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--surface-2); border-right: 1px solid var(--line); padding: 12px 10px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; color: var(--fg); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6); color: #fff;
}
.brand-mark .icon { width: 15px; height: 15px; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; margin-bottom: 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--muted); font: inherit; cursor: pointer; text-align: left;
}
.search-trigger:hover { border-color: var(--line-strong); color: var(--fg-2); }
.search-trigger > span { flex: 1; }
.nav-section { margin-top: 14px; }
.nav-label { padding: 0 8px 4px; font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 5px 8px; border-radius: var(--radius-sm);
  color: var(--fg-2); font-weight: 500;
}
.nav-item:hover { background: var(--surface-3); color: var(--fg); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }
.nav-item .icon { color: var(--muted); }
.nav-item[aria-current="page"] .icon { color: var(--accent); }
.nav-item > span:not(.count) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count {
  min-width: 20px; padding: 0 6px; border-radius: 10px; font-size: 11px; font-weight: 600;
  line-height: 18px; text-align: center; background: var(--surface-3); color: var(--fg-2);
}
.count.hot { background: var(--accent); color: var(--accent-fg); }
.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.health { display: grid; gap: 6px; padding: 4px 8px; font-size: 12px; color: var(--muted); }
.health-row { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot.warn { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.user-menu { display: flex; align-items: center; gap: 4px; padding: 0 4px; }
.user-menu .grow { flex: 1; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: none; position: sticky; top: 0; z-index: 20; height: var(--header-h);
  align-items: center; gap: 8px; padding: 0 12px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.topbar .brand { padding: 0; flex: 1; }
.banner {
  display: flex; align-items: center; gap: 10px; padding: 8px 24px; font-size: 13px; font-weight: 500;
  background: var(--danger-soft); color: var(--danger); border-bottom: 1px solid var(--line);
}
.banner.warn { background: var(--warning-soft); color: var(--warning); }
.banner form { margin-left: auto; }
.page { width: 100%; max-width: var(--content-w); margin: 0 auto; padding: 28px 32px 64px; }
.page-narrow { max-width: 760px; }

.page-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-header .titles { flex: 1; min-width: 240px; }
.page-header h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-header .lede { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumbs { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--fg); }

.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.layout-2 > * { min-width: 0; }
.layout-2 > aside { position: sticky; top: 20px; display: grid; gap: 16px; }
.layout-side { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.stack-sm { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.cluster { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

/* --- Barre d'onglets mobile et tiroir ------------------------------------------------- */

.tabbar {
  display: none; position: fixed; inset: auto 0 0 0; z-index: 30; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); border-top: 1px solid var(--line);
  grid-template-columns: repeat(5, 1fr);
}
.tabbar a, .tabbar button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font: 500 11px var(--font); background: none; border: 0; cursor: pointer;
}
.tabbar a:hover { text-decoration: none; }
.tabbar button, .tabbar button:hover { height: auto; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
.tabbar [aria-current="page"] { color: var(--accent-text); }
.tabbar .icon { width: 20px; height: 20px; }
.tabbar .count { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 16px; line-height: 16px; font-size: 10px; padding: 0 4px; }
.scrim { position: fixed; inset: 0; z-index: 40; background: rgb(0 0 0 / 0.35); }

/* La barre latérale prend 248 px : deux colonnes seulement s'il reste de la place. */
@media (max-width: 1180px) {
  .layout-2 { grid-template-columns: minmax(0, 1fr); }
  .layout-2 > aside { position: static; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 900px) {
  .layout-side { grid-template-columns: minmax(0, 1fr); }
  .layout-2 > aside { position: static; }
}
@media (max-width: 760px) {
  .app { display: block; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 50; width: min(84vw, 300px); transform: translateX(-102%);
    transition: transform 0.22s var(--ease); box-shadow: var(--shadow-lg);
  }
  body.drawer-open .sidebar { transform: none; }
  .topbar { display: flex; }
  .tabbar { display: grid; }
  .page { padding: 18px 16px calc(var(--tabbar-h) + 32px); }
  .banner { padding: 8px 16px; }
  input, select, textarea { font-size: 16px !important; }
  .hide-mobile { display: none !important; }
}
@media (min-width: 761px) { .show-mobile { display: none !important; } }

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

.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg);
  font: 500 13px var(--font); white-space: nowrap; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover, button:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary, button.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover, button.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger, button.btn-danger, button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover, button.btn-danger:hover, button.danger:hover { background: var(--danger-hover); }
.btn-ghost, button.btn-ghost, button.link {
  background: transparent; border-color: transparent; box-shadow: none; color: var(--fg-2);
}
.btn-ghost:hover, button.btn-ghost:hover, button.link:hover { background: var(--surface-3); color: var(--fg); }
.btn-ghost.danger-text, button.btn-ghost.danger-text { color: var(--danger); }
.btn-ghost.danger-text:hover { background: var(--danger-soft); }
.btn-sm, button.btn-sm, button.link { height: 26px; padding: 0 8px; font-size: 12.5px; }
.btn-lg { height: 38px; padding: 0 16px; font-size: 14px; }
.btn-icon, button.btn-icon { width: 32px; padding: 0; }
.btn-icon.btn-sm { width: 26px; }
.btn-block { width: 100%; }
button:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: progress; }
button.htmx-request { opacity: 0.6; cursor: progress; }
form.inline { display: inline; margin: 0; }

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

.form { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 550; color: var(--fg-2); }
.field .help, .help { font-size: 12px; color: var(--muted); }
.field.required > label::after { content: " *"; color: var(--danger); }
input, select, textarea {
  width: 100%; min-height: 34px; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); font: 14px var(--font); box-shadow: var(--shadow-sm);
  transition: border-color 0.12s, box-shadow 0.12s;
}
textarea { min-height: 84px; line-height: 1.5; resize: vertical; }
textarea.mono, .mono textarea { font: 12.5px/1.55 var(--mono); }
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select[multiple] { background-image: none; padding-right: 10px; min-height: 120px; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }
input[type="checkbox"], input[type="radio"] {
  width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0; accent-color: var(--accent); box-shadow: none; flex: none;
}
.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.choices > div, .choice {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface);
}
.choices label, .choice label { display: flex; align-items: center; gap: 8px; font-weight: 450; color: var(--fg); cursor: pointer; width: 100%; }
.check { display: flex; align-items: flex-start; gap: 8px; }
.check > input { margin-top: 2px; }
.check label { font-weight: 450; color: var(--fg); }
.errorlist { margin: 0; padding: 0; list-style: none; color: var(--danger); font-size: 12.5px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.searchbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.searchbar .grow { flex: 1 1 220px; position: relative; }
.searchbar .grow .icon { position: absolute; left: 10px; top: 9px; color: var(--faint); }
.searchbar .grow input { padding-left: 32px; }
.searchbar select { width: auto; }

/* --- Cartes, listes, tableaux -------------------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-header h2 { flex: 1; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.card-header h2 .icon { color: var(--muted); }
.card-body { padding: 16px; }
.card-footer { padding: 10px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card.danger-zone { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.row-item { display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px; color: inherit; }
a.row-item:hover, .row-item.hoverable:hover { background: var(--surface-2); text-decoration: none; }
.row-item .lead { flex: none; margin-top: 2px; color: var(--muted); }
.row-item .body { flex: 1; min-width: 0; }
.row-item .title { font-weight: 550; color: var(--fg); overflow-wrap: anywhere; }
.row-item .sub { margin-top: 3px; font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.row-item .trail { flex: none; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.row-actions { display: flex; gap: 2px; flex-wrap: wrap; margin-top: 8px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 550; font-size: 12px; color: var(--muted); padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }

dl.props { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13px; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; overflow-wrap: anywhere; }

/* --- Badges et indicateurs ----------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 10px;
  font-size: 11.5px; font-weight: 550; white-space: nowrap; background: var(--surface-3); color: var(--fg-2);
}
.badge .dot { width: 6px; height: 6px; box-shadow: none; background: currentColor; }
.badge.tone-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.tone-success { background: var(--success-soft); color: var(--success); }
.badge.tone-warning { background: var(--warning-soft); color: var(--warning); }
.badge.tone-danger { background: var(--danger-soft); color: var(--danger); }
.badge.tone-info { background: var(--info-soft); color: var(--info); }
.badge.outline { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }
.badge.mono { font-family: var(--mono); font-weight: 450; }

.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.meter.warn > span { background: var(--warning); }
.meter.bad > span { background: var(--danger); }
.meter-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
/* Largeurs par pas de 5 % : pas de style en ligne (CSP). */
.w-0{width:0}.w-5{width:5%}.w-10{width:10%}.w-15{width:15%}.w-20{width:20%}.w-25{width:25%}.w-30{width:30%}.w-35{width:35%}.w-40{width:40%}.w-45{width:45%}.w-50{width:50%}.w-55{width:55%}.w-60{width:60%}.w-65{width:65%}.w-70{width:70%}.w-75{width:75%}.w-80{width:80%}.w-85{width:85%}.w-90{width:90%}.w-95{width:95%}.w-100{width:100%}

.score { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; font-weight: 700; font-size: 15px; background: var(--surface-3); }
.score.tone-success { background: var(--success-soft); color: var(--success); }
.score.tone-warning { background: var(--warning-soft); color: var(--warning); }
.score.tone-danger { background: var(--danger-soft); color: var(--danger); }

/* --- Statistiques -------------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  display: grid; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); color: inherit; box-shadow: var(--shadow-sm); transition: border-color 0.12s, transform 0.12s;
}
a.stat:hover { border-color: var(--line-strong); text-decoration: none; transform: translateY(-1px); }
.stat .stat-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .stat-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; line-height: 1.1; }
.stat .stat-note { font-size: 12px; color: var(--faint); }
.stat.hot { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.stat.hot .stat-value { color: var(--accent-text); }

/* --- Onglets ------------------------------------------------------------------------- */

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; margin-bottom: -1px; white-space: nowrap;
  color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--fg); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--fg); border-bottom-color: var(--accent); }
.tabs .count { font-size: 10.5px; line-height: 16px; }
.segmented { display: inline-flex; padding: 2px; border-radius: var(--radius-sm); background: var(--surface-3); gap: 2px; }
.segmented a { padding: 3px 10px; border-radius: 4px; color: var(--muted); font-size: 12.5px; font-weight: 500; }
.segmented a:hover { text-decoration: none; color: var(--fg); }
.segmented a[aria-current="page"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow-sm); }

.side-nav { display: grid; gap: 2px; position: sticky; top: 20px; }
.side-nav a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm); color: var(--fg-2); font-weight: 500; }
.side-nav a > span:not(.count) { flex: 1; min-width: 0; }
.side-nav a:hover { background: var(--surface-3); text-decoration: none; }
.side-nav a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow-sm); color: var(--fg); }
.side-nav a .icon { color: var(--muted); }

/* --- Alertes, état vide, pagination -------------------------------------------------- */

.callout { display: flex; gap: 10px; padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; }
.callout > .icon { margin-top: 1px; }
.callout .callout-body { flex: 1; min-width: 0; }
.callout.tone-info { background: var(--info-soft); border-color: transparent; color: var(--fg); }
.callout.tone-info > .icon { color: var(--info); }
.callout.tone-warning { background: var(--warning-soft); border-color: transparent; }
.callout.tone-warning > .icon { color: var(--warning); }
.callout.tone-danger { background: var(--danger-soft); border-color: transparent; }
.callout.tone-danger > .icon { color: var(--danger); }
.callout.tone-success { background: var(--success-soft); border-color: transparent; }
.callout.tone-success > .icon { color: var(--success); }

.empty { display: grid; justify-items: center; gap: 8px; padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .empty-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-3); color: var(--muted); }
.empty .empty-icon .icon { width: 22px; height: 22px; }
.empty strong { color: var(--fg); font-weight: 600; }
.empty p { max-width: 46ch; margin: 0; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.pagination .cluster { gap: 4px; }

/* --- Toasts, dialogues, palette ------------------------------------------------------ */

.toasts { position: fixed; z-index: 60; right: 20px; bottom: 20px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px 11px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: 13px;
  animation: toast-in 0.24s var(--ease);
}
.toast .icon { margin-top: 1px; }
.toast.tone-success .icon { color: var(--success); }
.toast.tone-danger .icon { color: var(--danger); }
.toast.tone-info .icon { color: var(--info); }
.toast.tone-warning .icon { color: var(--warning); }
.toast > div { flex: 1; }
.toast button { height: 22px; width: 22px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@media (max-width: 760px) { .toasts { right: 16px; left: 16px; width: auto; bottom: calc(var(--tabbar-h) + 16px); } }

dialog {
  width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--fg); box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgb(10 10 16 / 0.45); backdrop-filter: blur(2px); }
dialog[open] { animation: dialog-in 0.18s var(--ease); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
.dialog-body { padding: 18px 20px; display: grid; gap: 8px; }
.dialog-body h2 { font-size: 15px; }
.dialog-body p { color: var(--fg-2); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--surface-2); }

dialog.palette { width: min(620px, calc(100vw - 24px)); margin-top: 12vh; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.palette-input .icon { color: var(--muted); }
.palette-input input { border: 0; box-shadow: none; padding: 0; min-height: 28px; font-size: 15px; background: transparent; }
.palette-input input:focus { box-shadow: none; }
.palette-results { max-height: min(56vh, 440px); overflow-y: auto; padding: 6px; }
.palette-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--fg); }
.palette-item:hover, .palette-item[aria-selected="true"] { background: var(--surface-3); text-decoration: none; }
.palette-item .icon { color: var(--muted); }
.palette-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item small { color: var(--faint); }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--faint); background: var(--surface-2); }

/* --- Conversation (entretien, forum) et chronologie ---------------------------------- */

.chat { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.avatar {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-3); color: var(--fg-2); font-size: 12px; font-weight: 650;
}
.avatar .icon { width: 15px; height: 15px; }
.avatar.agent { background: var(--accent-soft); color: var(--accent-text); }
.avatar.client { background: var(--info-soft); color: var(--info); }
.avatar.owner { background: var(--fg); color: var(--bg); }
.bubble { flex: 1; min-width: 0; }
.bubble-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.bubble-head strong { color: var(--fg); font-weight: 600; font-size: 13px; }
.bubble-body { padding: 10px 14px; border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg); background: var(--surface); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg.mine { flex-direction: row-reverse; }
.msg.mine .bubble { display: grid; justify-items: end; }
.msg.mine .bubble-head { flex-direction: row-reverse; }
.msg.mine .bubble-body { background: var(--accent-soft); border-color: transparent; border-radius: var(--radius-lg) 4px var(--radius-lg) var(--radius-lg); max-width: 85%; }
.msg.redacted .bubble-body { color: var(--faint); font-style: italic; background: var(--surface-2); }
.text { white-space: pre-wrap; overflow-wrap: anywhere; }
.typing { animation: blink 1.2s ease-in-out infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0.35; } }
.composer {
  position: sticky; bottom: 0; padding: 12px 0 4px; background: linear-gradient(to bottom, transparent, var(--bg) 18px);
}
.composer-box { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.composer-box textarea { border: 0; box-shadow: none; padding: 4px 6px; min-height: 60px; resize: none; }
.composer-box textarea:focus { box-shadow: none; }
@media (max-width: 760px) { .composer { bottom: var(--tabbar-h); } }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline > li { position: relative; display: flex; gap: 12px; padding: 0 0 18px; }
.timeline > li:last-child { padding-bottom: 0; }
.timeline .tl-dot { position: relative; z-index: 1; flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line-strong); color: var(--muted); }
.timeline .tl-dot .icon { width: 12px; height: 12px; }
.timeline .tl-dot.tone-accent { border-color: var(--accent); color: var(--accent); }
.timeline .tl-dot.tone-success { border-color: var(--success); color: var(--success); }
.timeline .tl-dot.tone-warning { border-color: var(--warning); color: var(--warning); }
.timeline .tl-dot.tone-danger { border-color: var(--danger); color: var(--danger); }
.timeline .tl-body { flex: 1; min-width: 0; padding-top: 2px; }
.timeline .tl-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.timeline .tl-head strong { color: var(--fg); font-weight: 600; }

/* --- Markdown rendu ------------------------------------------------------------------ */

.md { overflow-wrap: anywhere; line-height: 1.6; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md table, .md pre { margin: 8px 0; }
.md ul, .md ol { padding-left: 22px; }
.md li + li { margin-top: 2px; }
.md h1, .md h2, .md h3, .md h4 { margin: 16px 0 6px; }
.md h1 { font-size: 17px; }
.md h2 { font-size: 15px; }
.md h3, .md h4 { font-size: 14px; }
.md pre { white-space: pre; overflow-x: auto; background: var(--surface-2); border: 1px solid var(--line); padding: 10px 12px; border-radius: var(--radius-sm); }
.md pre code { background: none; padding: 0; }
.md blockquote { border-left: 3px solid var(--line-strong); padding-left: 12px; color: var(--muted); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 5px 9px; text-align: left; }
.md th { background: var(--surface-2); }
.prose { max-width: 72ch; }

/* --- Utilitaires --------------------------------------------------------------------- */

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.text-danger, .error { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.notice { color: var(--accent-text); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.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; }
.secret { padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--line-strong); font: 13px var(--mono); word-break: break-all; white-space: pre-wrap; }

details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.disclosure > summary { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; font-size: 13px; }
details.disclosure > summary::before { content: ""; border-left: 5px solid currentColor; border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform 0.15s; }
details.disclosure[open] > summary::before { transform: rotate(90deg); }
details.disclosure > summary:hover { color: var(--fg); }

/* Indicateur de chargement HTMX (la feuille par défaut de HTMX est désactivée : CSP). */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-swapping { opacity: 0; transition: opacity 0.15s; }
.htmx-added { animation: fade-in 0.25s var(--ease); }
@keyframes fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media print {
  .sidebar, .topbar, .tabbar, .toasts, .page-actions { display: none !important; }
  .app { display: block; }
}

/* --- Pages hors cadre (connexion, consentement) -------------------------------------- */

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(440px, 100%); }
.auth-card.wide { width: min(640px, 100%); }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; font-weight: 650; font-size: 16px; }
.auth-brand .brand-mark { width: 32px; height: 32px; border-radius: 9px; }
.auth-card .card-body { padding: 24px; }

.trail .meter { width: 96px; }
.trail .stack-sm { gap: 4px; justify-items: end; }
details > summary.card-header { border-bottom: 0; }
details[open] > summary.card-header { border-bottom: 1px solid var(--line); }
details > summary.card-header > .icon:last-child { transition: transform 0.15s; color: var(--muted); }
details[open] > summary.card-header > .icon:last-child { transform: rotate(180deg); }
