<div class="hedge-plan-page-wrap" style="grid-column:1/-1" id="hedge-plan-root"
     data-default-underly="{{ options_default_underly | default('ETH') }}"
     data-hedge-enabled="{{ '1' if hedge_plan_enabled else '0' }}"
     data-options-enabled="{{ '1' if options_enabled else '0' }}"
     data-show-perp="{{ '1' if hedge_plan_show_perp_options else '0' }}"
     data-show-oo="{{ '1' if hedge_plan_show_options_options else '0' }}"
     data-oo-close-mode-enabled="{{ '1' if hedge_plan_oo_close_mode_enabled else '0' }}"
     data-option-primary="{{ '1' if hedge_plan_option_primary|default(true) else '0' }}"
     data-budget-buffer="{{ hedge_plan_budget_buffer | default(0.95) }}"
     data-sizing-mode="{{ position_sizing_mode | default('risk') }}"
     data-is-full-margin="{{ '1' if position_sizing_mode == 'full_margin' else '0' }}">
  {% if not hedge_plan_enabled %}
  <div class="flash" style="margin-bottom:12px">对冲计划未启用:请在 <code>env配置 → 对冲计划</code> 打开 <code>HEDGE_PLAN_ENABLED</code>(可热更).</div>
  {% endif %}
  {% if not options_enabled %}
  <div class="flash" style="margin-bottom:12px">期权模块未启用,无法拉期权链.请先配置期权账户.</div>
  {% endif %}
  {% if hedge_plan_enabled and not hedge_plan_show_perp_options and not hedge_plan_show_options_options %}
  <div class="flash" style="margin-bottom:12px">永期与期期 Tab 均已隐藏:请在 env「期权/对冲模式」切换交易模式;进行中/历史仍可查看.</div>
  {% endif %}

  <div class="card hp-head-card">
    <div class="hp-head-row">
      <h2 class="hp-title">对冲计划 <span class="muted hp-title-sub">测算 · 下单</span>
        <a class="muted" href="/options/guide" target="_blank" rel="noopener" style="font-size:13px;font-weight:500;margin-left:8px">期权开平仓与监控说明</a>
      </h2>
      <button type="button" class="btn-secondary" id="hp-refresh" title="刷新永续行情与期权链">刷新行情</button>
    </div>
    <div class="hp-tabs" role="tablist" aria-label="对冲计划分类">
      {% if hedge_plan_show_perp_options %}
      <button type="button" class="hp-tab" role="tab" aria-selected="false" data-tab="perp_options">永期对冲</button>
      {% endif %}
      {% if hedge_plan_show_options_options %}
      <button type="button" class="hp-tab" role="tab" aria-selected="false" data-tab="options_options">期期对冲</button>
      {% endif %}
      <button type="button" class="hp-tab" role="tab" aria-selected="false" data-tab="active">进行中的计划</button>
      <button type="button" class="hp-tab" role="tab" aria-selected="false" data-tab="history">历史记录</button>
      <button type="button" class="hp-tab" role="tab" aria-selected="false" data-tab="stats">统计分析</button>
    </div>
    <p class="muted" id="hp-gate-line"></p>
    <p class="muted hp-acct-hint" id="hp-acct-hint">永续腿→合约账户 · 期权腿→期权账户</p>
  </div>

  <div id="hp-tab-perp_options" class="hp-tab-panel" role="tabpanel">
    <div class="options-dual-grid" id="hp-po-layout">
      <div class="card hp-po-perp-card">
        <h2>
          <span id="hp-po-mode-badge" class="hp-po-mode-badge">以期权为主</span>
          <span id="hp-po-card-title">执行参数</span>
          · <span id="hp-perp-uly-label">ETH</span>
          <span class="muted hp-acct-tag" id="hp-perp-acct-tag">合约账户</span>
        </h2>
        <details class="tip-collapse hp-rule-collapse">
          <summary class="tip-collapse-summary">规则说明</summary>
          <div class="tip-collapse-body rule-tip">
            <p><strong>账户</strong>：永续腿走<strong>合约账户</strong>(USDT);期权腿走<strong>期权账户</strong>(USDC)。两账户分开下单、资金不互通。</p>
            <p><strong>模式</strong>：在 env <code>HEDGE_PLAN_OPTION_PRIMARY</code> 切换(true=以期权为主 / false=保险模式);标题前标识当前模式。</p>
            <p><strong>保险模式</strong>：做多配 Put、做空配 Call;左填开仓/止盈止损;仅实值/平值;交易所 TP/SL 出场。</p>
            <p><strong>以期权为主</strong>：填参后点「策略启动」进入<strong>盯盘</strong>(非现场开仓);杠杆/间隔达标后自动先开期权再市价永续。右侧列表仅展示达标候选。</p>
          </div>
        </details>
        <div class="form-row hp-uly-row">
          <button type="button" class="btn-secondary hp-uly-btn active" data-uly="ETH">ETH</button>
          <button type="button" class="btn-secondary hp-uly-btn" data-uly="BTC">BTC</button>
        </div>
        <div class="hp-po-top">
          <div class="hp-oo-seg hp-po-dir-seg" role="group" aria-label="方向">
            <button type="button" class="btn-secondary hp-po-dir is-selected" data-dir="long" title="做多=买Call+永续空"><span class="hp-oo-check" aria-hidden="true">✓</span>做多</button>
            <button type="button" class="btn-secondary hp-po-dir" data-dir="short" title="做空=买Put+永续多"><span class="hp-oo-check" aria-hidden="true">✓</span>做空</button>
          </div>
        </div>
        <div class="hp-po-fields hidden" id="hp-po-fields-insurance" hidden>
          <label class="hp-po-field">
            <span class="hp-po-field-lab">开仓价 <em>USDT</em></span>
            <input type="number" step="any" id="hp-entry" placeholder="入场价" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
          </label>
          <label class="hp-po-field">
            <span class="hp-po-field-lab">张数 <em>合约张</em></span>
            <input type="number" step="any" id="hp-contracts" placeholder="数量" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
          </label>
          <label class="hp-po-field hp-po-field--tp">
            <span class="hp-po-field-lab">止盈 <em>USDT</em></span>
            <input type="number" step="any" id="hp-tp" placeholder="目标价" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
          </label>
          <label class="hp-po-field hp-po-field--sl">
            <span class="hp-po-field-lab">止损 <em>USDT</em></span>
            <input type="number" step="any" id="hp-sl" placeholder="保护价" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
          </label>
        </div>
        <div id="hp-po-fields-option-primary">
          <section class="hp-po-section" aria-labelledby="hp-po-sec-capital">
            <h3 id="hp-po-sec-capital" class="hp-po-section-title">资金与杠杆配置</h3>
            <div class="hp-po-fields hp-po-fields--section hp-po-fields--capital">
              <label class="hp-po-field">
                <span class="hp-po-field-lab">权利金 <em>USDC</em></span>
                <input type="number" step="any" id="hp-premium-budget" placeholder="预算(执行×0.95)" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
              </label>
              <label class="hp-po-field">
                <span class="hp-po-field-lab">永续杠杆</span>
                <input type="number" step="1" id="hp-perp-leverage" value="100" autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
              </label>
              <label class="hp-po-field">
                <span class="hp-po-field-lab">期权杠杆 <em>启动校验</em></span>
                <input type="number" step="1" id="hp-opt-leverage" value="100" autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
              </label>
            </div>
          </section>
          <section class="hp-po-section" aria-labelledby="hp-po-sec-select">
            <h3 id="hp-po-sec-select" class="hp-po-section-title">选约条件</h3>
            <div class="hp-po-fields hp-po-fields--section hp-po-fields--select">
              <label class="hp-po-field">
                <span class="hp-po-field-lab">到期时间 <em>最短h</em></span>
                <input type="number" step="1" id="hp-min-hours" value="36" autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
              </label>
              <label class="hp-po-field">
                <span class="hp-po-field-lab">期权间隔 <em>点</em></span>
                <input type="number" step="any" id="hp-strike-interval" value="15" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
              </label>
              <label class="hp-po-field hp-po-field--type">
                <span class="hp-po-field-lab">类型</span>
                <select id="hp-money-select" aria-label="虚实值类型">
                  <option value="otm" selected>虚值</option>
                  <option value="itm">实值/平值</option>
                  <option value="atm">仅平值</option>
                </select>
              </label>
              <label class="hp-po-field">
                <span class="hp-po-field-lab">比例 <em>期权:永续</em></span>
                <input type="number" step="any" id="hp-opt-perp-ratio" value="2" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
              </label>
            </div>
          </section>
          <section class="hp-po-section" aria-labelledby="hp-po-sec-exit">
            <h3 id="hp-po-sec-exit" class="hp-po-section-title">出场条件</h3>
            <div class="hp-po-fields hp-po-fields--section">
              <label class="hp-po-field">
                <span class="hp-po-field-lab">期权目标位 <em>相对K</em></span>
                <input type="number" step="any" id="hp-opt-target-pts" placeholder="点数" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
              </label>
              <label class="hp-po-field">
                <span class="hp-po-field-lab">永续目标位 <em>相对K</em></span>
                <input type="number" step="any" id="hp-perp-target-pts" placeholder="点数" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
              </label>
            </div>
          </section>
        </div>
        <div class="hp-po-summary">
          <div id="hp-perp-pnl-line" class="hp-po-pnl"></div>
          <div id="hp-sizing-line" class="muted hp-po-sizing"></div>
        </div>
      </div>
      <div class="card hp-po-right-card">
        <div class="hp-po-right-stack">
          <div class="hp-po-inner-card hp-po-perp-quote-card">
            <h2>永续行情 <span class="muted hp-acct-tag">合约账户</span></h2>
            <div class="hp-po-quote-head">
              <span id="hp-po-mark" class="hp-po-mark" aria-live="polite">标记 —</span>
            </div>
            <p id="hp-perp-quote" class="muted hp-po-meta">加载中…</p>
            <p id="hp-po-perp-quote-right" class="muted hp-po-meta" hidden></p>
          </div>
          <div class="hp-po-inner-card hp-opt-card">
            <h2>期权 · <span id="hp-opt-type-label">Call</span> <span class="muted hp-acct-tag" id="hp-opt-acct-tag">期权账户</span></h2>
            <div class="form-row hp-opt-toolbar hp-po-opt-toolbar">
              <select id="hp-exp-select"><option value="">选择到期日</option></select>
              <span class="hp-po-ins-money" id="hp-po-ins-money" hidden>
                <button type="button" class="btn-secondary hp-money-btn active" data-money="itm" title="实值+平值">实值/平值</button>
                <button type="button" class="btn-secondary hp-money-btn" data-money="atm" title="仅平值">仅平值</button>
              </span>
              <button type="button" class="btn-secondary" id="hp-recommend-opt" title="按当前类型自动匹配最近合约">自动匹配</button>
              <button type="button" class="btn-secondary" id="hp-load-chain">刷新链</button>
              <span id="hp-index-line" class="hp-po-index" aria-live="polite">指数 —</span>
            </div>
            <div class="options-strike-table-wrap hp-strike-table-wrap--6">
              <table class="options-strike-table" id="hp-strike-table">
                <thead>
                  <tr>
                    <th>行权价</th>
                    <th>实虚值</th>
                    <th title="指数÷卖一">杠杆</th>
                    <th>卖一/张</th>
                    <th>买一/张</th>
                    <th>操作</th>
                  </tr>
                </thead>
                <tbody id="hp-strike-tbody">
                  <tr><td colspan="6" class="muted">请刷新期权链</td></tr>
                </tbody>
              </table>
            </div>
            <div class="form-row hp-pick-row">
              <label>已选 <code id="hp-sel-inst">—</code></label>
              <label>张数 <span class="hp-unit">期权张</span> <input type="number" step="1" min="1" id="hp-sheets" value="1" autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" /></label>
              <span class="muted" id="hp-premium-line"></span>
            </div>
            <div id="hp-opt-bal-line" class="muted hp-po-meta hp-opt-bal-line"></div>
          </div>
        </div>
        <div class="form-row hp-action-row hp-po-action-row">
          <span id="hp-po-strategy-status" class="hp-po-strategy-status" aria-live="polite"></span>
          <button type="button" class="primary" id="hp-preview-btn" title="以期权为主=盯盘启动">策略启动</button>
        </div>
      </div>
    </div>
  </div>

  <div id="hp-tab-options_options" class="hp-tab-panel hidden" role="tabpanel" hidden>
    <div class="options-dual-grid" id="hp-oo-layout">
      <div class="card">
        <h2>期期参数 · <span id="hp-oo-uly-label">ETH</span> <span class="muted hp-acct-tag">期权账户</span></h2>
        <details class="tip-collapse hp-rule-collapse">
          <summary class="tip-collapse-summary">规则说明</summary>
          <div class="tip-collapse-body rule-tip">
            <p><strong>账户</strong>：两腿都在<strong>期权账户</strong>。可用预算 = min(交易 USDC × 对冲缓冲 <strong id="hp-oo-buf-ratio">{{ '%.2f'|format(hedge_plan_budget_buffer|default(0.95)|float) }}</strong>, 单笔预算);可在 env「对冲预算缓冲比例」改。</p>
            <p><strong>下单</strong>：选 Call + Put 后「计算」再「启动」。启动会再拉卖一并按最新价重算张数,IOC 完全成交才算成功;资金不足可在右侧划转。</p>
            <p><strong>板块</strong>：左填<strong>盈亏比</strong>(盈利金额÷总权利金,默认2)与张数模式(同张数/做多/做空);右 T 型选腿。<strong>两腿仅允许平值或虚值</strong>(禁实值)。出场:盈利腿达盈亏比即平;亏损腿「残值平」=本合约权利金跌至20%且有买一时平,「到期平」=持有至到期。</p>
          </div>
        </details>
        <div class="form-row hp-uly-row">
          <button type="button" class="btn-secondary hp-uly-btn-oo active" data-uly="ETH">ETH</button>
          <button type="button" class="btn-secondary hp-uly-btn-oo" data-uly="BTC">BTC</button>
        </div>
        <div class="form-row hp-target-row hp-oo-target-row">
          <label title="盈利金额 / 总权利金">盈亏比 <input type="number" step="0.1" min="0.1" id="hp-profit-rr" value="2" placeholder="默认2" autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-form-type="other" /></label>
          <span id="hp-oo-index" class="hp-oo-index" aria-live="polite">指数 —</span>
        </div>
        <div class="hp-oo-controls">
          <div class="hp-oo-ctrl">
            <span class="hp-oo-ctrl-lab">张数</span>
            <div class="hp-oo-seg" role="group" aria-label="自动张数">
              <button type="button" class="btn-secondary hp-oo-size-mode is-selected" data-oo-size="same_sheets" title="两腿同张数,总权利金≤预算"><span class="hp-oo-check" aria-hidden="true">✓</span>同张数</button>
              <button type="button" class="btn-secondary hp-oo-size-mode" data-oo-size="long_bias" title="偏多:Call 占比更高(比例见 env)"><span class="hp-oo-check" aria-hidden="true">✓</span>做多</button>
              <button type="button" class="btn-secondary hp-oo-size-mode" data-oo-size="short_bias" title="偏空:Put 占比更高(比例见 env)"><span class="hp-oo-check" aria-hidden="true">✓</span>做空</button>
            </div>
          </div>
          <div class="hp-oo-ctrl" id="hp-oo-close-mode-row">
            <span class="hp-oo-ctrl-lab" title="仅控制盈利腿平掉后的另一腿">平仓</span>
            <div class="hp-oo-seg" role="group" aria-label="平仓模式">
              <button type="button" class="btn-secondary hp-oo-close-mode is-selected" data-oo-close="close_all" title="盈利腿平后:亏损腿本合约权利金跌至20%且有买一时平掉(失败重试)"><span class="hp-oo-check" aria-hidden="true">✓</span>残值平</button>
              <button type="button" class="btn-secondary hp-oo-close-mode" data-oo-close="hold_expiry" title="盈利腿平后另一腿持有至到期"><span class="hp-oo-check" aria-hidden="true">✓</span>到期平</button>
            </div>
          </div>
        </div>
        <p class="muted hp-oo-meta" id="hp-oo-budget-line"></p>
        <div id="hp-oo-legs" class="hp-oo-legs">
          <div class="hp-oo-leg-row" data-leg="a">
            <div class="muted" id="hp-oo-leg-a-info">腿A: 尚未选用</div>
            <label>张数 <span class="hp-unit">期权张</span>
              <input type="number" step="1" min="0" id="hp-oo-sheets-a" value="1" disabled autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
            </label>
          </div>
          <div class="hp-oo-leg-row" data-leg="b">
            <div class="muted" id="hp-oo-leg-b-info">腿B: 尚未选用</div>
            <label>张数 <span class="hp-unit">期权张</span>
              <input type="number" step="1" min="0" id="hp-oo-sheets-b" value="1" disabled autocomplete="off" inputmode="numeric" data-lpignore="true" data-1p-ignore="true" data-form-type="other" />
            </label>
          </div>
          <p class="muted" id="hp-oo-prem-line"></p>
        </div>
      </div>
      <div class="card hp-opt-card">
        <h2>期权 T 型报价</h2>
        <div class="form-row">
          <select id="hp-oo-exp-select"><option value="">选择到期日</option></select>
          <button type="button" class="btn-secondary hp-oo-money-btn is-selected active" data-oo-money="atm_otm" title="平值+虚值" aria-pressed="true"><span class="hp-oo-check" aria-hidden="true">✓</span>平/虚</button>
          <button type="button" class="btn-secondary hp-oo-money-btn" data-oo-money="atm" title="仅平值" aria-pressed="false"><span class="hp-oo-check" aria-hidden="true">✓</span>仅平值</button>
          <button type="button" class="btn-secondary hp-oo-money-btn" data-oo-money="otm" title="仅虚值" aria-pressed="false"><span class="hp-oo-check" aria-hidden="true">✓</span>仅虚值</button>
          <button type="button" class="btn-secondary hp-oo-recommend-btn" id="hp-oo-recommend-atm" data-oo-rec="atm_straddle" title="最近平值 Call+Put" aria-pressed="false"><span class="hp-oo-check" aria-hidden="true">✓</span>推荐跨式</button>
          <button type="button" class="btn-secondary hp-oo-recommend-btn" id="hp-oo-recommend-otm" data-oo-rec="double_otm" title="最近虚值 Call+Put" aria-pressed="false"><span class="hp-oo-check" aria-hidden="true">✓</span>推荐双虚</button>
          <button type="button" class="btn-secondary" id="hp-oo-load-chain">刷新链</button>
          <button type="button" class="btn-secondary hp-oo-expand-btn" id="hp-oo-expand-all" title="展开该到期全部平值/虚值行权价;若当前为「仅平值」会自动切到「平/虚」" aria-pressed="false"><span class="hp-oo-check" aria-hidden="true">✓</span>显示全部</button>
        </div>
        <div class="options-strike-table-wrap hp-oo-table-wrap" id="hp-oo-table-wrap">
          <table class="options-strike-table options-strike-table--t" id="hp-oo-table">
            <thead>
              <tr>
                <th colspan="4" class="opt-t-head-call">Call</th>
                <th class="opt-t-head-mid">行权</th>
                <th colspan="4" class="opt-t-head-put">Put</th>
              </tr>
              <tr>
                <th>卖一/张</th><th title="行权价÷卖一">杠杆</th><th>实虚值</th><th>选用</th>
                <th>K</th>
                <th>实虚值</th><th>卖一/张</th><th title="行权价÷卖一">杠杆</th><th>选用</th>
              </tr>
            </thead>
            <tbody id="hp-oo-tbody">
              <tr><td colspan="9" class="muted">请刷新期权链</td></tr>
            </tbody>
          </table>
        </div>
        <div class="hp-oo-transfer hp-oo-transfer--compact" id="hp-oo-transfer">
          <div class="hp-oo-transfer-bals muted">
            <span>资金 <strong id="hp-oo-funding-usdc">—</strong></span>
            <span class="hp-oo-transfer-sep">·</span>
            <span>交易 <strong id="hp-oo-trading-usdc">—</strong></span>
            <span class="hp-oo-transfer-unit">USDC</span>
            <span class="muted" id="hp-oo-xfer-msg"></span>
          </div>
          <div class="form-row hp-oo-transfer-form" autocomplete="off">
            {# 诱饵账号框:避免浏览器把划转数量当成登录用户名填 dekun #}
            <input type="text" name="username" autocomplete="username" tabindex="-1" aria-hidden="true"
                   style="position:absolute;left:-9999px;width:1px;height:1px;opacity:0" value="">
            <select id="hp-oo-xfer-dir" aria-label="划转方向" autocomplete="off">
              <option value="funding_to_trading" selected>资金 → 交易</option>
              <option value="trading_to_funding">交易 → 资金</option>
            </select>
            <input type="number" id="hp-oo-xfer-amount" name="cm_hp_xfer_amt" min="0.01" step="0.01" placeholder="数量"
                   autocomplete="off" inputmode="decimal" data-lpignore="true" data-1p-ignore="true" data-bwignore="true" data-form-type="other" readonly />
            <button type="button" class="btn-secondary btn-sm" id="hp-oo-xfer-all">全部</button>
            <button type="button" class="btn-primary btn-sm" id="hp-oo-xfer-btn">划转</button>
          </div>
        </div>
        <div class="form-row hp-action-row">
          <button type="button" class="primary" id="hp-preview-btn-oo">计算</button>
        </div>
      </div>
    </div>
  </div>

  <div id="hp-tab-active" class="hp-tab-panel hidden" role="tabpanel" hidden>
    <div class="card">
      <h2>进行中的计划</h2>
      <p class="muted">仅显示已启动但尚未结束的计划；可查看每条腿的当前记录状态。</p>
      <div class="options-strike-table-wrap">
        <table class="options-strike-table hp-history-table">
          <thead>
            <tr>
              <th>ID</th><th>类型</th><th>标的</th><th>合约</th><th>状态</th><th>目标/止盈止损</th><th>开仓</th><th>操作</th>
            </tr>
          </thead>
          <tbody id="hp-active-tbody">
            <tr><td colspan="8" class="muted">加载中…</td></tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>

  <div id="hp-tab-history" class="hp-tab-panel hidden" role="tabpanel" hidden>
    <div class="card">
      <h2>历史记录</h2>
      <p class="muted">独立对冲计划历史(与普通交易记录分离)。点「成交细节」查看合约名与成交字段。</p>
      <div class="options-strike-table-wrap">
        <table class="options-strike-table hp-history-table">
          <thead>
            <tr>
              <th>ID</th><th>类型</th><th>标的</th><th>合约</th><th>状态</th><th>合计≈U</th><th>原因</th><th>开仓</th><th>结束</th><th>操作</th>
            </tr>
          </thead>
          <tbody id="hp-history-tbody">
            <tr><td colspan="10" class="muted">加载中…</td></tr>
          </tbody>
        </table>
      </div>
    </div>
  </div>

  <div id="hp-tab-stats" class="hp-tab-panel hidden" role="tabpanel" hidden>
    <div class="card">
      <h2>统计分析</h2>
      <p class="muted">按永期 / 期期分别统计:胜率、盈亏比、最大盈利、最大亏损、最大回撤(按结束时间累积)</p>
      <div id="hp-stats-box" class="muted">加载中…</div>
    </div>
  </div>

  <div id="hp-detail-modal" class="hp-modal-backdrop" hidden>
    <div class="hp-modal" role="dialog" aria-modal="true" aria-labelledby="hp-detail-title">
      <div class="hp-modal-head">
        <h3 id="hp-detail-title">成交细节</h3>
        <button type="button" class="btn-secondary" id="hp-detail-close">关闭</button>
      </div>
      <div id="hp-detail-body" class="hp-modal-body muted">加载中…</div>
    </div>
  </div>

  <div id="hp-preview-modal" class="hp-modal-backdrop" hidden>
    <div class="hp-modal hp-preview-modal" role="dialog" aria-modal="true" aria-labelledby="hp-preview-title">
      <div class="hp-modal-head">
        <h3 id="hp-preview-title">情景测算</h3>
        <button type="button" class="btn-secondary" id="hp-preview-cancel-x" aria-label="关闭">关闭</button>
      </div>
      <div id="hp-preview-summary" class="muted hp-preview-summary"></div>
      <div class="options-strike-table-wrap">
        <table class="options-strike-table" id="hp-result-table">
          <thead>
            <tr>
              <th>情景</th>
              <th>现货价</th>
              <th id="hp-preview-mid-th">永续/腿盈亏</th>
              <th>期权盈亏</th>
              <th>合计≈U</th>
              <th>说明</th>
            </tr>
          </thead>
          <tbody id="hp-result-tbody">
            <tr><td colspan="6" class="muted">计算中…</td></tr>
          </tbody>
        </table>
      </div>
      <div class="form-row hp-preview-actions">
        <button type="button" class="btn-secondary" id="hp-preview-cancel">取消</button>
        <button type="button" class="primary" id="hp-preview-start" disabled title="需开启 HEDGE_PLAN_LIVE_ORDER 等门禁">启动计划</button>
      </div>
    </div>
  </div>
</div>
<script src="/static/hedge_plan.js?v=46"></script>
