root = Card([zoneSelector, header, severitySummary, incidentsSection, resourcesSection, sheltersSection, routesSection, weatherSection, casualtiesSection, volunteersSection, donationsSection, aidRequestsSection, commsSection, roadsSection, hospitalsSection, tasksSection, requestResourcesForm, broadcastForm, sitrepForm], "card", "column", "l")

zoneSelector = Card([zoneLabel, zoneSelect], "clear", "row", "m", "center", "between")
zoneLabel = TextContent("**Focus Zone:**", "default")
zoneSelect = Select("focus_zone", zoneOptions, "All Zones", null, "medium")
zoneOptions = [optAll, optNorth, optSouth, optEast, optWest, optCentral]
optAll = SelectItem("all", "All Zones")
optNorth = SelectItem("north", "North Zone")
optSouth = SelectItem("south", "South Zone")
optEast = SelectItem("east", "East Zone")
optWest = SelectItem("west", "West Zone")
optCentral = SelectItem("central", "Central Zone")

header = CardHeader("Emergency Response Coordination Center", "Real-time situational awareness — Updated 2 min ago")

severitySummary = Card([severityTitle, severityChart, severityKpis], "sunk", "column", "m")
severityTitle = Heading("Overall Severity Summary", "h3")
severityChart = PieChart(severityLabels, severityValues, "donut", "circular")
severityLabels = ["Critical", "High", "Medium", "Low"]
severityValues = [3, 7, 12, 8]
severityKpis = Card([kpiCritical, kpiHigh, kpiMedium, kpiLow], "clear", "row", "m", "center", "around")
kpiCritical = Card([TextContent("**3**", "large-heavy"), TextContent("Critical", "small")], "card", "column", "xs", "center")
kpiHigh = Card([TextContent("**7**", "large-heavy"), TextContent("High", "small")], "card", "column", "xs", "center")
kpiMedium = Card([TextContent("**12**", "large-heavy"), TextContent("Medium", "small")], "card", "column", "xs", "center")
kpiLow = Card([TextContent("**8**", "large-heavy"), TextContent("Low", "small")], "card", "column", "xs", "center")

incidentsSection = Card([incidentsTitle, incidentsTable], "card", "column", "m")
incidentsTitle = Heading("Active Incidents by Zone", "h3")
incidentsTable = Table([incZone, incType, incSeverity, incStatus, incStarted])
incZone = Col("Zone", ["North", "North", "South", "East", "West", "Central", "Central", "East", "South", "West"])
incType = Col("Incident", ["Flood", "Landslide", "Fire", "Hazmat", "Building Collapse", "Flood", "Gas Leak", "Fire", "Flood", "Power Outage"])
incSeverity = Col("Severity", ["Critical", "High", "Critical", "High", "Critical", "Medium", "High", "Medium", "Low", "Low"])
incStatus = Col("Status", ["Active", "Active", "Active", "Contained", "Active", "Monitoring", "Active", "Contained", "Monitoring", "Resolved"])
incStarted = Col("Started", ["02:15", "03:40", "01:20", "04:10", "00:45", "05:30", "06:00", "05:45", "06:30", "04:00"])

resourcesSection = Card([resourcesTitle, resourcesTable], "card", "column", "m")
resourcesTitle = Heading("Vehicles, Personnel & Supplies Available", "h3")
resourcesTable = Table([resType, resAvailable, resInUse, resTotal])
resType = Col("Resource", ["Ambulances", "Fire Trucks", "Rescue Boats", "Helicopters", "Generators", "Water Tankers", "Medical Staff", "Firefighters", "Rescue Divers", "Engineers", "First Aid Kits", "Water (L)", "Food Rations", "Blankets", "Tents"])
resAvailable = Col("Available", [8, 12, 6, 3, 15, 10, 45, 60, 12, 8, 500, 15000, 8000, 1200, 200])
resInUse = Col("In Use", [12, 8, 4, 2, 10, 5, 30, 40, 8, 5, 300, 5000, 2000, 800, 150])
resTotal = Col("Total", [20, 20, 10, 5, 25, 15, 75, 100, 20, 13, 800, 20000, 10000, 2000, 350])

sheltersSection = Card([sheltersTitle, sheltersTable], "card", "column", "m")
sheltersTitle = Heading("Shelters — Capacity & Occupancy", "h3")
sheltersTable = Table([shName, shCapacity, shOccupancy, shAvailable, shStatus])
shName = Col("Shelter", ["North High School", "South Community Center", "East Arena", "West Church", "Central Stadium", "North Library", "South Gym", "East Convention Center"])
shCapacity = Col("Capacity", [300, 250, 500, 150, 1000, 200, 180, 400])
shOccupancy = Col("Occupancy", [285, 240, 420, 145, 850, 180, 160, 350])
shAvailable = Col("Available", [15, 10, 80, 5, 150, 20, 20, 50])
shStatus = Col("Status", ["Near Full", "Full", "Open", "Full", "Open", "Near Full", "Near Full", "Open"])

routesSection = Card([routesTitle, routesTable], "card", "column", "m")
routesTitle = Heading("Evacuation Route Status", "h3")
routesTable = Table([rtRoute, rtStatus, rtCapacity, rtLoad, rtEta])
rtRoute = Col("Route", ["North Hwy 101", "South I-5", "East Route 99", "West Coastal Rd", "Central Bridge", "North Alt 101", "South Alt I-5"])
rtStatus = Col("Status", ["Open", "Open", "Closed", "Restricted", "Open", "Open", "Closed"])
rtCapacity = Col("Capacity (veh/hr)", [1200, 1500, 800, 600, 2000, 900, 1100])
rtLoad = Col("Current Load", [850, 1100, 0, 200, 1400, 400, 0])
rtEta = Col("Est. Clear Time", ["—", "—", "4 hrs", "2 hrs", "—", "—", "6 hrs"])

weatherSection = Card([weatherTitle, weatherChart, weatherDetails], "card", "column", "m")
weatherTitle = Heading("Weather Forecast — Next 48 Hours", "h3")
weatherChart = LineChart(weatherHours, [tempSeries, precipSeries], "natural", "Hour", "Value")
weatherHours = ["Now", "+3h", "+6h", "+9h", "+12h", "+15h", "+18h", "+21h", "+24h", "+27h", "+30h", "+33h", "+36h", "+39h", "+42h", "+45h", "+48h"]
tempSeries = Series("Temp (°C)", [22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 12, 13, 14, 15, 16, 17])
precipSeries = Series("Precip (mm)", [0, 0, 2, 5, 8, 12, 15, 10, 5, 3, 1, 0, 0, 0, 0, 0, 0])
weatherDetails = Card([weatherWind, weatherAlert], "clear", "row", "m", "start", "between")
weatherWind = TextContent("**Wind:** SW 15-25 km/h, gusts to 40 km/h", "small")
weatherAlert = Callout("warning", "Heavy Rain Warning", "15-25 mm expected 12-18h from now. Flood risk rising in low-lying zones.")

casualtiesSection = Card([casualtiesTitle, casualtiesCards], "card", "column", "m")
casualtiesTitle = Heading("People Rescued & Casualties", "h3")
casualtiesCards = Card([rescuedCard, injuredCard, fatalCard, missingCard], "clear", "row", "m", "center", "around")
rescuedCard = Card([TextContent("**1,247**", "large-heavy"), TextContent("Rescued", "small"), TextContent("+89 last 6h", "small")], "card", "column", "xs", "center")
injuredCard = Card([TextContent("**312**", "large-heavy"), TextContent("Injured", "small"), TextContent("47 critical", "small")], "card", "column", "xs", "center")
fatalCard = Card([TextContent("**18**", "large-heavy"), TextContent("Fatalities", "small"), TextContent("+3 last 6h", "small")], "card", "column", "xs", "center")
missingCard = Card([TextContent("**42**", "large-heavy"), TextContent("Missing", "small"), TextContent("Active search", "small")], "card", "column", "xs", "center")

volunteersSection = Card([volunteersTitle, volunteersTable], "card", "column", "m")
volunteersTitle = Heading("Volunteers On Duty", "h3")
volunteersTable = Table([volName, volRole, volAssignment, volStatus])
volName = Col("Volunteer", ["M. Chen", "J. Rodriguez", "A. Patel", "K. Okafor", "S. Kim", "R. Silva", "L. Dubois", "T. Nguyen", "P. Kowalski", "E. Santos"])
volRole = Col("Role", ["Medical", "Logistics", "Search & Rescue", "Comms", "Shelter Ops", "Medical", "Logistics", "Search & Rescue", "Engineering", "Shelter Ops"])
volAssignment = Col("Assignment", ["North Shelter", "Central Depot", "East Zone", "Comms Hub", "West Shelter", "South Triage", "North Depot", "Central Collapse", "West Bridge", "East Shelter"])
volStatus = Col("Status", ["Active", "Active", "Active", "Active", "Active", "Break", "Active", "Active", "En Route", "Active"])

donationsSection = Card([donationsTitle, donationsTable], "card", "column", "m")
donationsTitle = Heading("Donations Received", "h3")
donationsTable = Table([donType, donAmount, donStatus, donReceived])
donType = Col("Type", ["Monetary", "Water", "Food", "Medical Supplies", "Clothing", "Blankets", "Fuel", "Generators", "Vehicles", "Volunteer Hours"])
donAmount = Col("Amount", ["$2.4M", "45,000 L", "12,000 meals", "800 kits", "5,000 pcs", "3,000", "20,000 L", "15 units", "8 trucks", "1,200 hrs"])
donStatus = Col("Status", ["Received", "Received", "Received", "In Transit", "Received", "Received", "Received", "Received", "Allocated", "Logged"])
donReceived = Col("Received", ["06:00", "05:30", "04:45", "07:15", "03:20", "02:10", "06:30", "05:00", "04:00", "Ongoing"])

aidRequestsSection = Card([aidTitle, aidTable], "card", "column", "m")
aidTitle = Heading("Aid Requests Awaiting Action", "h3")
aidTable = Table([aidRequest, aidLocation, aidPriority, aidStatus])
aidRequest = Col("Request", ["Medical evac", "Water delivery", "Shelter space", "Food resupply", "Generator", "Road clearance", "Comms restore", "Search team", "Debris removal", "Fuel delivery"])
aidLocation = Col("Location", ["North Zone", "South Zone", "East Zone", "West Zone", "Central Zone", "North Hwy", "Comms Hub", "Central Collapse", "West Bridge", "East Depot"])
aidPriority = Col("Priority", ["Critical", "High", "High", "Medium", "High", "Critical", "High", "Critical", "High", "Medium"])
aidStatus = Col("Status", ["Pending", "Pending", "Assigned", "Pending", "Pending", "Pending", "Assigned", "Pending", "Pending", "Pending"])

commsSection = Card([commsTitle, commsTable], "card", "column", "m")
commsTitle = Heading("Communication Channels", "h3")
commsTable = Table([comChannel, comStatus, comLastCheck, comNotes])
comChannel = Col("Channel", ["Primary Radio", "Backup Radio", "Satellite Phone", "Cell Network", "Internet/Fiber", "Mesh Network", "Emergency Alert", "Ham Radio", "Drone Relay", "Public Address"])
comStatus = Col("Status", ["Up", "Up", "Up", "Degraded", "Down", "Up", "Up", "Up", "Up", "Down"])
comLastCheck = Col("Last Check", ["06:58", "06:55", "06:50", "06:45", "06:40", "06:57", "06:59", "06:56", "06:54", "06:30"])
comNotes = Col("Notes", ["Clear", "Clear", "Clear", "Congested", "Outage", "Local only", "Active", "Clear", "Line of sight", "Power loss"])

roadsSection = Card([roadsTitle, roadsList], "card", "column", "m")
roadsTitle = Heading("Roads Closed", "h3")
roadsList = ListBlock(roadItems, "number")
roadItems = [road1, road2, road3, road4, road5, road6, road7]
road1 = ListItem("North Hwy 101 — Mile 12-18", "Flooding, impassable", null, "Detour via Route 9")
road2 = ListItem("South I-5 — Bridge 44", "Structural damage", null, "Closed indefinitely")
road3 = ListItem("East Route 99 — Segment 7", "Landslide debris", null, "Clearance in progress")
road4 = ListItem("West Coastal Rd — Cliff section", "Rockfall risk", null, "Geotech assessment")
road5 = ListItem("Central Bridge — Main span", "Inspection required", null, "Pedestrian only")
road6 = ListItem("North Alt 101 — Low water crossing", "Flash flood", null, "Monitoring")
road7 = ListItem("South Arterial — Downtown", "Building collapse debris", null, "Heavy equipment needed")

hospitalsSection = Card([hospitalsTitle, hospitalsTable], "card", "column", "m")
hospitalsTitle = Heading("Nearby Hospitals — Free Beds", "h3")
hospitalsTable = Table([hospName, hospFree, hospTotal, hospSpecialty, hospStatus])
hospName = Col("Hospital", ["North General", "South Memorial", "East Regional", "West Community", "Central Trauma", "North Children's", "South Veterans", "East Psychiatric"])
hospFree = Col("Free Beds", [12, 8, 25, 5, 30, 3, 15, 20])
hospTotal = Col("Total Beds", [120, 95, 180, 60, 250, 40, 100, 80])
hospSpecialty = Col("Specialty", ["Trauma/Burn", "Cardiac", "General/Trauma", "General", "Level 1 Trauma", "Pediatrics", "Rehab", "Psychiatric"])
hospStatus = Col("Status", ["Accepting", "Divert Critical", "Accepting", "Full", "Accepting", "Accepting", "Accepting", "Limited"])

tasksSection = Card([tasksTitle, tasksTable], "card", "column", "m")
tasksTitle = Heading("Open Tasks", "h3")
tasksTable = Table([taskDesc, taskAssignee, taskPriority, taskDue, taskStatus])
taskDesc = Col("Task", ["Establish North comms relay", "Clear East Route 99", "Evacuate South Zone Sector 4", "Deploy mobile hospital West", "Restore Central power grid", "Set up water purification East", "Coordinate air rescue North", "Distribute supplies Central", "Inspect West Bridge", "Brief incoming shift"])
taskAssignee = Col("Assignee", ["Comms Team Alpha", "Engineering Team 2", "Evac Group Bravo", "Medical Team Gamma", "Utility Crew 1", "Logistics Team 3", "Air Ops", "Supply Team Delta", "Structural Eng", "Ops Commander"])
taskPriority = Col("Priority", ["Critical", "Critical", "High", "High", "Critical", "High", "Critical", "Medium", "High", "Medium"])
taskDue = Col("Due", ["07:30", "08:00", "07:45", "09:00", "10:00", "08:30", "07:15", "12:00", "09:30", "08:00"])
taskStatus = Col("Status", ["In Progress", "In Progress", "Pending", "Assigned", "Planning", "En Route", "In Progress", "Assigned", "Pending", "Scheduled"])

requestResourcesForm = Card([reqTitle, reqForm], "card", "column", "m")
reqTitle = Heading("Request Additional Resources", "h3")
reqForm = Form("resource_request", reqButtons, [reqTypeField, reqQtyField, reqZoneField, reqJustifyField])
reqTypeField = FormControl("Resource Type", reqTypeSelect, "Select the resource category")
reqTypeSelect = Select("resource_type", reqTypeOptions, "Choose type", null, "medium")
reqTypeOptions = [reqOptVehicle, reqOptPersonnel, reqOptMedical, reqOptSupplies, reqOptEquipment, reqOptShelter, reqOptComms, reqOptFuel, reqOptFood, reqOptWater]
reqOptVehicle = SelectItem("vehicle", "Vehicles (ambulance, truck, boat, heli)")
reqOptPersonnel = SelectItem("personnel", "Personnel (medics, firefighters, engineers, divers)")
reqOptMedical = SelectItem("medical", "Medical Supplies (kits, meds, stretchers)")
reqOptSupplies = SelectItem("supplies", "General Supplies (food, water, blankets, tents)")
reqOptEquipment = SelectItem("equipment", "Heavy Equipment (generators, pumps, excavators)")
reqOptShelter = SelectItem("shelter", "Shelter Capacity (tents, cots, heating)")
reqOptComms = SelectItem("comms", "Communications (radios, satellites, mesh nodes)")
reqOptFuel = SelectItem("fuel", "Fuel (diesel, gasoline, aviation)")
reqOptFood = SelectItem("food", "Food Rations (MREs, bulk, special diets)")
reqOptWater = SelectItem("water", "Water (bottled, tankers, purification)")
reqQtyField = FormControl("Quantity", reqQtyInput, "Number of units needed")
reqQtyInput = Input("quantity", "1", "number")
reqZoneField = FormControl("Target Zone", reqZoneSelect, "Where resources should be deployed")
reqZoneSelect = Select("target_zone", reqZoneOptions, "Select zone", null, "medium")
reqZoneOptions = [reqZoneAll, reqZoneNorth, reqZoneSouth, reqZoneEast, reqZoneWest, reqZoneCentral]
reqZoneAll = SelectItem("all", "All Zones")
reqZoneNorth = SelectItem("north", "North Zone")
reqZoneSouth = SelectItem("south", "South Zone")
reqZoneEast = SelectItem("east", "East Zone")
reqZoneWest = SelectItem("west", "West Zone")
reqZoneCentral = SelectItem("central", "Central Zone")
reqJustifyField = FormControl("Justification", reqJustifyArea, "Operational reason for request")
reqJustifyArea = TextArea("justification", "Describe urgency and impact...", 3)
reqButtons = Buttons([reqSubmit, reqCancel], "row")
reqSubmit = Button("Submit Request", null, "primary")
reqCancel = Button("Cancel", null, "tertiary")

broadcastForm = Card([broadcastTitle, broadcastFormInner], "card", "column", "m")
broadcastTitle = Heading("Broadcast Emergency Update", "h3")
broadcastFormInner = Form("broadcast_update", broadcastButtons, [broadcastMsgField, broadcastChannelsField, broadcastUrgencyField])
broadcastMsgField = FormControl("Message", broadcastMsgArea, "Clear, concise update for all channels")
broadcastMsgArea = TextArea("message", "Enter update text...", 4)
broadcastChannelsField = FormControl("Channels", broadcastChannelsGroup, "Select distribution channels")
broadcastChannelsGroup = CheckBoxGroup("channels", broadcastChannelItems)
broadcastChannelItems = [chanRadio, chanSMS, chanApp, chanSirens, chanPA, chanSocial, chanTV, chanRadio, chanHam, chanDrone]
chanRadio = CheckBoxItem("Primary Radio", "Emergency services radio net", "ch_radio", true)
chanSMS = CheckBoxItem("SMS Alert", "Cell broadcast to public", "ch_sms", true)
chanApp = CheckBoxItem("Mobile App", "Push notification to app users", "ch_app", true)
chanSirens = CheckBoxItem("Sirens", "Outdoor warning sirens", "ch_sirens", false)
chanPA = CheckBoxItem("Public Address", "Vehicle-mounted PA systems", "ch_pa", false)
chanSocial = CheckBoxItem("Social Media", "Official accounts (X, FB, etc.)", "ch_social", true)
chanTV = CheckBoxItem("TV Crawl", "Emergency broadcast on TV", "ch_tv", false)
chanRadio = CheckBoxItem("Radio Broadcast", "Commercial radio interrupt", "ch_radio_bc", false)
chanHam = CheckBoxItem("Ham Relay", "Amateur radio networks", "ch_ham", true)
chanDrone = CheckBoxItem("Drone PA", "Drone-mounted speakers", "ch_drone", false)
broadcastUrgencyField = FormControl("Urgency Level", broadcastUrgencySelect, "Determines preemption behavior")
broadcastUrgencySelect = Select("urgency", broadcastUrgencyOptions, "Standard", null, "medium")
broadcastUrgencyOptions = [urgInfo, urgUrgent, urgEmergency, urgImmediate]
urgInfo = SelectItem("info", "Informational — No preemption")
urgUrgent = SelectItem("urgent", "Urgent — Preempt non-critical")
urgEmergency = SelectItem("emergency", "Emergency — Preempt all but life-safety")
urgImmediate = SelectItem("immediate", "Immediate — Maximum preemption (EAS)")
broadcastButtons = Buttons([broadcastSend, broadcastPreview, broadcastCancel], "row")
broadcastSend = Button("Send Now", null, "primary")
broadcastPreview = Button("Preview", null, "secondary")
broadcastCancel = Button("Cancel", null, "tertiary")

sitrepForm = Card([sitrepTitle, sitrepFormInner], "card", "column", "m")
sitrepTitle = Heading("File Situation Report (SITREP)", "h3")
sitrepFormInner = Form("situation_report", sitrepButtons, [sitrepPeriodField, sitrepZoneField, sitrepSummaryField, sitrepActionsField, sitrepNeedsField, sitrepNextField])
sitrepPeriodField = FormControl("Reporting Period", sitrepPeriodSelect, "Time window this report covers")
sitrepPeriodSelect = Select("period", sitrepPeriodOptions, "Last 6 hours", null, "medium")
sitrepPeriodOptions = [per1h, per3h, per6h, per12h, per24h, perCustom]
per1h = SelectItem("1h", "Last 1 hour")
per3h = SelectItem("3h", "Last 3 hours")
per6h = SelectItem("6h", "Last 6 hours")
per12h = SelectItem("12h", "Last 12 hours")
per24h = SelectItem("24h", "Last 24 hours")
perCustom = SelectItem("custom", "Custom range")
sitrepZoneField = FormControl("Zone Focus", sitrepZoneSelect, "Primary zone for this report")
sitrepZoneSelect = Select("sitrep_zone", sitrepZoneOptions, "All Zones", null, "medium")
sitrepZoneOptions = [sitrepAll, sitrepNorth, sitrepSouth, sitrepEast, sitrepWest, sitrepCentral]
sitrepAll = SelectItem("all", "All Zones")
sitrepNorth = SelectItem("north", "North Zone")
sitrepSouth = SelectItem("south", "South Zone")
sitrepEast = SelectItem("east", "East Zone")
sitrepWest = SelectItem("west", "West Zone")
sitrepCentral = SelectItem("central", "Central Zone")
sitrepSummaryField = FormControl("Executive Summary", sitrepSummaryArea, "2-3 sentences: situation, trend, critical concerns")
sitrepSummaryArea = TextArea("summary", "Summarize...", 3)
sitrepActionsField = FormControl("Actions Taken", sitrepActionsArea, "Key operations completed this period")
sitrepActionsArea = TextArea("actions", "List major actions...", 4)
sitrepNeedsField = FormControl("Critical Needs", sitrepNeedsArea, "Resources, decisions, or support required")
sitrepNeedsArea = TextArea("needs", "List critical needs...", 3)
sitrepNextField = FormControl("Next Period Priorities", sitrepNextArea, "Planned focus for next reporting period")
sitrepNextArea = TextArea("next_priorities", "Outline priorities...", 3)
sitrepButtons = Buttons([sitrepSubmit, sitrepSaveDraft, sitrepCancel], "row")
sitrepSubmit = Button("Submit SITREP", null, "primary")
sitrepSaveDraft = Button("Save Draft", null, "secondary")
sitrepCancel = Button("Cancel", null, "tertiary")