/* ==========================================================================
   BI Multi-Agent Hub — Design system
   Palette sombre premium, typographie Inter/JetBrains Mono, sans dépendance
   à un framework CSS externe (tout est ici, pour un contrôle total du rendu).
   ========================================================================== */

:root {
  --bg: #0a0e17;
  --bg-elevated: #0f1420;
  --surface: #131a29;
  --surface-2: #1a2233;
  --surface-hover: #202a40;
  --border: #263049;
  --border-soft: #1c2438;

  --text-primary: #eef1f8;
  --text-secondary: #9aa5bd;
  --text-muted: #6b7690;

  --accent: #6f6bf7;
  --accent-strong: #857ffb;
  --accent-soft: rgba(111, 107, 247, 0.14);
  --cyan: #22d3ee;
  --cyan-soft: rgba(34, 211, 238, 0.14);

  --success: #2fd47a;
  --success-soft: rgba(47, 212, 122, 0.14);
  --warning: #f5a524;
  --warning-soft: rgba(245, 165, 36, 0.14);
  --danger: #f0576b;
  --danger-soft: rgba(240, 87, 107, 0.14);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-lift: 0 16px 40px rgba(0, 0, 0, 0.38);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 12% 0%, rgba(111, 107, 247, 0.10), transparent 42%),
    radial-gradient(circle at 92% 8%, rgba(34, 211, 238, 0.07), transparent 38%);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--surface-hover); }

/* ---------------------------------------------------------------------- */
/* Layout général                                                          */
/* ---------------------------------------------------------------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 28px 6px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 20px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(111, 107, 247, 0.95), rgba(34, 211, 238, 0.75));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  color: #fff;
}
.brand-mark .ico {
  width: 22px;
  height: 22px;
}

/* Icônes : taille forcée (évite le défaut SVG 300x150) */
.sidebar .ico,
.sidebar svg.ico,
.side-nav .ico,
.side-nav svg,
.nav-icon svg {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
    max-width: 16px !important;
    max-height: 16px !important;
}
.brand-mark .ico,
.brand-mark svg {
    width: 22px !important;
    height: 22px !important;
    min-width: 22px !important;
    min-height: 22px !important;
    max-width: 22px !important;
    max-height: 22px !important;
}
.side-nav a {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
}
.nav-icon {
    width: 18px !important;
    height: 18px !important;
    flex: 0 0 18px !important;
}

.ico {
  width: 16px;
  height: 16px;
  max-width: 28px;
  max-height: 28px;
  display: block;
  flex-shrink: 0;
  overflow: hidden;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  pointer-events: none;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  flex-shrink: 0;
}
.nav-icon .ico {
  width: 16px;
  height: 16px;
}

.side-nav a {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--accent-strong);
  flex-shrink: 0;
}
.msg-avatar .ico { width: 16px; height: 16px; }
.msg-row.user .msg-avatar { color: var(--cyan); }

.agent-ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  color: inherit;
}
.agent-ico .ico { width: 18px; height: 18px; }

.fn-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}
.fn-icon .ico { width: 16px; height: 16px; }

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  background: var(--accent-soft);
  border: 1px solid rgba(111, 107, 247, 0.35);
  color: var(--accent-strong);
}
.empty-icon .ico { width: 26px; height: 26px; }

.card-title-ico {
  width: 15px;
  height: 15px;
  display: inline-flex;
  margin-right: 4px;
  vertical-align: -2px;
  color: var(--accent-strong);
}
.card-title-ico .ico { width: 15px; height: 15px; }


.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.brand-text strong { font-size: 14.5px; letter-spacing: -0.01em; }
.brand-text span { font-size: 11.5px; color: var(--text-muted); }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.side-nav a:hover { background: var(--surface); color: var(--text-primary); }
.side-nav a.active {
  background: var(--accent-soft);
  color: #cfceff;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.model-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 999px;
  width: fit-content;
}
.model-pill .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}
.footer-caption { font-size: 11px; color: var(--text-muted); }

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---------------------------------------------------------------------- */
/* Page de chat                                                            */
/* ---------------------------------------------------------------------- */

.chat-header {
  padding: 22px 32px 16px 32px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.chat-header h1 { font-size: 19px; margin: 0 0 4px 0; letter-spacing: -0.01em; }
.chat-header p { margin: 0; color: var(--text-secondary); font-size: 13.5px; }

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-secondary);
  max-width: 560px;
}
.empty-state h2 { color: var(--text-primary); font-size: 17px; margin-bottom: 8px; }
.suggestion-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}
.suggestion-chip {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, color 0.15s ease;
}
.suggestion-chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.msg-row { display: flex; gap: 12px; max-width: 880px; }
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 14.5px;
  line-height: 1.55;
}
.msg-row.user .msg-bubble { background: var(--accent-soft); border-color: rgba(111,107,247,0.35); }

/* --- Trace d'orchestration (timeline agents) --- */

.trace-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 6px;
  width: 100%;
}
.trace-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12.5px;
  cursor: pointer;
}
.trace-toggle:hover { color: var(--text-primary); }

.pipeline-caption {
  padding: 0 14px 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.pipeline-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 4px 14px 12px;
}
.pipeline-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  opacity: 0.55;
}
.pipeline-chip.active {
  opacity: 1;
  border-color: rgba(111, 107, 247, 0.55);
  background: var(--accent-soft);
  color: var(--text-primary);
  box-shadow: 0 0 0 1px rgba(111, 107, 247, 0.2);
}
.pipeline-chip.done {
  opacity: 1;
  border-color: rgba(47, 212, 122, 0.4);
  color: var(--success);
  background: var(--success-soft);
}
.pipeline-chip.skipped {
  opacity: 0.4;
  text-decoration: line-through;
  text-decoration-color: var(--text-muted);
}
.pipeline-chip.idle {
  opacity: 0.55;
}
.pipeline-arrow {
  color: var(--text-muted);
  font-size: 11px;
}

.trace-steps {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 8px 12px 8px;
}
.trace-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  font-size: 12.8px;
  border: 1px solid var(--border-soft);
  background: var(--bg-elevated);
}
.trace-step.supervisor {
  border-color: rgba(111, 107, 247, 0.35);
  background: linear-gradient(
    135deg,
    rgba(111, 107, 247, 0.10),
    rgba(34, 211, 238, 0.04)
  );
}
.trace-step:hover { border-color: var(--border); }
.trace-step .agent-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--accent-strong);
}
.trace-step .agent-icon .ico { width: 14px; height: 14px; }
.trace-step .trace-body { flex: 1; min-width: 0; }
.trace-step-toggle {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.trace-step-toggle:hover .trace-title {
  color: var(--text-primary);
}
.trace-step .trace-title {
  color: var(--text-primary);
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}
.trace-step .step-chevron {
  flex-shrink: 0;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  padding-top: 1px;
  opacity: 0.95;
}
.trace-step.collapsed {
  padding-top: 8px;
  padding-bottom: 8px;
}
.trace-step.collapsed .agent-icon {
  margin-top: 0;
}
.trace-step .trace-kind {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-strong);
}
.trace-meta {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}
.trace-meta-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  align-items: start;
}
.trace-meta-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 2px;
}
.trace-meta-value {
  color: var(--text-secondary);
  line-height: 1.45;
  font-size: 12.6px;
}
.trace-meta-value.emphasis {
  color: var(--text-primary);
  font-weight: 500;
}
.trace-step .trace-arrow {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
}
.reasoning-text {
  margin: 8px 0 0;
  color: var(--text-secondary);
  font-size: 13.2px;
  line-height: 1.55;
}
.sql-details {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}
.sql-details summary {
  cursor: pointer;
  user-select: none;
  color: var(--accent-strong);
  font-weight: 600;
}
.sql-details[open] summary { margin-bottom: 6px; }
.trace-step .sql-snippet {
  margin-top: 0; font-family: var(--font-mono); font-size: 11.5px;
  background: var(--bg); border: 1px solid var(--border-soft);
  border-radius: 6px; padding: 8px 10px; color: #b9c3dd; overflow-x: auto;
  white-space: pre-wrap; word-break: break-word;
}

/* --- Rapport final structuré --- */

.report-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.report-card.span-2 { grid-column: 1 / -1; }
.report-card h3 {
  margin: 0 0 10px 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}
.report-card.summary { border-color: rgba(111,107,247,0.35); background: linear-gradient(160deg, var(--accent-soft), var(--surface) 60%); }
.report-card.summary p { font-size: 15px; line-height: 1.6; margin: 0; }
.report-card ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; font-size: 13.3px; line-height: 1.5; }
.report-card ul.plain { list-style: none; padding-left: 0; }
.report-card .empty-hint { color: var(--text-muted); font-size: 13px; font-style: italic; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em;
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.needs_review { background: var(--warning-soft); color: var(--warning); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* --- Zone de saisie --- */

.composer {
  flex-shrink: 0;
  padding: 16px 32px 24px 32px;
  border-top: 1px solid var(--border-soft);
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
}
.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 10px 10px 10px 18px;
  max-width: 880px;
  margin: 0 auto;
  transition: border-color 0.15s ease;
}
.composer-box:focus-within { border-color: var(--accent); }
.composer-box textarea {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14.5px;
  line-height: 1.5;
  max-height: 140px;
  padding: 8px 0;
}
.composer-box textarea::placeholder { color: var(--text-muted); }
.send-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  border: none; background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}
.send-btn .ico { width: 18px; height: 18px; color: #fff; }
.send-btn:hover:not(:disabled) { background: var(--accent-strong); }
.send-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.composer-hint { text-align: center; font-size: 11px; color: var(--text-muted); margin-top: 10px; }

.thinking-row { display: flex; align-items: center; gap: 10px; color: var(--text-secondary); font-size: 13px; }
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(111, 107, 247, 0.25);
  border-top-color: var(--accent-strong);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}
.spinner-sm {
  width: 12px;
  height: 12px;
  border-width: 2px;
  margin-right: 6px;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.emoji-ico {
  font-size: 14px;
  line-height: 1;
  display: inline-block;
}
.trace-title-label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.thinking-dots span {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); margin-right: 3px; animation: pulse 1.2s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }

.error-banner {
  background: var(--danger-soft); border: 1px solid rgba(240,87,107,0.4);
  color: #ffb3bd; padding: 12px 16px; border-radius: var(--radius-md);
  font-size: 13.3px; max-width: 880px;
}

/* ---------------------------------------------------------------------- */
/* Espace admin                                                            */
/* ---------------------------------------------------------------------- */

.admin-page { padding: 28px 34px 40px 34px; overflow-y: auto; height: 100vh; }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.admin-topbar h1 { font-size: 20px; margin: 0 0 4px 0; }
.admin-topbar p { margin: 0; color: var(--text-secondary); font-size: 13.5px; }
.admin-actions { display: flex; gap: 10px; }

.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { border-color: var(--accent); background: var(--surface-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}
.kpi-card .kpi-label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-card .kpi-value { font-size: 25px; font-weight: 700; margin-top: 6px; letter-spacing: -0.01em; }
.kpi-card .kpi-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.charts-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.panel h2 { font-size: 13.5px; margin: 0 0 14px 0; color: var(--text-primary); }
.panel canvas { max-height: 260px; }

.tables-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
table.data-table th {
  text-align: left; color: var(--text-muted); font-weight: 500;
  padding: 8px 10px; border-bottom: 1px solid var(--border-soft);
  text-transform: uppercase; font-size: 10.8px; letter-spacing: 0.04em;
}
table.data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); color: var(--text-secondary); }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table td.primary { color: var(--text-primary); }
.table-scroll { max-height: 320px; overflow-y: auto; }

/* ---------------------------------------------------------------------- */
/* Connexion admin                                                         */
/* ---------------------------------------------------------------------- */

.login-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
}
.login-card {
  width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 30px;
  box-shadow: var(--shadow-lift);
}
.login-card .login-icon {
  width: 46px; height: 46px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 16px;
}
.login-card h1 { font-size: 17px; margin: 0 0 6px 0; }
.login-card p { font-size: 13px; color: var(--text-secondary); margin: 0 0 22px 0; }
.login-card input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-elevated);
  color: var(--text-primary); font-size: 14px; margin-bottom: 14px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  width: 100%; padding: 11px; border-radius: var(--radius-sm); border: none;
  background: var(--accent); color: white; font-size: 14px; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: var(--accent-strong); }
.login-error {
  background: var(--danger-soft); color: #ffb3bd; border: 1px solid rgba(240,87,107,0.4);
  padding: 9px 12px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 14px;
}

/* ---------------------------------------------------------------------- */
/* Page Architecture — grille live + diagramme animé                       */
/* ---------------------------------------------------------------------- */

.arch-shell {
  height: 100%;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px 24px;
  overflow: auto;
}

.arch-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.85fr);
  gap: 16px;
  flex: 1 1 auto;
  min-height: 520px;
}

.arch-diagram-pane,
.arch-explain-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.flow-canvas {
  position: relative;
  flex: 1 1 auto;
  min-height: 420px;
  height: 420px;
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 50% 18%, rgba(111, 107, 247, 0.16), transparent 42%),
    linear-gradient(180deg, #0c1220, #121a2b);
  border: 1px solid var(--border-soft);
  overflow: hidden;
}

.arch-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.arch-eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-strong);
}

.arch-top h1 {
  margin: 0 0 8px;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.arch-lead {
  margin: 0;
  max-width: 58ch;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.arch-cta-btn {
  display: inline-flex;
  align-items: center;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff !important;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.arch-cta-btn:hover { background: var(--accent-strong); }

.arch-diagram-pane {
  padding: 14px 14px 12px;
  gap: 10px;
}

.arch-explain-pane {
  padding: 16px;
  gap: 12px;
}

.arch-diagram-label {
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.flow-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.flow-path {
  fill: none;
  stroke: rgba(155, 168, 196, 0.22);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke 0.35s ease, stroke-width 0.35s ease, filter 0.35s ease;
}

.flow-path.lit {
  stroke: rgba(111, 107, 247, 0.85);
  stroke-width: 2.6;
  filter: drop-shadow(0 0 6px rgba(111, 107, 247, 0.45));
  stroke-dasharray: 8 8;
  animation: dash-flow 1.1s linear infinite;
}

@keyframes dash-flow {
  to { stroke-dashoffset: -24; }
}

.flow-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 84px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  opacity: 0.45;
  transition: all 0.3s ease;
  z-index: 2;
}

.flow-node .fn-icon {
  width: 18px;
  height: 18px;
  color: inherit;
}
.flow-node.done {
  opacity: 1;
  color: var(--success);
  border-color: rgba(47, 212, 122, 0.4);
  background: var(--success-soft);
}
.flow-node.active {
  opacity: 1;
  color: var(--text-primary);
  border-color: rgba(111, 107, 247, 0.65);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(111, 107, 247, 0.25), 0 10px 28px rgba(0, 0, 0, 0.28);
}
.flow-node.pulse {
  animation: node-pulse 1.6s ease-in-out infinite;
}

@keyframes node-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.05); }
}

.flow-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-muted);
}
.flow-legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.flow-legend .lg.done { background: var(--success); }
.flow-legend .lg.active { background: var(--accent-strong); }
.flow-legend .lg.idle { background: var(--text-muted); }

.arch-step-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.step-pill {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.step-pill.done {
  color: var(--success);
  border-color: rgba(47, 212, 122, 0.4);
}
.step-pill.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.arch-explain-card {
  flex: 1;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  overflow: auto;
}

.arch-step-kicker {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cyan);
}

.arch-explain-card h2 {
  margin: 0 0 10px;
  font-size: 17px;
  line-height: 1.35;
}

.arch-explain-body {
  margin: 0 0 12px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.arch-explain-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.arch-explain-controls {
  display: flex;
  gap: 8px;
}

.arch-ctrl {
  flex: 1;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.arch-ctrl.primary {
  background: var(--accent-soft);
  border-color: rgba(111, 107, 247, 0.45);
  color: var(--text-primary);
}
.arch-ctrl:hover { color: var(--text-primary); }

.arch-section-title {
  margin: 4px 0 12px;
  font-size: 16px;
  font-weight: 700;
}

.agent-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.agent-card {
  padding: 12px 13px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.25s ease, transform 0.25s ease, background 0.25s ease;
}
.agent-card.highlight {
  border-color: rgba(111, 107, 247, 0.55);
  background: linear-gradient(160deg, rgba(111, 107, 247, 0.12), var(--surface));
  transform: translateY(-2px);
}
.pipeline-chip .ico {
  width: 12px;
  height: 12px;
  margin-right: 2px;
}
.agent-card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.agent-card p {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
}
.ac-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}
.ac-meta span {
  display: inline-block;
  min-width: 28px;
  margin-right: 4px;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.arch-tech-strip {
  padding: 14px 16px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

.tech-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.tech-box {
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}
.tech-flow > span { color: var(--text-muted); font-size: 12px; }

.arch-tech-note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

@media (max-width: 1100px) {
  .agent-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .arch-stage { grid-template-columns: 1fr; min-height: auto; }
  .flow-canvas { min-height: 340px; }
}

@media (max-width: 720px) {
  .arch-shell { padding: 16px; }
  .arch-top h1 { font-size: 22px; }
  .agent-cards { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------- */
/* Responsive                                                              */
/* ---------------------------------------------------------------------- */

@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid, .tables-grid, .report-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 20; transform: translateX(-100%); transition: transform 0.2s ease; }
  .sidebar.open { transform: translateX(0); }
  .chat-header, .chat-scroll, .composer { padding-left: 16px; padding-right: 16px; }
  .suggestion-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
