:root { color-scheme: light; }
  * { box-sizing: border-box; }
  body { margin: 0; overflow-y: scroll; /* 常驻滚动条：防图表 resize 震荡环 */ font: 14px/1.6 -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
         "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
         background: #f5f5f7; color: #1d1d1f; -webkit-font-smoothing: antialiased;
         min-height: 100vh;
         background-image: radial-gradient(1100px 380px at 50% -8%, rgba(0,113,227,.06), transparent 70%); }
  header { position: sticky; top: 0; z-index: 50; padding: 12px 22px;
           background: rgba(255,255,255,.72); backdrop-filter: blur(20px) saturate(180%);
           -webkit-backdrop-filter: blur(20px) saturate(180%);
           border-bottom: 1px solid rgba(0,0,0,.08);
           display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
  header h1 { font-size: 16px; margin: 0; letter-spacing: .2px; color: #1d1d1f; font-weight: 650; }
  header h1 span { color: #0071e3; }
  nav { display: flex; gap: 2px; background: rgba(0,0,0,.05); padding: 3px; border-radius: 10px;
        max-width: 100%; }
  nav button { background: none; border: 0; color: #3c3c43; padding: 7px 13px; cursor: pointer;
               border-radius: 8px; font-size: 13px; transition: background .15s ease, color .15s ease;
               flex: 0 0 auto; }
  nav button:hover { color: #1d1d1f; }
  nav button.active { background: #fff; color: #1d1d1f; font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
  main { padding: 24px 22px 40px; max-width: 1200px; margin: 0 auto; }
  .cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
  .card { background: #fff; border: 1px solid rgba(0,0,0,.06); border-radius: 16px; padding: 16px 18px;
          box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.04);
          transition: box-shadow .2s ease, transform .15s ease; }
  .card:hover { box-shadow: 0 2px 4px rgba(0,0,0,.05), 0 12px 32px rgba(0,0,0,.08); }
  .card h3 { margin: 0 0 10px; font-size: 12px; color: #86868b; font-weight: 600; letter-spacing: .04em; }
  .big { font-size: 30px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
  .up { color: #ff3b30; } .down { color: #009944; }
  .muted { color: #6e6e73; font-size: 12px; }
  table { width: 100%; border-collapse: collapse; margin-top: 6px; }
  th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid #f0f0f2; font-size: 13px;
           font-variant-numeric: tabular-nums; }
  th.ta-r, td.ta-r { text-align: right; }
  .table-scroll { max-height: 55vh; overflow: auto; border-radius: 8px; }
  .table-scroll table { border-collapse: separate; border-spacing: 0; }
  .table-scroll thead th {
    position: -webkit-sticky; position: sticky; top: 0; z-index: 1;
    background: #fff; box-shadow: 0 1px 0 rgba(0,0,0,.08);
  }
  .col-sep { border-left: 1px solid #e8e8ed; }
  tbody tr:hover { background: rgba(0,0,0,.018); }
  th { color: #86868b; font-weight: 600; font-size: 12px; }
  input, select { background: #fff; border: 1px solid #d1d1d6; color: #1d1d1f; accent-color: #0071e3;
                  border-radius: 10px; padding: 7px 10px; width: 100%; font-size: 13px;
                  transition: border-color .15s ease, box-shadow .15s ease; }
  input:focus, select:focus { outline: none; border-color: #0071e3; box-shadow: 0 0 0 3px rgba(0,113,227,.18); }
  button.primary { background: #0071e3; color: #fff; border: 0; border-radius: 10px;
                   padding: 9px 20px; cursor: pointer; font-size: 13px; font-weight: 500;
                   transition: background .15s ease, transform .1s ease; }
  button.primary:hover { background: #0077ed; }
  button.primary:active { transform: scale(.98); }
  button.ghost { background: #fff; color: #1d1d1f; border: 1px solid #d1d1d6; border-radius: 10px;
                 padding: 9px 18px; cursor: pointer; font-size: 13px; transition: background .15s ease; }
  button.ghost:hover { background: #f2f2f7; }
  .seg { display: inline-flex; background: rgba(0,0,0,.05); border-radius: 10px; padding: 3px; gap: 2px; }
  .seg label { padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; color: #3c3c43;
               transition: background .15s ease, color .15s ease; user-select: none; white-space: nowrap; }
  .seg label:hover { color: #1d1d1f; }
  .seg label:has(input:checked) { background: #fff; color: #1d1d1f; font-weight: 600;
                                   box-shadow: 0 1px 3px rgba(0,0,0,.12); }
  .seg input { display: none; }
  .grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 14px; }
  .field { margin-bottom: 10px; }
  .field label { display: block; font-size: 12px; color: #86868b; margin-bottom: 4px; }
  .badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
  /* 信号圆块：替代文字堆叠，一眼读状态 */
  .sig-strip { display:flex; align-items:center; gap:9px; min-height:26px; flex-wrap:wrap; }
  .sig-dot { width:13px; height:13px; border-radius:50%; display:inline-block;
             background:currentColor; box-shadow: inset 0 0 0 2px rgba(255,255,255,.65), 0 1px 2px rgba(0,0,0,.10);
             position:relative; cursor:default; transition:transform .15s ease; }
  .sig-dot:hover { transform:scale(1.25); }
  .sig-dot.lg { width:19px; height:19px; box-shadow: inset 0 0 0 2.5px rgba(255,255,255,.7),
                0 0 0 4px rgba(0,0,0,.10), 0 2px 5px rgba(0,0,0,.16); }
  .sig-dot.dim { opacity:.32; }
  .sig-cap { font-size:12px; color:#3c3c43; font-weight:600; }
  .L1 { background: #e8f2ff; color: #0071e3; } .L2 { background: #fff3e0; color: #b25000; }
  .L3 { background: #f5e9fc; color: #9b30ff; } .OBS { background: #f2f2f7; color: #6e6e73; }
  .RB { background: #e6f7ee; color: #1a7f37; } .PM { background: #fff8e1; color: #ad6200; }
  .TREND { background: #ede9fe; color: #6d28d9; }
  .TREND_CORE, .TREND_CORE_EXIT { background: #e0e7ff; color: #3730a3; }
  .TREND_CORE_FD { background: #fee2e2; color: #991b1b; }
  .STABILIZE { background: #e0f2fe; color: #0369a1; }
  .STABILIZE_LB { background: #cffafe; color: #0e7490; }
  .REBOUND { background: #dcfce7; color: #15803d; }
  .CAPITULATION { background: #ffedd5; color: #c2410c; }
  .BLOWOFF_EXIT { background: #fff0f0; color: #c62828; }
  .REBOUND_END { background: #fff0f0; color: #c62828; }
  .GAP_TREND { background: #fef9c3; color: #a16207; }
  .DIP_STRENGTH { background: #f3e8ff; color: #7e22ce; }
  .REBOUND_FAST, .REBOUND_FAST_TAKE, .REBOUND_FAST_STOP, .REBOUND_FAST_HOLD { background: #fef3c7; color: #92400e; }
  .SPIKE_EXIT { background: #fff0f0; color: #c62828; }
  #toast-box { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column;
               gap: 10px; z-index: 99; max-width: min(380px, calc(100vw - 40px)); }
  .toast { position: relative; background: rgba(255,255,255,.92); backdrop-filter: blur(16px);
           -webkit-backdrop-filter: blur(16px); border: 1px solid rgba(0,0,0,.08);
           border-radius: 16px; padding: 12px 16px; padding-right: 30px;
           box-shadow: 0 12px 40px rgba(0,0,0,.16); }
  .toast-close { position: absolute; top: 8px; right: 10px; background: none; border: 0;
                 color: #86868b; font-size: 17px; line-height: 1; cursor: pointer; padding: 2px; }
  .toast-close:hover { color: #1d1d1f; }
  .pill { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
  .pill.ok { background: #e8f8ee; color: #1a7f37; } .pill.warn { background: #fff4e5; color: #ad6200; }
  .pill.err { background: #ffe9e8; color: #d70015; }
  .assert { padding: 8px 12px; border-radius: 10px; margin: 4px 0; font-size: 13px; }
  .assert.pass { background: #e8f8ee; color: #1a7f37; border: 1px solid #bfe8cd; }
  .assert.fail { background: #ffe9e8; color: #d70015; border: 1px solid #ffc1bd; }
  .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .chart-box { background: #fff; border: 1px solid rgba(0,0,0,.06); border-radius: 14px; overflow-x: hidden;
               margin: 0 -4px; width: calc(100% + 8px); padding: 0 0 8px; }
  .chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 6px 8px;
                  font-size: 12px; color: #6e6e73; align-items: center; }
  .chart-legend .lg { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
  .chart-legend .sw { display: inline-block; flex: none; }
  .stat { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
  .section-title { font-size: 16px; font-weight: 650; margin: 22px 0 12px; color: #1d1d1f; }
  .chip { display: inline-block; padding: 3px 11px; border-radius: 999px; font-size: 12px;
          border: 1px solid #e0e0e5; color: #6e6e73; background: #fff; margin: 2px 2px 2px 0; }
  .chip.active { background: #e8f2ff; color: #0071e3; border-color: #b8d9ff; font-weight: 600; }
  /* 外围市场快照：四个分组共用同一列宽，避免各表自动撑宽导致文字错位 */
  #global-box > .row { align-items: baseline; }
  .global-tables table { table-layout: fixed; }
  .global-tables th:nth-child(1), .global-tables td:nth-child(1) { width: 34%; }
  .global-tables th:nth-child(2), .global-tables td:nth-child(2) { width: 24%; }
  .global-tables th:nth-child(3), .global-tables td:nth-child(3) { width: 22%; }
  .global-tables th:nth-child(4), .global-tables td:nth-child(4) { width: 20%; }
  .replay-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(240px, 1fr); gap: 14px; }
  @media (max-width: 860px) { .replay-grid { grid-template-columns: 1fr; } }
  .note { font-size: 12px; color: #86868b; padding: 3px 0; border-bottom: 1px dashed #e0e0e5; }
  .side-btn { background: #fff; color: #1d1d1f; border: 1px solid #d1d1d6; border-radius: 10px;
              padding: 9px 20px; cursor: pointer; font-size: 13px; transition: background .15s ease; }
  .side-btn:hover { background: #f2f2f7; }
  .side-btn.active.buy { background: #ffe9e8; color: #d70015; border-color: #ffb3ad; font-weight: 600; }
  .side-btn.active.sell { background: #e8f8ee; color: #1a7f37; border-color: #bfe8cd; font-weight: 600; }
  .sys-banner { padding: 8px 22px; font-size: 13px; font-weight: 500; }
  .sys-banner.err { background: #ffe9e8; color: #d70015; }
  .sys-banner.warn { background: #fff4e5; color: #ad6200; }
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-thumb { background: #d1d1d6; border-radius: 8px; border: 2px solid #f5f5f7; }
  @media (max-width: 768px) {
    /* 8/15 修复：移动端不再隐藏后三个选项卡（回测复盘/参数/数据），
       改为横向滚动（隐藏滚动条），全部可见可点 */
    nav { overflow-x: auto; -webkit-overflow-scrolling: touch;
          scrollbar-width: none; flex-wrap: nowrap; }
    nav::-webkit-scrollbar { display: none; }
    .cards { grid-template-columns: 1fr 1fr; }
  }
  /* 大盘研判：左侧市场状态+三大指数竖排，右侧操作建议大块（仅 UI 布局）
     左列宽度随内容自适应（字少保底 280px，字多自动变宽）；
     左列格子按内容自适应高度；操作建议占满剩余宽度，内容多时自然向下延伸。 */
  .market-panel { display: grid; grid-template-columns: minmax(280px, max-content) minmax(0, 1fr); gap: 14px; align-items: start; }
  .market-left { display: grid; grid-auto-rows: auto; gap: 14px; min-width: 0; }
  .market-left #index-strip { display: contents; }
  @media (max-width: 920px) {
    .market-panel { grid-template-columns: 1fr; }
  }
  /* 顶部卡片：前三张（实时行情/模拟盘/最新信号）等宽，版本进展加宽 */
  .dash-top { grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(340px, 1.5fr); }
  @media (max-width: 1080px) {
    .dash-top { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dash-top .card:last-child { grid-column: 1 / -1; }
  }
  /* P6.9.97i：回测复盘「① 净值曲线」的 B/S/T 标记开关（纯展示层）。
     ⚠️ 不要用兄弟选择器 `#chk:not(:checked) ~ .chart-box …` —— 勾选框在 <label> 里、
     而 .chart-box 是 <label> 的兄弟，**兄弟选择器要求同一父节点** → 永不匹配。
     改用容器类：开关与图表同放 `.nav-marks-scope`，容器带 `off` 时隐藏标记与图例。
     取消勾选 = 只隐藏标记，**曲线本身完全不变**（恢复原样）。 */
  .nav-marks-toggle { display: flex; justify-content: flex-end; align-items: center;
    gap: 6px; font-size: 12px; color: #6e6e73; margin: 2px 0 6px; cursor: pointer;
    user-select: none; -webkit-user-select: none; }
  .nav-marks-toggle input { margin: 0; cursor: pointer; }
  .nav-marks-scope.off .nav-marks,
  .nav-marks-scope.off .nav-marks-legend { display: none; }
  /* P6.9.97i-3：全局 `input { width:100%; padding:7px 10px }`（为日期框/下拉框设计）
     同样命中 checkbox/radio → 勾选框被拉成通栏长条（方块在最左、文字在最右）= 「错位」。
     复选/单选恢复固有尺寸，不受该全局规则影响。 */
  input[type="checkbox"], input[type="radio"] {
    width: auto; height: auto; padding: 0; margin: 0 4px 0 0; border: 0;
    box-shadow: none; accent-color: #0071e3; vertical-align: -2px; }
