:root {
  --bg: #0b0e14;
  --panel: #12161f;
  --border: #1e2430;
  --text: #d7dce5;
  --muted: #7a8496;
  --up: #f6465d;
  --down: #2ebd85;
  --accent: #f0b90b;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- header ---- */
header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.brand { font-size: 20px; font-weight: 700; color: var(--accent); }
.brand span { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.price-block { display: flex; align-items: baseline; gap: 10px; }
.last { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.last.up { color: var(--up); }
.last.down { color: var(--down); }
.change { font-size: 15px; font-weight: 600; }
.change.up { color: var(--up); }
.change.down { color: var(--down); }
.stats { display: flex; gap: 20px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; font-size: 12px; }
.stat label { color: var(--muted); }
.stat span { font-variant-numeric: tabular-nums; }
.conn { margin-left: auto; font-size: 18px; color: var(--muted); }
.conn.ok { color: var(--down); }
.conn.bad { color: var(--up); }

/* ---- layout ---- */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 12px;
  padding: 12px 20px;
  min-height: 0;
}
.chart-box {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.intervals { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--border); }
.intervals button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.intervals button:hover { color: var(--text); }
.intervals button.active { background: #1c2230; color: var(--accent); border-color: var(--border); }
.hist-status { margin-left: auto; font-size: 12px; color: var(--muted); padding: 4px 8px; }
#chart { flex: 1; min-height: 420px; }
.chart-msg {
  position: absolute;
  inset: 42px 0 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  pointer-events: none;
}
.chart-msg.hide { display: none; }

/* ---- order book ---- */
.side {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  overflow-y: auto;
}
.side h3 { font-size: 13px; color: var(--muted); margin: 8px 0; font-weight: 600; }
.book { font-variant-numeric: tabular-nums; font-size: 13px; }
.book-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 6px;
  position: relative;
}
.book-row.head { color: var(--muted); font-size: 12px; }
.book-row .depth {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  opacity: .12;
  pointer-events: none;
}
.ask .px { color: var(--up); }
.bid .px { color: var(--down); }
.ask .qty, .bid .qty { color: var(--text); z-index: 1; }
.ask .px, .bid .px { z-index: 1; }
.spread {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 4px 0;
}
.note { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.note b { color: var(--text); }
.note.muted { opacity: .8; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 10px;
  border-top: 1px solid var(--border);
}

@media (max-width: 860px) {
  main { grid-template-columns: 1fr; }
  .side { max-height: 40vh; }
  .stats { gap: 12px; }
  .last { font-size: 22px; }
}
