<div id="paper-live">
  {# Headline = the COMPOUNDED backfilled record (latest persisted nav equity), with the live
     mark-to-market kept as a clearly-labeled secondary detail. nav is always provided by the handler. #}
  <p>paper equity
    <b class="{{ 'pos' if nav.equity >= nav.capital else 'neg' }}">${{ nav.equity|money }}</b>
    <span class="muted">/ capital ${{ nav.capital|money }}</span>
    <span class="{{ 'pos' if nav.pnl >= 0 else 'neg' }}">
      ({{ nav.pnl|money_signed }})</span>
  </p>
  {% if nav.has_history %}
  <p class="muted" style="font-size:12px; margin-top:-6px">
    marked to live prices now: ${{ nav.live_equity|money }}</p>
  {% endif %}
  <h3>open positions <span class="muted" style="font-size:12px">({{ v.positions|length }})</span></h3>
  {# Bound the height so a large book (e.g. 71 symbols) scrolls within a box instead of making the page
     endlessly tall — critical on mobile where each row stacks into a labeled card. #}
  <div class="table-wrap" style="max-height:420px; overflow-y:auto"><table class="fleet">
    <thead><tr><th>sleeve</th><th>symbol</th><th>qty</th><th>entry</th><th>last</th><th>PnL</th></tr></thead>
    <tbody>
    {% for p in v.positions %}
      <tr>
        <td data-label="sleeve" class="muted">{{ p.sleeve }}</td>
        <td data-label="symbol">{{ p.symbol }}</td>
        <td data-label="qty">{{ p.qty|qty }}</td>
        <td data-label="entry">{{ p.entry_price|qty }}</td>
        <td data-label="last">{{ p.last|qty }}</td>
        <td data-label="PnL" class="{{ 'pos' if p.pnl >= 0 else 'neg' }}">{{ p.pnl|money_signed }}</td>
      </tr>
    {% else %}
      <tr><td colspan="6" class="muted">no open positions</td></tr>
    {% endfor %}
    </tbody>
  </table></div>
  <p class="muted" style="font-size:11px">as of {{ now }} · marked to live prices (unknown → entry, 0 PnL)</p>
</div>
