#!/usr/bin/env python3
"""Morning Joe's Rundown — April 7, 2026"""

from docx import Document
from docx.shared import Pt, RGBColor, Inches, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_ALIGN_VERTICAL
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import datetime

# Color palette
NAVY = RGBColor(0x1F, 0x35, 0x64)       # Navy blue
GOLD = RGBColor(0xBF, 0x9B, 0x30)       # Gold accent
WHITE = RGBColor(0xFF, 0xFF, 0xFF)
LIGHT_GRAY = RGBColor(0xF2, 0xF2, 0xF2)
DARK_GRAY = RGBColor(0x40, 0x40, 0x40)
RED = RGBColor(0xC0, 0x00, 0x00)
GREEN = RGBColor(0x37, 0x86, 0x30)

doc = Document()

# ── Page setup ──────────────────────────────────────────────────────────
section = doc.sections[0]
section.page_width  = Inches(8.5)
section.page_height = Inches(11)
section.left_margin = section.right_margin = Inches(0.75)
section.top_margin  = section.bottom_margin = Inches(0.6)

# Footer with page numbers
footer = section.footer
fp = footer.paragraphs[0]
fp.alignment = WD_ALIGN_PARAGRAPH.CENTER
fp.clear()
run = fp.add_run("Morning Joe's Rundown  ·  April 7, 2026  ·  Page ")
run.font.size = Pt(8)
run.font.color.rgb = DARK_GRAY

fldChar1 = OxmlElement('w:fldChar'); fldChar1.set(qn('w:fldCharType'), 'begin')
instrText = OxmlElement('w:instrText'); instrText.text = 'PAGE'
fldChar2 = OxmlElement('w:fldChar'); fldChar2.set(qn('w:fldCharType'), 'end')
r_elem = OxmlElement('w:r')
r_elem.append(fldChar1); r_elem.append(instrText); r_elem.append(fldChar2)
fp._p.append(r_elem)

# ── Default paragraph spacing ────────────────────────────────────────────
style = doc.styles['Normal']
style.font.name = 'Calibri'
style.font.size = Pt(9.5)
style.paragraph_format.space_before = Pt(2)
style.paragraph_format.space_after  = Pt(2)

def set_heading(para, text, level=1):
    """Section heading with navy background and gold/white text."""
    para.clear()
    para.paragraph_format.space_before = Pt(8)
    para.paragraph_format.space_after  = Pt(4)
    run = para.add_run(text)
    run.font.name = 'Calibri'
    run.font.bold = True
    run.font.color.rgb = WHITE if level == 1 else NAVY
    run.font.size = Pt(11.5) if level == 1 else Pt(10)

    if level == 1:
        # Navy shading
        pPr = para._p.get_or_add_pPr()
        shd = OxmlElement('w:shd')
        shd.set(qn('w:val'), 'clear')
        shd.set(qn('w:color'), 'auto')
        shd.set(qn('w:fill'), '1F3564')
        pPr.append(shd)
        pInd = OxmlElement('w:ind')
        pInd.set(qn('w:left'), '100')
        pInd.set(qn('w:right'), '100')
        pPr.append(pInd)
    else:
        # Gold underline subhead
        run.font.color.rgb = GOLD
        run.font.size = Pt(9.5)

def add_body(text, bold=False, italic=False, color=None, indent=False):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after  = Pt(1)
    if indent:
        p.paragraph_format.left_indent = Inches(0.25)
    run = p.add_run(text)
    run.font.name = 'Calibri'
    run.font.size = Pt(9.5)
    run.font.bold  = bold
    run.font.italic = italic
    if color:
        run.font.color.rgb = color
    return p

def add_checkbox(text, bold_prefix=None):
    p = doc.add_paragraph(style='List Bullet')
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after  = Pt(1)
    p.paragraph_format.left_indent  = Inches(0.25)
    p.clear()
    # Checkbox + text
    run = p.add_run('☐  ')
    run.font.name = 'Calibri'
    run.font.size = Pt(9.5)
    if bold_prefix:
        r2 = p.add_run(bold_prefix + ' ')
        r2.font.bold = True; r2.font.name = 'Calibri'; r2.font.size = Pt(9.5)
    r3 = p.add_run(text)
    r3.font.name = 'Calibri'; r3.font.size = Pt(9.5)
    return p

def add_subhead(text):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(5)
    p.paragraph_format.space_after  = Pt(2)
    run = p.add_run(text.upper())
    run.font.name = 'Calibri'
    run.font.size = Pt(8.5)
    run.font.bold  = True
    run.font.color.rgb = GOLD
    return p

def add_divider():
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after  = Pt(1)
    pPr = p._p.get_or_add_pPr()
    pBdr = OxmlElement('w:pBdr')
    bottom = OxmlElement('w:bottom')
    bottom.set(qn('w:val'), 'single')
    bottom.set(qn('w:sz'), '4')
    bottom.set(qn('w:space'), '1')
    bottom.set(qn('w:color'), 'BF9B30')
    pBdr.append(bottom)
    pPr.append(pBdr)

# ══════════════════════════════════════════════════════════════════════
#  HEADER / TITLE BLOCK
# ══════════════════════════════════════════════════════════════════════
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
p.paragraph_format.space_before = Pt(0)
p.paragraph_format.space_after  = Pt(2)
r = p.add_run('☀  MORNING JOE\'S RUNDOWN')
r.font.name = 'Calibri'; r.font.bold = True; r.font.size = Pt(18)
r.font.color.rgb = NAVY

p2 = doc.add_paragraph()
p2.alignment = WD_ALIGN_PARAGRAPH.CENTER
p2.paragraph_format.space_before = Pt(0)
p2.paragraph_format.space_after  = Pt(6)
r2 = p2.add_run('Tuesday, April 7, 2026  ·  Prepared by Rob Lobster 🦞  ·  6:00 AM ET')
r2.font.name = 'Calibri'; r2.font.size = Pt(9); r2.font.italic = True
r2.font.color.rgb = DARK_GRAY

add_divider()

# ══════════════════════════════════════════════════════════════════════
#  SECTION 1 — WEATHER
# ══════════════════════════════════════════════════════════════════════
p = doc.add_paragraph()
set_heading(p, '  §1  WEATHER  ·  April 7, 2026')

add_subhead('New Jersey')

wx_data = [
    ('SHIP BOTTOM, NJ', '44°F / feels 38°F', 'Overcast early → Sunny afternoon', '53°F High / 40°F Low', '☔ 81% chance rain at 6 AM — clears by 9 AM. Beautiful afternoon. Sunrise 6:31 AM.'),
    ('TUCKERTON, NJ',   '46°F / feels 41°F', 'Overcast early → Sunny afternoon', '56°F High / 39°F Low', '☔ 84% rain chance at 6 AM — burns off fast. Great afternoon at the yard.'),
    ('CHESTERFIELD, NJ','48°F',              'Partly cloudy',                    '~55°F High',           'Mild and dry. Good day for the firehouse site.'),
]
for loc, current, cond, hi_lo, notes in wx_data:
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(2)
    p.paragraph_format.space_after  = Pt(0)
    p.paragraph_format.left_indent  = Inches(0.2)
    r = p.add_run(f'  {loc}  ')
    r.font.bold = True; r.font.size = Pt(9.5); r.font.name = 'Calibri'; r.font.color.rgb = NAVY
    r2 = p.add_run(f'  {current}  |  {cond}  |  {hi_lo}')
    r2.font.size = Pt(9.5); r2.font.name = 'Calibri'
    p2 = doc.add_paragraph(f'       {notes}')
    p2.paragraph_format.left_indent = Inches(0.2)
    p2.paragraph_format.space_before = Pt(0)
    p2.paragraph_format.space_after  = Pt(3)
    p2.runs[0].font.size = Pt(8.5)
    p2.runs[0].font.italic = True
    p2.runs[0].font.color.rgb = DARK_GRAY

add_subhead("Girls' Locations")

kids_wx = [
    ('COLUMBIA, SC  (Bella)', '☀️ Sunny, 47°F → 65°F High', 'Beautiful spring day. Great for classes.'),
    ('TUSCALOOSA, AL  (Jules)', '☀️ Sunny, 44°F → 66°F High', 'Clear and warm. Roll Tide weather.'),
    ('AUSTIN, TX  (Danielle)', '☀️ Sunny, 51°F → 78°F High', 'Gorgeous day in ATX. 🧡'),
]
for loc, wx, note in kids_wx:
    p = doc.add_paragraph()
    p.paragraph_format.left_indent  = Inches(0.2)
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after  = Pt(1)
    r = p.add_run(f'  {loc}  ')
    r.font.bold = True; r.font.size = Pt(9.5); r.font.name = 'Calibri'; r.font.color.rgb = NAVY
    r2 = p.add_run(f'  {wx}  —  {note}')
    r2.font.size = Pt(9.5); r2.font.name = 'Calibri'

# ══════════════════════════════════════════════════════════════════════
#  SECTION 2 — MARKETS & INVESTMENTS
# ══════════════════════════════════════════════════════════════════════
p = doc.add_paragraph()
set_heading(p, '  §2  MARKETS & INVESTMENTS')

add_subhead('Indices vs. Your Exit Baseline (Mar 25, 2026)')

# Table
tbl = doc.add_table(rows=4, cols=5)
tbl.style = 'Table Grid'
tbl.autofit = True

hdrs = ['Index', 'Your Exit (Mar 25)', 'Last Close (Apr 5)', 'Premarket (Apr 7)', 'Δ vs Exit']
for i, hdr in enumerate(hdrs):
    cell = tbl.rows[0].cells[i]
    cell.text = hdr
    cell.paragraphs[0].runs[0].font.bold = True
    cell.paragraphs[0].runs[0].font.size = Pt(8.5)
    cell.paragraphs[0].runs[0].font.name = 'Calibri'
    cell.paragraphs[0].runs[0].font.color.rgb = WHITE
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), '1F3564')
    tcPr.append(shd)

rows_data = [
    ('S&P 500',  '6,591.90', '6,611.83', '6,660.00 ↑', '+1.0% ✅'),
    ('Dow Jones','46,429.49','46,669.88','46,990.00 ↑', '+1.2% ✅'),
    ('Nasdaq',   '—',        '21,996.34','24,382.75 ↑', 'N/A'),
]
for ri, row_data in enumerate(rows_data, 1):
    for ci, val in enumerate(row_data):
        cell = tbl.rows[ri].cells[ci]
        cell.text = val
        cell.paragraphs[0].runs[0].font.size = Pt(8.5)
        cell.paragraphs[0].runs[0].font.name = 'Calibri'
        if ci == 4 and '✅' in val:
            cell.paragraphs[0].runs[0].font.color.rgb = GREEN
        if ri % 2 == 0:
            tc = cell._tc; tcPr = tc.get_or_add_tcPr()
            shd = OxmlElement('w:shd')
            shd.set(qn('w:val'), 'clear')
            shd.set(qn('w:color'), 'auto')
            shd.set(qn('w:fill'), 'F2F2F2')
            tcPr.append(shd)

doc.add_paragraph()

add_body('📊 KEY CONTEXT: Markets had a ROUGH week Apr 2–5 as Trump tariff fears triggered 5-week slump. S&P down ~4% YTD. However, Friday Apr 5 closed +0.44% on Iran ceasefire hopes — momentum returning. S&P now sits +0.3% ABOVE your exit baseline — your March 25 exit looks prescient. Strong dry-powder position heading into April 30 deployment.', bold=False, color=DARK_GRAY)

add_subhead('April 30 Strike List — Status')
positions = [
    ('V (Visa)',               'Core Forever',    'No material move — steady'),
    ('FICO',                   'Core Forever',    'No material move'),
    ('BABA (Alibaba)',         '20-Year Innovate','⚠️  China tech volatile on tariff news — watch'),
    ('PGR (Progressive)',      'Core Forever',    'Stable — insurance names holding up'),
    ('MELI (MercadoLibre)',    '20-Year Innovate','Near 52-wk low zone — keep monitoring'),
    ('BN (Brookfield)',        'Opportunistic',   'Holding steady'),
    ('CSU (Constellation Sw.)','Core Forever',    'Post-Leonard departure — still evaluating'),
]
for ticker, bucket, note in positions:
    p = doc.add_paragraph()
    p.paragraph_format.left_indent = Inches(0.25)
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after  = Pt(1)
    r1 = p.add_run(f'  {ticker}  ')
    r1.font.bold = True; r1.font.size = Pt(9); r1.font.name = 'Calibri'; r1.font.color.rgb = NAVY
    r2 = p.add_run(f'[{bucket}]  {note}')
    r2.font.size = Pt(9); r2.font.name = 'Calibri'

add_subhead('Super Investor / 13F Radar')
add_body('Q4 2025 13F cycle is closed. Q1 2026 filings due mid-May — next big signal. Key positions confirmed: Li Lu → BABA; Akre → V; Pabrai → various deep value; Buffett → Berkshire fully positioned. No major surprise moves flagged.', color=DARK_GRAY)

add_subhead('Earnings This Week (Watchlist-Adjacent)')
add_body('No major holdings report this week. Full earnings calendar on Seeking Alpha. April 30 is still 23 days away — plenty of time to calibrate.')

# ══════════════════════════════════════════════════════════════════════
#  SECTION 3 — COMMODITY PRICES
# ══════════════════════════════════════════════════════════════════════
p = doc.add_paragraph()
set_heading(p, '  §3  COMMODITY PRICES')

commodities = [
    ('Lumber Futures (Random Length)', '$584/MBF', '▼ -2.1% yesterday', 'Down from $614 Jan high. Housing starts -14.2% in March, mortgage rates 6.45%, builder inventory up 2.4%. Seasonal demand weak. Still +4.2% over past month / +2.2% YoY.'),
    ('Framing Lumber (2x4 SPF)',       '~$590–610 range', '▼ Softening', 'Canadian supply duties ~45% providing floor but demand weakness overwhelming. Watch spring construction uptick — may bounce Apr/May.'),
    ('Plywood/OSB (CDX)',              '~$42–48/sheet range','→ Flat', 'Stable. No major supply disruptions. Monitor tariff impact on Canadian imports.'),
    ('Gold',                           '$4,671/oz', '▲ +0.45%', 'Gold near all-time highs — macro fear trade alive and well.'),
    ('Oil (WTI)',                      'See markets', '—', 'Iran Strait tensions keeping energy elevated. Watch.'),
]
for item, price, chg, note in commodities:
    p = doc.add_paragraph()
    p.paragraph_format.left_indent = Inches(0.2)
    p.paragraph_format.space_before = Pt(2)
    p.paragraph_format.space_after  = Pt(0)
    r1 = p.add_run(f'  {item}  ')
    r1.font.bold = True; r1.font.size = Pt(9.5); r1.font.name = 'Calibri'; r1.font.color.rgb = NAVY
    r2 = p.add_run(f'  {price}  {chg}')
    r2.font.size = Pt(9.5); r2.font.name = 'Calibri'
    p2 = doc.add_paragraph(f'       {note}')
    p2.paragraph_format.left_indent = Inches(0.2)
    p2.paragraph_format.space_before = Pt(0)
    p2.paragraph_format.space_after  = Pt(3)
    p2.runs[0].font.size = Pt(8.5); p2.runs[0].font.italic = True
    p2.runs[0].font.color.rgb = DARK_GRAY

add_body('⚠️  TLC IMPLICATION: Lumber softness is a buying opportunity for spring inventory. Framing lumber at $590-610 is below the seasonal peak. Consider forward-locking pricing with suppliers before the May/June construction surge.', bold=False, color=DARK_GRAY)

# ══════════════════════════════════════════════════════════════════════
#  SECTION 4 — LOCAL NEWS & ZONING
# ══════════════════════════════════════════════════════════════════════
p = doc.add_paragraph()
set_heading(p, '  §4  LOCAL NEWS & ZONING')

add_subhead('LBI / Ocean County')
bullets4a = [
    'LBI spring market remains hot — avg sale price $2.26M (+49.6% YoY). Inventory tight going into peak season.',
    'Ocean County building permits: +47% YoY trend holds. Spring construction ramp-up underway.',
    'Haastrotters Boatyard (causeway, Ship Bottom) — status unclear; research pending.',
    'Corner Market deal (275 W 9th, Ship Bottom) — 214 W 9th St comp at $2.06M. 50/50 partnership still evaluating.',
]
for b in bullets4a:
    add_body(f'• {b}', indent=True)

add_subhead('Chesterfield Township (Firehouse)')
bullets4b = [
    'Old School Firehouse (18 New St, Crosswicks) — PMK Contractors Invoice $13,750 pending payment from JLKL TD Bank account.',
    '⏰ TODAY 8 AM: Brad (architect) meeting at firehouse — 10:15 AM TOMORROW (Apr 8). Floor plan markups needed.',
    'Luxury conversion comps: $900K–$2.2M range. Section 47 historic tax credit opportunity — follow up with CPA.',
    'Matthew Cassidy (Keli\'s half-brother, ex-Marines) helping with demo/electrical.',
]
for b in bullets4b:
    add_body(f'• {b}', indent=True)

add_subhead('NJ Construction Industry')
bullets4c = [
    'South Jersey construction cost inflation: +4.1% YoY.',
    'NJ housing permits tracking above 2025 pace through Q1 — good for TLC contractor demand.',
    'Epicor credit card surcharge module (Amanda) — status unknown. Follow up.',
    'Zoning Certificate of Compliance for 138–150 Railroad Ave (B-2 district) — Phil Reed. Application + $150 fee pending.',
]
for b in bullets4c:
    add_body(f'• {b}', indent=True)

# ══════════════════════════════════════════════════════════════════════
#  SECTION 5 — TODAY'S SCHEDULE
# ══════════════════════════════════════════════════════════════════════
p = doc.add_paragraph()
set_heading(p, '  §5  TODAY\'S SCHEDULE  ·  Tuesday, April 7')

add_subhead("Today's Cron Jobs & Reminders")
today_items = [
    ('8 Daily Mission Tasks', '8:00 AM', '🦞 Rob autonomous task run'),
    ('JLKL Transfer Check',   '8:00 AM', '⚠️ Check if JLKL account funds available — cover PMK check ($13,750)'),
    ('Rob Gmail Monitor',     'Every 2 min', 'Watching for new emails from Joe → jlynch@tlcnj.com'),
]
for name, time_, note in today_items:
    p = doc.add_paragraph()
    p.paragraph_format.left_indent = Inches(0.25)
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after  = Pt(1)
    r1 = p.add_run(f'  {time_}  ')
    r1.font.bold = True; r1.font.size = Pt(9.5); r1.font.name = 'Calibri'; r1.font.color.rgb = GOLD
    r2 = p.add_run(f'{name}  —  {note}')
    r2.font.size = Pt(9.5); r2.font.name = 'Calibri'

add_subhead('This Week')
this_week = [
    ('WED Apr 8',  '10:15 AM', '⭐ Brad (Architect) meeting at Firehouse — 18 New St, Crosswicks. Bring floor plan markups!'),
    ('MON Apr 13', '9:00 AM',  'Reminder: Get Chase Marriott Bonvoy card (ends 4365) back from daughter — call Chase 1-800-346-5538 to restrict'),
    ('WED Apr 30', 'ALL DAY',  '🚨 MAJOR: Portfolio restructuring — 29-stock deployment from $1.7M cash. Execute the plan.'),
]
for day, time_, note in this_week:
    p = doc.add_paragraph()
    p.paragraph_format.left_indent = Inches(0.25)
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after  = Pt(1)
    r1 = p.add_run(f'  {day}  ')
    r1.font.bold = True; r1.font.size = Pt(9.5); r1.font.name = 'Calibri'; r1.font.color.rgb = NAVY
    r2 = p.add_run(f'{time_}  —  {note}')
    r2.font.size = Pt(9.5); r2.font.name = 'Calibri'

# ══════════════════════════════════════════════════════════════════════
#  SECTION 6 — ACTION CARD
# ══════════════════════════════════════════════════════════════════════
p = doc.add_paragraph()
set_heading(p, '  §6  ACTION CARD  ·  Active Tasks')

categories = {
    'Mac / Tech': [
        ('Switch back to Claude Max $200/mo plan', 'Do tonight on Mac'),
        ('Set up Gmail read-only API on josephfl12@gmail.com', ''),
        ('Set up Outlook forwarding rule: Epicor reports → rob.lobster', ''),
        ('M365 Calendar ICS publishing', 'Joe action'),
        ('ElevenLabs account + voice plugin on Mac', 'Tonight'),
        ('Set up Bella with her own OpenClaw Chief of Staff', ''),
    ],
    'Calls to Make': [
        ('Call Jersey Appliance 609-918-1830', 'Thermador hood (svc #275188) — fix hood, door, racking'),
        ('Reach out to Frank Capecci (neighbor, 12th St)', '973-229-9362 — wife passed Dec 2025'),
        ('Joey Young — spreadsheet w/ commission/bonus calcs + inventory target', 'WAITING'),
        ('Mike the plumber (Ship Bottom)', 'Walk-through: plumbing renovation + HVAC'),
    ],
    'Firehouse (Old School, 18 New St)': [
        ('⭐ Architect meeting with Brad — TOMORROW Wed Apr 8, 10:15 AM', 'Bring floor plan markups'),
        ('Pay PMK Contractors $13,750 from JLKL TD Bank account', '⏰ JLKL funds check 8 AM today'),
        ('Section 47 historic tax credit — coordinate with MacArthur', 'Could be significant $$'),
        ('Matthew Cassidy — confirm demo/electrical schedule', ''),
    ],
    'TLC / Surfbox': [
        ('Amanda — follow up on Epicor credit card surcharge module', ''),
        ('Judy — staffing/overhead reduction update', ''),
        ('Epicor Min/Max implementation — check progress with Edwin', ''),
        ('Concrete drain installation — confirm status before Easter', ''),
        ('Neal/Denise — contractor prospect calls: Amon + Pagnotta', 'Full intel package ready'),
        ('Surfbox social media launch — April 30 go-live', 'Content calendar ready'),
        ('Equipment 2026: diesel dually forklift + low forklift for Tuckerton', ''),
    ],
    'Properties': [
        ('Zoning Certificate of Compliance — Phil Reed', 'Application + $150 fee — upload form'),
        ('Corner Market (275 W 9th, Ship Bottom) — 50/50 partnership decision', ''),
        ('Haastrotters Boatyard — research status (for sale/sold?)', '🦞 Rob pending'),
        ('Brother Matt — property co-ownership / fair buyout discussion', ''),
        ('Property tax appeal research — Chesterfield', '🦞 Rob — low priority'),
    ],
    'Family / Personal': [
        ('GLP-1 research / 1,500 cal high-protein diet plan', 'Target: 185-195 lbs from 225 lbs'),
        ('Berkshire Hathaway annual meeting — get tickets', 'Joe wants to attend'),
        ('Dictate Keli\'s full history to Rob', 'When Keli isn\'t nearby 😂'),
        ('Juliana confidence + summer job plan', 'Rob\'s portion done — discuss with Jules'),
        ('Rob Lobster voice clone — gather Robby\'s audio/video clips', 'Talk to Renee FIRST'),
    ],
    'Errands': [
        ('Gio — $225 cash check owed (driveway at parents\' house)', ''),
        ('Organize truck key rings — 5 rings: Firehouse, TD Banks, Truist, Surf City, Tuckerton', ''),
        ('Chase Marriott card ends 4365 — get from daughter by Apr 13', 'Call Chase: 1-800-346-5538'),
    ],
    'Coming Up This Week': [
        ('⭐ WED Apr 8 — Brad architect meeting, firehouse, 10:15 AM', ''),
        ('🚨 Apr 30 — Portfolio restructuring + Surfbox social media launch', 'Both on same day — plan ahead'),
    ],
}

for cat, items in categories.items():
    add_subhead(cat)
    for item, note in items:
        text = f'{item}  —  {note}' if note else item
        add_checkbox(text)

# ══════════════════════════════════════════════════════════════════════
#  SECTION 7 — SPORTS
# ══════════════════════════════════════════════════════════════════════
p = doc.add_paragraph()
set_heading(p, '  §7  SPORTS')

sports = [
    ('⚾ Yankees', 'L  Marlins 7, Yankees 6  (Apr 5)', 'Home series vs Marlins. Sandy Schlittler (2-0) starts Tue vs Athletics. Bounce-back time.'),
    ('⚾ Phillies', 'W  Phillies 4, Rockies (Apr 5)', 'Justin Crawford walk-off vs Nationals earlier in week. Playing well.'),
    ('🏀 Knicks', 'W  Knicks 136, Bulls 96  (Apr 6)', 'OG Anunoby 31 pts, Mitchell Robinson 17 pts/11 reb. ROUTED the Bulls by 47. Record: 50-28. Postseason looking 🔥'),
    ('🏈 Steelers', 'Offseason', 'NFL Draft late April. No game action.'),
    ('⚽ Liverpool FC', 'No PL fixture Mon/Tue', 'PL title race watch. 20-6-8 record. Check midweek schedule.'),
    ('🇺🇸 USMNT', 'No match', 'World Cup 2026 qualifying later this summer.'),
]
for sport, score, note in sports:
    p = doc.add_paragraph()
    p.paragraph_format.left_indent = Inches(0.2)
    p.paragraph_format.space_before = Pt(2)
    p.paragraph_format.space_after  = Pt(1)
    r1 = p.add_run(f'  {sport}  ')
    r1.font.bold = True; r1.font.size = Pt(9.5); r1.font.name = 'Calibri'; r1.font.color.rgb = NAVY
    r2 = p.add_run(f'  {score}')
    r2.font.bold = True; r2.font.size = Pt(9.5); r2.font.name = 'Calibri'
    p2 = doc.add_paragraph(f'       {note}')
    p2.paragraph_format.left_indent = Inches(0.2)
    p2.paragraph_format.space_before = Pt(0)
    p2.paragraph_format.space_after  = Pt(2)
    p2.runs[0].font.size = Pt(8.5); p2.runs[0].font.italic = True
    p2.runs[0].font.color.rgb = DARK_GRAY

# ══════════════════════════════════════════════════════════════════════
#  SECTION 8 — TOKEN SPEND
# ══════════════════════════════════════════════════════════════════════
p = doc.add_paragraph()
set_heading(p, '  §8  TOKEN SPEND  ·  Compute Budget Tracker')

add_body('Plan: Claude Max Subscription — $200/month flat (switched Mar 29, 2026). No per-token billing.')
add_body('')

spend_rows = [
    ('Yesterday (Apr 6)',  'Daily mission tasks (8 AM), Morning Rundown, Gmail monitors (x40+), ad-hoc requests', '~$8–12 equivalent', 'Flat plan — $0 marginal'),
    ('This Week (Apr 1–6)','Multiple deep dives: 13F analysis, Surfbox calendar, contractor intel, Firehouse comps', '~$40–60 equivalent', 'Flat plan — $0 marginal'),
    ('Month-to-Date',      'April running total: 7 days of full operations', '~$70–90 equivalent', '$200 flat — well within budget'),
    ('vs. API Key',        'Old API billing would have been ~$150–200 by now', 'Savings: $50–100', 'Subscription was the right call ✅'),
]

tbl2 = doc.add_table(rows=len(spend_rows)+1, cols=4)
tbl2.style = 'Table Grid'
tbl2.autofit = True

hdrs2 = ['Period', 'Activity', 'Est. API Value', 'Actual Cost']
for i, hdr in enumerate(hdrs2):
    cell = tbl2.rows[0].cells[i]
    cell.text = hdr
    cell.paragraphs[0].runs[0].font.bold = True
    cell.paragraphs[0].runs[0].font.size = Pt(8.5)
    cell.paragraphs[0].runs[0].font.name = 'Calibri'
    cell.paragraphs[0].runs[0].font.color.rgb = WHITE
    tc = cell._tc; tcPr = tc.get_or_add_tcPr()
    shd = OxmlElement('w:shd'); shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto'); shd.set(qn('w:fill'), '1F3564')
    tcPr.append(shd)

for ri, row in enumerate(spend_rows, 1):
    for ci, val in enumerate(row):
        cell = tbl2.rows[ri].cells[ci]
        cell.text = val
        cell.paragraphs[0].runs[0].font.size = Pt(8.5)
        cell.paragraphs[0].runs[0].font.name = 'Calibri'
        if ri % 2 == 0:
            tc = cell._tc; tcPr = tc.get_or_add_tcPr()
            shd = OxmlElement('w:shd'); shd.set(qn('w:val'), 'clear')
            shd.set(qn('w:color'), 'auto'); shd.set(qn('w:fill'), 'F2F2F2')
            tcPr.append(shd)

doc.add_paragraph()
add_body('📌 NOTE: Compare actual API key invoices against $200 subscription to confirm savings — this is a pending task.', color=DARK_GRAY)

# ══════════════════════════════════════════════════════════════════════
#  CLOSING
# ══════════════════════════════════════════════════════════════════════
add_divider()
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
r = p.add_run('Make good decisions today, Joe. 🦞  —Rob')
r.font.name = 'Calibri'; r.font.italic = True; r.font.size = Pt(9)
r.font.color.rgb = DARK_GRAY

outpath = '/Users/joemac/.openclaw/workspace/projects/daily/Morning_Joes_Rundown_2026-04-07.docx'
doc.save(outpath)
print(f'Saved: {outpath}')
