:root {
  --bg: #141416;
  --panel: #1d1f22;
  --panel-soft: #24272b;
  --panel-strong: #2d3136;
  --text: #f2f4f5;
  --muted: #9aa2aa;
  --line: rgba(255, 255, 255, 0.11);
  --blue: #5fb3ff;
  --green: #75d9b3;
  --amber: #f2c15b;
  --red: #ff7474;
  --ink: #080a0c;
}

* {
  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", Arial, sans-serif;
  letter-spacing: 0;
}

button,
textarea,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: #181a1d;
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

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

h1 {
  font-size: 24px;
  line-height: 1.1;
}

h2 {
  font-size: 14px;
  line-height: 1.2;
}

h3 {
  font-size: 15px;
  line-height: 1.25;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 5px 9px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}

.connection span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--amber);
}

.connection.ok span {
  background: var(--green);
}

.connection.bad span {
  background: var(--red);
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 330px;
  gap: 12px;
  padding: 12px;
}

.panel,
.composer,
.filters,
.task-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

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

.agent-stack,
.workbench,
.side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.agent-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 10px;
  color: var(--text);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  cursor: pointer;
}

.agent-card.active {
  border-color: var(--agent-accent);
  background: #202429;
}

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  background: #30343a;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 -10px 20px rgba(0, 0, 0, 0.22);
}

.avatar::before,
.avatar::after {
  content: "";
  position: absolute;
}

.avatar.boris {
  background:
    radial-gradient(circle at 50% 38%, #f1c18d 0 18%, transparent 19%),
    radial-gradient(circle at 48% 24%, #2d211b 0 21%, transparent 22%),
    linear-gradient(160deg, #a7ddf0, #283747 74%);
}

.avatar.boris::before {
  left: 18px;
  top: 25px;
  width: 23px;
  height: 22px;
  border-radius: 8px 8px 3px 3px;
  background: #edf3f7;
  box-shadow: inset 0 8px 0 #2f536b;
}

.avatar.boris::after {
  left: 23px;
  top: 22px;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #1e2930;
  box-shadow: 12px 0 0 #1e2930, 6px 9px 0 #b86f69;
}

.avatar.alina {
  background:
    radial-gradient(circle at 50% 37%, #f0c7a3 0 18%, transparent 19%),
    radial-gradient(circle at 49% 27%, #5b3d2c 0 26%, transparent 27%),
    linear-gradient(160deg, #c3b8ff, #2b3342 72%);
}

.avatar.alina::before {
  left: 16px;
  top: 26px;
  width: 26px;
  height: 22px;
  border-radius: 10px 10px 4px 4px;
  background: #f8f2e8;
  box-shadow: inset 0 8px 0 #9fadc2;
}

.avatar.alina::after {
  left: 23px;
  top: 22px;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #1d2228;
  box-shadow: 12px 0 0 #1d2228, 6px 9px 0 #c06a7c;
}

.agent-meta {
  min-width: 0;
}

.agent-role {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  margin-top: 4px;
}

.agent-summary {
  color: #c8ced3;
  font-size: 12px;
  line-height: 1.35;
  margin-top: 8px;
}

.composer {
  padding: 12px;
}

.agent-switch,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.agent-switch {
  margin-bottom: 10px;
}

.switch-btn,
.chip,
.icon-btn,
.primary-btn {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--text);
  cursor: pointer;
}

.switch-btn,
.chip {
  padding: 7px 10px;
  font-size: 13px;
}

.switch-btn.active,
.chip.active {
  color: var(--ink);
  background: var(--green);
  border-color: var(--green);
  font-weight: 750;
}

textarea {
  display: block;
  width: 100%;
  resize: vertical;
  min-height: 104px;
  padding: 11px 12px;
  color: var(--text);
  background: #111315;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea:focus,
select:focus {
  border-color: var(--blue);
}

.composer-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.primary-btn {
  padding: 8px 13px;
  background: var(--blue);
  border-color: var(--blue);
  color: var(--ink);
  font-weight: 800;
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.icon-btn {
  width: 34px;
  min-height: 34px;
  font-size: 12px;
  font-weight: 800;
}

.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

select {
  min-height: 36px;
  color: var(--text);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
}

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

.task-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 11px;
  cursor: pointer;
}

.task-card.active {
  border-color: var(--blue);
}

.task-title {
  font-weight: 750;
  line-height: 1.25;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 6px;
  color: var(--ink);
  background: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.status.completed {
  background: var(--green);
}

.status.failed,
.status.cancelled {
  background: var(--red);
}

.status.running,
.status.accepted {
  background: var(--blue);
}

.detail-panel {
  min-height: 230px;
}

.empty-state {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

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

.detail-block {
  padding: 10px;
  background: #151719;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.45;
}

.event-list {
  display: grid;
  gap: 7px;
}

.event {
  display: grid;
  gap: 3px;
  padding-left: 10px;
  border-left: 2px solid var(--line);
  color: #d4d9dd;
  font-size: 12px;
}

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

.metric,
.limit-line {
  padding: 9px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-label,
.limit-label {
  color: var(--muted);
  font-size: 11px;
}

.metric-value,
.limit-value {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.limits {
  display: grid;
  gap: 8px;
}

.toast {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px;
  color: var(--text);
  background: #262b31;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

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

  .agents-panel {
    order: 1;
  }

  .workbench {
    order: 2;
  }

  .side {
    order: 3;
  }

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

@media (max-width: 560px) {
  .topbar {
    padding: 12px;
  }

  h1 {
    font-size: 21px;
  }

  .layout {
    padding: 8px;
    gap: 8px;
  }

  .agent-stack,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  select {
    width: 100%;
  }
}
