:root {
  color-scheme: light;
  --ops-bg: #f6f7f8;
  --ops-ink: #17201f;
  --ops-muted: #66706f;
  --ops-line: #dfe4e2;
  --ops-panel: #ffffff;
  --ops-soft: #f1f4f3;
  --ops-green: #15704f;
  --ops-blue: #235f8c;
  --ops-red: #aa3f37;
  --ops-amber: #8f681d;
  --ops-violet: #66538d;
  --ops-shadow: 0 18px 42px rgba(23, 32, 31, 0.08);
  --ops-shadow-soft: 0 8px 22px rgba(23, 32, 31, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--ops-bg);
  color: var(--ops-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  margin: 0;
}

body::before {
  background: linear-gradient(180deg, #ffffff 0%, rgba(255, 255, 255, 0) 310px);
  content: "";
  inset: 0 0 auto;
  height: 360px;
  pointer-events: none;
  position: fixed;
  z-index: -1;
}

button,
input,
select {
  font: inherit;
}

.ops-shell {
  min-height: 100vh;
  margin: 0 auto;
  max-width: 1560px;
  padding: 28px;
}

.ops-topbar {
  align-items: center;
  border-bottom: 0;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 6px 0 4px;
}

.ops-kicker {
  color: var(--ops-muted);
  font-size: 12px;
  font-weight: 750;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.15;
  margin: 0;
}

h1 {
  font-size: 34px;
  letter-spacing: 0;
}

.ops-version {
  color: var(--ops-muted);
  display: inline-block;
  font-size: 13px;
  font-weight: 750;
  margin-top: 8px;
}

.ops-muted {
  color: var(--ops-muted);
  font-size: 12px;
}

.ops-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.ops-sync-status {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--ops-line);
  border-radius: 999px;
  color: var(--ops-muted);
  font-size: 13px;
  padding: 7px 11px;
  white-space: nowrap;
}

.ops-icon-button {
  align-items: center;
  background: #17201f;
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  min-width: 36px;
}

.ops-icon-button:hover {
  background: #24302e;
  border-color: #24302e;
}

.ops-summary-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  margin: 22px 0 16px;
}

.ops-metric {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  box-shadow: var(--ops-shadow-soft);
  cursor: default;
  min-height: 86px;
  padding: 14px 15px;
}

.ops-metric span {
  color: var(--ops-muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.25;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.ops-metric strong {
  display: block;
  font-size: 30px;
  line-height: 1.1;
}

.ops-agent-workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 360px;
  margin-bottom: 18px;
}

.ops-conversation-panel,
.ops-side-stack,
.ops-main-panel,
.ops-section {
  background: var(--ops-panel);
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  box-shadow: var(--ops-shadow);
}

.ops-conversation-panel,
.ops-side-stack {
  align-self: start;
  padding: 18px;
}

.ops-conversation-panel {
  display: grid;
  gap: 16px;
}

.ops-conversation-header {
  align-items: center;
  border-bottom: 1px solid var(--ops-line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding-bottom: 16px;
}

.ops-conversation-header h2 {
  font-size: 26px;
}

.ops-conversation-header #ops-agent-dock {
  max-width: 320px;
}

.ops-agent-title {
  align-items: center;
  display: flex;
  gap: 12px;
}

.ops-agent-avatar {
  align-items: center;
  background: #17201f;
  border-radius: 8px;
  color: #ffffff;
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.ops-main-panel {
  overflow: hidden;
  padding: 0 18px 18px;
}

.ops-section {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin-top: 18px;
  padding: 0;
}

.ops-section-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ops-section-header h2 {
  font-size: 18px;
}

.ops-section-header-spaced {
  margin-top: 22px;
}

.ops-side-stack .ops-section-header-spaced:first-child {
  margin-top: 0;
}

.ops-side-stack {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

.ops-agent-card,
.ops-approval-card,
.ops-feed-item,
.ops-automation-card,
.ops-ledger-card {
  background: #f8faf9;
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  padding: 12px;
}

.ops-conversation-header .ops-agent-card {
  background: transparent;
  border: 0;
  min-width: 260px;
  padding: 0;
  text-align: right;
}

.ops-agent-card + .ops-agent-card,
.ops-approval-card + .ops-approval-card,
.ops-feed-item + .ops-feed-item,
.ops-automation-card + .ops-automation-card,
.ops-ledger-card + .ops-ledger-card {
  margin-top: 10px;
}

.ops-agent-card strong,
.ops-automation-card strong,
.ops-ledger-card strong {
  display: block;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.ops-agent-card p,
.ops-approval-card p,
.ops-feed-item p,
.ops-automation-card p,
.ops-chat-message p,
.ops-ledger-card p {
  color: var(--ops-muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.ops-agent-chat {
  background:
    linear-gradient(180deg, rgba(250, 252, 251, 0.92), rgba(244, 247, 246, 0.96)),
    repeating-linear-gradient(0deg, transparent, transparent 31px, rgba(23, 32, 31, 0.025) 32px);
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  min-height: 460px;
  max-height: 610px;
  overflow: auto;
  padding: 22px;
}

.ops-chat-message {
  background: var(--ops-panel);
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  box-shadow: var(--ops-shadow-soft);
  max-width: 68%;
  padding: 14px 15px;
}

.ops-chat-message + .ops-chat-message {
  margin-top: 10px;
}

.ops-chat-message.user {
  background: #173f5f;
  border-color: #173f5f;
  color: #ffffff;
  margin-left: auto;
}

.ops-chat-message.user p,
.ops-chat-message.user span {
  color: rgba(255, 255, 255, 0.78);
}

.ops-chat-message span {
  color: var(--ops-muted);
  display: block;
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.ops-chat-message strong {
  display: block;
  font-size: 15px;
}

.ops-agent-form {
  align-items: stretch;
  background: #f8faf9;
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  display: grid;
  gap: 0;
  grid-template-columns: minmax(0, 1fr) 128px;
  padding: 8px;
}

.ops-agent-form label {
  color: var(--ops-muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  padding: 0;
  text-transform: uppercase;
}

.ops-agent-form textarea {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--ops-ink);
  line-height: 1.4;
  min-height: 72px;
  padding: 8px 10px;
  resize: vertical;
  width: 100%;
}

.ops-agent-form textarea:focus,
.ops-toolbar input:focus,
.ops-toolbar select:focus {
  outline: 2px solid rgba(35, 95, 140, 0.22);
  outline-offset: 1px;
}

.ops-agent-form button {
  background: #17201f;
  border: 1px solid #17201f;
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  font-weight: 750;
  min-height: 72px;
}

.ops-agent-form button:hover {
  background: #24302e;
}

.ops-approval-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

.ops-approval-actions button {
  background: var(--ops-panel);
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  color: var(--ops-ink);
  cursor: pointer;
  font-weight: 750;
  min-height: 34px;
}

.ops-approval-actions button:first-child {
  background: #17201f;
  border-color: #17201f;
  color: #ffffff;
}

.ops-action-log {
  border-top: 1px solid var(--ops-line);
  display: grid;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
}

.ops-change-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 10px;
}

.ops-change-detail {
  background: var(--ops-panel);
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  min-width: 0;
  padding: 9px;
}

.ops-change-detail span {
  color: var(--ops-muted);
  display: block;
  font-size: 11px;
  font-weight: 750;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.ops-change-detail p {
  margin: 0;
  overflow-wrap: anywhere;
}

.ops-action-item {
  background: var(--ops-panel);
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  padding: 9px;
}

.ops-action-item span {
  color: var(--ops-muted);
  display: block;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.ops-action-item strong {
  display: block;
  font-size: 13px;
}

.ops-task-run {
  background: #17201f;
  border: 1px solid #17201f;
  border-radius: 8px;
  color: #ffffff;
  cursor: pointer;
  font-weight: 750;
  margin-top: 10px;
  min-height: 34px;
  padding: 0 12px;
}

.ops-technical-hero {
  align-items: center;
  background: #f8faf9;
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 16px;
}

.ops-technical-hero.blocked,
.ops-technical-hero.attention {
  background: #fbefed;
  border-color: #e5aaa3;
}

.ops-technical-hero.degraded {
  background: #fbf4e6;
  border-color: #dfc38d;
}

.ops-technical-hero.ok {
  background: #edf7f1;
  border-color: #a9d5bd;
}

.ops-technical-hero h2 {
  font-size: 20px;
}

.ops-technical-hero p {
  color: var(--ops-muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 7px 0 0;
  max-width: 780px;
}

.ops-technical-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
}

.ops-technical-grid-wide {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
}

.ops-technical-card {
  background: #f8faf9;
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  min-width: 0;
  padding: 13px;
}

.ops-technical-card h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

.ops-technical-card dl {
  display: grid;
  gap: 7px;
  margin: 0;
}

.ops-technical-card dl div,
.ops-check-row {
  align-items: start;
  border-top: 1px solid rgba(23, 32, 31, 0.08);
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(90px, 0.42fr) minmax(0, 1fr);
  padding-top: 7px;
}

.ops-technical-card dl div:first-child,
.ops-check-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.ops-technical-card dt,
.ops-check-row span {
  color: var(--ops-muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.ops-technical-card dd {
  font-size: 13px;
  margin: 0;
  overflow-wrap: anywhere;
}

.ops-check-list {
  display: grid;
  gap: 8px;
}

.ops-check-row {
  align-items: center;
}

.ops-check-row strong {
  justify-self: start;
}

.ops-audit-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.ops-audit-prompts button {
  background: #ffffff;
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  color: #173f5f;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  min-height: 34px;
  padding: 0 10px;
}

.ops-tabs {
  background: #f8faf9;
  border-bottom: 1px solid var(--ops-line);
  display: flex;
  gap: 2px;
  margin: 0 -18px;
  overflow-x: auto;
  padding: 0 18px;
}

.ops-tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ops-muted);
  cursor: pointer;
  min-height: 50px;
  padding: 0 15px;
  white-space: nowrap;
}

.ops-tab.is-active {
  border-bottom-color: #17201f;
  color: var(--ops-ink);
  font-weight: 750;
}

.ops-toolbar {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 18px 0 0;
}

.ops-toolbar label {
  color: var(--ops-muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 5px;
  min-width: 150px;
  text-transform: uppercase;
}

.ops-search {
  flex: 1 1 260px;
}

.ops-toolbar input,
.ops-toolbar select {
  background: #ffffff;
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  color: var(--ops-ink);
  min-height: 40px;
  padding: 8px 11px;
  width: 100%;
}

.ops-view {
  display: none;
}

.ops-view.is-active {
  display: block;
}

.ops-table-wrap {
  border: 1px solid var(--ops-line);
  border-radius: 8px;
  overflow: auto;
}

.ops-table {
  border-collapse: collapse;
  min-width: 980px;
  width: 100%;
}

.ops-table th,
.ops-table td {
  border-bottom: 1px solid var(--ops-line);
  font-size: 13px;
  padding: 12px;
  text-align: left;
  vertical-align: top;
}

.ops-table th {
  background: #f8faf9;
  color: var(--ops-muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.ops-row-action {
  background: transparent;
  border: 0;
  color: #173f5f;
  cursor: pointer;
  font-weight: 750;
  padding: 0;
  text-align: left;
}

.ops-pill {
  align-items: center;
  border: 1px solid var(--ops-line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 750;
  min-height: 24px;
  padding: 2px 8px;
  white-space: nowrap;
}

.ops-pill.high,
.ops-pill.Erro,
.ops-pill.failed {
  background: #f8e6e3;
  border-color: #e5aaa3;
  color: var(--ops-red);
}

.ops-pill.medium,
.ops-pill.Pendente,
.ops-pill.waiting,
.ops-pill.queued,
.ops-pill.degraded {
  background: #f7edda;
  border-color: #dfc38d;
  color: var(--ops-amber);
}

.ops-pill.low,
.ops-pill.OK,
.ops-pill.ok,
.ops-pill.active,
.ops-pill.delivered,
.ops-pill.done,
.ops-pill.idle {
  background: #e2f1e9;
  border-color: #a9d5bd;
  color: var(--ops-green);
}

.ops-pill.blocked,
.ops-pill.waiting_approval,
.ops-pill.running {
  background: #f8e6e3;
  border-color: #e5aaa3;
  color: var(--ops-red);
}

.ops-pill.monitor {
  background: #e5eef6;
  border-color: #adc7dc;
  color: var(--ops-blue);
}

.ops-pill.automation {
  background: #e9edf7;
  border-color: #b8c3e3;
  color: var(--ops-violet);
}

.ops-pill.informational {
  background: #f1f3ef;
  color: var(--ops-muted);
}

.ops-empty {
  color: var(--ops-muted);
  font-size: 14px;
  padding: 18px;
  text-align: center;
}

.ops-detail {
  background: var(--ops-panel);
  border-left: 1px solid var(--ops-line);
  box-shadow: -18px 0 46px rgba(23, 32, 31, 0.16);
  bottom: 0;
  max-width: 520px;
  overflow: auto;
  padding: 18px;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateX(104%);
  transition: transform 180ms ease;
  width: min(520px, 100vw);
  z-index: 20;
}

.ops-detail.is-open {
  transform: translateX(0);
}

.ops-detail-header {
  align-items: center;
  border-bottom: 1px solid var(--ops-line);
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.ops-detail-grid {
  display: grid;
  gap: 10px;
}

.ops-detail-item {
  border-bottom: 1px solid var(--ops-line);
  padding-bottom: 10px;
}

.ops-detail-item span {
  color: var(--ops-muted);
  display: block;
  font-size: 12px;
  font-weight: 750;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.ops-detail-item strong,
.ops-detail-item code {
  font-size: 13px;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .ops-shell {
    padding: 16px;
  }

  .ops-topbar,
  .ops-agent-workspace,
  .ops-technical-hero {
    display: block;
  }

  .ops-actions {
    margin-top: 12px;
  }

  .ops-summary-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .ops-technical-grid,
  .ops-technical-grid-wide {
    grid-template-columns: 1fr;
  }

  .ops-change-grid {
    grid-template-columns: 1fr;
  }

  .ops-conversation-panel,
  .ops-side-stack {
    margin-bottom: 16px;
  }

  .ops-conversation-header {
    align-items: flex-start;
    display: grid;
  }

  .ops-chat-message {
    max-width: 92%;
  }

  .ops-agent-form {
    grid-template-columns: 1fr;
  }

  .ops-agent-form button {
    min-height: 46px;
  }
}

/* Layout principal */
.ops-body {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 64px);
  overflow: hidden;
}

/* Sidebar de agentes */
.ops-agent-sidebar { padding: 0.5rem; }
.ops-sidebar-title { font-size: 0.75rem; text-transform: uppercase; opacity: 0.6; margin-bottom: 0.5rem; }
.ops-agent-list { list-style: none; margin: 0; padding: 0; }
.ops-agent-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; font-size: 0.875rem; cursor: pointer; }
.ops-agent-item:hover { opacity: 0.8; }

/* Bolinhas de status */
.ops-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #666;
  flex-shrink: 0;
}
.ops-dot.ok { background: #22c55e; }
.ops-dot.error { background: #ef4444; }
.ops-dot.stale { background: #666; }

/* Filtros */
.ops-log-filters { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.ops-log-filters select { padding: 0.25rem 0.5rem; font-size: 0.8rem; border-radius: 4px; }

/* Feed de eventos */
.ops-log-section { display: flex; flex-direction: column; overflow: hidden; }
.ops-log-feed { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; font-family: monospace; font-size: 0.8rem; }
.ops-log-item {
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 0.1s;
}
.ops-log-item:hover { background: rgba(255,255,255,0.05); }
.ops-log-item.error { border-left: 3px solid #ef4444; }
.ops-log-item.warning { border-left: 3px solid #f59e0b; }
.ops-log-summary { display: flex; gap: 0.75rem; align-items: baseline; }
.ops-log-time { opacity: 0.5; font-size: 0.7rem; }
.ops-log-agent { font-weight: bold; min-width: 64px; }
.ops-log-type { opacity: 0.7; }
.ops-log-status-badge { font-size: 0.65rem; padding: 1px 5px; border-radius: 3px; }
.ops-log-status-badge.ok { background: #166534; color: #86efac; }
.ops-log-status-badge.error { background: #7f1d1d; color: #fca5a5; }
.ops-log-status-badge.warning { background: #713f12; color: #fde68a; }
.ops-log-meta { opacity: 0.5; font-size: 0.7rem; margin-top: 0.2rem; }

/* Painel de detalhe */
.ops-detail-panel {
  position: fixed; right: 0; top: 64px; bottom: 0;
  width: 400px; background: #1e1e1e;
  padding: 1rem; overflow-y: auto;
  border-left: 1px solid rgba(255,255,255,0.1);
  z-index: 100;
}
.ops-detail-panel[hidden] { display: none; }
.ops-close-btn { float: right; background: none; border: none; font-size: 1rem; cursor: pointer; opacity: 0.6; }
.ops-detail-pre { white-space: pre-wrap; font-size: 0.75rem; margin-top: 1rem; }
