:root {
  --bg: #eef3f1;
  --surface: #ffffff;
  --surface-2: #f7f8f4;
  --surface-3: #edf5f4;
  --ink: #172024;
  --muted: #637073;
  --line: #d5dfdc;
  --line-strong: #b7c6c2;
  --green: #2f7d57;
  --amber: #bc7424;
  --red: #b24d45;
  --teal: #25717c;
  --violet: #665a92;
  --indigo: #2f4777;
  --shadow: 0 18px 48px rgba(23, 32, 36, 0.09);
  --shadow-soft: 0 10px 28px rgba(23, 32, 36, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f8fbfa 0, var(--bg) 320px),
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

::selection {
  background: #cde8df;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid #1f2a2d;
  border-radius: 8px;
  background: #1f2a2d;
  color: #ffffff;
  cursor: pointer;
  min-height: 38px;
  padding: 0 16px;
  font-weight: 800;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

button:hover {
  background: #0f1517;
  box-shadow: 0 8px 20px rgba(23, 32, 36, 0.15);
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(37, 113, 124, 0.28);
  outline-offset: 2px;
}

button.secondary,
#refresh,
#export-json,
#export-markdown {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}

button.secondary:hover,
#refresh:hover,
#export-json:hover,
#export-markdown:hover {
  background: var(--surface-2);
}

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

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.topbar p {
  margin: 0;
}

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

.brand-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(37, 113, 124, 0.2);
}

.topbar h1 {
  font-size: 29px;
  line-height: 1;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.run-form {
  display: grid;
  grid-template-columns: minmax(190px, 1.4fr) 86px 86px minmax(150px, 1fr) auto;
  gap: 12px;
  align-items: end;
  width: min(920px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(247, 248, 244, 0.72);
  box-shadow: var(--shadow-soft);
  padding: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
  box-shadow: inset 0 1px 0 rgba(23, 32, 36, 0.03);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

select:hover,
input:hover {
  border-color: var(--line-strong);
}

.scenario-hint {
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.run-rail {
  border-right: 1px solid var(--line);
  padding: 22px 18px;
  background: #e3ecea;
  position: sticky;
  top: 89px;
  align-self: start;
  max-height: calc(100vh - 89px);
  overflow-y: auto;
}

.rail-heading,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rail-heading h2,
.panel-heading h3 {
  margin: 0;
}

.rail-heading h2 {
  font-size: 17px;
}

.panel-heading h3 {
  font-size: 18px;
}

.run-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.run-filter {
  min-width: 0;
}

.run-filter input {
  min-height: 40px;
  background: rgba(255, 255, 255, 0.88);
}

.run-filter-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-top: 14px;
}

.small-button {
  min-height: 40px;
  padding: 0 12px;
}

.lab-overview {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.overview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 14px;
  box-shadow: 0 8px 22px rgba(23, 32, 36, 0.05);
}

.overview-primary {
  border-color: rgba(47, 125, 87, 0.32);
  background: #f3fbf6;
}

.overview-card strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.overview-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.overview-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.run-card {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  padding: 14px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(23, 32, 36, 0.04);
}

.run-card:hover,
.run-card.active {
  border-color: #263235;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(23, 32, 36, 0.1);
  transform: none;
}

.run-card.severity-critical {
  border-left-color: var(--red);
}

.run-card.severity-warning,
.run-card.severity-degraded,
.run-card.severity-watch {
  border-left-color: var(--amber);
}

.run-card.severity-healthy {
  border-left-color: var(--green);
}

.run-card-topline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.run-card strong {
  font-size: 14px;
}

.run-finding {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

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

.run-meta span {
  border-radius: 999px;
  background: #edf4f2;
  padding: 3px 8px;
}

.health-chip {
  color: var(--teal) !important;
  font-weight: 800;
}

.empty-state {
  display: grid;
  gap: 4px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
  padding: 18px;
}

.empty-state strong {
  color: var(--ink);
}

.workspace {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 26px;
  min-width: 0;
}

.hero-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(237, 245, 244, 0.96)),
    var(--surface);
  padding: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-copy {
  min-width: 0;
}

.hero-strip h2 {
  margin: 4px 0 0;
  font-size: 30px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.hero-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.hero-facts span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 12px;
  padding: 0 10px;
}

.hero-facts strong {
  color: var(--ink);
}

.status-pill,
.severity {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-status {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill.healthy,
.severity.healthy,
.mini-status.healthy {
  background: var(--green);
}

.status-pill.info,
.severity.info,
.mini-status.info {
  background: var(--teal);
}

.status-pill.warning,
.severity.warning,
.mini-status.warning,
.mini-status.watch,
.mini-status.degraded {
  background: var(--amber);
}

.status-pill.critical,
.severity.critical,
.mini-status.critical {
  background: var(--red);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(116px, 1fr));
  gap: 12px;
}

.metric-card {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 106px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--line-strong);
}

.metric-card.metric-healthy::before {
  background: var(--green);
}

.metric-card.metric-warning,
.metric-card.metric-watch,
.metric-card.metric-degraded {
  background: #fffaf2;
}

.metric-card.metric-warning::before,
.metric-card.metric-watch::before,
.metric-card.metric-degraded::before {
  background: var(--amber);
}

.metric-card.metric-critical {
  background: #fff6f4;
}

.metric-card.metric-critical::before {
  background: var(--red);
}

.metric-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-card strong {
  font-size: 24px;
  line-height: 1;
}

.metric-card small {
  color: var(--muted);
  font-size: 12px;
}

.analysis-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.insight-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.75fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
  box-shadow: var(--shadow);
}

.compact-panel {
  box-shadow: none;
}

.panel-featured {
  border-color: rgba(37, 113, 124, 0.26);
  background:
    linear-gradient(180deg, #ffffff, #f8fbfa),
    var(--surface);
}

.heading-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.operator-summary {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.summary-line {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

.summary-actions {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.comparison-item {
  display: grid;
  gap: 6px;
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.comparison-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.comparison-item strong {
  font-size: 20px;
}

.delta.good {
  color: var(--green);
}

.delta.bad {
  color: var(--red);
}

.delta.neutral {
  color: var(--muted);
}

.agent-synthesis {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.agent-card {
  position: relative;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 14px;
  box-shadow: 0 10px 22px rgba(23, 32, 36, 0.04);
  overflow: hidden;
}

.agent-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--teal);
}

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

.agent-card h4 {
  margin: 0;
  font-size: 15px;
}

.agent-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.priority {
  border-radius: 999px;
  padding: 3px 8px;
  background: #1d2224;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.priority.p0 {
  background: var(--red);
}

.priority.p1 {
  background: var(--amber);
}

.priority.p2 {
  background: var(--teal);
}

.agent-card ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.playbook-objective {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.playbook-summary {
  margin: 14px 0 0;
  max-width: 960px;
  color: var(--muted);
  line-height: 1.55;
}

.success-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.success-strip span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eff7f1;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
}

.playbook-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.playbook-card {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 14px;
  box-shadow: 0 10px 24px rgba(23, 32, 36, 0.05);
}

.playbook-step-index {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(37, 113, 124, 0.2);
}

.playbook-card-body {
  min-width: 0;
}

.playbook-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.playbook-owner {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.playbook-card h4 {
  margin: 3px 0 0;
  font-size: 15px;
}

.playbook-card p {
  margin: 10px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.playbook-card code {
  display: block;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6f8f7;
  color: #263134;
  font-size: 12px;
  line-height: 1.45;
  padding: 9px;
  white-space: nowrap;
}

.playbook-card dl {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
}

.playbook-card dt {
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.playbook-card dd {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

canvas {
  display: block;
  width: 100%;
  height: 300px;
  margin-top: 12px;
}

.breakdown {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.breakdown-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 74px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.bar {
  height: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe7e4;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.bar .compute {
  background: var(--green);
}

.bar .collective {
  background: var(--teal);
}

.bar .dataloader {
  background: var(--amber);
}

.bar .storage {
  background: var(--violet);
}

.bar .idle {
  background: var(--red);
}

.diagnoses {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.diagnosis {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.diagnosis-critical {
  border-left-color: var(--red);
  background: #fff6f4;
}

.diagnosis-warning {
  border-left-color: var(--amber);
  background: #fffaf2;
}

.diagnosis-healthy {
  border-left-color: var(--green);
  background: #f4fbf6;
}

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

.diagnosis h4 {
  margin: 0;
  font-size: 15px;
}

.diagnosis ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.diagnosis li + li {
  margin-top: 5px;
}

.topology {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.node-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 12px;
  box-shadow: 0 8px 18px rgba(23, 32, 36, 0.04);
}

.node-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.gpu-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.gpu-tile {
  display: grid;
  place-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
  font-weight: 800;
  box-shadow: inset 0 -10px 20px rgba(23, 32, 36, 0.03);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 14px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
}

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

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

td {
  font-size: 14px;
}

tbody tr:hover {
  background: var(--surface-3);
}

.table-run-name {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
}

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

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

  .run-form {
    width: 100%;
  }

  .run-rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    position: static;
    max-height: none;
  }

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

  .metric-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }
}

@media (max-width: 820px) {
  .topbar,
  .hero-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .run-form,
  .analysis-layout,
  .insight-grid,
  .agent-grid,
  .playbook-grid,
  .metric-grid,
  .run-list {
    grid-template-columns: 1fr;
  }

  .heading-actions {
    justify-content: flex-start;
  }

  .workspace {
    padding: 16px;
  }

  .hero-strip h2 {
    font-size: 24px;
  }

  .playbook-card {
    grid-template-columns: 1fr;
  }

  .playbook-step-index {
    width: 30px;
    height: 30px;
  }
}

@media (max-width: 560px) {
  .topbar,
  .workspace,
  .run-rail {
    padding-left: 14px;
    padding-right: 14px;
  }

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

  .panel-heading,
  .diagnosis-head,
  .playbook-card header {
    align-items: flex-start;
    flex-direction: column;
  }
}
