/* Dark-mode terminal vibes. */
:root {
  --bg-0:        #0a0d12;
  --bg-1:        #121620;
  --bg-2:        #1b2030;
  --bg-3:        #232a3d;
  --border:      #2a3147;
  --text:        #e6e9ef;
  --text-muted:  #7d869c;
  --accent:      #ffd43b;       /* yellow */
  --accent-2:    #4c8bff;       /* blue (past trends) */
  --bid:         #22c55e;       /* green */
  --ask:         #ef4444;       /* red */
  --grid:        #1f2638;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg-0);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.muted { color: var(--text-muted); font-weight: 400; }

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.4px;
}
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
}
.ctrl {
  display: flex;
  flex-direction: column;
  font-size: 11px;
  color: var(--text-muted);
}
.ctrl-wide { min-width: 220px; }
.ctrl select, .ctrl input[type="range"] {
  margin-top: 3px;
}
select, input, button {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  font-family: inherit;
}
select:focus, input:focus, button:focus { outline: 1px solid var(--accent); }
.btn {
  cursor: pointer;
  padding: 6px 12px;
}
.btn-primary {
  background: var(--accent);
  color: #1a1a1a;
  border-color: var(--accent);
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.05); }

.status { display: flex; align-items: center; gap: 6px; }
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.dot-on  { background: var(--bid);  box-shadow: 0 0 6px var(--bid); }
.dot-off { background: var(--ask);  box-shadow: 0 0 6px var(--ask); }
.dot-warn{ background: var(--accent);box-shadow: 0 0 6px var(--accent); }

/* ---- Grid layout ---- */
.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 480px 1fr;
  grid-template-rows: 2fr 1fr;
  gap: 12px;
  padding: 12px;
  min-height: 0;
}
.panel {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-orderbook { grid-row: 1 / 3; }
.panel-chart     { grid-column: 2; grid-row: 1; }
.panel-curve     { grid-column: 2; grid-row: 2; }
.panel-subhead {
  padding: 6px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}
.spread-ctrls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ---- Order book (all-contracts table) ---- */
.ob-table-wrap {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}
.ob-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "SF Mono", "Menlo", monospace;
  font-size: 11.5px;
}
.ob-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-2);
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 9.5px;
  letter-spacing: 0.4px;
  font-weight: 500;
  padding: 7px 7px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  line-height: 1.2;
}
.ob-table tbody td {
  padding: 5px 7px;
  border-bottom: 1px solid #181d2a;
  white-space: nowrap;
}
.ob-table tbody tr:hover { background: var(--bg-2); }
.ob-table .num         { text-align: right; }
.ob-table .col-symbol  { color: var(--text); font-weight: 500; }
.ob-table .col-bid     { color: var(--bid); }
.ob-table .col-ask     { color: var(--ask); }
.ob-table .col-vol     { color: var(--text-muted); }
.ob-table .col-spread,
.ob-table .col-mid     { color: var(--text); }

/* ---- Charts ---- */
.chart-canvas, .curve-canvas {
  flex: 1;
  min-height: 0;
}
.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--text-muted);
}
.legend-item { display: flex; align-items: center; gap: 5px; }
.swatch {
  display: inline-block;
  width: 14px;
  height: 2px;
}
.swatch-yellow { background: var(--accent); }
.swatch-blue   { background: var(--accent-2); }
.swatch-long   { background: rgba(34, 197, 94, 0.5); height: 8px; width: 14px; }
.swatch-short  { background: rgba(239, 68, 68, 0.5); height: 8px; width: 14px; }

.curve-ctrls {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* ---- Bottom bar ---- */
.botbar {
  padding: 6px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-1);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ---- Range slider ---- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  width: 100%;
  padding: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: var(--bg-3);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  margin-top: -5px;
  cursor: pointer;
}
