/* Console chatbot — styles spécifiques (tokens + aki-app.css en base) */

.hidden { display: none !important; }
.small { font-size: var(--text-sm); }
.error { color: var(--color-danger-fg); }

code {
  font-family: var(--font-mono);
  background: var(--color-bg-subtle);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  font-size: 0.88em;
}

select option:disabled {
  color: var(--color-text-disabled);
}

/* Alias badges legacy → DS */
.badge.ok, .badge.cost-basis.ok { background: var(--color-success-bg); color: var(--color-success-fg); border-color: var(--color-success-border); }
.badge.warn, .badge.cost-basis.warn { background: var(--color-warn-bg); color: var(--color-warn-fg); border-color: var(--color-warn-border); }
.badge.err { background: var(--color-danger-bg); color: var(--color-danger-fg); border-color: var(--color-danger-border); }
.badge.type { background: var(--color-neutral-bg); color: var(--color-neutral-fg); border-color: var(--color-neutral-border); }

/* Boutons legacy (app.js génère ghost/danger sans btn) — exclure src-guess-btn / src-expand / src-cover / help-tip */
button:not(.btn):not(.src-guess-btn):not(.src-expand):not(.src-cover):not(.help-tip):not(.nav-group__toggle):not(.achatbot-feedback-fab__btn):not(.achatbot-feedback-mic):not(.achatbot-feedback-attach-link):not(.achatbot-feedback-attach-item__remove):not(.sys-prompt-accordion__toggle):not(.costs-sort-btn) {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--radius-md);
  font-size: var(--text-base); font-weight: var(--weight-medium); line-height: 1;
  height: 30px; border: 1px solid transparent; cursor: pointer;
  background: var(--color-primary-600); color: var(--color-text-on-primary);
  transition: all var(--duration-fast);
}
button:not(.btn):not(.src-guess-btn):not(.src-expand):not(.src-cover):not(.help-tip):not(.nav-group__toggle):not(.achatbot-feedback-fab__btn):not(.achatbot-feedback-mic):not(.achatbot-feedback-attach-link):not(.achatbot-feedback-attach-item__remove):not(.sys-prompt-accordion__toggle):not(.costs-sort-btn):hover { background: var(--color-primary-700); }
button:not(.btn):not(.src-guess-btn):not(.src-expand):not(.src-cover):not(.help-tip):not(.nav-group__toggle):not(.achatbot-feedback-fab__btn):not(.achatbot-feedback-mic):not(.achatbot-feedback-attach-link):not(.achatbot-feedback-attach-item__remove):not(.sys-prompt-accordion__toggle):not(.costs-sort-btn).ghost {
  background: transparent; color: var(--color-text-muted);
  border-color: var(--color-border-strong);
}
button:not(.btn):not(.src-guess-btn):not(.src-expand):not(.src-cover):not(.help-tip):not(.nav-group__toggle):not(.achatbot-feedback-fab__btn):not(.achatbot-feedback-mic):not(.achatbot-feedback-attach-link):not(.achatbot-feedback-attach-item__remove):not(.sys-prompt-accordion__toggle):not(.costs-sort-btn).ghost:hover { background: var(--color-bg-subtle); color: var(--color-text); }
button:not(.btn):not(.src-guess-btn):not(.src-expand):not(.src-cover):not(.help-tip):not(.nav-group__toggle):not(.achatbot-feedback-fab__btn):not(.achatbot-feedback-mic):not(.achatbot-feedback-attach-link):not(.achatbot-feedback-attach-item__remove):not(.sys-prompt-accordion__toggle):not(.costs-sort-btn).danger {
  background: transparent; color: var(--color-danger-fg);
  border-color: var(--color-danger-border);
}
button:not(.btn):not(.src-guess-btn):not(.src-expand):not(.src-cover):not(.help-tip):not(.nav-group__toggle):not(.achatbot-feedback-fab__btn):not(.achatbot-feedback-mic):not(.achatbot-feedback-attach-link):not(.achatbot-feedback-attach-item__remove):not(.sys-prompt-accordion__toggle):not(.costs-sort-btn).danger:hover { background: var(--color-danger-bg); }
button:not(.btn):not(.src-guess-btn):not(.src-expand):not(.src-cover):not(.help-tip):not(.nav-group__toggle):not(.achatbot-feedback-fab__btn):not(.achatbot-feedback-mic):not(.achatbot-feedback-attach-link):not(.achatbot-feedback-attach-item__remove):not(.sys-prompt-accordion__toggle):not(.costs-sort-btn):disabled { opacity: 0.55; cursor: not-allowed; }

input:not(.input):not([type="checkbox"]):not([type="radio"]),
select:not(.select), textarea:not(.textarea) {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-size: var(--text-base);
  background: var(--color-surface);
  color: var(--color-text);
  height: 32px;
}
textarea:not(.textarea) { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; }
input:not(.input):focus, select:not(.select):focus, textarea:not(.textarea):focus {
  outline: none; border-color: var(--color-primary-600); box-shadow: var(--shadow-focus);
}

/* ---------- Login (design Akiwi) ---------- */
.login-layout {
  display: grid;
  grid-template-columns: 1fr 480px;
  min-height: 100vh;
}
.login-aside {
  background: linear-gradient(160deg, #1C1917 0%, #292524 100%);
  color: white;
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-aside::before {
  content: "";
  position: absolute; top: -100px; right: -100px;
  width: 360px; height: 360px; border-radius: 50%;
  background: radial-gradient(circle, rgba(234,88,12,0.30), transparent 70%);
}
.login-aside::after {
  content: "";
  position: absolute; bottom: -80px; left: -80px;
  width: 280px; height: 280px; border-radius: 50%;
  background: radial-gradient(circle, rgba(132,204,22,0.25), transparent 70%);
}
.login-aside__brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; }
.login-aside__brand-mark {
  width: 48px; height: 48px; border-radius: var(--radius-lg);
  background: white; color: #1C1917;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 700; letter-spacing: -0.03em;
  position: relative;
}
.login-aside__brand-mark--sigil {
  width: 96px;
  height: 96px;
  object-fit: contain;
  padding: 8px;
  display: block;
}
.login-aside__brand-mark--sigil::after { display: none; }
.login-aside__brand-mark::after {
  content: ""; position: absolute; bottom: 6px; left: 10px; right: 10px;
  height: 3px; background: var(--color-signature-500); border-radius: 999px;
}
.login-aside__brand-name { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.login-aside__brand-sub { font-size: 13px; color: rgba(250,250,249,0.6); margin-top: 2px; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 600; }
.login-aside__brand-sub span { font-weight: 400; opacity: 0.85; }
.login-aside__quote { position: relative; z-index: 1; max-width: 440px; }
.login-aside__quote-text { font-size: 22px; font-weight: 500; line-height: 1.4; letter-spacing: -0.01em; }
.login-aside__quote-by { color: rgba(250,250,249,0.6); font-size: 13px; margin-top: 14px; }
.login-aside__stats { position: relative; z-index: 1; display: flex; gap: 32px; }
.login-aside__stat-label { font-size: 12px; color: rgba(250,250,249,0.5); text-transform: uppercase; letter-spacing: 0.08em; }
.login-aside__stat-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }

.login-main {
  display: flex; align-items: center; justify-content: center;
  padding: 40px; background: var(--color-bg); position: relative;
}
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login-card__head { margin-bottom: 14px; }
.login-card__title { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin: 0; }
.login-card__sub { font-size: 14px; color: var(--color-text-muted); margin-top: 4px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.login-card label input { width: 100%; }
.theme-floating { position: absolute; top: 16px; right: 16px; z-index: 2; }

@media (max-width: 880px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}

/* ---------- App shell ---------- */
.app-main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.app-main--workspace { background: var(--color-bg); }
.nav-item--external .nav-item__icon { opacity: 0.85; }

/* ---------- Workspace bar (style Chatbase) ---------- */
.workspace-bar {
  height: var(--header-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
}
.message-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  font-size: var(--text-sm);
  min-width: 0;
}
.message-meter.hidden { display: none; }
.message-meter__label { color: var(--muted); white-space: nowrap; }
.message-meter__bar {
  width: 88px;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  flex-shrink: 0;
}
.message-meter__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}
.message-meter.is-warn .message-meter__fill { background: #f59e0b; }
.message-meter.is-critical .message-meter__fill { background: #ef4444; }
.message-meter__count { font-variant-numeric: tabular-nums; white-space: nowrap; }

.message-quota-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: var(--text-sm);
}
.message-quota-inline__bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  max-width: 120px;
}
.message-quota-inline__fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}
.message-quota-inline.is-warn .message-quota-inline__fill { background: #f59e0b; }
.message-quota-inline.is-critical .message-quota-inline__fill { background: #ef4444; }

.emails-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) { .emails-layout { grid-template-columns: 1fr; } }
.emails-list { display: grid; gap: 6px; }
.emails-list__btn {
  text-align: left;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  cursor: pointer;
}
.emails-list__btn.is-active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.emails-editor textarea {
  width: 100%;
  min-height: 120px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
}
.emails-vars { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 16px; }
.emails-vars code {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-muted);
}

.billing-banner {
  background: var(--color-surface-elevated, var(--color-surface));
  border-bottom: 1px solid var(--color-border);
  padding: 10px 16px;
  font-size: var(--text-sm, 13px);
}
.billing-banner.hidden { display: none; }
.billing-banner__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
}
.badge--warn { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.workspace-selectors {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.workspace-sep {
  color: var(--color-text-disabled);
  font-size: var(--text-lg);
  font-weight: var(--weight-light);
  user-select: none;
}
.workspace-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: min(320px, 40vw);
}
.workspace-select {
  appearance: none;
  border: none;
  background: transparent;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  padding: 6px 28px 6px 4px;
  cursor: pointer;
  max-width: 100%;
  letter-spacing: var(--tracking-tight);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378716C' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
}
.workspace-select:hover { color: var(--color-primary-600); }
.workspace-select:focus { outline: none; box-shadow: var(--shadow-focus); border-radius: var(--radius-sm); }
.workspace-badge {
  font-size: var(--text-xs);
  color: var(--color-text-subtle);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  white-space: nowrap;
  flex-shrink: 0;
}
.workspace-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- Workspace body ---------- */
.workspace-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.agent-playground {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
}
.agent-panels {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
}
.agent-panels .page { max-width: 1100px; }
.agent-panels #page-agent.sources-page-active,
.agent-panels #page-agent.settings-page-active { max-width: none; width: 100%; }
.playground-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}
.playground-help-banner {
  flex-shrink: 0;
  padding: 10px 16px;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
}
.playground-help-banner__inner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: 1100px;
}
.playground-help-banner__icon { font-size: 1.25rem; line-height: 1.2; }
.playground-help-banner__text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--text-sm);
  line-height: 1.45;
}
:root[data-theme="dark"] .playground-help-banner,
html[data-theme="dark"] .playground-help-banner {
  background: rgba(234, 88, 12, 0.12);
  border-bottom-color: rgba(234, 88, 12, 0.35);
}
.playground-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.playground-lang {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}
.playground-lang select,
.playground-lang input {
  height: 28px;
  font-size: var(--text-sm);
}
.playground-frame--full {
  flex: 1;
  min-height: 0;
  height: auto;
  border: none;
  border-radius: 0;
  background: var(--color-bg);
}
:root[data-theme="dark"] .playground-toolbar,
html[data-theme="dark"] .playground-toolbar {
  background: var(--color-bg-subtle);
  border-bottom-color: var(--color-border);
}
:root[data-theme="dark"] .playground-frame--full,
html[data-theme="dark"] .playground-frame--full {
  background: var(--color-bg-subtle);
}
.playground-frame--full iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}
.playground-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 280px;
  font-size: var(--text-md);
  text-align: center;
  padding: 24px;
}

/* Nav sources (sous-menu sidebar) */
.nav-group { display: flex; flex-direction: column; gap: 1px; }
.nav-group__toggle {
  width: 100%;
  border: none !important;
  text-align: left;
  background: transparent !important;
  height: auto;
  padding: 7px 10px;
  font-weight: var(--weight-regular);
  color: var(--color-text-muted) !important;
  box-shadow: none !important;
  justify-content: flex-start;
}
.nav-group__toggle .nav-item__icon {
  color: var(--color-text-subtle) !important;
}
.nav-group__toggle:hover {
  background: var(--color-surface-hover) !important;
  color: var(--color-text) !important;
}
.nav-group__toggle:hover .nav-item__icon {
  color: var(--color-text-subtle) !important;
}
.nav-group__toggle.nav-item--active,
.nav-group--section-active > .nav-group__toggle {
  background: var(--color-surface) !important;
  color: var(--color-text) !important;
  font-weight: var(--weight-medium) !important;
  box-shadow: var(--shadow-sm) !important;
}
.nav-group__toggle.nav-item--active .nav-item__icon,
.nav-group--section-active > .nav-group__toggle .nav-item__icon {
  color: var(--color-primary-600) !important;
}
.nav-group__toggle .nav-item__chevron {
  width: 14px; height: 14px;
  margin-left: auto;
  transition: transform var(--duration-fast);
  color: var(--color-text-subtle);
}
.nav-group--open .nav-group__toggle .nav-item__chevron { transform: rotate(180deg); }
.nav-group:not(.nav-group--open) .nav-sub { display: none; }
.nav-sub { padding-left: 12px; display: flex; flex-direction: column; gap: 1px; }
.nav-item--sub {
  padding: 5px 10px 5px 28px;
  font-size: var(--text-sm);
}
.nav-item--sub.nav-item--active-sub,
.nav-item--sub.nav-item--active {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: var(--weight-medium);
}

/* Pages plateforme dans workspace */
.workspace-body > .page,
.workspace-body > section.page {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 32px;
}

/* ---------- Pages ---------- */
.page-head, .page__header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.page-head h2, .page__title { margin: 0; font-size: var(--text-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.back { text-decoration: none; color: var(--color-text-muted); margin-right: 6px; }
.back:hover { color: var(--color-text-link); text-decoration: none; }
.head-actions, .page__actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-xs);
}
.panel h4 { margin: 0 0 10px; font-size: var(--text-sm); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); }

/* Accordéons clients */
.client-accordion {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.client-accordion[open] { box-shadow: var(--shadow-md); }
.client-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; cursor: pointer; list-style: none; user-select: none;
}
.client-head::-webkit-details-marker { display: none; }
.client-head::marker { content: ""; }
.acc-chevron {
  flex: 0 0 10px; width: 10px; height: 10px;
  border-right: 2px solid var(--color-text-subtle);
  border-bottom: 2px solid var(--color-text-subtle);
  transform: rotate(-45deg); transition: transform .15s; margin-top: -2px;
}
.client-accordion[open] .acc-chevron { transform: rotate(45deg); margin-top: 2px; }
.client-head-main { flex: 1; min-width: 0; }
.client-title-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.client-head h3, .client-name { margin: 0; font-size: var(--text-lg); }
.client-meta { margin: 2px 0 0; }
.client-head-stats { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.client-cost {
  display: flex; flex-direction: column; align-items: flex-end;
  font-variant-numeric: tabular-nums; line-height: 1.2;
}
.client-cost b { font-size: var(--text-lg); }
.client-edit-btn, .client-settings-btn {
  padding: 2px 8px !important; font-size: var(--text-sm) !important;
  height: auto !important; border: none !important;
  color: var(--color-text-muted) !important; background: transparent !important;
}
.client-edit-btn:hover, .client-settings-btn:hover { color: var(--color-primary-600) !important; background: var(--color-bg-subtle) !important; }
.client-name-input { min-width: 180px; max-width: 320px; font-weight: 600; }
.client-body { padding: 0 16px 16px 38px; border-top: 1px solid var(--color-border); }
.accordion-empty { padding: 8px 2px; margin: 0; }
.agent-client-bar { margin-bottom: 16px; padding: 12px 16px; }
.agent-client-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; }
.agent-client-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Cards agents */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.cards > .card {
  padding: 16px 18px; cursor: pointer;
  transition: box-shadow var(--duration-fast), transform var(--duration-fast);
  position: relative;
}
.cards > .card.is-hidden-item, .client-accordion.is-hidden-item { opacity: 0.75; border-style: dashed; }
.cards > .card .card-delete { position: absolute; top: 12px; right: 12px; padding: 4px 10px; font-size: var(--text-sm); height: auto; }
.cards > .card.is-hidden-item .card-actions {
  position: absolute; top: 12px; right: 12px;
  display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end;
}
.cards > .card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.cards > .card h3 { margin: 0 0 4px; font-size: var(--text-md); font-weight: var(--weight-semibold); }
.cards > .card .desc { color: var(--color-text-muted); font-size: var(--text-sm); margin-bottom: 12px; min-height: 2.6em; }
.kpis { display: flex; gap: 16px; flex-wrap: wrap; }
.kpi b { display: block; font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.kpi span { font-size: var(--text-xs); color: var(--color-text-muted); }
.client-delete-btn { color: var(--color-danger-fg) !important; }
.client-restore-btn { color: var(--color-success-fg) !important; }

/* Tables (legacy markup → DS look) */
table {
  width: 100%; border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: var(--text-base);
  box-shadow: var(--shadow-xs);
}
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--color-border); }
th {
  background: var(--color-bg-subtle);
  color: var(--color-text-muted);
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--color-surface-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot .costs-total-row td {
  border-top: 2px solid var(--color-border-strong);
  padding-top: 12px;
  background: var(--color-bg-subtle);
}

/* Tabs agent (legacy .active → DS underline) */
.tabs { margin-bottom: 18px; }
.tabs button {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 12px; font-size: var(--text-base); font-weight: var(--weight-medium);
  color: var(--color-text-muted); border: none; background: transparent;
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
  height: auto;
}
.tabs button:hover { color: var(--color-text); background: transparent; }
.tabs button.active {
  color: var(--color-text);
  border-bottom-color: var(--color-primary-600);
  background: transparent;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }
.stat-line { display: flex; justify-content: space-between; padding: 4px 0; }
.stat-line b { font-variant-numeric: tabular-nums; }

/* Forms */
.inline-form { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.inline-form input[type="text"] { flex: 1; min-width: 220px; }
.banner, .alert--success {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  color: var(--color-success-fg);
  padding: 12px 16px; border-radius: var(--radius-md);
  margin-bottom: 14px; word-break: break-all;
}

.playground-frame {
  border: 1px solid var(--color-border); border-radius: var(--radius-xl); overflow: hidden;
  background: var(--color-bg-subtle);
  background-image: radial-gradient(var(--color-border) 1px, transparent 1px);
  background-size: 22px 22px;
  height: min(72vh, 760px);
}
.playground-frame iframe { width: 100%; height: 100%; border: none; }

.share-panel { margin-bottom: 16px; }
.share-label { display: flex; flex-direction: column; gap: 6px; font-weight: var(--weight-semibold); font-size: var(--text-sm); margin-bottom: 14px; }
.share-label textarea {
  font-weight: var(--weight-regular); width: 100%;
  font-family: var(--font-mono); font-size: var(--text-sm);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  padding: 10px 12px; resize: vertical; background: var(--color-surface-sunken);
}
.copy-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.copy-row input[type="text"] { flex: 1; min-width: 200px; font-family: var(--font-mono); font-size: var(--text-sm); }

/* ---------- Sources (écran documentaire) ---------- */
.sources-page { max-width: none !important; }
.sources-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.sources-top__title { margin: 0; font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.sources-top__sub { margin: 4px 0 0; }
.sources-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.sources-stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 10px 14px;
  min-width: 88px;
  box-shadow: var(--shadow-xs);
}
.sources-stat b { display: block; font-size: var(--text-xl); font-variant-numeric: tabular-nums; line-height: 1.2; }
.sources-stat span { font-size: var(--text-xs); color: var(--color-text-muted); }
.sources-stat--embed { border-color: var(--color-primary-200, #fdba74); background: var(--color-primary-50, #fff7ed); }
[data-theme="dark"] .sources-stat--embed { background: rgba(234, 88, 12, 0.12); border-color: rgba(251, 146, 60, 0.35); }

.sources-layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 960px) {
  .sources-layout { grid-template-columns: 1fr; }
}

.sources-add { padding: 18px 20px; position: sticky; top: 12px; }
.sources-add__head { margin-bottom: 16px; }
.sources-add__badge {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-primary-700);
  background: var(--color-primary-100);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  margin-bottom: 6px;
}
[data-theme="dark"] .sources-add__badge {
  background: rgba(234, 88, 12, 0.18);
  color: var(--color-primary-300);
}
.sources-add__title { margin: 0; font-size: var(--text-md); font-weight: var(--weight-semibold); }

.src-form--compact {
  display: flex; flex-direction: column; gap: 12px;
  margin: 0;
}
.src-form--compact label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: var(--text-sm); font-weight: var(--weight-medium);
}
.src-form--compact label input,
.src-form--compact label select,
.src-form--compact label textarea {
  font-weight: var(--weight-regular);
  width: 100%;
}
.src-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 400px) { .src-form-grid { grid-template-columns: 1fr; } }
.src-form-checks { display: flex; flex-direction: column; gap: 6px; }
.src-callout {
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  line-height: 1.45;
  margin: 0;
}
.src-drop input[type="file"] { font-size: var(--text-sm); }
.src-drop__hint { margin-top: 4px; }

.src-drop-zone {
  position: relative;
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-bg-subtle);
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.src-drop-zone:hover,
.src-drop-zone:focus-visible {
  border-color: var(--color-accent);
  background: var(--color-surface);
  outline: none;
}
.src-drop-zone.is-dragover {
  border-color: var(--color-accent);
  background: var(--color-accent-bg, var(--color-bg-subtle));
  box-shadow: inset 0 0 0 1px var(--color-accent);
}
.src-drop-zone__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.src-drop-zone__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 28px 16px;
  text-align: center;
  pointer-events: none;
}
.src-drop-zone__icon {
  font-size: 1.5rem;
  line-height: 1;
  opacity: 0.55;
}
.src-drop-zone__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.pdf-file-queue {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.pdf-queue-item {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr) auto auto auto;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}
@media (max-width: 480px) {
  .pdf-queue-item { grid-template-columns: 1fr; }
}
.pdf-queue-item__name {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pdf-queue-item input {
  font-size: var(--text-sm) !important;
  padding: 6px 8px !important;
  height: auto !important;
  min-width: 0;
}
.pdf-queue-item__status {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.pdf-queue-item__status.is-err { color: var(--color-danger-fg); }
.pdf-queue-item--single {
  grid-template-columns: minmax(0, 1fr) auto auto;
}
.pdf-guess-status { margin: 8px 0 0; }
.src-drop-zone.has-files .src-drop-zone__content { padding: 16px; }
.src-drop-zone.has-files .src-drop-zone__title { font-size: var(--text-xs); }

.sources-status {
  font-size: var(--text-sm);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  line-height: 1.4;
}
.sources-status.is-ok { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-success-fg); }
.sources-status.is-err { background: var(--color-danger-bg); border-color: var(--color-danger-border); color: var(--color-danger-fg); }
#sources-action-status:not(.hidden) { margin-bottom: 12px; }

.sources-list__toolbar { margin-bottom: 12px; }
.sources-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
}
.sources-filter { flex: 1 1 200px; min-width: 160px; max-width: none; }
.sources-filter-select {
  flex: 0 0 auto;
  width: auto;
  min-width: 120px;
  font-size: var(--text-sm);
  padding: 6px 10px !important;
  height: auto !important;
}
.sources-filter-count { flex: 0 0 auto; white-space: nowrap; }
.sources-footnote { margin-top: 12px; }

.sources-table-wrap {
  padding: 0;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
}
.sources-table { margin: 0; border: none; border-radius: 0; box-shadow: none; min-width: 1098px; }
.sources-table th.src-th-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.sources-table th.src-th-sortable:hover { background: var(--color-surface-hover); }
.sources-table th.src-th-sortable.is-sorted { color: var(--color-accent-fg); }
.src-sort-ind {
  display: inline-block;
  margin-left: 4px;
  font-size: var(--text-xs);
  opacity: 0.85;
}
.sources-table th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  white-space: nowrap;
}
.sources-table tbody > tr:not(.src-url-row) { height: 62px; }
.sources-table tbody > tr:not(.src-url-row) > td {
  height: 62px;
  max-height: 62px;
  overflow: hidden;
  vertical-align: middle;
}
.sources-table tbody > tr:not(.src-url-row) > td.src-cover-cell {
  width: 58px;
  min-width: 58px;
  max-width: 58px;
  padding: 1px 10px 1px 1px;
  vertical-align: middle;
  overflow: visible;
}
.sources-table tbody > tr:not(.src-url-row) > td.src-info-cell,
.sources-table tbody > tr:not(.src-url-row) > td:last-child {
  overflow: visible;
}
.sources-table tbody > tr:not(.src-url-row):has(.src-info-badge.is-open) {
  position: relative;
  z-index: 3;
}
.sources-table td { padding: 8px 12px; vertical-align: middle; font-size: var(--text-sm); }
.sources-table td.src-cover-cell { padding: 1px 10px 1px 1px; }
.sources-table td.src-cover-cell--empty {
  background: transparent;
  border-right: none;
}
.src-th-cover {
  width: 58px;
  min-width: 58px;
  padding: 10px 4px !important;
}
.sources-table td.src-cell-main { min-width: 360px; max-width: 0; }
.src-cell-title { font-weight: var(--weight-semibold); color: var(--color-text); line-height: 1.35; word-break: break-word; }
.src-cell-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
  overflow: hidden;
}
.src-cell-body {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.src-inline-line {
  display: flex; align-items: center; gap: 4px; min-width: 0; flex: 1; overflow: hidden;
}
.src-inline-line .src-expand { flex-shrink: 0; margin-right: 2px; }
.src-cell-filename {
  flex: 0 1 108px;
  min-width: 56px;
  max-width: 108px;
  font-family: var(--font-mono);
  font-size: 0.72em;
  color: var(--color-text-muted);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.src-inline-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}
.src-inline-block {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.src-cover {
  display: block;
  width: 100%;
  height: 60px;
  border-radius: 0 8px 8px 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-left-width: 3px;
  background: var(--color-bg-subtle);
  cursor: pointer;
  padding: 0;
  transition: border-color .15s, box-shadow .15s, transform .15s;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
}
.src-cover:hover, .src-cover:focus-visible {
  border-color: var(--color-accent);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--color-accent) 18%, transparent),
    inset 0 1px 0 rgba(255,255,255,.08);
  outline: none;
  transform: scale(1.02);
}
.src-cover--pdf { border-left-color: #F59E0B; }
.src-cover--text { border-left-color: #0EA5E9; }
.src-cover--web { border-left-color: #10B981; }
.src-cover--youtube { border-left-color: #F43F5E; }
.src-cover--pdf:not(:has(.src-cover-img)) { background: linear-gradient(145deg, #FFFBEB 0%, #FEF3C7 55%, #FDE68A 100%); }
.src-cover--text:not(:has(.src-cover-img)) { background: linear-gradient(145deg, #F0F9FF 0%, #E0F2FE 55%, #BAE6FD 100%); }
.src-cover--web:not(:has(.src-cover-img)) { background: linear-gradient(145deg, #ECFDF5 0%, #D1FAE5 55%, #A7F3D0 100%); }
.src-cover--youtube:not(:has(.src-cover-img)) { background: linear-gradient(145deg, #FFF1F2 0%, #FFE4E6 55%, #FECDD3 100%); }
[data-theme="dark"] .src-cover--pdf:not(:has(.src-cover-img)) { background: linear-gradient(145deg, rgba(180,83,9,.22), rgba(253,230,138,.12)); }
[data-theme="dark"] .src-cover--text:not(:has(.src-cover-img)) { background: linear-gradient(145deg, rgba(3,105,161,.22), rgba(186,230,253,.1)); }
[data-theme="dark"] .src-cover--web:not(:has(.src-cover-img)) { background: linear-gradient(145deg, rgba(4,120,87,.22), rgba(167,243,208,.1)); }
[data-theme="dark"] .src-cover--youtube:not(:has(.src-cover-img)) { background: linear-gradient(145deg, rgba(190,18,60,.22), rgba(254,205,211,.1)); }
.src-cover-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.src-cover-ph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.src-cover-ph-icon {
  font-size: 1.35rem;
  line-height: 1;
  opacity: 0.72;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.08));
}
.sources-table tr.src-row-no-cite .src-cover-img { filter: grayscale(0.35); }
.sources-table tr.src-row-no-cite .src-cover { opacity: 0.85; }
.src-inline-title {
  flex: 1 1 120px;
  min-width: 72px;
  font-size: var(--text-xs) !important;
  padding: 4px 8px !important;
  height: 28px !important;
  width: auto;
}
.src-inline-date {
  flex: 0 0 126px;
  width: 126px;
  font-size: var(--text-xs) !important;
  padding: 4px 6px !important;
  height: 28px !important;
}
.src-cite-label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.src-cite-label input { margin: 0; }
.sources-table tr.src-row-no-cite { opacity: 0.72; }
.src-guess-btn {
  flex-shrink: 0; position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  background: none; border: none; cursor: pointer;
  padding: 0; border-radius: 6px; color: #000;
  opacity: 1; transition: opacity .12s, color .12s, background .12s;
}
[data-theme="dark"] .src-guess-btn { color: #fff; }
.src-guess-btn:hover:not(:disabled) { opacity: 1; background: var(--color-bg-subtle); }
.src-guess-btn:disabled:not(.is-loading) { opacity: .35; cursor: default; }
.src-guess-btn.is-loading { opacity: 1; cursor: default; }
.src-guess-btn svg { width: 14px; height: 14px; fill: currentColor; display: block; }
.src-guess-btn.is-loading svg { visibility: hidden; }
.src-guess-btn.is-loading::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border-strong);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: src-spin 0.65s linear infinite;
}
@keyframes src-spin { to { transform: rotate(360deg); } }
.src-th-source {
  display: flex;
  align-items: center;
  gap: 6px;
}
.src-th-source .src-guess-all-btn { opacity: 1; }
.src-th-source .src-guess-all-btn:hover:not(:disabled) { opacity: 1; }
.src-inline-status {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--color-text-muted);
  white-space: nowrap;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.src-cell-meta {
  margin-top: 2px;
  font-size: 10px;
  color: var(--color-text-muted);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.src-th-info { width: 44px; text-align: center; }
.src-info-cell { width: 44px; text-align: center; vertical-align: middle; }
.src-info-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  text-transform: none;
  letter-spacing: 0.01em;
  color: var(--color-text-muted);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  font-family: inherit;
}
.src-info-badge:hover,
.src-info-badge:focus-visible,
.src-info-badge.is-open {
  color: var(--color-accent-fg);
  background: var(--color-accent-bg, var(--color-primary-50));
  border-color: var(--color-accent-border, var(--color-primary-200));
  outline: none;
}
.src-info-popover {
  display: none;
  position: absolute;
  left: 0;
  top: auto;
  bottom: calc(100% + 8px);
  transform: none;
  z-index: 120;
  min-width: 280px;
  max-width: min(360px, 88vw);
  padding: 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong, var(--color-border));
  background: var(--color-surface);
  box-shadow: var(--shadow-lg, 0 10px 28px rgba(0,0,0,.14));
  text-align: left;
  font-weight: var(--weight-normal);
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.4;
  color: var(--color-text);
}
[data-theme="dark"] .src-info-popover {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  box-shadow: 0 12px 32px rgba(0,0,0,.45);
}
.src-info-badge:hover .src-info-popover,
.src-info-badge:focus-visible .src-info-popover,
.src-info-badge.is-open .src-info-popover { display: block; }
.src-info-popover__title {
  margin: 0;
  padding: 10px 12px 8px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}
.src-info-popover__body { padding: 4px 12px 10px; }
.src-info-popover__row {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 6px 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-xs);
}
.src-info-popover__row:last-child { border-bottom: none; }
.src-info-popover__label { color: var(--color-text-muted); font-weight: var(--weight-medium); }
.src-info-popover__value { color: var(--color-text); word-break: break-word; }
.src-type-badge {
  display: inline-flex; align-items: center;
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  padding: 3px 8px; border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  white-space: nowrap;
}
.src-type-badge--pdf { color: #B45309; background: #FFFBEB; border-color: #FDE68A; }
.src-type-badge--text { color: #0369A1; background: #F0F9FF; border-color: #BAE6FD; }
.src-type-badge--web { color: #047857; background: #ECFDF5; border-color: #A7F3D0; }
.src-type-badge--youtube { color: #BE123C; background: #FFF1F2; border-color: #FECDD3; }
[data-theme="dark"] .src-type-badge--pdf { background: rgba(180,83,9,.15); border-color: rgba(253,230,138,.3); color: #FCD34D; }
[data-theme="dark"] .src-type-badge--text { background: rgba(3,105,161,.15); border-color: rgba(186,230,253,.25); color: #7DD3FC; }
[data-theme="dark"] .src-type-badge--web { background: rgba(4,120,87,.15); border-color: rgba(167,243,208,.25); color: #6EE7B7; }
[data-theme="dark"] .src-type-badge--youtube { background: rgba(190,18,60,.15); border-color: rgba(254,205,211,.25); color: #FDA4AF; }

.src-priority {
  font-size: var(--text-xs) !important;
  max-width: 130px;
  padding: 4px 8px !important;
  height: auto !important;
}
.src-actions {
  display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end;
}
.src-actions .btn { padding: 4px 8px; height: 28px; font-size: var(--text-xs); }
.src-edit-text-btn {
  gap: 4px;
  padding: 4px 10px !important;
  font-weight: var(--weight-medium);
}
.src-edit-text-btn__icon { font-size: 14px; line-height: 1; }
.src-action-danger { color: var(--color-danger-fg) !important; }
.src-action-danger:hover { background: var(--color-danger-bg) !important; }
.src-action-delete { padding: 4px 6px !important; min-width: 28px; }
.src-action-delete svg { width: 14px; height: 14px; fill: currentColor; display: block; }
.src-auto-label {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-xs); color: var(--color-text-muted);
  margin-right: 4px; white-space: nowrap;
}
.src-auto-label--compact { font-size: 10px; gap: 3px; margin-right: 2px; }
.src-auto-label input { width: auto; margin: 0; flex-shrink: 0; }
.src-auto-text { line-height: 1.2; }
.src-auto-interval {
  font-size: var(--text-xs) !important;
  max-width: 108px;
  padding: 3px 6px !important;
  height: 28px !important;
}
.src-auto-interval option:disabled { color: var(--color-text-muted); }
.cover-modal-preview {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.cover-modal-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-modal-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.cover-modal-tabs button.is-active {
  background: var(--color-bg-subtle);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}
.cover-modal-pane.hidden { display: none; }

.sources-empty {
  text-align: center;
  padding: 48px 24px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-bg-subtle);
}
.sources-empty__title { margin: 0 0 6px; font-weight: var(--weight-semibold); }

.sources-table .src-folder-row td { vertical-align: middle; }
.sources-table td.num { white-space: nowrap; }
.sources-table .badge { white-space: nowrap; }

.src-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--color-overlay);
}
.src-modal.hidden { display: none; }
.src-modal__panel {
  width: min(640px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  margin: 0;
}
.src-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.src-modal__head h3 { margin: 0; font-size: var(--text-lg); }
.src-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.upgrade-offer-panel { max-width: 480px; }
.upgrade-offer-body { margin: 0; line-height: 1.55; }
.upgrade-offer-body strong { color: var(--color-text); }
.upgrade-offer-price {
  display: block;
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  font-size: var(--text-lg);
}
.upgrade-offer-note { margin: 10px 0 0; }
.upgrade-promo-wrap { margin-top: 14px; }
.upgrade-promo-wrap.hidden { display: none; }
.billing-promo-field input {
  width: 9rem;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  font-size: var(--text-sm, 13px);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.btn--quota-hint:not(:disabled) {
  opacity: 0.92;
  box-shadow: inset 0 0 0 1px var(--color-warning, #d97706);
}
.src-folder-toggle { cursor: pointer; }
.src-folder-toggle:hover { background: var(--color-surface-hover); }
.src-expand {
  min-width: 26px; height: 26px !important; padding: 0 !important;
  font-weight: 700; font-size: 12px;
  border: 1px solid var(--color-border) !important;
  background: var(--color-surface) !important;
  color: var(--color-text-muted) !important;
  border-radius: var(--radius-sm) !important;
  margin-right: 6px; vertical-align: middle;
}
.src-url-row td { background: var(--color-bg-subtle); border-top: none; }
.src-url-row .src-url-cell { padding-left: 2.4rem; }
.src-url-link { font-weight: var(--weight-semibold); word-break: break-word; text-decoration: none; color: var(--color-text-link); }
.src-url-link:hover { text-decoration: underline; }
.src-url-path { word-break: break-all; margin-top: 2px; font-family: var(--font-mono); font-size: 0.82em; opacity: 0.85; }
.mono { font-family: var(--font-mono); font-size: 0.92em; }

/* Masquer en-tête agent redondant sur écrans dédiés */
.sources-page-active .page-head,
.sources-page-active #agent-client-bar,
.settings-page-active .page-head,
.settings-page-active #agent-client-bar { display: none !important; }

/* ---------- Config pages (paramètres agent / client) ---------- */
.config-page { max-width: none !important; }
.config-top { margin-bottom: 20px; }
.config-top__intro { display: flex; align-items: flex-start; gap: 12px; }
.config-top__back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); color: var(--color-text-muted);
  text-decoration: none; flex-shrink: 0; margin-top: 2px;
}
.config-top__back:hover { background: var(--color-bg-subtle); color: var(--color-text); text-decoration: none; }
.config-top__title { margin: 0; font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.config-top__sub { margin: 4px 0 0; }

.config-form { display: flex; flex-direction: column; }
.config-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
.config-layout--client { grid-template-columns: 1fr minmax(260px, 320px); align-items: start; }
@media (max-width: 1024px) { .config-layout--client { grid-template-columns: 1fr; } }
.config-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.config-sidebar { position: sticky; top: 12px; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }

.config-propagate-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; }
.config-propagate-bar__label { font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.config-propagate-bar__hint { flex: 1; min-width: 200px; }
.config-apply--sample { cursor: default; pointer-events: none; vertical-align: middle; margin: 0 2px; }

.config-section { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.config-section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.config-section__title { margin: 0; font-size: var(--text-md); font-weight: var(--weight-semibold); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.config-section__hint { margin: -4px 0 0; }
.config-section__actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .config-grid { grid-template-columns: 1fr; } }

.config-field {
  display: flex; flex-direction: column; gap: 5px;
  font-size: var(--text-sm); font-weight: var(--weight-medium);
}
.config-field--grow { flex: 1; min-width: 0; }
.config-field input, .config-field select, .config-field textarea { font-weight: var(--weight-regular); width: 100%; }
.config-field__row { display: flex; align-items: center; gap: 12px; }
.config-field__row--top { align-items: flex-start; }
.config-field__label-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-bottom: 2px;
}
.config-field__label-text {
  font-size: var(--text-sm); font-weight: var(--weight-medium);
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.config-apply--title { align-self: auto; }
.config-subsection__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-bottom: 4px;
}
.config-color { height: 38px; padding: 4px; cursor: pointer; }
.config-textarea--prompt { font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.45; }
.prompt-field-wrap {
  display: flex; align-items: flex-start; gap: 6px; margin-top: 0.35rem;
}
.prompt-field-wrap textarea { flex: 1; min-width: 0; }
.prompt-field-wrap .prompt-magic-btn { margin-top: 4px; flex-shrink: 0; }

.sys-prompts-list { display: flex; flex-direction: column; gap: 8px; }
.sys-prompt-accordion {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.sys-prompt-accordion__toggle {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border: none;
  background: var(--color-surface);
  text-align: left;
  cursor: pointer;
  color: var(--color-text);
  font: inherit;
}
.sys-prompt-accordion__toggle:hover { background: var(--color-surface-hover); }
.sys-prompt-accordion.is-open .sys-prompt-accordion__toggle {
  border-bottom: 1px solid var(--color-border);
}
.sys-prompt-accordion__chevron {
  flex-shrink: 0;
  width: 16px;
  color: var(--color-text-muted);
  transition: transform var(--duration-fast);
  margin-top: 2px;
}
.sys-prompt-accordion.is-open .sys-prompt-accordion__chevron { transform: rotate(90deg); }
.sys-prompt-accordion__head { flex: 1; min-width: 0; }
.sys-prompt-accordion__title { margin: 0; font-size: var(--text-base); }
.sys-prompt-accordion__meta { font-size: var(--text-xs); color: var(--color-text-muted); margin: 2px 0 0; }
.sys-prompt-accordion__body {
  padding: 12px 14px 14px;
  background: var(--color-bg-subtle);
}
.sys-prompt-accordion__body.hidden { display: none; }
.sys-prompt-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  background: var(--color-bg-elevated, #fff);
}
[data-theme="dark"] .sys-prompt-card { background: var(--color-bg-subtle); }
.sys-prompt-card__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 8px;
}
.sys-prompt-card__title { margin: 0; font-size: var(--text-base); }
.sys-prompt-card__meta { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: 2px; }
.sys-prompt-card__actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sys-prompt-card textarea {
  width: 100%; min-height: 8rem; font-family: var(--font-mono);
  font-size: var(--text-sm); line-height: 1.45;
}
.sys-prompt-card__foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap; margin-top: 10px;
}
.sys-prompt-modal { max-width: 560px; width: calc(100vw - 32px); }

.fb-access-ips { display: flex; flex-direction: column; gap: 6px; }
.fb-access-ip-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 10px; border-radius: var(--radius-md);
  background: var(--color-bg-subtle); border: 1px solid var(--color-border);
}
.fb-access-clients {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px 16px; margin-top: 8px;
}
.fb-access-client { margin: 0; }

.config-apply {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: var(--radius-md);
  background: var(--color-bg-subtle); border: 1px solid var(--color-border);
  font-size: var(--text-xs); font-weight: var(--weight-semibold);
  color: var(--color-text-muted); white-space: nowrap; flex-shrink: 0;
  cursor: pointer; user-select: none; line-height: 1.2;
  letter-spacing: 0.01em;
}
.config-apply:hover { border-color: var(--color-border-strong, #c4c4c4); color: var(--color-text); }
.config-apply:has(input:checked) {
  background: var(--color-neutral-bg, #ececec);
  color: var(--color-text);
  border-color: var(--color-neutral-border, var(--color-border));
}
.config-apply input { width: auto !important; margin: 0; flex-shrink: 0; cursor: pointer; }
.config-apply--inline { align-self: flex-end; }
.config-field__row--top .config-apply--inline { align-self: flex-start; margin-top: 22px; }
.config-subsection .config-field__row .config-apply--inline { align-self: center; margin-top: 0; }

.config-subsection {
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--color-bg-subtle); border: 1px solid var(--color-border);
}
.config-subsection__label { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-text-muted); display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Infobulles d'aide (?) — petit cercle noir discret */
.field-label {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 2px;
}
.help-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 0.75rem; height: 0.75rem; padding: 0; flex-shrink: 0;
  border: 1px solid #1a1618; border-radius: 50%;
  background: transparent; color: #1a1618;
  font-size: 0.5rem; font-weight: 700; line-height: 1;
  cursor: help; vertical-align: middle; position: relative;
  transition: opacity var(--duration-fast);
}
.help-tip span {
  display: block; margin-top: -0.5px;
}
.help-tip:hover,
.help-tip:focus-visible {
  opacity: 0.65; outline: none;
  z-index: 10150;
}
[data-theme="dark"] .help-tip,
html[data-theme="dark"] .help-tip {
  border-color: #e7e5e4; color: #e7e5e4; background: transparent;
}
[data-theme="dark"] .help-tip:hover,
[data-theme="dark"] .help-tip:focus-visible,
html[data-theme="dark"] .help-tip:hover,
html[data-theme="dark"] .help-tip:focus-visible {
  opacity: 0.65;
}
.config-field:has(.help-tip:hover),
.config-field:has(.help-tip:focus-visible),
label.check:has(.help-tip:hover),
label.check:has(.help-tip:focus-visible),
label.config-apply:has(.help-tip:hover),
label.config-apply:has(.help-tip:focus-visible),
.config-section__title:has(.help-tip:hover),
.config-section__title:has(.help-tip:focus-visible),
.config-subsection__label:has(.help-tip:hover),
.config-subsection__label:has(.help-tip:focus-visible),
.config-field__label-text:has(.help-tip:hover),
.config-field__label-text:has(.help-tip:focus-visible),
.config-propagate-bar__label:has(.help-tip:hover),
.config-propagate-bar__label:has(.help-tip:focus-visible) {
  position: relative;
  z-index: 10150;
  overflow: visible;
}
.config-section,
.config-grid,
.config-main,
.field-label {
  overflow: visible;
}
.help-tip::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 7px);
  transform: translateX(-50%);
  width: max-content; max-width: min(280px, 88vw);
  padding: 8px 10px; border-radius: var(--radius-md);
  background: var(--color-text); color: var(--color-bg, #fff);
  font-size: var(--text-xs); font-weight: var(--weight-regular); line-height: 1.45;
  text-align: left; white-space: normal;
  pointer-events: none; opacity: 0; visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  z-index: 10151; box-shadow: var(--shadow-md, 0 4px 14px rgba(0,0,0,.15));
}
.help-tip::before {
  content: "";
  position: absolute; left: 50%; bottom: calc(100% + 1px);
  transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--color-text);
  opacity: 0; visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  z-index: 10152; pointer-events: none;
}
.help-tip:hover::after,
.help-tip:hover::before,
.help-tip:focus-visible::after,
.help-tip:focus-visible::before {
  opacity: 1; visibility: visible;
}
label.check .help-tip { margin-left: 2px; }
.config-apply .help-tip { margin-left: 4px; }
.check:has(.help-tip) { flex-wrap: wrap; row-gap: 4px; }


.config-section__actions.merge-actions { flex-wrap: wrap; align-items: center; }
.config-sidebar__actions > .btn + .help-tip,
.config-sidebar__actions > .btn--secondary + .help-tip {
  margin: 0;
  align-self: center;
}
.config-sidebar__action-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.config-sidebar__action-row > .btn { flex: 1; min-width: 0; }

.costs-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.costs-summary__item {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-bg-subtle);
}
.costs-summary__item strong { display: block; font-size: var(--text-lg); }
.costs-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.costs-toolbar input[type="search"] { max-width: 220px; }
.costs-pagination {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 12px;
}
.costs-sort-btn {
  background: none; border: none; padding: 0; font: inherit; font-weight: inherit;
  color: inherit; cursor: pointer; text-align: inherit;
}
.costs-sort-btn:hover { text-decoration: underline; }
.costs-sort-btn.is-active { color: var(--color-primary-600); }
.costs-total-row { background: var(--color-bg-subtle); }

.config-sidebar__actions {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 4px; padding-top: 12px;
  border-top: 1px solid var(--color-border);
}
.config-savebar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 14px 0 4px; border-top: 1px solid var(--color-border); margin-top: 4px;
}
.config-status { font-size: var(--text-sm); margin-left: auto; }
.config-banner {
  padding: 12px 14px; border-radius: var(--radius-md);
  background: var(--color-success-bg); border: 1px solid var(--color-success-border);
}

/* Wizard pages (nouveau client / nouvel agent) */
.wizard-page { max-width: none !important; }
.wizard-layout { display: flex; flex-direction: column; gap: 14px; }
.wizard-layout--split {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 300px);
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) { .wizard-layout--split { grid-template-columns: 1fr; } }
.wizard-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.wizard-aside {
  position: sticky; top: 12px;
  padding: 16px 18px; display: flex; flex-direction: column; gap: 10px;
}
.wizard-aside__list {
  margin: 0; padding-left: 18px;
  display: flex; flex-direction: column; gap: 8px; line-height: 1.45;
}
.wizard-aside__link { margin: 4px 0 0; }
.wizard-savebar { border-top: none; padding-top: 0; margin-top: 0; }
.config-field__hint { font-weight: var(--weight-regular); line-height: 1.35; }

.wizard-result { margin-top: 0; }
.wizard-result:not(.hidden) {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
}
.wizard-result h4 { margin: 0 0 12px; font-size: var(--text-md); font-weight: var(--weight-semibold); }
.wizard-result .result-block { display: flex; flex-direction: column; gap: 12px; font-size: var(--text-sm); line-height: 1.5; }
.wizard-result .result-block code {
  display: block; margin-top: 4px; padding: 8px 10px;
  background: var(--color-bg-subtle); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); font-size: var(--text-xs); word-break: break-all;
}
.wizard-result .result-block p { margin: 0; }
.wizard-result > button, .wizard-result .btn { margin-top: 4px; align-self: flex-start; }

/* ---------- Écosystème (superadmin) ---------- */
.ecosystem-page .config-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.ecosystem-top-actions { display: flex; gap: 8px; flex-shrink: 0; }
.ecosystem-kpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px;
}
@media (max-width: 900px) { .ecosystem-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .ecosystem-kpis { grid-template-columns: 1fr; } }
.ecosystem-kpi {
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; text-align: center;
}
.ecosystem-kpi__val { font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.ecosystem-kpi__lbl { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); }

.business-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
@media (max-width: 900px) { .business-grid { grid-template-columns: 1fr; } }
.business-grid .table-wrap { overflow-x: auto; }
.business-grid table { width: 100%; font-size: var(--text-sm); }

/* ---------- Tableau de bord SaaS ---------- */
.saas-page .config-top { margin-bottom: 16px; }
.saas-kpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px;
}
@media (max-width: 1100px) { .saas-kpis { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .saas-kpis { grid-template-columns: 1fr; } }
.saas-kpi {
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.saas-kpi__val { font-size: var(--text-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.saas-kpi__lbl { font-size: var(--text-xs); color: var(--color-text-muted); text-transform: uppercase; letter-spacing: var(--tracking-caps); }
.saas-kpi__delta { font-size: var(--text-xs); font-weight: var(--weight-medium); }
.saas-kpi__delta.is-up { color: var(--color-success-600, #16a34a); }
.saas-kpi__delta.is-down { color: var(--color-danger-600, #dc2626); }
.saas-kpi__delta.is-neutral { color: var(--color-text-muted); }

.saas-charts {
  display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px;
}
@media (max-width: 1000px) { .saas-charts { grid-template-columns: 1fr; } }
.saas-chart-panel { padding: 16px 18px; }
.saas-chart-panel h3 { margin: 0 0 14px; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.saas-chart { width: 100%; height: auto; display: block; }
.saas-chart__bar { fill: var(--color-primary-500, #6366f1); opacity: 0.85; transition: opacity 0.15s; }
.saas-chart__bar:hover { opacity: 1; }
.saas-chart__bar--secondary { fill: var(--color-primary-300, #a5b4fc); }
.saas-chart__bar--danger { fill: var(--color-danger-400, #f87171); }
.saas-chart__axis { stroke: var(--color-border); stroke-width: 1; }
.saas-chart__label { font-size: 10px; fill: var(--color-text-muted); }
.saas-chart__grid { stroke: var(--color-border); stroke-width: 0.5; stroke-dasharray: 3 3; opacity: 0.6; }
.saas-chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: var(--text-xs); color: var(--color-text-muted); }
.saas-chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.saas-chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.saas-plan-bars { display: flex; flex-direction: column; gap: 10px; }
.saas-plan-row { display: grid; grid-template-columns: 100px 1fr 56px; gap: 10px; align-items: center; font-size: var(--text-sm); }
.saas-plan-row__bar-wrap { height: 8px; background: var(--color-bg-subtle); border-radius: var(--radius-full); overflow: hidden; }
.saas-plan-row__bar { height: 100%; background: var(--color-primary-500, #6366f1); border-radius: var(--radius-full); transition: width 0.3s; }
.saas-plan-row__val { text-align: right; font-variant-numeric: tabular-nums; color: var(--color-text-muted); font-size: var(--text-xs); }

.saas-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 12px;
}
.saas-search { flex: 1; min-width: 180px; max-width: 320px; }
.saas-tabs { display: flex; gap: 4px; }
.saas-tab {
  padding: 6px 12px; font-size: var(--text-sm); border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: transparent; cursor: pointer; color: var(--color-text-muted);
}
.saas-tab.is-active { background: var(--color-primary-50, #eef2ff); border-color: var(--color-primary-300); color: var(--color-primary-700); font-weight: var(--weight-medium); }
.saas-footnote { margin: 12px 4px 0; }

/* ---------- Charge Supabase (superadmin) ---------- */
.charge-header {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px;
  padding: 16px 18px; margin-bottom: 16px;
}
.charge-header__title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.charge-header__title-row h3 { margin: 0; font-size: var(--text-lg); }
.charge-health-pill {
  font-size: var(--text-xs); font-weight: var(--weight-medium); padding: 3px 10px; border-radius: var(--radius-full);
  background: var(--color-bg-subtle); color: var(--color-text-muted);
}
.charge-health-pill.is-up { background: var(--color-success-50, #f0fdf4); color: var(--color-success-700, #15803d); }
.charge-health-pill.is-down { background: var(--color-danger-50, #fef2f2); color: var(--color-danger-700, #b91c1c); }
.charge-header__meta {
  display: flex; flex-wrap: wrap; gap: 18px; font-size: var(--text-sm);
}
.charge-header__meta div { display: flex; flex-direction: column; gap: 2px; min-width: 110px; }
.charge-grid {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px;
}
@media (max-width: 900px) { .charge-grid { grid-template-columns: 1fr; } }
.charge-panel { padding: 16px 18px; }
.charge-panel h3 { margin: 0 0 8px; font-size: var(--text-sm); font-weight: var(--weight-semibold); }
.charge-panel__sub { margin: 0 0 14px; line-height: 1.45; }
.charge-meter { margin-bottom: 12px; }
.charge-meter__head { display: flex; justify-content: space-between; font-size: var(--text-sm); margin-bottom: 6px; }
.charge-meter__track { height: 8px; background: var(--color-bg-subtle); border-radius: var(--radius-full); overflow: hidden; }
.charge-meter__fill { height: 100%; background: var(--color-primary-500, #6366f1); border-radius: var(--radius-full); transition: width 0.3s; }
.charge-meter__fill.is-warn { background: var(--color-warning-500, #f59e0b); }
.charge-conn { display: flex; justify-content: space-between; font-size: var(--text-sm); margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--color-border); }
.charge-services { display: flex; flex-direction: column; gap: 8px; }
.charge-service-row { display: flex; justify-content: space-between; align-items: center; font-size: var(--text-sm); }
.charge-status { font-size: var(--text-xs); font-weight: var(--weight-medium); padding: 2px 8px; border-radius: var(--radius-full); }
.charge-status--ok { background: var(--color-success-50, #f0fdf4); color: var(--color-success-700, #15803d); }
.charge-status--bad { background: var(--color-danger-50, #fef2f2); color: var(--color-danger-700, #b91c1c); }
.charge-usage-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.charge-usage-head h3 { margin: 0; }
.charge-usage-total { font-size: var(--text-xl); }
.charge-usage-kpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px;
}
@media (max-width: 700px) { .charge-usage-kpis { grid-template-columns: repeat(2, 1fr); } }
.charge-chart__bar { fill: var(--color-success-500, #22c55e); opacity: 0.9; }
.charge-footnote { margin: 12px 4px 0; padding-left: 1.2rem; }

.saas-row-test { opacity: 0.88; }
.saas-row-test td:first-child strong { font-style: italic; }
.saas-badge-test { background: var(--color-warning-100, #fef3c7); color: var(--color-warning-800, #92400e); border-color: var(--color-warning-300, #fcd34d); }
.saas-badge-client { background: var(--color-success-50, #f0fdf4); color: var(--color-success-800, #166534); border-color: var(--color-success-200, #bbf7d0); }
.saas-badge-origin { background: var(--color-bg-subtle); color: var(--color-text-muted); font-weight: var(--weight-normal); }

.commerce-grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .commerce-grid { grid-template-columns: 1fr 1fr; } }
.commerce-form-grid { display: grid; gap: 10px; }
.commerce-form-row {
  display: grid;
  grid-template-columns: 120px 1fr 100px;
  gap: 10px;
  align-items: center;
  font-size: var(--text-sm);
}
.commerce-form-row input[type="number"] { width: 100%; }
.commerce-computed { font-size: var(--text-xs); color: var(--color-text-muted); }
.commerce-promo-form { display: grid; gap: 10px; margin-bottom: 16px; }
.commerce-promo-form .field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }

.ecosystem-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 14px; margin-bottom: 16px;
}
.ecosystem-search { flex: 1; min-width: 180px; max-width: 320px; }
.ecosystem-show-hidden { margin-left: auto; white-space: nowrap; }

.ecosystem-layout {
  display: grid; grid-template-columns: 1fr minmax(280px, 340px); gap: 16px; align-items: start;
}
@media (max-width: 1100px) { .ecosystem-layout { grid-template-columns: 1fr; } }
.ecosystem-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.ecosystem-footnote { margin: 0; padding: 0 4px; }
.ecosystem-sidebar {
  position: sticky; top: 12px; padding: 16px 18px;
  display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 48px); overflow-y: auto;
}
.ecosystem-sidebar__hint { margin: -4px 0 0; line-height: 1.45; }
.ecosystem-sidebar__actions { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.ecosystem-sidebar__link { margin: 4px 0 0; }
.ecosystem-assign-section { display: flex; flex-direction: column; gap: 6px; }
.ecosystem-assign-section__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.eco-assignees { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.eco-assignee {
  font-size: var(--text-xs); padding: 2px 8px; border-radius: var(--radius-full);
  background: var(--color-primary-100); color: var(--color-primary-700);
  border: 1px solid var(--color-primary-200);
}
.eco-agent-list { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.eco-agent-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: var(--color-bg-subtle);
  cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s;
}
.eco-agent-row:hover { box-shadow: var(--shadow-xs); border-color: var(--color-border-strong, var(--color-border)); }
.eco-agent-row.is-hidden-item { opacity: 0.75; border-style: dashed; }
.eco-agent-row__main { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.eco-agent-row__slug { font-size: var(--text-sm); }
.eco-agent-row__desc { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eco-agent-row__stats { display: flex; gap: 10px; flex-shrink: 0; }
.eco-stat { font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; }
.eco-stat b { color: var(--color-text); }
.eco-stat--cost b { color: var(--color-primary-600); }
.eco-agent-row__actions { display: flex; gap: 4px; flex-shrink: 0; }
.eco-agent-row__actions .btn { pointer-events: auto; }

.ecosystem-client .client-title-wrap .btn { height: 26px; padding: 0 8px; font-size: var(--text-xs); }

/* Wizard & settings (legacy) */
.wizard { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.wizard label { display: flex; flex-direction: column; gap: 5px; font-weight: var(--weight-semibold); font-size: var(--text-sm); flex: 1; }
.wizard label input, .wizard label select, .wizard label textarea { font-weight: var(--weight-regular); width: 100%; }
.field-row { display: flex; gap: 14px; }
.merge-actions { align-items: center; flex-wrap: wrap; }
.merge-loading { display: inline-flex; align-items: center; }
.inline-spinner {
  width: 14px; height: 14px;
  border: 2px solid var(--color-border); border-top-color: var(--color-primary-600);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 700px) { .field-row { flex-direction: column; } }
.check {
  display: inline-flex; flex-direction: row !important; align-items: center;
  gap: 8px !important; cursor: pointer; line-height: 1.35;
}
.check input {
  width: 1rem !important; height: 1rem !important; margin: 0; padding: 0;
  flex-shrink: 0; cursor: pointer;
}
.check input:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.check:has(input:disabled) {
  cursor: default;
  flex-wrap: wrap;
}
.check .plan-gate-hint {
  flex-basis: 100%;
  margin: 2px 0 0 1.5rem;
  line-height: 1.35;
}
.check .plan-gate-hint a { color: var(--color-primary-600); }

.role-badge { font-size: var(--text-xs); padding: 2px 8px; border-radius: var(--radius-full); background: var(--color-neutral-bg); color: var(--color-neutral-fg); border: 1px solid var(--color-neutral-border); }
.role-badge.super { background: var(--color-primary-100); color: var(--color-primary-700); border-color: var(--color-primary-200); }
.role-badge.client { background: var(--color-neutral-bg); color: var(--color-text-muted); border-color: var(--color-border); }
[data-theme="dark"] .role-badge.super { background: rgba(234, 88, 12, 0.16); color: var(--color-primary-300); }
.status-pending { color: var(--color-warn-fg); }
.status-disabled { color: var(--color-danger-fg); }

/* Utilisateurs — liste améliorée + impersonation */
.users-table .users-name-row { display: flex; align-items: flex-start; gap: 10px; }
.users-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.users-status { font-size: var(--text-xs); font-weight: var(--weight-semibold); padding: 2px 8px; border-radius: var(--radius-full); }
.users-status--active { background: rgba(34, 197, 94, 0.12); color: #15803d; }
.users-status--pending { background: rgba(234, 179, 8, 0.14); color: #a16207; }
.users-status--disabled { background: rgba(239, 68, 68, 0.1); color: #b91c1c; }
.users-row--pending { background: rgba(234, 179, 8, 0.04); }
.users-row--disabled { background: rgba(239, 68, 68, 0.03); }
.impersonate-btn {
  border: none; background: none; cursor: pointer; font-size: 1.15rem; line-height: 1;
  padding: 2px 4px; border-radius: 6px; flex-shrink: 0;
  filter: hue-rotate(195deg) saturate(2.2);
  transition: transform 0.12s ease, background 0.12s ease;
}
.impersonate-btn:hover { transform: scale(1.12); background: rgba(59, 130, 246, 0.1); }
.impersonation-pill {
  position: fixed; left: 16px; bottom: 16px; z-index: 100100;
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-radius: 999px; border: 2px solid #c45c4c; background: #fff5f5; color: #8b2942;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 20px rgba(196, 92, 76, 0.22);
}
.impersonation-pill:hover { background: #ffe8e8; }
.impersonation-pill__icon { filter: hue-rotate(-35deg) saturate(1.4); }

/* Retours produit — couleurs par statut */
.fb-table tbody tr { transition: background 0.12s ease; }
.fb-row--open { background: rgba(234, 179, 8, 0.1); }
.fb-row--in_progress { background: rgba(59, 130, 246, 0.1); }
.fb-row--done { background: rgba(34, 197, 94, 0.08); }
.fb-row--wont_fix { background: rgba(239, 68, 68, 0.08); }
.fb-row--open:hover { background: rgba(234, 179, 8, 0.16); }
.fb-row--in_progress:hover { background: rgba(59, 130, 246, 0.16); }
.fb-row--done:hover { background: rgba(34, 197, 94, 0.12); }
.fb-row--wont_fix:hover { background: rgba(239, 68, 68, 0.12); }
[data-theme="dark"] .fb-row--open { background: rgba(234, 179, 8, 0.12); }
[data-theme="dark"] .fb-row--in_progress { background: rgba(59, 130, 246, 0.14); }
[data-theme="dark"] .fb-row--done { background: rgba(34, 197, 94, 0.1); }
[data-theme="dark"] .fb-row--wont_fix { background: rgba(239, 68, 68, 0.1); }

.fb-notes-cell { max-width: 280px; white-space: pre-wrap; word-break: break-word; }
.fb-notes-edit { width: 100%; min-width: 12rem; resize: vertical; font-size: var(--text-sm); line-height: 1.35; }

/* Pages superadmin pleine largeur */
.workspace-body > #page-ecosystem,
.workspace-body > #page-business,
.workspace-body > #page-commerce,
.workspace-body > #page-emails,
.workspace-body > #page-charge,
.workspace-body > #page-costs,
.workspace-body > #page-users,
.workspace-body > #page-feedback,
.workspace-body > #page-system-prompts,
.workspace-body > #page-feedback-access {
  max-width: none;
  margin: 0;
  width: 100%;
}

.fb-capture-cell { white-space: nowrap; }
.fb-thumb-btn {
  display: inline-flex;
  padding: 0;
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 6px;
  background: var(--color-bg-subtle, #f9fafb);
  cursor: zoom-in;
  overflow: hidden;
  vertical-align: middle;
}
.fb-thumb-btn + .fb-thumb-btn { margin-left: 4px; }
.fb-thumb-btn:hover { border-color: var(--color-primary-400, #fb923c); box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.15); }
.fb-thumb {
  display: block;
  width: 56px;
  height: 56px;
  object-fit: cover;
}
.fb-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10050;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.fb-lightbox.hidden { display: none; }
.fb-lightbox__panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: min(96vw, 1400px);
  max-height: 90vh;
  overflow-y: auto;
}
.fb-lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}
.fb-lightbox__desc,
.fb-lightbox__resolution {
  margin: 0;
  width: 100%;
  color: #fff;
  font-size: var(--text-sm);
  line-height: 1.45;
  text-align: left;
}
.fb-lightbox__desc { font-weight: 500; }
.fb-lightbox__resolution { color: rgba(255, 255, 255, 0.88); }
.fb-lightbox__img {
  max-width: 100%;
  max-height: min(70vh, 900px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
body.fb-lightbox-open { overflow: hidden; }

/* ---------- Notifications retours traités ---------- */
.feedback-notify {
  position: relative;
}
.feedback-notify__btn {
  position: relative;
}
.feedback-notify__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-primary-600, #ea580c);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.1rem;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--color-surface, #fff);
}
.feedback-notify__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(22rem, calc(100vw - 2rem));
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
  z-index: 200;
  display: flex;
  flex-direction: column;
  max-height: 75vh;
  max-height: 75dvh;
}
.feedback-notify__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border, #e5e7eb);
}
.feedback-notify__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.feedback-notify__foot {
  padding: 10px 12px;
  border-top: 1px solid var(--color-border, #e5e7eb);
  display: flex;
  justify-content: flex-end;
}
.feedback-notify-item {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--color-bg-subtle, #f9fafb);
  border: 1px solid var(--color-border, #e5e7eb);
}
.feedback-notify-item__head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.feedback-notify-item__resolved { margin-left: auto; white-space: nowrap; }
.feedback-notify-item__desc { margin: 0 0 6px; }
.feedback-notify-item__notes { margin: 0; font-weight: 500; }
[data-theme="dark"] .feedback-notify__badge {
  box-shadow: 0 0 0 2px var(--color-surface, #1a1618);
}
[data-theme="dark"] .feedback-notify__panel {
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}
[data-theme="dark"] .impersonation-pill { background: #3a1f1f; color: #fecaca; border-color: #ef4444; }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.user-actions button { padding: 4px 10px; font-size: var(--text-sm); height: 26px; }
.assign-checklist {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 240px; overflow: auto;
  margin-top: 6px; padding: 10px; border: 1px solid var(--color-border); border-radius: 8px;
  background: var(--color-surface-sunken); color: var(--color-text);
}
.assign-checklist label {
  display: flex; gap: 8px; align-items: center; font-weight: normal; cursor: pointer;
  color: var(--color-text);
}
.assign-checklist label:hover { background: var(--color-surface-hover); border-radius: var(--radius-md); }
.invite-link-box { word-break: break-all; margin-top: 8px; }
.invite-link-box code { display: block; padding: 8px; margin-top: 4px; }

.batch-field { position: relative; }
.batch-field > .batch-apply {
  flex-direction: row !important; align-items: center; gap: 6px !important;
  font-weight: var(--weight-medium) !important; font-size: var(--text-sm) !important;
  color: var(--color-text-muted); margin-bottom: 4px;
}
.batch-field > .batch-apply input { width: auto !important; }
textarea.readonly { background: var(--color-surface-sunken); color: var(--color-text-muted); cursor: default; }
.batch-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.batch-toolbar-label { font-weight: var(--weight-semibold); font-size: var(--text-sm); margin-right: 4px; }
.cs-show-hidden-wrap { margin-left: auto !important; font-weight: var(--weight-medium) !important; font-size: var(--text-sm) !important; }
.cs-agents-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: min(60vh, 480px); overflow-y: auto;
  margin-top: 4px;
}
.cs-agents-list label {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: var(--color-bg);
  font-size: var(--text-sm); cursor: pointer;
}
.cs-agents-list label:hover { background: var(--color-surface-hover); }
.cs-agents-list input { width: auto !important; margin: 0; }
.cs-agent-row {
  flex-direction: row !important; align-items: center; gap: 8px !important;
  font-weight: var(--weight-medium) !important; font-size: var(--text-sm) !important; padding: 4px 0;
}
.cs-agent-row input { width: auto !important; flex-shrink: 0; }
.cs-agent-row .agent-slug { font-weight: var(--weight-regular); }

.prompt-history-panel {
  margin-top: 8px; padding: 10px 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
}
.prompt-history-panel summary { cursor: pointer; font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.prompt-history-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; max-height: 280px; overflow-y: auto; }
.prompt-history-item { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 10px 12px; background: var(--color-surface); }
.prompt-history-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.prompt-history-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.prompt-history-content {
  margin-top: 8px; padding: 10px; background: var(--color-surface-sunken);
  border-radius: var(--radius-sm); font-size: var(--text-sm);
  white-space: pre-wrap; max-height: 180px; overflow-y: auto;
}
.prompt-history-content.hidden { display: none; }

p.small.warn { color: var(--color-warn-fg); margin: 6px 0 0; }

/* Profils d'embedding — paramètres techniques */
.embed-profile-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.embed-profile-card {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  background: var(--color-bg, #fff);
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.embed-profile-card:hover { border-color: var(--color-primary-400); }
.embed-profile-card.is-selected {
  border-color: var(--color-primary-600);
  box-shadow: 0 0 0 1px var(--color-primary-600);
  background: var(--color-primary-50, #fff7ed);
}
[data-theme="dark"] .embed-profile-card,
html[data-theme="dark"] .embed-profile-card {
  background: var(--color-surface, #1c1917);
}
[data-theme="dark"] .embed-profile-card.is-selected,
html[data-theme="dark"] .embed-profile-card.is-selected {
  background: rgba(234, 88, 12, 0.14);
  border-color: var(--color-primary-500, #ea580c);
}
.embed-profile-card input { position: absolute; opacity: 0; pointer-events: none; }
.embed-profile-card__title { font-weight: var(--weight-semibold); margin: 0 0 6px; color: var(--color-text); }
.embed-profile-card__meta { font-size: var(--text-xs); color: var(--color-text-muted); margin: 0 0 8px; }
.embed-profile-card__desc { font-size: var(--text-sm); margin: 0; color: var(--color-text); line-height: 1.45; }
.embed-profile-card__warn {
  margin-top: 8px; font-size: var(--text-xs); color: var(--color-warn-fg, #a16207);
  font-weight: var(--weight-medium);
}
[data-theme="dark"] .embed-profile-card__warn,
html[data-theme="dark"] .embed-profile-card__warn {
  color: #fbbf24;
}
.embed-qwen-consent {
  margin-top: 14px; padding: 12px 14px;
  border: 1px solid var(--color-warn-border, #ca8a04);
  border-radius: var(--radius-md);
  background: var(--color-warn-bg, rgba(234, 179, 8, 0.12));
  color: var(--color-text);
}
.embed-qwen-consent__label { font-size: var(--text-sm); line-height: 1.45; color: var(--color-text); }
.embed-agent-summary {
  padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--color-bg-subtle); border: 1px solid var(--color-border);
}
.modal-dialog {
  border: none; border-radius: var(--radius-lg);
  padding: 24px; max-width: 440px;
  box-shadow: var(--shadow-lg, 0 12px 40px rgba(0,0,0,.18));
}
.modal-dialog::backdrop { background: rgba(0,0,0,.45); }
.modal-dialog__actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.config-layout--single { max-width: 960px; }
