<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>{% block title %}cockpit{% endblock %} · fxhnt</title>
  <script src="/static/htmx.min.js"></script>   <!-- vendored, no CDN: works on the tailnet w/o external egress -->

  <style>
    /* ── Design system: a professional trading-app dark theme. ONE palette (CSS vars), sans for prose +
       tabular mono for figures (the shift away from all-monospace that makes it read like an app, not a
       console), a consistent type scale + component set. Every page inherits this. ── */
    :root {
      color-scheme: dark;
      --bg:#0b0e14; --surface:#111722; --surface-2:#151c28; --raised:#1a2230;
      --border:#232c3a; --border-soft:#1a212c;
      --text:#e6edf5; --muted:#8b97a8; --faint:#6a7788;
      --accent:#4c9aff; --pos:#3fb950; --neg:#f85149; --warn:#e3a008;
      --sans:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,Roboto,"Helvetica Neue",sans-serif;
      --mono:ui-monospace,"SF Mono",SFMono-Regular,Menlo,Consolas,monospace;
      --radius:12px;
    }
    * { box-sizing:border-box; }
    body { background:var(--bg); color:var(--text); font:14.5px/1.55 var(--sans); margin:0;
           -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility; }
    /* figures + data tables use tabular mono so columns align + numbers read like an instrument panel */
    table, .stat, .num, .hl-equity, code, .mono { font-family:var(--mono); font-variant-numeric:tabular-nums; }
    h1 { font-size:21px; font-weight:650; letter-spacing:-.01em; }
    h2 { font-size:16px; font-weight:600; } h3 { font-size:14px; font-weight:600; }
    header { display:flex; align-items:center; gap:14px; padding:13px 22px; border-bottom:1px solid var(--border);
             background:linear-gradient(180deg,#0e131c,var(--bg)); flex-wrap:wrap; row-gap:8px; position:sticky; top:0; z-index:30; }
    header img { height:26px; } header h1 { font-size:15.5px; margin:0; font-weight:600; letter-spacing:-.01em; }
    main { padding:22px; max-width:1120px; margin:0 auto; }
    table { border-collapse:collapse; width:100%; font-size:13px; }
    th,td { text-align:right; padding:7px 11px; border-bottom:1px solid var(--border-soft); }
    thead th { color:var(--muted); font-family:var(--sans); font-weight:600; font-size:11px; letter-spacing:.03em;
               text-transform:uppercase; border-bottom:1px solid var(--border); }
    tbody tr:hover { background:rgba(76,154,255,.04); }
    th:first-child, td:first-child { text-align:left; }
    a { color:var(--accent); text-decoration:none; } a:hover { text-decoration:underline; }
    /* ── VERDICT banner: the trust anchor — a plain-language "is this working?" at the top of a page ── */
    .verdict { border:1px solid var(--border); border-left:3px solid var(--muted); border-radius:10px;
               padding:12px 15px; font-size:14px; line-height:1.5; background:var(--surface); }
    .verdict b { color:var(--text); font-weight:650; }
    .verdict.ok { border-left-color:var(--pos); background:linear-gradient(90deg,rgba(63,185,80,.07),var(--surface) 60%); }
    .verdict.warn { border-left-color:var(--warn); background:linear-gradient(90deg,rgba(227,160,8,.07),var(--surface) 60%); }
    .verdict.bad { border-left-color:var(--neg); background:linear-gradient(90deg,rgba(248,81,73,.07),var(--surface) 60%); }
    .badge { padding:2px 9px; border-radius:20px; font-size:11.5px; font-family:var(--sans); font-weight:600; }
    .WAIT { background:#21262d; color:#8b949e; } .GO { background:#193b1e; color:#3fb950; } .NO_GO { background:#3b1919; color:#f85149; }
    .PASS { background:#193b1e; color:#3fb950; } .FAIL { background:#3b1919; color:#f85149; }
    .pos { color:#3fb950; } .neg { color:#f85149; } .muted { color:#8b949e; }
    /* execution-mode badge: PAPER (neutral) vs LIVE (green) — on every track for an unmissable console */
    .badge-exec { padding:1px 6px; border-radius:8px; font-size:10px; letter-spacing:.04em; font-weight:600;
                  border:1px solid #30363d; }
    .badge-exec.paper { background:#1c2128; color:#8b949e; }
    .badge-exec.live { background:#193b1e; color:#3fb950; border-color:#238636; }
    /* RESEARCH section: visually dimmed/secondary — "not the fund" */
    .section.research { opacity:.62; }
    .section.research:hover { opacity:1; }
    .section.deploy > h2 { border-bottom-color:#238636; }
    svg { max-width: 100%; height: auto; }
    /* single tidy nav row: Overview · Paper · Replay · Backtest */
    nav.bar { display:flex; gap:16px; margin-left:24px; flex-wrap:wrap; row-gap:8px; font-size:13px; }
    nav.bar a { color:#8b949e; }
    nav.bar a:hover { color:#c9d1d9; }
    nav.bar a.on { color:#58a6ff; font-weight:600; }
    /* overview home: cards */
    .cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:14px; }
    .card { border:1px solid var(--border); border-radius:var(--radius); padding:15px 17px;
            background:var(--surface); box-shadow:0 1px 2px rgba(0,0,0,.25); }
    .card h3 { margin:0 0 9px; font-size:11px; color:var(--muted); font-weight:600; font-family:var(--sans);
               text-transform:uppercase; letter-spacing:.05em; }
    .stat { font-size:26px; font-weight:650; letter-spacing:-.01em; line-height:1.1; }
    .stat .unit { font-size:13px; color:var(--muted); font-weight:400; }
    /* connected fund headline: the backfill record line + the multi-year curve */
    .headline { border:1px solid var(--border); border-radius:var(--radius); padding:16px 18px;
                background:var(--surface); box-shadow:0 1px 2px rgba(0,0,0,.25); }
    .headline-line { display:flex; align-items:baseline; gap:8px; flex-wrap:wrap; font-size:15px; }
    .headline-line .hl-equity { font-size:27px; font-weight:700; letter-spacing:-.01em; }
    .headline-curve { margin-top:10px; }
    .chip { margin-left:auto; font-size:12px; color:#8b949e; border:1px solid #21262d;
            border-radius:8px; padding:2px 8px; }
    .tag { font-size:11px; color:#6e7681; }
    tr.subhead td { font-size:11px; letter-spacing:.04em; text-transform:uppercase;
                    padding-top:12px; border-bottom:0; }
    .section { margin:22px 0; }
    .section > h2 { font-size:15px; margin:0 0 12px; border-bottom:1px solid #21262d; padding-bottom:6px; }
    .entrypoints { display:flex; gap:12px; flex-wrap:wrap; }
    .entrypoints a { border:1px solid #21262d; border-radius:8px; padding:8px 16px; color:#58a6ff; }
    .entrypoints a:hover { border-color:#58a6ff; }
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    /* B3 funding: a semantic amber for "decaying", distinct from the neutral-grey WAIT. */
    .b { display:inline-flex; align-items:center; gap:4px; padding:2px 8px; border-radius:20px;
         font-size:11px; font-weight:600; line-height:1.4; white-space:nowrap; }
    .b.small { font-size:10px; padding:1px 6px; }
    .b .dot { width:6px; height:6px; border-radius:50%; background:currentColor; }
    .b.funded { background:#193b1e; color:#3fb950; }
    .b.decaying { background:#3a2d10; color:#d29922; }
    .b.defunded { background:#3b1919; color:#f85149; }
    /* capital meter (allocation vs ceiling) */
    .meter { margin-top:12px; padding-top:12px; border-top:1px dashed #30363d; }
    .meter .mrow { display:flex; justify-content:space-between; font-size:12px; color:#8b949e; margin-bottom:6px; }
    .meter .mrow b { color:#c9d1d9; font-weight:600; }
    .capbar { height:8px; border-radius:6px; background:#161b22; overflow:hidden; border:1px solid #21262d; }
    .capbar > i { display:block; height:100%; background:linear-gradient(90deg,#238636,#3fb950); border-radius:6px; }
    .meter .mcap { display:flex; justify-content:space-between; font-size:10.5px; color:#6e7681; margin-top:5px; }
    /* executed twin: a nested sub-line/sub-row under a modeled edge */
    .exec-tag { font-size:9.5px; letter-spacing:.05em; text-transform:uppercase; color:#6e7681;
                border:1px solid #30363d; border-radius:5px; padding:1px 5px; }
    tr.exrow td { padding-top:2px; }
    tr.exrow td:first-child { padding-left:22px; color:#6e7681; font-size:11.5px; }
    /* detail lifecycle blocks */
    .lc { border:1px solid #21262d; border-radius:10px; margin:11px 0; overflow:hidden; }
    .lc > .lct { display:flex; align-items:center; gap:8px; padding:9px 12px; background:#161b22;
                 font-size:11px; letter-spacing:.05em; text-transform:uppercase; color:#8b949e;
                 border-bottom:1px solid #21262d; }
    .lc > .lct .r { margin-left:auto; text-transform:none; letter-spacing:0; }
    .lc .lcb { padding:11px 12px; }
    .kv { display:flex; justify-content:space-between; gap:12px; padding:4px 0; font-size:12.5px;
          border-bottom:1px solid #21262d; } .kv:last-child { border-bottom:0; }
    .kv .k { color:#8b949e; } .kv .v { font-weight:600; text-align:right; }
    .why { font-size:11.5px; color:#6e7681; margin-top:7px; line-height:1.5; }
    /* bottom tabs: hidden on desktop, shown on mobile */
    nav.tabs { display:none; }
    @media (max-width: 640px) {
      nav.bar { display:none; }               /* hide the top nav row on mobile */
      main { padding:12px 12px 76px 12px; }           /* clear the fixed bottom bar */
      nav.tabs { position:fixed; bottom:0; left:0; right:0; z-index:20; display:grid;
                 grid-template-columns:repeat(4,1fr); background:rgba(13,17,23,.94);
                 backdrop-filter:blur(10px); border-top:1px solid #21262d; }
      nav.tabs .tab { padding:9px 0 11px; text-align:center; color:#6e7681; font-size:10.5px;
                      letter-spacing:.02em; }
      nav.tabs .tab .ic { display:block; font-size:16px; line-height:1; margin:0 auto 4px; }
      nav.tabs .tab.on { color:#58a6ff; }
      nav.tabs .tab:focus-visible { outline:2px solid #58a6ff; outline-offset:-2px; }
      th, td { padding: 5px 7px; }
      header { padding: 12px 14px; } header h1 { font-size: 15px; }
      /* fleet table -> cards */
      table.fleet thead { display: none; }
      table.fleet tr { display: block; border: 1px solid #21262d; border-radius: 8px;
                       margin-bottom: 10px; padding: 4px 8px; }
      table.fleet td { display: flex; justify-content: space-between; align-items: center;
                       text-align: right; border: 0; padding: 5px 2px; gap: 12px; }
      table.fleet td::before { content: attr(data-label); color: #8b949e; text-align: left;
                               font-size: 12px; }
      table.fleet td:first-child { font-size: 15px; padding-top: 6px; }
      table.fleet td:first-child::before { content: ""; }   /* strategy name = card title, no label */
    }
  </style>
</head>
<body>
  {# One tidy nav row; the current page is highlighted. (/paper/sim must be matched before the /paper
     prefix so Backtest, not Paper, lights up.) #}
  {% set path = request.url.path if request else '/' %}
  <header><img src="/static/fxhnt.png" alt="fxhnt"><h1>{{ self.title() }}</h1>
    {# hx-boost: nav links swap the <body> via htmx (SPA-smooth) instead of full page loads. htmx 1.x runs
       inline <script> tags in the swapped content, so each page's IIFE re-initializes after a boosted swap
       (the replay scrubber, the sim form + result scrubber re-bind to the fresh DOM); hx-* attributes are
       re-processed automatically. The replay Play loop is stopped on htmx:beforeSwap so navigating away
       mid-Play doesn't leave a runaway fetch loop on the detached page. #}
    <nav class="bar" hx-boost="true">
      <a href="/" class="{{ 'on' if path == '/' }}">Overview</a>
      <a href="/paper" class="{{ 'on' if path == '/paper' or path.startswith('/paper/crypto') }}">Paper</a>
      <a href="/paper/replay" class="{{ 'on' if path.startswith('/paper/replay') }}">Replay</a>
      <a href="/paper/sim" class="{{ 'on' if path.startswith('/paper/sim') }}">Backtest</a>
    </nav>
    <span class="muted" style="margin-left:auto">{{ now }}</span></header>
  {# mobile bottom-tab nav: thumb-reachable, shown only <=640px (see CSS). Mirrors the desktop nav.bar. #}
  <nav class="tabs" hx-boost="true" aria-label="Primary">
    <a href="/" class="tab {{ 'on' if path == '/' }}"><span class="ic" aria-hidden="true">▚</span>Overview</a>
    <a href="/paper" class="tab {{ 'on' if path == '/paper' or path.startswith('/paper/crypto') }}"><span class="ic" aria-hidden="true">▤</span>Paper</a>
    <a href="/paper/replay" class="tab {{ 'on' if path.startswith('/paper/replay') }}"><span class="ic" aria-hidden="true">▶</span>Replay</a>
    <a href="/paper/sim" class="tab {{ 'on' if path.startswith('/paper/sim') }}"><span class="ic" aria-hidden="true">◷</span>Backtest</a>
  </nav>
  <main>{% block body %}{% endblock %}</main>
</body>
</html>
