:root {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #09090b;
  --panel-strong: #09090b;
  --line: #27272a;
  --line-soft: #27272a;
  --text: #f4f4f5;
  --muted: #71717a;
  --dim: #71717a;
  --emerald: #10b981;
  --emerald-deep: #09090b;
  --crimson: #ef4444;
  --crimson-deep: #09090b;
  --mono-font: "JetBrains Mono", "Fira Code", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono-font);
}

button,
table {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.terminal-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 12px 0 20px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 48px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0 12px;
}

.brand,
.status-strip,
.nav-links,
.book-controls,
.state-meta {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-family: var(--mono-font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--emerald);
}

.nav-links {
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line-soft);
  background: var(--bg);
}

.nav-links a,
.book-controls button {
  min-height: 34px;
  border: 0;
  color: var(--muted);
  background: transparent;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-links a:hover,
.book-controls button:hover,
.book-controls .active {
  background: var(--line);
  color: var(--text);
}

.status-strip {
  justify-content: flex-end;
  gap: 8px;
  font-family: var(--mono-font);
  color: var(--muted);
  font-size: 12px;
}

.status-strip strong {
  color: var(--text);
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--emerald);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 12px;
  padding: 12px 0;
}

.hero-copy,
.market-state,
.panel,
.metric {
  border: 1px solid var(--line);
  background: var(--panel);
}

.hero-copy {
  min-height: 620px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: clamp(18px, 3vw, 32px);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--dim);
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  max-width: 18ch;
  margin-bottom: 18px;
  font-family: var(--mono-font);
  font-size: clamp(38px, 5.6vw, 84px);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-lede {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(15px, 1.5vw, 20px);
  line-height: 1.4;
}

.decision-stream {
  width: 100%;
  margin-top: 24px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.stream-chrome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.stream-chrome h2 {
  font-size: 18px;
}

.stream-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 4px;
}

.stream-tabs button {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--dim);
  padding: 0 10px;
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.stream-tabs button:hover,
.stream-tabs button.active {
  background: var(--line);
  color: var(--text);
}

.terminal-window {
  position: relative;
  min-height: 264px;
  padding: 12px 12px 12px 48px;
  overflow: hidden;
  font-family: var(--mono-font);
}

.terminal-rail {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: 36px;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  border-right: 1px solid var(--line);
  padding-top: 16px;
}

.terminal-rail span {
  width: 7px;
  height: 7px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.log-stream {
  display: grid;
  gap: 6px;
  min-height: 196px;
}

.log-line {
  display: grid;
  grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.log-line code {
  color: var(--text);
  font-family: var(--mono-font);
}

.log-level {
  align-self: start;
  color: var(--dim);
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.log-level.info {
  color: var(--muted);
}

.log-level.warning {
  color: var(--crimson);
}

.log-level.reasoner {
  color: var(--muted);
}

.log-level.execute,
.log-level.fill {
  color: var(--emerald);
}

.log-level.risk {
  color: var(--crimson);
}

.terminal-prompt {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  color: var(--dim);
  font-size: 12px;
}

.terminal-prompt span::before {
  content: "$ ";
  color: var(--emerald);
}

.terminal-prompt i {
  display: inline-block;
  width: 8px;
  height: 15px;
  background: var(--emerald);
  animation: cursor-blink 1s steps(1) infinite;
}

@keyframes cursor-blink {
  50% {
    opacity: 0;
  }
}

.model-sandbox {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
}

.sandbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.sandbox-header h2 {
  font-size: 18px;
}

.sandbox-mode {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--dim);
  padding: 0 9px;
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.sandbox-form {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.sandbox-form label,
.trace-title,
.forecast-topline span,
.forecast-field span {
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.sandbox-form label,
.forecast-topline span,
.forecast-field span {
  color: var(--dim);
}

.sandbox-input-row {
  display: grid;
  grid-template-columns: minmax(130px, 180px) minmax(280px, auto);
  gap: 8px;
}

.sandbox-input-row input,
.sandbox-input-row button {
  min-height: 46px;
  border: 1px solid var(--line);
  font-family: var(--mono-font);
  font-weight: 800;
}

.sandbox-input-row input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  padding: 0 14px;
  font-size: 18px;
  text-transform: uppercase;
}

.sandbox-input-row input:focus {
  border-color: var(--emerald);
  outline: 0;
}

.sandbox-input-row button {
  background: var(--bg);
  color: var(--text);
  padding: 0 12px;
  font-size: 12px;
  letter-spacing: 0;
}

.sandbox-input-row button:hover {
  border-color: var(--emerald);
  color: var(--emerald);
}

.sandbox-input-row button:disabled {
  cursor: wait;
  background: var(--line);
  color: var(--dim);
}

.sandbox-results {
  border-top: 1px solid var(--line);
  min-height: 0;
}

.sandbox-results pre {
  margin: 0;
  min-height: 176px;
  overflow-x: auto;
  background: var(--bg);
  border: 0;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.55;
}

.font-mono {
  font-family: var(--mono-font);
}

.text-zinc-400 {
  color: var(--muted);
}

.text-emerald-400 {
  color: var(--emerald);
}

.text-red-400 {
  color: var(--crimson);
}

.json-key {
  color: var(--muted);
}

.json-string {
  color: inherit;
}

.json-number {
  color: var(--dim);
}

.json-punctuation {
  color: var(--dim);
}

.reasoning-trace {
  border-top: 1px solid var(--line);
  padding: 16px;
  font-family: var(--mono-font);
}

.trace-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
}

.trace-title i {
  width: 7px;
  height: 13px;
  background: var(--emerald);
  animation: cursor-blink 0.86s steps(1) infinite;
}

.trace-lines {
  display: grid;
  gap: 9px;
  min-height: 136px;
}

.trace-line {
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.trace-line span {
  color: var(--emerald);
  font-weight: 800;
}

.forecast-card {
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.forecast-topline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.forecast-topline div {
  display: grid;
  gap: 10px;
  min-height: 104px;
  align-content: center;
  border-right: 1px solid var(--line);
  padding: 16px;
}

.forecast-topline div:last-child {
  border-right: 0;
}

.forecast-topline strong {
  font-family: var(--mono-font);
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1;
}

.result-direction.direction-long {
  color: var(--emerald);
}

.result-direction.direction-short {
  color: var(--crimson);
}

.forecast-body {
  display: grid;
  gap: 0;
}

.forecast-field {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding: 16px;
}

.forecast-field:last-child {
  border-bottom: 0;
}

.forecast-field strong {
  font-size: 15px;
  line-height: 1.35;
}

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

.boundary-grid p {
  display: grid;
  gap: 8px;
  min-height: 72px;
  margin: 0;
  align-content: center;
  border: 1px solid var(--line);
  background: #09090b;
  padding: 12px;
}

.boundary-grid b,
.boundary-grid em {
  font-family: var(--mono-font);
  font-size: 12px;
  font-style: normal;
}

.boundary-grid b {
  color: var(--dim);
  text-transform: uppercase;
}

.boundary-grid em {
  color: var(--text);
}

.thesis p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.product-matrix {
  width: 100%;
  margin-top: 12px;
  border: 1px solid #27272a;
  background: #09090b;
}

.matrix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #27272a;
  padding: 12px;
}

.matrix-header h2 {
  font-size: 18px;
}

.matrix-session {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid #27272a;
  background: var(--bg);
  color: var(--dim);
  padding: 0 9px;
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.matrix-table-wrap {
  overflow-x: auto;
}

.matrix-table {
  min-width: 980px;
  border-collapse: collapse;
}

.matrix-table th,
.matrix-table td {
  border-bottom: 1px solid #27272a;
  border-right: 1px solid #27272a;
  padding: 10px 12px;
}

.matrix-table th:last-child,
.matrix-table td:last-child {
  border-right: 0;
}

.matrix-table tbody tr:last-child td {
  border-bottom: 0;
}

.matrix-table th {
  background: var(--bg);
  color: var(--dim);
  font-size: 10px;
}

.matrix-table tbody tr {
  position: relative;
}

.matrix-table tbody tr:hover,
.matrix-table tbody tr:focus {
  background: var(--panel-strong);
  outline: 0;
}

.matrix-table tbody tr::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 14px;
  bottom: calc(100% - 4px);
  z-index: 4;
  width: min(420px, calc(100vw - 64px));
  border: 1px solid #27272a;
  background: var(--bg);
  color: var(--text);
  padding: 8px 10px;
  font-family: var(--mono-font);
  font-size: 11px;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.matrix-table tbody tr:hover::after,
.matrix-table tbody tr:focus::after {
  opacity: 1;
  transform: translateY(0);
}

.matrix-table td {
  color: var(--muted);
  font-family: var(--mono-font);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}

.matrix-table td strong {
  margin-bottom: 5px;
  color: var(--text);
  font-family: var(--mono-font);
  font-size: 13px;
}

.matrix-table td small {
  color: var(--dim);
  font-family: var(--mono-font);
  font-size: 11px;
}

.matrix-table em {
  color: var(--dim);
  font-style: normal;
}

.matrix-efficiency {
  color: var(--text);
  font-weight: 800;
}

.entry-text {
  color: var(--emerald);
}

.risk-text {
  color: var(--crimson);
}

.rs,
.action-chip {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border: 1px solid #27272a;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.rs.weak,
.action-short {
  border-color: var(--crimson);
  background: var(--crimson-deep);
  color: var(--crimson);
}

.rs.strong,
.action-long {
  border-color: var(--emerald);
  background: var(--emerald-deep);
  color: var(--emerald);
}

.rs.neutral {
  background: var(--bg);
  color: var(--dim);
}

.action-pass,
.action-skip {
  background: var(--bg);
  color: var(--crimson);
  border-color: var(--crimson);
}

.action-skip {
  border-color: var(--crimson);
  color: var(--crimson);
}

.market-state {
  display: flex;
  min-height: 320px;
  flex-direction: column;
  justify-content: space-between;
  padding: 20px;
}

.state-topline {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-family: var(--mono-font);
  font-size: 12px;
  text-transform: uppercase;
}

.timestamp {
  color: var(--dim);
}

.state-value {
  font-family: var(--mono-font);
  font-size: clamp(76px, 9vw, 128px);
  line-height: 0.9;
}

.state-meta {
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

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

.metric {
  min-height: 112px;
  padding: 14px;
}

.metric span,
.metric small {
  display: block;
  color: var(--dim);
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin: 14px 0 10px;
  font-family: var(--mono-font);
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

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

.panel {
  min-width: 0;
}

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

.panel-header.tight {
  min-height: 76px;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0;
}

.book-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 2px;
  border: 1px solid var(--line-soft);
  background: var(--bg);
  padding: 4px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

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

th {
  color: var(--dim);
  background: var(--bg);
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

tbody tr:hover {
  background: var(--panel-strong);
}

td strong {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
}

td small {
  display: block;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.25;
}

.domain,
.badge,
.verdict,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border: 1px solid var(--line);
  padding: 0 9px;
  font-family: var(--mono-font);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.domain,
.pill {
  background: var(--bg);
  color: var(--muted);
}

.badge {
  min-width: 58px;
}

.badge-positive,
.long {
  border-color: var(--emerald);
  background: var(--emerald-deep);
  color: var(--emerald);
}

.badge-negative,
.short {
  border-color: var(--crimson);
  background: var(--crimson-deep);
  color: var(--crimson);
}

.badge-neutral,
.fade {
  border-color: var(--line);
  background: var(--bg);
  color: var(--muted);
}

.fade {
  border-color: var(--crimson);
  color: var(--crimson);
}

.pass {
  border-color: var(--line);
  background: var(--bg);
  color: var(--dim);
}

.positive {
  color: var(--emerald) !important;
}

.negative {
  color: var(--crimson) !important;
}

.side-stack {
  display: grid;
  gap: 12px;
  align-content: start;
}

.compact-panel {
  min-height: 280px;
}

.agent-list {
  padding: 8px 12px 12px;
}

.agent-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  min-height: 42px;
  border-bottom: 1px solid var(--line-soft);
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.agent-row strong {
  font-family: var(--mono-font);
  font-size: 12px;
  text-transform: uppercase;
}

.risk-bars {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.risk-bars div {
  display: grid;
  gap: 6px;
}

.risk-bars span {
  color: var(--muted);
  font-family: var(--mono-font);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.risk-bars i {
  display: block;
  height: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  position: relative;
}

.risk-bars i::before {
  content: "";
  display: block;
  width: var(--bar);
  height: 100%;
  background: var(--emerald);
}

@media (max-width: 1080px) {
  .topbar,
  .hero-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .nav-links,
  .status-strip {
    justify-self: start;
  }

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

@media (max-width: 680px) {
  .terminal-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 10px;
  }

  .topbar {
    padding: 12px;
  }

  .nav-links {
    width: 100%;
    overflow-x: auto;
  }

  .hero-copy,
  .market-state {
    min-height: 260px;
    padding: 20px;
  }

  .stream-chrome,
  .log-line {
    grid-template-columns: 1fr;
  }

  .stream-tabs {
    justify-content: flex-start;
  }

  .terminal-window {
    padding-left: 44px;
  }

  .sandbox-header,
  .matrix-header,
  .forecast-field {
    grid-template-columns: 1fr;
  }

  .sandbox-header,
  .matrix-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .sandbox-input-row,
  .forecast-topline,
  .boundary-grid {
    grid-template-columns: 1fr;
  }

  .forecast-topline div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .forecast-topline div:last-child {
    border-bottom: 0;
  }

  .metric-row {
    grid-template-columns: 1fr;
  }

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

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