/* =====================================================================
   HaoQuantX · 深邃终端主题
   ===================================================================== */
:root {
  --bg:     #0a0d12;   /* 页面底 */
  --panel:  #10141c;   /* 卡片/面板 */
  --panel2: #161d29;   /* 输入框/浮层 */
  --panel3: #0d1119;   /* 深一层面板（状态/代码） */
  --line:   #1f2836;   /* 边框/分隔线 */
  --line2:  #2a3547;   /* 强边框 */
  --text:   #dbe3ee;   /* 主文本 */
  --muted:  #6b7a94;   /* 次要文本 */
  --faint:  #48546b;   /* 弱文本/占位 */
  --accent: #22d3ee;   /* 青色荧光主强调 */
  --accent-dim: rgba(34, 211, 238, .14);
  --green:  #2dd48a;   /* 涨 */
  --red:    #f2555a;   /* 跌 */
  --amber:  #f5a623;   /* 警示/模拟盘 */
  --mono: "SF Mono", "JetBrains Mono", "Menlo", Consolas, monospace;
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  /* 兼容旧引用：--card/--border/--bg3 对齐现有面板色（曾未定义导致卡片透明无边框） */
  --card:  #10141c;    /* = --panel */
  --border: #1f2836;   /* = --line */
  --bg3:  #0d1119;     /* = --panel3 */
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* =====================================================================
   顶部条
   ===================================================================== */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 18px; height: 54px;
  background: linear-gradient(180deg, #0e141d, #0a0d12);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; user-select: none; }
.brand-mark {
  color: var(--accent);
  font-size: 13px;
  text-shadow: 0 0 10px var(--accent);
  animation: pulse 3s ease-in-out infinite;
}
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: 1px; }
.brand-name em { font-style: normal; color: var(--accent); font-weight: 500; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }

.top-ticker {
  display: flex; align-items: baseline; gap: 12px;
  padding: 5px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
}
.ticker-inst { font-size: 12px; color: var(--muted); letter-spacing: .5px; }
.ticker-price { font-size: 17px; font-weight: 600; color: var(--accent); }
.ticker-chg { font-size: 13px; font-weight: 600; }

.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
/* 顶栏工具控件统一高度 + 分组 */
.topbar-right .lang-switch,
.topbar-right .ui-mode-switch,
.topbar-right .badge,
.topbar-right .btn-small {
  height: 28px; box-sizing: border-box;
}
.topbar-right .lang-switch { height: 28px; }
/* 状态组：徽章 + WS */
.topbar-right .badge { display: inline-flex; align-items: center; line-height: 1; }
/* 登出按钮：紧凑幽灵风格 */
.topbar-right .btn-small {
  padding: 0 14px; font-size: 12px; font-weight: 600;
  background: var(--panel2); border: 1px solid var(--line);
  color: var(--muted); border-radius: 7px;
}
.topbar-right .btn-small:hover {
  color: var(--red); border-color: var(--red);
  background: rgba(242,85,90,.08); filter: none; transform: none;
}
/* 语言切换：紧凑 */
.topbar-right .lang-switch { padding: 0 8px; font-size: 12px; }
/* 简单/复杂 + AI 开关：紧凑胶囊 */
.topbar-right .ui-mode-switch { padding: 0 8px; gap: 5px; }

.badge {
  padding: 3px 10px; border-radius: 20px; font-size: 12px;
  background: var(--panel2); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}
.badge-demo { color: var(--amber); border-color: rgba(245,166,35,.4); background: rgba(245,166,35,.08); }
.badge-live { color: var(--red); border-color: rgba(242,85,90,.45); background: rgba(242,85,90,.08); }
.badge-running { color: var(--green); border-color: rgba(45,212,138,.45); background: rgba(45,212,138,.08); }
.badge-warn { color: var(--amber); border-color: rgba(245,166,35,.55); background: rgba(245,166,35,.15); }
.ws-badge { display: inline-flex; align-items: center; gap: 6px; }

/* 账户简单模式警告（acct_lv=1 时合约下单被拒） */
.acct-warn {
  grid-column: 1 / -1; margin-top: 4px; padding: 6px 10px; border-radius: 6px;
  font-size: 12px; color: var(--amber);
  background: rgba(245,166,35,.1); border: 1px solid rgba(245,166,35,.35);
}

/* 总本金/总仓位上限联动提示 */
.linkage-hint {
  margin-top: 6px; padding: 6px 10px; border-radius: 6px;
  font-size: 12px; color: var(--muted);
  background: var(--panel2); border: 1px dashed var(--line);
}
.linkage-hint.warn {
  color: var(--amber);
  background: rgba(245,166,35,.08); border: 1px solid rgba(245,166,35,.4);
}

.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted);
}
.badge-running .dot { animation: blink 1.8s ease-in-out infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

/* 简单/复杂模式开关 */
.ui-mode-switch {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 20px; padding: 3px 10px; cursor: pointer;
  user-select: none;
}
.ui-mode-switch .mode-label {
  font-size: 11px; color: var(--faint); font-weight: 600;
  transition: color .15s;
}
.ui-mode-switch .mode-slider {
  position: relative; width: 26px; height: 14px;
  background: var(--bg3); border-radius: 8px; border: 1px solid var(--line);
  transition: background .15s;
}
.ui-mode-switch .mode-knob {
  position: absolute; top: 1px; left: 1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--muted);
  transition: transform .18s ease, background .15s;
}
.ui-mode-switch[data-mode="advanced"] .mode-knob {
  transform: translateX(12px);
  background: var(--accent);
  box-shadow: 0 0 6px rgba(34,211,238,.5);
}
.ui-mode-switch[data-mode="advanced"] .mode-label[data-mode="advanced"] { color: var(--accent); }
.ui-mode-switch[data-mode="simple"] .mode-label[data-mode="simple"] { color: var(--text); }

/* AI 总开关：开（on）高亮 */
.ui-mode-switch[data-mode="on"] .mode-knob {
  transform: translateX(12px);
  background: var(--accent);
  box-shadow: 0 0 6px rgba(34,211,238,.5);
}
.ui-mode-switch[data-mode="on"] .mode-label[data-mode="on"] { color: var(--accent); }
.ui-mode-switch[data-mode="off"] .mode-label[data-mode="off"] { color: var(--text); }

/* 语言切换下拉 */
.lang-switch {
  background: var(--panel2); border: 1px solid var(--line2);
  border-radius: 7px; padding: 6px 8px; cursor: pointer;
  font-size: 12.5px; color: var(--text);
  max-width: 110px; flex: 0 0 auto;
}

/* =====================================================================
   侧边栏
   ===================================================================== */
.body-wrap { display: flex; flex: 1; min-height: 0; }

.sidebar {
  width: 172px; flex-shrink: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 10px;
  display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto;
}
/* 侧边栏顶部品牌区 */
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 2px 10px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}
.sidebar-logo {
  color: var(--accent); font-size: 16px;
  text-shadow: 0 0 10px var(--accent);
  animation: pulse 3s ease-in-out infinite;
  flex-shrink: 0;
}
.sidebar-brand-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sidebar-title { font-size: 13.5px; font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
.sidebar-title em { font-style: normal; color: var(--accent); font-weight: 500; }
.sidebar-sub { font-size: 10.5px; color: var(--faint); white-space: nowrap; }
/* 侧边栏底部用户区 */
.user-block {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px;
}
.user-avatar {
  width: 32px; height: 32px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-dim); color: var(--accent);
  font-weight: 700; font-size: 14px; border-radius: 50%;
}
.user-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: 1.5px;
  color: var(--faint); text-transform: uppercase;
  padding: 0 10px 6px;
}
.tab {
  display: flex; align-items: center; gap: 8px;
  background: none; border: none; color: var(--muted);
  padding: 8px 12px; font-size: 13.5px; cursor: pointer;
  border-radius: 7px; text-align: left;
  transition: all .16s ease;
  position: relative;
}
.tab::before {
  content: ""; width: 3px; height: 0; border-radius: 3px;
  background: var(--accent); position: absolute; left: 0;
  transition: height .16s ease;
}
.tab:hover { color: var(--text); background: var(--panel2); }
.tab.active {
  color: var(--accent); background: var(--accent-dim);
  font-weight: 600;
}
.tab.active::before { height: 16px; }

.sidebar-foot { margin-top: auto; padding: 8px 10px 0; }
.env-chip {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--faint);
}
.env-chip .dot { background: var(--green); }
.about-link {
  display: block; margin-top: 10px; padding: 6px 10px;
  font-size: 11.5px; color: var(--faint); text-decoration: none;
  border-radius: 7px;
}
.about-link:hover { color: var(--accent); background: var(--panel2); text-decoration: none; }

/* ---- 管理端（/admin）布局 ---- */
.admin-content { max-width: 1100px; }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.admin-grid .card { margin: 0; }
.guard-box {
  max-width: 420px; margin: 120px auto; text-align: center; padding: 40px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
}
.guard-box p { color: var(--muted); margin: 0 0 20px; }
@media (max-width: 768px) { .admin-grid { grid-template-columns: 1fr; } }

/* ---- 首次使用引导（空态） ---- */
.empty-guide {
  padding: 28px; background: var(--panel); border: 1px dashed var(--line2);
  border-radius: 10px; text-align: left;
}
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 14px; }
.empty-steps { margin: 0 0 16px; padding-left: 20px; color: var(--muted); font-size: 14px; }
.empty-steps li { margin: 6px 0; }

/* 首启引导卡（仪表盘顶部 3 步清单） */
.onboarding-card { margin-bottom: 14px; border-left: 3px solid var(--accent); }
.onboarding-card .card-head { display: flex; justify-content: space-between; align-items: center; }
.onb-steps { list-style: none; margin: 8px 0 0; padding: 0; }
.onb-step { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.onb-step:last-child { border-bottom: none; }
.onb-n {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--panel2); border: 1px solid var(--line2);
  color: var(--accent); font-family: var(--mono); font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.onb-txt { flex: 1; color: var(--text); }
.onb-done { color: var(--green); font-weight: 600; flex: none; }

/* 策略创建分步向导 */
.strat-steps { display: flex; gap: 8px; margin: 14px 0 4px; flex-wrap: wrap; }
.strat-step-dot {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--faint); font-size: 13px;
  padding: 4px 10px; border-radius: 20px;
  background: var(--panel2); border: 1px solid var(--line2);
}
.strat-step-dot .n {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--panel3); color: var(--muted);
  font-family: var(--mono); font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.strat-step-dot.active { color: var(--text); border-color: var(--accent); }
.strat-step-dot.active .n { background: var(--accent); color: #04151a; }
.strat-step-dot.done { color: var(--green); }
.strat-step-dot.done .n { background: var(--green); color: #04151a; }
.strat-step .btn-row { margin-top: 14px; }

/* =====================================================================
   内容区
   ===================================================================== */
.content { flex: 1; padding: 22px; max-width: 1300px; min-width: 0; }
.panel { display: none; }
.panel.active { display: block; animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.panel-head h2 { font-size: 17px; margin: 0; letter-spacing: .3px; }
.head-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* 时间周期按钮组（对标 OKX 周期切换器） */
.tf-toggle {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px;
}
.tf-btn {
  padding: 5px 12px; font-size: 12px; font-weight: 600;
  color: var(--muted); background: transparent; border: none;
  border-radius: 6px; cursor: pointer; line-height: 1.2;
  transition: all .15s ease;
}
.tf-btn:hover { color: var(--text); }
.tf-btn.active { background: var(--accent); color: #0a0d12; }

/* 选币：搜索框 + 下拉 */
.inst-picker { display: flex; align-items: center; gap: 6px; }
.inst-search {
  padding: 5px 10px; font-size: 12.5px;
  background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; width: 110px;
}
.inst-search:focus { border-color: var(--accent); outline: none; }
.inst-search::placeholder { color: var(--faint); }

/* 热门币 chips（对标 OKX 顶部快捷币切换） */
.hot-coins {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 12px;
}
/* 量化信号：多空建议 + 信号面板（右信息栏顶部，纵向叠放） */
.signal-strip {
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: 0;
}
.signal-strip .regime-card {
  margin-bottom: 0;
  background: linear-gradient(180deg, var(--panel), var(--panel2));
}
@media (max-width: 900px) { .signal-strip { grid-template-columns: 1fr; } }
.coin-chip {
  padding: 4px 12px; font-size: 12.5px; font-weight: 600;
  background: var(--panel); border: 1px solid var(--line);
  color: var(--muted); border-radius: 16px; cursor: pointer;
  transition: all .15s ease;
}
.coin-chip:hover { color: var(--text); border-color: var(--accent); }
.coin-chip.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }

/* 运行策略迷你条：仪表盘顶部实时状态 */
.strat-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; margin-bottom: 16px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; font-size: 12.5px;
}
.strat-strip-label {
  font-size: 11px; font-weight: 600; letter-spacing: 1px;
  color: var(--faint); text-transform: uppercase; flex-shrink: 0;
}
.strat-strip-body {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  color: var(--muted); flex: 1; min-width: 0;
}
.strat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 14px; font-size: 12px;
  background: var(--panel2); border: 1px solid var(--line);
  cursor: pointer; transition: border-color .15s;
}
.strat-chip:hover { border-color: var(--accent); }
.strat-chip .chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.strat-chip .chip-type { font-weight: 600; color: var(--text); }
.strat-chip .chip-inst { color: var(--muted); }
.strat-chip .chip-pnl { font-family: var(--mono); }
.strat-chip .chip-pnl.pos { color: var(--green); }
.strat-chip .chip-pnl.neg { color: var(--red); }


/* 卡片 */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px; margin-bottom: 16px;
  transition: border-color .18s ease, transform .18s ease, box-shadow .18s ease;
}
.card:hover {
  border-color: var(--line2);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.card-tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: 1px;
  color: var(--faint);
}
.sub-head { margin: 14px 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }
@media (max-width: 980px) { .ticker-strip { grid-template-columns: repeat(2, 1fr); } }

/* 激进版交易舱：K线主区 + 右信息栏（盘口/多空/信号/bot） */
.trade-deck { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 3fr) minmax(0, 1.6fr); gap: 14px; align-items: stretch; }
.deck-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.deck-main .deck-chart { flex: 1 1 auto; height: 480px; margin-bottom: 0; }
.deck-main .deck-bottom { }
/* 下单列（对标 OKX 左侧下单面板）：窄列纵向 + 下单|持仓 tab 切换 */
.deck-order { min-width: 0; }
.order-tabs {
  display: flex; gap: 4px; margin-bottom: 8px;
  padding: 3px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px;
}
.ot-tab {
  flex: 1; padding: 6px 0; font-size: 12.5px; font-weight: 600;
  color: var(--muted); background: transparent; border: none;
  border-radius: 6px; cursor: pointer; transition: all .15s ease;
}
.ot-tab:hover { color: var(--text); }
.ot-tab.active { background: var(--accent); color: #0a0d12; }
.ot-pane { display: none; }
.ot-pane.active { display: block; }
.deck-order .order-card { height: 100%; }
.deck-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.deck-side .card { flex: 1 1 auto; }
.deck-side .deck-book { flex: 0 0 auto; }
.deck-side .regime-card { overflow: hidden; }
@media (max-width: 1300px) { .trade-deck { grid-template-columns: minmax(0, 220px) minmax(0, 3fr) minmax(0, 1.6fr); } }
@media (max-width: 1100px) { .trade-deck { grid-template-columns: 1fr; } .deck-main .deck-chart { height: 360px; } }

/* 底部大区：当前仓位 / 当前委托（对标 OKX layout-md-bottom） */
.chart {
  width: 100%; height: 400px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 16px;
}
.muted { color: var(--muted); }

/* =====================================================================
   行情条
   ===================================================================== */
.ticker-strip {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 16px; margin-bottom: 12px;
}
.ticker-item { display: flex; flex-direction: column; gap: 2px; }
.ticker-item label { color: var(--muted); font-size: 10.5px; letter-spacing: .5px; }
.ticker-item span { font-size: 17px; font-weight: 600; font-family: var(--mono); }
.ticker-main span { font-size: 22px; color: var(--text); }
.ticker-item .up { color: var(--green); }
.ticker-item .down { color: var(--red); }

/* 价格闪烁 */
.flash-up { animation: flashUp .6s ease; }
.flash-down { animation: flashDown .6s ease; }
@keyframes flashUp { 0% { color: var(--green); } 100% { color: inherit; } }
@keyframes flashDown { 0% { color: var(--red); } 100% { color: inherit; } }

/* =====================================================================
   表单
   ===================================================================== */
.form-grid {
  display: grid; grid-template-columns: 1fr; gap: 0 18px;
  max-width: 520px;
}
/* 下单列表单：纵向窄列（仿 OKX 下单面板） */
.order-card { }
.order-form {
  display: grid; grid-template-columns: 1fr; gap: 10px;
  max-width: none;
}
.order-form .form-row {
  display: block; margin-bottom: 0;
}
.order-form .form-row label {
  display: block; margin-bottom: 4px;
  font-size: 11px; color: var(--muted);
}
.order-form .form-row select,
.order-form .form-row input[type="number"] {
  width: 100%; padding: 7px 10px;
  background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; font-size: 13px;
}
.order-form .form-row select:focus,
.order-form .form-row input:focus {
  border-color: var(--accent); outline: none;
}
.order-form .form-row input::placeholder { color: var(--faint); }
.order-form .btn-row {
  margin-top: 4px;
}
.order-form .hint {
  font-size: 11.5px; margin-top: 2px;
}
/* 下单区：买入/卖出 + 市价/限价 切换按钮（对标 OKX 下单面板） */
.hidden-select { display: none; }
.side-toggle, .type-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
}
.side-btn, .type-btn {
  padding: 8px 0; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel2); color: var(--muted); cursor: pointer;
  transition: all .15s ease;
}
.side-btn:hover, .type-btn:hover { color: var(--text); }
.side-btn.side-buy.active { background: rgba(45,212,138,.15); border-color: var(--green); color: var(--green); }
.side-btn.side-sell.active { background: rgba(242,85,90,.15); border-color: var(--red); color: var(--red); }
.type-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
/* 下单按钮：随方向变绿/红 */
.order-submit-buy { background: var(--green) !important; border-color: var(--green) !important; color: #0a0d12 !important; }
.order-submit-sell { background: var(--red) !important; border-color: var(--red) !important; color: #0a0d12 !important; }

/* form-row 用 grid：label 定宽列 + 控件列 + hint 跨整行，避免文字错位 */
.form-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 10px;
  margin-bottom: 8px;
}
.form-row label {
  color: var(--muted); flex-shrink: 0; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
select, input {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line2); border-radius: 7px;
  padding: 8px 11px; font-size: 13px; outline: none;
  width: 100%; min-width: 0;
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type="datetime-local"] { font-family: var(--mono); font-size: 12.5px; }
.param-form {
  margin: 14px 0 4px; padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.param-form .form-row { max-width: 520px; }

.mode-hint {
  margin-top: 10px; font-size: 12.5px; color: var(--muted);
}
.mode-hint a { color: var(--accent); text-decoration: none; cursor: pointer; }
.mode-hint a:hover { text-decoration: underline; }

.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; padding: 10px 4px 0; }
.pager .btn { padding: 6px 14px; font-size: 13px; }
.pager-info { color: var(--muted); font-size: 13px; font-family: var(--mono); }
.btn {
  padding: 9px 20px; border: none; border-radius: 7px;
  font-size: 14px; font-weight: 600; cursor: pointer; color: #fff;
  transition: all .16s ease;
}
.btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--accent); color: #04232a;
  box-shadow: 0 0 16px rgba(34,211,238,.25);
}
.btn-danger { background: var(--red); }
.btn-danger:hover { box-shadow: 0 0 16px rgba(242,85,90,.3); }
.btn-ghost {
  background: transparent; color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-ghost:hover { background: var(--accent-dim); }
.preset-btn { font-size: 12.5px; padding: 6px 12px; margin-top: 10px; }

/* 网格预设下拉 */
.preset-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 10px; max-width: 340px;
}
.preset-row .preset-label {
  color: var(--muted); font-size: 12.5px; flex-shrink: 0;
  width: 110px; text-align: right;
}
.preset-row select { flex: 1; }

/* 傻瓜式配置：分组标题 / 字段说明 / 单位 / 实时预览 */
.form-group-title {
  margin: 14px 0 6px; padding-left: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: 1px;
  color: var(--accent); border-left: 3px solid var(--accent);
  text-transform: uppercase;
}
.field-unit {
  font-size: 11.5px; color: var(--muted);
  white-space: nowrap; padding-left: 4px;
}
.field-hint {
  grid-column: 1 / -1;  /* 跨 label+控件+单位 整行，单独一行显示 */
  font-size: 11.5px; color: var(--muted);
  padding: 2px 0 4px 110px; line-height: 1.5;
}
.form-row input[type="text"] {
  background: var(--panel2); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px; padding: 6px 10px;
  font-size: 13px; width: 100%;
  box-sizing: border-box;
}
.preview-card {
  margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  background: var(--panel3); border: 1px solid var(--line);
}
.preview-title {
  font-size: 12px; font-weight: 600; color: var(--accent);
  margin-bottom: 8px; letter-spacing: 0.5px;
}
.preview-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}
.preview-item {
  background: var(--panel2); border-radius: 8px; padding: 8px 10px;
}
.preview-item label {
  display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px;
}
.preview-item b { font-size: 13px; color: var(--text); }

.msg { margin-top: 10px; color: var(--amber); font-size: 13px; min-height: 18px; }
.msg.err { color: var(--red); }
.msg.ok { color: var(--green); }

/* =====================================================================
   状态面板（结构化）
   ===================================================================== */
.status-panel {
  background: var(--panel3); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px; margin-bottom: 4px;
  font-size: 13px; line-height: 1.8;
  max-height: 340px; overflow-y: auto;
}
.status-panel .empty { color: var(--faint); }
.status-panel .kpi-row {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 12px;
}
.kpi {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px;
}
.kpi .k-label { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.kpi .k-value { font-size: 17px; font-weight: 600; font-family: var(--mono); }
.kpi .k-value.pos { color: var(--green); }
.kpi .k-value.neg { color: var(--red); }

/* 网格等级进度条 */
.grid-progress {
  margin-top: 4px;
}
.gp-track {
  height: 8px; border-radius: 5px; overflow: hidden;
  background: var(--panel2); border: 1px solid var(--line);
  margin-top: 6px;
}
.gp-fill {
  height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, #0ea5b7, var(--accent));
  transition: width .5s ease;
}
.gp-caption {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 5px;
}
.level-bar { display: flex; gap: 3px; margin-top: 10px; }
.level-cell {
  flex: 1; height: 12px; border-radius: 3px;
  background: var(--panel2); border: 1px solid var(--line);
}
.level-cell.filled { background: var(--accent-dim); border-color: var(--accent); }
.level-cell.pending { background: rgba(245,166,35,.25); border-color: var(--amber); }

.status-box {
  background: var(--panel3); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.8;
  overflow: auto; max-height: 150px;
  color: var(--muted);
  white-space: pre-wrap; word-break: break-all;
}

/* =====================================================================
   余额 / 持仓
   ===================================================================== */
.balance-list, .pos-list { list-style: none; margin: 0; padding: 0; }
.balance-list li, .pos-list li {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 8px 4px; border-bottom: 1px solid var(--line);
  font-size: 13px; font-family: var(--mono);
}
.balance-list li:last-child, .pos-list li:last-child { border-bottom: none; }
.pos-green { color: var(--green); }
.pos-red { color: var(--red); }

/* 账户权益汇总 */
.summary-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin-bottom: 6px;
}
.sum-cell {
  padding: 8px 10px; background: rgba(127,127,127,.07);
  border-radius: 6px; border: 1px solid rgba(127,127,127,.12);
}
.sum-cell label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.sum-cell b { font-family: var(--mono); font-size: 15px; color: var(--text); }
.sum-cell .sum-equity { font-size: 18px; color: var(--accent); }

/* 持仓筛选 + 完整表格 */
.pos-filter-row { margin-bottom: 8px; }
.pos-filter-row select {
  width: 100%; padding: 5px 8px; background: var(--bg);
  border: 1px solid rgba(127,127,127,.25); border-radius: 5px;
  color: var(--text); font-size: 12.5px;
}
.pos-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.pos-table th {
  text-align: left; padding: 4px 6px; color: var(--muted);
  border-bottom: 1px solid rgba(127,127,127,.25); font-weight: 600;
  white-space: nowrap;
}
.pos-table td {
  padding: 6px; border-bottom: 1px solid rgba(127,127,127,.08);
  font-family: var(--mono); white-space: nowrap;
}
.pos-table td .muted { font-size: 10.5px; }

/* 纪律搏杀 bot 状态卡片 */
.bot-state {
  display: inline-block; padding: 4px 10px; border-radius: 5px;
  font-size: 13px; font-weight: 700; font-family: var(--mono); margin-bottom: 8px;
}
.bot-running { background: rgba(34,197,94,.12); color: var(--green); }
.bot-stopped { background: rgba(127,127,127,.1); color: var(--muted); }
.tag-dry {
  margin-left: 6px; padding: 1px 6px; border-radius: 4px; font-size: 10px;
  background: rgba(255,165,0,.15); color: #ffa500; font-weight: 600;
}
.bot-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.bot-meta b { color: var(--text); font-family: var(--mono); }
.bot-actions { margin-bottom: 8px; display: flex; gap: 8px; }
.bot-actions .btn {
  padding: 5px 14px; border-radius: 5px; border: 1px solid rgba(127,127,127,.3);
  background: rgba(127,127,127,.1); color: var(--text); font-size: 12.5px;
  cursor: pointer;
}
.bot-actions .btn:hover { background: rgba(127,127,127,.2); }
.bot-actions .btn-danger { border-color: rgba(242,85,90,.5); color: var(--red); }
.bot-actions .btn-danger:hover { background: rgba(242,85,90,.12); }
/* 多 bot 并行卡片 */
.bot-card {
  background: var(--panel); border: 1px solid #1f2836; border-radius: 8px;
  padding: 10px 14px; margin-bottom: 10px;
}
.bot-card-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-size: 14px; color: var(--accent);
}
.bot-card-head .btn { padding: 3px 10px; font-size: 11.5px; }
.btn-sm { padding: 3px 10px; font-size: 11.5px; }


/* =====================================================================
   回测
   ===================================================================== */
.bt-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 22px;
}
@media (max-width: 980px) { .bt-grid { grid-template-columns: 1fr; } }
.progress {
  height: 8px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 5px; margin-top: 16px; overflow: hidden; display: none;
}
.progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #0ea5b7, var(--accent));
  box-shadow: 0 0 8px rgba(34,211,238,.5);
  transition: width .3s ease;
}
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 980px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 13px 15px;
}
.stat-card .stat-label { color: var(--muted); font-size: 11px; margin-bottom: 5px; letter-spacing: .5px; }
.stat-card .stat-value { font-size: 21px; font-weight: 700; font-family: var(--mono); }
.stat-green { color: var(--green); }
.stat-red { color: var(--red); }
.stat-cyan { color: var(--accent); }

/* =====================================================================
   设置 / 提示
   ===================================================================== */
.hint { color: var(--faint); font-size: 12px; line-height: 1.9; margin-top: 14px; }
.hint::before { content: "ℹ "; color: var(--accent); }

/* =====================================================================
   多空建议卡片
   ===================================================================== */
.regime-card .regime-dir {
  font-size: 26px; font-weight: 700; font-family: var(--mono);
  margin-bottom: 8px;
}
.regime-card .regime-meta {
  display: flex; gap: 20px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--muted);
}
.regime-card .regime-meta b { color: var(--text); font-family: var(--mono); }
.regime-card .regime-reverse {
  margin-top: 10px; padding: 8px 12px;
  background: rgba(242,85,90,.1); border: 1px solid rgba(242,85,90,.4);
  border-radius: 7px; color: var(--red); font-size: 12.5px;
}

/* 多周期信号面板 */
.verdict {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border-radius: 8px; margin-bottom: 10px;
  font-size: 22px; font-weight: 700; font-family: var(--mono);
}
.verdict .verdict-advice {
  font-size: 13px; font-weight: 500; font-family: var(--body, inherit);
  opacity: .9;
}
.verdict-long {
  background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.45);
  color: var(--green);
}
.verdict-short {
  background: rgba(242,85,90,.12); border: 1px solid rgba(242,85,90,.45);
  color: var(--red);
}
.verdict-watch {
  background: rgba(127,127,127,.08); border: 1px solid rgba(127,127,127,.3);
  color: var(--muted);
}
.regime-board-hint {
  font-size: 11.5px; color: var(--muted); margin-bottom: 8px; line-height: 1.5;
}
.regime-board {
  width: 100%; border-collapse: collapse; font-size: 12.5px;
}
.regime-board th {
  text-align: left; padding: 4px 8px; color: var(--muted);
  border-bottom: 1px solid rgba(127,127,127,.25); font-weight: 600;
}
.regime-board td {
  padding: 5px 8px; border-bottom: 1px solid rgba(127,127,127,.08);
  vertical-align: middle;
}
.regime-board .tf { font-family: var(--mono); color: var(--muted); }
.regime-board .dir { font-family: var(--mono); font-weight: 600; }
.regime-board .conf { font-family: var(--mono); }
.regime-board .hit { font-family: var(--mono); color: var(--muted); }
.regime-board .conf-bar {
  width: 56px; height: 5px; background: rgba(127,127,127,.15);
  border-radius: 3px; margin-top: 2px; overflow: hidden;
}
.regime-board .conf-bar i {
  display: block; height: 100%; background: var(--accent); border-radius: 3px;
}
.regime-board-ts {
  margin-top: 6px; font-size: 11.5px; color: var(--muted);
}

/* =====================================================================
   表格（成交明细 / 交易历史）
   ===================================================================== */
.trade-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--mono); font-size: 11.5px;
}
.trade-table th, .trade-table td {
  padding: 6px 8px; text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.trade-table th:first-child, .trade-table td:first-child { text-align: left; }
.trade-table thead th {
  color: var(--faint); font-weight: 600; font-size: 10.5px;
  letter-spacing: .5px; text-transform: uppercase;
}
.trade-table tbody tr:nth-child(even) { background: rgba(255,255,255,.015); }
.trade-table tbody tr:hover { background: var(--accent-dim); }
.trade-table.compact td { padding: 4px 6px; font-size: 11px; }
.trade-table .pos-green { color: var(--green); }
.trade-table .pos-red { color: var(--red); }

/* 回测成交明细折叠块 */
.bt-trades {
  grid-column: 1 / -1;
  margin-top: 4px;
  background: var(--panel3);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}
.bt-trades summary {
  cursor: pointer; color: var(--accent);
  font-size: 12.5px; font-weight: 600;
  user-select: none; padding: 2px 0;
}
.bt-trades summary:hover { text-decoration: underline; }
.bt-trades .trade-table { margin-top: 10px; }

/* =====================================================================
   图表加载骨架
   ===================================================================== */
.chart.loading { position: relative; overflow: hidden; }
.chart.loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(34,211,238,.06), transparent);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* =====================================================================
   响应式
   ===================================================================== */
@media (max-width: 820px) {
  .body-wrap { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; flex-wrap: wrap;
    gap: 4px; padding: 8px 10px;
    border-right: none; border-bottom: 1px solid var(--line);
  }
  .nav-group { flex-direction: row; align-items: center; }
  .nav-label { display: none; }
  .sidebar-foot { display: none; }
  .top-ticker .ticker-inst { display: none; }
  .content { padding: 14px; }
  .ticker-strip { grid-template-columns: repeat(2, 1fr); gap: 10px 0; }
  .chart { height: 300px; }
}

/* =====================================================================
   动效降级
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001s !important;
    transition-duration: .001s !important;
  }
}

/* =====================================================================
   多策略列表
   ===================================================================== */
.strategy-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
  margin-top: 10px;
  align-items: start;
}
@media (max-width: 820px) {
  .strategy-list { grid-template-columns: 1fr; }
}
.strategy-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  display: flex;
  flex-direction: column;
}
.strategy-card .card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.strategy-card .card-head h3 {
  font-size: 15px;
  margin: 0;
  flex: 1;
}
.strategy-card .card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.strategy-card .card-actions .btn {
  padding: 5px 12px;
  font-size: 12px;
}
.strategy-card .status-panel {
  margin-top: 10px;
}
/* 3Commas 风格：卡头精简摘要 + 可折叠详情 */
.sc-summary {
  display: flex; gap: 16px; margin: 10px 0 0;
  padding: 8px 10px; border-radius: 6px;
  background: var(--panel2); border: 1px solid var(--line);
}
.sc-sum { display: flex; flex-direction: column; gap: 2px; }
.sc-sum span { font-size: 11px; color: var(--muted); }
.sc-sum b { font-family: var(--mono); font-size: 14px; color: var(--text); }
.sc-body {
  max-height: 0; overflow: hidden;
  transition: max-height .25s ease;
}
.strategy-card.expanded .sc-body {
  max-height: 420px; overflow-y: auto;
}
.sc-toggle {
  margin-top: 8px; align-self: flex-start;
  background: none; border: 1px solid var(--line); border-radius: 6px;
  color: var(--muted); padding: 5px 10px; font-size: 12px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.sc-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* =====================================================================
   账户列表（设置页）
   ===================================================================== */
.account-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.account-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.account-item.active {
  border-color: var(--accent);
}
.account-item .acct-name {
  font-weight: 600;
  flex: 1;
}
.account-item .acct-env {
  color: var(--muted);
}
.account-item .acct-cred {
  color: var(--green);
}
.account-item .acct-cred[data-missing] {
  color: var(--red);
}
.account-item .btn {
  padding: 4px 10px;
  font-size: 12px;
}

/* =====================================================================
   AI 生成策略卡片
   ===================================================================== */
.ai-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.ai-tab {
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px; transition: all .15s;
}
.ai-tab:hover { color: var(--text); }
.ai-tab.active {
  color: var(--accent); border-color: var(--accent);
  background: var(--accent-dim); font-weight: 600;
}
.ai-pane textarea {
  width: 100%; box-sizing: border-box; background: var(--panel2);
  border: 1px solid var(--line2); border-radius: 7px; color: var(--text);
  padding: 10px; font-size: 13px; resize: vertical; font-family: inherit;
}
.ai-reason {
  margin: 10px 0; padding: 10px 12px; border-radius: 8px;
  background: var(--accent-dim); border: 1px solid rgba(34,211,238,.3);
  color: var(--text); font-size: 13px;
}
.ai-param-row {
  display: flex; gap: 10px; align-items: baseline; margin-bottom: 8px;
}
.ai-param-row .ai-type {
  font-weight: 700; color: var(--accent); font-size: 14px;
}
.ai-param-row .ai-inst { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.ai-params-preview {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px; margin-bottom: 10px;
}
.ai-param {
  display: flex; justify-content: space-between; gap: 8px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 10px; font-size: 12px;
}
.ai-param span { color: var(--muted); }
.ai-param b { font-family: var(--mono); }

/* =====================================================================
   盘口深度卡片
   ===================================================================== */
.book-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  align-items: stretch;
}
@media (max-width: 820px) { .book-grid { grid-template-columns: 1fr; } }
.book-table-wrap { min-width: 0; }
.book-table { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.book-col { display: flex; flex-direction: column; gap: 2px; }
.book-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 8px; border-radius: 4px; font-family: var(--mono); font-size: 12px;
}
.book-row .book-px { font-weight: 600; }
.book-row .book-sz { color: var(--muted); }
.book-chart-wrap { min-width: 0; height: 260px; border-radius: 8px;
  background: var(--panel3); border: 1px solid var(--line); }

/* =====================================================================
   策略卡增强：迷你因子条
   ===================================================================== */
.mini-bar {
  height: 4px; border-radius: 2px; margin-top: 4px;
  background: var(--panel2); border: 1px solid var(--line); overflow: hidden;
}
.mini-bar i { display: block; height: 100%; border-radius: 2px; }
.badge-running .dot { animation: blink 1.8s ease-in-out infinite; }

/* =====================================================================
   表格横向滚动容器（移动端防撑破）
   ===================================================================== */
.pos-table, .trade-table, .book-table {
  display: block; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.regime-board { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
button, select, input, textarea { touch-action: manipulation; }

/* =====================================================================
   交易终端专业感：报价条 / 卡片 / KPI 细化
   ===================================================================== */
.ticker-strip { grid-template-columns: repeat(4, 1fr); }
.ticker-item span { letter-spacing: .2px; }
.ticker-item .up, .ticker-item .down { font-weight: 700; }
.ticker-main span { background: linear-gradient(180deg, var(--text), var(--accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.card-head h3 { letter-spacing: .3px; }
.kpi { border: 1px solid var(--line); background: var(--panel2); }
.kpi .k-value { font-variant-numeric: tabular-nums; }
.sum-cell b { font-variant-numeric: tabular-nums; }
.pos-table td, .trade-table td { font-variant-numeric: tabular-nums; }

/* =====================================================================
   移动端细化
   ===================================================================== */
@media (max-width: 820px) {
  .topbar { gap: 10px; padding: 0 10px; height: 48px; }
  .top-ticker { padding: 3px 10px; }
  .top-ticker .ticker-inst { display: none; }
  .top-ticker .ticker-chg { display: none; }
  .brand-name { font-size: 13px; }
  .lang-switch { max-width: 60px; font-size: 11px; padding: 5px 6px; }
  .ui-mode-switch { padding: 2px 8px; }
  .content { padding: 12px; }
  .summary-grid { grid-template-columns: 1fr; }
  .book-grid { grid-template-columns: 1fr; }
  .book-chart-wrap { height: 180px; }
  .card { padding: 12px; }
  .kpi-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr; }
  .chart { height: 280px; }
}
@media (max-width: 980px) {
  .book-grid { grid-template-columns: 1fr; }
}

/* =====================================================================
   3Commas 风格：顶部资产条 + 侧边栏图标
   ===================================================================== */
.asset-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.asset-cell {
  display: flex; flex-direction: column; gap: 2px;
  padding: 4px 14px 4px 0; margin-right: 6px;
  border-right: 1px solid var(--line);
  min-width: 90px;
}
.asset-cell:last-of-type { border-right: none; }
.asset-cell label { font-size: 11px; color: var(--muted); }
.asset-cell b { font-family: var(--mono); font-size: 15px; color: var(--text);
  font-variant-numeric: tabular-nums; }
.asset-cell b.asset-equity { font-size: 18px; color: var(--accent); }
.asset-cell b.pos { color: var(--green); }
.asset-cell b.neg { color: var(--red); }
.asset-refresh {
  margin-left: auto; padding: 4px 10px; font-size: 14px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 6px; cursor: pointer; line-height: 1.2;
}
.asset-refresh:hover { color: var(--accent); border-color: var(--accent); }
/* 账户回撤停手红标（组合风控 kill-switch） */
.risk-off-badge {
  font-size: 12px; font-weight: 700; color: #fff;
  background: var(--red); border-radius: 6px; padding: 3px 10px;
  margin-right: 6px; white-space: nowrap;
  animation: risk-pulse 1.5s ease-in-out infinite;
}
@keyframes risk-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
/* 风险驾驶舱 + 实盘权益曲线（差异化产品面） */
.risk-off-banner {
  font-size: 12px; font-weight: 700; color: #fff; background: var(--red);
  border-radius: 6px; padding: 6px 10px; margin-bottom: 8px; text-align: center;
}
.cockpit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px;
}
.cockpit-cell {
  display: flex; flex-direction: column; gap: 1px; padding: 6px 8px;
  background: var(--panel2); border-radius: 6px;
}
.cockpit-cell label { font-size: 10px; color: var(--muted); }
.cockpit-cell b { font-family: var(--mono); font-size: 13px; color: var(--text);
  font-variant-numeric: tabular-nums; }
.cockpit-strats { display: flex; flex-direction: column; gap: 3px; max-height: 120px; overflow-y: auto; }
.cockpit-strat {
  display: flex; align-items: center; gap: 6px; font-size: 11px;
  padding: 3px 6px; background: var(--panel2); border-radius: 4px;
}
.cockpit-strat b { margin-left: auto; font-family: var(--mono); font-weight: 600; }
.equity-chart { width: 100%; height: 180px; }
/* 管理员面板（用户套餐管理） */
.admin-user-list { display: flex; flex-direction: column; gap: 6px; }

/* 操作审计日志 */
.admin-audit { display: flex; flex-direction: column; gap: 4px; max-height: 400px; overflow-y: auto; }
.audit-row { padding: 5px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit-row:last-child { border-bottom: none; }
.audit-row b { color: var(--text); }
.audit-action { color: var(--accent); font-family: var(--mono); font-size: 12px; }
.current-plan {
  padding: 8px 0; margin-bottom: 10px;
  border-bottom: 1px dashed var(--line); font-size: 13px;
}
.cur-plan-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 2px; }
.cur-plan-name { font-weight: 600; color: var(--accent); font-size: 16px; }
.admin-user-head, .admin-user-row {
  display: grid; grid-template-columns: 1.2fr 0.7fr 1fr 1.2fr 0.6fr auto;
  gap: 6px; align-items: center; font-size: 12px;
}
.admin-user-head { color: var(--muted); font-weight: 600; padding: 2px 4px; }
.admin-user-row {
  background: var(--panel2); border-radius: 6px; padding: 6px 8px;
}
.admin-uname { font-weight: 600; }
.admin-user-row select, .admin-user-row input {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  border-radius: 4px; padding: 3px 6px; font-size: 12px;
}
/* 激活码列表 */
.admin-code-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.admin-code-row {
  display: flex; align-items: center; gap: 8px; font-size: 12px;
  background: var(--panel2); border-radius: 4px; padding: 4px 8px;
}
.admin-code { font-family: var(--mono); color: var(--accent); letter-spacing: 1px; }
/* 全局市场切换（现货/合约），对标 OKX 顶部交易类型 tab */
.market-switch {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; margin-right: 6px; flex-shrink: 0;
}
.ms-tab {
  padding: 5px 14px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); background: transparent; border: none;
  border-radius: 6px; cursor: pointer; line-height: 1.2;
  transition: background .15s, color .15s;
}
.ms-tab:hover { color: var(--text); }
.ms-tab.active {
  background: var(--accent); color: #0a0d12;
}

/* 市场卡片「历史最好」次级指标：弱化显示，与主收益（全周期）区分 */
.metric-best .metric-label { font-style: italic; }
.metric-best .metric-val { color: var(--muted); }
.metric-best .hint { margin: 0; color: var(--faint); }

/* 付费风控对比表（回测面板） */
.rc-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.rc-table th, .rc-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.rc-table th { color: var(--muted); font-weight: 600; }
.rc-table td:first-child { color: var(--muted); }
.rc-table td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }

.nav-icon {
  width: 18px; font-size: 14px; color: var(--faint);
  text-align: center; flex-shrink: 0;
}
.tab.active .nav-icon { color: var(--accent); }

/* 窄屏：资产条允许换行 */
@media (max-width: 820px) {
  .asset-bar { flex-wrap: wrap; gap: 4px 12px; padding: 6px 12px; }
  .asset-cell { min-width: 72px; padding: 2px 10px 2px 0; margin-right: 0; }
  .asset-cell b.asset-equity { font-size: 15px; }
  .asset-refresh { padding: 3px 8px; }
}

/* =====================================================================
   日志查看器
   ===================================================================== */
.log-file-select { min-width: 220px; max-width: 340px; }
.log-viewer { padding: 0; }
.log-viewer .hint { padding: 10px 14px 0; margin: 0; }
.log-content {
  margin: 0; padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.7;
  color: var(--muted);
  background: var(--panel);
  border-top: 1px solid var(--line);
  white-space: pre-wrap; word-break: break-all;
  max-height: 70vh; overflow: auto;
}
.log-content:empty::after { content: "（暂无日志内容）"; color: var(--faint); }

.bt-export-row { margin-top: -4px; margin-bottom: 12px; }
.bt-export-row .btn { padding: 5px 14px; font-size: 12px; }

/* ===== 登录 / 首启引导 遮罩 ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(5, 8, 12, .88); backdrop-filter: blur(6px);
}
.login-card {
  background: var(--panel); border: 1px solid var(--line2); border-radius: 14px;
  padding: 32px 36px; width: 360px; max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.login-brand {
  font-size: 24px; font-weight: 800; letter-spacing: 1px;
  color: var(--text); text-align: center; margin-bottom: 22px;
}
.login-brand em { color: var(--accent); font-style: normal; }
.login-card h3 { margin: 0 0 4px; font-size: 16px; }
.login-card .form-row { margin-bottom: 14px; }
.login-card input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  background: var(--panel2); border: 1px solid var(--line2);
  color: var(--text); font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card .btn-row { justify-content: center; margin-top: 16px; }
.login-card .btn-primary { width: 100%; }
.login-card .msg { margin-top: 12px; text-align: center; }

/* 登录卡片：窄卡标签堆叠在输入框上方（标准 auth 表单布局） */
.login-card .form-row {
  grid-template-columns: 1fr;
  align-items: stretch;
  margin-bottom: 12px;
}
.login-card .form-row label { margin-bottom: 5px; font-size: 12px; white-space: normal; }
/* 次要按钮（注册账号/忘记密码/返回登录）做轻量文字链接行，弱化视觉 */
.login-card .btn-row.secondary { justify-content: center; gap: 18px; margin-top: 4px; }
.login-card .btn-row.secondary .btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 12.5px; font-weight: 400; padding: 4px 6px;
}
.login-card .btn-row.secondary .btn:hover { color: var(--accent); text-decoration: underline; }
.login-card .hint { text-align: center; color: var(--faint); font-size: 12px; margin-top: 4px; }

/* ---- Toast 通知（右上角堆叠，操作反馈统一）---- */
#toastContainer {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; max-width: 340px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 10px 14px; border-radius: 8px;
  background: var(--panel2); border: 1px solid var(--line2);
  color: var(--text); font-size: 13px; line-height: 1.5;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  display: flex; align-items: flex-start; gap: 8px;
  animation: toastIn .18s ease-out;
  white-space: pre-wrap; word-break: break-word;
}
.toast.success { border-color: var(--green); }
.toast.success::before { content: "✓"; color: var(--green); font-weight: 700; }
.toast.error { border-color: var(--red); }
.toast.error::before { content: "✕"; color: var(--red); font-weight: 700; }
.toast.info { border-color: var(--accent); }
.toast.info::before { content: "ℹ"; color: var(--accent); font-weight: 700; }
.toast.fade { opacity: 0; transition: opacity .3s ease; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: none; }
}

/* =====================================================================
   移动端响应式（PWA）
   ===================================================================== */
@media (max-width: 768px) {
  .topbar { gap: 8px; padding: 0 10px; height: 46px; }
  .brand-name, .top-ticker { display: none; }   /* 小屏省空间：品牌名/顶部行情隐藏 */
  .topbar-right { gap: 4px; }
  .topbar-right .lang-switch { display: none; }

  /* 侧边栏 → 顶部横向滚动 tab 条 */
  .body-wrap { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center;
    padding: 6px 8px; gap: 4px; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--line);
    flex-shrink: 0;
  }
  .sidebar-brand, .sidebar-foot, .nav-label { display: none; }
  .sidebar .nav-group { display: contents; }   /* 让所有 tab 展平成一条横向滚动 */
  .tab { white-space: nowrap; padding: 7px 12px; font-size: 12.5px; flex-shrink: 0; }

  .content { padding: 12px; }
  .panel-head h2 { font-size: 15px; }
  /* 表格/卡片横向滚动而非挤爆 */
  .table-wrap, .card-grid { overflow-x: auto; }
}

/* 应用内通知中心（顶栏铃铛） */
.notify-center { position: relative; }
.notify-bell {
  background: transparent; border: 1px solid var(--line2); border-radius: 6px;
  padding: 4px 8px; cursor: pointer; color: var(--muted); font-size: 14px; height: 28px;
}
.notify-bell:hover { color: var(--text); border-color: var(--accent); }
.notify-badge {
  position: absolute; top: -5px; right: -6px; background: var(--red); color: #fff;
  border-radius: 9px; font-size: 10px; min-width: 16px; height: 16px; line-height: 16px;
  text-align: center; padding: 0 4px; font-weight: 700;
}
.notify-dropdown {
  position: absolute; top: 34px; right: 0; width: 320px; max-height: 440px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line2); border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.55); z-index: 100;
}
.notify-head { padding: 10px 14px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 13px; color: var(--text); }
.notify-list { padding: 4px 0; }
.notify-item { padding: 8px 14px; border-bottom: 1px solid var(--line); }
.notify-item:last-child { border-bottom: none; }
.notify-msg { font-size: 12.5px; color: var(--text); white-space: pre-wrap; line-height: 1.55; }
.notify-time { font-size: 11px; color: var(--faint); margin-top: 3px; }

/* 账户总览（仪表盘右栏） */
.acct-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.acct-row:last-child { border-bottom: none; }
.acct-name { color: var(--text); display: flex; align-items: center; gap: 6px; }
.acct-meta { display: flex; align-items: center; gap: 4px; }
.acct-summary {
  display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px;
  border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted);
}
.acct-summary b { color: var(--text); font-family: var(--mono); }
