:root {
  --bg: #0b0e14;
  --panel: #141a24;
  --panel2: #1b2330;
  --line: #232c3b;
  --txt: #e6edf3;
  --muted: #8b97a7;
  --accent: #f5a623;
  --green: #2ecc71;
  --red: #ff5d5d;
  --blue: #4aa3ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
}

/* ── 顶栏 ── */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: linear-gradient(90deg, #141a24, #0f141d);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #e8590c); color: #1a1205;
  font-weight: 800; font-size: 22px;
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: .5px; }
.brand .sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.brand .sub em { color: var(--accent); font-style: normal; }

.controls { display: flex; align-items: center; gap: 10px; }
.controls select {
  background: var(--panel2); color: var(--txt); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 13px;
}
.btn {
  border: none; border-radius: 8px; padding: 9px 16px; font-weight: 600;
  cursor: pointer; font-size: 13px; transition: .15s;
}
.btn.start { background: var(--green); color: #04210f; }
.btn.stop { background: var(--red); color: #2a0606; }
.btn.flat { background: #7a2222; color: #ffd9d9; border: 1px solid var(--red); }
.btn.test { background: var(--panel2); color: var(--blue); border: 1px solid var(--blue); }
.sym-input {
  background: var(--panel2); color: var(--txt); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; width: 110px; text-transform: uppercase;
}
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn:not(:disabled):hover { filter: brightness(1.12); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: #555; box-shadow: none; }

main { padding: 18px 20px; max-width: 1500px; margin: 0 auto; }

/* ── 状态卡片 ── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.card label { color: var(--muted); font-size: 12px; display: block; }
.card b { font-size: 24px; display: block; margin-top: 4px; font-variant-numeric: tabular-nums; }
.card small { color: var(--muted); font-size: 11px; }
.card.halt b { color: var(--green); }
.card.halt.tripped { border-color: var(--red); }
.card.halt.tripped b { color: var(--red); }
.num.pos { color: var(--green); }
.num.neg { color: var(--red); }

/* ── 网格面板 ── */
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  min-height: 220px;
}
.panel.wide { grid-column: 1 / -1; }
.panel h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.pill {
  background: var(--panel2); color: var(--muted); border-radius: 20px; padding: 2px 10px; font-size: 11px;
}
.pill.live { color: var(--green); }
#equityChart { width: 100%; max-height: 300px; }

/* ── 表格 ── */
.table-wrap { overflow: auto; max-height: 320px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--panel); }
td.empty, tr.empty td { text-align: center; color: var(--muted); }

/* ── 事件流 ── */
.event-log { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow: auto; }
.event-log li {
  display: flex; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--line); font-size: 12.5px;
  align-items: baseline;
}
.event-log .t { color: var(--muted); font-size: 11px; min-width: 56px; }
.event-log .tag { border-radius: 5px; padding: 1px 7px; font-size: 11px; font-weight: 600; min-width: 52px; text-align: center; }
.tag.open { background: rgba(74,163,255,.15); color: var(--blue); }
.tag.exit { background: rgba(46,204,113,.15); color: var(--green); }
.tag.filter, .tag.reject { background: rgba(139,151,167,.15); color: var(--muted); }
.tag.halt, .tag.error { background: rgba(255,93,93,.18); color: var(--red); }
.tag.signal { background: rgba(245,166,35,.15); color: var(--accent); }
.tag.status { background: rgba(255,255,255,.07); color: var(--txt); }

/* ── 策略面板 ── */
.strategy-box { font-size: 12.5px; line-height: 1.7; }
.strategy-box .row { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding: 3px 0; }
.strategy-box .row span:first-child { color: var(--muted); }
.strategy-box .grp { color: var(--accent); font-weight: 600; margin: 8px 0 2px; }

footer {
  text-align: center; color: var(--muted); font-size: 12px; padding: 18px; border-top: 1px solid var(--line);
  margin-top: 12px;
}

/* ── 响应式: 平板(≤900) ── */
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; gap: 10px; align-items: stretch; }
  .controls { flex-wrap: wrap; justify-content: flex-start; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  main { padding: 14px 12px; }
}

/* ── 响应式: 手机(≤600) ── */
@media (max-width: 600px) {
  body { font-size: 13px; }
  .topbar { padding: 10px 12px; }
  .brand .logo { width: 34px; height: 34px; font-size: 18px; }
  .brand h1 { font-size: 16px; }
  .brand .sub { font-size: 11px; }
  .controls { gap: 8px; }
  .controls select { flex: 1 1 44%; padding: 10px; font-size: 14px; }
  .controls .btn { flex: 1 1 30%; padding: 11px 8px; font-size: 14px; min-height: 44px; }
  #ws-dot { order: -1; align-self: center; }
  .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card { padding: 10px 12px; }
  .card b { font-size: 20px; }
  .panel { padding: 12px; min-height: 0; }
  #equityChart { max-height: 220px; }
  th, td { padding: 6px 6px; font-size: 12px; }
  .event-log li { font-size: 12px; }
  .strategy-box { font-size: 12px; }
  footer { font-size: 11px; padding: 14px 12px; }
}

/* ── 触控设备: 更大点击区 ── */
@media (hover: none) {
  .btn { min-height: 40px; }
  .controls select { min-height: 40px; }
}
