root = Card([header, alertsRow, quickActions, weatherSection, congestionSection, transitSection, airSection, energySection, waterSection, incidentsSection, emergencySection, parkingSection, eventsSection, reportsSection, backlogSection, roadworksSection, maintenanceSection, districtFocusSection, dispatchSection, alertSection])

header = CardHeader("City Operations Center", "Live overview · Updated just now")

alertsRow = Card([alertCallout], "sunk")
alertCallout = Callout("warning", "Heat advisory in effect", "Temperatures above 35°C in southern districts until 20:00. Public cooling centers open.")

quickActions = Buttons([focusBtn, dispatchBtn, alertBtn])
focusBtn = Button("Focus on a district", null, "secondary")
dispatchBtn = Button("Dispatch a crew", null, "secondary")
alertBtn = Button("Send public alert", null, "primary")

weatherSection = Card([weatherTitle, weatherKpis], "sunk")
weatherTitle = Heading("Current weather", "h3")
weatherKpis = Table([weatherMetric, weatherValue])
weatherMetric = Col("Metric", ["Temperature", "Humidity", "Wind", "Condition"])
weatherValue = Col("Value", ["34°C", "58%", "12 km/h", "Sunny, hazy"])

congestionSection = Card([congestionTitle, congestionChart, congestionKpis], "sunk")
congestionTitle = Heading("Congestion right now", "h3")
congestionChart = HorizontalBarChart(["Downtown", "Northgate", "Riverside", "Eastside", "Southport"], [congestionSeries], "grouped", "Avg speed (km/h)", "District")
congestionSeries = Series("Avg speed", [14, 22, 31, 28, 19])
congestionKpis = Table([congMetric, congValue])
congMetric = Col("Status", ["Downtown", "Overall"])
congValue = Col("Level", ["Severe", "Moderate"])

transitSection = Card([transitTitle, transitKpis], "sunk")
transitTitle = Heading("Transit punctuality", "h3")
transitKpis = Table([transitMetric, transitValue])
transitMetric = Col("Mode", ["Buses", "Metro", "Trams"])
transitValue = Col("On-time %", ["82%", "94%", "88%"])

airSection = Card([airTitle, airChart], "sunk")
airTitle = Heading("Air quality by district", "h3")
airChart = BarChart(["Downtown", "Northgate", "Riverside", "Eastside", "Southport"], [airSeries], "grouped", "District", "AQI")
airSeries = Series("AQI", [88, 62, 45, 71, 58])

energySection = Card([energyTitle, energyChart], "sunk")
energyTitle = Heading("Energy use — past week", "h3")
energyChart = AreaChart(["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], [energySeries], "natural", "Day", "MWh")
energySeries = Series("Consumption", [120, 132, 128, 145, 138, 96, 89])

waterSection = Card([waterTitle, waterKpis], "sunk")
waterTitle = Heading("Water use today", "h3")
waterKpis = Table([waterMetric, waterValue])
waterMetric = Col("Metric", ["Used", "Capacity", "Status"])
waterValue = Col("Value", ["42,300 m³", "55,000 m³", "Normal"])

incidentsSection = Card([incidentsTitle, incidentsTable], "sunk")
incidentsTitle = Heading("Open incidents", "h3")
incidentsTable = Table([incidentId, incidentType, incidentLocation, incidentSeverity])
incidentId = Col("ID", ["INC-1042", "INC-1043", "INC-1044", "INC-1045"])
incidentType = Col("Type", ["Water main break", "Traffic signal outage", "Fire — commercial", "Road flooding"])
incidentLocation = Col("Location", ["Riverside Ave", "Downtown / 5th St", "Southport Market", "Eastside underpass"])
incidentSeverity = Col("Severity", ["Critical", "High", "Critical", "High"])

emergencySection = Card([emergencyTitle, emergencyTable], "sunk")
emergencyTitle = Heading("Emergency vehicles deployed", "h3")
emergencyTable = Table([unitId, unitType, unitLocation, unitStatus])
unitId = Col("Unit", ["E-12", "A-7", "P-3", "E-9"])
unitType = Col("Type", ["Engine", "Ambulance", "Patrol", "Engine"])
unitLocation = Col("Location", ["Northgate", "Downtown", "Riverside", "Southport"])
unitStatus = Col("Status", ["On scene", "En route", "Patrolling", "On scene"])

parkingSection = Card([parkingTitle, parkingChart], "sunk")
parkingTitle = Heading("Parking availability — downtown", "h3")
parkingChart = SingleStackedBarChart(["Garage A", "Garage B", "Garage C"], [72, 45, 88])

eventsSection = Card([eventsTitle, eventsList], "sunk")
eventsTitle = Heading("Public events this weekend", "h3")
eventsList = ListBlock([event1, event2, event3])
event1 = ListItem("Riverside Food Festival", "Sat 10:00–18:00 · Riverside Park")
event2 = ListItem("Downtown Night Market", "Sat 17:00–22:00 · Market Square")
event3 = ListItem("City Marathon", "Sun 07:00–12:00 · Multiple districts")

reportsSection = Card([reportsTitle, reportsList], "sunk")
reportsTitle = Heading("Citizen reports — live", "h3")
reportsList = ListBlock([report1, report2, report3])
report1 = ListItem("Pothole on Main St", "Northgate · 2 min ago")
report2 = ListItem("Broken streetlight", "Eastside · 6 min ago")
report3 = ListItem("Illegal dumping", "Riverside · 11 min ago")

backlogSection = Card([backlogTitle, backlogKpis], "sunk")
backlogTitle = Heading("Service request backlog", "h3")
backlogKpis = Table([backlogMetric, backlogValue])
backlogMetric = Col("Category", ["Potholes", "Streetlights", "Trash", "Parks"])
backlogValue = Col("Open", ["214", "98", "56", "31"])

roadworksSection = Card([roadworksTitle, roadworksList], "sunk")
roadworksTitle = Heading("Roadworks planned this month", "h3")
roadworksList = ListBlock([roadwork1, roadwork2, roadwork3])
roadwork1 = ListItem("5th St resurfacing", "Downtown · Mar 18–22")
roadwork2 = ListItem("Northgate bridge repairs", "Northgate · Mar 20–27")
roadwork3 = ListItem("Eastside sewer upgrade", "Eastside · Mar 24–31")

maintenanceSection = Card([maintenanceTitle, maintenanceTable], "sunk")
maintenanceTitle = Heading("Infrastructure jobs due for maintenance", "h3")
maintenanceTable = Table([maintAsset, maintType, maintDue, maintPriority])
maintAsset = Col("Asset", ["Water pump #4", "Traffic signal #12", "Metro escalator", "Bridge deck"])
maintType = Col("Type", ["Pump", "Signal", "Escalator", "Bridge"])
maintDue = Col("Due", ["Mar 15", "Mar 19", "Mar 22", "Mar 28"])
maintPriority = Col("Priority", ["High", "Medium", "High", "Low"])

districtFocusSection = Card([districtTitle, districtForm], "sunk")
districtTitle = Heading("Focus on one district", "h3")
districtForm = Form("district-focus", districtButtons, [districtSelectField])
districtSelectField = FormControl("District", districtSelect)
districtSelect = Select("district", [districtDowntown, districtNorthgate, districtRiverside, districtEastside, districtSouthport], "Choose a district")
districtDowntown = SelectItem("downtown", "Downtown")
districtNorthgate = SelectItem("northgate", "Northgate")
districtRiverside = SelectItem("riverside", "Riverside")
districtEastside = SelectItem("eastside", "Eastside")
districtSouthport = SelectItem("southport", "Southport")
districtButtons = Buttons([districtSubmit])
districtSubmit = Button("Apply focus", null, "primary")

dispatchSection = Card([dispatchTitle, dispatchForm], "sunk")
dispatchTitle = Heading("Dispatch a crew", "h3")
dispatchForm = Form("dispatch-crew", dispatchButtons, [dispatchTypeField, dispatchLocationField])
dispatchTypeField = FormControl("Crew type", dispatchTypeSelect)
dispatchTypeSelect = Select("crew_type", [dispatchWater, dispatchRoad, dispatchPower, dispatchWaste], "Select crew type")
dispatchWater = SelectItem("water", "Water")
dispatchRoad = SelectItem("road", "Road")
dispatchPower = SelectItem("power", "Power")
dispatchWaste = SelectItem("waste", "Waste")
dispatchLocationField = FormControl("Location", dispatchLocationInput)
dispatchLocationInput = Input("location", "e.g. 5th & Main")
dispatchButtons = Buttons([dispatchSubmit])
dispatchSubmit = Button("Dispatch crew", null, "primary")

alertSection = Card([alertTitle, alertForm], "sunk")
alertTitle = Heading("Send public alert", "h3")
alertForm = Form("public-alert", alertButtons, [alertMessageField, alertChannelField])
alertMessageField = FormControl("Message", alertMessageInput)
alertMessageInput = Input("message", "Write the alert message...")
alertChannelField = FormControl("Channel", alertChannelSelect)
alertChannelSelect = Select("channel", [alertSms, alertApp, alertAll], "Select channel")
alertSms = SelectItem("sms", "SMS")
alertApp = SelectItem("app", "City app")
alertAll = SelectItem("all", "All channels")
alertButtons = Buttons([alertSend])
alertSend = Button("Send alert", null, "primary")