:root {
  --bg-deep: #07090f;
  --bg-card: #0e1320;
  --bg-card-2: #111827;
  --border: #1b2336;
  --border-strong: #2a3650;
  --text-primary: #e6ecf3;
  --text-dim: #6b7689;
  --text-dimmer: #3f4858;
  --positive: #22d3ee;
  --support: #34d399;
  --negative: #fb7185;
  --warning: #fbbf24;
  --blue: #60a5fa;
  --regime-pos: #0b332a;
  --regime-neg: #34101c;
  --regime-neutral: #14181f;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background: linear-gradient(180deg, var(--bg-deep) 0%, #040608 100%);
  color: var(--text-primary);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

code,
pre,
.brand-name,
.brand-subtitle,
.instrument-tabs,
.symbol,
.spot,
.spot-label,
.ts,
.es-line,
.cockpit-status-grid,
.panel-title,
.panel-subtitle,
.mini-stat,
.status-strip,
.level-list,
.tv-preview,
.change-list,
.narrator-feed,
.tab-bar,
.metric-toggle,
.metric-meta,
.chart-label,
.axis-label,
.banner {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}

.hidden { display: none !important; }

.banner {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 7px 14px;
  border-bottom: 1px solid rgba(251, 191, 36, 0.42);
  background: rgba(74, 60, 10, 0.86);
  color: #fde68a;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.banner span {
  color: #d8c98c;
  text-transform: none;
  letter-spacing: 0;
}

#header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  min-height: 116px;
  padding: 12px 18px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 9, 15, 0.82);
}

.header-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 320px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-subtitle {
  margin-top: 1px;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.instrument-tabs {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(4, 6, 8, 0.72);
}

.instrument-tabs button {
  min-width: 44px;
  min-height: 28px;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 800;
}

.instrument-tabs button:first-child { border-left: 0; }
.instrument-tabs button:hover { color: var(--text-primary); background: rgba(255, 255, 255, 0.035); }
.instrument-tabs button.active { color: var(--positive); background: rgba(34, 211, 238, 0.13); }

.symbol-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.symbol {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
}

.underlier-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: rgba(14, 19, 32, 0.9);
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.spot-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.spot {
  font-size: 30px;
  font-weight: 500;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.spot-label {
  color: var(--text-dim);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ts,
.es-line {
  color: var(--text-dim);
  font-size: 11px;
}

.es-line {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.header-right {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 0;
}

.header-note {
  max-width: 640px;
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  line-height: 1.35;
}

.cockpit-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(118px, 1fr));
  gap: 6px;
  width: min(760px, 100%);
}

.cockpit-status-item,
.overview-card,
.data-health,
#chart-stack,
#narrator,
.risk-section,
.research-panel {
  border: 1px solid var(--border);
  background: rgba(14, 19, 32, 0.76);
}

.cockpit-status-item {
  min-width: 0;
  padding: 7px 9px;
  border-radius: 6px;
}

.cockpit-status-item span,
.mini-k,
.status-k {
  display: block;
  color: var(--text-dim);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cockpit-status-item strong,
.mini-v,
.status-v {
  display: block;
  margin-top: 2px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.data-health {
  display: grid;
  grid-template-columns: minmax(270px, 0.9fr) minmax(430px, 1.15fr) minmax(260px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 18px;
  border-width: 0 0 1px;
  background: rgba(5, 8, 14, 0.9);
}

.health-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.health-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--warning);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.55);
}

.health-label {
  color: var(--warning);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 12px;
  font-weight: 800;
}

.health-updated,
.health-message {
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
}

.health-components {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.health-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(14, 19, 32, 0.78);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
}

.health-chip .hk { color: var(--text-dim); text-transform: uppercase; }
.health-chip .hv { color: var(--text-primary); }

.trader-overview {
  display: grid;
  grid-template-columns: minmax(260px, 1.1fr) minmax(360px, 1.35fr) minmax(260px, 0.9fr) minmax(250px, 0.9fr);
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}

.overview-card {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-title {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel-subtitle {
  color: var(--text-dimmer);
  font-size: 10px;
  text-align: right;
  text-transform: uppercase;
}

.regime-card {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--regime-neutral);
}

.regime-card.regime-pos { background: var(--regime-pos); border-color: #14613f; }
.regime-card.regime-neg { background: var(--regime-neg); border-color: #6b1f30; }

.regime-label {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.regime-pos .regime-label { color: var(--support); }
.regime-neg .regime-label { color: var(--negative); }

.regime-dist {
  margin-top: 3px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
}

.regime-net,
.regime-conv {
  margin-top: 3px;
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
}

.regime-conv {
  color: var(--text-dimmer);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.structure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}

.mini-stat,
.status-item {
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(7, 9, 15, 0.55);
}

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

.level-list,
.change-list,
.narrator-feed {
  display: grid;
  gap: 6px;
}

.level-list {
  max-height: 286px;
  overflow-y: auto;
  padding-right: 2px;
}

.level-row {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) minmax(82px, 0.82fr) minmax(92px, 0.88fr) minmax(118px, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 7px 8px;
  border: 1px solid rgba(31, 42, 63, 0.92);
  border-left: 3px solid var(--border-strong);
  border-radius: 6px;
  background: rgba(7, 9, 15, 0.56);
  font-size: 12px;
}

.level-row.above,
.level-row.call { border-left-color: var(--negative); }
.level-row.below,
.level-row.put { border-left-color: var(--support); }
.level-row.near,
.level-row.flip { border-left-color: var(--warning); }
.level-row.max-pain { border-left-color: var(--blue); }

.level-name {
  color: var(--text-primary);
  font-weight: 800;
}

.level-price,
.level-distance {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.level-read {
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tv-copy-btn {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(34, 211, 238, 0.5);
  border-radius: 6px;
  background: rgba(34, 211, 238, 0.13);
  color: #67e8f9;
  font-weight: 900;
}

.tv-copy-btn:hover:not(:disabled) { background: rgba(34, 211, 238, 0.21); }
.tv-copy-btn:disabled { opacity: 0.5; }

.tv-copy-helper,
.tv-copy-state {
  margin-top: 7px;
  color: var(--text-dim);
  font-size: 12px;
}

.tv-copy-state { color: var(--support); min-height: 17px; }

.tv-preview {
  min-height: 112px;
  max-height: 132px;
  overflow: hidden;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid rgba(31, 42, 63, 0.92);
  border-radius: 6px;
  background: rgba(7, 9, 15, 0.6);
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.36;
  white-space: pre-wrap;
}

.change-row,
.feed-entry,
.panel-empty {
  padding: 8px;
  border: 1px solid rgba(31, 42, 63, 0.92);
  border-radius: 6px;
  background: rgba(7, 9, 15, 0.55);
  color: var(--text-dim);
}

.change-row strong,
.feed-entry strong { color: var(--text-primary); }

.view-toggle {
  display: inline-flex;
  margin: 10px 18px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: rgba(4, 6, 8, 0.72);
}

.view-btn {
  min-width: 92px;
  min-height: 30px;
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-weight: 800;
}

.view-btn:first-child { border-left: 0; }
.view-btn.active { color: var(--positive); background: rgba(34, 211, 238, 0.13); }

.view-container {
  display: none;
  padding: 10px 18px;
}

.view-container.active { display: block; }

.chart-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.chart-panel-head small {
  color: var(--text-dimmer);
  font-size: 10px;
  text-transform: uppercase;
}

#chart-stack {
  position: relative;
  height: clamp(360px, 46vh, 560px);
  overflow: hidden;
  border-radius: 8px;
  background: #05070d;
}

#chart-host {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#chart-svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-bg { fill: #05070d; }
.grid-line {
  stroke: rgba(70, 80, 100, 0.28);
  stroke-width: 1;
}
.grid-line.faint { stroke: rgba(70, 80, 100, 0.18); }
.wick {
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.wick.up,
.candle.up { stroke: var(--support); fill: var(--support); }
.wick.down,
.candle.down { stroke: var(--negative); fill: var(--negative); }
.level-line {
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}
.level-line.call,
.level-line.above { stroke: rgba(251, 113, 133, 0.9); }
.level-line.put,
.level-line.below { stroke: rgba(52, 211, 153, 0.9); }
.level-line.flip {
  stroke: rgba(251, 191, 36, 0.96);
  stroke-dasharray: 8 6;
}
.level-line.max-pain {
  stroke: rgba(96, 165, 250, 0.82);
  stroke-dasharray: 4 5;
}
.level-line.near { stroke: rgba(251, 191, 36, 0.88); }
.price-line {
  stroke: rgba(230, 236, 243, 0.96);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

#chart-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.chart-label {
  position: absolute;
  right: 54px;
  transform: translateY(-50%);
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 5px;
  background: rgba(7, 9, 15, 0.94);
  font-size: 11px;
  white-space: nowrap;
}

.chart-label.call { color: var(--negative); }
.chart-label.put { color: var(--support); }
.chart-label.flip { color: var(--warning); }
.chart-label.max-pain { color: var(--blue); }
.chart-label.vwap { color: #2dd4bf; }
.chart-label.price { color: var(--text-primary); }

.axis-label {
  position: absolute;
  left: 8px;
  color: var(--text-dimmer);
  font-size: 10px;
  transform: translateY(-50%);
}

#narrator {
  margin: 0 18px 10px;
  padding: 10px;
  border-radius: 8px;
}

.narrator-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}

.narrator-title,
.narrator-status {
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.feed-entry {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 8px;
}

.feed-time {
  color: var(--text-dimmer);
}

.feed-body {
  color: var(--text-dim);
}

.research-panel {
  display: none;
  min-height: 260px;
  padding: 10px;
  border-radius: 8px;
}

.research-panel.active { display: block; }

.tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.tab-bar button,
.metric-toggle button {
  min-height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(7, 9, 15, 0.74);
  color: var(--text-dim);
  font-weight: 800;
}

.tab-bar button.active,
.metric-toggle button.active {
  color: var(--positive);
  border-color: rgba(34, 211, 238, 0.42);
  background: rgba(34, 211, 238, 0.12);
}

.heatmap-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.metric-toggle {
  display: flex;
  gap: 6px;
}

.metric-meta {
  color: var(--text-dim);
}

.heatmap-preview {
  display: grid;
  grid-template-columns: 80px repeat(8, minmax(42px, 1fr));
  gap: 2px;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
}

.heatmap-cell {
  min-height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(31, 42, 63, 0.8);
  color: var(--text-dim);
}

.heatmap-cell.head {
  color: var(--text-primary);
  background: rgba(17, 24, 39, 0.86);
  font-weight: 800;
}

.heatmap-cell.pos { background: rgba(34, 211, 238, 0.16); color: #a5f3fc; }
.heatmap-cell.neg { background: rgba(251, 113, 133, 0.16); color: #fecdd3; }
.heatmap-cell.spot { outline: 1px solid var(--warning); }

.interval-preview {
  margin-top: 8px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 24px;
  margin-bottom: 8px;
  color: var(--text-dim);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
}

.chart-legend span {
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(7, 9, 15, 0.58);
}

.legend-a { color: var(--support); }
.legend-b { color: var(--negative); }
.legend-c { color: #a78bfa; }

.research-chart {
  position: relative;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid rgba(31, 42, 63, 0.8);
  border-radius: 8px;
  background: #05070d;
}

.research-chart svg {
  display: block;
  width: 100%;
  height: 260px;
}

.research-grid {
  stroke: rgba(70, 80, 100, 0.24);
  stroke-width: 1;
}

.research-line {
  fill: none;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.research-line.line-0 { stroke: var(--support); }
.research-line.line-1 { stroke: var(--negative); }
.research-line.line-2 {
  stroke: #a78bfa;
  stroke-dasharray: 6 5;
}

.research-last {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(7, 9, 15, 0.86);
  color: var(--text-primary);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 11px;
}

.bar-chart {
  display: flex;
  align-items: end;
  gap: 8px;
  min-height: 260px;
  padding: 18px 14px 30px;
}

.flow-bar {
  position: relative;
  display: flex;
  flex: 1;
  align-items: end;
  justify-content: center;
  gap: 3px;
  height: 190px;
  min-width: 28px;
}

.flow-bar .bar {
  width: 38%;
  min-height: 4px;
  border-radius: 3px 3px 0 0;
}

.flow-bar .bar.call { background: rgba(52, 211, 153, 0.72); }
.flow-bar .bar.put { background: rgba(251, 113, 133, 0.72); }

.flow-bar span {
  position: absolute;
  bottom: -22px;
  color: var(--text-dimmer);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 9px;
  white-space: nowrap;
}

.risk-section {
  margin: 10px 18px 18px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 12px;
}

.risk-section strong { color: var(--text-primary); }

@media (max-width: 980px) {
  #header {
    flex-direction: column;
  }

  .header-right {
    align-items: stretch;
    width: 100%;
  }

  .header-note {
    max-width: none;
    text-align: left;
  }
}

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

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

@media (max-width: 760px) {
  .banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-row,
  .spot-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .cockpit-status-grid,
  .trader-overview,
  .structure-grid,
  .status-strip,
  .data-health {
    grid-template-columns: 1fr;
  }

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

  .level-price,
  .level-distance {
    text-align: left;
  }

  .level-read {
    grid-column: 1 / -1;
    white-space: normal;
  }

  .feed-entry {
    grid-template-columns: 1fr;
  }
}
