"""Halden Freight steering committee deck, built with the consulting-slides skill.

Run from this folder: python build_deck.py  ->  halden-freight-steerco.pptx
"""
import sys
from pathlib import Path

HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE.parent / "consulting-slides" / "scripts"))
from deckkit import *  # noqa: E402,F403

SRC = "Source: Halden Freight finance team (FY2023-25), as provided in brief; team analysis"

prs = new_deck()

# 1. Cover
title_slide(prs, "Restoring operating profit to €35M by 2027",
            "Halden Freight · Steering committee · 20 November 2026",
            note="Illustrative example · Fictional company and sample data")

# 2. Executive summary
s = content_slide(prs, "Three low-risk levers worth €16M restore operating profit to €37M by 2027",
                  tracker="Executive summary")
exec_summary(s, [
    ("The answer", "Approve route optimisation, subcontractor renegotiation and fuel efficiency now: "
                   "€16M a year by 2027 takes operating profit from €21M to €37M¹, above the €35M target."),
    ("Why profit fell", "Fuel (−€9M), driver wages (−€7M) and subcontracted haulage (−€6M) rose faster "
                        "than the €8M of price increases passed to customers."),
    ("Where the money is", "Wages, fuel and haulage hold €388M of the €528M addressable cost base; "
                           "empty running rose from 18% to 24% of kilometres."),
    ("Decide today", "Approve three levers, fund a study of depot consolidation (€3M, high risk) "
                     "and move €2M of SG&A cuts into the 2027 budget."),
])
illustrative(s)
source(s, SRC, footnote="1. All else equal: 2025 operating profit of €21M plus €16M run-rate savings")

# 3. Profit bridge
s = content_slide(prs, "Operating profit fell €17M since 2023 as fuel, wages and haulage costs outran price rises",
                  tracker="Diagnosis")
waterfall(s, [
    ("2023", 38, "total"),
    ("Fuel", -9, "delta"),
    ("Driver wages", -7, "delta"),
    ("Subcontracted haulage", -6, "delta"),
    ("Price increases", 8, "delta"),
    ("Depots and network", -3, "delta"),
    ("2025", 21, "total"),
], number_format='+0;-0;0', total_format='0', unit="Operating profit bridge, 2023 to 2025, €M")
illustrative(s)
source(s, SRC)

# 4. Cost base
s = content_slide(prs, "Wages, fuel and subcontracted haulage make up 73% of the €528M addressable cost base",
                  tracker="Diagnosis")
bar_chart(s, ["Driver wages", "Subcontracted haulage", "Fuel", "Depots and network",
              "Overheads (SG&A)", "Fleet maintenance"],
          [210, 96, 82, 58, 47, 35], highlight=[0, 1, 2], number_format='0', w=8.3,
          unit="Addressable cost by category, 2025, €M")
callout(s, "So what", [
    "€388M (73%) sits in three categories",
    "Wages are the largest pool, but no wage lever was sized in this phase",
    "Haulage and fuel can be addressed through procurement and routing",
])
illustrative(s)
source(s, SRC)

# 5. Levers
s = content_slide(prs, "Five levers could save €21M a year; the three fastest carry €16M at low or medium risk",
                  tracker="Options")
bar_chart(s, ["Route and load optimisation", "Subcontractor renegotiation", "Fuel hedging and telematics",
              "Depot consolidation", "Overhead (SG&A) reduction"],
          [7, 5, 4, 3, 2], highlight=[0, 1, 2], number_format='0', w=8.3,
          unit="Annual run-rate saving by 2027, €M")
callout(s, "Why these three first", [
    "Empty running rose from 18% to 24% of kilometres since 2023",
    "All three show impact within 3-9 months",
    "Depot consolidation is high risk and takes 12-18 months",
])
illustrative(s)
source(s, SRC)

# 6. Recommendation
s = content_slide(prs, "Approve three levers now; study depot consolidation and fold SG&A cuts into the 2027 budget",
                  tracker="Recommendation")
table(s, ["Lever", "Saving, €M a year", "Time to impact", "Risk", "Recommendation"], [
    ["Route and load optimisation", "7", "6-9 months", "Low", "Approve now"],
    ["Subcontractor renegotiation", "5", "3-6 months", "Medium", "Approve now"],
    ["Fuel hedging and telematics", "4", "3-6 months", "Low", "Approve now"],
    ["Depot consolidation", "3", "12-18 months", "High", "Study, decide in March"],
    ["Overhead (SG&A) reduction", "2", "6 months", "Medium", "Include in 2027 budget"],
], col_widths=[3.6, 2.0, 2.0, 1.6, 3.133], row_h=0.62, size=13)
illustrative(s)
source(s, SRC)

# 7. Next steps
s = content_slide(prs, "Approval today starts all three levers before the end of January 2027",
                  tracker="Next steps")
table(s, ["Action", "Owner", "By"], [
    ["Launch the route and load optimisation programme", "COO", "15 Dec 2026"],
    ["Include the €2M SG&A reduction in the 2027 budget", "CFO", "15 Dec 2026"],
    ["Issue the subcontractor panel tender", "Head of Procurement", "8 Jan 2027"],
    ["Agree fuel hedging policy and roll out telematics-led driving", "CFO", "31 Jan 2027"],
    ["Bring the depot consolidation study back to this committee", "Network Director", "31 Mar 2027"],
], col_widths=[7.333, 3.0, 2.0], row_h=0.62, size=13)
illustrative(s)
source(s, "Source: team proposal for discussion")

out = HERE / "halden-freight-steerco.pptx"
prs.save(out)
print(out)
