:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --line: #dce4e2;
  --text: #17211f;
  --muted: #66736f;
  --accent: #0d7c66;
  --accent-2: #3b5bdb;
  --warn: #c77700;
  --danger: #b94141;
  --ink: #121918;
  --shadow: 0 18px 50px rgba(31, 44, 41, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 276px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  background: #121918;
  color: #f6fbfa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark,
.avatar {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-weight: 800;
}

.brand-mark {
  background: #d8f36a;
  color: #121918;
}

.brand span,
.tenant-card span,
.tenant-card small {
  display: block;
  color: rgba(246, 251, 250, 0.62);
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(246, 251, 250, 0.74);
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.icon {
  width: 18px;
  height: 18px;
  border: 1.7px solid currentColor;
  border-radius: 5px;
  opacity: 0.78;
}

.icon-chat {
  border-radius: 8px 8px 8px 3px;
}

.icon-agent {
  border-radius: 50%;
}

.icon-book {
  border-left-width: 5px;
}

.icon-send {
  transform: skew(-8deg);
}

.icon-chart {
  border-top: 0;
  border-right: 0;
}

.icon-team {
  border-radius: 50% 50% 5px 5px;
}

.icon-link {
  border-radius: 9px;
}

.tenant-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-toolbar,
.panel-head,
.agent-card-head,
.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 3.2vw, 42px);
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

h3 {
  margin-bottom: 8px;
  font-size: 17px;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button,
.small-button,
.icon-button,
.tab,
.editor-toolbar button,
.ai-action,
.chat-input button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface);
  color: var(--text);
}

.primary-button,
.chat-input button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.ghost-button:hover,
.small-button:hover,
.tab:hover,
.editor-toolbar button:hover {
  border-color: #b8c8c4;
}

.view {
  display: none;
}

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

.metrics-grid,
.cards-grid,
.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric,
.panel,
.agent-card,
.agent-workspace,
.knowledge-tile,
.placeholder,
.chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span,
.metric small,
.agent-row span,
.agent-meta,
.debug-panel,
.client-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 28px;
}

.positive {
  color: var(--accent);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

.panel-large {
  min-height: 220px;
}

.agent-list,
.queue-list,
.risk-list,
.audit-box,
.debug-panel {
  display: grid;
  gap: 10px;
}

.agent-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.agent-row strong,
.agent-row span {
  display: block;
}

.avatar.sales {
  background: #d8f36a;
  color: #243000;
}

.avatar.support {
  background: #dbe7ff;
  color: #23459d;
}

.avatar.ops {
  background: #ffd8b7;
  color: #813f02;
}

.status {
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.status.active {
  background: #daf3e6;
  color: #0b6b44;
}

.status.paused {
  background: #fff0cf;
  color: #8a5600;
}

.status.draft {
  background: #e9edf2;
  color: #4d5965;
}

.queue-list span,
.audit-box span {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 14px;
}

.pipeline span {
  border-radius: 999px;
  padding: 8px 11px;
  background: var(--surface-2);
  color: #354641;
  font-size: 13px;
  font-weight: 700;
}

.risk-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.section-toolbar {
  margin-bottom: 16px;
}

.cards-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.agent-card {
  padding: 18px;
}

.agent-card.selected {
  outline: 2px solid rgba(13, 124, 102, 0.24);
}

.agent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agent-meta span {
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
}

.agent-workspace {
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.tab {
  flex: 0 0 auto;
  background: transparent;
}

.tab.is-active {
  border-color: var(--accent);
  background: #e3f5ef;
  color: var(--accent);
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 0;
}

.prompt-editor {
  min-width: 0;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.editor-body {
  min-height: 360px;
  padding: 22px;
  outline: none;
  line-height: 1.6;
}

.editor-body h3 {
  margin-top: 18px;
  color: #24312e;
  font-size: 14px;
}

.context-panel {
  border-left: 1px solid var(--line);
  padding: 18px;
  background: #fbfcfc;
}

.ai-action {
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
}

.audit-box {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.knowledge-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.knowledge-tile {
  padding: 18px;
}

.knowledge-tile strong,
.knowledge-tile span {
  display: block;
}

.progress {
  height: 8px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6ecea;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.inbox-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 260px;
  min-height: 640px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.dialog-list,
.client-card {
  padding: 14px;
  background: #fbfcfc;
}

.dialog-list {
  border-right: 1px solid var(--line);
}

.dialog {
  display: grid;
  width: 100%;
  gap: 4px;
  margin-bottom: 8px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
}

.dialog.is-active,
.dialog:hover {
  border-color: var(--line);
  background: var(--surface);
}

.dialog span {
  color: var(--muted);
}

.conversation-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
}

.message {
  max-width: 74%;
  border-radius: 8px;
  padding: 11px 13px;
  line-height: 1.45;
}

.incoming {
  align-self: flex-start;
  background: #eef3f1;
}

.outgoing {
  align-self: flex-end;
  background: #dff4ed;
}

.operator {
  align-self: flex-end;
  background: #dbe7ff;
}

.handoff-note {
  align-self: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: #fff0cf;
  color: #8a5600;
  font-size: 13px;
}

.client-card {
  display: grid;
  align-content: start;
  gap: 12px;
  border-left: 1px solid var(--line);
}

.chart-panel {
  display: flex;
  align-items: end;
  gap: 14px;
  height: 420px;
  padding: 28px;
}

.bar {
  flex: 1;
  min-width: 34px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #3b5bdb, #0d7c66);
}

.placeholder {
  padding: 38px;
}

.test-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  width: min(440px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(31, 44, 41, 0.12);
  transform: translateX(100%);
  transition: transform 180ms ease;
}

.test-drawer.is-open {
  transform: translateX(0);
}

.drawer-head {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.drawer-head span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 22px;
}

.drawer-chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  overflow: auto;
}

.debug-panel {
  margin: 0 18px 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.chat-input {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 18px;
  border-top: 1px solid var(--line);
}

.chat-input input {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
}

@media (max-width: 1100px) {
  .metrics-grid,
  .knowledge-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .editor-layout,
  .inbox-layout {
    grid-template-columns: 1fr;
  }

  .context-panel,
  .client-card,
  .dialog-list {
    border: 0;
  }
}

@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    padding: 18px;
  }

  .topbar,
  .section-toolbar {
    display: grid;
  }

  .metrics-grid,
  .cards-grid,
  .knowledge-grid {
    grid-template-columns: 1fr;
  }

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