:root {
  --bg: #0b0e11;
  --panel: #12161c;
  --panel-2: #1a1f27;
  --ink: #eaecef;
  --muted: #848e9c;
  --line: #2b3139;
  --buy: #0ecb81;
  --sell: #f6465d;
  --warn: #f0b90b;
  --accent: #f0b90b;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
}

.shell {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 100vh;
}

.rail {
  border-right: 1px solid var(--line);
  background: #0d1116;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 0.65rem; align-items: center; padding: 0 0.35rem; }
.brand-mark {
  width: 2rem; height: 2rem;
  display: grid; place-items: center;
  background: var(--accent); color: #111;
  font-family: var(--mono); font-weight: 700; font-size: 0.75rem;
  border-radius: 4px;
}
.brand-name { font-weight: 700; letter-spacing: -0.02em; }
.brand-sub { font-size: 0.7rem; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.nav-link {
  text-decoration: none; color: var(--muted);
  padding: 0.55rem 0.7rem; border-radius: 4px;
  font-weight: 600; font-size: 0.9rem;
}
.nav-link:hover { color: var(--ink); background: var(--panel-2); }
.nav-link.is-active {
  color: var(--ink);
  background: var(--panel-2);
  box-shadow: inset 2px 0 0 var(--accent);
}

.rail-foot { font-size: 0.72rem; color: var(--muted); padding: 0 0.4rem; }

.main { padding: 0.85rem 1rem 1.5rem; max-width: 1400px; }
.top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--line); padding-bottom: 0.65rem;
}
.top h1 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.top-meta { font-size: 0.78rem; color: var(--muted); display: flex; gap: 0.4rem; flex-wrap: wrap; }

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.85rem 1rem;
  border-radius: 4px;
}
.panel h2 {
  margin: 0 0 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.metric {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
}
.metric.sm { font-size: 1rem; }
.muted { color: var(--muted); }
.good { color: var(--buy); }
.bad { color: var(--sell); }
.warn { color: var(--warn); }

.pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-2);
  color: var(--ink);
}
.pill.ok { border-color: rgba(14,203,129,0.4); color: var(--buy); }
.pill.paper { border-color: rgba(240,185,11,0.45); color: var(--warn); }
.pill.kill { border-color: rgba(246,70,93,0.45); color: var(--sell); }
.pill.rej { border-color: rgba(240,185,11,0.35); color: var(--warn); }

/* —— Bybit-like desk —— */
.desk { display: flex; flex-direction: column; gap: 0.65rem; }

.ticker-bar {
  display: grid;
  grid-template-columns: 1.4fr repeat(5, minmax(0, 1fr));
  gap: 0.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.65rem 0.75rem;
  align-items: center;
}
.ticker-pair { display: flex; gap: 0.4rem; }
.pair-select, .tf-select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--mono);
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  border-radius: 3px;
}
.label { display: block; font-size: 0.68rem; color: var(--muted); margin-bottom: 0.15rem; }
.ticker-price strong, .ticker-stat strong {
  font-family: var(--mono);
  font-size: 0.95rem;
}

.desk-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 0.65rem;
  min-height: 420px;
}

.chart-panel, .trade-panel, .bottom-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.chart-panel { padding: 0.5rem 0.6rem 0.7rem; display: flex; flex-direction: column; }
.chart-head {
  display: flex; justify-content: space-between;
  font-size: 0.78rem; color: var(--muted); margin-bottom: 0.35rem;
}
#cc-chart {
  width: 100%;
  height: 340px;
  background: #0a0d11;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.chart-legend {
  display: flex; gap: 0.75rem; align-items: center;
  margin-top: 0.4rem; font-size: 0.75rem;
}
.leg.up::before, .leg.down::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 0.3rem; border-radius: 1px;
}
.leg.up::before { background: var(--buy); }
.leg.down::before { background: var(--sell); }

.trade-panel { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.55rem; }
.trade-tabs { display: flex; gap: 0.5rem; border-bottom: 1px solid var(--line); padding-bottom: 0.45rem; }
.trade-tabs .tab { font-size: 0.82rem; font-weight: 700; }
.trade-tabs .tab.on { color: var(--accent); box-shadow: inset 0 -2px 0 var(--accent); padding-bottom: 0.35rem; }
.trade-block .help { margin: 0; font-size: 0.78rem; color: var(--muted); line-height: 1.4; }
.check {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; color: var(--muted); margin-top: 0.45rem; cursor: pointer;
}

.btn-buy, .btn-sell, .btn-ghost, button, .btn {
  font-family: var(--sans);
  font-weight: 700;
  border: none;
  border-radius: 4px;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  width: 100%;
  font-size: 0.92rem;
}
.btn-buy { background: var(--buy); color: #04140d; }
.btn-sell { background: var(--sell); color: #fff; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}
.btn-buy:hover, .btn-sell:hover { filter: brightness(1.08); }
.btn-row-desk { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.35rem; }
.btn-row-desk .sm, button.sm { padding: 0.45rem 0.35rem; font-size: 0.75rem; }
.btn-row-desk:has(.btn-sell) { grid-template-columns: 1fr 1fr; }

.strat-list { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.35rem 0; }
.strat-list .check { align-items: flex-start; }
.strat-list .check span { line-height: 1.25; }
.strat-group-title {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 0.4rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}
.brain-list {
  max-height: 210px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-2);
  padding: 0.4rem 0.5rem;
}
.brain-list .check strong { color: var(--accent); }
.slot-box {
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--panel-2);
  padding: 0.4rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 140px;
  overflow: auto;
}
.slot-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-family: var(--mono);
}
.trade-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin-top: 0.25rem;
}
.trade-stats div {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 0.4rem 0.5rem;
}
.trade-stats span { display: block; font-size: 0.68rem; color: var(--muted); }
.trade-stats strong { font-family: var(--mono); font-size: 0.95rem; }

.msg {
  margin: 0.2rem 0 0;
  padding: 0.5rem 0.55rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 0.78rem;
  font-weight: 600;
}
.msg.good { border-color: rgba(14,203,129,0.35); color: var(--buy); }
.msg.bad { border-color: rgba(246,70,93,0.35); color: var(--sell); }
.sm { font-size: 0.78rem; }

.bottom-panel { padding: 0.5rem 0.65rem 0.75rem; }
.bottom-tabs { display: flex; gap: 0.25rem; margin-bottom: 0.45rem; }
.btab {
  width: auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
}
.btab.on { color: var(--ink); border-color: var(--line); background: var(--panel-2); }
.tab-pane { display: none; max-height: 220px; overflow: auto; }
.tab-pane.on { display: block; }

.desk-table, table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
th, td {
  text-align: left;
  padding: 0.4rem 0.35rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  position: sticky; top: 0; background: var(--panel);
}
td.mono, .mono { font-family: var(--mono); font-size: 0.78rem; }

.help { color: var(--muted); line-height: 1.4; }
.note { margin-top: 0.5rem; font-size: 0.8rem; color: var(--muted); }
.note a { color: var(--accent); font-weight: 600; }
.empty {
  padding: 1rem;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 0.85rem;
}
.plain-list { margin: 0; padding-left: 1.1rem; line-height: 1.55; }
.steps { margin: 0; padding-left: 1.2rem; line-height: 1.6; }
.details { margin-top: 0.5rem; }
.details summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.gate-row { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.gate {
  font-weight: 700; font-size: 0.8rem;
  padding: 0.35rem 0.55rem; border: 1px solid var(--line); border-radius: 3px;
}
.gate.on { color: var(--buy); border-color: rgba(14,203,129,0.4); }
.gate.off { color: var(--sell); border-color: rgba(246,70,93,0.4); }
.gate-list { margin: 0.35rem 0 0; padding-left: 1.1rem; font-size: 0.78rem; }
.gate-list li.ok { color: var(--buy); }
.gate-list li.bad { color: var(--sell); }
.actions { display: flex; flex-wrap: wrap; gap: 0.55rem; align-items: end; }
label {
  display: flex; flex-direction: column; gap: 0.25rem;
  font-size: 0.75rem; color: var(--muted); font-weight: 600;
}
label.check { flex-direction: row; align-items: center; font-weight: 500; }
input[type="text"], select {
  font-family: var(--mono);
  border: 1px solid var(--line);
  background: var(--panel-2);
  padding: 0.45rem 0.55rem;
  color: var(--ink);
  border-radius: 3px;
}
button.danger { background: var(--sell); color: #fff; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
pre.mono { white-space: pre-wrap; word-break: break-word; margin: 0; }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .desk-grid { grid-template-columns: 1fr; }
  .ticker-bar { grid-template-columns: 1fr 1fr; }
  .grid, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-2, .span-4 { grid-column: span 2; }
}
@media (max-width: 560px) {
  .grid, .grid-2, .grid-3, .ticker-bar { grid-template-columns: 1fr; }
  .span-2, .span-4 { grid-column: span 1; }
}
