"""Build Shotgun financial model (.xlsx)."""
from openpyxl import Workbook
from openpyxl.styles import Font, PatternFill, Alignment, Border, Side
from openpyxl.utils import get_column_letter
from openpyxl.comments import Comment

OUT = "/sessions/nice-sleepy-pascal/mnt/outputs/shotgun-financial-model.xlsx"

# Color constants per skill
BLUE = Font(name="Arial", size=10, color="0000FF")
BLUE_BOLD = Font(name="Arial", size=10, color="0000FF", bold=True)
BLACK = Font(name="Arial", size=10, color="000000")
BLACK_BOLD = Font(name="Arial", size=10, color="000000", bold=True)
GREEN = Font(name="Arial", size=10, color="008000")
GREEN_BOLD = Font(name="Arial", size=10, color="008000", bold=True)
HEADER = Font(name="Arial", size=11, color="FFFFFF", bold=True)
TITLE = Font(name="Arial", size=16, color="0A1733", bold=True)
SECTION = Font(name="Arial", size=12, color="0A1733", bold=True)
NOTE = Font(name="Arial", size=9, color="6B7280", italic=True)

NAVY_FILL = PatternFill("solid", start_color="0A1733")
AMBER_FILL = PatternFill("solid", start_color="F4B33C")
LIGHT_FILL = PatternFill("solid", start_color="F7F4ED")
GRAY_FILL = PatternFill("solid", start_color="E8E4D8")
HIGHLIGHT_FILL = PatternFill("solid", start_color="FFFACD")

thin = Side(border_style="thin", color="CCCCCC")
border_all = Border(left=thin, right=thin, top=thin, bottom=thin)
center = Alignment(horizontal="center", vertical="center")
left = Alignment(horizontal="left", vertical="center", wrap_text=True)
right = Alignment(horizontal="right", vertical="center")

FMT_USD = '"$"#,##0;("$"#,##0);-'
FMT_USD2 = '"$"#,##0.00;("$"#,##0.00);-'
FMT_PCT = '0.0%;(0.0%);-'
FMT_NUM = '#,##0;(#,##0);-'
FMT_MULT = '0.0"x"'

wb = Workbook()

# =============== SHEET 1: ASSUMPTIONS ===============
a = wb.active
a.title = "Assumptions"
a.sheet_view.showGridLines = False

a["A1"] = "Shotgun - Financial Model"
a["A1"].font = Font(name="Arial", size=20, color="0A1733", bold=True)
a["A2"] = "Designated-driver-for-your-own-car - pilot launch model"
a["A2"].font = NOTE
a["A3"] = "Color key: Blue = input | Black = formula | Green = cross-sheet link | Yellow = key assumption"
a["A3"].font = NOTE

a["A5"] = "Pricing & per-trip metrics"
a["A5"].font = SECTION
a["A5"].fill = AMBER_FILL

pricing = [
    ("Avg fare per Standard trip ($)", 36.00, FMT_USD2, "Pilot pricing: $28 base + $2.20/mi @ ~3.6 mi billable"),
    ("Avg fare per By-the-hour trip ($)", 110.00, FMT_USD2, "$45/hr x 2.4 hr avg duration"),
    ("Avg fare per Long-haul trip ($)", 320.00, FMT_USD2, "$0.95/mi x 340 mi avg"),
    ("Mix: Standard %", 0.78, FMT_PCT, "Heaviest in pilot - bar/medical core use"),
    ("Mix: By-the-hour %", 0.18, FMT_PCT, ""),
    ("Mix: Long-haul %", 0.04, FMT_PCT, "Long-haul is high-value but rare in pilot"),
]
for i, (label, val, fmt, note) in enumerate(pricing):
    r = 6 + i
    a[f"A{r}"] = label
    a[f"A{r}"].font = BLACK
    a[f"B{r}"] = val
    a[f"B{r}"].font = BLUE
    a[f"B{r}"].number_format = fmt
    a[f"C{r}"] = note
    a[f"C{r}"].font = NOTE
    a[f"C{r}"].alignment = left

a["A12"] = "Blended fare per trip ($)"
a["A12"].font = BLACK_BOLD
a["B12"] = "=B6*B9 + B7*B10 + B8*B11"
a["B12"].font = BLACK_BOLD
a["B12"].number_format = FMT_USD2
a["B12"].fill = HIGHLIGHT_FILL
a["C12"] = "Weighted average across service mix"
a["C12"].font = NOTE

a["A14"] = "Driver economics"
a["A14"].font = SECTION
a["A14"].fill = AMBER_FILL

driver_econ = [
    ("Driver pay % of fare", 0.68, FMT_PCT, "Industry-comparable; lower than Uber as driver doesn't supply vehicle"),
    ("Driver tips captured (% of fare)", 0.06, FMT_PCT, "Driver keeps 100% of tips; not platform revenue"),
    ("Driver cost per trip - scooter & ops ($)", 0.85, FMT_USD2, "E-scooter amortization + battery + maintenance"),
]
for i, (label, val, fmt, note) in enumerate(driver_econ):
    r = 15 + i
    a[f"A{r}"] = label
    a[f"A{r}"].font = BLACK
    a[f"B{r}"] = val
    a[f"B{r}"].font = BLUE
    a[f"B{r}"].number_format = fmt
    a[f"C{r}"] = note
    a[f"C{r}"].font = NOTE

a["A19"] = "Platform costs per trip"
a["A19"].font = SECTION
a["A19"].fill = AMBER_FILL

plat_costs = [
    ("Insurance per active trip ($)", 1.85, FMT_USD2, "Commercial auto policy, ~$0.025/min x 75 min avg"),
    ("Payment processing (% of fare)", 0.029, FMT_PCT, "Stripe-equivalent"),
    ("Customer support per trip ($)", 0.40, FMT_USD2, "AI-first; human escalation ~6%"),
    ("Tech/infra per trip ($)", 0.18, FMT_USD2, "Cloud + maps + SMS"),
    ("Variable acquisition cost per trip ($)", 1.10, FMT_USD2, "Decays with cohort age; this is steady-state blended"),
]
for i, (label, val, fmt, note) in enumerate(plat_costs):
    r = 20 + i
    a[f"A{r}"] = label
    a[f"A{r}"].font = BLACK
    a[f"B{r}"] = val
    a[f"B{r}"].font = BLUE
    a[f"B{r}"].number_format = fmt
    a[f"C{r}"] = note
    a[f"C{r}"].font = NOTE

a["A26"] = "Demand model - pilot city (Austin, TX)"
a["A26"].font = SECTION
a["A26"].fill = AMBER_FILL

demand = [
    ("Metro adult population", 2200000, FMT_NUM, "Austin-Round Rock MSA, est. 2026", False),
    ("Adults who drove to drink last 30 days (%)", 0.22, FMT_PCT, "NHTSA / proprietary survey, est.", False),
    ("Addressable bar-night customers", "=B27*B28", FMT_NUM, "Calculated: metro x drove-to-drink %", True),
    ("Trips per Shotgun customer per month", 1.6, FMT_NUM, "Cohort 2 average from waitlist intent survey", False),
    ("Pilot market penetration target - Mo 12", 0.025, FMT_PCT, "% of addressable using Shotgun monthly by Mo 12", False),
    ("Other-segment uplift (medical/long-haul/hourly)", 0.18, FMT_PCT, "Trips from non-bar segments as % of bar trips", False),
]
for i, (label, val, fmt, note, is_formula) in enumerate(demand):
    r = 27 + i
    a[f"A{r}"] = label
    a[f"A{r}"].font = BLACK
    a[f"B{r}"] = val
    a[f"B{r}"].font = BLACK if is_formula else BLUE
    a[f"B{r}"].number_format = fmt
    a[f"C{r}"] = note
    a[f"C{r}"].font = NOTE

a.column_dimensions["A"].width = 44
a.column_dimensions["B"].width = 18
a.column_dimensions["C"].width = 56

# =============== SHEET 2: UNIT ECONOMICS ===============
u = wb.create_sheet("Unit Economics")
u.sheet_view.showGridLines = False

u["A1"] = "Per-Trip Unit Economics"
u["A1"].font = TITLE
u["A2"] = "Built from Assumptions tab. Change inputs there; this updates."
u["A2"].font = NOTE

u["A4"] = "Line item"
u["B4"] = "Per trip"
u["C4"] = "% of fare"
u["D4"] = "Notes"
for col in ["A4", "B4", "C4", "D4"]:
    u[col].font = HEADER
    u[col].fill = NAVY_FILL
    u[col].alignment = center
    u[col].border = border_all

ue_rows = [
    ("Blended fare", "=Assumptions!B12", "=B5/B5", "Avg revenue per trip across mix"),
    ("Driver pay (incl. base + bonuses)", "=B5*Assumptions!B15", "=B6/$B$5", "% of fare to driver"),
    ("Driver scooter/ops cost (passed-thru)", "=Assumptions!B17", "=B7/$B$5", ""),
    ("Insurance (commercial auto, per trip)", "=Assumptions!B20", "=B8/$B$5", ""),
    ("Payment processing", "=B5*Assumptions!B21", "=B9/$B$5", ""),
    ("Customer support", "=Assumptions!B22", "=B10/$B$5", ""),
    ("Tech/infra", "=Assumptions!B23", "=B11/$B$5", ""),
    ("Variable customer acquisition", "=Assumptions!B24", "=B12/$B$5", "Steady-state, blended cohort"),
]
for i, (label, formula, pct, note) in enumerate(ue_rows):
    r = 5 + i
    u[f"A{r}"] = label
    u[f"A{r}"].font = BLACK
    u[f"B{r}"] = formula
    u[f"B{r}"].font = GREEN if "Assumptions" in formula else BLACK
    u[f"B{r}"].number_format = FMT_USD2
    u[f"C{r}"] = pct
    u[f"C{r}"].font = BLACK
    u[f"C{r}"].number_format = FMT_PCT
    u[f"D{r}"] = note
    u[f"D{r}"].font = NOTE
    u[f"D{r}"].alignment = left

u["A14"] = "Contribution margin per trip"
u["A14"].font = BLACK_BOLD
u["A14"].fill = LIGHT_FILL
u["B14"] = "=B5 - SUM(B6:B12)"
u["B14"].font = BLACK_BOLD
u["B14"].number_format = FMT_USD2
u["B14"].fill = LIGHT_FILL
u["C14"] = "=B14/$B$5"
u["C14"].font = BLACK_BOLD
u["C14"].number_format = FMT_PCT
u["C14"].fill = LIGHT_FILL
u["D14"] = "Cash to platform after all variable costs"
u["D14"].font = NOTE

u["A16"] = "Take rate (platform revenue / GMV)"
u["A16"].font = BLACK_BOLD
u["B16"] = "=B5 - B6"
u["B16"].font = BLACK_BOLD
u["B16"].number_format = FMT_USD2
u["C16"] = "=B16/B5"
u["C16"].font = BLACK_BOLD
u["C16"].number_format = FMT_PCT
u["D16"] = "Net revenue to Shotgun before variable platform costs"
u["D16"].font = NOTE

u["A18"] = "Target contribution margin"
u["A18"].font = BLACK
u["B18"] = "=Assumptions!B12*0.16"
u["B18"].font = GREEN
u["B18"].number_format = FMT_USD2
u["C18"] = 0.16
u["C18"].font = BLUE
u["C18"].number_format = FMT_PCT
u["D18"] = "Goal: 16%+ at maturity (vs. modeled current)"
u["D18"].font = NOTE

u["A20"] = "Comparison to rideshare benchmark"
u["A20"].font = SECTION
u["A21"] = "Uber, public 2024 take rate (vehicle-included)"
u["A21"].font = BLACK
u["B21"] = 0.276
u["B21"].font = BLUE
u["B21"].number_format = FMT_PCT
u["A22"] = "Shotgun modeled take rate"
u["A22"].font = BLACK
u["B22"] = "=C16"
u["B22"].font = BLACK
u["B22"].number_format = FMT_PCT
u["A23"] = "Note"
u["A23"].font = BLACK
u["B23"] = "Lower take justified - driver doesn't supply vehicle so absolute pay can be lower while % is competitive."
u["B23"].font = NOTE
u.merge_cells("B23:D23")
u["B23"].alignment = left

u.column_dimensions["A"].width = 38
u.column_dimensions["B"].width = 14
u.column_dimensions["C"].width = 12
u.column_dimensions["D"].width = 50

# =============== SHEET 3: 24-MONTH OPERATING MODEL ===============
o = wb.create_sheet("Operating Model")
o.sheet_view.showGridLines = False

o["A1"] = "24-Month Operating Model"
o["A1"].font = TITLE
o["A2"] = "Single-city pilot (Mo 1-9), 4-city expansion (Mo 10-24). All projections."
o["A2"].font = NOTE

months = [f"Mo {i+1}" for i in range(24)]
o["A4"] = "Month"
o["A4"].font = HEADER
o["A4"].fill = NAVY_FILL
o["A4"].alignment = center
for i, m in enumerate(months):
    col = get_column_letter(2 + i)
    o[f"{col}4"] = m
    o[f"{col}4"].font = HEADER
    o[f"{col}4"].fill = NAVY_FILL
    o[f"{col}4"].alignment = center

o["A5"] = "Cities live"
o["A5"].font = BLACK
cities = [1]*9 + [2]*3 + [3]*3 + [4]*9
for i, c in enumerate(cities):
    col = get_column_letter(2 + i)
    o[f"{col}5"] = c
    o[f"{col}5"].font = BLUE
    o[f"{col}5"].alignment = center

o["A6"] = "Trips per city / month"
o["A6"].font = BLACK
trips_per_city = [
    400, 900, 1800, 3000, 4500, 6500, 9000, 12000, 15500,
    19000, 22000, 25000,
    27500, 30000, 32500,
    35000, 37500, 40000, 42500, 45000, 47500, 50000, 52500, 55000
]
for i, t in enumerate(trips_per_city):
    col = get_column_letter(2 + i)
    o[f"{col}6"] = t
    o[f"{col}6"].font = BLUE
    o[f"{col}6"].alignment = right
    o[f"{col}6"].number_format = FMT_NUM

o["A7"] = "Total trips"
o["A7"].font = BLACK_BOLD
for i in range(24):
    col = get_column_letter(2 + i)
    o[f"{col}7"] = f"={col}5*{col}6"
    o[f"{col}7"].font = BLACK_BOLD
    o[f"{col}7"].number_format = FMT_NUM

o["A9"] = "GMV (gross fare)"
o["A9"].font = BLACK
for i in range(24):
    col = get_column_letter(2 + i)
    o[f"{col}9"] = f"={col}7*Assumptions!$B$12"
    o[f"{col}9"].font = GREEN
    o[f"{col}9"].number_format = FMT_USD

o["A10"] = "Net revenue (take)"
o["A10"].font = BLACK_BOLD
for i in range(24):
    col = get_column_letter(2 + i)
    o[f"{col}10"] = f"={col}7*'Unit Economics'!$B$16"
    o[f"{col}10"].font = GREEN_BOLD
    o[f"{col}10"].number_format = FMT_USD
    o[f"{col}10"].fill = LIGHT_FILL

o["A12"] = "Variable platform costs"
o["A12"].font = SECTION
o["A13"] = "Variable costs (insurance + ops + CAC + processing)"
o["A13"].font = BLACK
for i in range(24):
    col = get_column_letter(2 + i)
    o[f"{col}13"] = f"={col}7*(Assumptions!$B$20 + Assumptions!$B$22 + Assumptions!$B$23 + Assumptions!$B$24) + {col}9*Assumptions!$B$21"
    o[f"{col}13"].font = GREEN
    o[f"{col}13"].number_format = FMT_USD

o["A14"] = "Contribution margin ($)"
o["A14"].font = BLACK_BOLD
for i in range(24):
    col = get_column_letter(2 + i)
    o[f"{col}14"] = f"={col}10 - {col}13"
    o[f"{col}14"].font = BLACK_BOLD
    o[f"{col}14"].number_format = FMT_USD
    o[f"{col}14"].fill = LIGHT_FILL

o["A15"] = "Contribution margin (%)"
o["A15"].font = BLACK
for i in range(24):
    col = get_column_letter(2 + i)
    o[f"{col}15"] = f"=IFERROR({col}14/{col}10,0)"
    o[f"{col}15"].font = BLACK
    o[f"{col}15"].number_format = FMT_PCT

o["A17"] = "Fixed costs"
o["A17"].font = SECTION

salaries = [40000, 45000, 55000, 75000, 95000, 115000, 135000, 155000, 175000,
            210000, 240000, 270000,
            305000, 330000, 350000,
            375000, 395000, 410000, 425000, 440000, 455000, 470000, 485000, 500000]
o["A18"] = "Salaries & contractors"
o["A18"].font = BLACK
for i, s in enumerate(salaries):
    col = get_column_letter(2 + i)
    o[f"{col}18"] = s
    o[f"{col}18"].font = BLUE
    o[f"{col}18"].number_format = FMT_USD

o["A19"] = "Tech infrastructure & tools"
o["A19"].font = BLACK
for i in range(24):
    col = get_column_letter(2 + i)
    val = 8000 if i < 6 else 14000 if i < 12 else 22000 if i < 18 else 30000
    o[f"{col}19"] = val
    o[f"{col}19"].font = BLUE
    o[f"{col}19"].number_format = FMT_USD

o["A20"] = "Marketing & growth (above CAC)"
o["A20"].font = BLACK
for i in range(24):
    col = get_column_letter(2 + i)
    val = 60000 if i in [0, 9, 12, 15] else 25000 if i < 6 else 35000 if i < 12 else 50000
    o[f"{col}20"] = val
    o[f"{col}20"].font = BLUE
    o[f"{col}20"].number_format = FMT_USD

o["A21"] = "Driver acquisition & onboarding"
o["A21"].font = BLACK
for i in range(24):
    col = get_column_letter(2 + i)
    val = 25000 if i in [0, 9, 12, 15] else 6000 if i < 6 else 10000 if i < 12 else 14000
    o[f"{col}21"] = val
    o[f"{col}21"].font = BLUE
    o[f"{col}21"].number_format = FMT_USD

o["A22"] = "G&A (legal, finance, office)"
o["A22"].font = BLACK
for i in range(24):
    col = get_column_letter(2 + i)
    val = 8000 if i < 6 else 18000 if i < 12 else 30000 if i < 18 else 45000
    o[f"{col}22"] = val
    o[f"{col}22"].font = BLUE
    o[f"{col}22"].number_format = FMT_USD

o["A24"] = "Total fixed costs"
o["A24"].font = BLACK_BOLD
for i in range(24):
    col = get_column_letter(2 + i)
    o[f"{col}24"] = f"=SUM({col}18:{col}22)"
    o[f"{col}24"].font = BLACK_BOLD
    o[f"{col}24"].number_format = FMT_USD

o["A26"] = "EBITDA"
o["A26"].font = BLACK_BOLD
o["A26"].fill = AMBER_FILL
for i in range(24):
    col = get_column_letter(2 + i)
    o[f"{col}26"] = f"={col}14 - {col}24"
    o[f"{col}26"].font = BLACK_BOLD
    o[f"{col}26"].number_format = FMT_USD
    o[f"{col}26"].fill = AMBER_FILL

o["A28"] = "Beginning cash"
o["A28"].font = BLACK
o["B28"] = 5000000
o["B28"].font = BLUE
o["B28"].number_format = FMT_USD

for i in range(1, 24):
    col = get_column_letter(2 + i)
    prev = get_column_letter(1 + i)
    o[f"{col}28"] = f"={prev}29"
    o[f"{col}28"].font = BLACK
    o[f"{col}28"].number_format = FMT_USD

o["A29"] = "Ending cash"
o["A29"].font = BLACK_BOLD
for i in range(24):
    col = get_column_letter(2 + i)
    o[f"{col}29"] = f"={col}28 + {col}26"
    o[f"{col}29"].font = BLACK_BOLD
    o[f"{col}29"].number_format = FMT_USD
    o[f"{col}29"].fill = LIGHT_FILL

o["A31"] = "Cumulative trips"
o["A31"].font = BLACK
o["B31"] = "=B7"
o["B31"].font = BLACK
o["B31"].number_format = FMT_NUM
for i in range(1, 24):
    col = get_column_letter(2 + i)
    prev = get_column_letter(1 + i)
    o[f"{col}31"] = f"={prev}31 + {col}7"
    o[f"{col}31"].font = BLACK
    o[f"{col}31"].number_format = FMT_NUM

o["A32"] = "Cumulative GMV"
o["A32"].font = BLACK
o["B32"] = "=B9"
o["B32"].font = BLACK
o["B32"].number_format = FMT_USD
for i in range(1, 24):
    col = get_column_letter(2 + i)
    prev = get_column_letter(1 + i)
    o[f"{col}32"] = f"={prev}32 + {col}9"
    o[f"{col}32"].font = BLACK
    o[f"{col}32"].number_format = FMT_USD

o.column_dimensions["A"].width = 38
for i in range(24):
    o.column_dimensions[get_column_letter(2 + i)].width = 12
o.freeze_panes = "B5"

# =============== SHEET 4: SENSITIVITY ===============
s = wb.create_sheet("Sensitivity")
s.sheet_view.showGridLines = False

s["A1"] = "Sensitivity - Mo-24 Annualized EBITDA"
s["A1"].font = TITLE
s["A2"] = "Driver pay % (rows) x Trips/city/month at Mo 24 (cols). Values in $M annualized."
s["A2"].font = NOTE

driver_pcts = [0.60, 0.64, 0.68, 0.72, 0.76]
trip_levels = [40000, 50000, 55000, 65000, 80000]

s["B5"] = "Trips / city / month at Mo 24"
s["B5"].font = BLACK_BOLD
s.merge_cells("B5:F5")
s["B5"].alignment = center
s["A6"] = "Driver pay %"
s["A6"].font = BLACK_BOLD
s["A6"].alignment = center

for j, t in enumerate(trip_levels):
    col = get_column_letter(2 + j)
    s[f"{col}6"] = t
    s[f"{col}6"].font = HEADER
    s[f"{col}6"].fill = NAVY_FILL
    s[f"{col}6"].alignment = center
    s[f"{col}6"].number_format = FMT_NUM

for i, dp in enumerate(driver_pcts):
    r = 7 + i
    s[f"A{r}"] = dp
    s[f"A{r}"].font = HEADER
    s[f"A{r}"].fill = NAVY_FILL
    s[f"A{r}"].alignment = center
    s[f"A{r}"].number_format = FMT_PCT
    for j, t in enumerate(trip_levels):
        col = get_column_letter(2 + j)
        formula = (
            f"=(4*{t}*12*"
            f"(Assumptions!$B$12*(1 - {dp}) "
            f"- Assumptions!$B$20 - Assumptions!$B$22 - Assumptions!$B$23 - Assumptions!$B$24 "
            f"- Assumptions!$B$12*Assumptions!$B$21))"
            f"/1000000"
            f"-(500000+30000+50000+14000+45000)*12/1000000"
        )
        s[f"{col}{r}"] = formula
        s[f"{col}{r}"].font = BLACK
        s[f"{col}{r}"].number_format = '"$"#,##0.0"M";("$"#,##0.0"M");"-"'
        s[f"{col}{r}"].alignment = right

s["A14"] = "Read this:"
s["A14"].font = SECTION
s["A15"] = "Center cell is base case Mo-24 annualized EBITDA at 68% driver pay x 55K trips/city/mo."
s["A15"].font = BLACK
s["A16"] = "Up-and-right (more trips, less driver pay) is high EBITDA but supply-side risky - drivers churn."
s["A16"].font = BLACK
s["A17"] = "Down-and-left (high pay, low volume) is the failure mode: we lose money but drivers stay."
s["A17"].font = BLACK
s["A18"] = "Investable region: ~66-72% driver pay x 50-65K trips/city/mo."
s["A18"].font = BLACK_BOLD
s["A18"].fill = HIGHLIGHT_FILL

s.column_dimensions["A"].width = 22
for j in range(5):
    s.column_dimensions[get_column_letter(2 + j)].width = 16

# =============== SHEET 5: USE OF FUNDS ===============
f = wb.create_sheet("Use of Funds")
f.sheet_view.showGridLines = False

f["A1"] = "Seed Round Use of Funds"
f["A1"].font = TITLE
f["A2"] = "$5.0M seed - 18 months runway - Series A target Mo 14-16"
f["A2"].font = NOTE

f["A4"] = "Category"
f["B4"] = "Allocation ($M)"
f["C4"] = "% of round"
f["D4"] = "What it buys"
for col in ["A4", "B4", "C4", "D4"]:
    f[col].font = HEADER
    f[col].fill = NAVY_FILL
    f[col].alignment = center

uses = [
    ("Engineering & product", 1.6, "8 engineers, 1 PM, 1 designer for 18 mo (rider app, driver app, dispatch, insurance integration)"),
    ("City launches (4 markets)", 1.2, "Driver acquisition, hub setup, local marketing across 4 cities Mo 1-15"),
    ("Insurance underwriting & legal", 0.6, "Custom commercial-auto policy, regulatory, T&Cs, driver agreement"),
    ("Operations & support", 0.5, "AI-first support stack + 6 human escalation reps by Mo 24"),
    ("Marketing & brand", 0.7, "Brand identity, performance marketing, paid social"),
    ("Working capital & buffer", 0.4, "Insurance prepays, driver payout float, contingency"),
]
for i, (cat, amt, what) in enumerate(uses):
    r = 5 + i
    f[f"A{r}"] = cat
    f[f"A{r}"].font = BLACK
    f[f"B{r}"] = amt
    f[f"B{r}"].font = BLUE
    f[f"B{r}"].number_format = '"$"#,##0.0"M"'
    f[f"C{r}"] = f"=B{r}/$B$11"
    f[f"C{r}"].font = BLACK
    f[f"C{r}"].number_format = FMT_PCT
    f[f"D{r}"] = what
    f[f"D{r}"].font = NOTE
    f[f"D{r}"].alignment = left

f["A11"] = "TOTAL"
f["A11"].font = BLACK_BOLD
f["A11"].fill = AMBER_FILL
f["B11"] = "=SUM(B5:B10)"
f["B11"].font = BLACK_BOLD
f["B11"].fill = AMBER_FILL
f["B11"].number_format = '"$"#,##0.0"M"'
f["C11"] = "=SUM(C5:C10)"
f["C11"].font = BLACK_BOLD
f["C11"].fill = AMBER_FILL
f["C11"].number_format = FMT_PCT

f["A13"] = "Milestones unlocked by this raise"
f["A13"].font = SECTION

milestones = [
    ("Mo 3", "Pilot launches, first 1,000 paid trips"),
    ("Mo 6", "Contribution-margin positive in pilot city"),
    ("Mo 9", "Pilot-city take rate stabilized; ready for City #2"),
    ("Mo 12", "2 cities live, $900K monthly GMV"),
    ("Mo 15", "3 cities live, Series A pitch in market"),
    ("Mo 18", "4 cities live, ~$2.5M monthly GMV, Series A closed"),
]
for i, (ts, desc) in enumerate(milestones):
    r = 14 + i
    f[f"A{r}"] = ts
    f[f"A{r}"].font = BLACK_BOLD
    f[f"A{r}"].alignment = center
    f[f"B{r}"] = desc
    f[f"B{r}"].font = BLACK
    f.merge_cells(f"B{r}:D{r}")
    f[f"B{r}"].alignment = left

f.column_dimensions["A"].width = 28
f.column_dimensions["B"].width = 16
f.column_dimensions["C"].width = 12
f.column_dimensions["D"].width = 60

wb.save(OUT)
print("Saved:", OUT)
