:root {
  --ink: #172433;
  --muted: #5f6f7f;
  --line: #dce3e9;
  --surface: #ffffff;
  --canvas: #f3f6f8;
  --accent: #087d75;
  --accent-dark: #05645e;
  --accent-soft: #e7f4f2;
  --danger: #b73737;
  --danger-soft: #fff0ef;
  --success: #20734a;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
a { color: var(--accent-dark); }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid rgba(8, 125, 117, .3); outline-offset: 2px; }
[hidden] { display: none !important; }

.topbar { background: #152b35; color: #f5f8f9; border-bottom: 3px solid #27a69b; }
.topbar-inner { max-width: 1440px; min-height: 76px; margin: 0 auto; padding: 12px 32px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid #5f7a83; border-radius: 10px; color: #82d8ce; font-family: Georgia, serif; font-size: 25px; font-weight: 700; }
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .02em; font-size: 16px; }
.brand small { color: #b9cbd1; font-size: 12px; }
.back-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: #dbe8eb; text-decoration: none; font-size: 14px; }
.back-link:hover { color: #82d8ce; }

.page-shell { max-width: 1440px; margin: 0 auto; padding: 36px 32px 56px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.overline { margin: 0 0 4px; color: var(--accent-dark); text-transform: uppercase; letter-spacing: .14em; font-size: 11px; font-weight: 700; }
h1 { margin: 0; font-family: "Trebuchet MS", "Aptos", sans-serif; font-size: clamp(28px, 3vw, 40px); line-height: 1.2; letter-spacing: -.025em; }
.lead { max-width: 720px; margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.environment-badge { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); color: var(--muted); white-space: nowrap; font-size: 13px; }
.environment-badge span { width: 8px; height: 8px; border-radius: 50%; background: #9aabb4; }
.environment-badge.ready span { background: var(--success); }
.environment-badge.error span { background: var(--danger); }
.global-message { margin-bottom: 20px; padding: 12px 16px; border: 1px solid #e6b9b4; border-radius: 8px; background: var(--danger-soft); color: #862e2a; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; gap: 24px; }
.main-column, .side-column { display: grid; gap: 20px; min-width: 0; }
.side-column { position: sticky; top: 20px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 3px 12px rgba(23, 36, 51, .035); }
.main-column > .panel { padding: 24px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.panel-heading > div { display: flex; align-items: center; gap: 10px; }
.panel-heading h2, .run-panel h2, .side-title h2 { margin: 0; font-size: 18px; line-height: 1.35; }
.step { color: var(--accent); font-family: var(--mono); font-size: 12px; font-weight: 700; }
.panel-meta { color: var(--muted); font-size: 13px; }

.scenario-picker { padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.scenario-picker > label, .field > span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 650; }
.picker-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
select, input, textarea { width: 100%; min-width: 0; border: 1px solid #bdcbd3; border-radius: 7px; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
select, input { min-height: 44px; padding: 9px 11px; }
textarea { padding: 10px 11px; resize: vertical; line-height: 1.5; }
select:hover, input:hover, textarea:hover { border-color: #819ba6; }
select:focus, input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(8, 125, 117, .09); outline: none; }
input:disabled, textarea:disabled, select:disabled { background: #edf1f3; color: #6c7a84; }
.field-hint, .field small { display: block; margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border: 1px solid transparent; border-radius: 7px; font-weight: 650; transition: background .15s, border-color .15s, color .15s, transform .1s; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button.secondary { background: var(--accent-soft); color: var(--accent-dark); border-color: #b9dcd7; }
.button.secondary:hover:not(:disabled) { background: #d8ece9; border-color: #84bdb6; }
.button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.button.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.danger { background: #fff; color: var(--danger); border-color: #d79b98; }
.button.danger:hover:not(:disabled) { background: var(--danger-soft); }
.button.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.button.ghost:hover:not(:disabled) { background: #edf2f4; color: var(--ink); }

.scenario-list-header, .scenario-item { display: grid; grid-template-columns: minmax(160px, 1fr) 82px 82px 105px 40px; gap: 10px; align-items: center; }
.scenario-list-header { padding: 16px 0 7px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.scenario-item { padding: 14px 0; border-top: 1px solid #edf1f3; }
.scenario-item:first-child { border-top: 0; }
.scenario-name { min-width: 0; }
.scenario-name strong, .scenario-name small { display: block; }
.scenario-name strong { font-size: 14px; }
.scenario-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.scenario-item input { padding: 8px 9px; font-family: var(--mono); font-size: 13px; }
.icon-button { display: grid; place-items: center; width: 40px; height: 44px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #7a8b96; }
.icon-button:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.empty-state { display: grid; justify-items: center; padding: 28px 16px 10px; text-align: center; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 10px; color: #8ca6ad; }
.empty-state strong { color: var(--ink); font-size: 14px; }
.empty-state span { margin-top: 3px; font-size: 13px; }

.parameters-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 16px; }
.field-wide { grid-column: 1 / -1; }
.switch-row { display: flex; align-items: center; gap: 16px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); cursor: pointer; }
.switch-row > span:first-child { flex: 1; }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 14px; }
.switch-row small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.switch-row input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.switch-control { position: relative; flex: 0 0 auto; width: 46px; height: 26px; border-radius: 20px; background: #9aabb4; transition: background .18s; }
.switch-control::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s; }
.switch-row input:checked + .switch-control { background: var(--accent); }
.switch-row input:checked + .switch-control::after { transform: translateX(20px); }
.switch-row input:focus-visible + .switch-control { outline: 3px solid rgba(8, 125, 117, .3); outline-offset: 3px; }
.identity-note { margin-top: 14px; padding: 10px 12px; border-radius: 6px; background: #eef5f6; color: #35545b; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

.run-panel { padding: 24px; border-top: 3px solid var(--accent); }
.run-label { color: var(--accent-dark); text-transform: uppercase; letter-spacing: .12em; font-size: 10px; font-weight: 750; }
.run-panel h2 { margin-top: 7px; font-size: 22px; }
.run-panel > p { color: var(--muted); font-size: 13px; }
.run-facts { margin: 22px 0; }
.run-facts div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid #edf1f3; }
.run-facts dt { color: var(--muted); font-size: 13px; }
.run-facts dd { margin: 0; font-family: var(--mono); font-size: 13px; font-weight: 650; text-align: right; }
.stage-toggle { display: flex; align-items: flex-start; gap: 10px; margin: 16px 0; cursor: pointer; }
.stage-toggle input { flex: 0 0 auto; width: 18px; min-height: 18px; margin-top: 2px; accent-color: var(--accent); }
.stage-toggle strong, .stage-toggle small { display: block; }
.stage-toggle strong { font-size: 13px; }
.stage-toggle small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.stage-threshold { display: grid; grid-template-columns: minmax(0, 1fr) 70px; align-items: center; gap: 10px; margin: 12px 0; color: var(--muted); font-size: 12px; }
.stage-threshold input { min-height: 38px; padding: 6px 8px; }
.stage-list { margin: 14px 0; padding: 0; list-style: none; }
.stage-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 9px; margin-top: 5px; border-radius: 5px; background: #f3f6f8; color: var(--muted); font-size: 11px; }
.stage-list li.running { background: var(--accent-soft); color: var(--accent-dark); }
.stage-list li.success { background: #e7f4ed; color: var(--success); }
.stage-list li.failed { background: var(--danger-soft); color: var(--danger); }
.run-button { width: 100%; margin-top: 10px; }
.run-warning { margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px !important; }
.environment-panel { padding: 20px 24px; }
.side-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.side-title h2 { font-size: 15px; }
.side-title a { font-size: 12px; }
.environment-list { margin: 14px 0 0; }
.environment-list div { margin-top: 13px; }
.environment-list dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.environment-list dd { margin: 3px 0 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12px; }
.environment-list dd.ok { color: var(--success); }
.environment-list dd.error { color: var(--danger); }

.results-panel { min-width: 0; overflow: hidden; }
.text-button { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 8px; border: 0; background: transparent; color: var(--accent-dark); font-size: 12px; }
.text-button:hover:not(:disabled) { text-decoration: underline; }
.text-button svg { width: 16px; height: 16px; }
.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.metric { padding: 12px; border-left: 2px solid #b9c6cd; background: #f7f9fa; }
.metric span, .metric strong { display: block; }
.metric span { color: var(--muted); font-size: 11px; }
.metric strong { margin-top: 3px; font-family: var(--mono); font-size: 21px; line-height: 1.25; }
.metric.success { border-color: var(--success); }
.metric.success strong { color: var(--success); }
.metric.failed { border-color: var(--danger); }
.metric.failed strong { color: var(--danger); }
.metric.response { border-color: var(--accent); }
.metric.response strong { color: var(--accent-dark); }
.progress-track { height: 6px; margin-top: 20px; overflow: hidden; border-radius: 6px; background: #e6ecef; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s ease-out; }
.progress-caption { display: flex; justify-content: space-between; gap: 16px; margin-top: 7px; color: var(--muted); font-size: 12px; }
#run-elapsed { font-family: var(--mono); }
.latency-section, .pair-section { margin-top: 22px; }
.statistics-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.statistics-heading h3 { margin: 0; font-size: 14px; }
.statistics-heading span { color: var(--muted); font-size: 11px; }
.latency-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.latency-card { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfc; }
.latency-card-wide { grid-column: 1 / -1; }
.latency-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.latency-card-header strong { font-size: 12px; }
.latency-card-header span { color: var(--muted); font-family: var(--mono); font-size: 10px; white-space: nowrap; }
.latency-card canvas { display: block; width: 100%; height: 220px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; color: var(--muted); font-size: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 50%; }
.latency-empty { display: grid; place-items: center; min-height: 120px; color: var(--muted); font-size: 12px; }
.pair-table-wrap { max-height: 420px; margin-top: 0; }
.pair-table-wrap table { min-width: 900px; }
.pair-table-wrap td:nth-child(2), .pair-table-wrap td:nth-child(3) { max-width: 280px; font-family: inherit; }
.pair-table-wrap td:nth-child(n+4) { font-family: var(--mono); white-space: nowrap; }
.results-empty { padding: 24px 0 2px; color: var(--muted); font-size: 13px; text-align: center; }
.table-wrap { max-height: 520px; margin-top: 18px; overflow: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; padding: 9px 10px; background: #edf2f4; color: #526773; text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
td { max-width: 230px; padding: 10px; border-top: 1px solid #edf1f3; vertical-align: top; overflow-wrap: anywhere; }
td:nth-child(2), td:nth-child(4) { font-family: var(--mono); }
.status-pill { display: inline-block; padding: 2px 7px; border-radius: 12px; background: #edf2f4; white-space: nowrap; }
.status-pill.success { background: #e7f4ed; color: var(--success); }
.status-pill.failed { background: var(--danger-soft); color: var(--danger); }
.status-pill.cancelled { color: var(--muted); }
.execution-monitor { margin-top: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; }
.monitor-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 14px; background: #f5f8f9; border-bottom: 1px solid var(--line); }
.monitor-heading h3 { margin: 0; font-size: 14px; }
.monitor-heading span { color: var(--muted); font-size: 11px; }
.monitor-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: 240px; }
.execution-chats { max-height: 360px; padding: 8px; overflow-y: auto; background: #f7f9fa; border-right: 1px solid var(--line); }
.execution-chat { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; margin-bottom: 4px; padding: 7px 9px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--ink); text-align: left; }
.execution-chat:hover { background: #eaf0f2; }
.execution-chat.selected { border-color: #9fc9c4; background: var(--accent-soft); }
.execution-chat > span { min-width: 0; flex: 1; }
.execution-chat strong, .execution-chat small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.execution-chat strong { font-size: 12px; }
.execution-chat small { color: var(--muted); font-size: 10px; }
.chat-state-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: #9aabb4; }
.execution-chat.running .chat-state-dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(8,125,117,.12); }
.execution-chat.success .chat-state-dot { background: var(--success); }
.execution-chat.failed .chat-state-dot { background: var(--danger); }
.execution-detail { min-width: 0; padding: 14px; }
.execution-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.execution-detail-header strong, .execution-detail-header small { display: block; }
.execution-detail-header strong { font-size: 14px; }
.execution-detail-header small { margin-top: 2px; color: var(--muted); font-family: var(--mono); font-size: 10px; overflow-wrap: anywhere; }
.execution-current { margin-top: 12px; padding: 9px 11px; border-radius: 6px; background: #eef5f6; color: #35545b; font-size: 12px; }
.execution-steps { display: flex; flex-wrap: wrap; gap: 5px; margin: 12px 0; padding: 0; list-style: none; }
.execution-step { max-width: 100%; padding: 3px 7px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.execution-step.running { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-dark); }
.execution-step.done { border-color: #b6d8c5; background: #edf7f1; color: var(--success); }
.execution-step.failed { border-color: #e1aaa6; background: var(--danger-soft); color: var(--danger); }
.execution-log { max-height: 170px; min-height: 54px; overflow-y: auto; padding: 8px 10px; border-radius: 6px; background: #172b35; color: #dce8eb; font-family: var(--mono); font-size: 10px; line-height: 1.55; }
.log-entry { margin-bottom: 4px; overflow-wrap: anywhere; }
.log-entry:last-child { margin-bottom: 0; }
.log-entry.sent { color: #82d8ce; }
.log-entry.received { color: #a8deb9; }
.log-entry.error { color: #ffb5ae; }
.log-time { margin-right: 7px; color: #91a8b0; }
.runners { position: fixed; left: -10000px; top: 0; width: 1px; height: 1px; overflow: hidden; pointer-events: none; }
.runners iframe { width: 1px; height: 1px; border: 0; }

@media (max-width: 1050px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; }
  .page-shell, .topbar-inner { padding-left: 22px; padding-right: 22px; }
  .metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .side-column { position: static; grid-row: 1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .run-panel { grid-row: span 2; }
  .page-heading { align-items: flex-start; }
}
@media (max-width: 600px) {
  .topbar-inner { min-height: 68px; padding: 10px 16px; }
  .brand small, .back-link { font-size: 0; }
  .back-link svg { width: 24px; height: 24px; }
  .page-shell { padding: 24px 14px 36px; }
  .page-heading { display: block; }
  .environment-badge { margin-top: 16px; }
  .main-column > .panel { padding: 18px 16px; }
  .side-column { grid-template-columns: 1fr; }
  .scenario-list-header { display: none; }
  .scenario-item { grid-template-columns: repeat(2, minmax(0, 1fr)) 40px; gap: 10px; }
  .scenario-name { grid-column: 1 / -1; }
  .scenario-item label:nth-of-type(3) { grid-column: 1 / 3; }
  .scenario-item .icon-button { grid-column: 3; grid-row: 3; }
  .scenario-item label::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; }
  .picker-row { grid-template-columns: 1fr; }
  .parameters-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:last-child { grid-column: 1 / -1; }
  .latency-charts { grid-template-columns: 1fr; }
  .latency-card-wide { grid-column: auto; }
  .statistics-heading { display: block; }
  .statistics-heading span { display: block; margin-top: 3px; }
  .latency-card-header { display: block; }
  .latency-card-header span { display: block; margin-top: 3px; white-space: normal; }
  .panel-heading { align-items: flex-start; }
  .results-panel .panel-heading { display: block; }
  .results-panel .text-button { margin-top: 8px; padding-left: 0; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 650px; }
  .monitor-heading { display: block; }
  .monitor-heading span { display: block; margin-top: 3px; }
  .monitor-layout { grid-template-columns: 1fr; }
  .execution-chats { max-height: 150px; border-right: 0; border-bottom: 1px solid var(--line); }
  .execution-detail { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
