root = Card([header, metricsRow, weatherAdvisory, flightsSection, delayedCallout, gateChangesSection, connectionsAtRisk, crewsAvailable, rebookAction], "card", "column", "l")

header = Card([hubTitle, hubSelector], "clear", "row", "m", "center", "between")
hubTitle = Heading("Hub Operations Desk — ORD", "h2")
hubSelector = Select("hub_select", hubOptions, "Select hub", null, "ORD", "medium")
hubOptions = [optORD, optLAX, optJFK, optATL, optDFW]
optORD = SelectItem("ORD", "Chicago O'Hare (ORD)")
optLAX = SelectItem("LAX", "Los Angeles (LAX)")
optJFK = SelectItem("JFK", "New York JFK (JFK)")
optATL = SelectItem("ATL", "Atlanta (ATL)")
optDFW = SelectItem("DFW", "Dallas/Fort Worth (DFW)")

metricsRow = Card([onTimeMetric, cancellationsMetric, loadMetric, turnaroundMetric], "sunk", "row", "m", "stretch", "between")
onTimeMetric = Card([onTimeLabel, onTimeValue], "card", "column", "xs", "center")
onTimeLabel = TextContent("On-Time Performance", "small")
onTimeValue = TextContent("78%", "large-heavy")
cancellationsMetric = Card([cancellationsLabel, cancellationsValue], "card", "column", "xs", "center")
cancellationsLabel = TextContent("Cancellations Today", "small")
cancellationsValue = TextContent("12", "large-heavy")
loadMetric = Card([loadLabel, loadValue], "card", "column", "xs", "center")
loadLabel = TextContent("Avg Passenger Load", "small")
loadValue = TextContent("84%", "large-heavy")
turnaroundMetric = Card([turnaroundLabel, turnaroundValue], "card", "column", "xs", "center")
turnaroundLabel = TextContent("Avg Turnaround Time", "small")
turnaroundValue = TextContent("42 min", "large-heavy")

weatherAdvisory = Callout("warning", "Weather Advisory — ORD", "Thunderstorms expected 14:00–18:00 local. Wind gusts 25–35 kt. Expect ground stops and departure delays 30–60 min. De-icing operations active.")

flightsSection = Card([flightsHeader, flightsTable], "card", "column", "m")
flightsHeader = Heading("Active Flights", "h3")
flightsTable = Table([colNumber, colRoute, colGate, colStatus, colDeptTime, colArrTime])
colNumber = Col("Flight", ["UA 124", "UA 302", "UA 557", "UA 819", "UA 210", "UA 445", "UA 678", "UA 903", "UA 156", "UA 732"])
colRoute = Col("Route", ["ORD→LAX", "ORD→JFK", "ORD→DEN", "ORD→SFO", "ORD→ATL", "ORD→SEA", "ORD→MIA", "ORD→BOS", "ORD→LAS", "ORD→PHX"])
colGate = Col("Gate", ["B12", "C24", "B8", "E15", "C3", "F22", "B19", "C31", "E7", "F11"])
colStatus = Col("Status", ["On Time", "Delayed", "On Time", "Delayed", "On Time", "Cancelled", "On Time", "Delayed", "On Time", "On Time"])
colDeptTime = Col("Departure", ["08:15", "09:30", "10:45", "11:20", "12:05", "13:40", "14:10", "15:55", "16:30", "17:45"])
colArrTime = Col("Arrival", ["10:30", "12:45", "12:15", "13:50", "14:20", "16:55", "17:25", "19:10", "18:45", "20:00"])

delayedCallout = Callout("error", "Delayed Flights Requiring Attention", "UA 302 (ORD→JFK) — Gate C24 — Delayed 45 min (crew timing)\nUA 819 (ORD→SFO) — Gate E15 — Delayed 30 min (weather)\nUA 903 (ORD→BOS) — Gate C31 — Delayed 25 min (inbound late)\nUA 445 (ORD→SEA) — Gate F22 — Cancelled (mechanical)")

gateChangesSection = Card([gateChangesHeader, gateChangesList], "card", "column", "m")
gateChangesHeader = Heading("Recent Gate Changes", "h3")
gateChangesList = ListBlock([gc1, gc2, gc3, gc4, gc5], "number")
gc1 = ListItem("UA 302 → JFK", "Gate C24 → C28 (15 min ago)", null, "Notify pax")
gc2 = ListItem("UA 819 → SFO", "Gate E15 → E18 (22 min ago)", null, "Notify pax")
gc3 = ListItem("UA 557 → DEN", "Gate B8 → B14 (35 min ago)", null, "Completed")
gc4 = ListItem("UA 156 → LAS", "Gate E7 → E10 (41 min ago)", null, "Completed")
gc5 = ListItem("UA 732 → PHX", "Gate F11 → F14 (50 min ago)", null, "Completed")

connectionsAtRisk = Card([connectionsHeader, connectionsTable], "card", "column", "m")
connectionsHeader = Heading("Connections at Risk", "h3")
connectionsTable = Table([connFlight, connInbound, connConnecting, connTime, connRisk])
connFlight = Col("Inbound", ["UA 302", "UA 819", "UA 903", "UA 557"])
connInbound = Col("From", ["ORD→JFK", "ORD→SFO", "ORD→BOS", "ORD→DEN"])
connConnecting = Col("Connecting To", ["AA 145→LAX", "UA 221→HNL", "DL 308→TPA", "UA 412→SLC"])
connTime = Col("Connect Time", ["35 min", "28 min", "42 min", "31 min"])
connRisk = Col("Risk Level", ["High", "Critical", "Medium", "High"])

crewsAvailable = Card([crewsHeader, crewsList], "card", "column", "m")
crewsHeader = Heading("Crews Available for Reassignment", "h3")
crewsList = ListBlock([crew1, crew2, crew3, crew4], "number")
crew1 = ListItem("Capt. M. Rodriguez / FO J. Chen", "737 qualified — Duty 4:12 remaining — At Gate C24", null, "Assign")
crew2 = ListItem("Capt. K. Patel / FO R. Brooks", "777/787 qualified — Duty 6:45 remaining — Crew Room B", null, "Assign")
crew3 = ListItem("Capt. S. Kim / FO A. Torres", "A320 qualified — Duty 3:30 remaining — At Gate E18", null, "Assign")
crew4 = ListItem("Capt. D. Wilson / FO L. Nguyen", "737 qualified — Duty 5:20 remaining — Crew Room A", null, "Assign")

rebookAction = Card([rebookHeader, rebookButtons], "card", "column", "m")
rebookHeader = Heading("Passenger Rebooking Actions", "h3")
rebookButtons = Buttons([rebookBtn, massRebookBtn, viewPaxBtn], "row")
rebookBtn = Button("Rebook Selected Passengers", null, "primary")
massRebookBtn = Button("Auto-Rebook All Affected", null, "secondary")
viewPaxBtn = Button("View Affected Passenger List", null, "tertiary")