{% extends "base.html" %}
{% from "_macros.html" import exec_badge, rollup_plan_pill %}
{% block title %}Paper books{% endblock %}
{% block body %}
{# D4 (Task 5) — the consolidated Paper-books landing: BOTH paper books as clickable summary cards. The
   crypto 4-edge book (simulated, `PAPER`) kept its OWN unique detail (live per-symbol book / trades /
   individual edges) at its card's target (`/paper/crypto` — the former `/paper` content, UNCHANGED). The
   IBKR paper account (also `PAPER`) links to its holdings detail (Task 3's `strategy.html`), which now
   also shows the per-strategy breakdown. Neither card is a dead end — an unconnected/empty IBKR account
   renders a clean state, never a 500. #}
{# ── TRADER HEADER: h1 + a one-line subtitle. The two book cards below say the rest — no orientation blurb. #}
<h1 style="margin:0 0 2px">Paper books</h1>
<div class="muted" style="font-size:12.5px; margin-bottom:16px">the fund's live paper accounts — proving the edges with simulated money before real capital</div>
<div class="cards" style="grid-template-columns:repeat(auto-fit,minmax(300px,1fr))">

  <a href="/paper/crypto" style="text-decoration:none; color:inherit">
    <div class="card" style="padding:16px 18px; height:100%">
      <h3>Bybit 4-edge book {{ exec_badge('paper') }}</h3>
      <div class="muted" style="font-size:11px">account value</div>
      {% if headline.has_record %}
      <div class="stat">${{ headline.final_equity|money }}
        <span class="unit {{ 'pos' if headline.total_return_pct >= 0 else 'neg' }}">{{ '%+.0f'|format(headline.total_return_pct) }}%</span></div>
      <div class="muted" style="font-size:12px">Sharpe {{ '%.2f'|format(headline.sharpe) }} · maxDD {{ '%.0f'|format(headline.max_dd_pct) }}% · since {{ headline.since }}</div>
      {% if headline_curve %}<div style="margin-top:8px">{{ headline_curve|safe }}</div>{% endif %}
      {% else %}
      <p class="muted">no backfilled record yet</p>
      {% endif %}
      <div class="muted" style="font-size:11px; margin-top:10px">Simulated 4-edge crypto book, live on Bybit → holdings &amp; trades</div>
    </div>
  </a>

  {% if ibkr_view %}
  <a href="{{ ibkr_href }}" style="text-decoration:none; color:inherit">
    <div class="card" style="padding:16px 18px; height:100%">
      <h3>IBKR paper account {{ exec_badge('paper') }}</h3>
      <div class="muted" style="font-size:11px">account value</div>
      <div class="stat">${{ ibkr_rollup.total_nav|money }}</div>
      <div class="muted" style="font-size:12px">{{ ibkr_rollup.n_executing }} strateg{{ 'y' if ibkr_rollup.n_executing == 1 else 'ies' }} trading
        · {{ ibkr_view.all_positions|length }} holdings</div>
      {% if ibkr_rollup.n_executing > 0 %}
      <div style="margin-top:6px">{{ rollup_plan_pill(ibkr_rollup) }}</div>
      {% endif %}
      {% if ibkr_curve %}<div style="margin-top:8px">{{ ibkr_curve|safe }}</div>{% endif %}
      <div class="muted" style="font-size:11px; margin-top:10px">Real IBKR paper account (US equities/options) → holdings &amp; per-strategy breakdown</div>
    </div>
  </a>
  {% else %}
  <div class="card" style="padding:16px 18px; opacity:.6">
    <h3>IBKR paper account {{ exec_badge('paper') }}</h3>
    <p class="muted">not connected yet — no account data yet</p>
  </div>
  {% endif %}

</div>
{% endblock %}
