:root {
  --canvas: #f5f6f3;
  --surface: #ffffff;
  --panel: #ecefeb;
  --ink: #111814;
  --muted: #66716a;
  --line: #d8ddd7;
  --teal: #0f766e;
  --teal-dark: #075e58;
  --amber: #b9812d;
  --amber-soft: #fff3df;
  --red: #b45353;
  --red-soft: #fff0f0;
  --blue: #315f9f;
  --blue-soft: #edf4ff;
  --shadow: 0 18px 48px rgba(17, 24, 20, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px;
  align-items: center;
  min-height: 72px;
  padding: 14px clamp(16px, 4vw, 44px);
  border-bottom: 1px solid rgba(216, 221, 215, 0.9);
  background: rgba(245, 246, 243, 0.94);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-mark,
.agent-avatar {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 850;
  letter-spacing: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  font-size: 13px;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand strong {
  font-size: 18px;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.topnav {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.topnav a,
.status-button,
.text-button {
  min-height: 38px;
  border-radius: 8px;
  font-weight: 800;
}

.topnav a {
  padding: 9px 12px;
  color: var(--muted);
  font-size: 14px;
}

.topnav a:hover,
.topnav a:focus-visible {
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal-dark);
  outline: none;
}

.status-button,
.text-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  white-space: nowrap;
}

.status-button {
  padding: 9px 12px;
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--amber);
}

.status-button.is-live .status-dot {
  background: var(--teal);
}

.status-button.is-error .status-dot {
  background: var(--red);
}

.text-button {
  padding: 8px 12px;
  font-size: 13px;
}

main {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 26px 0 56px;
}

.command-strip,
.metric-band,
.orchestrator-band,
.workspace,
.agents-band,
.method-band {
  margin-bottom: 18px;
}

.command-strip {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(160px, 220px) minmax(150px, 190px) minmax(180px, 260px);
  gap: 12px;
  align-items: stretch;
}

.command-title,
.control,
.data-stamp,
.metric-band > div,
.panel,
.agents-band,
.method-band {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.command-title {
  padding: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(34px, 4.4vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 2.8vw, 34px);
  line-height: 1.08;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 12px;
  font-size: 16px;
}

.control,
.data-stamp {
  display: grid;
  gap: 8px;
  align-content: center;
  padding: 18px;
}

.control span,
.data-stamp span,
.metric-band span,
.brief-stat span,
dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 750;
}

.data-stamp strong {
  font-size: 14px;
  line-height: 1.25;
}

.metric-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.metric-band > div {
  min-width: 0;
  padding: 18px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.metric-band strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.orchestrator-band {
  box-shadow: none;
}

.orchestrator-band .panel {
  background: linear-gradient(180deg, #ffffff 0%, #f9fbf8 100%);
}

.orchestrator-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 16px;
  align-items: start;
}

.master-identity {
  min-height: 142px;
}

.master-identity .agent-avatar {
  background: var(--ink);
}

.master-stats {
  margin: 0;
}

.x-queue {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.queue-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.queue-item {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.queue-item strong,
.queue-item span {
  display: block;
}

.queue-item > div > span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.protocols-workspace {
  grid-template-columns: minmax(320px, 0.72fr) minmax(0, 1.28fr);
}

.panel,
.agents-band,
.method-band {
  padding: 22px;
}

.section-head {
  display: flex;
  gap: 18px;
  align-items: start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-head p {
  max-width: 460px;
  margin-bottom: 0;
  color: var(--muted);
}

.section-head.compact {
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

tr.is-selected td {
  background: var(--amber-soft);
}

.chain-button,
.protocol-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.chain-button strong,
.protocol-button strong {
  display: block;
  font-size: 15px;
}

.chain-button span,
.protocol-button span {
  color: var(--muted);
  font-size: 12px;
}

.risk-pill,
.source-pill,
.confidence {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 850;
}

.risk-low {
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal-dark);
}

.risk-medium {
  background: var(--amber-soft);
  color: #8a5a10;
}

.risk-high {
  background: var(--red-soft);
  color: var(--red);
}

.agent-identity {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px;
  background: var(--panel);
  border-radius: 8px;
}

.agent-avatar {
  width: 64px;
  height: 64px;
  font-size: 18px;
}

.agent-identity p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.agent-stats {
  display: grid;
  gap: 1px;
  overflow: hidden;
  margin: 16px 0 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.agent-stats div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 13px;
  background: var(--surface);
}

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

.protocol-list {
  display: grid;
  gap: 10px;
}

.protocol-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.protocol-row.is-selected {
  border-color: rgba(185, 129, 45, 0.75);
  background: var(--amber-soft);
}

.protocol-button {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 70px;
  padding: 12px;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.brief-stat {
  min-width: 0;
  padding: 16px;
  border-radius: 8px;
  background: var(--panel);
}

.brief-stat strong {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brief-copy,
.risk-stack,
.evidence-ledger {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.brief-copy p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.risk-stack ul,
.method-steps {
  margin: 0;
  padding-left: 20px;
}

.risk-stack li,
.method-steps li {
  margin-bottom: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.evidence-ledger table {
  min-width: 620px;
}

.source-pill {
  background: var(--blue-soft);
  color: var(--blue);
}

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

.agent-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.agent-card.is-assigned {
  background: var(--amber-soft);
}

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

.agent-card strong {
  margin-top: 12px;
  font-size: 16px;
}

.agent-card span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.method-band {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 1fr);
  gap: 28px;
  align-items: start;
}

.method-band p {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

@media (max-width: 1040px) {
  .topbar,
  .command-strip,
  .workspace,
  .protocols-workspace,
  .orchestrator-grid,
  .method-band {
    grid-template-columns: 1fr;
  }

  .topnav {
    justify-content: start;
    overflow-x: auto;
  }

  .metric-band,
  .queue-list,
  .agents-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar {
    gap: 12px;
  }

  .topnav {
    order: 3;
    grid-column: 1 / -1;
  }

  .status-button {
    justify-self: end;
    max-width: 170px;
  }

  .metric-band,
  .brief-grid,
  .queue-list,
  .agents-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 38px;
  }

  .section-head {
    display: grid;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  table,
  .evidence-ledger table {
    min-width: 0;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  tbody {
    display: grid;
    gap: 8px;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
  }

  tr.is-selected td {
    background: transparent;
  }

  tr.is-selected {
    background: var(--amber-soft);
  }

  td {
    display: grid;
    grid-template-columns: minmax(88px, 0.44fr) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 9px 10px;
    border-bottom: 0;
    font-size: 13px;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .chain-button {
    padding: 0;
  }
}
