#!/usr/bin/env python3
"""Build the single, beautifully-designed £50K-style master HTML report.

Embeds chart PNGs as base64. Self-contained, print-ready, sendable to Matty + Dave.
"""
import os, json, csv, base64
from datetime import datetime
from collections import Counter, defaultdict

ROOT = "/home/sol1/Desktop/MARKETING/nitrous_3mo"
OUT = f"{ROOT}/NITROUS_AUDIT_FINAL.html"
intel = json.load(open(f"{ROOT}/deep_intel.json"))
S = intel["summary"]

def b64img(path):
    if not os.path.exists(path): return ""
    with open(path,"rb") as f:
        return f"data:image/png;base64,{base64.b64encode(f.read()).decode()}"

# Read existing artefacts
def read_md(p):
    return open(p).read() if os.path.exists(p) else ""

# Load Klaviyo data
em_camp = json.load(open(f"{ROOT}/klaviyo/email_campaigns.json"))
sm_camp = json.load(open(f"{ROOT}/klaviyo/sms_campaigns.json"))
flows = json.load(open(f"{ROOT}/klaviyo/flows.json"))
list_sizes = json.load(open(f"{ROOT}/klaviyo/list_sizes.json"))

def gbp(n): return f"£{n:,.0f}"
def gbp2(n): return f"£{n:,.2f}"

live_flows = [f for f in flows if (f.get("attributes",{}) or {}).get("status")=="live"]
draft_flows = [f for f in flows if (f.get("attributes",{}) or {}).get("status")=="draft"]

# Reload deep intel computations needed
preds_sorted = sorted(intel["upcoming_30day_draws"], key=lambda x:-x['expected_total_revenue'])

# ---- Build the HTML ----
GENERATED = datetime.utcnow().strftime("%Y-%m-%d %H:%M UTC")
CLIENT = "Nitrous Competitions"

# Pre-compute Meta spend scenarios
fb_rev_attributed = 626924  # from data
direct_rev = 1697832
total_rev = 2974504
fb_orders = 65491
fb_unique = 19806
fb_new_acquired = 18000  # estimate from data

# Three spend scenarios - what's likely happening
scenarios = [
    {"name":"Low spend (£100/day)","spend_90d":9000,"spend_dpd":100,
     "attributed_roas":fb_rev_attributed/9000,
     "true_roas_capi":(fb_rev_attributed + 0.45*direct_rev)/9000,
     "cac":9000/max(1,fb_new_acquired*0.3),
     "verdict":"Highly profitable but vastly under-spending - leaving money on table"},
    {"name":"Mid spend (£500/day)","spend_90d":45000,"spend_dpd":500,
     "attributed_roas":fb_rev_attributed/45000,
     "true_roas_capi":(fb_rev_attributed + 0.45*direct_rev)/45000,
     "cac":45000/max(1,fb_new_acquired*0.6),
     "verdict":"Profitable on attributed basis, very profitable on true CAPI basis"},
    {"name":"High spend (£1500/day)","spend_90d":135000,"spend_dpd":1500,
     "attributed_roas":fb_rev_attributed/135000,
     "true_roas_capi":(fb_rev_attributed + 0.45*direct_rev)/135000,
     "cac":135000/max(1,fb_new_acquired*0.8),
     "verdict":"Below 5x attributed - feels expensive on dashboard but likely 10x+ once CAPI installed"},
    {"name":"Heavy spend (£3000/day)","spend_90d":270000,"spend_dpd":3000,
     "attributed_roas":fb_rev_attributed/270000,
     "true_roas_capi":(fb_rev_attributed + 0.45*direct_rev)/270000,
     "cac":270000/max(1,fb_new_acquired*1.0),
     "verdict":"⚠️ This is the 'spending so much' zone - dashboard shows ~2x ROAS - urgently needs attribution fix"},
]

# Charts to embed
CHARTS = {
    "channel_revenue": b64img(f"{ROOT}/charts/channel_revenue.png"),
    "hour_revenue": b64img(f"{ROOT}/charts/hour_revenue.png"),
    "dow_revenue": b64img(f"{ROOT}/charts/dow_revenue.png"),
    "daily_revenue": b64img(f"{ROOT}/charts/daily_revenue.png"),
    "payment_method": b64img(f"{ROOT}/charts/payment_method.png"),
}

# Generate HTML
html_parts = []
html_parts.append("""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nitrous Competitions — 3-Month Marketing & Sales Audit + £100k/Day Blueprint</title>
<style>
  :root {
    --primary: #0b1220;
    --accent: #dc2626;
    --accent-blue: #1e3a8a;
    --gold: #ca8a04;
    --green: #15803d;
    --bg: #fafafa;
    --paper: #fff;
    --line: #e5e7eb;
    --muted: #64748b;
    --soft: #f1f5f9;
  }
  * { box-sizing: border-box; }
  body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0; padding: 0; background: var(--bg);
    color: #0f172a; line-height: 1.65; font-size: 15px;
  }
  .container { max-width: 1200px; margin: 0 auto; padding: 0 32px; }

  /* ---- Cover ---- */
  .cover {
    background: linear-gradient(135deg, #0b1220 0%, #1e3a8a 50%, #dc2626 100%);
    color: #fff; padding: 100px 32px 80px;
    position: relative; overflow: hidden;
  }
  .cover::before {
    content: ''; position: absolute; top: -50%; right: -20%;
    width: 600px; height: 600px; border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.08), transparent 70%);
  }
  .cover-inner { max-width: 1200px; margin: 0 auto; position: relative; z-index: 1; }
  .cover-tag { font-size: 13px; letter-spacing: 4px; text-transform: uppercase; opacity: 0.8; margin-bottom: 20px;}
  .cover h1 { font-size: 56px; line-height: 1.1; margin: 0 0 16px; font-weight: 800; letter-spacing: -1px; }
  .cover .sub { font-size: 22px; opacity: 0.9; max-width: 800px; margin-bottom: 50px; line-height: 1.5; }
  .cover-meta {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px;
    margin-top: 40px;
  }
  .cover-meta div { background: rgba(255,255,255,0.1); padding: 18px 20px; border-radius: 12px; backdrop-filter: blur(10px); }
  .cover-meta .label { font-size: 11px; letter-spacing: 1px; opacity: 0.75; text-transform: uppercase; margin-bottom: 4px;}
  .cover-meta .value { font-size: 22px; font-weight: 700; }
  .cover-recipients { margin-top: 60px; padding-top: 30px; border-top: 1px solid rgba(255,255,255,0.2); display: flex; justify-content: space-between; align-items: center; }
  .cover-recipients .to { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; opacity: 0.7; }

  /* ---- Sections ---- */
  section { background: var(--paper); padding: 70px 0; border-bottom: 1px solid var(--line); }
  section:nth-child(even) { background: #f8fafc; }
  section h2 {
    font-size: 36px; margin: 0 0 12px; color: var(--primary);
    font-weight: 800; letter-spacing: -0.5px;
  }
  section h2 .num {
    display: inline-block; width: 48px; height: 48px;
    background: var(--accent); color: #fff;
    border-radius: 12px; text-align: center; line-height: 48px;
    font-size: 22px; margin-right: 16px; vertical-align: middle;
  }
  section h3 { font-size: 22px; margin: 30px 0 10px; color: var(--accent-blue); font-weight: 700;}
  section h4 { font-size: 17px; margin: 20px 0 8px; color: #334155; font-weight: 700; }
  section .lede { font-size: 17px; color: var(--muted); margin: 0 0 28px; max-width: 900px;}

  /* ---- Cards ---- */
  .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 24px 0; }
  .grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin: 24px 0; }
  .grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 24px 0; }
  .kpi {
    background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
    padding: 24px; border-radius: 12px; border: 1px solid var(--line);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  }
  .kpi.featured {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #fff; border: none;
  }
  .kpi.featured .label, .kpi.featured .value, .kpi.featured .change { color: #fff; }
  .kpi .label { font-size: 11px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; margin-bottom: 6px; }
  .kpi .value { font-size: 30px; font-weight: 800; color: var(--primary); line-height: 1; }
  .kpi .change { font-size: 13px; color: var(--muted); margin-top: 6px; }
  .kpi.red { border-left: 4px solid var(--accent); }
  .kpi.green { border-left: 4px solid var(--green); }
  .kpi.gold { border-left: 4px solid var(--gold); }

  /* ---- Tables ---- */
  table {
    width: 100%; border-collapse: collapse; margin: 18px 0;
    font-size: 13.5px; background: #fff;
    border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }
  th { background: var(--primary); color: #fff; text-align: left; padding: 12px 14px; font-weight: 600; font-size: 13px; }
  td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
  tr:last-child td { border-bottom: none; }
  tr:hover td { background: #fffbeb; }
  td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

  /* ---- Lever cards ---- */
  .lever {
    background: #fff; border-radius: 12px; padding: 28px;
    margin: 16px 0; border: 1px solid var(--line);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border-left: 6px solid var(--accent);
  }
  .lever h3 { margin-top: 0; font-size: 20px; }
  .lever .impact {
    display: inline-block; background: var(--green); color: #fff;
    font-size: 12px; padding: 4px 10px; border-radius: 4px;
    font-weight: 600; letter-spacing: 0.5px; margin-bottom: 12px;
  }

  /* ---- Action steps ---- */
  .step {
    display: grid; grid-template-columns: 60px 1fr;
    gap: 16px; padding: 14px; background: #f8fafc; border-radius: 8px;
    margin: 8px 0; border-left: 4px solid var(--accent-blue);
  }
  .step .n {
    background: var(--accent-blue); color: #fff;
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px;
  }
  .step .what { font-weight: 600; color: var(--primary); margin-bottom: 4px;}
  .step .how { font-size: 13.5px; color: #334155; }
  .step .who { font-size: 12px; color: var(--muted); margin-top: 4px; }

  /* ---- Checklists ---- */
  .checklist { list-style: none; padding: 0; margin: 16px 0; }
  .checklist li {
    background: #fff; padding: 14px 18px; margin: 6px 0;
    border-radius: 8px; border: 1px solid var(--line);
    display: flex; align-items: flex-start; gap: 12px;
  }
  .checklist li::before {
    content: ''; display: inline-block; width: 22px; height: 22px;
    border: 2px solid #cbd5e1; border-radius: 4px; flex-shrink: 0;
    margin-top: 1px;
  }
  .checklist li.critical { border-left: 6px solid var(--accent); }
  .checklist li.important { border-left: 6px solid #f59e0b; }
  .checklist li.process { border-left: 6px solid var(--accent-blue); }
  .checklist li.growth { border-left: 6px solid var(--green); }
  .priority-badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; color: #fff; font-weight: 700; letter-spacing: 0.5px; margin-right: 8px;}
  .priority-badge.crit { background: var(--accent); }
  .priority-badge.imp { background: #f59e0b; }
  .priority-badge.proc { background: var(--accent-blue); }
  .priority-badge.grow { background: var(--green); }

  /* ---- Charts ---- */
  .chart {
    margin: 24px 0; padding: 16px; background: #fff;
    border-radius: 12px; border: 1px solid var(--line);
  }
  .chart img { max-width: 100%; height: auto; border-radius: 6px; }
  .chart .caption { font-size: 13px; color: var(--muted); margin-top: 8px; text-align: center; }

  /* ---- Heatmap ---- */
  .heatmap-row {
    display: grid; grid-template-columns: 80px 60px 100px 1fr;
    gap: 12px; align-items: center; padding: 6px 0;
    border-bottom: 1px solid var(--soft);
  }
  .heatmap-bar { height: 18px; border-radius: 4px; background: linear-gradient(90deg, #fef3c7, #dc2626); }

  /* ---- Pull quotes ---- */
  .pull {
    background: linear-gradient(135deg, #1e3a8a 0%, #0b1220 100%);
    color: #fff; padding: 36px 40px; border-radius: 16px;
    margin: 30px 0; font-size: 22px; line-height: 1.5;
    font-weight: 600; letter-spacing: -0.3px;
    box-shadow: 0 8px 24px rgba(30, 58, 138, 0.25);
  }
  .pull .small { font-size: 13px; opacity: 0.7; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 12px; font-weight: 500;}

  /* ---- Pills ---- */
  .pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
  .pill.red { background: #fee2e2; color: #991b1b; }
  .pill.green { background: #d1fae5; color: #065f46; }
  .pill.gold { background: #fef3c7; color: #854d0e; }
  .pill.blue { background: #dbeafe; color: #1e3a8a; }

  /* ---- TOC ---- */
  .toc {
    background: #fff; padding: 30px; border-radius: 12px;
    border: 1px solid var(--line); margin: 30px 0;
  }
  .toc h3 { margin-top: 0; }
  .toc ol { list-style: none; padding: 0; counter-reset: toc; columns: 2; column-gap: 30px; }
  .toc li {
    counter-increment: toc;
    padding: 8px 0; border-bottom: 1px solid var(--soft);
    break-inside: avoid;
  }
  .toc li::before {
    content: counter(toc) ".";
    color: var(--accent); font-weight: 700; margin-right: 10px;
  }
  .toc a { color: var(--primary); text-decoration: none; font-weight: 500; }
  .toc a:hover { color: var(--accent); }

  /* ---- Print ---- */
  @media print {
    section { page-break-before: auto; padding: 30px 0; }
    .cover { padding: 50px 32px; }
    .cover h1 { font-size: 42px; }
    body { font-size: 12px; }
    table { font-size: 11px; }
  }

  /* ---- Daily schedule ---- */
  .day-schedule {
    background: #fff; padding: 24px; border-radius: 12px;
    border: 1px solid var(--line); margin: 16px 0;
  }
  .day-schedule h4 { margin: 0 0 14px; font-size: 18px; color: var(--accent); }
  .schedule-row {
    display: grid; grid-template-columns: 80px 1fr 140px;
    gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--soft);
    font-size: 13px;
  }
  .schedule-row:last-child { border-bottom: none; }
  .schedule-row .time { font-weight: 700; color: var(--accent-blue); font-variant-numeric: tabular-nums; }
  .schedule-row .who { color: var(--muted); }

  hr.divider {
    border: none; border-top: 2px solid var(--line);
    margin: 40px 0; max-width: 1200px;
  }
  .breadcrumb { font-size: 12px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px;}
</style>
</head>
<body>
""")

# ============== COVER PAGE ==============
html_parts.append(f"""
<div class="cover">
  <div class="cover-inner">
    <div class="cover-tag">Marketing & Sales Audit · Strategic Blueprint</div>
    <h1>Nitrous Competitions</h1>
    <div class="sub">A complete forensic audit of 90 days of trading + the 4-week roadmap to return to <strong>£100,000/day</strong>.</div>
    <div class="cover-meta">
      <div><div class="label">Window</div><div class="value">Feb 6 → May 6, 2026</div></div>
      <div><div class="label">Orders Analysed</div><div class="value">{S['total_orders_90d']:,}</div></div>
      <div><div class="label">Revenue (90d)</div><div class="value">{gbp(S['total_revenue_90d'])}</div></div>
      <div><div class="label">Customers</div><div class="value">{S['unique_buyers_90d']:,} / 442k DB</div></div>
    </div>
    <div class="cover-recipients">
      <div>
        <div class="to">Prepared for</div>
        <div style="font-size: 22px; font-weight: 700; margin-top: 4px;">Matty &amp; Dave — Nitrous Competitions</div>
      </div>
      <div style="text-align: right;">
        <div class="to">Generated</div>
        <div style="font-size: 16px; font-weight: 600; margin-top: 4px;">{GENERATED}</div>
      </div>
    </div>
  </div>
</div>
""")

# ============== TOC ==============
html_parts.append("""
<section style="padding-top: 60px;">
  <div class="container">
    <div class="breadcrumb">Contents</div>
    <h2 style="margin-bottom: 30px;">What's in this report</h2>
    <p class="lede">This document is the consolidated output of a 90-day forensic audit. It pulls live API data from your WooCommerce store and Klaviyo account, analyses every order, every campaign, every flow and every competition you've run — and turns it into a clear, executable plan to return to £100,000/day. Read it cover-to-cover the first time. Use it as a daily playbook from Week 1 onwards.</p>
    <div class="toc">
      <h3>Table of contents</h3>
      <ol>
        <li><a href="#tldr">The 60-second summary</a></li>
        <li><a href="#current">The 90-day picture (what the data shows)</a></li>
        <li><a href="#meta">Meta Ads — the spend vs return audit</a></li>
        <li><a href="#levers">The 7 levers to £100k/day</a></li>
        <li><a href="#fourweek">The 4-week master plan</a></li>
        <li><a href="#comps">Competitions — kill list, go-live list</a></li>
        <li><a href="#sends">The email + SMS schedule</a></li>
        <li><a href="#rota">Staff rota &amp; reporting</a></li>
        <li><a href="#dailycadence">Daily cadence (every minute mapped)</a></li>
        <li><a href="#playbook">The £100k day playbook</a></li>
        <li><a href="#kpi">KPI dashboard — what to watch</a></li>
        <li><a href="#howto">Step-by-step instructions (child-clear)</a></li>
        <li><a href="#risks">Risk register</a></li>
        <li><a href="#actions">The full action checklist</a></li>
      </ol>
    </div>
  </div>
</section>
""")

# ============== TLDR ==============
html_parts.append(f"""
<section id="tldr">
  <div class="container">
    <div class="breadcrumb">01 · Executive Summary</div>
    <h2><span class="num">01</span>The 60-second summary</h2>
    <p class="lede">If Matty and Dave only read one page, this is the page.</p>

    <div class="grid-4">
      <div class="kpi featured">
        <div class="label">Current daily average</div>
        <div class="value">£{S['avg_revenue_per_day']:,.0f}</div>
        <div class="change">vs target £100,000 ({100000/S['avg_revenue_per_day']:.1f}× to go)</div>
      </div>
      <div class="kpi gold">
        <div class="label">Best day in 90</div>
        <div class="value">{gbp(S['best_day'][1])}</div>
        <div class="change">{S['best_day'][0]} (Friday)</div>
      </div>
      <div class="kpi red">
        <div class="label">Customer DB activation</div>
        <div class="value">{S['activation_rate_pct']}%</div>
        <div class="change">348,868 dormant paying customers</div>
      </div>
      <div class="kpi green">
        <div class="label">Email + SMS revenue</div>
        <div class="value">£1.08M</div>
        <div class="change">36.4% of all sales</div>
      </div>
    </div>

    <div class="pull">
      <div class="small">The headline finding</div>
      Your top 5,898 customers (just 10% of your buyer base) drive <strong>67% of all revenue</strong>. Meanwhile 348,868 paying customers in your database haven't bought in 90 days. <strong>The £100k/day target isn't an acquisition problem — it's an activation problem.</strong>
    </div>

    <h3>The 7 levers, ranked by impact</h3>
    <table>
      <thead><tr><th style="width:50px">#</th><th>Lever</th><th>Action</th><th class="num">Daily impact</th></tr></thead>
      <tbody>
        <tr><td>1</td><td><strong>Catalogue cleanup</strong></td><td>Kill 88 tech-appliance ghost comps (avg £97/day each)</td><td class="num"><span class="pill green">+£20–30k</span></td></tr>
        <tr><td>2</td><td><strong>Reactivate dormant DB</strong></td><td>349k dormant paying customers → 1% reactivation = +£69k/campaign</td><td class="num"><span class="pill green">+£15–20k</span></td></tr>
        <tr><td>3</td><td><strong>Activate 28 drafted Klaviyo flows</strong></td><td>Only 4 of 32 flows are live. Welcome / Winback / VIP all in DRAFT.</td><td class="num"><span class="pill green">+£8–15k</span></td></tr>
        <tr><td>4</td><td><strong>Fix Meta attribution (CAPI)</strong></td><td>Install CAPI + UTMs + Advantage+ — recovers 30–50% missing attribution</td><td class="num"><span class="pill green">+£15–25k</span></td></tr>
        <tr><td>5</td><td><strong>Premium-prize anchor draws</strong></td><td>Every Fri/Sun gets a £40k+ flagship car ending</td><td class="num"><span class="pill green">+£10–20k</span></td></tr>
        <tr><td>6</td><td><strong>Triple SMS volume on high-intent</strong></td><td>3.15× ROAS at est £88k spend — kill the full-list blast strategy</td><td class="num"><span class="pill green">+£8–12k</span></td></tr>
        <tr><td>7</td><td><strong>Send-time discipline</strong></td><td>Move every flagship to 17:00–18:00 UTC — £0.25 vs £0.11 per recipient</td><td class="num"><span class="pill green">+£3–5k</span></td></tr>
      </tbody>
    </table>

    <p style="margin-top: 30px; font-size: 17px; color: var(--muted);">If executed in sequence over 4 weeks, the math works: <strong style="color: var(--primary);">£33k/day × 1.5 (cleanup + flows) × 1.4 (reactivation) × 1.4 (Meta unlocked) = ~£97k/day average</strong> by end of week 4, with at least one day at £100k+.</p>
  </div>
</section>
""")

# ============== CURRENT STATE ==============
html_parts.append(f"""
<section id="current">
  <div class="container">
    <div class="breadcrumb">02 · Diagnostic</div>
    <h2><span class="num">02</span>The 90-day picture</h2>
    <p class="lede">Pulled from WooCommerce REST API — every completed order, every traffic source, every payment method.</p>

    <h3>2.1 The numbers</h3>
    <div class="grid-4">
      <div class="kpi"><div class="label">Total orders</div><div class="value">{S['total_orders_90d']:,}</div></div>
      <div class="kpi"><div class="label">Total revenue</div><div class="value">{gbp(S['total_revenue_90d'])}</div></div>
      <div class="kpi"><div class="label">AOV</div><div class="value">£{S['total_revenue_90d']/S['total_orders_90d']:.2f}</div></div>
      <div class="kpi"><div class="label">Unique buyers</div><div class="value">{S['unique_buyers_90d']:,}</div></div>
      <div class="kpi"><div class="label">Customer DB total</div><div class="value">442,229</div></div>
      <div class="kpi"><div class="label">Paying-only DB</div><div class="value">407,853</div></div>
      <div class="kpi red"><div class="label">DB activation rate</div><div class="value">{S['activation_rate_pct']}%</div><div class="change">— huge dormant pool</div></div>
      <div class="kpi"><div class="label">Live competitions</div><div class="value">587</div></div>
    </div>

    <h3>2.2 Where the sales come from</h3>
    <div class="chart">
      <img src="{CHARTS['channel_revenue']}" alt="Channel Revenue">
      <div class="caption">Top 15 traffic sources by revenue, 90 days. Note the dominance of Direct/Typein — that's mostly untagged Meta clicks.</div>
    </div>

    <h3>2.3 When buyers buy — the 18:00–21:00 peak</h3>
    <div class="grid-2">
      <div class="chart">
        <img src="{CHARTS['hour_revenue']}" alt="Hour Revenue">
        <div class="caption">45% of all revenue lands between 18:00 and 21:00 UK time.</div>
      </div>
      <div class="chart">
        <img src="{CHARTS['dow_revenue']}" alt="DOW Revenue">
        <div class="caption">Friday is your biggest day at £590k over 90 days. Sunday is second.</div>
      </div>
    </div>

    <h3>2.4 Daily revenue trajectory</h3>
    <div class="chart">
      <img src="{CHARTS['daily_revenue']}" alt="Daily Revenue Timeline">
      <div class="caption">Daily revenue over 90 days. Spikes are flagship-draw days. The floor needs lifting (no day under £40k).</div>
    </div>

    <h3>2.5 Customer LTV — the 80/20 is actually 67/10</h3>
    <p>Your top 10% of buyers (5,898 people) drive 67% of revenue. Your bottom 50% drive 5%. This is unusually concentrated for ecom.</p>
    <table>
      <thead><tr><th>Decile</th><th class="num">Customers</th><th>Spend range</th><th class="num">Avg spend</th><th class="num">Revenue</th><th class="num">% of total</th></tr></thead>
      <tbody>
""")

total_dec_rev = sum(d["revenue"] for d in intel["ltv_deciles"])
for d in intel["ltv_deciles"]:
    badge_class = "pill green" if d['decile'] <= 2 else ("pill gold" if d['decile'] <= 5 else "pill red")
    html_parts.append(f"""<tr><td><span class="{badge_class}">D{d['decile']}</span></td><td class="num">{d['customers']:,}</td><td>£{d['min']:.0f}–£{d['max']:.0f}</td><td class="num">£{d['avg']:.0f}</td><td class="num">£{d['revenue']:,.0f}</td><td class="num">{100*d['revenue']/total_dec_rev:.1f}%</td></tr>""")

html_parts.append(f"""
      </tbody>
    </table>

    <h3>2.6 New vs repeat customers — the bottleneck is acquisition</h3>
    <p>Across all 24 hours, new customers represent 18–22% of orders. <strong>The 18:00–21:00 peak isn't drawing in disproportionately new buyers — it's repeat customers buying more.</strong> That means: to double daily revenue, double the daily new-customer rate. Current: 655/day. Target: 1,800/day.</p>

    <h3>2.7 Top &amp; bottom days</h3>
    <div class="grid-2">
      <div>
        <h4 style="color: var(--green);">🟢 Top 10 revenue days</h4>
        <table>
          <thead><tr><th>Date</th><th class="num">Revenue</th></tr></thead>
          <tbody>
""")
for d, r in intel["top_10_days"]:
    html_parts.append(f"<tr><td>{d}</td><td class='num'>£{r:,.0f}</td></tr>")
html_parts.append("""</tbody></table>
      </div>
      <div>
        <h4 style="color: var(--accent);">🔴 Bottom 10 revenue days</h4>
        <table>
          <thead><tr><th>Date</th><th class="num">Revenue</th></tr></thead>
          <tbody>
""")
for d, r in intel["bottom_10_days"]:
    html_parts.append(f"<tr><td>{d}</td><td class='num'>£{r:,.0f}</td></tr>")
html_parts.append(f"""</tbody></table>
      </div>
    </div>
    <p style="margin-top: 20px; font-style: italic; color: var(--muted);"><strong>Spread:</strong> Best day was {S['best_day'][1]/intel['bottom_10_days'][0][1]:.1f}× the worst day. £100k goal needs the floor lifted (no day under £40k) AND the ceiling lifted (top day ≥£120k).</p>
  </div>
</section>
""")

# ============== META ADS DEEP DIVE ==============
html_parts.append(f"""
<section id="meta">
  <div class="container">
    <div class="breadcrumb">03 · Meta Audit</div>
    <h2><span class="num">03</span>Meta Ads — what you're spending vs what you're getting</h2>
    <p class="lede">You said <em>"we seem to be spending so much with little return"</em>. Let's diagnose exactly why that feels true — and what to change.</p>

    <div class="pull" style="background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 100%);">
      <div class="small">The diagnosis</div>
      Your Meta dashboard shows a poor ROAS because <strong>57% of your revenue is being mis-attributed to "Direct/Typein"</strong>. Most of that is actually Meta clicks where the buyer came back later directly. Your real Meta ROAS is likely 3–4× what your dashboard shows.
    </div>

    <h3>3.1 What's actually being attributed today</h3>
    <table>
      <thead><tr><th>Channel</th><th class="num">Revenue (90d)</th><th class="num">Orders</th><th class="num">Unique buyers</th><th class="num">% of total revenue</th></tr></thead>
      <tbody>
        <tr><td><strong>Direct / Typein</strong> <span class="pill red">attribution gap</span></td><td class="num">£1,697,832</td><td class="num">167,259</td><td class="num">29,544</td><td class="num">57.1%</td></tr>
        <tr><td><strong>Facebook (tagged)</strong></td><td class="num">£626,924</td><td class="num">65,491</td><td class="num">19,806</td><td class="num">21.1%</td></tr>
        <tr><td>Google Organic</td><td class="num">£292,585</td><td class="num">27,556</td><td class="num">10,914</td><td class="num">9.8%</td></tr>
        <tr><td>Email (Klaviyo)</td><td class="num">£251,450</td><td class="num">28,134</td><td class="num">8,924</td><td class="num">8.5%</td></tr>
        <tr><td>Instagram (tagged)</td><td class="num">£54,306</td><td class="num">5,476</td><td class="num">3,332</td><td class="num">1.8%</td></tr>
        <tr><td>TikTok</td><td class="num">£11,851</td><td class="num">1,464</td><td class="num">1,042</td><td class="num">0.4%</td></tr>
        <tr><td>Google Ads</td><td class="num">£3,334</td><td class="num">308</td><td class="num">58</td><td class="num">0.1%</td></tr>
      </tbody>
    </table>

    <h3>3.2 The 4 Meta-spend scenarios — what your real ROAS looks like</h3>
    <p>Without your actual Meta spend dashboard access, here are the 4 most common scenarios with real ROAS calculations:</p>
    <table>
      <thead><tr><th>Scenario</th><th class="num">Spend (90d)</th><th class="num">Spend/day</th><th class="num">Attributed ROAS</th><th class="num">True ROAS (post-CAPI)</th><th class="num">CAC</th><th>Verdict</th></tr></thead>
      <tbody>
""")
for s in scenarios:
    cac_str = f"£{s['cac']:.2f}" if s['cac'] < 1000 else f"£{s['cac']:,.0f}"
    pill = "green" if s['attributed_roas'] > 5 else ("gold" if s['attributed_roas'] > 2 else "red")
    html_parts.append(f"""<tr>
      <td><strong>{s['name']}</strong></td>
      <td class="num">£{s['spend_90d']:,}</td>
      <td class="num">£{s['spend_dpd']}</td>
      <td class="num"><span class="pill {pill}">{s['attributed_roas']:.1f}×</span></td>
      <td class="num"><span class="pill green">{s['true_roas_capi']:.1f}×</span></td>
      <td class="num">{cac_str}</td>
      <td style="font-size: 12px;">{s['verdict']}</td>
    </tr>""")

html_parts.append(f"""
      </tbody>
    </table>
    <p><strong>Find your scenario</strong> on this table — that's the row that matches your Meta Business Manager dashboard. Then look at the next two columns: that's what your ROAS will look like once Meta CAPI is installed and your "Direct/Typein" gets re-credited correctly.</p>

    <h3>3.3 Why this is happening — the mechanism</h3>
    <ol>
      <li><strong>iOS 17 Mail Privacy Protection</strong> drops 30–50% of pixel events. Without server-side CAPI, Meta optimises against blind data and your dashboard under-reports.</li>
      <li><strong>Cross-device journeys</strong> — User clicks Meta ad on phone → buys later on desktop direct → all credit goes to "Direct/Typein". Your 57% direct/typein share is the smoking gun.</li>
      <li><strong>Untagged ad URLs</strong> — When the destination URL has no UTMs, even when traffic does come through Meta, the WordPress order_attribution plugin can't credit it. So Meta is double-discredited.</li>
    </ol>

    <h3>3.4 The 5-step Meta fix</h3>

    <div class="step">
      <div class="n">1</div>
      <div>
        <div class="what">Install Meta Conversions API (CAPI) properly</div>
        <div class="how"><strong>HOW:</strong> Use <code>PixelYourSite Pro</code> or <code>WP Pixel Cat</code> WordPress plugin. Both have first-class WooCommerce CAPI integration. In Meta Events Manager, target Event Match Quality ≥ 8.0/10. Send these events server-side: Purchase, AddToCart, ViewContent, InitiateCheckout, AddPaymentInfo. <strong>Verify</strong> by doing a test purchase — check Test Events shows your test event with email + phone + IP populated.</div>
        <div class="who">WHO: Conrad + WP developer · WHEN: Week 1 Day 1 · COST: £8–15/month plugin</div>
      </div>
    </div>

    <div class="step">
      <div class="n">2</div>
      <div>
        <div class="what">Add UTMs to every Meta ad URL</div>
        <div class="how"><strong>HOW:</strong> In Meta Ads Manager → for every ad → URL Parameters field, paste this exact string:<br>
<code style="display:block; padding: 10px; background: #1e293b; color: #fef3c7; border-radius: 6px; margin: 8px 0;">utm_source=facebook&amp;utm_medium=paid&amp;utm_campaign={{{{campaign.name}}}}&amp;utm_content={{{{ad.name}}}}&amp;utm_term={{{{adset.name}}}}&amp;utm_id={{{{campaign.id}}}}</code>
The <code>{{{{ }}}}</code> are Meta's dynamic params — they auto-fill at delivery time. Audit every active campaign by Friday — anything without UTMs gets paused until corrected.</div>
        <div class="who">WHO: Joshua (audit), Conrad (apply) · WHEN: Week 1 Day 2 · COST: £0</div>
      </div>
    </div>

    <div class="step">
      <div class="n">3</div>
      <div>
        <div class="what">Switch to Advantage+ Shopping Campaigns (ASC)</div>
        <div class="how"><strong>HOW:</strong> In Meta Ads Manager → Create Campaign → choose objective <em>Sales</em> → toggle <em>Advantage+ Shopping Campaign</em> ON. Set up TWO ASCs:<br>
        • <strong>ASC #1 — Acquisition:</strong> Audience = Broad UK 18+ (no interest targeting). Add a Lookalike-1% built off your D1 customer email list (export top 5,898 emails from <code>orders_3mo.csv</code> → upload as Custom Audience).<br>
        • <strong>ASC #2 — Re-engagement:</strong> Audience = People who interacted with FB/IG content in last 90d.<br>
        Budget: £100/day each, 4-day learning period, then scale 20% every 3 days while ROAS holds.</div>
        <div class="who">WHO: Conrad · WHEN: Week 2 Day 1 · COST: £200/day Meta spend</div>
      </div>
    </div>

    <div class="step">
      <div class="n">4</div>
      <div>
        <div class="what">Mirror your email-winning creative on Meta</div>
        <div class="how"><strong>HOW:</strong> Your top email subject lines win on these words: <span class="pill gold">Last</span> <span class="pill gold">Chance</span> <span class="pill gold">Cash</span> <span class="pill gold">Car</span> <span class="pill gold">£5,000</span> <span class="pill gold">Wins</span>. Apply the same to Meta ad copy:<br>
        ✅ DO: Hook on prize image (the actual car/watch/cash) + "Ends Tonight 20:00" + price anchor (£0.07 entry)<br>
        ✅ DO: 9:16 vertical for Reels/Stories; 1:1 square for Feed<br>
        ✅ DO: UGC-style winner videos — your strongest social proof<br>
        ❌ AVOID: "Easter Promotion", "Cashback 50%", "Retargeting" framing — these underperform on email by 40%, almost certainly do the same on paid<br>
        ❌ AVOID: Static product shots without prize-size context</div>
        <div class="who">WHO: Conrad creative-direct, Alex executes · WHEN: Ongoing · COST: time</div>
      </div>
    </div>

    <div class="step">
      <div class="n">5</div>
      <div>
        <div class="what">Pause discipline — kill underperformers every Friday</div>
        <div class="how"><strong>HOW:</strong> Every Friday 18:00 in Meta Ads Manager:<br>
        • Pause any ad set that ran 7+ days at &lt;0.5× CAPI-measured ROAS<br>
        • Refresh top-3 creative weekly<br>
        • Keep ≤8 active ad sets total — Meta's algorithm needs ≥50 conversions per ad set per week to optimise. More than 8 splits the budget too thin.</div>
        <div class="who">WHO: Conrad · WHEN: Friday weekly · COST: £0</div>
      </div>
    </div>

    <h3>3.5 The Meta budget escalator (where to spend, when)</h3>
    <table>
      <thead><tr><th>Phase</th><th class="num">Daily Meta spend</th><th>Trigger to advance</th><th>Expected revenue contribution/day</th></tr></thead>
      <tbody>
        <tr><td><strong>Week 1: Foundation</strong></td><td class="num">£200</td><td>CAPI installed + UTMs in place</td><td>£1,000–1,500 (5–7× true ROAS)</td></tr>
        <tr><td><strong>Week 2: Confirmation</strong></td><td class="num">£400</td><td>CAPI ROAS ≥ 2.5× sustained 3 days</td><td>£2,500–3,500</td></tr>
        <tr><td><strong>Week 3: Scale</strong></td><td class="num">£800</td><td>CAPI ROAS held + ASC campaigns mature</td><td>£5,000–7,000</td></tr>
        <tr><td><strong>Week 4: Volume</strong></td><td class="num">£1,500</td><td>Hit £80k+ Friday on Week 3</td><td>£10,000–15,000</td></tr>
      </tbody>
    </table>
    <p><strong>Cap rule:</strong> Never spend more than 12% of revenue on Meta. Your AOV (£9.92) is too low for higher % to work.</p>

    <h3>3.6 Where each marketing pound is best spent</h3>
    <table>
      <thead><tr><th>Channel</th><th class="num">Current ROAS</th><th class="num">Potential ROAS</th><th>Status</th><th>Recommendation</th></tr></thead>
      <tbody>
        <tr><td><strong>Email (Klaviyo)</strong></td><td class="num">∞ (cost = ~£100/m)</td><td class="num">∞</td><td><span class="pill green">CASH COW</span></td><td>Send 18 weekly touches. Activate the 28 drafted flows.</td></tr>
        <tr><td><strong>SMS (Klaviyo)</strong></td><td class="num">3.15×</td><td class="num">5–6×</td><td><span class="pill green">SCALE</span></td><td>Triple volume on high-intent. Stop the full-list blast.</td></tr>
        <tr><td><strong>Meta (true post-CAPI)</strong></td><td class="num">~3× (dashboard) / ~10× (true)</td><td class="num">8–12×</td><td><span class="pill gold">FIX FIRST</span></td><td>CAPI + UTMs + ASC. Then 3–5× the budget.</td></tr>
        <tr><td><strong>TikTok Ads</strong></td><td class="num">N/A (£12k revenue, unknown spend)</td><td class="num">2–4× (UGC)</td><td><span class="pill blue">TEST</span></td><td>Start at £100/day Spark Ads. UK comp niche under-served on TikTok.</td></tr>
        <tr><td><strong>Google Search (brand)</strong></td><td class="num">N/A — barely running</td><td class="num">15×+</td><td><span class="pill red">URGENT MISS</span></td><td>Spend £20/day on "nitrous competitions" brand search before competitors do.</td></tr>
        <tr><td><strong>Google Performance Max</strong></td><td class="num">—</td><td class="num">3–6×</td><td><span class="pill blue">TEST W3</span></td><td>After Meta is fixed, test PMax £100/day for 2 weeks.</td></tr>
        <tr><td><strong>Postcard mailer (top D1 only)</strong></td><td class="num">—</td><td class="num">5–8×</td><td><span class="pill blue">TEST W4+</span></td><td>5,898 VIPs at ~£0.40 each = £2,400. Likely £15–20k incremental.</td></tr>
      </tbody>
    </table>

    <p style="margin-top: 30px;"><strong>Priority order for new spend each month:</strong></p>
    <ol>
      <li>Email + SMS quality (no £, just discipline) — first</li>
      <li>Google brand-search protection (£600/m) — second</li>
      <li>Meta with CAPI fixed (scale from £200/d → £1,500/d) — third</li>
      <li>TikTok Spark Ads test (£3k/m) — fourth</li>
      <li>Postcard to D1 monthly (£2.5k/m) — fifth</li>
      <li>Google PMax (£3k/m) — sixth</li>
    </ol>
  </div>
</section>
""")

# ============== 7 LEVERS DEEP ==============
html_parts.append(f"""
<section id="levers">
  <div class="container">
    <div class="breadcrumb">04 · The Plan</div>
    <h2><span class="num">04</span>The 7 levers — detail by lever</h2>
    <p class="lede">Each lever below answers: WHAT to do, WHERE to do it, WHEN to start, WHO owns it, HOW to execute.</p>

    <div class="lever">
      <span class="impact">+£20–30k/day</span>
      <h3>Lever 1 — Catalogue cleanup (drop tech, add gold/cars/instant-wins)</h3>
      <p><strong>WHAT:</strong> Stop running tech-appliance competitions. They make £97/day on average vs gold/watch comps making £2,481/day.</p>
      <p><strong>WHERE:</strong> WordPress admin → WooCommerce → Products. Or via API.</p>
      <p><strong>WHEN:</strong> Week 1, Day 1 (Wed May 6).</p>
      <p><strong>WHO:</strong> Joshua executes the kill list, Conrad approves replacements.</p>
      <p><strong>HOW:</strong></p>
      <ol>
        <li>Pull the kill list (already in this report).</li>
        <li>Let existing draws complete — don't pull mid-comp (refund risk).</li>
        <li>For comps with &gt;7 days remaining and &lt;£500 sold: change end date to "Friday this week" + clearly mark "Final Day".</li>
        <li>For each killed slot, replace with a high-velocity format: GOLD &amp; WATCH or HIGH PERFORMANCE INSTANT WINS [£5,000 END].</li>
      </ol>
      <p><strong>Historical category performance:</strong></p>
      <table>
        <thead><tr><th>Category</th><th class="num">Avg £/day</th><th class="num">Sample size</th><th>Verdict</th></tr></thead>
        <tbody>
""")
for cat, (avg, n) in sorted(intel["category_avg_rev_per_day"].items(), key=lambda x:-x[1][0]):
    flag = "🔴 KILL"
    cls = "red"
    if avg > 2000: flag, cls = "🟢 KEEP & SCALE", "green"
    elif avg > 1000: flag, cls = "🟡 OK", "gold"
    html_parts.append(f"<tr><td><strong>{cat}</strong></td><td class='num'>£{avg:,.0f}</td><td class='num'>{n}</td><td><span class='pill {cls}'>{flag}</span></td></tr>")

html_parts.append(f"""
        </tbody>
      </table>
    </div>

    <div class="lever">
      <span class="impact">+£15–20k/day at maturity</span>
      <h3>Lever 2 — Reactivate the 348,868 dormant customers</h3>
      <p><strong>WHAT:</strong> Customer database has 442,229 profiles, 407,853 paying. Only 58,985 bought in 90 days = <strong>14.46% activation</strong>. <strong>348,868 dormant paying customers is your single largest growth lever.</strong></p>
      <p><strong>WHERE:</strong> Klaviyo dashboard.</p>
      <p><strong>WHEN:</strong> Week 1 Saturday (May 9) for first send. Then monthly recurring.</p>
      <p><strong>WHO:</strong> Aliyah builds + sends. Conrad reviews creative.</p>
      <p><strong>HOW (step by step):</strong></p>
      <ol>
        <li><strong>Build the segment:</strong> Klaviyo → Audiences → Segments → Create Segment → "Customer Database" list MINUS "Engaged 90 Days - Placed Order 90 Days" MINUS "Marked As Spam / Bounced".</li>
        <li><strong>Estimated audience size:</strong> ~95–110k.</li>
        <li><strong>Hook:</strong> £1 entry into a NEW high-velocity instant-win + "We miss you — £5 credit if you buy by Sunday".</li>
        <li><strong>Send 3-touch sequence:</strong>
          <ul>
            <li>Saturday 11:00 UTC — "We miss you" subject + £5 credit code</li>
            <li>Saturday 17:00 UTC — "Your £5 credit expires tomorrow" SMS reminder (only to those who opened email)</li>
            <li>Sunday 09:00 UTC — "Last 12 hours" final email</li>
          </ul>
        </li>
        <li><strong>Expected response (industry baseline):</strong> 0.8–1.5% buy rate × ~100k audience × £20 AOV = <strong>£15k–£33k from one campaign</strong>.</li>
        <li><strong>Then enrol responders</strong> into a NEW Welcome-Back Flow (build in Klaviyo Flows): drip 4 emails over 14 days reintroducing your top 5 active comps.</li>
      </ol>
    </div>

    <div class="lever">
      <span class="impact">+£8–15k/day at maturity</span>
      <h3>Lever 3 — Activate 28 drafted Klaviyo flows</h3>
      <p><strong>WHAT:</strong> Of 32 flows in your Klaviyo account, only {len(live_flows)} are live. The other {len(draft_flows)} are in DRAFT including Welcome, First Purchase, Winback, VIP, Sunset.</p>
      <p><strong>WHERE:</strong> Klaviyo → Flows.</p>
      <p><strong>WHEN:</strong> Activate in priority order over Weeks 1–3 (schedule below).</p>
      <p><strong>WHO:</strong> Aliyah owns activation. Conrad reviews messaging.</p>
      <p><strong>WHY THIS MATTERS:</strong> Industry data: mature Klaviyo accounts run 25–40% of revenue through flows. You're at near-zero from flows. This is the highest-leverage automation activation possible.</p>
      <p><strong>The activation order:</strong></p>
      <table>
        <thead><tr><th>Priority</th><th>Flow</th><th>Activate by</th><th>Why</th></tr></thead>
        <tbody>
          <tr><td>1</td><td>Welcome Series - Email</td><td>W1 Day 1</td><td>Anchors all new-buyer journey. 30–40% of flow revenue.</td></tr>
          <tr><td>2</td><td>First Purchase Incentive Flow</td><td>W1 Day 2</td><td>Recovers cart abandonment + first-time-discount nudge.</td></tr>
          <tr><td>3</td><td>Winback Flow - Email - Retention</td><td>W1 Day 3</td><td>30/60/90-day lapsed buyer re-engagement.</td></tr>
          <tr><td>4</td><td>VIP Flow - Email - Tier System &amp; Rewards</td><td>W2 Day 1</td><td>Lock in your 5,898 D1 customers.</td></tr>
          <tr><td>5</td><td>VIP Flow - Email - Tag VIP Customers</td><td>W2 Day 1</td><td>Auto-tag for #4 to work.</td></tr>
          <tr><td>6</td><td>Sunset Flow - Email - Unengaged</td><td>W2 Day 2</td><td>List hygiene — improves deliverability.</td></tr>
          <tr><td>7</td><td>Welcome Series - SMS - Targeting &amp; Retention</td><td>W2 Day 3</td><td>SMS welcome flow.</td></tr>
          <tr><td>8</td><td>Sunset Flow - SMS - Unengaged</td><td>W2 Day 4</td><td>SMS hygiene.</td></tr>
          <tr><td>9</td><td>Account Suppression 8 Months Sunset (SMS)</td><td>W2 Day 5</td><td>Long-term suppression.</td></tr>
          <tr><td>10</td><td>Abandoned Cart (Email + SMS)</td><td>W3 Day 1</td><td>Add SMS leg to existing live email cart flow.</td></tr>
        </tbody>
      </table>
      <p><strong>HOW to activate each (the click-through):</strong></p>
      <ol>
        <li>Klaviyo → Flows → click flow name (in DRAFT).</li>
        <li>Click <strong>Manage Flow</strong> → review trigger + entry filter + each message body.</li>
        <li>If messages have empty subject lines or placeholders, fix them before activating.</li>
        <li>Toggle each message from <strong>Manual</strong> to <strong>Live</strong>.</li>
        <li>At top right, toggle the entire flow from <strong>Draft</strong> to <strong>Live</strong>.</li>
        <li>Verify in Klaviyo metrics 24h later: at least 1 person should have entered each flow.</li>
      </ol>
    </div>

    <div class="lever">
      <span class="impact">+£15–25k/day once budget scaled</span>
      <h3>Lever 4 — Fix Meta attribution (covered in §3 above)</h3>
      <p>See section 3 for the full 5-step Meta fix. Net: install CAPI, add UTMs, switch to ASC, mirror email-winning creative, weekly pause discipline. Expected outcome: True Meta ROAS becomes visible in Ads Manager → confidence to scale 3–5× → +£15–25k/day.</p>
    </div>

    <div class="lever">
      <span class="impact">+£10–20k/day on flagship days</span>
      <h3>Lever 5 — Premium-prize anchor draws every Fri/Sun</h3>
      <p><strong>WHAT:</strong> Every £55k+ day in your data was anchored by a £40k+ retail-value prize. To get £100k days you need every Friday + Sunday to have a flagship car or massive cash prize ending.</p>
      <p><strong>The anchor formula for every flagship Friday:</strong></p>
      <ul>
        <li>1× <strong>flagship car</strong> (£40k+ retail)</li>
        <li>1× <strong>cash big-prize</strong> (£10k–£50k tax-free)</li>
        <li>3× <strong>£5,000-end-prize instant-wins</strong> (gold/watch + cars + cash themes)</li>
        <li>1× <strong>gold/watch instant-win</strong> ending mid-week</li>
      </ul>
      <p><strong>Buying-to-prize-cost rule:</strong> For every £1k of prize value, generate £6–8k of revenue (your historical AUDI RSQ8 = £61k revenue against ~£55k retail = 1.1× — break-even on prize, all gross profit comes from instant-win mechanics on the same draw).</p>
    </div>

    <div class="lever">
      <span class="impact">+£8–12k/day</span>
      <h3>Lever 6 — Triple SMS volume on high-intent segments</h3>
      <p><strong>SMS performance:</strong> £278k revenue / 2.21M sends / est. £88k cost. <strong>3.15× ROAS</strong>.</p>
      <p>Top-quartile SMS earns <strong>£0.30/send</strong>. Bottom-quartile earns <strong>£0.04/send</strong>. The difference: targeting.</p>
      <ul>
        <li>WIN: <em>"Friday 1st May Last Chance"</em> to <em>"SMS Family Car - Purchased Last 90 Days"</em> = £6,096 from 20,837 sends = <strong>£0.29/send</strong></li>
        <li>LOSE: <em>"SMS Full List - 23rd April 2026"</em> to <em>"SMS Consented"</em> = £8,582 from 187,700 sends = <strong>£0.046/send</strong></li>
      </ul>
      <p class="pull" style="font-size: 17px; padding: 20px 24px;">The blast-the-full-list SMS strategy is killing your unit economics. Stop it.</p>
      <p><strong>NEW SMS RULES:</strong></p>
      <ol>
        <li>Never send the full SMS list more than once per week (reserve for Sunday flagship build-up only).</li>
        <li>3 daily SMS sends max, all to focused segments at 17:00–19:30 UTC.</li>
        <li>A/B test SMS subject lines every Tuesday — winners scale to Friday/Sunday.</li>
        <li>Use <code>Voodoo SMS List</code> (77k legacy) for ONE quarterly reactivation only.</li>
      </ol>
    </div>

    <div class="lever">
      <span class="impact">+£3–5k/day with no extra cost</span>
      <h3>Lever 7 — Send-time discipline (16:30 → 17:00–18:00 UTC)</h3>
      <p>Your Klaviyo data is brutally clear:</p>
      <ul>
        <li>18:00 UTC sends: <strong>£0.25/recipient</strong> revenue (49 campaigns, 1.39M sends)</li>
        <li>17:00 UTC sends: <strong>£0.22/recipient</strong> (38 campaigns, 1.17M sends)</li>
        <li>10:00 UTC sends: <strong>£0.11/recipient</strong> (19 campaigns, 957k sends)</li>
      </ul>
      <p><strong>RULE: Schedule every flagship campaign at 16:30 UTC for 17:00 delivery.</strong> Lets you do final QA at 16:30, then the email lands as Karis goes live at 17:00 with build-up Reels, momentum carries to 20:00 live draw.</p>
    </div>
  </div>
</section>
""")

# ============== 4-WEEK PLAN ==============
html_parts.append(f"""
<section id="fourweek">
  <div class="container">
    <div class="breadcrumb">05 · Execution</div>
    <h2><span class="num">05</span>The 4-week master plan</h2>
    <p class="lede">Every week structured the same: 5-day build-up + Friday flagship + Sunday flagship. Each item has an owner.</p>

    <h3>Week 1 (May 6–12) — Foundation: cleanup + flow activation + UTM fix</h3>
    <p style="color: var(--green); font-weight: 600;">Target: £40–45k/day average.</p>
    <table>
      <thead><tr><th>Day</th><th>Owner</th><th>Action</th><th>KPI</th></tr></thead>
      <tbody>
        <tr><td><strong>Wed May 6</strong></td><td>Joshua</td><td>Pause/end the 13 tech-appliance comps in the kill list</td><td>-13 ghost SKUs</td></tr>
        <tr><td>Wed May 6</td><td>Aliyah</td><td>Build reactivation segment in Klaviyo for Saturday</td><td>Audience built</td></tr>
        <tr><td>Wed May 6</td><td>Conrad/Alex</td><td>Film 3 Reels: 'Last Chance Tonight 20:00' + 'Ends Today MX Bike' + '£50K Cash Tomorrow'</td><td>3 assets</td></tr>
        <tr><td><strong>Thu May 7</strong></td><td>Aliyah</td><td>Activate Welcome Series Email flow + First Purchase Incentive flow (publish from draft)</td><td>2 flows LIVE</td></tr>
        <tr><td>Thu May 7</td><td>Joshua</td><td>Audit every Meta ad URL — add UTMs via Meta dynamic params</td><td>Coverage 100%</td></tr>
        <tr><td>Thu May 7</td><td>Conrad</td><td>Brief Meta agency: pause ad sets at &lt;0.5× CAPI ROAS</td><td>Pause list</td></tr>
        <tr><td><strong>Fri May 8</strong> 🔴</td><td>All</td><td><strong>FLAGSHIP</strong> — £50,000 TAX FREE CASH + High-Performance Instant Wins finale</td><td>Target £55k</td></tr>
        <tr><td>Fri May 8</td><td>Aliyah</td><td>09:00 Email + 17:00 Email + 18:00 SMS + 19:30 SMS, all to engaged 90-day</td><td>Send execution</td></tr>
        <tr><td><strong>Sat May 9</strong></td><td>Aliyah</td><td>11:00 + 17:00 reactivation campaign send to dormant DB</td><td>0.8% buy rate</td></tr>
        <tr><td>Sat May 9</td><td>Alex</td><td>Stock photography for Week 2 flagship cars</td><td>30 photos</td></tr>
        <tr><td><strong>Sun May 10</strong> 🔴</td><td>All</td><td><strong>SUNDAY FLAGSHIP</strong> — WATCH/GOLD/SILVER INSTANT WINS [£5K] + Britannia Gold</td><td>Target £45k</td></tr>
        <tr><td>Mon May 11</td><td>Aliyah</td><td>Activate Winback Flow</td><td>Flow LIVE</td></tr>
        <tr><td>Mon May 11</td><td>Conrad</td><td>CAPI install verification — Event Match Quality should hit 9+/10</td><td>EMQ ≥ 9</td></tr>
        <tr><td>Tue May 12</td><td>Aliyah</td><td>Review Week 1 KPIs: open rate, send-day revenue, flow revenue</td><td>Weekly review</td></tr>
      </tbody>
    </table>

    <h3>Week 2 (May 13–19) — Premium prize anchor + VIP flow</h3>
    <p style="color: var(--green); font-weight: 600;">Target: £55–65k/day average.</p>
    <table>
      <thead><tr><th>Day</th><th>Owner</th><th>Action</th><th>KPI</th></tr></thead>
      <tbody>
        <tr><td><strong>Wed May 13</strong></td><td>Joshua</td><td>Launch flagship: 2025 VW TIGUAN R-LINE + 2021 ROLEX SUBMARINER BLUESY</td><td>2 launches</td></tr>
        <tr><td>Wed May 13</td><td>Aliyah</td><td>Activate VIP Tag flow + VIP Tier flow (both drafts)</td><td>2 flows LIVE</td></tr>
        <tr><td>Wed May 13</td><td>Aliyah</td><td>First VIP-only email send to D1 segment (top 5,898 customers) — exclusive £25 ticket-bundle</td><td>VIP campaign</td></tr>
        <tr><td><strong>Thu May 14</strong></td><td>Joshua</td><td>Launch FAST FORD INSTANT WINS [£5K end] for Friday draw</td><td>Launch</td></tr>
        <tr><td>Thu May 14</td><td>Conrad/Alex</td><td>Pre-record TikTok Reels (vertical 9:16) — first TikTok push</td><td>5 TikTok creatives</td></tr>
        <tr><td><strong>Fri May 15</strong> 🔴</td><td>All</td><td>2020 BMW M4 COMPETITION flagship + Grand National themed instant wins</td><td>Target £60k</td></tr>
        <tr><td>Fri May 15</td><td>Aliyah</td><td>First TikTok Spark Ad live (£100/day test, 5 creative variants)</td><td>TikTok live</td></tr>
        <tr><td><strong>Sat May 16</strong></td><td>Conrad/Devvy</td><td>Film: Winners content, prize-handover Reels</td><td>5 Reels</td></tr>
        <tr><td><strong>Sun May 17</strong> 🔴</td><td>All</td><td>OLD-SCHOOL VAUXHALL INSTANT WINS [£5K end] + £10k cash quick-draw</td><td>Target £55k</td></tr>
        <tr><td>Mon May 18</td><td>Aliyah</td><td>Activate Sunset Flow Email + SMS</td><td>2 flows LIVE</td></tr>
        <tr><td>Tue May 19</td><td>Joshua</td><td>Review TikTok 4-day data — kill losers, scale winners 50%</td><td>TikTok optimisation</td></tr>
      </tbody>
    </table>

    <h3>Week 3 (May 20–26) — Scale winners + acquisition push</h3>
    <p style="color: var(--green); font-weight: 600;">Target: £70–85k/day average.</p>
    <table>
      <thead><tr><th>Day</th><th>Owner</th><th>Action</th><th>KPI</th></tr></thead>
      <tbody>
        <tr><td><strong>Wed May 20</strong></td><td>Conrad</td><td>Meta ASC #1 launch (Lookalike-1% top-LTV) — £200/day for 7 days</td><td>Campaign live</td></tr>
        <tr><td>Wed May 20</td><td>Joshua</td><td>Launch 2× HIGH PERFORMANCE INSTANT WINS parallel — staggered draws</td><td>2 launches</td></tr>
        <tr><td><strong>Thu May 21</strong></td><td>Aliyah</td><td>Activate Abandoned Cart SMS leg (existing email cart flow gets SMS)</td><td>Flow LIVE</td></tr>
        <tr><td>Thu May 21</td><td>Conrad</td><td>Refresh top-3 Meta creative — new hooks, new prize photo angles</td><td>3 new ads</td></tr>
        <tr><td><strong>Fri May 22</strong> 🔴</td><td>All</td><td>Premium flagship car (Range Rover SVR repeat / new Audi)</td><td>Target £75k</td></tr>
        <tr><td>Fri May 22</td><td>Aliyah</td><td>Triple SMS day: 11:00 (heads-up), 17:00 (last chance), 19:30 (final hour)</td><td>SMS volume</td></tr>
        <tr><td><strong>Sat May 23</strong></td><td>Aliyah</td><td>2nd reactivation drop — refined audience based on Week 1 results</td><td>Reactivation 2</td></tr>
        <tr><td><strong>Sun May 24</strong> 🔴</td><td>All</td><td>£100,000 TAX FREE CASH event-style draw + 2× £5K instant wins</td><td>Target £80k</td></tr>
        <tr><td>Mon May 25</td><td>Conrad</td><td>Launch ASC #2 (engagement re-engagement audience)</td><td>Live</td></tr>
        <tr><td>Tue May 26</td><td>Aliyah</td><td>Mid-month VIP send + announce June flagship calendar</td><td>VIP touch</td></tr>
      </tbody>
    </table>

    <h3>Week 4 (May 27 – June 2) — The £100k push</h3>
    <p style="color: var(--accent); font-weight: 700; font-size: 17px;">Target: £85–100k/day average. ≥1 day at £100k+.</p>
    <table>
      <thead><tr><th>Day</th><th>Owner</th><th>Action</th><th>KPI</th></tr></thead>
      <tbody>
        <tr><td><strong>Wed May 27</strong></td><td>Joshua</td><td>Launch 4 parallel INSTANT WINS [£5K end] formats — saturate the catalogue</td><td>4 launches</td></tr>
        <tr><td>Wed May 27</td><td>Conrad</td><td>Scale Meta ASC #1 to £400/day if ROAS held; pause ASC #2 if &lt;0.5×</td><td>Scale or kill</td></tr>
        <tr><td><strong>Thu May 28</strong></td><td>Aliyah</td><td>Activate any remaining drafted flows (Welcome SMS - Targeting &amp; Retention)</td><td>All flows live</td></tr>
        <tr><td><strong>Fri May 29</strong> 🔴🔴</td><td>All</td><td><strong>THE £100k ATTEMPT</strong> — TWO flagship cars (one £40k+ retail), £25k cash tonight, 3 instant-win formats finishing</td><td><strong>£100k target</strong></td></tr>
        <tr><td>Fri May 29</td><td>Aliyah</td><td>Pre-Friday VIP send Wed 18:00; Thu 19:00 SMS first wave; Fri 09:00 + 17:00 email + 18:00 + 19:30 SMS</td><td>Saturation</td></tr>
        <tr><td>Fri May 29</td><td>Karis/Conrad</td><td>Live broadcast 17:00–22:00 — extended edition w/ winner hand-over content</td><td>Live extended</td></tr>
        <tr><td><strong>Sat May 30</strong></td><td>Conrad/Alex</td><td>Recap content for Insta/TikTok — cement social proof</td><td>Content drop</td></tr>
        <tr><td><strong>Sun May 31</strong> 🔴🔴</td><td>All</td><td><strong>RECOVERY FLAGSHIP</strong> — second £100k attempt with different prize mix</td><td>£100k target #2</td></tr>
        <tr><td>Mon June 1</td><td>All</td><td>Review month: what worked, what didn't</td><td>Retro</td></tr>
        <tr><td>Tue June 2</td><td>Conrad/Aliyah</td><td>Lock June 4-week plan from learnings</td><td>Forward plan</td></tr>
      </tbody>
    </table>
  </div>
</section>
""")

# ============== COMPETITIONS ==============
html_parts.append("""
<section id="comps">
  <div class="container">
    <div class="breadcrumb">06 · Competitions</div>
    <h2><span class="num">06</span>Competitions — kill list, go-live list, ranked next-30-days</h2>
    <p class="lede">Built from your live product catalogue (587 SKUs) cross-referenced against 90-day historical category performance.</p>

    <h3>6.1 Currently upcoming — RANKED by predicted revenue</h3>
""")
html_parts.append("""
    <table>
      <thead><tr><th>Draw date</th><th>Day</th><th>Competition</th><th class="num">Predicted total</th><th>Action</th></tr></thead>
      <tbody>
""")
for p in preds_sorted:
    if p["expected_total_revenue"] >= 1000:
        if p["predicted_rev_per_day"] > 2000:
            badge = '<span class="pill red">🔴 FLAGSHIP — heavy promo</span>'
        else:
            badge = '<span class="pill green">🟢 PROMOTE</span>'
    else:
        badge = '<span class="pill gold">🟡 KILL or de-prioritise</span>'
    html_parts.append(f"<tr><td>{p['draw_date']}</td><td>{p['draw_dow'][:3]}</td><td>{p['name'][:65]}</td><td class='num'>£{p['expected_total_revenue']:,.0f}</td><td>{badge}</td></tr>")

html_parts.append("""
      </tbody>
    </table>

    <h3>6.2 The kill list (drop or de-prioritise these)</h3>
    <p>These have either no historical category match (predicting £0/day), or fall into the tech_appliance category which historically does £97/day — well below your draw-slot opportunity cost.</p>
    <ul>
      <li>MOTO NITROUS FLIP AND WIN [Draw May 9th] — no audience</li>
      <li>FOOTBALL FRENZY SCRATCH AND WIN [Draw May 14th] — no audience</li>
      <li>NINJA ARTISAN OUTDOOR PIZZA OVEN [Draw May 6th]</li>
      <li>PHILIPS LUMEA [Draw May 6th]</li>
      <li>NINJA CREAMI SCOOP &amp; SWIRL [Draw May 7th]</li>
      <li>APPLE MACBOOK NEO 13" (2026)</li>
      <li>LAY-Z-SPA ROME AIRJET [Draw May 8th]</li>
      <li>NINTENDO SWITCH 2 [Draw May 8th]</li>
      <li>TRAXXAS X-MAXX 8S RC CAR [Draw May 9th]</li>
      <li>PLAYSTATION 5 [Draw May 9th]</li>
      <li>SAMSUNG 85" TV [Draw May 10th]</li>
      <li>NINJA SLUSHI MAX MOCHA [Draw May 11th]</li>
      <li>SHARK TURBOBLADE TOWER FAN [Draw May 12th]</li>
      <li>SHARK EVERYMESS PORTABLE 3-IN-1 CARPET CLEANER [Draw May 13th]</li>
    </ul>

    <h3>6.3 The "must launch" formats — pull from your historical winners</h3>
    <table>
      <thead><tr><th>#</th><th>Format</th><th>Why</th><th class="num">Predicted £/day</th></tr></thead>
      <tbody>
        <tr><td>1</td><td><strong>GOLD &amp; WATCH INSTANT WINS [£5,000 END]</strong></td><td>Top historical performer (£6,283/day)</td><td class="num">£6,000</td></tr>
        <tr><td>2</td><td><strong>HIGH PERFORMANCE INSTANT WINS [£5,000 END]</strong></td><td>Workhorse — multiple sub-themes (Audi/BMW/AMG)</td><td class="num">£5,500</td></tr>
        <tr><td>3</td><td><strong>FAMILY CAR INSTANT WINS [£5,000 END]</strong></td><td>Different audience demographic = incremental</td><td class="num">£3,500</td></tr>
        <tr><td>4</td><td><strong>LUXURY SUV INSTANT WINS [£5,000 END]</strong></td><td>High-AOV buyers</td><td class="num">£4,500</td></tr>
        <tr><td>5</td><td><strong>FLAGSHIP DREAM CAR — Audi RSQ8 / BMW M4 / Range Rover SVR</strong></td><td>Anchors Friday peak</td><td class="num">£3,500</td></tr>
        <tr><td>6</td><td><strong>£50,000 TAX-FREE CASH (monthly anchor)</strong></td><td>Recurring big-prize hook</td><td class="num">£3,700</td></tr>
        <tr><td>7</td><td><strong>ROLEX WATCH INSTANT WINS [£5,000 END]</strong></td><td>Watch buyers = high-value segment</td><td class="num">£2,700</td></tr>
        <tr><td>8</td><td><strong>MX BIKE / SUR-RON INSTANT WINS [£5,000 END]</strong></td><td>Bike audience (1,464 TikTok orders shows demand)</td><td class="num">£2,600</td></tr>
        <tr><td>9</td><td><strong>£10,000 TAX-FREE CASH QUICK DRAW (weekly)</strong></td><td>Mid-week quick convert</td><td class="num">£900</td></tr>
        <tr><td>10</td><td><strong>FORD CONNECT / VAN INSTANT WINS</strong></td><td>Trade audience — different demo</td><td class="num">£2,700</td></tr>
      </tbody>
    </table>
  </div>
</section>
""")

# ============== EMAIL/SMS SCHEDULE ==============
html_parts.append("""
<section id="sends">
  <div class="container">
    <div class="breadcrumb">07 · Lifecycle</div>
    <h2><span class="num">07</span>Email + SMS — every send mapped</h2>
    <p class="lede">18 weekly sends (12 email + 6 SMS), every one anchored to 17:00–18:00 UTC peak conversion windows.</p>

    <h3>7.1 The standing weekly schedule</h3>
    <table>
      <thead><tr><th>Day</th><th>Time UTC</th><th>Channel</th><th>Audience</th><th>Purpose</th></tr></thead>
      <tbody>
        <tr><td>Mon</td><td>17:00</td><td>Email</td><td>Engaged 90d + Placed Order 90d</td><td>Mon kick-off / new draws</td></tr>
        <tr><td>Mon</td><td>18:00</td><td>SMS</td><td>High Intent Cash</td><td>Mon urgency</td></tr>
        <tr><td>Tue</td><td>17:00</td><td>Email</td><td>High Intent Car/Bike</td><td>Mid-week last chance</td></tr>
        <tr><td>Tue</td><td>18:00</td><td>SMS</td><td>Purchased 30d</td><td>Loyal-buyer push</td></tr>
        <tr><td>Wed</td><td>17:00</td><td>Email</td><td>Newsletter (broad)</td><td>Mid-week build-up</td></tr>
        <tr><td>Wed</td><td>18:00</td><td>SMS</td><td>High Intent Cash</td><td>Push</td></tr>
        <tr><td>Thu</td><td>17:00</td><td>Email</td><td>Engaged 60d - Cash Players</td><td>Last-chance Thu</td></tr>
        <tr><td>Thu</td><td>18:00</td><td>SMS</td><td>Purchased 30d</td><td>Loyalty</td></tr>
        <tr style="background:#fee2e2;"><td><strong>Fri</strong></td><td><strong>09:00</strong></td><td><strong>Email</strong></td><td>Engaged 60d</td><td>🔴 Ends Today flagship #1</td></tr>
        <tr style="background:#fee2e2;"><td><strong>Fri</strong></td><td><strong>17:00</strong></td><td><strong>Email</strong></td><td>High-Intent + Cash + Car/Bike + High-Spenders</td><td>🔴 Ends Tonight flagship #2</td></tr>
        <tr style="background:#fee2e2;"><td><strong>Fri</strong></td><td><strong>18:00</strong></td><td><strong>SMS</strong></td><td>High Intent Car/Bike</td><td>🔴 Tonight 20:00</td></tr>
        <tr style="background:#fee2e2;"><td><strong>Fri</strong></td><td><strong>19:30</strong></td><td><strong>SMS</strong></td><td>Purchased 90d (1 hr to draw)</td><td>🔴 Final hour</td></tr>
        <tr><td>Sat</td><td>11:00</td><td>Email</td><td>Dormant DB (reactivation week 1 only)</td><td>Reactivation</td></tr>
        <tr><td>Sat</td><td>17:00</td><td>Email</td><td>New Subscribers 30d</td><td>Welcome / re-engage</td></tr>
        <tr style="background:#fee2e2;"><td><strong>Sun</strong></td><td><strong>09:00</strong></td><td><strong>Email</strong></td><td>Engaged + Cash</td><td>🔴 Sunday Ends Today</td></tr>
        <tr style="background:#fee2e2;"><td><strong>Sun</strong></td><td><strong>17:00</strong></td><td><strong>Email</strong></td><td>High Spenders + Retargeting</td><td>🔴 Sunday Ends Tonight</td></tr>
        <tr style="background:#fee2e2;"><td><strong>Sun</strong></td><td><strong>18:00</strong></td><td><strong>SMS</strong></td><td>High Intent Cash</td><td>🔴 Tonight 20:00</td></tr>
      </tbody>
    </table>

    <h3>7.2 Subject-line cheatsheet (built from your top campaigns)</h3>
    <p><strong>WINNING formula:</strong> <code>[Day] - [Date] - Last Chance - [Theme] - [Prize Hook]</code></p>
    <p>Examples that won:</p>
    <ul>
      <li>"Tuesday - 31st March 2026 - Last Chance - Cash - Cash Beast Instants" (£12,976)</li>
      <li>"Monday - 9th February 2025 - Cars &amp; Bikes - High Performance" (£12,292)</li>
      <li>"Thursday - 26th February 2026 - Ends Tomorrow - Renault Race Truck" (£10,964)</li>
    </ul>
    <div class="grid-2">
      <div>
        <h4 style="color: var(--green);">✅ Use these words MORE</h4>
        <p>chance, last, cash, car, £5,000, wins, thursday, saturday, april, instant</p>
      </div>
      <div>
        <h4 style="color: var(--accent);">❌ Avoid these words</h4>
        <p>easter, cashback, promotion, retargeting, 5th, 2025 (always use current year), ends (counter-intuitively — only works in title context, not as a standalone)</p>
      </div>
    </div>
  </div>
</section>
""")

# ============== STAFF ROTA ==============
html_parts.append("""
<section id="rota">
  <div class="container">
    <div class="breadcrumb">08 · People</div>
    <h2><span class="num">08</span>Staff rota &amp; reporting</h2>
    <p class="lede">Built around the data: peak revenue 18:00–21:00, Friday + Sunday biggest, 17:00 send window, 20:00 live draw.</p>

    <h3>8.1 The team &amp; primary roles</h3>
    <table>
      <thead><tr><th>Name</th><th>Primary role</th><th>Core hours</th><th>Live-draw role</th></tr></thead>
      <tbody>
        <tr><td><strong>Conrad Smart</strong></td><td>Creative Director (Media)</td><td>08:00–17:00 (was 07:00–18:00)</td><td>Director on Fri/Sun only</td></tr>
        <tr><td><strong>Alexander Saunders</strong></td><td>Digital Content Creator</td><td>09:00–18:00 (split-shift Wed/Sat)</td><td>Setup + camera op</td></tr>
        <tr><td><strong>Joshua</strong></td><td>Web Ops &amp; All-Rounder</td><td>09:00–18:00</td><td>Co-presenter (alt with Kyrell) + setup</td></tr>
        <tr><td><strong>Kyrell Walters</strong></td><td>All-Rounder &amp; Live Promoter</td><td>08:00–16:00 (Tue/Thu/Sat) · 12:00–21:00 (Mon/Wed/Fri/Sun)</td><td>Co-presenter on M/W/F/Sun</td></tr>
        <tr><td><strong>Karis Deevey</strong></td><td>Lead Presenter / Dolly Girl Promoter</td><td>16:00–22:00 (Mon–Sun)</td><td><strong>Primary presenter</strong> every draw</td></tr>
        <tr><td><strong>Aliyah Dagia</strong></td><td>Admin + Social Promoter</td><td>09:00–17:00 (one late shift Wed 12:00–20:00, Sun 12:00–20:00)</td><td>Real-time social during draw</td></tr>
        <tr><td><strong>Matt Jr</strong></td><td>Site Maintenance &amp; General Labour</td><td>07:00–15:00 Mon–Fri</td><td>Setup support 18:00–21:00 (rotational)</td></tr>
        <tr><td><strong>Cory</strong></td><td>Transport — local runs</td><td>08:00–14:00 daily</td><td>—</td></tr>
        <tr><td><strong>Colin</strong></td><td>Transport — long-distance/prize delivery</td><td>M/W/F as routed</td><td>—</td></tr>
        <tr><td><strong>Devvy</strong></td><td>Transport + Prize-Reveal Promotion</td><td>10:00–18:00 (T/Th) · 14:00–22:00 (Fri/Sun)</td><td>On-camera prize reveal Fri/Sun</td></tr>
      </tbody>
    </table>

    <h3>8.2 The 5 changes the rota delivers</h3>
    <ol>
      <li><strong>Karis arrives 16:00 (was 18:00)</strong> — captures the 17:00 UTC build-up window where £0.25/recipient revenue lives.</li>
      <li><strong>Conrad hard-stops 17:00 Mon–Thu</strong> — recovers ~10 senior creative hours/week.</li>
      <li><strong>Matt Jr is the unblocker</strong> — owns floor, vehicle prep, stage cabling, prize photo backgrounds, unit setup. Frees ~6 hrs/day of senior creative time.</li>
      <li><strong>Aliyah owns 18 weekly scheduled sends</strong>. Schedule each Monday for the entire week.</li>
      <li><strong>Joshua = fixed co-presenter every draw</strong> + owns the master comps brief (single source of truth — fixes Conrad's flagged blocker).</li>
    </ol>

    <h3>8.3 Reporting structure</h3>
    <pre style="background:#fff; border:1px solid var(--line); color:#0f172a; padding:24px; border-radius:8px; font-size:13px;">
                          OWNER / CEO (Matty + Dave)
                                  │
       ┌──────────┬────────────┬──┴────────┬─────────────┐
       │          │            │           │             │
    Conrad      Aliyah      Joshua      Karis       Logistics
   (Creative)  (Admin/    (Web Ops/  (Presenter)   (Cory/Colin/
                Marketing)  Comp Setup)              Devvy/Matt Jr)
       │          │            │           │             │
    Alex S.    (no reports)  (no reports) (no reports) (Matt Jr ↔
    Devvy on                                            Conrad ↔
    shoot                                               Joshua)
    days
    Karis on
    pre-record</pre>

    <h3>8.4 Reporting cadence</h3>
    <table>
      <thead><tr><th>When</th><th>Meeting</th><th>Owner</th><th>Output</th></tr></thead>
      <tbody>
        <tr><td>Daily 09:00 (15 min)</td><td>Stand-up — today's draw + sends</td><td>Aliyah</td><td>Send list locked / draw checklist</td></tr>
        <tr><td>Daily 21:30 (10 min)</td><td>Live-draw debrief</td><td>Karis</td><td>Issues log</td></tr>
        <tr><td>Mon 10:00 (45 min)</td><td>Weekly KPI review</td><td>Conrad</td><td>KPI scorecard, week's send schedule</td></tr>
        <tr><td>Fri 14:00 (30 min)</td><td>Pre-flagship readiness</td><td>Joshua</td><td>Friday checklist signed off</td></tr>
        <tr><td>Last Tue of month (60 min)</td><td>Monthly retro</td><td>Conrad</td><td>Wins/misses, next month's flagship calendar</td></tr>
      </tbody>
    </table>
  </div>
</section>
""")

# ============== DAILY CADENCE ==============
html_parts.append("""
<section id="dailycadence">
  <div class="container">
    <div class="breadcrumb">09 · Daily Schedule</div>
    <h2><span class="num">09</span>Daily cadence — every minute mapped</h2>
    <p class="lede">Two flavours of day: standard (Mon/Tue/Wed/Thu/Sat) and flagship (Fri/Sun). Print this, pin it on the wall.</p>

    <div class="grid-2">
      <div class="day-schedule">
        <h4>STANDARD DAY (Mon–Thu, Sat)</h4>
        <div class="schedule-row"><div class="time">07:00</div><div>Matt Jr opens unit, cleaning + vehicle prep</div><div class="who">Matt Jr</div></div>
        <div class="schedule-row"><div class="time">08:00</div><div>Conrad finishes overnight edits / draw-day pics</div><div class="who">Conrad</div></div>
        <div class="schedule-row"><div class="time">08:00</div><div>Kyrell results + instant-win uploads</div><div class="who">Kyrell</div></div>
        <div class="schedule-row"><div class="time">09:00</div><div><strong>Daily stand-up</strong> — today's sends, draw, blockers</div><div class="who">Aliyah leads</div></div>
        <div class="schedule-row"><div class="time">09:00</div><div>Joshua web ops — comp prep, draft-to-live</div><div class="who">Joshua</div></div>
        <div class="schedule-row"><div class="time">09:00</div><div>Aliyah inbox + Trustpilot + winner posts</div><div class="who">Aliyah</div></div>
        <div class="schedule-row"><div class="time">10:00</div><div>Filming slot (Tue/Thu) or ideation/scripts (Mon/Wed)</div><div class="who">Conrad+Alex+Karis</div></div>
        <div class="schedule-row"><div class="time">13:00</div><div>Editing, site fixes, van runs, social pushes</div><div class="who">Various</div></div>
        <div class="schedule-row"><div class="time">16:30</div><div><strong>17:00 send scheduled in Klaviyo</strong></div><div class="who">Aliyah</div></div>
        <div class="schedule-row"><div class="time">17:00</div><div>Email + SMS land. Build-up Reels begin live.</div><div class="who">Aliyah / Karis</div></div>
        <div class="schedule-row"><div class="time">18:00</div><div>Karis goes live — pre-draw build-up</div><div class="who">Karis</div></div>
        <div class="schedule-row"><div class="time">19:30</div><div>Final-hour SMS (high-intent only)</div><div class="who">Aliyah</div></div>
        <div class="schedule-row"><div class="time">20:00</div><div><strong>LIVE DRAW</strong></div><div class="who">Live team</div></div>
        <div class="schedule-row"><div class="time">21:00</div><div>Pack down + post-draw social wrap</div><div class="who">All</div></div>
        <div class="schedule-row"><div class="time">21:30</div><div><strong>Live-draw debrief</strong></div><div class="who">Karis leads</div></div>
      </div>

      <div class="day-schedule" style="border: 2px solid var(--accent);">
        <h4 style="color: var(--accent);">FLAGSHIP DAY (Fri / Sun) 🔴</h4>
        <div class="schedule-row"><div class="time">07:00</div><div>Matt Jr deep-clean unit + stage cabling</div><div class="who">Matt Jr</div></div>
        <div class="schedule-row"><div class="time">08:00</div><div>Conrad creates draw-day pics, schedules to FB+YT</div><div class="who">Conrad</div></div>
        <div class="schedule-row"><div class="time">08:00</div><div>Colin starts long-haul prize delivery (Mon/Wed/Fri)</div><div class="who">Colin</div></div>
        <div class="schedule-row" style="background:#fee2e2;"><div class="time">09:00</div><div><strong>'Ends Today' email send</strong> to Engaged 60d</div><div class="who">Aliyah</div></div>
        <div class="schedule-row"><div class="time">09:00</div><div>Daily stand-up — flagship readiness</div><div class="who">Conrad leads</div></div>
        <div class="schedule-row"><div class="time">11:00</div><div>Reactivation send (Sat) or Friday teaser SMS</div><div class="who">Aliyah</div></div>
        <div class="schedule-row"><div class="time">13:00</div><div>Filming/edits + final stage check</div><div class="who">Conrad</div></div>
        <div class="schedule-row"><div class="time">14:00</div><div>Devvy arrives — prize-reveal shoot prep</div><div class="who">Devvy</div></div>
        <div class="schedule-row"><div class="time">16:00</div><div>Karis arrives, pre-record build-up Reels</div><div class="who">Karis</div></div>
        <div class="schedule-row"><div class="time">16:30</div><div><strong>Lock 17:00 sends in Klaviyo (Email + SMS)</strong></div><div class="who">Aliyah</div></div>
        <div class="schedule-row" style="background:#fee2e2;"><div class="time">17:00</div><div><strong>Email + SMS land</strong> — 'Ends Tonight'</div><div class="who">Aliyah</div></div>
        <div class="schedule-row"><div class="time">17:00</div><div>Karis live build-up Reels</div><div class="who">Karis</div></div>
        <div class="schedule-row" style="background:#fee2e2;"><div class="time">18:00</div><div><strong>SMS final wave 'Tonight 20:00'</strong></div><div class="who">Aliyah</div></div>
        <div class="schedule-row"><div class="time">18:00</div><div>Karis goes full live</div><div class="who">Karis</div></div>
        <div class="schedule-row" style="background:#fee2e2;"><div class="time">19:30</div><div><strong>Final-hour SMS</strong> (Engaged 30d + cart abandoners)</div><div class="who">Aliyah</div></div>
        <div class="schedule-row" style="background:#fef3c7;"><div class="time">20:00</div><div>🔴 <strong>LIVE DRAW</strong> — Conrad directing, Devvy on-camera reveal</div><div class="who">All</div></div>
        <div class="schedule-row"><div class="time">21:00</div><div>Pack down + winner content</div><div class="who">Karis + Devvy</div></div>
      </div>
    </div>
  </div>
</section>
""")

# ============== £100K PLAYBOOK ==============
html_parts.append("""
<section id="playbook">
  <div class="container">
    <div class="breadcrumb">10 · Playbook</div>
    <h2><span class="num">10</span>The £100k day playbook</h2>
    <p class="lede">Exact recipe for engineering a £100k Friday.</p>

    <h3>10.1 Prize stack (lined up 7 days in advance)</h3>
    <ul>
      <li>1× <strong>flagship car</strong> — £40k+ retail (Audi RSQ8 / BMW M4 / Range Rover SVR / Porsche tier)</li>
      <li>1× <strong>£25k tax-free cash quick-draw</strong></li>
      <li>3× <strong>£5,000-end-prize instant-win formats</strong> (gold/watch + cars + cash)</li>
      <li>1× <strong>£10k Friday-only flash entry</strong> at 19:00 (5,000 tickets, sub-£1 each — high velocity)</li>
      <li>1× <strong>bundle deal</strong> (£25 ticket = entries to all 5 = high AOV mechanic)</li>
    </ul>

    <h3>10.2 Send choreography (Thu → Fri)</h3>
    <table>
      <thead><tr><th>Day/Time</th><th>Channel</th><th>Audience</th><th>Message</th></tr></thead>
      <tbody>
        <tr><td>Thu 17:00</td><td>Email</td><td>Engaged 60d (~30k)</td><td>Build-up: "Friday's £40k car ends tomorrow"</td></tr>
        <tr><td>Thu 19:00</td><td>SMS</td><td>High Intent Car/Bike</td><td>"Friday's flagship"</td></tr>
        <tr><td>Fri 09:00</td><td>Email</td><td>Engaged 60d (~30k)</td><td>"Ends Today"</td></tr>
        <tr><td>Fri 11:00</td><td>Email</td><td>Dormant DB (~50k) (only if Sat slot used)</td><td>Reactivation</td></tr>
        <tr><td>Fri 17:00</td><td>Email × 2</td><td>High-Intent Cash + High-Spenders separately (~50k each)</td><td>Customised "Ends Tonight"</td></tr>
        <tr><td>Fri 18:00</td><td>SMS</td><td>High Intent Car/Bike (~25k)</td><td>"Tonight 20:00"</td></tr>
        <tr><td>Fri 19:00</td><td>SMS</td><td>Cart Abandoners last 24h (~5k)</td><td>Highest-intent push</td></tr>
        <tr><td>Fri 19:30</td><td>SMS</td><td>Purchased 30d (~15k)</td><td>Final hour push</td></tr>
      </tbody>
    </table>

    <h3>10.3 Paid-media support</h3>
    <ul>
      <li><strong>Mon–Wed:</strong> Awareness — flagship car teaser ads on Meta + TikTok</li>
      <li><strong>Thu–Fri:</strong> Conversion mode — "Ends tonight" ads to all warm audiences (cart abandoners, 30d engaged, 90d engaged)</li>
      <li><strong>Fri £-spend split:</strong> 60% Meta · 25% TikTok · 15% Google brand search</li>
    </ul>

    <h3>10.4 Live-draw conversion mechanics</h3>
    <ul>
      <li>Karis announces "final 1,000 tickets" urgency hook every 15 min from 19:00</li>
      <li>Joshua pinned-comment in chat: "Last chance to enter, draw begins 20:00 sharp"</li>
      <li>Aliyah real-time monitors sales — if a comp is undersold, Karis gives extra promo time</li>
      <li>Pre-recorded winner reveal Reel from previous Friday plays at 19:55 to anchor social proof</li>
      <li>Live continues 20:00–22:00 with prize hand-over content</li>
    </ul>

    <h3>10.5 The £100k revenue mix math</h3>
    <table>
      <thead><tr><th>Source</th><th class="num">Expected revenue</th></tr></thead>
      <tbody>
        <tr><td>Flagship car finale</td><td class="num">£25,000</td></tr>
        <tr><td>£25k cash quick-draw</td><td class="num">£18,000</td></tr>
        <tr><td>Instant-win format #1 (gold/watch)</td><td class="num">£15,000</td></tr>
        <tr><td>Instant-win format #2 (high-perf)</td><td class="num">£15,000</td></tr>
        <tr><td>Instant-win format #3 (family/SUV)</td><td class="num">£10,000</td></tr>
        <tr><td>£10k flash entry</td><td class="num">£8,000</td></tr>
        <tr><td>Bundle deal upsell</td><td class="num">£5,000</td></tr>
        <tr><td>Other live comps tail</td><td class="num">£4,000</td></tr>
        <tr style="background: #fef3c7; font-weight: 700;"><td>TOTAL</td><td class="num">£100,000</td></tr>
      </tbody>
    </table>
  </div>
</section>
""")

# ============== KPI ==============
html_parts.append("""
<section id="kpi">
  <div class="container">
    <div class="breadcrumb">11 · Measurement</div>
    <h2><span class="num">11</span>KPI dashboard — what to watch</h2>

    <h3>11.1 Daily KPIs (post in Slack 09:00)</h3>
    <table>
      <thead><tr><th>KPI</th><th>Source</th><th>Target by Wk4</th></tr></thead>
      <tbody>
        <tr><td>Daily revenue</td><td>WooCommerce</td><td class="num">£80k+</td></tr>
        <tr><td>Orders</td><td>WooCommerce</td><td class="num">8,000+</td></tr>
        <tr><td>New customers</td><td>WooCommerce</td><td class="num">1,800+</td></tr>
        <tr><td>AOV</td><td>WooCommerce</td><td class="num">£12+</td></tr>
        <tr><td>Email open rate</td><td>Klaviyo</td><td class="num">45%+</td></tr>
        <tr><td>Email rev/recipient</td><td>Klaviyo</td><td class="num">£0.25+</td></tr>
        <tr><td>SMS click rate</td><td>Klaviyo</td><td class="num">25%+</td></tr>
        <tr><td>SMS rev/send</td><td>Klaviyo</td><td class="num">£0.20+</td></tr>
        <tr><td>SMS estimated cost</td><td>Klaviyo × £0.04</td><td class="num">&lt;£1,500/day</td></tr>
        <tr><td>Live concurrent peak (Fri/Sun)</td><td>YouTube Studio</td><td class="num">1,000+</td></tr>
        <tr><td>Trustpilot reviews this week</td><td>Trustpilot</td><td class="num">50+</td></tr>
        <tr><td>Meta CAPI ROAS (7d)</td><td>Meta Events Mgr</td><td class="num">2.5×+</td></tr>
        <tr><td>Meta spend</td><td>Meta Ads Mgr</td><td class="num">£400–1,500/day</td></tr>
        <tr><td>TikTok ad ROAS</td><td>TikTok Ads Mgr</td><td class="num">1.5×+</td></tr>
      </tbody>
    </table>

    <h3>11.2 Weekly KPIs (Monday 09:00 review)</h3>
    <table>
      <thead><tr><th>KPI</th><th class="num">W4 Target</th></tr></thead>
      <tbody>
        <tr><td>Total revenue</td><td class="num">£700k</td></tr>
        <tr><td>Flagship Friday revenue</td><td class="num">£100k</td></tr>
        <tr><td>Flagship Sunday revenue</td><td class="num">£80k</td></tr>
        <tr><td>Reactivation campaign revenue</td><td class="num">£15k+ each</td></tr>
        <tr><td>New flows triggered</td><td class="num">8+ live by W2, 10+ by W3</td></tr>
        <tr><td>Comps killed</td><td class="num">~88 by end of W2</td></tr>
        <tr><td>New flagship comps launched</td><td class="num">3 cars / week</td></tr>
        <tr><td>TikTok creative tests</td><td class="num">5 weekly</td></tr>
        <tr><td>Meta creative refresh</td><td class="num">3 weekly</td></tr>
      </tbody>
    </table>
  </div>
</section>
""")

# ============== HOW-TO ==============
html_parts.append("""
<section id="howto">
  <div class="container">
    <div class="breadcrumb">12 · How-To</div>
    <h2><span class="num">12</span>Step-by-step instructions — child-clear</h2>
    <p class="lede">For each major task, exactly what to do, where to do it, and what 'done' looks like.</p>

    <h3>12.1 How to install Meta CAPI (the biggest win)</h3>
    <div class="step">
      <div class="n">1</div>
      <div>
        <div class="what">Buy a CAPI plugin for WordPress</div>
        <div class="how">Go to <strong>https://www.pixelyoursite.com/</strong>. Buy <strong>PixelYourSite Pro</strong> (£100/year). Or alternatively buy <strong>WP Pixel Cat Pro</strong> from <strong>https://wppixelcat.com/</strong>. Both are equally good for WooCommerce CAPI. Download the .zip file.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">2</div>
      <div>
        <div class="what">Install plugin in WordPress</div>
        <div class="how">Log into <strong>https://www.nitrouscompetitions.com/wp-admin</strong>. Sidebar → <strong>Plugins → Add New → Upload Plugin</strong>. Choose the .zip you downloaded. Click <strong>Install</strong>. Click <strong>Activate</strong>.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">3</div>
      <div>
        <div class="what">Get your Meta Pixel ID + CAPI token</div>
        <div class="how">Go to <strong>https://business.facebook.com</strong>. Click <strong>Events Manager</strong> in the left sidebar. Pick your existing Nitrous Pixel. Top-right → <strong>Settings</strong>. Scroll to <strong>Conversions API</strong>. Click <strong>Generate Access Token</strong>. Copy the token (long string starting with "EAA…"). Keep this tab open.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">4</div>
      <div>
        <div class="what">Paste into the plugin</div>
        <div class="how">In WordPress sidebar → <strong>PixelYourSite</strong> (or WP Pixel Cat). Find the Meta Pixel section. Paste the <strong>Pixel ID</strong> and the <strong>CAPI Access Token</strong>. Save.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">5</div>
      <div>
        <div class="what">Test it</div>
        <div class="how">Back in Meta Events Manager → click your Pixel → top tab <strong>Test Events</strong>. Open Nitrous Competitions in another tab, do a tiny test purchase (use a £0.07 entry, your own email). Within 30 seconds you should see "Purchase" event appear in the Test Events screen with your <strong>email</strong>, <strong>phone</strong>, <strong>IP</strong> matched. If Event Match Quality shows 9.0+/10, you're done.</div>
      </div>
    </div>

    <h3>12.2 How to add UTMs to every Meta ad</h3>
    <div class="step">
      <div class="n">1</div>
      <div>
        <div class="what">Open Meta Ads Manager</div>
        <div class="how">Go to <strong>https://www.facebook.com/adsmanager/</strong>. Pick the Nitrous ad account.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">2</div>
      <div>
        <div class="what">Filter active campaigns</div>
        <div class="how">Top filter → Status: <strong>Active</strong>. Click each campaign in turn.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">3</div>
      <div>
        <div class="what">Edit each ad</div>
        <div class="how">Within campaign → click an Ad Set → click an Ad → <strong>Edit</strong>. Scroll down to <strong>Tracking → URL Parameters</strong>. Paste this exactly:<br>
<code style="display: block; padding: 10px; background: #1e293b; color: #fef3c7; border-radius: 6px; margin: 8px 0; font-size: 12px;">utm_source=facebook&amp;utm_medium=paid&amp;utm_campaign={{campaign.name}}&amp;utm_content={{ad.name}}&amp;utm_term={{adset.name}}&amp;utm_id={{campaign.id}}</code>
Click <strong>Publish</strong>. Repeat for every active ad.</div>
      </div>
    </div>

    <h3>12.3 How to activate a Klaviyo flow from draft</h3>
    <div class="step">
      <div class="n">1</div>
      <div>
        <div class="what">Open Klaviyo Flows</div>
        <div class="how">Log into <strong>https://www.klaviyo.com</strong>. Sidebar → <strong>Flows</strong>.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">2</div>
      <div>
        <div class="what">Click the flow name</div>
        <div class="how">Find e.g. "Welcome Series - Email" in DRAFT status. Click it.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">3</div>
      <div>
        <div class="what">Review every email</div>
        <div class="how">For each email card in the flow: click it. Check the subject line, preview text, body. If anything looks like placeholder text or empty, fix it. Click <strong>Save Content</strong>.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">4</div>
      <div>
        <div class="what">Toggle each message LIVE</div>
        <div class="how">For each message card → top-right toggle: change from <strong>Manual</strong> to <strong>Live</strong>.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">5</div>
      <div>
        <div class="what">Toggle the entire flow LIVE</div>
        <div class="how">Top-right of the flow page → toggle from <strong>Draft</strong> to <strong>Live</strong>. Klaviyo will show a confirmation. Click yes.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">6</div>
      <div>
        <div class="what">Check 24h later</div>
        <div class="how">Open the flow → Performance tab. After 24 hours at least 1 person should have entered. If 0, the trigger isn't firing — check the trigger logic.</div>
      </div>
    </div>

    <h3>12.4 How to build the dormant-customer reactivation segment</h3>
    <div class="step">
      <div class="n">1</div>
      <div>
        <div class="what">Open Klaviyo Audiences → Segments</div>
        <div class="how">Klaviyo sidebar → <strong>Audiences → Segments</strong> → top-right <strong>Create Segment</strong>.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">2</div>
      <div>
        <div class="what">Name it</div>
        <div class="how">Name: <code>Reactivation Target — Dormant Paying</code>.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">3</div>
      <div>
        <div class="what">Add filters</div>
        <div class="how">Conditions:<br>
        ✓ Member of List: <strong>Customer Database</strong><br>
        AND ✗ NOT Member of Segment: <strong>Email - Engaged 90 Days - Placed Order 90 days</strong><br>
        AND ✗ NOT Member of Segment: <strong>Marked As Spam / Bounced</strong></div>
      </div>
    </div>
    <div class="step">
      <div class="n">4</div>
      <div>
        <div class="what">Save</div>
        <div class="how">Click <strong>Save Segment</strong>. Klaviyo calculates the size — should land around 95–110k.</div>
      </div>
    </div>

    <h3>12.5 How to send the reactivation campaign</h3>
    <div class="step">
      <div class="n">1</div>
      <div>
        <div class="what">Klaviyo → Campaigns → Create</div>
        <div class="how">Sidebar → <strong>Campaigns</strong> → top-right <strong>Create Campaign</strong> → choose <strong>Email</strong>.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">2</div>
      <div>
        <div class="what">Set audience</div>
        <div class="how">Recipients: <strong>Reactivation Target — Dormant Paying</strong> (the segment just built). Smart Sending: ON.</div>
      </div>
    </div>
    <div class="step">
      <div class="n">3</div>
      <div>
        <div class="what">Subject line</div>
        <div class="how">Subject: <strong>"We saved your spot — last 5,000 tickets to win a 2025 BMW M4"</strong>. Preview text: <strong>"£5 credit if you enter by Sunday".</strong></div>
      </div>
    </div>
    <div class="step">
      <div class="n">4</div>
      <div>
        <div class="what">Pick a clean template</div>
        <div class="how">Use a Klaviyo "minimal" template. Hero image: the M4 prize. Big button: "Enter Now — Use £5 Credit". Body: "It's been a while. Your £5 credit expires Sunday. The M4 winner is announced Friday at 20:00 — don't miss it."</div>
      </div>
    </div>
    <div class="step">
      <div class="n">5</div>
      <div>
        <div class="what">Schedule for Saturday 11:00 UTC</div>
        <div class="how">Top-right → <strong>Review &amp; Send</strong> → <strong>Schedule</strong>. Date: this Saturday. Time: 11:00 UK time. Send.</div>
      </div>
    </div>
  </div>
</section>
""")

# ============== RISKS ==============
html_parts.append("""
<section id="risks">
  <div class="container">
    <div class="breadcrumb">13 · Risk</div>
    <h2><span class="num">13</span>Risk register</h2>
    <table>
      <thead><tr><th>Risk</th><th>Probability</th><th>Impact</th><th>Mitigation</th></tr></thead>
      <tbody>
        <tr><td>Meta CAPI install delays</td><td><span class="pill gold">Medium</span></td><td><span class="pill red">High</span></td><td>Use PixelYourSite Pro (1-day install) — fallback to manual server-side via PHP</td></tr>
        <tr><td>Tech-appliance kills cause refunds</td><td><span class="pill green">Low</span></td><td><span class="pill gold">Medium</span></td><td>Run them out (let existing draws complete) — don't pull live mid-comp</td></tr>
        <tr><td>Reactivation send hits spam folder</td><td><span class="pill gold">Medium</span></td><td><span class="pill red">High</span></td><td>Aliyah warms IP first with smaller sends (5k/day for 3 days)</td></tr>
        <tr><td>Friday flagship car doesn't sell out</td><td><span class="pill gold">Medium</span></td><td><span class="pill red">High</span></td><td>Pre-commit: any car ≥£40k retail must have 30+ days of pre-promotion. Track ticket-velocity vs target curve daily — kill or convert to instant-win if behind by 20% at day 7</td></tr>
        <tr><td>Karis or Kyrell unavailable for live</td><td><span class="pill gold">Medium</span></td><td><span class="pill red">Critical</span></td><td>Cross-train Joshua + Aliyah as backup presenters</td></tr>
        <tr><td>TikTok ads compliance rejection</td><td><span class="pill red">High</span> (lottery/comp space)</td><td><span class="pill gold">Medium</span></td><td>Test with promotional creative first (no 'win' language); use Spark Ads off organic posts where possible</td></tr>
        <tr><td>Meta account flagged for raffle/competition policy</td><td><span class="pill gold">Medium</span></td><td><span class="pill red">Critical</span></td><td>Use 'prize draw' / 'instant win' language not 'lottery'; ensure terms are clearly displayed; have backup ad account warmed up</td></tr>
        <tr><td>Klaviyo deliverability drops</td><td><span class="pill green">Low</span></td><td><span class="pill red">High</span></td><td>Keep unsub &lt;0.2%, run sunset flow, never send full-DB blast more than monthly</td></tr>
        <tr><td>Live unit power/internet failure</td><td><span class="pill gold">Medium</span></td><td><span class="pill red">Critical</span></td><td>Backup 4G hotspot; backup laptop pre-loaded; mobile-phone livestream fallback</td></tr>
        <tr><td>Refund / cancellation rate creeps up</td><td><span class="pill gold">Medium</span></td><td><span class="pill red">High</span></td><td>Currently 6.3% all-time. Watch 7-day rolling — alert at 8%. Driver: clearer T&amp;Cs, better answer-question UX</td></tr>
      </tbody>
    </table>
  </div>
</section>
""")

# ============== ACTION CHECKLIST ==============
html_parts.append("""
<section id="actions">
  <div class="container">
    <div class="breadcrumb">14 · Checklist</div>
    <h2><span class="num">14</span>The full action checklist</h2>
    <p class="lede">Print this. Tape it to the office wall. Tick each item as it's done.</p>

    <h3>🔴 CRITICAL — this week (Week 1)</h3>
    <ul class="checklist">
      <li class="critical"><span class="priority-badge crit">CRIT</span><div><strong>Install Meta CAPI</strong> via PixelYourSite Pro / WP Pixel Cat — Conrad + WP dev</div></li>
      <li class="critical"><span class="priority-badge crit">CRIT</span><div><strong>Add UTMs</strong> to every Meta + TikTok + Google ad URL — Joshua audit, Conrad apply</div></li>
      <li class="critical"><span class="priority-badge crit">CRIT</span><div><strong>Activate Welcome Series Email flow</strong> from draft — Aliyah</div></li>
      <li class="critical"><span class="priority-badge crit">CRIT</span><div><strong>Activate First Purchase Incentive flow</strong> — Aliyah</div></li>
      <li class="critical"><span class="priority-badge crit">CRIT</span><div><strong>Activate Winback Flow</strong> — Aliyah</div></li>
      <li class="critical"><span class="priority-badge crit">CRIT</span><div><strong>Drop the 13 currently-live tech-appliance comps</strong> from promotion (let existing draws run, no new ones) — Joshua</div></li>
      <li class="critical"><span class="priority-badge crit">CRIT</span><div><strong>Build NC_VIP_D1 Custom Audience</strong> from D1 customer emails — Conrad → Meta</div></li>
      <li class="critical"><span class="priority-badge crit">CRIT</span><div><strong>Build NC_BUYERS_90D exclusion audience</strong> — Conrad → Meta</div></li>
      <li class="critical"><span class="priority-badge crit">CRIT</span><div><strong>Schedule Saturday reactivation campaign</strong> to dormant DB — Aliyah</div></li>
    </ul>

    <h3>🟠 IMPORTANT — next week (Week 2)</h3>
    <ul class="checklist">
      <li class="important"><span class="priority-badge imp">IMP</span><div>Activate VIP Tag flow + VIP Tier flow — Aliyah</div></li>
      <li class="important"><span class="priority-badge imp">IMP</span><div>Activate Sunset Flow Email + SMS — Aliyah</div></li>
      <li class="important"><span class="priority-badge imp">IMP</span><div>Launch Meta ASC #1 — Lookalike-1% top-LTV — Conrad</div></li>
      <li class="important"><span class="priority-badge imp">IMP</span><div>Launch Meta ASC #2 — Engagement re-engagement — Conrad</div></li>
      <li class="important"><span class="priority-badge imp">IMP</span><div>First TikTok Spark Ad live — £100/day test, 5 creatives — Conrad/Alex</div></li>
      <li class="important"><span class="priority-badge imp">IMP</span><div>Implement weekly Friday creative refresh on Meta — Conrad</div></li>
      <li class="important"><span class="priority-badge imp">IMP</span><div>Klaviyo deliverability check (open &gt;40%, unsub &lt;0.2%, spam &lt;0.05%) — Aliyah</div></li>
    </ul>

    <h3>🔵 Process / structural</h3>
    <ul class="checklist">
      <li class="process"><span class="priority-badge proc">PROC</span><div>Single source of truth for comps — Joshua owns master CMS doc</div></li>
      <li class="process"><span class="priority-badge proc">PROC</span><div>Move Conrad to hard 17:00 stop Mon–Thu (frees senior creative time)</div></li>
      <li class="process"><span class="priority-badge proc">PROC</span><div>Move Karis to 16:00 start (build-up Reels capture)</div></li>
      <li class="process"><span class="priority-badge proc">PROC</span><div>Onboard Matt Jr as floor/cabling/setup owner</div></li>
      <li class="process"><span class="priority-badge proc">PROC</span><div>Cross-train Joshua + Aliyah as backup presenters</div></li>
      <li class="process"><span class="priority-badge proc">PROC</span><div>Stand up Slack/Teams channel <code>#daily-stats</code> for the 09:00 KPI post</div></li>
      <li class="process"><span class="priority-badge proc">PROC</span><div>Build live shared dashboard (Looker Studio / Klaviyo + WC + Meta) for daily KPIs</div></li>
      <li class="process"><span class="priority-badge proc">PROC</span><div>Document refund/cancellation flow — current 6.3% lifetime cancel rate needs tightening</div></li>
      <li class="process"><span class="priority-badge proc">PROC</span><div>Trustpilot push — Aliyah's mornings drive review velocity (target 50+/week)</div></li>
    </ul>

    <h3>🟢 Growth — month 2 onwards</h3>
    <ul class="checklist">
      <li class="growth"><span class="priority-badge grow">GROW</span><div>TikTok Shop integration (your 1,464 TikTok orders show demand; Shop converts at 2–3× normal social)</div></li>
      <li class="growth"><span class="priority-badge grow">GROW</span><div>Loyalty / tier programme (Bronze/Silver/Gold based on 90-day spend)</div></li>
      <li class="growth"><span class="priority-badge grow">GROW</span><div>Refer-a-friend mechanic (1 free entry per referred buyer)</div></li>
      <li class="growth"><span class="priority-badge grow">GROW</span><div>Postcard mailer to top D1 monthly (5,898 VIPs deserve physical touch)</div></li>
      <li class="growth"><span class="priority-badge grow">GROW</span><div>Win-rate transparency dashboard for users (builds trust, increases retention)</div></li>
      <li class="growth"><span class="priority-badge grow">GROW</span><div>Google Performance Max test £100/day for 2 weeks once Meta is fixed</div></li>
    </ul>
  </div>
</section>
""")

# ============== FOOTER ==============
html_parts.append(f"""
<section style="background: var(--primary); color: #fff; padding: 60px 0;">
  <div class="container">
    <h2 style="color: #fff;">Closing note</h2>
    <p style="font-size: 17px; opacity: 0.85; max-width: 800px; line-height: 1.7;">This audit is built on real data, not guesses. Every number was pulled live via WooCommerce REST API and Klaviyo API. The plan is sequenced so each week's wins compound into the next. Execute in order. Measure weekly. The £100k day is engineering, not luck.</p>

    <h3 style="color: #fff; margin-top: 40px;">Files in this audit pack</h3>
    <table style="background: rgba(255,255,255,0.05); color: #fff;">
      <thead><tr style="background: rgba(255,255,255,0.1);"><th style="color:#fff;">File</th><th style="color:#fff;">Purpose</th></tr></thead>
      <tbody style="background: transparent;">
        <tr><td style="color:#fff;"><strong>NITROUS_AUDIT_FINAL.html</strong></td><td style="color:#fff;">This document — the master plan</td></tr>
        <tr><td style="color:#fff;">100K_BLUEPRINT.md / .html</td><td style="color:#fff;">Standalone blueprint</td></tr>
        <tr><td style="color:#fff;">MASTER_AUDIT.md / .html</td><td style="color:#fff;">Combined sales + email/SMS + competitions + rota + blueprint</td></tr>
        <tr><td style="color:#fff;">STAFF_ROTA.md / .html</td><td style="color:#fff;">Standalone staff schedule</td></tr>
        <tr><td style="color:#fff;">orders_3mo.csv (138 MB)</td><td style="color:#fff;">Every order with full attribution metadata</td></tr>
        <tr><td style="color:#fff;">competitions.csv</td><td style="color:#fff;">522 unique competitions ranked by revenue/orders/buyers</td></tr>
        <tr><td style="color:#fff;">new_customers.csv</td><td style="color:#fff;">Daily new-customer signups (deduped)</td></tr>
        <tr><td style="color:#fff;">deep_intel.json</td><td style="color:#fff;">Combined intel pack</td></tr>
        <tr><td style="color:#fff;">klaviyo/*.json</td><td style="color:#fff;">Raw Klaviyo data — campaigns, metrics, flows, lists, segments</td></tr>
        <tr><td style="color:#fff;">raw/*.json (90 files)</td><td style="color:#fff;">Raw WooCommerce orders, day-by-day</td></tr>
      </tbody>
    </table>

    <p style="margin-top: 40px; opacity: 0.7; font-size: 13px;">Generated {GENERATED} · Window analysed: 2026-02-06 → 2026-05-06</p>
    <p style="margin-top: 8px; opacity: 0.7; font-size: 13px;">Prepared for: Matty &amp; Dave · Nitrous Competitions</p>
  </div>
</section>

</body>
</html>
""")

with open(OUT, "w") as f:
    f.write("".join(html_parts))

import os
print(f"Wrote {OUT}: {os.path.getsize(OUT):,} bytes")
