root = Card([header, alertsSection, kpiRow, generationSection, forecastSection, plantSection, outageSection, maintenanceSection, controlsRow], "clear", "column", "l")
header = Card([networkTitle, livePill, statusTag], "sunk", "row", "m", "center", "between")
networkTitle = CardHeader("Aurora Power Network", "Operations console · live")
livePill = Badge("LIVE", "destructive")
statusTag = Tag("Grid stable", null, null, "success")
alertsSection = Card([alertsHeading, alert1, alert2, alert3], "sunk", "column", "m")
alertsHeading = CardHeader("Live alerts", "3 active · updated continuously")
alert1 = Alert("Demand risk at evening peak", "Forecast demand reaches 92% of capacity at 18:00", "warning")
alert2 = Alert("Storm warning — East coast", "Wind speeds above 70 km/h expected from 22:00", "info")
alert3 = Alert("Voltage dip near Redmoor", "Crews dispatched to Redmoor substation, East region", "destructive")
kpiRow = Card([loadKpi, capacityKpi, priceKpi, emissionsKpi], "clear", "row", "m", "stretch")
loadKpi = Card([loadLabel, loadValue, loadSub], "sunk", "column", "xs")
loadLabel = TextContent("Current load", "small")
loadValue = TextContent("18.4 GW", "large-heavy")
loadSub = TextContent("▲ 3.1% vs yesterday", "small")
capacityKpi = Card([capacityLabel, capacityValue, capacityBar], "sunk", "column", "xs")
capacityLabel = TextContent("Capacity used", "small")
capacityValue = TextContent("88%", "large-heavy")
capacityBar = Progress(88, "21.0 GW total capacity")
priceKpi = Card([priceLabel, priceValue, priceSub], "sunk", "column", "xs")
priceLabel = TextContent("Spot price", "small")
priceValue = TextContent("£48.20", "large-heavy")
priceSub = TextContent("per MWh · day-ahead", "small")
emissionsKpi = Card([emissionsLabel, emissionsValue, emissionsSub], "sunk", "column", "xs")
emissionsLabel = TextContent("Emissions today", "small")
emissionsValue = TextContent("1,248 t", "large-heavy")
emissionsSub = TextContent("CO₂e · 12% below target", "small")
generationSection = Card([genHeader, genPie, genTotal], "sunk", "column", "m")
genHeader = CardHeader("Generation by source", "Live output mix")
genPie = PieChart(["Wind", "Solar", "Gas", "Nuclear", "Hydro"], [42, 18, 24, 11, 5], "donut")
genTotal = TextContent("Total output: 18.4 GW · renewables share 65%", "small")
forecastSection = Card([forecastHeader, forecastChart], "sunk", "column", "m")
forecastHeader = CardHeader("Demand forecast", "Next 24 hours · peak 19.3 GW at 18:00")
forecastChart = AreaChart(demandLabels, [demandSeries], "natural", "Time", "GW")
demandLabels = ["00:00", "02:00", "04:00", "06:00", "08:00", "10:00", "12:00", "14:00", "16:00", "18:00", "20:00", "22:00"]
demandSeries = Series("Demand (GW)", [14.2, 13.1, 12.4, 12.8, 15.6, 17.1, 18.2, 18.9, 19.2, 19.3, 17.8, 16.4])
plantSection = Card([plantHeader, plantTable], "sunk", "column", "m")
plantHeader = CardHeader("Power plants", "Output and status by plant")
plantTable = Table([plantCol, sourceCol, regionCol, outputCol, statusCol])
plantCol = Col("Plant", ["Humber Wind Farm", "Solstice Solar Park", "Kestrel Gas CCGT", "Helios Nuclear", "Glenmoor Hydro", "Beacon Battery"])
sourceCol = Col("Source", ["Wind", "Solar", "Gas", "Nuclear", "Hydro", "Storage"])
regionCol = Col("Region", ["East", "South", "North", "West", "North", "Central"])
outputCol = Col("Output (MW)", [1240, 480, 1850, 2400, 320, 150], "number")
statusCol = Col("Status", ["Online", "Online", "Online", "Online", "Reduced", "Charging"])
outageSection = Card([outageHeader, outageTable], "sunk", "column", "m")
outageHeader = CardHeader("Outages", "Active and scheduled disruptions")
outageTable = Table([outageId, outageRegion, outageAffected, outageStatus])
outageId = Col("Incident", ["Redmoor substation fault", "South Bank cable fault", "Overhead line 401 planned works"])
outageRegion = Col("Affected region", ["East", "South", "West"])
outageAffected = Col("Customers affected", [12400, 3200, 0], "number")
outageStatus = Col("Status", ["Crew en route", "Ongoing", "Scheduled 14 Jun"])
maintenanceSection = Card([maintHeader, maintTable], "sunk", "column", "m")
maintHeader = CardHeader("Maintenance planned", "This month · June")
maintTable = Table([maintDate, maintAsset, maintRegion, maintDuration])
maintDate = Col("Date", ["12 Jun", "14 Jun", "19 Jun", "26 Jun"])
maintAsset = Col("Asset", ["Transformer T-3, Redmoor", "Overhead line 401", "Gas turbine G-2, Kestrel", "HV switchgear, Central substation"])
maintRegion = Col("Region", ["East", "West", "North", "Central"])
maintDuration = Col("Duration", ["6 h", "8 h", "24 h", "10 h"])
controlsRow = Card([regionFocusCard, curtailmentCard], "clear", "row", "m", "stretch")
regionFocusCard = Card([regionFocusHeader, regionForm], "sunk", "column", "m")
regionFocusHeader = CardHeader("Focus on a region", "Narrow all views to one region")
regionForm = Form("region-focus", regionButtons, [regionField])
regionField = FormControl("Region", regionSelect)
regionSelect = Select("region", [regionAll, regionNorth, regionSouth, regionEast, regionWest, regionCentral], "All regions")
regionAll = SelectItem("all", "All regions")
regionNorth = SelectItem("north", "North")
regionSouth = SelectItem("south", "South")
regionEast = SelectItem("east", "East")
regionWest = SelectItem("west", "West")
regionCentral = SelectItem("central", "Central")
regionButtons = Buttons([applyRegionBtn])
applyRegionBtn = Button("Apply region filter", null, "primary")
curtailmentCard = Card([curtailHeader, curtailBlock], "sunk", "column", "m")
curtailHeader = CardHeader("Curtailment", "Order a reduction in generation")
curtailBlock = DialogBlock("Order curtailment", "Order curtailment", "Choose a plant, the reduction amount, and the time window.", [curtailForm], "outline")
curtailForm = Form("curtailment-order", curtailButtons, [plantField, mwField, windowField])
plantField = FormControl("Plant", curtailPlant)
curtailPlant = Select("plant", [curtailKestrel, curtailHumber, curtailSolstice], "Select plant")
curtailKestrel = SelectItem("kestrel", "Kestrel Gas CCGT — North")
curtailHumber = SelectItem("humber", "Humber Wind Farm — East")
curtailSolstice = SelectItem("solstice", "Solstice Solar Park — South")
mwField = FormControl("Reduction amount", curtailMw, "In megawatts")
curtailMw = Input("reduction_mw", "e.g. 250", "number")
windowField = FormControl("Time window", curtailWindow)
curtailWindow = DatePicker("window", "range")
curtail