root = Card([header, kpiRow, alertsRow, lineSection, chartsRow, maintenanceSection, inventorySection, supplierSection, shiftsSection, safetySection, qualitySection, energySection, workOrdersSection, scheduleSection, focusSection, andonSection, exportSection])

header = CardHeader("Factory Floor Supervisor Console", "Live overview — Shift A · 14:32")

kpiRow = Card([oeeCard, unitsCard, energyCard], "sunk", "row", "m")
oeeCard = Card([oeeLabel, oeeValue, oeeProgress], "clear", "column", "xs")
oeeLabel = TextContent("Overall Equipment Effectiveness", "small")
oeeValue = TextContent("**87.4%**", "large-heavy")
oeeProgress = Progress(87.4, "Target 85%")
unitsCard = Card([unitsLabel, unitsValue, unitsProgress], "clear", "column", "xs")
unitsLabel = TextContent("Units Produced vs Today's Target", "small")
unitsValue = TextContent("**4,820 / 5,000**", "large-heavy")
unitsProgress = Progress(96.4, "96% of target")
energyCard = Card([energyLabel, energyValue, energyProgress], "clear", "column", "xs")
energyLabel = TextContent("Energy Use Today", "small")
energyValue = TextContent("**12.4 MWh**", "large-heavy")
energyProgress = Progress(62, "62% of daily budget")

alertsRow = Callout("warning", "Live Andon Alerts", "Line 2 — Press #7 jammed · Line 4 — operator call for material", "warning")

lineSection = Card([lineHeader, lineTable])
lineHeader = Heading("Production Lines", "h3")
lineTable = Table([lineNameCol, lineRateCol, lineStatusCol])
lineNameCol = Col("Line", ["Line 1", "Line 2", "Line 3", "Line 4"])
lineRateCol = Col("Rate (units/hr)", [220, 0, 185, 240])
lineStatusCol = Col("Status", ["Running", "Down — jam", "Running", "Running"])

chartsRow = Card([defectChart, downtimeChart], "sunk", "row", "m")
defectChart = Card([defectHeading, defectLine])
defectHeading = Heading("Defect Rate — Past Month", "h3")
defectLine = LineChart(["W1", "W2", "W3", "W4"], [defectSeries], "linear", "Week", "Defect %")
defectSeries = Series("Defect rate", [2.1, 1.8, 2.4, 1.6])
downtimeChart = Card([downtimeHeading, downtimePie])
downtimeHeading = Heading("Downtime by Cause", "h3")
downtimePie = PieChart(["Jams", "Changeover", "Material", "Maintenance", "Other"], [38, 27, 18, 12, 5], "donut")

maintenanceSection = Card([maintHeading, maintList])
maintHeading = Heading("Machines Due for Maintenance", "h3")
maintList = ListBlock([maintItem1, maintItem2, maintItem3])
maintItem1 = ListItem("Press #3", "Due today — 2,400 hrs run", null, "Schedule")
maintItem2 = ListItem("Conveyor #2", "Due in 2 days — belt wear", null, "Schedule")
maintItem3 = ListItem("Robot arm #1", "Due in 5 days — lubrication", null, "Schedule")

inventorySection = Card([invHeading, invTable])
invHeading = Heading("Stock Levels", "h3")
invTable = Table([invMatCol, invQtyCol, invStatusCol])
invMatCol = Col("Material", ["Steel coils", "Resin", "Packaging"])
invQtyCol = Col("On hand", ["42 t", "18 t", "12,400 units"])
invStatusCol = Col("Status", ["OK", "Low — reorder", "OK"])

supplierSection = Card([suppHeading, suppList])
suppHeading = Heading("Supplier Deliveries Due This Week", "h3")
suppList = ListBlock([supp1, supp2, supp3])
supp1 = ListItem("SteelCo — 20 t coils", "Due today 16:00", null, "Track")
supp2 = ListItem("ResinWorks — 10 t pellets", "Due Wed 09:00", null, "Track")
supp3 = ListItem("PackPlus — 5,000 boxes", "Due Fri 11:30", null, "Track")

shiftsSection = Card([shiftHeading, shiftChart])
shiftHeading = Heading("Shift Output Comparison", "h3")
shiftChart = BarChart(["Shift A", "Shift B", "Shift C"], [shiftSeries])
shiftSeries = Series("Units", [4820, 4510, 4630])

safetySection = Card([safetyHeading, safetyList])
safetyHeading = Heading("Safety", "h3")
safetyList = ListBlock([safetyIncident, safetyDays])
safetyIncident = ListItem("Incidents this year", "2 recordable incidents")
safetyDays = ListItem("Days since last incident", "143 days")

qualitySection = Card([qualityHeading, qualityList])
qualityHeading = Heading("Batches on Quality Hold", "h3")
qualityList = ListBlock([qBatch1, qBatch2])
qBatch1 = ListItem("Batch #B-2041", "Line 1 — viscosity out of spec", null, "Review")
qBatch2 = ListItem("Batch #B-2047", "Line 3 — color mismatch", null, "Review")

workOrdersSection = Card([woHeading, woTable])
woHeading = Heading("Open Work Orders", "h3")
woTable = Table([woIdCol, woLineCol, woPriorityCol])
woIdCol = Col("Order", ["WO-1182", "WO-1181", "WO-1179"])
woLineCol = Col("Line", ["Line 2", "Line 1", "Line 3"])
woPriorityCol = Col("Priority", ["Critical", "High", "Medium"])

scheduleSection = Card([scheduleHeading, scheduleForm])
scheduleHeading = Heading("Schedule Maintenance", "h3")
scheduleForm = Form("schedule-maint", scheduleButtons, [machineField, dateField])
machineField = FormControl("Machine", machineSelect)
machineSelect = Select("machine", [machineOpt1, machineOpt2, machineOpt3], "Select machine")
machineOpt1 = SelectItem("press3", "Press #3")
machineOpt2 = SelectItem("conv2", "Conveyor #2")
machineOpt3 = SelectItem("robot1", "Robot arm #1")
dateField = FormControl("Date", dateInput)
dateInput = DatePicker("maintenance_date", "single")
scheduleButtons = Buttons([scheduleSubmit])
scheduleSubmit = Button("Schedule maintenance", null, "primary")

focusSection = Card([focusHeading, focusButtons])
focusHeading = Heading("Focus on a Line", "h3")
focusButtons = Buttons([focusLine1, focusLine2, focusLine3, focusLine4])
focusLine1 = Button("Focus Line 1", null, "secondary")
focusLine2 = Button("Focus Line 2", null, "secondary")
focusLine3 = Button("Focus Line 3", null, "secondary")
focusLine4 = Button("Focus Line 4", null, "secondary")

andonSection = Card([andonHeading, andonList])
andonHeading = Heading("Live Andon Alerts", "h3")
andonList = ListBlock([andon1, andon2])
andon1 = ListItem("Line 2 — Press #7 jammed", "Opened 14:28 · 4 min ago", null, "Acknowledge")
andon2 = ListItem("Line 4 — material request", "Opened 14:30 · 2 min ago", null, "Acknowledge")

exportSection = Card([exportButtons])
exportButtons = Buttons([exportReport])
exportReport = Button("Export Shift Report", null, "primary")