root = Card([screenHeader, liveAndon, kpisRow, productionSection, chartsRow, qualitySection, shiftsSection, workOrdersSection, inventorySection, suppliersSection, maintenanceSection, focusSection, exportBtn], "card", "column", "l")
screenHeader = CardHeader("Factory Floor Console", "Plant 2 · Morning shift · Updated 14:32")
liveAndon = Alert("Live andon: Line B", "Station 3 jam — operator assistance requested", "warning")
kpisRow = Card([oeeKpi, unitsKpi, safetyKpi, energyKpi], "sunk", "row", "m")
oeeKpi = Card([oeeTitle, oeeValue], "sunk")
oeeTitle = Heading("Overall equipment effectiveness", "h4")
oeeValue = TextContent("**82%** · availability 91% · performance 94% · quality 94%", "default")
unitsKpi = Card([unitsTitle, unitsProgress], "sunk")
unitsTitle = Heading("Units vs today's target", "h4")
unitsProgress = Progress(83, "1,240 / 1,500 units")
safetyKpi = Card([safetyTitle, safetyValue], "sunk")
safetyTitle = Heading("Safety", "h4")
safetyValue = TextContent("**2 incidents** this year · **87 days** since last", "default")
energyKpi = Card([energyTitle, energyValue], "sunk")
energyTitle = Heading("Energy use today", "h4")
energyValue = TextContent("**8.4 MWh** · 12% below target", "default")
productionSection = Card([linesHeading, linesTable], "sunk")
linesHeading = Heading("Production lines — rate and status", "h2")
linesTable = Table([lineNameCol, lineRateCol, lineStatusCol])
lineNameCol = Col("Line", ["Line A", "Line B", "Line C", "Line D"])
lineRateCol = Col("Rate (units/h)", [142, 0, 118, 96])
lineStatusCol = Col("Status", ["Running", "Down — jam", "Running", "Waiting material"])
chartsRow = Card([defectCard, downtimeCard], "sunk", "row", "l")
defectCard = Card([defectHeading, defectChart], "sunk")
defectHeading = Heading("Defect rate — past month", "h3")
defectChart = LineChart(["Wk1", "Wk2", "Wk3", "Wk4"], [defectSeries], "linear", "Week", "Defect %")
defectSeries = Series("Defect rate", [3.1, 2.6, 2.2, 1.8])
downtimeCard = Card([downtimeHeading, downtimeChart], "sunk")
downtimeHeading = Heading("Downtime by cause — today", "h3")
downtimeChart = PieChart(["Changeover", "Breakdown", "Material", "QC hold"], [46, 28, 18, 8], "donut")
qualitySection = Card([qualityHeading, qualityTable], "sunk")
qualityHeading = Heading("Batches on quality hold", "h2")
qualityTable = Table([batchIdCol, batchProductCol, batchQtyCol, batchReasonCol])
batchIdCol = Col("Batch", ["B-4821", "B-4823", "B-4826"])
batchProductCol = Col("Product", ["Bracket 220", "Shaft 110", "Housing 09"])
batchQtyCol = Col("Qty", ["120", "80", "45"])
batchReasonCol = Col("Reason", ["Dimension out of spec", "Surface defect", "Material cert missing"])
shiftsSection = Card([shiftsHeading, shiftsChart], "sunk")
shiftsHeading = Heading("Shift output comparison", "h2")
shiftsChart = BarChart(["Shift A", "Shift B", "Shift C"], [shiftSeries], "grouped", "Shift", "Units")
shiftSeries = Series("Units produced", [520, 468, 252])
workOrdersSection = Card([workOrdersHeading, workOrdersTable], "sunk")
workOrdersHeading = Heading("Open work orders", "h2")
workOrdersTable = Table([woIdCol, woLineCol, woPriorityCol, woStatusCol])
woIdCol = Col("Work order", ["WO-2214", "WO-2215", "WO-2216", "WO-2217"])
woLineCol = Col("Line", ["A", "C", "B", "A"])
woPriorityCol = Col("Priority", ["High", "High", "Medium", "Low"])
woStatusCol = Col("Status", ["In progress", "Queued", "Queued", "Scheduled"])
inventorySection = Card([inventoryHeading, inventoryTable], "sunk")
inventoryHeading = Heading("Stock", "h2")
inventoryTable = Table([materialCol, stockCol, reorderCol, stockStatusCol])
materialCol = Col("Material", ["Steel coil", "Resin", "Packaging"])
stockCol = Col("Current", ["120 t", "4,500 kg", "32 pallets"])
reorderCol = Col("Reorder level", ["80 t", "3,000 kg", "20 pallets"])
stockStatusCol = Col("Status", ["OK", "OK", "Low"])
suppliersSection = Card([suppliersHeading, suppliersTable], "sunk")
suppliersHeading = Heading("Supplier deliveries due this week", "h2")
suppliersTable = Table([supplierNameCol, supplierMaterialCol, supplierDateCol, supplierStatusCol])
supplierNameCol = Col("Supplier", ["Arcelor Mittal", "BASF", "PackCo"])
supplierMaterialCol = Col("Material", ["Steel coil", "Resin", "Packaging"])
supplierDateCol = Col("Due", ["Tue 10:00", "Wed 14:00", "Fri 08:00"])
supplierStatusCol = Col("Status", ["Confirmed", "In transit", "Pending"])
maintenanceSection = Card([maintenanceHeading, maintenanceTable, scheduleHeading, maintenanceForm], "sunk")
maintenanceHeading = Heading("Machines due for maintenance", "h2")
maintenanceTable = Table([machineCol, dueCol, lastCol])
machineCol = Col("Machine", ["Press 3", "Robot 2", "Conveyor 1", "Furnace 4"])
dueCol = Col("Due", ["Today 18:00", "Tomorrow", "Feb 28", "Mar 2"])
lastCol = Col("Last service", ["Jan 12", "Jan 28", "Dec 30", "Nov 15"])
scheduleHeading = Heading("Schedule maintenance", "h3")
maintenanceForm = Form("schedule-maintenance", scheduleButtons, [machineField, dateField])
machineField = FormControl("Machine", machineSelect)
machineSelect = Select("machine", [machinePress3, machineRobot2, machineConveyor1, machineFurnace4], "Select machine")
machinePress3 = SelectItem("press3", "Press 3")
machineRobot2 = SelectItem("robot2", "Robot 2")
machineConveyor1 = SelectItem("conveyor1", "Conveyor 1")
machineFurnace4 = SelectItem("furnace4", "Furnace 4")
dateField = FormControl("Date", maintenanceDate)
maintenanceDate = DatePicker("maintenance_date", "single")
scheduleButtons = Buttons([scheduleBtn])
scheduleBtn = Button("Schedule maintenance", null, "primary")
focusSection = Card([focusHeading, focusForm], "sunk")
focusHeading = Heading("Focus on line", "h2")
focusForm = Form("focus-line", focusButtons, [focusField])
focusField = FormControl("Line to focus", focusSelect)
focusSelect = Select("line_focus", [focusAll, focusA, focusB, focusC, focusD], "All lines")
focusAll = SelectItem("all", "All lines")
focusA = SelectItem("line-a", "Line A")
focusB = SelectItem("line-b", "Line B")
focusC = SelectItem("line-c", "Line C")
focusD = SelectItem("line-d", "Line D")
focusButtons = Buttons([focusBtn])
focusBtn = Button("Apply focus", null, "primary")
exportBtn = Button("Export shift report", null, "primary")