* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: #0d1117;
  color: #c9d1d9;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */

.sidebar {
  width: 260px;
  min-width: 260px;
  background: #0d1117;
  border-right: 1px solid #21262d;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
}

.logo { font-size: 15px; color: #58a6ff; font-weight: bold; }
.logo span { color: #484f58; font-weight: normal; }

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px;
}

.sidebar-section { margin-bottom: 20px; }

.sidebar-section-title {
  font-size: 10px;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 0 8px;
  margin-bottom: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #8b949e;
  transition: background 0.1s, color 0.1s;
  border: 1px solid transparent;
}

.nav-item:hover { background: #161b22; color: #c9d1d9; }

.nav-item.active {
  background: #161b22;
  color: #c9d1d9;
  border-color: #30363d;
}

.nav-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item-meta { font-size: 10px; color: #484f58; }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-running { background: #3fb950; animation: pulse 1.5s infinite; }
.dot-stopped { background: #484f58; }
.dot-failed  { background: #f85149; }
.dot-strategy { background: #58a6ff; }
.dot-val-running { background: #d29922; animation: pulse 1.5s infinite; }
.dot-val-done    { background: #a371f7; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid #21262d;
  flex-shrink: 0;
}

/* ── Main Panel ─────────────────────────────────────────────────────────── */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.main-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
}

.main-header h1 {
  font-size: 14px;
  color: #c9d1d9;
  font-weight: bold;
  flex: 1;
}

.main-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #484f58;
  font-size: 13px;
  gap: 8px;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover:not(:disabled) { opacity: 0.85; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary  { background: #238636; color: #fff; }
.btn-danger   { background: #da3633; color: #fff; }
.btn-info     { background: #1f6feb; color: #fff; }
.btn-purple   { background: #6e40c9; color: #fff; }
.btn-ghost    { background: #21262d; color: #c9d1d9; border: 1px solid #30363d; }
.btn-sm       { padding: 4px 10px; font-size: 11px; }

/* ── Status badge ───────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-running  { background: #0d2818; color: #3fb950; border: 1px solid #3fb950; }
.badge-stopped  { background: #161b22; color: #8b949e; border: 1px solid #30363d; }
.badge-failed   { background: #2d1117; color: #f85149; border: 1px solid #f85149; }
.badge-completed { background: #1a1a3e; color: #a371f7; border: 1px solid #a371f7; }

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 11px;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

/* ── Metrics row ────────────────────────────────────────────────────────── */

.metrics-row {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.metric .value {
  font-size: 26px;
  font-weight: bold;
  line-height: 1;
}

.metric .label {
  font-size: 10px;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
}

.green { color: #3fb950; }
.red   { color: #f85149; }
.blue  { color: #58a6ff; }
.muted { color: #484f58; }

/* ── Table ──────────────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; font-size: 12px; }

th {
  text-align: left;
  padding: 8px 10px;
  color: #484f58;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #30363d;
  font-weight: normal;
  white-space: nowrap;
}

td {
  padding: 8px 10px;
  border-bottom: 1px solid #21262d;
  white-space: nowrap;
}

tr:hover td { background: #1c2128; }

tr.keep td:first-child   { border-left: 3px solid #3fb950; }
tr.discard td:first-child { border-left: 3px solid #f85149; }
tr.crash td:first-child   { border-left: 3px solid #484f58; }

.tag-keep    { color: #3fb950; }
.tag-discard { color: #f85149; }
.tag-crash   { color: #484f58; }

/* ── Chart ──────────────────────────────────────────────────────────────── */

.chart-wrap { position: relative; height: 160px; margin-bottom: 4px; }

canvas { display: block; }

/* ── Conversation ───────────────────────────────────────────────────────── */

.conv-item {
  border: 1px solid #21262d;
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}

.conv-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 11px;
  color: #8b949e;
}

.conv-header:hover { background: #1c2128; }

.conv-role {
  font-weight: bold;
  min-width: 70px;
}

.conv-role.assistant { color: #58a6ff; }
.conv-role.input     { color: #3fb950; }
.conv-role.system    { color: #d29922; }
.conv-role.briefing  { color: #a371f7; }

.conv-exp  { color: #484f58; }
.conv-time { color: #484f58; margin-left: auto; }

.conv-body {
  display: none;
  padding: 10px 12px;
  font-size: 11px;
  color: #8b949e;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px solid #21262d;
  line-height: 1.6;
  max-height: 400px;
  overflow-y: auto;
}

.conv-body.open { display: block; }

/* ── Strategy editor ────────────────────────────────────────────────────── */

.json-editor {
  width: 100%;
  min-height: 360px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

.json-editor:focus { outline: none; border-color: #58a6ff; }

/* ── Form ───────────────────────────────────────────────────────────────── */

.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.form-label {
  font-size: 11px;
  color: #8b949e;
  min-width: 90px;
}

.form-input {
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 6px 10px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
}

.form-input:focus { outline: none; border-color: #58a6ff; }

select.form-input { min-width: 160px; }

.form-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #484f58;
  margin: 16px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #21262d;
}

.condition-row {
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.modal-wide { width: 700px; }

/* ── Config edit form ───────────────────────────────────────────────────── */

.cfg-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #484f58;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #21262d;
  display: flex;
  align-items: center;
}

.cfg-field { display: flex; flex-direction: column; gap: 4px; }
.cfg-label { font-size: 10px; color: #8b949e; text-transform: uppercase; letter-spacing: .04em; }

.cfg-condition-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 24px;
  width: 520px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 14px;
  color: #c9d1d9;
  margin-bottom: 20px;
}

.modal-footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #21262d;
}

/* ── Walk-forward grid ──────────────────────────────────────────────────── */

.wf-table { border-collapse: collapse; font-size: 11px; width: 100%; }

.wf-table th, .wf-table td {
  padding: 6px 10px;
  border: 1px solid #21262d;
  text-align: center;
  white-space: nowrap;
}

.wf-table th { background: #0d1117; color: #484f58; font-weight: normal; }

.wf-cell-good { background: #0d2818; color: #3fb950; }
.wf-cell-ok   { background: #1a1500; color: #d29922; }
.wf-cell-bad  { background: #2d1117; color: #f85149; }

/* ── Walk-forward distribution ───────────────────────────────────────────── */

.wf-dist-block {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #21262d;
}

.wf-dist-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #484f58;
  margin-bottom: 10px;
}

.wf-dist-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.wf-dist-chart-title {
  font-size: 10px;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}

/* ── Validation table ───────────────────────────────────────────────────── */

.val-table { font-size: 12px; }

.val-table .section-is  { color: #58a6ff; }
.val-table .section-oos { color: #d29922; }

.val-pass { color: #3fb950; }
.val-fail { color: #f85149; }
.val-warn { color: #d29922; }

/* ── Error box ──────────────────────────────────────────────────────────── */

.error-box {
  background: #2d1117;
  border: 1px solid #f85149;
  border-radius: 6px;
  padding: 12px;
  font-size: 12px;
  color: #f85149;
  margin-bottom: 16px;
}

/* ── Scrollbar ──────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #484f58; }

/* ── Strategy card ───────────────────────────────────────────────────────── */

.sc-root {
  border: 1px solid #21262d;
  border-radius: 6px;
  overflow: hidden;
  background: #0a0e14;
}

.sc-section {
  padding: 14px 18px;
  border-bottom: 1px solid #21262d;
}
.sc-section:last-child { border-bottom: none; }

.sc-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #484f58;
  margin-bottom: 12px;
}

/* ── Conditions ── */
.sc-cond {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 7px 0;
  border-bottom: 1px solid #161b22;
}
.sc-cond:last-of-type { border-bottom: none; }

.sc-cond-type {
  font-size: 10px;
  color: #58a6ff;
  font-weight: 600;
  min-width: 160px;
  flex-shrink: 0;
  letter-spacing: .02em;
}

.sc-cond-params {
  display: flex;
  gap: 20px;
}

.sc-param { display: flex; flex-direction: column; align-items: flex-start; }
.sc-param-val { font-size: 14px; font-weight: bold; line-height: 1.2; }
.sc-param-key {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #484f58;
  margin-top: 1px;
}

.sc-cond-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid #161b22;
  font-size: 11px;
  color: #484f58;
}

.sc-logic-pill {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #d29922;
  background: rgba(210,153,34,.12);
  border: 1px solid rgba(210,153,34,.4);
  border-radius: 3px;
  padding: 2px 6px;
}

/* ── Exits ── */
.sc-exits {
  display: flex;
  gap: 0;
}

.sc-exit {
  flex: 1;
}

.sc-exit:not(:last-child) {
  padding-right: 24px;
  margin-right: 24px;
  border-right: 1px solid #21262d;
}

.sc-exit-val {
  font-size: 24px;
  font-weight: bold;
  line-height: 1.1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.sc-exit-key {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #484f58;
  margin-top: 4px;
}

.sc-exit-sub {
  font-size: 10px;
  color: #484f58;
  margin-top: 3px;
}

/* ── Sizing strip ── */
.sc-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  line-height: 1.8;
}

.sc-strip-val  { color: #c9d1d9; }
.sc-strip-blue { color: #58a6ff; font-weight: bold; }
.sc-strip-dim  { color: #484f58; font-size: 11px; }
.sc-strip-sep  { color: #30363d; margin: 0 2px; }

/* ── Chart tooltip ───────────────────────────────────────────────────────── */

.chart-tooltip {
  position: fixed;
  z-index: 200;
  background: #1c2128;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 12px 14px;
  width: 300px;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  font-size: 11px;
  font-family: 'SF Mono','Fira Code','Consolas',monospace;
}

.chart-tooltip-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid #21262d;
}

.chart-tooltip-metrics {
  display: flex;
  gap: 20px;
  margin-bottom: 8px;
}

.chart-tooltip-metric .v {
  font-size: 15px;
  font-weight: bold;
  line-height: 1.2;
}

.chart-tooltip-metric .l {
  font-size: 9px;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ── Agent sidebar item ──────────────────────────────────────────────────── */

.sidebar-agent {
  padding: 8px;
  border-top: 1px solid #21262d;
  flex-shrink: 0;
}

.nav-item-agent { color: #a371f7; }
.nav-item-agent .agent-glyph { font-size: 14px; line-height: 1; }
.nav-item-agent:hover { background: #1a1a3e; color: #d2a8ff; }
.nav-item-agent.active { background: #1a1a3e; color: #d2a8ff; border-color: #6e40c9; }

/* ── Agent panel ─────────────────────────────────────────────────────────── */

.mode-toggle {
  display: flex;
  border-radius: 6px;
  overflow: hidden;
}

.btn-toggle {
  background: #21262d;
  color: #484f58;
  border: 1px solid #30363d;
  border-radius: 0;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: bold;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}

.btn-toggle:first-child { border-radius: 6px 0 0 6px; }
.btn-toggle:last-child  { border-radius: 0 6px 6px 0; border-left: none; }
.btn-toggle:hover       { background: #30363d; color: #8b949e; }

.btn-toggle-active {
  background: #30363d;
  color: #c9d1d9;
  border: 1px solid #484f58;
  border-radius: 0;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: bold;
  font-family: inherit;
  cursor: default;
}

.btn-toggle-active:first-child { border-radius: 6px 0 0 6px; }
.btn-toggle-active:last-child  { border-radius: 0 6px 6px 0; border-left: none; }

/* ── Prompt sections (preview mode) ─────────────────────────────────────── */

.prompt-lede {
  padding: 12px 16px;
  font-size: 11px;
  color: #8b949e;
  border-bottom: 1px solid #21262d;
  background: #0d1117;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.prompt-section { border-bottom: 1px solid #21262d; }
.prompt-section:last-child { border-bottom: none; }

.prompt-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}

.prompt-section-header:hover { background: #1c2128; }

.prompt-section-chevron {
  font-size: 9px;
  color: #484f58;
  width: 10px;
  flex-shrink: 0;
  transition: transform 0.15s;
  display: inline-block;
}

.prompt-section.open .prompt-section-chevron { transform: rotate(90deg); }

.prompt-section-title { flex: 1; font-size: 12px; color: #c9d1d9; font-weight: bold; }
.prompt-section-lines { font-size: 10px; color: #484f58; }

.prompt-section-body { display: none; }
.prompt-section.open .prompt-section-body { display: block; }

.prompt-section-pre {
  padding: 12px 16px 16px;
  font-size: 11px;
  color: #8b949e;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  background: #0d1117;
  border-top: 1px solid #21262d;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── Prompt edit mode ────────────────────────────────────────────────────── */

.prompt-edit-wrap {
  padding: 12px 16px 16px;
  background: #0d1117;
}

.prompt-editor-unsaved {
  border-color: #d29922 !important;
}

/* ── Drawer ─────────────────────────────────────────────────────────────── */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 640px;
  max-width: calc(100vw - 260px);
  height: 100vh;
  background: #161b22;
  border-left: 1px solid #30363d;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 50;
  overflow: hidden;
}

.drawer.open {
  transform: translateX(0);
  box-shadow: -8px 0 32px rgba(0,0,0,0.5);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
  display: none;
  cursor: default;
}

.drawer-backdrop.open { display: block; }

.drawer-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #21262d;
  flex-shrink: 0;
  background: #0d1117;
  min-height: 52px;
}

.drawer-close {
  background: none;
  border: none;
  color: #484f58;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  font-family: inherit;
  flex-shrink: 0;
}

.drawer-close:hover { color: #c9d1d9; background: #21262d; }

.drawer-tabs {
  display: flex;
  border-bottom: 1px solid #21262d;
  padding: 0 12px;
  flex-shrink: 0;
  background: #0d1117;
}

.drawer-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #484f58;
  font-family: inherit;
  font-size: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: color 0.1s;
  margin-bottom: -1px;
  white-space: nowrap;
}

.drawer-tab:hover { color: #8b949e; }
.drawer-tab.active { color: #c9d1d9; border-bottom-color: #58a6ff; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ── Dashboard — live cards ──────────────────────────────────────────────── */

.live-section { margin-bottom: 32px; }

.live-section-title {
  font-size: 10px;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
}

.live-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.live-card {
  background: #0a1f10;
  border: 1px solid #238636;
  border-radius: 10px;
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.live-card:hover { background: #0c2615; border-color: #3fb950; }

.live-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.live-card-name {
  font-size: 14px;
  font-weight: bold;
  color: #c9d1d9;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.live-card-metrics {
  display: flex;
  gap: 28px;
  margin-bottom: 16px;
}

.live-card-metric .v {
  font-size: 24px;
  font-weight: bold;
  line-height: 1;
}

.live-card-metric .l {
  font-size: 9px;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 4px;
}

.live-card-actions { display: flex; gap: 8px; }

/* ── Dashboard — history table ───────────────────────────────────────────── */

.history-section-title {
  font-size: 10px;
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 12px;
}

tr.history-row { cursor: pointer; }

/* ── Period badge (header) ───────────────────────────────────────────────── */

.period-badge {
  font-size: 11px;
  color: #8b949e;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 3px 10px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* Period row inside summary card */
.period-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #21262d;
  font-size: 11px;
}

.period-row-label {
  color: #484f58;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-size: 10px;
}

.period-row-value {
  color: #8b949e;
  font-variant-numeric: tabular-nums;
}

/* ── Startup state ───────────────────────────────────────────────────────── */

.startup-card {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 28px 32px;
  max-width: 680px;
}

.startup-period {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 24px;
}

.startup-period-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #484f58;
  margin-right: 4px;
}

.startup-period-value {
  font-size: 18px;
  font-weight: bold;
  color: #c9d1d9;
  font-variant-numeric: tabular-nums;
}

.startup-period-arrow {
  font-size: 16px;
  color: #484f58;
}

.startup-phase {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #21262d;
}

.startup-phase-text {
  font-size: 13px;
  color: #58a6ff;
}

.startup-logs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.startup-log-line {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 11px;
  line-height: 1.5;
}

.startup-log-time {
  color: #484f58;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  width: 52px;
}

.startup-log-msg {
  color: #8b949e;
}

/* ── Chat conversation ───────────────────────────────────────────────────── */

.chat-wrap {
  display: flex;
  flex-direction: column;
}

/* Baseline card */
.chat-baseline {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 28px;
  font-size: 12px;
}

.chat-baseline-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-baseline-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #484f58;
}

/* Briefing card */
.chat-briefing {
  background: #0d1117;
  border: 1px solid #21262d;
  border-left: 3px solid #d29922;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 24px;
  font-size: 12px;
}

.chat-briefing-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #d29922;
  margin-bottom: 6px;
}

/* Experiment divider */
.chat-exp-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #484f58;
}

.chat-exp-divider::before,
.chat-exp-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #21262d;
}

.chat-exp-divider span { flex-shrink: 0; }

/* Chat rows */
.chat-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}

.chat-row-result { flex-direction: row-reverse; }

/* Avatars */
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 3px;
}

.chat-avatar-agent {
  background: #12122a;
  color: #a371f7;
  border: 1px solid #6e40c9;
}

.chat-avatar-result {
  background: #161b22;
  color: #484f58;
  border: 1px solid #30363d;
  font-size: 11px;
}

/* Bubbles */
.chat-bubble {
  max-width: 84%;
  border-radius: 4px 12px 12px 12px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.6;
}

.chat-row-result .chat-bubble { border-radius: 12px 4px 12px 12px; }

.chat-bubble-agent   { background: #0e0e24; border: 1px solid #3d2a7a; }
.chat-bubble-keep    { background: #091a0d; border: 1px solid #1a5c28; }
.chat-bubble-discard { background: #1c0a0a; border: 1px solid #6e1a1a; }
.chat-bubble-crash   { background: #161b22; border: 1px solid #30363d; }

/* Agent bubble internals */
.chat-bubble-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.chat-thread {
  font-size: 11px;
  font-weight: bold;
  color: #a371f7;
}

.chat-thread-type {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #6e40c9;
  background: rgba(110,64,201,.15);
  border: 1px solid rgba(110,64,201,.3);
  padding: 1px 6px;
  border-radius: 3px;
}

.chat-ts {
  font-size: 10px;
  color: #484f58;
  margin-left: auto;
}

.chat-field-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #484f58;
  margin-top: 10px;
  margin-bottom: 4px;
}

.chat-hypothesis {
  color: #c9d1d9;
  font-size: 12px;
  line-height: 1.65;
}

.chat-diagnosis {
  color: #8b949e;
  font-size: 11px;
  line-height: 1.65;
}

.chat-conclusion {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #1a1a3e;
  font-size: 11px;
  color: #8b949e;
  line-height: 1.6;
}

/* Result bubble internals */
.chat-result-headline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.chat-result-icon { font-size: 15px; font-weight: bold; line-height: 1; }
.chat-result-label { font-size: 13px; font-weight: bold; letter-spacing: .02em; }
.chat-result-reason { font-size: 10px; color: #8b949e; font-style: italic; }
.chat-result-stat { font-size: 12px; color: #8b949e; }
.chat-result-stat strong { color: #c9d1d9; }

.chat-result-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #8b949e;
  margin-bottom: 8px;
}

.chat-sep { color: #30363d; }

/* Diagnostics grid in details */
.chat-diag-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 12px;
  margin-bottom: 10px;
}

.chat-diag-cell { display: flex; flex-direction: column; }

.chat-diag-val {
  font-size: 13px;
  font-weight: bold;
  color: #c9d1d9;
  line-height: 1.2;
}

.chat-diag-key {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #484f58;
  margin-top: 2px;
}

.chat-exits {
  font-size: 11px;
  color: #484f58;
  margin-bottom: 8px;
  line-height: 1.6;
}

/* Annual returns */
.chat-annuals {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.chat-annual { text-align: center; min-width: 34px; }

.chat-annual-val {
  font-size: 11px;
  font-weight: bold;
  line-height: 1.2;
}

.chat-annual-year {
  font-size: 9px;
  color: #484f58;
  margin-top: 2px;
}

.chat-winners-losers {
  font-size: 10px;
  color: #3fb950;
  line-height: 1.6;
  margin-top: 4px;
}

/* Expandable toggle */
.chat-toggle {
  font-size: 11px;
  color: #484f58;
  cursor: pointer;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
}

.chat-toggle:hover { color: #8b949e; }

.chat-arrow { font-size: 9px; display: inline-block; }

.chat-section-body { margin-top: 10px; }

.chat-raw-pre {
  font-size: 10px;
  color: #484f58;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  font-family: inherit;
  margin: 0;
}
