:root {
  --bg: #f6f4ef;
  --paper: #ffffff;
  --paper-soft: #f5f5f4;
  --ink: #101010;
  --copy: #4b4b4b;
  --muted: #737373;
  --line: #dfdfdf;
  --line-strong: #191919;
  --accent: #ff565c;
  --accent-strong: #ff3d47;
  --dark: #0a0a0a;
  --dark-soft: #111111;
  --dark-copy: #bebebe;
  --dark-line: #262626;
  --ok: #0f766e;
  --warn: #b45309;
  --review: #5b5bd6;
  --max: 1480px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Montserrat", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 0 24px;
  border-bottom: 1px solid var(--dark-line);
  background: var(--dark);
  color: #ffffff;
}

.brand-lockup,
.topbar-actions,
.topbar-meta,
.live-indicator,
.language-switcher,
.scenario-controls,
.icon-controls,
.speed-control {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: block;
  width: 28px;
  height: 46px;
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-name {
  font-size: 1rem;
  font-weight: 800;
}

.topbar-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 18px;
  min-width: 0;
}

.topbar-meta {
  justify-content: flex-end;
  gap: 18px;
  min-width: 0;
  color: var(--dark-copy);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.live-indicator {
  gap: 8px;
  color: #ffffff;
}

.topbar-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--dark);
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.language-switcher {
  border: 1px solid var(--dark-line);
}

.language-switcher button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  min-width: 44px;
  border: 0;
  border-left: 1px solid var(--dark-line);
  background: var(--dark-soft);
  color: var(--dark-copy);
  font-size: 0.78rem;
  font-weight: 800;
}

.language-switcher button:first-child {
  border-left: 0;
}

.language-switcher button.active {
  background: #ffffff;
  color: var(--dark);
}

.language-switcher button:hover {
  color: #ffffff;
}

.language-switcher button.active:hover {
  color: var(--dark);
}

.topbar-cta:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.signal-dot,
.status-marker {
  display: inline-block;
  width: 9px;
  height: 9px;
  background: var(--accent);
}

.signal-dot {
  animation: pulse 1.2s steps(2, end) infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.dashboard {
  width: min(var(--max), calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
  gap: 24px;
  align-items: end;
  padding: 26px 0;
  border-bottom: 1px solid var(--line-strong);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  font-size: 3.3rem;
  line-height: 1;
  font-weight: 900;
}

h2 {
  font-size: 1.25rem;
  line-height: 1.1;
  font-weight: 800;
}

h3 {
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 800;
}

.scenario-controls {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.view-tabs {
  display: inline-flex;
  border: 1px solid var(--dark-line);
  background: var(--dark-line);
  gap: 1px;
}

.view-tabs button {
  min-height: 42px;
  min-width: 124px;
  border: 0;
  border-radius: 0;
  background: var(--dark-soft);
  color: var(--dark-copy);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.view-tabs button:hover,
.view-tabs button.active {
  background: var(--accent);
  color: var(--dark);
}

.dashboard-view {
  display: none;
}

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

.field {
  display: grid;
  gap: 6px;
  min-width: 210px;
}

.field span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

select,
.icon-button,
.speed-control button {
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
}

select {
  width: 100%;
  padding: 0 34px 0 12px;
  font-size: 0.88rem;
  font-weight: 700;
}

.icon-controls {
  gap: 8px;
  align-self: end;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  padding: 0;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.icon-button:hover,
.speed-control button:hover,
select:focus {
  border-color: var(--accent);
  outline: 0;
}

.speed-control {
  align-self: end;
  border: 1px solid var(--line-strong);
}

.speed-control button {
  min-width: 50px;
  border: 0;
  border-left: 1px solid var(--line-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.speed-control button:first-child {
  border-left: 0;
}

.speed-control button.active {
  background: var(--accent);
  color: var(--dark);
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 18px 0;
  border: 1px solid var(--line-strong);
  background: var(--line-strong);
  gap: 1px;
}

.metric {
  min-height: 102px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  background: var(--paper);
}

.metric span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  color: var(--ink);
  font-size: 2rem;
  line-height: 1;
  font-weight: 900;
}

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

.agent-card,
.panel {
  border: 1px solid var(--line-strong);
  background: var(--paper);
}

.agent-card {
  display: grid;
  min-height: 230px;
  grid-template-rows: auto 1fr auto;
  padding: 16px;
  transition:
    border-color 160ms ease,
    opacity 160ms ease;
}

.agent-card.focused {
  border-color: var(--accent);
  box-shadow: inset 4px 0 0 var(--accent);
}

.agent-card.dimmed {
  opacity: 0.46;
}

.agent-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.agent-name {
  display: block;
  font-size: 1.26rem;
  line-height: 1;
  font-weight: 900;
}

.agent-role {
  display: block;
  margin-top: 5px;
  color: var(--copy);
  font-size: 0.82rem;
  font-weight: 700;
}

.agent-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 96px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-marker.idle {
  background: var(--muted);
}

.status-marker.working {
  background: var(--accent);
}

.status-marker.reviewing {
  background: var(--review);
}

.status-marker.blocked {
  background: var(--warn);
}

.agent-work {
  align-self: center;
  min-height: 70px;
  display: grid;
  gap: 6px;
  align-content: center;
  color: var(--copy);
  font-size: 0.88rem;
}

.agent-work strong {
  color: var(--ink);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.agent-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.agent-stat {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px;
  background: var(--paper-soft);
}

.agent-stat span {
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
}

.agent-stat strong {
  font-size: 1.05rem;
  line-height: 1;
  font-weight: 900;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.collaboration-panel {
  margin-bottom: 18px;
}

.collaboration-head {
  min-height: 78px;
}

.collaboration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.collaboration-example {
  min-width: 0;
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--paper);
}

.scenario-tag {
  justify-self: start;
  border: 1px solid var(--line-strong);
  padding: 7px 9px;
  background: var(--paper-soft);
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.collaboration-flow {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) 34px minmax(0, 1.15fr);
  gap: 0;
  align-items: center;
}

.collab-stack {
  display: grid;
  gap: 10px;
}

.collab-node {
  min-width: 0;
  min-height: 88px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
}

.collab-node.primary-node {
  border-color: var(--accent);
  background: #fff7f7;
}

.collab-node strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  line-height: 1.2;
  font-weight: 900;
}

.collab-node span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--copy);
  font-size: 0.76rem;
  line-height: 1.45;
  font-weight: 600;
}

.collab-link {
  position: relative;
  min-height: 88px;
}

.collab-link::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 5px;
  right: 5px;
  height: 2px;
  background: var(--line-strong);
}

.collab-link::after {
  content: "";
  position: absolute;
  top: calc(50% - 7px);
  right: 2px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 9px solid var(--line-strong);
}

.panel {
  min-width: 0;
}

.panel-head {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-soft);
}

.panel-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
}

.compact-field {
  min-width: 170px;
}

.compact-field select {
  min-height: 38px;
  font-size: 0.8rem;
}

.clock,
.state-badge {
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.state-badge.active {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.state-badge.review {
  border-color: var(--review);
  color: var(--review);
}

.state-badge.resolved {
  border-color: var(--ok);
  color: var(--ok);
}

.state-badge.escalated {
  border-color: var(--warn);
  color: var(--warn);
}

.activity-feed {
  height: 620px;
  overflow: auto;
  background: var(--paper);
}

.activity-empty,
.detail-empty {
  padding: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.activity-row {
  width: 100%;
  display: grid;
  grid-template-columns: 86px minmax(120px, 170px) minmax(0, 1fr) 96px;
  gap: 14px;
  align-items: start;
  padding: 14px 16px 14px 12px;
  border: 0;
  border-left: 4px solid transparent;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  color: inherit;
  text-align: left;
}

.activity-row:hover,
.activity-row.selected {
  background: #fff7f7;
}

.activity-row.selected {
  border-left-color: var(--accent);
}

.event-time,
.event-agent,
.event-status,
.event-kind {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.event-time,
.event-kind {
  color: var(--muted);
}

.event-agent {
  color: var(--ink);
}

.event-main {
  min-width: 0;
}

.event-title {
  display: block;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.event-detail {
  margin-top: 4px;
  color: var(--copy);
  font-size: 0.82rem;
  line-height: 1.45;
}

.event-status {
  justify-self: end;
  color: var(--muted);
}

.event-status.success {
  color: var(--ok);
}

.event-status.warning {
  color: var(--warn);
}

.event-status.review {
  color: var(--review);
}

.event-status.escalated {
  color: var(--accent-strong);
}

.detail-body {
  min-height: 620px;
  padding: 16px;
}

.detail-summary {
  display: grid;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.detail-summary h3 {
  font-size: 1.45rem;
  line-height: 1.15;
}

.detail-copy {
  color: var(--copy);
  font-size: 0.9rem;
  line-height: 1.65;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin-top: 14px;
  border: 1px solid var(--line);
  background: var(--line);
}

.detail-kv {
  min-height: 70px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 10px;
  background: var(--paper-soft);
}

.detail-kv span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-kv strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
}

.log-sections {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.log-section {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
}

.log-section span,
.timeline-heading {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.log-section p,
.log-section li {
  color: var(--copy);
  font-size: 0.82rem;
  line-height: 1.55;
}

.log-section ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.timeline-heading {
  margin-top: 18px;
}

.timeline {
  display: grid;
  gap: 0;
  margin-top: 16px;
  border-top: 1px solid var(--line);
}

.timeline-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.timeline-time {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.timeline-title {
  font-size: 0.86rem;
  font-weight: 800;
}

.timeline-detail {
  margin-top: 4px;
  color: var(--copy);
  font-size: 0.8rem;
  line-height: 1.45;
}

.health-view.active {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.topology-panel {
  overflow: hidden;
}

.topology-head h2 {
  max-width: 760px;
}

.topology-grid {
  display: grid;
  grid-template-columns:
    minmax(0, 1.05fr) 28px minmax(0, 1.18fr) 28px minmax(0, 1.12fr)
    28px minmax(0, 1.08fr) 28px minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
  padding: 16px;
}

.topology-column {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.topology-column-title {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.topology-node {
  min-height: 94px;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--paper-soft);
}

.topology-node strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.88rem;
  line-height: 1.2;
  font-weight: 900;
}

.topology-node span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--copy);
  font-size: 0.76rem;
  line-height: 1.45;
  font-weight: 600;
}

.topology-core .topology-node,
.topology-box .topology-node {
  border-color: var(--line-strong);
  background: #ffffff;
}

.topology-node.accent-node {
  border-color: var(--accent);
  background: #fff7f7;
}

.topology-node.hardware-node {
  background: var(--dark);
  color: #ffffff;
}

.topology-node.hardware-node strong {
  color: #ffffff;
}

.topology-node.hardware-node span {
  color: var(--dark-copy);
}

.topology-flow {
  position: relative;
}

.topology-flow::before {
  content: "";
  position: absolute;
  top: 94px;
  left: 4px;
  right: 4px;
  height: 2px;
  background: var(--line-strong);
}

.topology-flow::after {
  content: "";
  position: absolute;
  top: 88px;
  right: 2px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 9px solid var(--line-strong);
}

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

.health-tile {
  min-height: 250px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
}

.health-status {
  justify-self: start;
  border: 1px solid var(--line-strong);
  padding: 7px 9px;
  background: var(--paper-soft);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.health-status.ok {
  border-color: var(--ok);
  color: var(--ok);
}

.health-tile ul {
  display: grid;
  gap: 8px;
  align-content: start;
  margin: 0;
  padding: 0;
  list-style: none;
}

.health-tile li {
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  color: var(--copy);
  font-size: 0.82rem;
  font-weight: 650;
}

.health-tile li:last-child {
  border-bottom: 0;
}

@media (max-width: 1180px) {
  h1 {
    font-size: 2.6rem;
  }

  .hero-band,
  .workbench {
    grid-template-columns: 1fr;
  }

  .scenario-controls {
    justify-content: flex-start;
  }

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

  .collaboration-grid {
    grid-template-columns: 1fr;
  }

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

  .topology-flow {
    display: none;
  }

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

@media (max-width: 760px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .topbar-meta {
    width: 100%;
    justify-content: space-between;
    gap: 12px;
  }

  .topbar-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-cta {
    width: 100%;
  }

  .language-switcher {
    width: 100%;
  }

  .language-switcher button {
    flex: 1;
  }

  .dashboard {
    width: min(var(--max), calc(100vw - 20px));
    padding-top: 12px;
  }

  .hero-band {
    padding-top: 18px;
  }

  h1 {
    font-size: 2rem;
  }

  .scenario-controls,
  .field {
    width: 100%;
  }

  .icon-controls,
  .speed-control {
    width: 100%;
  }

  .icon-button,
  .speed-control button {
    flex: 1;
  }

  .view-tabs {
    width: 100%;
  }

  .view-tabs button {
    min-width: 0;
    flex: 1;
  }

  .metrics-strip,
  .agent-grid,
  .detail-grid,
  .topology-grid,
  .health-grid {
    grid-template-columns: 1fr;
  }

  .topology-grid {
    gap: 12px;
    padding: 12px;
  }

  .metric {
    min-height: 76px;
  }

  .agent-card {
    min-height: 210px;
  }

  .activity-feed,
  .detail-body {
    height: auto;
    min-height: 360px;
  }

  .activity-row {
    grid-template-columns: 70px minmax(0, 1fr);
    gap: 8px 12px;
  }

  .event-status {
    justify-self: start;
  }

  .event-main {
    grid-column: 1 / -1;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-actions,
  .compact-field {
    width: 100%;
  }

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

  .collaboration-flow {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .collab-link {
    display: none;
  }
}
