/* ============================================================
   SouzaHarness — Design System (tema escuro, ferramenta técnica)
   Neurodesign: baixa carga cognitiva, hierarquia forte, cores de
   status consistentes, feedback imediato, contraste WCAG AA.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  /* Superfícies (azul-carvão: menos fadiga que preto puro) */
  --bg-0: #0B0E14;
  --bg-1: #10141D;
  --bg-2: #161B26;
  --bg-3: #1D2431;
  --border: #262E3D;
  --border-strong: #354054;

  /* Texto (contraste AA garantido sobre --bg-0/--bg-2) */
  --text-1: #E8ECF4;
  --text-2: #A8B2C4;
  --text-3: #8A94A8;

  /* Ação primária (Von Restorff: único elemento saturado por tela) */
  --accent: #4F8CFF;
  --accent-hover: #6BA1FF;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --on-accent: #0B0E14;

  /* Status (consistentes em todo o app) */
  --st-queued: #A8B2C4;
  --st-queued-bg: rgba(168, 178, 196, 0.12);
  --st-running: #5B9DFF;
  --st-running-bg: rgba(79, 140, 255, 0.14);
  --st-success: #3ECF8E;
  --st-success-bg: rgba(62, 207, 142, 0.12);
  --st-danger: #FF7A7A;
  --st-danger-bg: rgba(255, 107, 107, 0.12);
  --st-warn: #F0B45B;
  --st-warn-bg: rgba(240, 180, 91, 0.12);

  /* Categorias de eventos (timeline) */
  --ev-llm: #B48CFF;
  --ev-llm-bg: rgba(180, 140, 255, 0.12);
  --ev-tool: #F0B45B;
  --ev-tool-bg: rgba(240, 180, 91, 0.12);
  --ev-deleg: #4FD1C5;
  --ev-deleg-bg: rgba(79, 209, 197, 0.12);

  /* Tipografia (stack de sistema) */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas,
               "Liberation Mono", Menlo, monospace;
  --fs-xs: 0.75rem;    /* 12px — meta, timestamps */
  --fs-sm: 0.8125rem;  /* 13px — secundário */
  --fs-md: 0.875rem;   /* 14px — base */
  --fs-lg: 1rem;       /* 16px — destaque */
  --fs-xl: 1.25rem;    /* 20px — título de seção */
  --fs-2xl: 1.5rem;    /* 24px — título de página */

  /* Ritmo (escala de 4px) */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 999px;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, 0.45);

  --sidebar-w: 232px;
  --transition-fast: 140ms ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-0);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--font-mono); }
[hidden] { display: none !important; }

/* Foco visível (acessibilidade AA) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.view:focus-visible, .view:focus { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   Layout: sidebar fixa + conteúdo
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  padding: var(--sp-4) var(--sp-3);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  margin-bottom: var(--sp-6);
  color: var(--text-1);
  font-weight: 700;
  font-size: var(--fs-lg);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; }

.nav { display: flex; flex-direction: column; gap: var(--sp-1); flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  min-height: 40px;
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-weight: 500;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-item:hover { background: var(--bg-2); color: var(--text-1); text-decoration: none; }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}
.nav-item svg { flex-shrink: 0; }

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

.health {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.health-dot {
  width: 8px; height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  background: var(--text-3);
}
.health-dot[data-state="ok"] { background: var(--st-success); }
.health-dot[data-state="warn"] { background: var(--st-warn); }
.health-dot[data-state="down"] { background: var(--st-danger); }
.health-dot[data-state="checking"] { background: var(--text-3); animation: pulse-dot 1.4s ease-in-out infinite; }

.main { min-width: 0; }

.view {
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-8) 96px;
}

/* Cabeçalho de página */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.page-title { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-3); font-size: var(--fs-sm); margin-top: var(--sp-1); }

/* ============================================================
   Componentes base
   ============================================================ */

/* ---- Botões (Fitts: altura mínima 40px) ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-5);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), border-color var(--transition-fast),
              color var(--transition-fast), transform var(--transition-fast);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-2);
  border-color: var(--border-strong);
  color: var(--text-1);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-3); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--text-1); }

.btn-sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn-block { width: 100%; }

/* Spinner interno de botão / geral */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
.spinner-lg { width: 28px; height: 28px; border-width: 3px; color: var(--accent); }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Painéis / cards ---- */
.panel {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
}
.panel + .panel { margin-top: var(--sp-5); }
.panel-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  margin-bottom: var(--sp-4);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-4);
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.card-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.card-title { font-size: var(--fs-lg); font-weight: 700; }
.card-desc { color: var(--text-2); font-size: var(--fs-sm); }
.card-meta { color: var(--text-3); font-size: var(--fs-xs); }

/* ---- Chips de status (consistentes em todo o app) ---- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.chip .dot {
  width: 7px; height: 7px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex-shrink: 0;
}
.chip-queued { background: var(--st-queued-bg); color: var(--st-queued); }
.chip-running { background: var(--st-running-bg); color: var(--st-running); }
.chip-running .dot { animation: pulse-dot 1.2s ease-in-out infinite; }
.chip-completed { background: var(--st-success-bg); color: var(--st-success); }
.chip-failed { background: var(--st-danger-bg); color: var(--st-danger); }
.chip-cancelled { background: var(--st-queued-bg); color: var(--st-queued); text-decoration: line-through; text-decoration-thickness: 1px; }
.btn-cancel-run { color: var(--st-danger); }
.btn-cancel-run:hover:not(:disabled) { background: var(--st-danger-bg); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

/* ---- Badges (tipos de evento, tool, etc.) ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}
.badge-neutral { background: var(--st-queued-bg); color: var(--st-queued); }
.badge-info { background: var(--st-running-bg); color: var(--st-running); }
.badge-success { background: var(--st-success-bg); color: var(--st-success); }
.badge-danger { background: var(--st-danger-bg); color: var(--st-danger); }
.badge-warn { background: var(--st-warn-bg); color: var(--st-warn); }
.badge-llm { background: var(--ev-llm-bg); color: var(--ev-llm); }
.badge-tool { background: var(--ev-tool-bg); color: var(--ev-tool); }
.badge-deleg { background: var(--ev-deleg-bg); color: var(--ev-deleg); }

.tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
}
.tag-list { display: flex; flex-wrap: wrap; gap: var(--sp-1); }

/* ---- Formulários ---- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field:last-child { margin-bottom: 0; }

.field label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-1);
}
.field .optional { color: var(--text-3); font-weight: 400; font-size: var(--fs-xs); }
.field .required { color: var(--st-danger); }

.hint { font-size: var(--fs-xs); color: var(--text-3); margin: 0; }
.hint-ok { color: var(--st-success); }
.hint-error { color: var(--st-danger); }

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px var(--sp-3);
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--text-1);
  font-family: inherit;
  font-size: var(--fs-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
textarea { resize: vertical; line-height: 1.5; }
textarea.mono, input.mono { font-family: var(--font-mono); font-size: var(--fs-sm); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input.invalid, textarea.invalid {
  border-color: var(--st-danger);
  box-shadow: 0 0 0 3px var(--st-danger-bg);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }

/* Seta nativa do select (CSP default-src 'self' bloqueia data: URIs).
   color-scheme: dark garante dropdown escuro nos navegadores modernos. */
select { color-scheme: dark; cursor: pointer; }

.checkbox-field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}
.checkbox-field input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}
.checkbox-field label { font-size: var(--fs-sm); font-weight: 500; cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.form-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
  flex-wrap: wrap;
}

/* Switch (auto-refresh) */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--text-2);
  user-select: none;
}
.switch input {
  position: absolute;
  opacity: 0;
  width: 40px; height: 22px;
  margin: 0;
  cursor: pointer;
}
.switch .track {
  position: relative;
  width: 40px; height: 22px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
  flex-shrink: 0;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: var(--radius-full);
  background: var(--text-2);
  transition: transform var(--transition-fast), background var(--transition-fast);
}
.switch input:checked + .track { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); background: var(--accent); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Progressive disclosure */
details.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-1);
  margin-bottom: var(--sp-4);
}
details.disclosure summary {
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-2);
  list-style: none;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  border-radius: var(--radius-md);
}
details.disclosure summary::-webkit-details-marker { display: none; }
details.disclosure summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid var(--text-3);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform var(--transition-fast);
}
details.disclosure[open] summary::before { transform: rotate(90deg); }
details.disclosure summary:hover { color: var(--text-1); }
details.disclosure .disclosure-body { padding: var(--sp-2) var(--sp-4) var(--sp-4); }

/* ---- Blocos de código / resultado ---- */
pre.code {
  margin: 0;
  padding: var(--sp-4);
  background: var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-1);
  max-height: 480px;
  overflow-y: auto;
}

.result-block { border-left: 3px solid var(--st-success); }
.error-block { border-left: 3px solid var(--st-danger); }
.result-block pre.code, .error-block pre.code { border: none; background: transparent; padding: 0; }
.result-block, .error-block {
  background: var(--bg-2);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-top: var(--sp-5);
}
.block-label {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  margin-bottom: var(--sp-3);
}
.result-block .block-label { color: var(--st-success); }
.error-block .block-label { color: var(--st-danger); }

/* ============================================================
   Gate de conexão
   ============================================================ */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6);
  background:
    radial-gradient(800px 400px at 50% -10%, rgba(79, 140, 255, 0.08), transparent),
    var(--bg-0);
}

.gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-10) var(--sp-8);
  box-shadow: var(--shadow-2);
  text-align: center;
}
.gate-logo { margin-bottom: var(--sp-4); }
.gate-card h1 { font-size: var(--fs-2xl); letter-spacing: -0.02em; }
.gate-subtitle { color: var(--text-2); font-size: var(--fs-sm); margin: var(--sp-2) 0 var(--sp-6); }
.gate-card form { text-align: left; }

.gate-alert {
  text-align: left;
  background: var(--st-danger-bg);
  border: 1px solid rgba(255, 107, 107, 0.35);
  color: var(--st-danger);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-4);
}

.gate-advanced { margin-bottom: var(--sp-4); }
.gate-advanced summary {
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-bottom: var(--sp-3);
}
.gate-advanced summary:hover { color: var(--text-2); }

.gate-health {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  margin-top: var(--sp-6);
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* ============================================================
   Dashboard de execuções
   ============================================================ */
.runs-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.runs-toolbar .field-inline {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.runs-toolbar .field-inline label { font-size: var(--fs-sm); color: var(--text-3); }
.runs-toolbar select { min-height: 34px; width: auto; font-size: var(--fs-sm); padding-top: 5px; padding-bottom: 5px; }
.runs-toolbar .spacer { flex: 1; }

.run-list { display: flex; flex-direction: column; gap: var(--sp-2); }

.run-row {
  display: grid;
  grid-template-columns: 118px 1fr auto;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-1);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.run-row:hover {
  background: var(--bg-3);
  border-color: var(--border-strong);
  text-decoration: none;
}
.run-row-main { min-width: 0; }
.run-task {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.run-meta {
  display: flex;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: 2px;
  flex-wrap: wrap;
}
.run-meta .mono { font-size: var(--fs-xs); }
.run-when { font-size: var(--fs-xs); color: var(--text-3); text-align: right; white-space: nowrap; }
.run-when .line { display: block; }

/* Estado vazio */
.empty-state {
  text-align: center;
  padding: var(--sp-10) var(--sp-6);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-1);
}
.empty-state svg { margin-bottom: var(--sp-4); }
.empty-state h2 { font-size: var(--fs-xl); margin-bottom: var(--sp-2); }
.empty-state p { color: var(--text-2); font-size: var(--fs-sm); max-width: 380px; margin: 0 auto var(--sp-6); }

/* Skeleton (loading) */
.skeleton-row {
  height: 68px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border: 1px solid var(--border);
}
.skeleton-row + .skeleton-row { margin-top: var(--sp-2); }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-10);
  color: var(--text-3);
  font-size: var(--fs-sm);
}

/* ============================================================
   Detalhe da execução
   ============================================================ */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-sm);
  color: var(--text-3);
  margin-bottom: var(--sp-4);
}
.back-link:hover { color: var(--text-1); text-decoration: none; }

.run-header-top {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-bottom: var(--sp-4);
}
.run-id {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-2);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
}
.btn-copy {
  min-height: 28px;
  padding: 0 var(--sp-2);
}
.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  color: var(--st-running);
  margin-left: auto;
}
.live-indicator .dot {
  width: 7px; height: 7px;
  border-radius: var(--radius-full);
  background: currentColor;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--sp-4);
}
.meta-item .meta-label {
  font-size: var(--fs-xs);
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.meta-item .meta-value { font-size: var(--fs-sm); font-weight: 600; word-break: break-word; }

/* Timeline vertical */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}
.tl-item {
  position: relative;
  padding: 0 0 var(--sp-5) var(--sp-8);
}
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute;
  left: 0;
  top: 4px;
  width: 16px; height: 16px;
  border-radius: var(--radius-full);
  background: var(--bg-2);
  border: 3px solid var(--st-queued);
}
.tl-item[data-cat="info"] .tl-dot { border-color: var(--st-running); }
.tl-item[data-cat="success"] .tl-dot { border-color: var(--st-success); }
.tl-item[data-cat="danger"] .tl-dot { border-color: var(--st-danger); }
.tl-item[data-cat="llm"] .tl-dot { border-color: var(--ev-llm); }
.tl-item[data-cat="tool"] .tl-dot { border-color: var(--ev-tool); }
.tl-item[data-cat="deleg"] .tl-dot { border-color: var(--ev-deleg); }

.tl-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.tl-agent {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.tl-time { font-size: var(--fs-xs); color: var(--text-3); margin-left: auto; white-space: nowrap; }
.tl-item details { margin-top: var(--sp-2); }
.tl-item summary {
  cursor: pointer;
  font-size: var(--fs-xs);
  color: var(--text-3);
  user-select: none;
}
.tl-item summary:hover { color: var(--text-2); }
.tl-item pre.code { margin-top: var(--sp-2); max-height: 320px; }

/* ============================================================
   Provedores / Ferramentas
   ============================================================ */
.test-area {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-4);
  margin-top: var(--sp-1);
}
.test-row { display: flex; gap: var(--sp-2); align-items: flex-end; }
.test-row .field { flex: 1; margin-bottom: 0; }

.test-result { margin-top: var(--sp-3); }
.test-result-head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--text-3);
  flex-wrap: wrap;
}
.latency {
  font-family: var(--font-mono);
  color: var(--text-2);
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  padding: 1px 6px;
}

.tool-form .field { margin-bottom: var(--sp-3); }

/* ============================================================
   Config (somente leitura)
   ============================================================ */
.config-section { margin-bottom: var(--sp-8); }
.config-section h2 {
  font-size: var(--fs-xl);
  margin-bottom: var(--sp-4);
  letter-spacing: -0.01em;
}
.kv-row {
  display: flex;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  flex-wrap: wrap;
}
.kv-row .k { color: var(--text-3); min-width: 96px; }
.kv-row .v { color: var(--text-1); font-weight: 500; word-break: break-word; }

/* ============================================================
   Toasts (feedback imediato — Doherty)
   ============================================================ */
.toasts {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 1000;
  max-width: 380px;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
  animation: toast-in 200ms ease;
  word-break: break-word;
}
.toast-success { border-left: 3px solid var(--st-success); }
.toast-error { border-left: 3px solid var(--st-danger); }
.toast-info { border-left: 3px solid var(--accent); }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: opacity 200ms ease, transform 200ms ease; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Responsivo
   ============================================================ */
@media (max-width: 900px) {
  .app { grid-template-columns: 64px 1fr; }
  .sidebar { padding: var(--sp-4) var(--sp-2); }
  .brand-name, .nav-item span, .sidebar-footer .health-text, #btn-disconnect span { display: none; }
  .brand, .nav-item { justify-content: center; padding: 10px; }
  .health { justify-content: center; padding: 0; }
  #btn-disconnect { justify-content: center; }
  .view { padding: var(--sp-5) var(--sp-4) 96px; }
  .form-row { grid-template-columns: 1fr; }
  .run-row { grid-template-columns: 100px 1fr; }
  .run-when { display: none; }
}

@media (max-width: 560px) {
  .card-grid { grid-template-columns: 1fr; }
  .test-row { flex-direction: column; align-items: stretch; }
  .toasts { left: var(--sp-4); right: var(--sp-4); max-width: none; }
}
