// Help / how-to page — comprehensive documentation of the dashboard for the
// portfolio manager. Static content; no DB payload required.
//
// Structure:
//   - TL;DR
//   - Quick guide (5 steps)
//   - The six pages — one section each, with an expandable "deep dive"
//     describing how the underlying methodology was constructed
//   - Data foundation (universe, refresh cadence, "as of" semantics)
//   - Glossary

const _SECTION_MAX_WIDTH = 880;

function HelpHeader() {
  return (
    <div>
      <Mono style={{ fontSize: 10, color: CX.accent, letterSpacing: '0.18em' }}>01 · /Q.INTRO</Mono>
      <h1 style={{
        fontFamily: CX.display, fontSize: 40, fontWeight: 400,
        letterSpacing: '-0.02em', margin: '8px 0 6px', color: CX.textHi,
      }}>
        Intro<span style={{ color: CX.accent }}>.</span>
      </h1>
      <Mono style={{ fontSize: 11, color: CX.faint, letterSpacing: '0.08em' }}>
        portfolio-manager guide · methodology deep-dives
      </Mono>
    </div>
  );
}

function HelpKicker({ label }) {
  return (
    <Mono style={{
      fontSize: 10, color: CX.accent, letterSpacing: '0.22em',
      textTransform: 'uppercase', marginBottom: 8, display: 'block',
    }}>{label}</Mono>
  );
}

function HelpSectionTitle({ children }) {
  return (
    <h2 style={{
      fontFamily: CX.display, fontSize: 22, fontWeight: 500,
      letterSpacing: '-0.01em', color: CX.textHi, margin: '0 0 14px',
    }}>{children}</h2>
  );
}

function HelpProse({ children }) {
  return (
    <div style={{
      fontFamily: CX.display, fontSize: 14, lineHeight: 1.6,
      color: CX.text, maxWidth: _SECTION_MAX_WIDTH,
    }}>{children}</div>
  );
}

function HelpCallout({ children }) {
  return (
    <div style={{
      borderLeft: `2px solid ${CX.accent}`,
      background: CX.accentVery,
      padding: '12px 16px',
      maxWidth: _SECTION_MAX_WIDTH,
      fontFamily: CX.display, fontSize: 13, lineHeight: 1.55, color: CX.text,
    }}>{children}</div>
  );
}

// Native <details> with styled marker — clicking the summary expands the
// deep-dive content inline. No React state needed.
function DeepDive({ label, children }) {
  return (
    <details style={{
      maxWidth: _SECTION_MAX_WIDTH,
      borderTop: `1px solid ${CX.line}`,
      marginTop: 14,
    }}>
      <summary style={{
        listStyle: 'none', cursor: 'pointer',
        padding: '12px 0',
        display: 'flex', alignItems: 'center', gap: 10,
        fontFamily: CX.mono, fontSize: 11, color: CX.accent,
        letterSpacing: '0.16em', textTransform: 'uppercase',
        userSelect: 'none',
      }}>
        <span className="cortex-deepdive-arrow" style={{
          display: 'inline-block', width: 10, textAlign: 'center',
          transition: 'transform .15s ease',
        }}>▸</span>
        <span>Deep dive · {label}</span>
      </summary>
      <div style={{
        padding: '4px 0 20px 20px',
        fontFamily: CX.display, fontSize: 13, lineHeight: 1.62,
        color: CX.dim, borderLeft: `1px dashed ${CX.line}`,
        marginLeft: 4,
      }}>{children}</div>
      <style>{`
        details[open] > summary .cortex-deepdive-arrow { transform: rotate(90deg); }
        summary::-webkit-details-marker { display: none; }
        summary:hover { color: ${CX.textHi}; }
      `}</style>
    </details>
  );
}

function HelpKeyValue({ k, v }) {
  return (
    <div style={{
      display: 'grid', gridTemplateColumns: '180px 1fr', gap: 12,
      padding: '8px 0', borderTop: `1px solid ${CX.line}`,
      fontFamily: CX.mono, fontSize: 12,
    }}>
      <span style={{ color: CX.faint, letterSpacing: '0.06em' }}>{k}</span>
      <span style={{ color: CX.text }}>{v}</span>
    </div>
  );
}

// Reusable: one "page" entry with title, one-paragraph description, and a
// deep-dive collapsible underneath.
function PageEntry({ num, title, oneLiner, useFor, deepDiveLabel, deepDive }) {
  return (
    <div style={{ marginBottom: 36 }}>
      <div style={{ display: 'flex', alignItems: 'baseline', gap: 12, marginBottom: 6 }}>
        <Mono style={{
          fontSize: 11, color: CX.accent, letterSpacing: '0.18em', width: 24,
        }}>{String(num).padStart(2, '0')}</Mono>
        <h3 style={{
          fontFamily: CX.display, fontSize: 18, fontWeight: 500,
          letterSpacing: '-0.01em', color: CX.textHi, margin: 0,
        }}>{title}</h3>
      </div>
      <HelpProse>
        <p style={{ margin: '0 0 10px' }}>{oneLiner}</p>
        <p style={{ margin: 0, color: CX.dim }}>
          <Mono style={{ fontSize: 10, color: CX.faint, letterSpacing: '0.18em', marginRight: 8 }}>USE</Mono>
          {useFor}
        </p>
      </HelpProse>
      <DeepDive label={deepDiveLabel}>{deepDive}</DeepDive>
    </div>
  );
}

function PageHelp() {
  return (
    <div style={{ padding: '32px 32px 64px', overflowY: 'auto', height: '100%' }}>
      <HelpHeader />

      {/* ─── TL;DR ──────────────────────────────────────────────────────────── */}
      <div style={{ marginTop: 36 }}>
        <HelpKicker label="TL;DR" />
        <HelpSectionTitle>What is this?</HelpSectionTitle>
        <HelpProse>
          <p style={{ margin: '0 0 12px' }}>
            Cortex is a research prioritization tool for Nordic small-caps. Every
            night it pulls fresh prices and reports for every instrument on
            Nordic First North and Small Cap lists, recomputes a 6-factor
            scorecard (quality, value, growth, momentum, inflection, risk) for
            ~750 eligible names, bins them into five signal buckets, and ranks
            within each bucket by a research-priority composite.
          </p>
          <p style={{ margin: '0 0 12px' }}>
            You don&rsquo;t use it to pick stocks directly — you use it to decide
            which 5&ndash;15 names to spend research time on this week.
            Everything below the queue (tear sheet, similarity, models, backtest)
            is decision support, not signal generation.
          </p>
          <p style={{ margin: 0, color: CX.dim }}>
            Updated nightly at ~03:00 UTC. The header shows the precise
            <Mono style={{ color: CX.text, marginLeft: 6, marginRight: 6 }}>built_at</Mono>
            timestamp of the data you&rsquo;re looking at.
          </p>
        </HelpProse>
      </div>

      {/* ─── Quick guide ────────────────────────────────────────────────────── */}
      <div style={{ marginTop: 48 }}>
        <HelpKicker label="QUICK GUIDE" />
        <HelpSectionTitle>A 90-second weekly workflow</HelpSectionTitle>
        <HelpProse>
          <ol style={{ paddingLeft: 22, margin: 0 }}>
            <li style={{ marginBottom: 14 }}>
              <strong style={{ color: CX.textHi }}>Open Research Queue</strong>.
              Scan the top of each bucket. Compounders are the long-term core;
              cheap_decent are deep-value plays; inflection candidates are
              turnarounds with early momentum; pullbacks are quality names that
              just sold off; danger is your &ldquo;don&rsquo;t touch&rdquo; list.
            </li>
            <li style={{ marginBottom: 14 }}>
              <strong style={{ color: CX.textHi }}>Filter to your appetite</strong>.
              Use the bucket / country / sector chips and the min-quality / max-risk
              sliders. A typical PM scan: buckets = compounder + cheap_decent + inflection,
              min-quality = 60, max-risk = 60.
            </li>
            <li style={{ marginBottom: 14 }}>
              <strong style={{ color: CX.textHi }}>Click any row → Drill In</strong>.
              The drill-in panel shows the factor breakdown and the AI text signal
              (recent press releases scored for operating momentum, balance-sheet
              risk, dilution risk, etc.). If it&rsquo;s interesting, hit
              &ldquo;Open tear sheet&rdquo;.
            </li>
            <li style={{ marginBottom: 14 }}>
              <strong style={{ color: CX.textHi }}>Use Tear Sheet → Similar To…</strong>{' '}
              to broaden the set. If you like the company but want comparables,
              Similar To finds the 12&ndash;15 closest names by financial fingerprint
              across the whole Nordic universe (not just the queue).
            </li>
            <li style={{ marginBottom: 0 }}>
              <strong style={{ color: CX.textHi }}>Watchlist &amp; Notes</strong>{' '}
              to track decisions. Hold / Watch / Pass with a one-line rationale.
              Notes are timestamped so you have a paper trail of why you skipped
              a name three months ago.
            </li>
          </ol>
        </HelpProse>
      </div>

      {/* ─── The six pages ──────────────────────────────────────────────────── */}
      <div style={{ marginTop: 56 }}>
        <HelpKicker label="THE SIX PAGES" />
        <HelpSectionTitle>What each page does, and how it&rsquo;s built</HelpSectionTitle>

        <PageEntry
          num={1}
          title="Research Queue"
          oneLiner={
            "Every eligible Nordic small-cap, scored on six factors and binned into one of five signal buckets. Ranked within each bucket by a composite that combines the bucket-relevant factors, an AI text signal, and a risk penalty."
          }
          useFor="Weekly prioritization. Pick 5–15 names to research deeper from the top of the buckets that match your style."
          deepDiveLabel="Buckets &amp; composite scores"
          deepDive={
            <>
              <p style={{ margin: '0 0 10px' }}>
                Six factor scores (quality / value / growth / momentum / inflection / risk)
                are computed for each eligible company. Each factor is a weighted blend of
                cross-sectionally rank-z-scored sub-features. Buckets are then assigned by
                eligibility cuts on those factor scores:
              </p>
              <HelpKeyValue k="compounder"   v="quality ≥ 80, growth ≥ 60, risk ≤ 50, liquidity ≥ 40" />
              <HelpKeyValue k="cheap_decent" v="value ≥ 80, quality ≥ 50, risk ≤ 60, ≥3 of last 5y FCF-positive" />
              <HelpKeyValue k="inflection"   v="inflection ≥ 75, momentum ≥ 50, risk ≤ 70" />
              <HelpKeyValue k="pullback"     v="quality ≥ 75, risk ≤ 60, drawdown from 52w high ≤ -25%" />
              <HelpKeyValue k="danger"       v="risk ≥ 75 (selected, not filtered)" />
              <p style={{ margin: '14px 0 10px' }}>
                Within a bucket, the rank comes from a composite that&rsquo;s
                bucket-specific. Compounder, for example, weights quality 0.45,
                growth 0.225, momentum 0.135, value 0.09, AI-text 0.10, with a
                &minus;0.25 risk penalty. Each composite is normalized over the
                factors actually present for that company — so a name with no
                recent AI-scored docs still gets a valid composite.
              </p>
              <p style={{ margin: 0 }}>
                A company can satisfy multiple buckets&rsquo; cuts. In practice it
                goes into the &ldquo;best&rdquo; one by composite score; ties are
                broken in the order compounder → cheap_decent → inflection →
                pullback → danger.
              </p>
            </>
          }
        />

        <PageEntry
          num={2}
          title="Tear Sheet"
          oneLiner={
            "One-page company view: identity, current factor scores, 1Y price chart with multi-window toggle, factor radar, AI-text signal panel, and risk flags. The TickerSelector accepts any name in the queue."
          }
          useFor="Drill-down after the queue surfaces something interesting. Always read the AI risk flags — the bottom panel lists dilution events, drawdowns, and balance-sheet stress signals if any are active."
          deepDiveLabel="Factor scores &amp; ranks"
          deepDive={
            <>
              <p style={{ margin: '0 0 10px' }}>
                Each of the six factor scores is a 0&ndash;100 cross-sectional
                rank. The underlying sub-features and weights:
              </p>
              <HelpKeyValue k="quality"    v="ROIC 0.25 · EBIT margin 0.20 · cash conversion 0.20 · balance 0.15 · margin stability 0.10 · dilution discipline 0.10" />
              <HelpKeyValue k="value"      v="EV/EBIT 0.30 · FCF yield 0.25 · EV/EBITDA 0.20 · earnings yield 0.15 · valuation-vs-own 0.10" />
              <HelpKeyValue k="growth"     v="revenue CAGR 3y 0.30 · sales/share growth 0.25 · EBIT growth 0.20 · margin expansion 0.15 · FCF growth 0.10" />
              <HelpKeyValue k="momentum"   v="12m ex-1m 0.35 · 6m 0.25 · relative-strength-vs-sector 0.20 · trend stability 0.20" />
              <HelpKeyValue k="inflection" v="EBIT margin inflection 0.30 · revenue acceleration 0.25 · FCF improvement 0.20 · ROIC improvement 0.15 · net-debt reduction 0.10" />
              <HelpKeyValue k="risk"       v="leverage 0.25 · dilution 0.20 · liquidity 0.20 · FCF risk 0.15 · volatility 0.10 · margin deterioration 0.10" />
              <p style={{ margin: '14px 0 0' }}>
                Ranks are computed within the eligible universe at the
                feature_date, so a 70 today and a 70 a year ago aren&rsquo;t directly
                comparable — they always describe position relative to today&rsquo;s
                Nordic small-cap pool.
              </p>
            </>
          }
        />

        <PageEntry
          num={3}
          title="Similar To…"
          oneLiner={
            "Nearest neighbours across the whole Nordic universe by 12-dimensional financial fingerprint — operating profile, growth, balance, size + liquidity, share-count discipline. Returns top-K by Euclidean distance over rank-z-scored features."
          }
          useFor="After a tear-sheet hit. If you like GENI but want to know who else looks like GENI on the fundamentals, this is the page. Cuts past sector/industry labels (which are often unhelpful for small-caps)."
          deepDiveLabel="Factor-vector similarity"
          deepDive={
            <>
              <p style={{ margin: '0 0 10px' }}>
                Each eligible company at the feature_date is represented by a
                12-dim vector covering five aspects:
              </p>
              <ul style={{ paddingLeft: 22, margin: '0 0 10px' }}>
                <li style={{ marginBottom: 6 }}><strong style={{ color: CX.textHi }}>Operating profile</strong>: gross margin, EBIT margin, FCF margin, ROIC</li>
                <li style={{ marginBottom: 6 }}><strong style={{ color: CX.textHi }}>Growth</strong>: revenue CAGR 3y, EBIT growth YoY</li>
                <li style={{ marginBottom: 6 }}><strong style={{ color: CX.textHi }}>Balance</strong>: net debt / EBITDA, equity ratio</li>
                <li style={{ marginBottom: 6 }}><strong style={{ color: CX.textHi }}>Size + liquidity</strong>: log market cap, log 90-day avg daily turnover</li>
                <li style={{ marginBottom: 0 }}><strong style={{ color: CX.textHi }}>Capital discipline</strong>: 3y share-count growth</li>
              </ul>
              <p style={{ margin: '0 0 10px' }}>
                Each dimension is normalized via percentile-rank → z-score (robust
                to small-cap outliers vs raw values), then pairwise Euclidean
                distance is computed. NaN-tolerant: missing features in a pair
                are masked out and the distance is scaled by √(D / n_present),
                so a sparser pair doesn&rsquo;t artificially look closer.
              </p>
              <p style={{ margin: 0 }}>
                Top-K neighbours per company are persisted to
                <Mono style={{ color: CX.text, marginLeft: 4, marginRight: 4 }}>cortex.similar_companies</Mono>
                nightly. There&rsquo;s also a semantic similarity path via
                OpenAI text-embedding-3-large on a per-company summary doc
                (annual report + 90-day press releases), kept in
                <Mono style={{ color: CX.text, marginLeft: 4, marginRight: 4 }}>cortex.company_embeddings</Mono>{' '}
                — currently not exposed on this page, but available for future
                &ldquo;narrative similarity&rdquo; views.
              </p>
            </>
          }
        />

        <PageEntry
          num={4}
          title="Backtest Results"
          oneLiner={
            "Walk-forward portfolio simulations of the queue methodology. Compares portfolio variants (top-N by bucket, top-N overall, etc.) against a Nordic small-cap benchmark across rolling 12-month windows."
          }
          useFor="Sanity-check the queue's ex-post behaviour. Look at the excess-return distribution — if a variant only outperforms in 3 of 9 periods, it's regime-sensitive and the queue rank should be taken with skepticism."
          deepDiveLabel="Walk-forward backtest"
          deepDive={
            <>
              <p style={{ margin: '0 0 10px' }}>
                For each historical feature_date, the queue methodology is
                re-applied to the universe as it was on that date, top-N names
                per bucket are &ldquo;held&rdquo; for 12 months, and the
                portfolio&rsquo;s forward return is compared against the
                equal-weighted benchmark over the same instruments.
              </p>
              <p style={{ margin: '0 0 10px' }}>
                Transaction cost + slippage budget is configurable (defaults to
                40 bps round-trip, applied at each rebalance). Portfolio sizing
                is bucketed: min 10 / max 50 names per portfolio,
                top-percent threshold defaulting to 10% of the eligible pool.
              </p>
              <p style={{ margin: 0 }}>
                Walk-forward avoids look-ahead bias. The score-construction
                weights, eligibility cuts, and bucket composites are the same
                in-sample and out-of-sample — there&rsquo;s no fitting on the
                test windows.
              </p>
            </>
          }
        />

        <PageEntry
          num={5}
          title="Model Rankings"
          oneLiner={
            "Out-of-sample 12-month-ahead score from three ML models (LightGBM, tuned LightGBM, transformer) trained on 36-month sequences of monthly factor features. The transformer score is an ensemble of 8 walk-forward fold checkpoints."
          }
          useFor="A second opinion vs the rule-based queue. Where a name appears top-decile in BOTH the queue and one of the models, that's a stronger conviction signal than either alone."
          deepDiveLabel="Model construction"
          deepDive={
            <>
              <p style={{ margin: '0 0 10px' }}>
                Three production models, trained on the same monthly feature
                panel (~200 features per company-month, 36-month lookback):
              </p>
              <HelpKeyValue k="lightgbm"             v="LightGBM classifier predicting top-20% in next 12m return. Default hyperparameters." />
              <HelpKeyValue k="tuned_lightgbm"        v="Same target, Bayesian-tuned (depth, leaves, learning_rate) on validation folds." />
              <HelpKeyValue k="lightgbm_regression"   v="LightGBM regressor predicting the 12m relative return directly." />
              <HelpKeyValue k="transformer"           v="TimeSeriesTransformer with attention pooling (2 layers, 4 heads, d_model=128). 8 walk-forward folds; production score is the mean sigmoid across folds." />
              <p style={{ margin: '14px 0 10px' }}>
                All models are evaluated by walk-forward: train on data up to
                t−12m, predict at t, score on the realized 12m return through
                t+12m. The hit-rate and excess-return-12m columns are
                aggregated over all out-of-sample folds.
              </p>
              <p style={{ margin: 0 }}>
                Features are monthly-aggregated (e.g. month-end revenue,
                returns, margins), so model predictions are stable within a
                month and refresh meaningfully at month-end. The nightly job
                does <em>not</em> re-run inference for this reason — model
                predictions are refreshed in a separate monthly schedule.
              </p>
            </>
          }
        />

        <PageEntry
          num={6}
          title="Watchlist &amp; Notes"
          oneLiner={
            "Tag companies as Held, Watch, or Pass. Add timestamped notes with rationale. Both feed back into the queue (held/watch flags appear as chips in the queue row)."
          }
          useFor="Decision-trail discipline. When you skip a name, write a one-line reason; in three months when it pops up again, your prior take is right there. Held positions are excluded from new-research surfacing by default."
          deepDiveLabel="State model"
          deepDive={
            <>
              <p style={{ margin: '0 0 10px' }}>
                Two underlying tables:
                <Mono style={{ color: CX.text, marginLeft: 4 }}>cortex.watchlist</Mono>
                (the current status per security_id with a one-line rationale) and
                <Mono style={{ color: CX.text, marginLeft: 4 }}>cortex.notes</Mono>
                (append-only log; each note has author, date, body).
              </p>
              <p style={{ margin: '0 0 10px' }}>
                The queue join applies the watchlist state as the
                <Mono style={{ color: CX.text, marginLeft: 4, marginRight: 4 }}>held</Mono>and
                <Mono style={{ color: CX.text, marginLeft: 4, marginRight: 4 }}>watch</Mono>
                booleans per row, which the queue&rsquo;s row chips render
                directly. There&rsquo;s no separate state stored on the row —
                the queue is always re-derived from watchlist + scores at
                build time.
              </p>
              <p style={{ margin: 0 }}>
                Decisions (
                <Mono style={{ color: CX.text, marginLeft: 4, marginRight: 4 }}>cortex.decisions</Mono>
                ) is a third table that exists for future use — to log explicit
                buy/sell decisions with size and price. Not wired into the UI yet.
              </p>
            </>
          }
        />
      </div>

      {/* ─── Data foundation ────────────────────────────────────────────────── */}
      <div style={{ marginTop: 56 }}>
        <HelpKicker label="DATA FOUNDATION" />
        <HelpSectionTitle>Universe, refresh, and freshness</HelpSectionTitle>
        <HelpProse>
          <p style={{ margin: '0 0 14px' }}>
            The universe is every instrument on Nordic First North + Small Cap
            lists across Sweden, Norway, Denmark, Finland, and Iceland that
            Börsdata exposes. That&rsquo;s ~1700 instruments raw, narrowed to
            ~750 with enough fundamental history to compute the full feature
            stack. Currently-listed First North 25 constituents are flagged
            with a chip in the queue.
          </p>
          <p style={{ margin: '0 0 14px' }}>
            The header timestamp (<Mono style={{ color: CX.text }}>data as of …</Mono>)
            is the precise moment the nightly job wrote the on-screen payloads
            to the database. The asof date (
            <Mono style={{ color: CX.text }}>asof 2026-04-01</Mono>) is the feature_date the queue is computed at — typically the most recent quarter-end with closed reporting.
          </p>
        </HelpProse>
        <HelpCallout>
          <strong style={{ color: CX.textHi }}>If &ldquo;data as of&rdquo; is more
          than ~36 hours stale</strong>, the nightly refresh hasn&rsquo;t completed
          successfully. Check the GitHub Actions logs of the
          <Mono style={{ color: CX.text, marginLeft: 6, marginRight: 6 }}>nightly-refresh</Mono>
          workflow in <Mono style={{ color: CX.text, marginRight: 4 }}>garage-projects-ab/scai</Mono>.
        </HelpCallout>

        <DeepDive label="What runs every night">
          <p style={{ margin: '0 0 10px' }}>
            The 03:00 UTC workflow in order:
          </p>
          <HelpKeyValue k="1. Börsdata ingest" v="last ~10 trading days of prices + last 2 of each report cadence (~200 API calls vs the 10k/day budget)" />
          <HelpKeyValue k="2. scai-load"        v="upserts raw snapshots into Supabase (scai schema)" />
          <HelpKeyValue k="3. compute-features" v="rebuilds cortex.features_quarterly at the latest feature_date" />
          <HelpKeyValue k="4. compute-scores"   v="rebuilds cortex.scores with the six factor scores per eligible company" />
          <HelpKeyValue k="5. compute-embeddings" v="hash-and-skip — only re-embeds companies whose source summary changed" />
          <HelpKeyValue k="6. compute-similarity" v="rebuilds cortex.similar_companies from embeddings + factor vectors" />
          <HelpKeyValue k="7. generate-queue"   v="rebuilds cortex.research_queue with bucket composites + ranks" />
          <HelpKeyValue k="8. build-payload"    v="splits the rendered dashboard into 7 JSONB rows in cortex.dashboard_payload — what your browser reads" />
          <p style={{ margin: '14px 0 0' }}>
            Model rankings (LightGBM / transformer) are NOT in nightly —
            they&rsquo;re refreshed in a separate monthly workflow because the
            features feeding them are monthly-aggregated.
          </p>
        </DeepDive>
      </div>

      {/* ─── Glossary ───────────────────────────────────────────────────────── */}
      <div style={{ marginTop: 56, marginBottom: 32 }}>
        <HelpKicker label="GLOSSARY" />
        <HelpSectionTitle>Terms &amp; symbols</HelpSectionTitle>
        <div style={{ maxWidth: _SECTION_MAX_WIDTH }}>
          <HelpKeyValue k="compounder"     v="High quality + growth, low risk. The long-term core list." />
          <HelpKeyValue k="cheap_decent"   v="Deep value, decent quality, FCF-positive history. Mean-reversion play." />
          <HelpKeyValue k="inflection"     v="Improving margins + accelerating revenue + early momentum. Turnaround." />
          <HelpKeyValue k="pullback"       v="Quality name in drawdown ≥25% off 52w high. Tactical entry." />
          <HelpKeyValue k="danger"         v="Risk score ≥ 75. Track but don't touch." />
          <HelpKeyValue k="quality"        v="Composite of profitability, balance, capital discipline." />
          <HelpKeyValue k="value"          v="Composite of EV multiples + FCF yield (lower better)." />
          <HelpKeyValue k="growth"         v="Composite of multi-year revenue + EBIT trajectory." />
          <HelpKeyValue k="momentum"       v="Price momentum, sector-relative, trend stability." />
          <HelpKeyValue k="inflection"     v="Recent acceleration in fundamentals — margins, growth, FCF." />
          <HelpKeyValue k="risk"           v="Leverage + dilution + liquidity + volatility + margin deterioration." />
          <HelpKeyValue k="ai_score"       v="Composite of recent press-release sentiment + signal counts. Optional — many small-caps have no Cision coverage." />
          <HelpKeyValue k="research_priority" v="Per-bucket composite that ranks within each bucket. Includes a 10% AI factor weight and a 25–30% risk penalty." />
          <HelpKeyValue k="asof"           v="The feature_date the queue is computed at. Typically the most recent quarter-end." />
          <HelpKeyValue k="data as of"     v="The wall-clock moment the nightly job wrote the on-screen payloads to the DB." />
        </div>
      </div>
    </div>
  );
}

window.PageHelp = PageHelp;
