root = Card([header, zoneFocus, incidentsSection, severitySummary, resourcesSection, sheltersSection, routesSection, weatherSection, statsSection, volunteersSection, donationsSection, requestsSection, commsSection, roadsSection, hospitalsSection, tasksSection, requestForm, broadcastForm, sitrepForm, footer])

header = CardHeader("Emergency Response Coordination Center", "Live overview — updated 2 minutes ago")

zoneFocus = Form("zone-focus", focusButtons, [focusField])
focusField = FormControl("Focus on zone", focusSelect)
focusSelect = Select("zone", [zoneAll, zoneNorth, zoneSouth, zoneEast, zoneWest], "Select a zone", null, null, "medium")
zoneAll = SelectItem("all", "All zones")
zoneNorth = SelectItem("north", "North Zone")
zoneSouth = SelectItem("south", "South Zone")
zoneEast = SelectItem("east", "East Zone")
zoneWest = SelectItem("west", "West Zone")
focusButtons = Buttons([focusBtn])
focusBtn = Button("Apply focus", null, "primary")

incidentsSection = Card([incidentsHeading, incidentsTable], "sunk")
incidentsHeading = Heading("Active incidents by zone", "h2")
incidentsTable = Table([incidentZone, incidentType, incidentSeverity, incidentStatus])
incidentZone = Col("Zone", ["North", "North", "South", "South", "East", "West"])
incidentType = Col("Incident", ["Structure fire", "Flooding", "Gas leak", "Building collapse", "Power outage", "Wildfire"])
incidentSeverity = Col("Severity", ["Critical", "High", "Critical", "Moderate", "High", "Severe"])
incidentStatus = Col("Status", ["Responding", "Monitoring", "Responding", "Contained", "Monitoring", "Responding"])

severitySummary = Card([severityHeading, severityBars], "sunk")
severityHeading = Heading("Overall severity summary", "h3")
severityBars = SingleStackedBarChart(["Critical", "High", "Moderate", "Low"], [12, 28, 35, 25])

resourcesSection = Card([resourcesHeading, resourcesTable], "sunk")
resourcesHeading = Heading("Available resources", "h3")
resourcesTable = Table([resType, resAvailable, resDeployed, resTotal])
resType = Col("Resource", ["Vehicles", "Personnel", "Supplies (pallets)"])
resAvailable = Col("Available", [34, 128, 215])
resDeployed = Col("Deployed", [41, 96, 180])
resTotal = Col("Total", [75, 224, 395])

sheltersSection = Card([sheltersHeading, sheltersTable], "sunk")
sheltersHeading = Heading("Shelters — capacity and occupancy", "h3")
sheltersTable = Table([shelterName, shelterCapacity, shelterOccupancy, shelterStatus])
shelterName = Col("Shelter", ["Riverside High School", "Central Gym", "St. Mary's Hall", "Fairgrounds Pavilion"])
shelterCapacity = Col("Capacity", [500, 300, 200, 800])
shelterOccupancy = Col("Occupancy", [412, 287, 96, 654])
shelterStatus = Col("Status", ["Open", "Near full", "Open", "Open"])

routesSection = Card([routesHeading, routesTable], "sunk")
routesHeading = Heading("Evacuation routes", "h3")
routesTable = Table([routeName, routeStatus, routeCondition])
routeName = Col("Route", ["Route 1 — Coastal Hwy", "Route 2 — Mountain Rd", "Route 3 — Valley Blvd", "Route 4 — River Crossing"])
routeStatus = Col("Status", ["Open", "Congested", "Closed", "Open"])
routeCondition = Col("Condition", ["Clear", "Slow traffic", "Flooded", "Clear"])

weatherSection = Card([weatherHeading, weatherChart], "sunk")
weatherHeading = Heading("Weather forecast — next 48 hours", "h3")
weatherChart = LineChart(["0h", "6h", "12h", "18h", "24h", "30h", "36h", "42h", "48h"], [tempSeries, rainSeries], "natural", "Time", "Temp (°C) / Rain (mm)")
tempSeries = Series("Temperature", [22, 21, 20, 19, 18, 17, 16, 16, 15])
rainSeries = Series("Rainfall", [0, 2, 5, 8, 12, 10, 6, 3, 1])

statsSection = Card([statsHeading, statsTable], "sunk")
statsHeading = Heading("Rescue progress", "h3")
statsTable = Table([statMetric, statCount])
statMetric = Col("Metric", ["People rescued", "Casualties", "Missing persons"])
statCount = Col("Count", [1472, 38, 12])

volunteersSection = Card([volunteersHeading, volunteersTable], "sunk")
volunteersHeading = Heading("Volunteers on duty", "h3")
volunteersTable = Table([volName, volAssignment, volZone])
volName = Col("Volunteer", ["Maria Lopez", "James Chen", "Aisha Khan", "David Osei", "Elena Rossi"])
volAssignment = Col("Assignment", ["Shelter triage", "Supply distribution", "First aid", "Route clearing", "Communications"])
volZone = Col("Zone", ["North", "South", "East", "West", "North"])

donationsSection = Card([donationsHeading, donationsTable], "sunk")
donationsHeading = Heading("Donations received", "h3")
donationsTable = Table([donType, donAmount, donValue])
donType = Col("Type", ["Water (liters)", "Food (meals)", "Clothing (kg)", "Cash (USD)"])
donAmount = Col("Amount", [12000, 8500, 3200, 45000])
donValue = Col("Estimated value", ["$6,000", "$42,500", "$8,000", "$45,000"])

requestsSection = Card([requestsHeading, requestsTable], "sunk")
requestsHeading = Heading("Aid requests awaiting action", "h3")
requestsTable = Table([reqId, reqZone, reqItem, reqUrgency])
reqId = Col("Request ID", ["R-1041", "R-1042", "R-1043", "R-1044"])
reqZone = Col("Zone", ["North", "East", "South", "West"])
reqItem = Col("Item", ["Tents", "Medical supplies", "Generators", "Drinking water"])
reqUrgency = Col("Urgency", ["High", "Critical", "Medium", "High"])

commsSection = Card([commsHeading, commsTable], "sunk")
commsHeading = Heading("Communication channels", "h3")
commsTable = Table([commChannel, commStatus])
commChannel = Col("Channel", ["Radio — Dispatch", "Satellite phone", "Internet uplink", "Cell network", "Amateur radio"])
commStatus = Col("Status", ["Up", "Up", "Down", "Partial", "Up"])

roadsSection = Card([roadsHeading, roadsTable], "sunk")
roadsHeading = Heading("Roads closed", "h3")
roadsTable = Table([roadName, roadReason, roadEstimate])
roadName = Col("Road", ["Mountain Rd", "River Crossing", "Old Mill Rd", "Harbor Way"])
roadReason = Col("Reason", ["Flooding", "Bridge damage", "Landslide", "Debris"])
roadEstimate = Col("Reopen ETA", ["24h", "48h", "12h", "6h"])

hospitalsSection = Card([hospitalsHeading, hospitalsTable], "sunk")
hospitalsHeading = Heading("Nearby hospitals — free beds", "h3")
hospitalsTable = Table([hospName, hospFreeBeds, hospTotalBeds, hospDistance])
hospName = Col("Hospital", ["St. Mary's General", "Northside Medical", "Valley Community", "Harbor Health"])
hospFreeBeds = Col("Free beds", [42, 18, 63, 27])
hospTotalBeds = Col("Total beds", [200, 150, 180, 120])
hospDistance = Col("Distance", ["3 km", "8 km", "12 km", "5 km"])

tasksSection = Card([tasksHeading, tasksTable], "sunk")
tasksHeading = Heading("Open tasks", "h3")
tasksTable = Table([taskName, taskAssignee, taskDue])
taskName = Col("Task", ["Restore power substation", "Deliver water to East zone", "Set up field hospital", "Repair comms tower", "Clear Route 3"])
taskAssignee = Col("Assignee", ["Crew 4 — J. Rivera", "Logistics — S. Patel", "Medical — Dr. Wu", "Tech — L. Novak", "Crew 2 — M. Berg"])
taskDue = Col("Due", ["2h", "4h", "6h", "3h", "5h"])

requestForm = Card([requestHeading, requestFormInner])
requestHeading = Heading("Request more resources", "h3")
requestFormInner = Form("resource-request", requestButtons, [reqTypeField, reqQtyField, reqZoneField])
reqTypeField = FormControl("Resource type", reqTypeSelect)
reqTypeSelect = Select("resource_type", [reqWater, reqFood, reqMedical, reqFuel, reqTents], "Select type")
reqWater = SelectItem("water", "Drinking water")
reqFood = SelectItem("food", "Food rations")
reqMedical = SelectItem("medical", "Medical supplies")
reqFuel = SelectItem("fuel", "Fuel")
reqTents = SelectItem("tents", "Tents")
reqQtyField = FormControl("Quantity", reqQtyInput)
reqQtyInput = Input("quantity", "e.g. 500", "number")
reqZoneField = FormControl("Destination zone", reqZoneSelect)
reqZoneSelect = Select("dest_zone", [reqZoneN, reqZoneS, reqZoneE, reqZoneW], "Select zone")
reqZoneN = SelectItem("north", "North")
reqZoneS = SelectItem("south", "South")
reqZoneE = SelectItem("east", "East")
reqZoneW = SelectItem("west", "West")
requestButtons = Buttons([submitRequestBtn])
submitRequestBtn = Button("Submit request", null, "primary")

broadcastForm = Card([broadcastHeading, broadcastFormInner])
broadcastHeading = Heading("Broadcast update", "h3")
broadcastFormInner = Form("broadcast", broadcastButtons, [broadcastMsgField, broadcastChannelField])
broadcastMsgField = FormControl("Message", broadcastMsgInput, "This will be sent to all public channels")
broadcastMsgInput = TextArea("message", "Write the update message...", 4)
broadcastChannelField = FormControl("Channel", broadcastChannelSelect)
broadcastChannelSelect = Select("channel", [bcRadio, bcSocial, bcSms, bcAll], "Select channel")
bcRadio = SelectItem("radio", "Radio")
bcSocial = SelectItem("social", "Social media")
bcSms = SelectItem("sms", "SMS")
bcAll = SelectItem("all", "All channels")
broadcastButtons = Buttons([broadcastBtn])
broadcastBtn = Button("Broadcast now", null, "primary")

sitrepForm = Card([sitrepHeading, sitrepFormInner])
sitrepHeading = Heading("File situation report", "h3")
sitrepFormInner = Form("sitrep", sitrepButtons, [sitrepZoneField, sitrepSummaryField, sitrepUrgencyField])
sitrepZoneField = FormControl("Zone", sitrepZoneSelect)
sitrepZoneSelect = Select("sitrep_zone", [srNorth, srSouth, srEast, srWest], "Select zone")
srNorth = SelectItem("north", "North")
srSouth = SelectItem("south", "South")
srEast = SelectItem("east", "East")
srWest = SelectItem("west", "West")
sitrepSummaryField = FormControl("Summary", sitrepSummaryInput)
sitrepSummaryInput = TextArea("summary", "Describe the situation...", 4)
sitrepUrgencyField = FormControl("Urgency", sitrepUrgencySelect)
sitrepUrgencySelect = Select("urgency", [urLow, urMed, urHigh, urCrit], "Select urgency")
urLow = SelectItem("low", "Low")
urMed = SelectItem("medium", "Medium")
urHigh = SelectItem("high", "High")
urCrit = SelectItem("critical", "Critical")
sitrepButtons = Buttons([sitrepBtn])
sitrepBtn = Button("File report", null, "primary")

footer = FollowUpBlock([fu1, fu2, fu3])
fu1 = FollowUpItem("Show incident details for North zone")
fu2 = FollowUpItem("List shelters that are near full")
fu3 = FollowUpItem("Summarize the last broadcast")