/* Automate HSH — feuille de style
   Direction : outil interne calme et lisible pour un bailleur social.
   Palette « ardoise bleue » sur gris lin, une seule famille (Source Sans 3),
   la couleur réservée aux statuts et à l'action principale. */
:root {
  --bg: #f4f5f3;
  --bg-sidebar: #eceeeb;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --surface-3: #eef0ed;
  --border: #dfe3df;
  --border-strong: #c3cac5;
  --text: #1f2a2b;
  --text-2: #51605f;
  --text-3: #7d8a89;
  --accent: #2f6f8f;
  --accent-hover: #255b76;
  --accent-soft: #e2edf3;
  --accent-text: #24596f;
  --user-bubble: #e2edf3;
  --green: #2e7d5b; --green-soft: #e1f0e8;
  --amber: #96690f; --amber-soft: #f7ebcf;
  --red: #b8433a; --red-soft: #f7e2df;
  --orange: #b85c14; --orange-soft: #f9e8d8;
  --blue: var(--accent); --blue-soft: var(--accent-soft);
  --shadow: 0 1px 2px rgba(31, 42, 43, .05), 0 10px 30px -18px rgba(31, 42, 43, .25);
  --shadow-lg: 0 24px 60px -24px rgba(31, 42, 43, .4);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Source Sans 3', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 264px;
}
[data-theme="dark"] {
  --bg: #1c2223;
  --bg-sidebar: #171c1d;
  --surface: #242b2c;
  --surface-2: #202727;
  --surface-3: #2d3536;
  --border: #36403f;
  --border-strong: #4a5555;
  --text: #e9edeb;
  --text-2: #b0bab8;
  --text-3: #7f8b89;
  --accent: #78b4d0;
  --accent-hover: #93c5dc;
  --accent-soft: #243a44;
  --accent-text: #9fd0e6;
  --user-bubble: #2a3b43;
  --green: #6cc39a; --green-soft: #22382e;
  --amber: #e2b45a; --amber-soft: #3c321c;
  --red: #ee8378; --red-soft: #432826;
  --orange: #efa060; --orange-soft: #3f2e1f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -24px rgba(0, 0, 0, .8);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15.5px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -.005em; margin: 0; line-height: 1.25; }
h1 { font-size: 26px; } h2 { font-size: 20px; } h3 { font-size: 17px; }
p { margin: 0; }
code, pre { font-family: var(--mono); font-size: .86em; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; overflow: hidden; }
.app.sidebar-collapsed { grid-template-columns: 1fr; }
.sidebar { background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }
.app.sidebar-collapsed .sidebar { display: none; }
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; position: relative; }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 10px; }
.brand .logo { width: 36px; height: 36px; border-radius: 9px; display: block; }
.brand .name { font-size: 17px; font-weight: 600; line-height: 1.15; }
.brand .tag { font-size: 12.5px; color: var(--text-3); display: block; }
.brand .collapse { margin-left: auto; }

.new-chat { margin: 6px 12px 10px; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; width: calc(100% - 24px); text-align: left; font-weight: 600; color: var(--accent-text); }
.new-chat:hover { background: var(--accent-soft); }
.new-chat .plus { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }

.nav { padding: 4px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav button { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; text-align: left; color: var(--text-2); width: 100%; font-size: 15.5px; }
.nav button:hover { background: var(--surface); color: var(--text); }
.nav button.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav .icon { color: var(--text-3); }
.nav button.c-blue .icon { color: var(--blue); } .nav button.c-green .icon { color: var(--green); } .nav button.c-orange .icon { color: var(--orange); } .nav button.c-red .icon { color: var(--red); }
.nav button.active.c-blue { background: var(--blue-soft); color: var(--accent-text); }
.nav button.active.c-green { background: var(--green-soft); color: var(--green); }
.nav button.active.c-orange { background: var(--orange-soft); color: var(--orange); }
.nav button.active.c-red { background: var(--red-soft); color: var(--red); }
.nav .count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--amber); color: #fff; font-size: 12.5px; font-weight: 600; display: grid; place-items: center; }
.nav .lock { margin-left: auto; color: var(--text-3); display: grid; }
.nav .subnav { display: flex; flex-direction: column; gap: 1px; margin: 0 0 2px; }
.nav .subnav button { padding: 6px 12px 6px 41px; font-size: 14.5px; }
.nav .subnav button.active { background: transparent; color: var(--green); }

.recents { flex: 1; overflow-y: auto; padding: 8px 12px 10px; }
.recents h6 { margin: 12px 12px 6px; font-size: 13px; font-weight: 600; color: var(--text-3); }
.recent { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; cursor: pointer; color: var(--text-2); font-size: 14.5px; }
.recent:hover { background: var(--surface); color: var(--text); }
.recent.active { background: var(--surface); color: var(--text); }
.recent .title { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.recent .del { opacity: 0; border: 0; background: transparent; cursor: pointer; color: var(--text-3); padding: 2px; border-radius: 6px; display: grid; }
.recent:hover .del, .recent .del:focus-visible { opacity: 1; }
.recent .del:hover { color: var(--red); }

.sidebar-footer { border-top: 1px solid var(--border); padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-meta { flex: 1; min-width: 0; }
.user-meta .n { font-weight: 600; font-size: 14px; }
.user-meta .r { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- generic ---------- */
.icon { width: 18px; height: 18px; flex: none; }
.icon.sm { width: 15px; height: 15px; }
.icon.lg { width: 24px; height: 24px; }
.icon-btn { border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 6px; cursor: pointer; color: var(--text-2); display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14.5px; white-space: nowrap; color: var(--text); }
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.big { padding: 13px 20px; font-size: 16px; border-radius: 10px; width: 100%; justify-content: center; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--red); }
.btn.sm { padding: 5px 11px; font-size: 13.5px; }
.btn.block { width: 100%; justify-content: center; }
button.link { border: 0; background: none; padding: 0; color: var(--accent-text); text-decoration: underline; cursor: pointer; font-weight: 600; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue, .badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.muted { color: var(--text-3); }
.small { font-size: 13.5px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.hr { height: 1px; background: var(--border); margin: 14px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.card.flat { background: var(--surface-2); }
.block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.block > h3 { margin-bottom: 12px; }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kpi .card, .kpi .card.flat { padding: 12px 14px; }
.kpi .v { font-size: 26px; font-weight: 600; line-height: 1.1; }
.kpi .l { color: var(--text-3); font-size: 13.5px; margin-top: 3px; }
.help { font-size: 13.5px; color: var(--text-3); margin-top: 8px; }
.or { color: var(--text-3); font-size: 14px; margin: 12px 0 10px; }
dl.tile-meta, dl.meta-list { margin: 0; display: grid; gap: 6px; }
dl.tile-meta div, dl.meta-list div { display: grid; grid-template-columns: 130px 1fr; gap: 8px; font-size: 14.5px; }
dl dt { color: var(--text-3); } dl dd { margin: 0; color: var(--text); }
dl.meta-list { gap: 8px; padding: 14px 18px; background: var(--surface-2); border-radius: var(--radius-sm); }

.view { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.view-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 28px 36px 10px; max-width: 1100px; width: 100%; }
.view-header p { margin: 6px 0 0; color: var(--text-2); max-width: 62ch; }
.view-body { padding: 14px 36px 48px; max-width: 1100px; width: 100%; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; position: sticky; top: 0; z-index: 2; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.tabs button { border: 0; background: transparent; padding: 10px 14px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; display: inline-flex; align-items: center; gap: 7px; font-size: 15px; }
.tabs button.active { color: var(--accent-text); border-bottom-color: var(--accent); }
.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pills button { border: 1px solid var(--border); background: var(--surface); padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 14px; color: var(--text-2); }
.pills button.active { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; font-weight: 600; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.field .help { margin-top: 2px; }
.input, select.input, textarea.input { width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 90px; line-height: 1.5; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row .input { flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); border: 0; cursor: pointer; transition: background .15s; flex: none; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 19px; }
details.advanced { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 0 18px; }
details.advanced summary { cursor: pointer; padding: 12px 0; font-weight: 600; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details.advanced summary::before { content: ''; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-left: 4px; }
details.advanced[open] summary::before { transform: rotate(45deg); }
details.advanced .option { padding: 10px 0 12px; border-top: 1px solid var(--border); }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 4px; }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 13.5px; color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
.table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.dpe { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; font-weight: 700; color: #fff; font-size: 13px; }
.dpe-A { background: #2e9e4f; } .dpe-B { background: #52b04a; } .dpe-C { background: #b7c22c; } .dpe-D { background: #e3c82c; color: #3b3200; }
.dpe-E { background: #f0a73a; } .dpe-F { background: #e8762c; } .dpe-G { background: #d63f2a; }

/* ---------- chat ---------- */
.chat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-scroll { flex: 1; overflow-y: auto; }
.chat-inner { max-width: 760px; margin: 0 auto; padding: 24px 24px 24px; }
.hero { padding: 12vh 0 28px; }
.hero h1 { font-size: 30px; font-weight: 600; }
.hero-logo { width: 52px; height: 52px; border-radius: 13px; display: block; margin-bottom: 18px; }
.hero-note { color: var(--text-2); margin-top: 10px; max-width: 60ch; }
.hero-note.muted { color: var(--text-3); font-size: 14.5px; }
.suggestions { border-top: 1px solid var(--border); }
.suggestions-title { font-size: 13.5px; font-weight: 600; color: var(--text-3); padding: 14px 0 4px; }
.suggestions button { width: 100%; text-align: left; padding: 11px 4px; border: 0; border-bottom: 1px solid var(--border); background: transparent; cursor: pointer; color: var(--text); font-size: 15.5px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.suggestions button .icon { color: var(--text-3); opacity: 0; }
.suggestions button:hover { color: var(--accent-text); }
.suggestions button:hover .icon { opacity: 1; color: var(--accent-text); }

.msg { display: flex; gap: 14px; margin: 0 0 24px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--user-bubble); border-radius: 16px 16px 4px 16px; padding: 11px 16px; max-width: 78%; white-space: pre-wrap; }
.msg.assistant .av { width: 30px; height: 30px; border-radius: 8px; overflow: hidden; flex: none; margin-top: 2px; }
.msg.assistant .av img { width: 100%; height: 100%; display: block; }
.msg .body { min-width: 0; flex: 1; }
.msg .meta { font-size: 13px; color: var(--text-3); margin-top: 6px; display: flex; gap: 10px; align-items: center; }
.md { line-height: 1.55; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md h1 { font-size: 21px; margin: 18px 0 8px; } .md h2 { font-size: 18px; margin: 18px 0 6px; } .md h3 { font-size: 16px; margin: 14px 0 4px; }
.md p { margin: 8px 0; } .md ul, .md ol { margin: 6px 0; padding-left: 22px; } .md li { margin: 3px 0; }
.md table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-3); font-weight: 600; font-size: 13.5px; }
.md code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.md pre { background: var(--surface-3); padding: 12px 14px; border-radius: 10px; overflow-x: auto; }
.md pre code { background: transparent; padding: 0; }
.md blockquote { margin: 8px 0; padding: 4px 14px; border-left: 3px solid var(--accent); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.md em { color: var(--text-2); }
.trace { display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; font-size: 13px; color: var(--text-3); }
.trace div { display: flex; gap: 6px; align-items: center; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.src-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 12.5px; color: var(--text-2); cursor: pointer; font-family: inherit; }
.src-chip:hover { border-color: var(--accent); color: var(--accent-text); }
.src-chip.db, .src-chip.db:hover { cursor: default; border-color: var(--border); color: var(--text-2); }
.menu-block { padding: 8px 10px 10px; }
.menu-stat { font-size: 14px; margin: 2px 0; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.kb-kind { font-size: 12.5px; font-weight: 600; color: var(--text-3); padding: 10px 6px 4px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; min-width: 0; }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar-fill { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; opacity: .85; }
.bar-label { font-size: 10.5px; color: var(--text-3); white-space: nowrap; }
.persona-pick { position: relative; flex: 1; min-width: 0; }
.user-btn { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 4px; border-radius: 10px; cursor: pointer; text-align: left; }
.user-btn:hover { background: var(--surface); }
.user-btn > .icon { color: var(--text-3); margin-left: auto; }
.kb-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
.kb-tree { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; background: var(--surface-2); max-height: 680px; overflow-y: auto; }
.kb-folder { margin-bottom: 8px; }
.kb-folder-hd { display: flex; align-items: center; gap: 2px; padding: 4px; font-weight: 600; }
.kb-folder-hd .n { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; }
.kb-folder-hd .icon-btn { padding: 3px; opacity: .45; }
.kb-folder:hover .icon-btn { opacity: 1; }
.kb-doc { display: flex; flex-direction: column; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 8px 6px 26px; border-radius: 8px; cursor: pointer; color: var(--text-2); }
.kb-doc:hover { background: var(--surface); color: var(--text); }
.kb-doc.active { background: var(--accent-soft); color: var(--accent-text); }
.kb-doc .t { font-weight: 600; font-size: 14.5px; }
.kb-doc .d { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.kb-editor { min-width: 0; }
.acc-tree { max-height: 360px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.acc-dir { margin-bottom: 8px; }
.acc-team { margin: 4px 0 4px 22px; }
.acc-metiers { margin-left: 22px; display: flex; flex-direction: column; gap: 2px; }
.acc-tree label { gap: 8px; cursor: pointer; padding: 2px 0; }
.task-chip { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--accent); background: var(--surface); color: var(--accent-text); cursor: pointer; font-weight: 600; font-size: 14.5px; margin: 4px 6px 4px 0; }
.task-chip:hover { background: var(--accent); color: #fff; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer-wrap { padding: 6px 24px 16px; }
.composer { max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); padding: 10px 12px 8px; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea { width: 100%; border: 0; background: transparent; resize: none; outline: none; min-height: 44px; max-height: 220px; padding: 6px 6px 2px; font-size: 16px; line-height: 1.5; }
.composer-bar { display: flex; align-items: center; gap: 6px; padding-top: 4px; }
.composer-hint { max-width: 760px; margin: 8px auto 0; font-size: 13px; color: var(--text-3); }
.model-pick { position: relative; }
.model-pick > button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 6px 8px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-size: 14px; }
.model-pick > button:hover { background: var(--surface-3); color: var(--text); }
.menu { position: absolute; bottom: calc(100% + 6px); left: 0; min-width: 260px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 20; }
.menu button { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-3); }
.menu button .t { font-weight: 600; display: flex; gap: 8px; align-items: center; width: 100%; }
.menu button .d { font-size: 13px; color: var(--text-3); }
.send { margin-left: auto; width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; cursor: pointer; }
.send:hover { background: var(--accent-hover); }
.send:disabled { background: var(--border-strong); cursor: not-allowed; }

/* ---------- tâches ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 12px; }
.tile.disabled { opacity: .6; }
.tile .ic { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.ic { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.ic.orange { background: #f6e6d9; color: #a7532d; } .ic.blue { background: var(--accent-soft); color: var(--accent-text); } .ic.green { background: var(--green-soft); color: var(--green); } .ic.purple { background: #ebe4f5; color: #5f4a98; } .ic.gray { background: var(--surface-3); color: var(--text-2); }
[data-theme="dark"] .ic.orange { background: #46302a; color: #f0a785; } [data-theme="dark"] .ic.purple { background: #342c48; color: #bda7e8; }
.tile h3 { font-size: 19px; }
.tile .desc { color: var(--text-2); font-size: 14.5px; }
.tile .foot { display: flex; gap: 6px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.tile.new { border-style: dashed; background: transparent; align-items: center; justify-content: center; text-align: center; color: var(--text-3); cursor: pointer; min-height: 200px; font-weight: 600; }
.tile.new:hover { color: var(--accent-text); border-color: var(--accent); }

.flow { display: flex; align-items: center; overflow-x: auto; padding: 6px 2px 12px; }
.flow-node { flex: none; width: 122px; text-align: center; padding: 10px 6px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface); transition: border-color .2s, box-shadow .2s, opacity .2s; }
.flow-node .fn-ic { width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 6px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); transition: background .2s; }
.flow-node .fn-t { font-weight: 600; font-size: 13px; }
.flow-node .fn-s { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-node.n8n { border-style: dashed; }
.flow-node.running { border-color: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.flow-node.running .fn-ic { background: var(--accent); color: #fff; }
.flow-node.done { border-color: var(--green); border-style: solid; }
.flow-node.done .fn-ic { background: var(--green); color: #fff; }
.flow-node.error { border-color: var(--red); }
.flow-node.error .fn-ic { background: var(--red); color: #fff; }
.flow-node.skipped { opacity: .4; }
.flow-link { flex: none; width: 34px; height: 3px; background: repeating-linear-gradient(90deg, var(--border-strong) 0 6px, transparent 6px 12px); }
.flow-link.running { background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 12px); animation: flowdash .45s linear infinite; }
.flow-link.done { background: var(--green); }
.flow-caption { font-size: 12.5px; color: var(--text-3); margin: 0 0 12px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px var(--accent-soft); } 50% { box-shadow: 0 0 0 8px transparent; } }
@keyframes flowdash { to { background-position: 12px 0; } }
.steps { display: flex; flex-direction: column; gap: 8px; }
.step { display: flex; align-items: center; gap: 10px; font-size: 14.5px; color: var(--text-3); }
.step .st { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.step.running { color: var(--text); } .step.running .st { border-color: var(--accent); border-top-color: transparent; animation: spin .8s linear infinite; }
.step.done { color: var(--text-2); } .step.done .st { background: var(--green); border-color: var(--green); color: #fff; }
.step.error .st { background: var(--red); border-color: var(--red); color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.dropzone { display: block; border: 1.5px dashed var(--border-strong); border-radius: 12px; padding: 24px; text-align: center; color: var(--text-2); cursor: pointer; background: var(--surface-2); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .icon { display: block; margin: 0 auto 8px; color: var(--text-3); }
.dropzone input { display: none; }
.file-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 9px; background: var(--surface-3); font-size: 14px; }
pre.code { background: #1b2122; color: #e6ebe9; padding: 14px 16px; border-radius: 10px; overflow: auto; max-height: 360px; font-size: 12.5px; line-height: 1.5; margin: 0; }
.log { background: #111; color: #9fe3a7; font-family: var(--mono); font-size: 12.5px; padding: 12px 14px; border-radius: 10px; white-space: pre-wrap; max-height: 220px; overflow: auto; }
.result-summary { margin-top: 8px; }

/* ---------- drawer / modal / toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20, 28, 29, .4); z-index: 40; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 96vw); background: var(--bg); border-left: 1px solid var(--border); z-index: 41; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-head h2 { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; background: var(--surface); flex-wrap: wrap; }
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 42; padding: 20px; }
.modal .box { width: min(620px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column; animation: pop .15s ease-out; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal .box .drawer-body { padding: 18px 22px; }
.modal .box .drawer-head { border-radius: 16px 16px 0 0; }
.modal .box .drawer-foot { border-radius: 0 0 16px 16px; }
#toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; font-size: 14.5px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; animation: pop .15s; max-width: 380px; }
.toast.error { background: var(--red); color: #fff; }
.toast.success { background: var(--green); color: #fff; }

/* ---------- rapports ---------- */
.report-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.report-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 16px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); cursor: pointer; }
.report-row:last-child { border-bottom: 0; }
.report-list > .btn.block { border: 0; border-top: 1px solid var(--border); border-radius: 0; padding: 12px; }
.report-row:hover { background: var(--surface-2); }
.report-row .status { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14.5px; }
.report-row .status .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.report-row .t { font-weight: 600; }
.report-row .s { color: var(--text-2); font-size: 14.5px; margin-top: 2px; }
.report-row .m { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }
.status-realise { color: var(--green); } .status-a_valider { color: var(--amber); } .status-erreur { color: var(--red); }

/* ---------- organisation ---------- */
.tree { display: flex; flex-direction: column; gap: 12px; }
.dir { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.dir > .hd { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.dir > .hd h3 { flex: 1; }
.team { padding: 10px 16px 10px 28px; border-bottom: 1px solid var(--border); }
.team:last-child { border-bottom: 0; }
.team .hd { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.team .hd .n { flex: 1; }
.metiers { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0 24px; }
.metier { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 999px; background: var(--surface-3); font-size: 13.5px; }
.metier button, .inline-del { border: 0; background: transparent; cursor: pointer; color: var(--text-3); padding: 2px; display: grid; border-radius: 50%; }
.metier button:hover, .inline-del:hover { color: var(--red); }
.add-inline { display: inline-flex; align-items: center; gap: 5px; border: 1px dashed var(--border-strong); background: transparent; border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 13.5px; color: var(--text-3); }
.add-inline:hover { color: var(--accent-text); border-color: var(--accent); }

.empty { text-align: center; color: var(--text-3); padding: 40px 20px; border: 1px dashed var(--border); border-radius: var(--radius); }
.notice { padding: 10px 14px; border-radius: 10px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.notice .icon { margin-top: 2px; }
.notice.info { background: var(--accent-soft); color: var(--accent-text); }
.notice.warn { background: var(--amber-soft); color: var(--amber); }
.notice.ok { background: var(--green-soft); color: var(--green); }
.notice.err { background: var(--red-soft); color: var(--red); }
.key-status { font-size: 13.5px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .app.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.sidebar-collapsed .sidebar { display: flex; }
  .view-header, .view-body { padding-left: 16px; padding-right: 16px; }
  .report-row { grid-template-columns: 1fr; gap: 6px; }
  .hero { padding-top: 6vh; } .hero h1 { font-size: 24px; }
  dl.tile-meta div, dl.meta-list div { grid-template-columns: 1fr; gap: 0; }
  .kb-layout { grid-template-columns: 1fr; }
}
