root = Card([header, metricsRow, trendsSection, budgetSection, peopleSection, risksSection, initiativesSection, boardSection], "card", "column", "l")
header = Card([titleBlock, controlsRow], "clear", "row", "m", "center", "between")
titleBlock = Card([mainTitle, subtitle], "clear", "column", "xs")
mainTitle = Heading("CEO Quarterly Command View", "h1")
subtitle = TextContent("Q2 2024 • Global • All Regions", "default")
controlsRow = Card([quarterSelect, regionSelect, exportBtn], "clear", "row", "m", "center", "end")
quarterSelect = Select("quarter", quarterOptions, "Select quarter", [], "medium")
quarterOptions = [q1Opt, q2Opt, q3Opt, q4Opt]
q1Opt = SelectItem("Q1-2024", "Q1 2024")
q2Opt = SelectItem("Q2-2024", "Q2 2024")
q3Opt = SelectItem("Q3-2024", "Q3 2024")
q4Opt = SelectItem("Q4-2024", "Q4 2024")
regionSelect = Select("region", regionOptions, "Select region", [], "medium")
regionOptions = [globalOpt, amerOpt, emeaOpt, apacOpt]
globalOpt = SelectItem("global", "Global")
amerOpt = SelectItem("amer", "Americas")
emeaOpt = SelectItem("emea", "EMEA")
apacOpt = SelectItem("apac", "APAC")
exportBtn = Button("Export Pack", ["export-pack"], "primary")

metricsRow = Card([revCard, costCard, profitCard, runwayCard, pipelineCard, winRateCard, custCard, churnCard, npsCard], "clear", "row", "m", "stretch", "start", true)
revCard = Card([revLabel, revValue, revDelta], "card", "column", "xs")
revLabel = TextContent("Revenue", "small")
revValue = TextContent("$42.8M", "large-heavy")
revDelta = TextContent("+12% vs plan", "small")
costCard = Card([costLabel, costValue, costDelta], "card", "column", "xs")
costLabel = TextContent("Costs", "small")
costValue = TextContent("$28.4M", "large-heavy")
costDelta = TextContent("-3% vs plan", "small")
profitCard = Card([profitLabel, profitValue, profitDelta], "card", "column", "xs")
profitLabel = TextContent("Profit", "small")
profitValue = TextContent("$14.4M", "large-heavy")
profitDelta = TextContent("+28% vs plan", "small")
runwayCard = Card([runwayLabel, runwayValue, runwayDelta], "card", "column", "xs")
runwayLabel = TextContent("Runway", "small")
runwayValue = TextContent("18 months", "large-heavy")
runwayDelta = TextContent("+2 mo vs last Q", "small")
pipelineCard = Card([pipeLabel, pipeValue, pipeDelta], "card", "column", "xs")
pipeLabel = TextContent("Pipeline", "small")
pipeValue = TextContent("$89.2M", "large-heavy")
pipeDelta = TextContent("+15% QoQ", "small")
winRateCard = Card([winLabel, winValue, winDelta], "card", "column", "xs")
winLabel = TextContent("Win Rate", "small")
winValue = TextContent("34%", "large-heavy")
winDelta = TextContent("+3pp QoQ", "small")
custCard = Card([custLabel, custValue, custDelta], "card", "column", "xs")
custLabel = TextContent("Customers", "small")
custValue = TextContent("2,847", "large-heavy")
custDelta = TextContent("+234 QoQ", "small")
churnCard = Card([churnLabel, churnValue, churnDelta], "card", "column", "xs")
churnLabel = TextContent("Churn Rate", "small")
churnValue = TextContent("4.2%", "large-heavy")
churnDelta = TextContent("-0.5pp QoQ", "small")
npsCard = Card([npsLabel, npsValue, npsDelta], "card", "column", "xs")
npsLabel = TextContent("NPS", "small")
npsValue = TextContent("62", "large-heavy")
npsDelta = TextContent("+4 vs last Q", "small")

trendsSection = Card([trendsHeader, revTrendChart, costTrendChart], "card", "column", "m")
trendsHeader = CardHeader("Quarterly Trends", "Revenue and costs over last 4 quarters")
revTrendChart = BarChart(revLabels, [revSeries, planRevSeries], "grouped", "Quarter", "USD (M)")
revLabels = ["Q3-23", "Q4-23", "Q1-24", "Q2-24"]
revSeries = Series("Actual Revenue", [34.2, 37.8, 39.5, 42.8])
planRevSeries = Series("Plan Revenue", [33.0, 35.5, 38.0, 40.0])
costTrendChart = BarChart(costLabels, [costSeries, planCostSeries], "grouped", "Quarter", "USD (M)")
costLabels = ["Q3-23", "Q4-23", "Q1-24", "Q2-24"]
costSeries = Series("Actual Costs", [24.1, 25.8, 26.9, 28.4])
planCostSeries = Series("Plan Costs", [25.0, 26.0, 27.5, 29.0])

budgetSection = Card([budgetHeader, budgetChart], "card", "column", "m")
budgetHeader = CardHeader("Budget vs Plan by Department", "Q2 2024 actual spend against approved budget")
budgetChart = HorizontalBarChart(deptLabels, [budgetActualSeries, budgetPlanSeries], "grouped", "USD (M)", "Department")
deptLabels = ["Engineering", "Sales & Marketing", "Product", "G&A", "Operations", "R&D"]
budgetActualSeries = Series("Actual", [8.2, 12.5, 3.8, 4.1, 2.3, 3.5])
budgetPlanSeries = Series("Plan", [8.5, 13.0, 4.0, 4.0, 2.5, 3.8])

peopleSection = Card([peopleHeader, headcountChart], "card", "column", "m")
peopleHeader = CardHeader("Headcount by Department", "Full-time employees as of Q2 2024 end")
headcountChart = HorizontalBarChart(hcLabels, [hcSeries], "grouped", "Headcount", "Department")
hcLabels = ["Engineering", "Sales & Marketing", "Product", "G&A", "Operations", "R&D"]
hcSeries = Series("Headcount", [185, 142, 48, 67, 34, 52])

risksSection = Card([risksHeader, risksTable], "card", "column", "m")
risksHeader = CardHeader("Top Risks", "Key risks with owners and mitigation status")
risksTable = Table([riskCol, ownerCol, severityCol, statusCol, mitigationCol])
riskCol = Col("Risk", ["Revenue concentration", "Talent retention", "Competitive pressure", "Regulatory changes", "Technical debt"])
ownerCol = Col("Owner", ["CRO", "CHRO", "CPO", "General Counsel", "CTO"])
severityCol = Col("Severity", ["High", "High", "Medium", "Medium", "High"])
statusCol = Col("Status", ["Mitigating", "Monitoring", "Active", "Watching", "Mitigating"])
mitigationCol = Col("Mitigation", ["Expand enterprise", "Retention program", "Differentiation", "Compliance audit", "Refactor sprint"])

initiativesSection = Card([initHeader, initTable], "card", "column", "m")
initHeader = CardHeader("Strategic Initiatives", "Quarterly priorities with status and progress")
initTable = Table([initCol, ownerCol2, statusCol2, progressCol, targetCol])
initCol = Col("Initiative", ["Enterprise expansion", "PLG motion", "AI product line", "International launch", "Platform reliability"])
ownerCol2 = Col("Owner", ["CRO", "CMO", "CPO", "VP Intl", "CTO"])
statusCol2 = Col("Status", ["On Track", "At Risk", "On Track", "Delayed", "On Track"])
progressCol = Col("Progress %", [65, 35, 45, 20, 80])
targetCol = Col("Target Date", ["Q3-24", "Q4-24", "Q1-25", "Q2-25", "Q3-24"])

boardSection = Card([boardHeader, boardItems], "card", "column", "m")
boardHeader = CardHeader("Next Board Meeting Items", "Agenda items prepared for upcoming board session")
boardItems = ListBlock(boardList, "number")
boardList = [board1, board2, board3, board4, board5, board6]
board1 = ListItem("Q2 financial results & Q3 forecast", "Revenue, costs, profit variance analysis", null, null)
board2 = ListItem("Enterprise GTM strategy approval", "Investment ask: $8.5M for H2 expansion", null, null)
board3 = ListItem("AI product roadmap & funding", "Technical milestones and market timing", null, null)
board4 = ListItem("Risk register review", "Top 5 risks with mitigation updates", null, null)
board5 = ListItem("Compensation & retention plan", "Equity refresh and salary bands", null, null)
board6 = ListItem("International entity setup", "Legal structure for EU/APAC expansion", null, null)