:root {
  color-scheme: dark;
  --bg: #08090f;
  --panel: #14141e;
  --panel-2: #191827;
  --line: #2a2b3b;
  --line-soft: #232434;
  --text: #f4f1ff;
  --muted: #9695bd;
  --purple: #7861f2;
  --purple-2: #2d254f;
  --green: #00c487;
  --amber: #ffb020;
  --red: #ff6370;
  --cyan: #30c7d8;
  --card-radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  border-right: 1px solid var(--line);
  background: #13131d;
  padding: 28px 12px;
}

.brand-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 0 10px 30px;
}

.brand {
  color: #7284ff;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: 0;
}

.workspace-select,
.nav-item,
.secondary-button,
.primary-button,
.small-button,
.icon-button,
.send-button {
  border: 1px solid var(--line);
  color: var(--text);
}

.workspace-select {
  align-items: center;
  background: #0d0d15;
  border-radius: var(--card-radius);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 18px;
  min-height: 54px;
  padding: 0 16px;
  width: 100%;
}

.workspace-icon {
  background: var(--purple-2);
  border-radius: 6px;
  color: var(--purple);
  display: grid;
  height: 30px;
  place-items: center;
  width: 30px;
}

.chevron {
  color: var(--muted);
  margin-left: auto;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  align-items: center;
  background: transparent;
  border-color: transparent;
  border-radius: var(--card-radius);
  color: var(--muted);
  display: flex;
  font-size: 18px;
  gap: 14px;
  min-height: 45px;
  padding: 0 14px;
  text-align: left;
}

.nav-item span {
  color: #a2a0c4;
  width: 22px;
}

.nav-item b {
  background: var(--amber);
  border-radius: 999px;
  color: white;
  font-size: 12px;
  margin-left: auto;
  padding: 2px 7px;
}

.nav-item.active,
.nav-item:hover {
  background: #2b244d;
  color: white;
}

.main {
  padding: 46px 54px 64px;
}

.page-header,
.detail-header,
.panel-header,
.modal-header,
.header-actions,
.filters {
  align-items: center;
  display: flex;
}

.page-header,
.detail-header {
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 36px;
  line-height: 1.05;
}

h2 {
  color: #b9b6dd;
  font-size: 14px;
  letter-spacing: 0;
  text-transform: uppercase;
}

p {
  color: var(--muted);
}

.header-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.secondary-button,
.primary-button,
.small-button {
  border-radius: var(--card-radius);
  min-height: 46px;
  padding: 0 16px;
}

.secondary-button {
  background: #0b0c13;
}

.primary-button {
  background: var(--purple);
  border-color: var(--purple);
  font-weight: 700;
}

.small-button {
  background: #201a38;
  border-color: #3a315f;
  color: #d9d3ff;
  min-height: 32px;
  padding: 0 10px;
}

.icon-button,
.send-button {
  align-items: center;
  background: #201a38;
  border-radius: var(--card-radius);
  display: inline-grid;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.filters {
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-field {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  display: flex;
  gap: 10px;
  min-height: 44px;
  min-width: min(100%, 340px);
  padding: 0 14px;
}

.search-field input,
.filters select,
.modal input,
.modal select,
.modal textarea,
.composer input {
  background: transparent;
  border: 0;
  color: var(--text);
  outline: 0;
  width: 100%;
}

.filters select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  min-height: 44px;
  padding: 0 12px;
  width: 176px;
}

.agent-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
}

.agent-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  min-height: 220px;
  padding: 26px;
  text-align: left;
  transition: border-color 150ms ease, transform 150ms ease;
}

.agent-card:hover {
  border-color: #534d80;
  transform: translateY(-1px);
}

.agent-card-top,
.agent-meta,
.detail-title {
  align-items: center;
  display: flex;
}

.agent-card-top {
  justify-content: space-between;
  margin-bottom: 18px;
}

.agent-identity {
  align-items: center;
  display: grid;
  gap: 2px;
  grid-template-columns: 42px 1fr;
}

.avatar {
  background:
    radial-gradient(circle at 32% 24%, #ffd1b2 0 18%, transparent 19%),
    radial-gradient(circle at 58% 22%, #84f0d8 0 16%, transparent 17%),
    linear-gradient(135deg, #5840d8, #00a7a7 55%, #33213a);
  border-radius: 999px;
  height: 42px;
  width: 42px;
}

.avatar.large {
  height: 58px;
  width: 58px;
}

.agent-name {
  font-size: 21px;
  font-weight: 800;
}

.agent-role,
.agent-description {
  color: var(--muted);
}

.agent-description {
  font-size: 17px;
  line-height: 1.35;
  min-height: 68px;
}

.status-pill,
.risk-pill,
.provider-pill,
.tag {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 7px 10px;
  text-transform: uppercase;
}

.status-pill.active,
.risk-pill.low {
  background: #063d31;
  color: var(--green);
}

.status-pill.paused,
.risk-pill.medium {
  background: #45330a;
  color: var(--amber);
}

.status-pill.training,
.risk-pill.high {
  background: #4a1c25;
  color: var(--red);
}

.provider-pill,
.tag {
  background: #24203e;
  color: #9e92e9;
}

.agent-meta {
  color: var(--muted);
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

.hidden {
  display: none;
}

.detail-title {
  gap: 14px;
  margin-right: auto;
}

.detail-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.55fr);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: 16px;
}

.panel-header {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.chat-panel,
.tools-panel,
.skills-panel {
  grid-column: 1 / -1;
}

.chat-log {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 14px;
  max-height: 270px;
  min-height: 250px;
  overflow: auto;
  padding: 8px 0 14px;
}

.message {
  background: #10111a;
  border: 1px solid var(--line-soft);
  border-radius: var(--card-radius);
  color: #d9d6ef;
  line-height: 1.45;
  max-width: 760px;
  padding: 12px 14px;
}

.message.user {
  background: var(--purple);
  justify-self: end;
}

.message small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
}

.composer {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 38px 1fr 42px;
  padding-top: 12px;
}

.composer input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  min-height: 40px;
  padding: 0 12px;
}

dl {
  display: grid;
  gap: 0;
  margin: 14px 0 0;
}

.row {
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 31px;
  gap: 14px;
}

dt {
  color: var(--muted);
}

dd {
  font-weight: 700;
  margin: 0;
  text-align: right;
}

.badge-list,
.rule-list,
.skill-list,
.tool-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.rule {
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  color: #d7d3f5;
  padding: 8px 10px;
}

.tool-group,
.skill-card {
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  padding: 14px;
}

.tool-group {
  width: 100%;
}

.tool-group h3,
.skill-card h3 {
  font-size: 15px;
  margin: 0 0 10px;
}

.tool-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-chip {
  background: #0f1018;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #dcd9f7;
  font-size: 12px;
  padding: 7px 9px;
}

.skill-card {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  width: 100%;
}

.skill-card p {
  font-size: 13px;
  margin-top: 2px;
}

.modal {
  background: transparent;
  border: 0;
  color: var(--text);
  max-width: min(720px, calc(100vw - 28px));
  width: 720px;
}

.modal::backdrop {
  background: rgb(0 0 0 / 72%);
}

.modal-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  display: grid;
  gap: 16px;
  padding: 22px;
}

.modal-header {
  justify-content: space-between;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal label {
  color: var(--muted);
  display: grid;
  gap: 7px;
  font-size: 13px;
}

.modal input,
.modal select,
.modal textarea {
  background: #10111a;
  border: 1px solid var(--line);
  border-radius: var(--card-radius);
  min-height: 42px;
  padding: 10px 12px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.approval-note {
  background: #231b35;
  border: 1px solid #453568;
  border-radius: var(--card-radius);
  color: #d9d3ff;
  padding: 12px;
}

@media (max-width: 1180px) {
  .agent-grid,
  .detail-layout {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }

  .chat-panel,
  .tools-panel,
  .skills-panel {
    grid-column: 1 / -1;
  }
}

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

  .sidebar {
    position: static;
  }

  .main {
    padding: 24px 16px 42px;
  }

  .page-header,
  .detail-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-grid,
  .detail-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
  }

  .filters select,
  .search-field {
    width: 100%;
  }
}
