root = Card([header, quarterControls, metrics, trends, budgetSection, headcountSection, risks, initiatives, runway, pipeline, winRate, customers, nps, boardMeeting, exportActions])

header = CardHeader("Quarterly Command View", "Q3 2024 · All regions")

quarterControls = Card([quarterHeading, quarterButtons, regionSelect], "sunk", "row", "m", "center", "between")
quarterHeading = Heading("Reporting Period", "h3")
quarterButtons = Buttons([q1Btn, q2Btn, q3Btn])
q1Btn = Button("Q1 2024", null, "secondary")
q2Btn = Button("Q2 2024", null, "secondary")
q3Btn = Button("Q3 2024", null, "primary")
regionSelect = Select("region", [regionAll, regionNA, regionEU, regionAPAC], "All regions", null, "All regions")

regionAll = SelectItem("all", "All regions")
regionNA = SelectItem("na", "North America")
regionEU = SelectItem("eu", "Europe")
regionAPAC = SelectItem("apac", "Asia Pacific")

metrics = Card([metricsHeading, metricTable])
metricsHeading = Heading("Financial Snapshot", "h3")
metricTable = Table([metricName, metricValue])
metricName = Col("Metric", ["Revenue", "Costs", "Profit", "Runway", "Pipeline Value", "Win Rate", "Customers", "Churn", "NPS"])
metricValue = Col("Value", ["$48.2M", "$31.6M", "$16.6M", "14 months", "$82.4M", "38%", "12,480", "2.1%", "54"])

trends = Card([trendsHeading, revenueChart, costsChart])
trendsHeading = Heading("Quarterly Trends", "h3")
revenueChart = BarChart(["Q1", "Q2", "Q3", "Q4"], [revenueSeries], "grouped", "Quarter", "Revenue ($M)")
revenueSeries = Series("Revenue", [38.4, 41.2, 45.8, 48.2])
costsChart = LineChart(["Q1", "Q2", "Q3", "Q4"], [costsSeries], "linear", "Quarter", "Costs ($M)")
costsSeries = Series("Costs", [27.1, 28.9, 30.4, 31.6])

budgetSection = Card([budgetHeading, budgetChart])
budgetHeading = Heading("Budget vs Plan by Department", "h3")
budgetChart = HorizontalBarChart(["Engineering", "Sales", "Marketing", "Operations", "Support"], [budgetActual, budgetPlan], "grouped", "Budget ($M)", "Department")
budgetActual = Series("Actual", [12.4, 8.2, 6.1, 3.4, 1.5])
budgetPlan = Series("Plan", [11.8, 8.5, 6.4, 3.2, 1.6])

headcountSection = Card([headcountHeading, headcountChart])
headcountHeading = Heading("Headcount by Department", "h3")
headcountChart = BarChart(["Engineering", "Sales", "Marketing", "Operations", "Support"], [headcountSeries], "grouped", "Department", "Employees")
headcountSeries = Series("Headcount", [142, 96, 38, 24, 31])

risks = Card([risksHeading, riskTable])
risksHeading = Heading("Top Risks", "h3")
riskTable = Table([riskName, riskOwner, riskLevel])
riskName = Col("Risk", ["Key customer concentration", "Talent attrition in engineering", "Supply chain delay", "Regulatory change in EU"])
riskOwner = Col("Owner", ["Maria Chen", "David Okafor", "Priya Patel", "James Whitfield"])
riskLevel = Col("Level", ["High", "Medium", "High", "Medium"])

initiatives = Card([initHeading, initTable])
initHeading = Heading("Strategic Initiatives", "h3")
initTable = Table([initName, initStatus])
initName = Col("Initiative", ["Global expansion", "AI product launch", "Cost optimization", "Customer success revamp"])
initStatus = Col("Status", ["On track", "At risk", "On track", "Delayed"])

runway = Card([runwayHeading, runwayValue])
runwayHeading = Heading("Months of Runway", "h3")
runwayValue = Progress(14, "14 months of runway remaining")

pipeline = Card([pipelineHeading, pipelineValue])
pipelineHeading = Heading("Sales Pipeline Value", "h3")
pipelineValue = TextContent("**$82.4M** in active pipeline across 214 deals", "large-heavy")

winRate = Card([winRateHeading, winRateValue])
winRateHeading = Heading("Win Rate", "h3")
winRateValue = Progress(38, "38% win rate across all stages")

customers = Card([customersHeading, customerTable])
customersHeading = Heading("Customer Base", "h3")
customerTable = Table([customerName, customerValue])
customerName = Col("Metric", ["Active Customers", "Churn Rate", "Net New Customers"])
customerValue = Col("Value", ["12,480", "2.1%", "1,340"])

nps = Card([npsHeading, npsValue])
npsHeading = Heading("Net Promoter Score", "h3")
npsValue = TextContent("**54** — strong promoter base, up 6 points from last quarter", "large")

boardMeeting = Card([boardHeading, boardList])
boardHeading = Heading("Next Board Meeting Items", "h3")
boardList = ListBlock([boardItem1, boardItem2, boardItem3, boardItem4], "number")
boardItem1 = ListItem("Approve Q4 budget allocation", "Finance will present revised plan based on Q3 actuals")
boardItem2 = ListItem("Review AI product launch timeline", "Product team to share go-to-market strategy")
boardItem3 = ListItem("Discuss EU regulatory impact", "Legal to brief on compliance requirements")
boardItem4 = ListItem("Confirm executive compensation changes", "Compensation committee recommendation")

exportActions = Card([exportHeading, exportButtons], "sunk")
exportHeading = Heading("Export Pack", "h3")
exportButtons = Buttons([exportPDF, exportSlides, exportCSV])
exportPDF = Button("Export PDF pack", null, "primary")
exportSlides = Button("Export slides", null, "secondary")
exportCSV = Button("Export raw data (CSV)", null, "secondary")