/* 玻璃基差回归交易系统 - 浏览器版样式(浅色主题) */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #f0f2f5; color: #333; font-size: 13px;
  display: flex; flex-direction: column; min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
#topbar {
  background: #fff; padding: 8px 14px; display: flex; align-items: center;
  gap: 16px; flex-wrap: wrap; box-shadow: 0 1px 4px rgba(0,0,0,.08); z-index: 5;
}
.brand { font-size: 15px; font-weight: 700; }
.tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cap { color: #555; margin-left: 8px; }
.cap input { width: 88px; padding: 3px 6px; border: 1px solid #ccc; border-radius: 4px; }
.stats { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.stat { color: #444; }
.stat.rp { font-weight: 700; }
.badge { padding: 3px 12px; border-radius: 12px; color: #fff; font-weight: 700; font-size: 12px; }
.badge.bull { background: #d62728; }
.badge.bear { background: #1565c0; }
.badge.neutral { background: #7f7f7f; }

/* ---------- 按钮 ---------- */
.btn {
  padding: 5px 12px; border: 1px solid #ccc; border-radius: 4px; background: #fff;
  cursor: pointer; font-size: 12px;
}
.btn:hover:not(:disabled) { background: #f5f5f5; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: #1a7f37; border-color: #1a7f37; color: #fff; font-weight: 700; }
.btn.primary:disabled { opacity: .45; }
.btn.danger { color: #c62828; border-color: #e0b4b4; }
.btn.small { padding: 3px 9px; }
.btn.small.active { background: #1f77b4; border-color: #1f77b4; color: #fff; }

/* ---------- 主体 ---------- */
main { flex: 1; display: flex; gap: 8px; padding: 8px; min-height: 0; overflow-y: auto; }
.card {
  background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
  padding: 8px 10px; display: flex; flex-direction: column;
}
#bigPanel { flex: 3.2; min-width: 0; overflow-y: auto; }
#tierPanel { flex: 1; min-width: 300px; max-width: 380px;
  display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
#tierCards { display: flex; flex-direction: column; gap: 8px; }

/* ---------- 产业实时动态窗口 ---------- */
.news-card { flex: 1 1 auto; min-height: 180px; }
.news-card .panel-head { margin-bottom: 2px; }
.news-more { font-size: 12px; color: #1f77b4; text-decoration: none; }
.news-more:hover { text-decoration: underline; }
.news-ts { font-size: 11px; color: #aaa; font-family: Consolas, monospace; }
.news-list { flex: 1; overflow-y: auto; min-height: 140px; }
.news-item { display: flex; align-items: baseline; gap: 6px; padding: 4px 2px;
  border-bottom: 1px dashed #f0f0f0; color: #333; text-decoration: none;
  font-size: 12px; line-height: 1.5; }
.news-item:hover { background: #f7f9fc; }
.news-item.is-new { background: #fff7e6; }
.news-item.is-new .nt { color: #d46b08; font-weight: 700; }
.news-item .nt { color: #999; flex: 0 0 78px; font-size: 11px;
  font-family: Consolas, monospace; }
.news-item .ni { flex: 1; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; }
.news-empty { color: #bbb; font-size: 12px; }
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.panel-head b { font-size: 13px; }
.spacer { flex: 1; }
.dim { color: #999; }
.tier-radios label { margin-right: 8px; cursor: pointer; }
.tier-radios input { vertical-align: -2px; }
.tier-radios .checked { color: #1f77b4; font-weight: 700; }
/* 回测系列按钮组(盘面回测模式显示) */
.bt-sym-wrap { display: inline-flex; align-items: center; gap: 5px; }
/* 技术指标切换下拉(MACD/SAR) */
#indSel {
  padding: 2px 6px; border: 1px solid #ccc; border-radius: 4px;
  font-size: 12px; background: #fff; cursor: pointer;
}
#btSeriesBtns { display: inline-flex; align-items: center; gap: 4px; }
/* 回测明细中可点击的合约代码 */
.bt-sym-link { color: #1f77b4; cursor: pointer; text-decoration: underline dotted; }
.bt-sym-link:hover { font-weight: 700; }

/* ---------- 图表 ---------- */
/* 主图占剩余空间(不与基差窗口争高度), 基差窗口固定高度, 互不重叠;
   min-height 保证小屏下基差/技术指标两个固定窗口不会把主图压缩消失,
   高度不够时 main 容器滚动(下方媒体查询同时缩小固定窗口高度) */
.chart-lg { flex: 1 1 0; min-height: 280px; height: auto; overflow: hidden; }
.basis-head { display: flex; align-items: baseline; gap: 8px; margin-top: 6px;
  border-top: 1px dashed #ddd; padding-top: 6px; }
.basis-head b { font-size: 12.5px; }
.basis-head .sym-tag { margin-left: auto; color: #9467bd; font-weight: 700; }
.chart-sm { flex: 0 0 190px; height: 190px; overflow: hidden; }
/* MACD 日线副图窗口(基差窗口下方) */
#macdChart { flex: 0 0 170px; height: 170px; overflow: hidden; }

/* 矮屏(笔记本/小窗): 缩小两个固定高度副图, 给主图让空间 */
@media (max-height: 820px) {
  .chart-sm { flex-basis: 150px; height: 150px; }
  #macdChart { flex-basis: 130px; height: 130px; }
}
@media (max-height: 700px) {
  .chart-sm { flex-basis: 120px; height: 120px; }
  #macdChart { flex-basis: 110px; height: 110px; }
  .chart-lg { min-height: 240px; }
}

/* ---------- 监控小窗口 ---------- */
.tier-card { border-left: 4px solid #ccc; }
.tier-card.tradeable { border-left-color: #1a7f37; }
.tier-head { display: flex; align-items: baseline; gap: 8px; }
.tier-head .sym { color: #1f77b4; font-weight: 700; font-size: 14px; }
.tier-head .name { color: #888; font-size: 11px; }
.tier-head .basis { margin-left: auto; font-weight: 700; }
.basis.pos { color: #d62728; }
.basis.neg { color: #2ca02c; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; margin: 5px 0; }
.grid2 .k { color: #888; }
.grid2 .v { font-weight: 700; text-align: right; }
.v.up { color: #d62728; }
.v.down { color: #2ca02c; }
.signal { padding: 2px 8px; border-radius: 3px; background: #f2f4f7; font-size: 12px; }
.signal.hot { background: #fdecea; color: #c62828; font-weight: 700; }
.signal.pos-open { background: #e8f5e9; color: #1a7f37; font-weight: 700; }
.tail-line { display: block; font-size: 11px; color: #b26a00; font-weight: 600; }
.fills { font-family: Consolas, monospace; font-size: 11px; color: #555;
  max-height: 92px; overflow-y: auto; border-top: 1px dashed #eee; padding-top: 4px; }
.fills .open-long  { color: #d62728; }
.fills .open-short { color: #2ca02c; }
.fills .close-long { color: #2ca02c; }
.fills .close-short{ color: #d62728; }

/* ---------- 底部日志 ---------- */
footer.card { margin: 0 8px 8px; flex: 0 0 150px; }
#logBox { overflow-y: auto; font-family: Consolas, monospace; font-size: 11.5px;
  flex: 1; line-height: 1.55; }
#logBox .info { color: #333; }
#logBox .warn { color: #b26a00; }
#logBox .err  { color: #c62828; }
#logBox .buy  { color: #d62728; font-weight: 700; }
#logBox .sell { color: #2ca02c; font-weight: 700; }

/* ============ 开仓阈值设置弹窗 ============ */
.modal{position:fixed;inset:0;background:rgba(0,0,0,.45);display:flex;
       align-items:center;justify-content:center;z-index:100}
.modal.hidden{display:none}
.modal-box{width:min(640px,92vw);padding:14px 18px 12px}
.thr-grid{display:flex;gap:24px;margin:12px 0 10px;flex-wrap:wrap}
.thr-col{flex:1 1 240px;display:flex;flex-direction:column;gap:8px}
.thr-title{font-weight:700;font-size:13px;padding:4px 8px;border-radius:4px}
.thr-title.bear{background:#fdecea;color:#c62828}
.thr-title.bull{background:#e8f5e9;color:#2e7d32}
.thr-col label{display:flex;align-items:center;justify-content:space-between;
               gap:10px;font-size:13px}
.thr-col input{width:110px;padding:4px 8px;border:1px solid #ccc;border-radius:4px;
               font-size:13px;text-align:right}
.thr-foot{display:flex;align-items:center;gap:10px;border-top:1px solid #eee;
          padding-top:10px}

/* ============ 策略回测弹窗 ============ */
.modal-wide{width:min(1120px,95vw);max-height:92vh;overflow:auto}
.bt-controls{display:flex;align-items:center;gap:14px;flex-wrap:wrap;
             margin:10px 0 6px;padding:8px 10px;background:#fafafa;border-radius:6px}
.bt-controls label{display:flex;align-items:center;gap:6px;font-size:13px}
.bt-controls input{padding:4px 8px;border:1px solid #ccc;border-radius:4px;font-size:13px}
#btStatus{font-size:12px;color:#666;max-width:340px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.bt-results{margin-top:6px}
.bt-cards{display:flex;gap:10px;flex-wrap:wrap;margin:8px 0}
.bt-card{background:#fafafa;border-radius:6px;padding:8px 14px;flex:1 1 110px;text-align:center}
.bt-card .k{font-size:11px;color:#888}
.bt-card .v{font-size:19px;font-weight:700;margin-top:2px}
.bt-chart{height:300px;background:#fff;border:1px solid #f0f0f0;border-radius:6px;margin-bottom:8px}
.bt-chart-sm{height:170px;background:#fff;border:1px solid #f0f0f0;border-radius:6px;margin-bottom:8px}
.bt-charts-row{display:flex;gap:8px}
.bt-chart-half{flex:1;height:230px;background:#fff;border:1px solid #f0f0f0;border-radius:6px}
.bt-trades{margin-top:10px;font-size:13px}
.bt-table-wrap{max-height:320px;overflow:auto;margin-top:6px;border:1px solid #eee;border-radius:6px}
.bt-trades table{width:100%;border-collapse:collapse;font-size:12px;background:#fff}
.bt-trades th,.bt-trades td{padding:5px 8px;border-bottom:1px solid #eee;text-align:center;white-space:nowrap}
.bt-trades th{background:#fafafa;position:sticky;top:0}
.bt-note{font-size:11px;color:#999;line-height:1.7}

.sl-label{display:flex;align-items:center;gap:6px;font-size:13px;white-space:nowrap}
.sl-label input{width:64px;padding:4px 8px;border:1px solid #ccc;border-radius:4px;
                font-size:13px;text-align:right}
