:root {
  color-scheme: dark;
  --base-950: #0b1220;
  --base-900: #0f1727;
  --base-850: #111a2e;
  --base-800: #162033;
  --base-700: #202b41;
  --line: rgba(255, 255, 255, 0.06);
  --line-strong: rgba(255, 255, 255, 0.12);
  --ink: #e2e8f0;
  --strong: #f8fafc;
  --muted: #94a3b8;
  --faint: #64748b;
  --primary: #4da3ff;
  --safe: #34d399;
  --warning: #fbbf24;
  --high: #fb923c;
  --critical: #f87171;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--base-950);
}

body {
  min-width: 1280px;
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei UI", "Microsoft YaHei", ui-sans-serif, system-ui, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 0;
  content: "";
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 24px 24px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.72), transparent 82%);
}

body::after {
  position: fixed;
  inset: 0;
  z-index: 0;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 8%, rgba(77, 163, 255, 0.14), transparent 24%),
    radial-gradient(circle at 82% 0%, rgba(52, 211, 153, 0.1), transparent 22%),
    linear-gradient(180deg, rgba(15, 23, 39, 0.74), rgba(11, 18, 32, 0.96));
}

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

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 13px;
  background: rgba(20, 52, 59, 0.92);
  color: var(--ink);
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

button:hover,
.button-link:hover {
  border-color: var(--line-strong);
  background: var(--base-800);
  color: var(--strong);
}

button:focus-visible,
.button-link:focus-visible,
select:focus,
textarea:focus {
  outline: 1px solid rgba(77, 163, 255, 0.72);
  outline-offset: 2px;
}

button.primary,
button.active {
  border-color: rgba(77, 163, 255, 0.35);
  background: rgba(77, 163, 255, 0.1);
  color: var(--primary);
}

button.ghost,
.button-link {
  background: var(--base-850);
  color: var(--muted);
}

button.small {
  min-height: 28px;
  padding: 0 9px;
  font-size: 11px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.lab-shell {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  min-height: 100vh;
  padding: 12px;
}

.lab-header {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 39, 0.92);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.brand {
  min-width: 0;
}

.eyebrow,
.kicker {
  display: block;
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 3px;
  color: var(--strong);
  font-size: 18px;
  font-weight: 750;
  line-height: 1.16;
}

h2 {
  margin-bottom: 0;
  color: var(--strong);
  font-size: 13px;
  font-weight: 700;
}

.subtitle {
  margin-bottom: 0;
  color: var(--faint);
  font-size: 12px;
}

.actions,
.command-actions,
.flow-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.lab-header > .actions {
  max-width: 760px;
}

#flowWindow {
  max-width: 220px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lab-header > .actions button,
.lab-header > .actions .button-link {
  white-space: nowrap;
  height: 34px;
  padding-top: 0;
  padding-bottom: 0;
}

.mode-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(11, 18, 32, 0.98);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  padding: 0 6px 0 9px;
}

.mode-control label {
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.mode-control select {
  width: auto;
  min-width: 70px;
  height: 28px;
  min-height: 28px;
  border: 1px solid rgba(77, 163, 255, 0.18);
  border-radius: 6px;
  background: #0f1727;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 900;
  line-height: 28px;
  padding: 0 22px 0 8px;
  appearance: auto;
}

.mode-control select option {
  background: #0f1727;
  color: #f8fafc;
}

.mode-control select:focus {
  box-shadow: none;
}

.help-dot {
  flex: 0 0 22px;
  inline-size: 22px;
  min-inline-size: 22px;
  block-size: 22px;
  min-block-size: 22px;
  aspect-ratio: 1 / 1;
  border-radius: 999px;
  padding: 0;
  border-color: rgba(77, 163, 255, 0.24);
  background: rgba(77, 163, 255, 0.14);
  color: #bfdbfe;
  font-family: Arial, sans-serif;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
}

.help-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: none;
  width: min(340px, 78vw);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(11, 18, 32, 0.98);
  box-shadow: var(--shadow);
  padding: 10px 12px;
  text-align: left;
}

.help-popover strong,
.help-popover span {
  display: block;
}

.help-popover strong {
  margin-bottom: 4px;
  color: var(--strong);
  font-size: 12px;
}

.help-popover span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: normal;
}

.mode-control:hover .help-popover,
.mode-control:focus-within .help-popover {
  display: block;
}

.mode-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  max-width: 128px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  position: relative;
  min-height: 82px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--base-850);
  box-shadow: var(--shadow);
  padding: 11px;
}

.stat-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(77, 163, 255, 0.46), transparent);
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  color: var(--strong);
  font-size: 24px;
  line-height: 1;
}

.stat-card span {
  color: var(--faint);
  font-size: 11px;
  font-weight: 750;
}

.stat-card.danger {
  border-color: rgba(248, 113, 113, 0.28);
}

.stat-card.warning {
  border-color: rgba(251, 191, 36, 0.28);
}

.stat-card.success {
  border-color: rgba(52, 211, 153, 0.25);
}

.stat-card.danger strong {
  color: var(--critical);
}

.stat-card.warning strong {
  color: var(--warning);
}

.stat-card.success strong,
.stat-card.info strong {
  color: var(--strong);
}

.split {
  display: grid;
  grid-template-columns: minmax(344px, 0.32fr) minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.command-pane,
.flow-pane {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.panel {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--base-850);
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
  padding: 9px 12px;
}

.command-card {
  display: grid;
  min-height: 398px;
}

.field {
  display: grid;
  gap: 6px;
  padding: 12px 12px 0;
  color: var(--faint);
  font-size: 11px;
  font-weight: 800;
}

.field.grow {
  align-content: stretch;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--base-900);
  color: var(--ink);
  outline: none;
}

select {
  min-height: 34px;
  padding: 0 10px;
}

input {
  min-height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 160px;
  resize: vertical;
  padding: 11px;
  line-height: 1.55;
}

select:focus,
input:focus,
textarea:focus {
  border-color: rgba(66, 232, 255, 0.72);
  box-shadow: 0 0 0 3px rgba(66, 232, 255, 0.10);
}

.field-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.42fr) minmax(0, 1fr);
}

.field.compact {
  min-width: 0;
}

.scenario-summary {
  display: grid;
  gap: 5px;
  margin: 10px 14px 0;
  border: 1px solid rgba(108, 235, 222, 0.14);
  border-radius: 8px;
  padding: 10px 11px;
  background: rgba(4, 16, 20, 0.48);
}

.scenario-summary strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
}

.scenario-summary span,
.scenario-summary em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.scenario-summary em {
  color: var(--cyan);
  font-weight: 800;
}

.panel-note {
  color: var(--faint);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .field-row {
    grid-template-columns: 1fr;
  }
}

.command-actions {
  justify-content: flex-start;
  padding: 12px;
}

.preset-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.preset {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: auto;
  padding: 9px 10px;
  text-align: left;
  background: var(--base-900);
}

.preset strong {
  color: var(--strong);
  font-size: 12px;
}

.preset span {
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
}

.benchmark-panel {
  overflow: visible;
}

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

.benchmark-controls .field {
  padding: 0;
}

.field.mini {
  gap: 5px;
  min-width: 0;
  font-size: 10px;
}

.field.mini.wide {
  grid-column: 1 / -1;
}

.benchmark-detail {
  display: grid;
  gap: 9px;
  margin: 10px 12px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: var(--base-900);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.benchmark-detail strong {
  color: var(--strong);
}

.benchmark-detail .case-title {
  display: grid;
  gap: 4px;
}

.benchmark-detail .case-title strong {
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.benchmark-detail .case-title span {
  color: var(--faint);
  overflow-wrap: anywhere;
}

.benchmark-meta {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 5px 8px;
}

.benchmark-meta span {
  color: var(--faint);
}

.benchmark-meta strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.benchmark-json {
  max-height: 132px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
  background: #070d16;
  color: #cbd5e1;
  font-size: 10px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.benchmark-json::-webkit-scrollbar {
  display: none;
}

.benchmark-actions {
  display: flex;
  gap: 8px;
  padding: 12px;
}

.benchmark-actions button {
  flex: 1 1 0;
  min-width: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  border: 1px solid rgba(52, 211, 153, 0.22);
  border-radius: 999px;
  padding: 0 8px;
  color: var(--safe);
  background: rgba(52, 211, 153, 0.08);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.loading {
  border-color: rgba(251, 191, 36, 0.28);
  color: var(--warning);
  background: rgba(251, 191, 36, 0.1);
}

.pill.bad {
  border-color: rgba(248, 113, 113, 0.28);
  color: var(--critical);
  background: rgba(248, 113, 113, 0.1);
}

.flow-card {
  min-height: 520px;
}

.flow-title {
  align-items: flex-start;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 10px;
  padding: 12px;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--base-900);
}

.stage::after {
  position: absolute;
  top: 43px;
  right: -18px;
  width: 38px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, rgba(77, 163, 255, 0), rgba(77, 163, 255, 0.62));
}

.stage:last-child::after {
  display: none;
}

.stage-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  color: var(--strong);
  font-size: 11px;
  font-weight: 800;
}

.stage-head span {
  color: var(--faint);
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.stage-body {
  display: grid;
  gap: 8px;
  max-height: 374px;
  overflow: auto;
  padding: 10px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.stage-body::-webkit-scrollbar {
  display: none;
}

.flow-node,
.stream-row {
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 7px;
  padding: 9px;
  background: var(--base-850);
  cursor: pointer;
}

.flow-node:hover,
.stream-row:hover,
.flow-node.active,
.stream-row.active {
  border-color: var(--line-strong);
  background: var(--base-800);
}

.flow-node.danger,
.stream-row.danger {
  border-left-color: var(--critical);
  background: rgba(248, 113, 113, 0.08);
}

.flow-node.warning,
.stream-row.warning {
  border-left-color: var(--warning);
  background: rgba(251, 191, 36, 0.07);
}

.flow-node.success,
.stream-row.success {
  border-left-color: var(--safe);
  background: rgba(52, 211, 153, 0.06);
}

.flow-node.info,
.stream-row.info {
  border-left-color: var(--primary);
}

.node-top,
.row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.node-type,
.row-type {
  color: var(--strong);
  font-size: 11px;
  font-weight: 850;
}

.node-time,
.row-time {
  color: var(--faint);
  font-size: 10px;
  font-weight: 800;
}

.node-title,
.row-title {
  color: var(--strong);
  font-size: 12px;
  font-weight: 850;
  line-height: 1.35;
}

.node-summary,
.row-summary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--base-900);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.chip.danger {
  border-color: rgba(248, 113, 113, 0.28);
  background: rgba(248, 113, 113, 0.1);
  color: var(--critical);
}

.chip.warning {
  border-color: rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.1);
  color: var(--warning);
}

.chip.success {
  border-color: rgba(52, 211, 153, 0.25);
  background: rgba(52, 211, 153, 0.09);
  color: var(--safe);
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.46fr) minmax(0, 0.54fr);
  gap: 12px;
  min-height: 0;
}

.stream-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding: 14px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.stream-list::-webkit-scrollbar,
pre::-webkit-scrollbar {
  display: none;
}

.detail-card {
  min-width: 0;
}

.detail-empty {
  padding: 12px;
  color: var(--faint);
}

.detail-body {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.detail-summary {
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 7px;
  padding: 11px;
  background: var(--base-900);
}

.detail-summary strong {
  display: block;
  margin-bottom: 5px;
  color: var(--strong);
  font-size: 13px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 7px;
  color: var(--faint);
  font-size: 11px;
}

.detail-grid strong {
  color: var(--ink);
  word-break: break-word;
}

pre {
  max-height: 240px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
  background: #070d16;
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.empty {
  padding: 18px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

.stage-empty {
  display: grid;
  min-height: 92px;
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.02);
  line-height: 1.55;
  text-align: left;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--base-850);
  padding: 8px;
}

.pagination span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.pagination button {
  height: 28px;
  min-height: 28px;
  padding: 0 9px;
  font-size: 11px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--base-950);
}

::-webkit-scrollbar-thumb {
  border: 2px solid var(--base-950);
  border-radius: 8px;
  background: #263349;
}

::-webkit-scrollbar-thumb:hover {
  background: #33425c;
}

@media (max-width: 1280px) {
  body {
    min-width: 0;
  }

  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .split,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .lab-header {
    align-items: flex-start;
    grid-template-columns: 1fr;
  }

  .lab-header > .actions {
    justify-content: flex-start;
    max-width: 100%;
  }

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

  .stage {
    min-height: 220px;
  }

  .stage::after {
    display: none;
  }
}

@media (max-width: 760px) {
  .lab-shell {
    padding: 10px;
  }

  .status-strip {
    grid-template-columns: 1fr 1fr;
  }
}
