root = Card([header, kpis, alerts, oeeSection, productionSection, linesSection, qualitySection, downtimeSection, maintenanceSection, inventorySection, suppliersSection, shiftsSection, safetySection, holdSection, energySection, workOrdersSection, scheduleForm, focusSection, exportBtn, andonSection])
header = CardHeader("Factory Floor Console", "Live overview · Shift A · 14:32")
kpis = Card([kpiTitle, kpiTable], "sunk")
kpiTitle = Heading("Key metrics", "h3")
kpiTable = Table([kpiName, kpiValue])
kpiName = Col("Metric", ["OEE", "Units produced", "Target", "Energy use today"])
kpiValue = Col("Value", ["82.4%", "4,210", "5,000", "18.3 MWh"])
alerts = Callout("warning", "Andon alert on Line 3", "Press station 12 — operator requested assistance. See live andon below.")
oeeSection = Card([oeeHeading, oeeChart], "card")
oeeHeading = Heading("Overall equipment effectiveness", "h3")
oeeChart = RadialChart(["Availability", "Performance", "Quality"], [91, 90, 99])
productionSection = Card([prodHeading, prodChart], "card")
prodHeading = Heading("Units produced vs today's target", "h3")
prodChart = BarChart(["06:00", "08:00", "10:00", "12:00", "14:00"], [producedSeries, targetSeries], "grouped", "Hour", "Units")
producedSeries = Series("Produced", [420, 890, 1380, 2100, 4210])
targetSeries = Series("Target", [500, 1000, 1500, 2500, 5000])
linesSection = Card([linesHeading, linesTable], "card")
linesHeading = Heading("Production lines", "h3")
linesTable = Table([lineName, lineRate, lineStatus])
lineName = Col("Line", ["Line 1", "Line 2", "Line 3", "Line 4"])
lineRate = Col("Rate (units/hr)", [185, 172, 96, 210])
lineStatus = Col("Status", ["Running", "Running", "Andon", "Running"])
qualitySection = Card([qualityHeading, qualityChart], "card")
qualityHeading = Heading("Defect rate — past month", "h3")
qualityChart = LineChart(["Week 1", "Week 2", "Week 3", "Week 4"], [defectSeries], "linear", "Week", "Defect %")
defectSeries = Series("Defect rate", [1.8, 1.5, 1.2, 0.9])
downtimeSection = Card([downtimeHeading, downtimeChart], "card")
downtimeHeading = Heading("Downtime by cause", "h3")
downtimeChart = PieChart(["Changeover", "Breakdown", "Material shortage", "Maintenance", "Other"], [45, 30, 12, 8, 5], "donut")
maintenanceSection = Card([maintHeading, maintList], "card")
maintHeading = Heading("Machines due for maintenance", "h3")
maintList = ListBlock([maintItem1, maintItem2, maintItem3], "number")
maintItem1 = ListItem("Press P-12", "Due today · 200 hrs since last service")
maintItem2 = ListItem("Conveyor C-4", "Due in 2 days · belt wear detected")
maintItem3 = ListItem("Robot R-7", "Due in 5 days · scheduled lubrication")
inventorySection = Card([invHeading, invTable], "card")
invHeading = Heading("Stock levels", "h3")
invTable = Table([invMaterial, invQty, invStatus])
invMaterial = Col("Material", ["Steel coils", "Resin pellets", "Packaging boxes"])
invQty = Col("Stock (kg/units)", ["12,400 kg", "3,150 kg", "8,900 units"])
invStatus = Col("Status", ["OK", "Low — reorder", "OK"])
suppliersSection = Card([suppHeading, suppTable], "card")
suppHeading = Heading("Supplier deliveries due this week", "h3")
suppTable = Table([suppName, suppItem, suppDate])
suppName = Col("Supplier", ["MetalWorks", "PolyChem", "BoxCo"])
suppItem = Col("Item", ["Steel coils", "Resin pellets", "Packaging boxes"])
suppDate = Col("Due", ["Tue", "Wed", "Fri"])
shiftsSection = Card([shiftHeading, shiftChart], "card")
shiftHeading = Heading("Shift output comparison", "h3")
shiftChart = BarChart(["Shift A", "Shift B", "Shift C"], [shiftSeries], "grouped", "Shift", "Units")
shiftSeries = Series("Output", [4210, 3850, 2940])
safetySection = Card([safetyHeading, safetyTable], "card")
safetyHeading = Heading("Safety", "h3")
safetyTable = Table([safetyMetric, safetyValue])
safetyMetric = Col("Metric", ["Incidents this year", "Days since last incident"])
safetyValue = Col("Value", ["2", "47"])
holdSection = Card([holdHeading, holdTable], "card")
holdHeading = Heading("Batches on quality hold", "h3")
holdTable = Table([holdBatch, holdProduct, holdReason])
holdBatch = Col("Batch", ["B-2041", "B-2038"])
holdProduct = Col("Product", ["Valve housing", "Pipe fitting"])
holdReason = Col("Reason", ["Dimensional check", "Material traceability"])
energySection = Card([energyHeading, energyChart], "card")
energyHeading = Heading("Energy use today", "h3")
energyChart = AreaChart(["06:00", "08:00", "10:00", "12:00", "14:00"], [energySeries], "linear", "Hour", "MWh")
energySeries = Series("Energy", [2.1, 3.4, 4.2, 4.8, 3.8])
workOrdersSection = Card([woHeading, woTable], "card")
woHeading = Heading("Open work orders", "h3")
woTable = Table([woId, woPriority, woLine, woDue])
woId = Col("Order", ["WO-118", "WO-117", "WO-116", "WO-115"])
woPriority = Col("Priority", ["High", "High", "Medium", "Low"])
woLine = Col("Line", ["Line 2", "Line 1", "Line 4", "Line 3"])
woDue = Col("Due", ["Today", "Today", "Thu", "Fri"])
scheduleForm = Card([schedHeading, schedForm], "card")
schedHeading = Heading("Schedule maintenance", "h3")
schedForm = Form("schedule-maintenance", schedButtons, [machineField, dateField])
machineField = FormControl("Machine", machineSelect)
machineSelect = Select("machine", [machineOpt1, machineOpt2, machineOpt3], "Select machine")
machineOpt1 = SelectItem("press-p12", "Press P-12")
machineOpt2 = SelectItem("conveyor-c4", "Conveyor C-4")
machineOpt3 = SelectItem("robot-r7", "Robot R-7")
dateField = FormControl("Date", dateInput)
dateInput = DatePicker("maintenance_date", "single")
schedButtons = Buttons([schedSubmit])
schedSubmit = Button("Schedule", null, "primary")
focusSection = Card([focusHeading, focusForm], "card")
focusHeading = Heading("Focus on one line", "h3")
focusForm = Form("focus-line", focusButtons, [focusField])
focusField = FormControl("Line", focusSelect)
focusSelect = Select("line", [focusOpt1, focusOpt2, focusOpt3, focusOpt4], "Choose line")
focusOpt1 = SelectItem("line1", "Line 1")
focusOpt2 = SelectItem("line2", "Line 2")
focusOpt3 = SelectItem("line3", "Line 3")
focusOpt4 = SelectItem("line4", "Line 4")
focusButtons = Buttons([focusSubmit])
focusSubmit = Button("Focus line", null, "primary")
exportBtn = Buttons([exportReport])
exportReport = Button("Export shift report", null, "secondary")
andonSection = Card([andonHeading, andonList], "sunk")
andonHeading = Heading("Live andon alerts", "h3")
andonList = ListBlock([andon1, andon2], "image")
andon1 = ListItem("Line 3 · Press station 12", "Operator assistance requested · 2 min ago")
andon2 = ListItem("Line 2 · Packing station 4", "Material jam · resolved")
andonList = ListBlock([andon1, andon2], "image")