@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #080c12;
  --bg-panel: #0d1117;
  --bg-panel-header: #111820;
  --border: #1a2332;
  --border-glow: #00e5c7;
  --text-primary: #e0e6ed;
  --text-secondary: #6b7b8d;
  --text-muted: #3d4f5f;
  --accent-cyan: #00e5c7;
  --accent-orange: #ff8c42;
  --positive: #22c55e;
  --negative: #ef4444;
  --warn: #eab308;
}

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

body {
  font-family: 'JetBrains Mono', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 229, 199, 0.015) 2px,
    rgba(0, 229, 199, 0.015) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* === HEADER === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.header-title .diamond {
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  transform: rotate(45deg);
  box-shadow: 0 0 8px var(--accent-cyan);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  color: var(--text-secondary);
}

.mode-badge {
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.mode-badge.live {
  background: rgba(34, 197, 94, 0.15);
  color: var(--positive);
  border: 1px solid var(--positive);
}

.mode-badge.simulate {
  background: rgba(0, 229, 199, 0.1);
  color: var(--accent-cyan);
  border: 1px solid var(--accent-cyan);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--positive);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.disconnected {
  background: var(--negative);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--positive); }
  50% { opacity: 0.4; box-shadow: 0 0 12px var(--positive); }
}

/* === KPI BAR === */
.kpi-bar {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}

.kpi-box {
  background: var(--bg-panel);
  padding: 12px 16px;
  text-align: center;
  transition: background 0.3s;
}

.kpi-box:hover {
  background: var(--bg-panel-header);
}

.kpi-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 9px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.kpi-value.positive { color: var(--positive); }
.kpi-value.negative { color: var(--negative); }
.kpi-value.cyan { color: var(--accent-cyan); }

/* === GRID LAYOUT === */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto;
  gap: 1px;
  background: var(--border);
}

.grid-full {
  grid-column: 1 / -1;
}

/* === PANELS === */
.panel {
  background: var(--bg-panel);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.3s;
}

.panel:hover {
  box-shadow: inset 0 0 30px rgba(0, 229, 199, 0.02);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-panel-header);
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-cyan);
}

.panel-header .subtitle {
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 1px;
}

.panel-body {
  flex: 1;
  padding: 12px 16px;
  overflow: auto;
}

/* === EQUITY CHART === */
#equityChart {
  width: 100% !important;
  height: 220px !important;
}

/* === PERFORMANCE TABLE === */
.perf-table {
  width: 100%;
  border-collapse: collapse;
}

.perf-table tr {
  border-bottom: 1px solid rgba(26, 35, 50, 0.5);
}

.perf-table td {
  padding: 6px 0;
  font-size: 12px;
}

.perf-table td:first-child {
  color: var(--text-secondary);
}

.perf-table td:last-child {
  text-align: right;
  font-weight: 500;
}

.perf-section {
  font-size: 9px;
  color: var(--accent-cyan);
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 10px 0 4px;
}

/* === ARB SCANNER TABLE === */
.arb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.arb-table th {
  text-align: left;
  padding: 6px 8px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.arb-table td {
  padding: 8px;
  border-bottom: 1px solid rgba(26, 35, 50, 0.3);
}

.arb-table tr {
  transition: background 0.2s;
}

.arb-table tr:hover {
  background: rgba(0, 229, 199, 0.03);
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.status-badge.live {
  background: rgba(34, 197, 94, 0.15);
  color: var(--positive);
}

.status-badge.low_liquidity {
  background: rgba(255, 140, 66, 0.15);
  color: var(--accent-orange);
}

.status-badge.below_threshold {
  background: rgba(107, 123, 141, 0.15);
  color: var(--text-secondary);
}

.status-badge.near_arb {
  background: rgba(0, 229, 199, 0.08);
  color: var(--accent-cyan);
}

/* === POSITIONS === */
.position-card {
  padding: 10px 0;
  border-bottom: 1px solid rgba(26, 35, 50, 0.4);
}

.position-card:last-child { border-bottom: none; }

.pos-market {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
}

.pos-tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-left: 6px;
}

.pos-tag.arb {
  background: rgba(0, 229, 199, 0.15);
  color: var(--accent-cyan);
}

.pos-tag.mm {
  background: rgba(255, 140, 66, 0.15);
  color: var(--accent-orange);
}

.pos-detail {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* === MM QUOTES === */
.quote-card {
  padding: 10px 0;
  border-bottom: 1px solid rgba(26, 35, 50, 0.4);
}

.quote-market {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.quote-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
}

.quote-bar {
  height: 6px;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.quote-bar.bid { background: var(--accent-cyan); }
.quote-bar.ask { background: var(--accent-orange); }

.quote-meta {
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* === HEATMAP === */
.heatmap {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 60px;
  padding: 8px 0;
}

.heatmap-bar {
  flex: 1;
  background: var(--accent-cyan);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  opacity: 0.7;
  transition: height 0.5s, opacity 0.3s;
}

.heatmap-bar:hover {
  opacity: 1;
}

.heatmap-labels {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: var(--text-muted);
  padding: 4px 0;
}

/* === RISK PANEL === */
.risk-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 12px;
}

.risk-label { color: var(--text-secondary); }
.risk-value { font-weight: 600; }

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(26, 35, 50, 0.8);
  border-radius: 3px;
  overflow: hidden;
  margin: 4px 0 8px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s, background 0.5s;
}

.progress-fill.green { background: var(--positive); }
.progress-fill.orange { background: var(--accent-orange); }
.progress-fill.red { background: var(--negative); }

.circuit-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
}

.circuit-status.ok { color: var(--positive); }
.circuit-status.tripped { color: var(--negative); }

/* === EXECUTION TAPE === */
.tape-entry {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(26, 35, 50, 0.2);
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.tape-time {
  color: var(--text-muted);
  font-size: 10px;
  min-width: 60px;
}

.tape-tag {
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  min-width: 30px;
  text-align: center;
}

.tape-tag.arb { background: rgba(0, 229, 199, 0.15); color: var(--accent-cyan); }
.tape-tag.mm { background: rgba(255, 140, 66, 0.15); color: var(--accent-orange); }
.tape-tag.skip { background: rgba(107, 123, 141, 0.1); color: var(--text-muted); }

.tape-market { color: var(--text-primary); flex: 1; }

.tape-pnl { font-weight: 600; min-width: 60px; text-align: right; }
.tape-pnl.positive { color: var(--positive); }
.tape-pnl.negative { color: var(--negative); }

.tape-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tape-status.filled { background: var(--positive); }
.tape-status.pending { background: var(--accent-orange); }
.tape-status.skipped { background: var(--text-muted); }

/* === HERO P&L === */
.hero-pnl {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.hero-pnl.positive {
  color: var(--positive);
  text-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.hero-pnl.negative {
  color: var(--negative);
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg-panel); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === RESPONSIVE === */
@media (max-width: 1280px) {
  .kpi-bar { grid-template-columns: repeat(4, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .grid-full { grid-column: 1; }
}
