root = Card([header, quarterSelect, healthSummary, projectsHeading, projectsTable, milestonesHeading, milestonesList, budgetHeading, budgetChart, utilizationHeading, utilizationBar, risksHeading, risksList, deadlinesHeading, deadlinesList, paceHeading, paceChart, blockedHeading, blockedList, actionsHeading, actionsButtons, exportDialog, archiveDialog, requestDialog])

header = CardHeader("Portfolio Review — Q3 2024", "PMO · Updated 12 Sep 2024")

quarterSelect = Form("quarter", quarterButtons, [quarterField])
quarterField = FormControl("Quarter", quarterInput)
quarterInput = Select("quarter", [q2, q3, q4], "Select quarter", null, null, "small")
q2 = SelectItem("Q2 2024", "Q2 2024")
q3 = SelectItem("Q3 2024", "Q3 2024")
q4 = SelectItem("Q4 2024", "Q4 2024")
quarterButtons = Buttons([applyQuarterBtn])
applyQuarterBtn = Button("Apply")

healthSummary = Callout("success", "Portfolio health: On track", "13 of 15 projects are on schedule; 2 need attention. Budget burn is within tolerance and delivery pace is stable.")

projectsHeading = Heading("Active Projects", "h2")
projectsTable = Table([projName, projOwner, projDeadline, projHealth])
projName = Col("Project", ["Atlas Migration", "Helios Platform", "Nimbus CRM", "Orion Data Hub", "Pulse Mobile App"])
projOwner = Col("Owner", ["A. Chen", "M. Okafor", "S. Patel", "R. Gomez", "L. Novak"])
projDeadline = Col("Deadline", ["2024-10-15", "2024-11-01", "2024-09-28", "2024-12-10", "2024-10-30"])
projHealth = Col("Health", ["On track", "At risk", "On track", "On track", "At risk"])

milestonesHeading = Heading("Overdue Milestones", "h2")
milestonesList = ListBlock([ms1, ms2, ms3], "number")
ms1 = ListItem("Helios Platform — API v2 freeze", "Due 2024-09-05 · 7 days overdue", null, "Review")
ms2 = ListItem("Atlas Migration — Data cutover", "Due 2024-09-08 · 4 days overdue", null, "Review")
ms3 = ListItem("Pulse Mobile App — Beta sign-off", "Due 2024-09-10 · 2 days overdue", null, "Review")

budgetHeading = Heading("Budget Spent vs Allocation", "h2")
budgetChart = BarChart(["Atlas", "Helios", "Nimbus", "Orion", "Pulse"], [spentSeries, allocSeries], "grouped", "Project", "USD (k)")
spentSeries = Series("Spent", [420, 680, 310, 520, 260])
allocSeries = Series("Allocated", [500, 750, 350, 600, 300])

utilizationHeading = Heading("Team Utilization", "h2")
utilizationBar = SingleStackedBarChart(["Eng", "Design", "PMO", "QA"], [72, 85, 64, 78])

risksHeading = Heading("Risks", "h2")
risksList = ListBlock([risk1, risk2, risk3, risk4], "number")
risk1 = ListItem("High — Helios API dependency", "Vendor delay may push release by 2 weeks", null, "Mitigate")
risk2 = ListItem("Medium — Atlas data quality", "Legacy records need manual cleanup", null, "Mitigate")
risk3 = ListItem("Low — Nimbus scope creep", "Feature requests growing, monitor weekly", null, "Monitor")
risk4 = ListItem("Medium — Pulse team capacity", "Two engineers on leave in October", null, "Mitigate")

deadlinesHeading = Heading("Deadlines in Next Two Weeks", "h2")
deadlinesList = ListBlock([dl1, dl2, dl3], "number")
dl1 = ListItem("Nimbus CRM — GA release", "Due 2024-09-28 · Owner S. Patel", null, "View")
dl2 = ListItem("Atlas Migration — UAT complete", "Due 2024-09-30 · Owner A. Chen", null, "View")
dl3 = ListItem("Helios Platform — Security review", "Due 2024-10-02 · Owner M. Okafor", null, "View")

paceHeading = Heading("Delivery Pace — Last 6 Sprints", "h2")
paceChart = LineChart(["S1", "S2", "S3", "S4", "S5", "S6"], [plannedSeries, deliveredSeries], "linear", "Sprint", "Story points")
plannedSeries = Series("Planned", [320, 340, 310, 360, 330, 350])
deliveredSeries = Series("Delivered", [310, 330, 300, 350, 320, 340])

blockedHeading = Heading("Blocked Work Items", "h2")
blockedList = ListBlock([blk1, blk2, blk3], "number")
blk1 = ListItem("Helios — SSO integration", "Blocked on vendor credentials · 3 days", null, "Unblock")
blk2 = ListItem("Orion — ETL pipeline", "Awaiting data access approval · 5 days", null, "Unblock")
blk3 = ListItem("Pulse — Push notifications", "Certificates expired · 1 day", null, "Unblock")

actionsHeading = Heading("Actions", "h2")
actionsButtons = Buttons([exportBtn, archiveBtn, requestBtn])
exportBtn = Button("Export Review")
archiveBtn = Button("Archive Finished Project", null, "secondary")
requestBtn = Button("Request More People", null, "secondary")

exportDialog = DialogBlock("Export Options", "Export Portfolio Review", "Choose a format for the Q3 2024 review.", [exportFormat])
exportFormat = Form("export-format", exportButtons, [exportSelectField])
exportSelectField = FormControl("Format", exportSelect)
exportSelect = Select("format", [fmtPdf, fmtCsv, fmtPpt], "Select format")
fmtPdf = SelectItem("PDF", "PDF report")
fmtCsv = SelectItem("CSV", "CSV data")
fmtPpt = SelectItem("PPTX", "Slides deck")
exportButtons = Buttons([exportSubmitBtn])
exportSubmitBtn = Button("Export", null, "primary")

archiveDialog = DialogBlock("Archive Project", "Archive a finished project", "Select a project to move to the archive.", [archiveForm])
archiveForm = Form("archive-project", archiveButtons, [archiveSelectField])
archiveSelectField = FormControl("Project", archiveSelect)
archiveSelect = Select("project", [archAtlas, archHelios, archNimbus], "Select project")
archAtlas = SelectItem("Atlas Migration", "Atlas Migration")
archHelios = SelectItem("Helios Platform", "Helios Platform")
archNimbus = SelectItem("Nimbus CRM", "Nimbus CRM")
archiveButtons = Buttons([archiveConfirmBtn])
archiveConfirmBtn = Button("Archive", null, "primary")

requestDialog = DialogBlock("Request More People", "Request additional headcount", "Specify the project and staffing need.", [requestForm])
requestForm = Form("request-people", requestButtons, [requestProjectField, requestRoleField, requestCountField])
requestProjectField = FormControl("Project", requestProjectSelect)
requestProjectSelect = Select("project", [reqPulse, reqHelios, reqOrion], "Select project")
reqPulse = SelectItem("Pulse Mobile App", "Pulse Mobile App")
reqHelios = SelectItem("Helios Platform", "Helios Platform")
reqOrion = SelectItem("Orion Data Hub", "Orion Data Hub")
requestRoleField = FormControl("Role needed", requestRoleSelect)
requestRoleSelect = Select("role", [roleEng, roleQA, roleDesign], "Select role")
roleEng = SelectItem("Engineer", "Engineer")
roleQA = SelectItem("QA", "QA")
roleDesign = SelectItem("Designer", "Designer")
requestCountField = FormControl("Number of people", requestCountInput)
requestCountInput = Input("count", "e.g. 2", "number")
requestButtons = Buttons([requestSubmitBtn, requestCancelBtn])
requestSubmitBtn = Button("Submit request", null, "primary")
requestCancelBtn = Button("Cancel", null, "tertiary")