root = Card([header, oeeSection, productionTargetSection, linesSection, defectsSection, downtimeSection, maintenanceDueSection, stockSection, deliveriesSection, shiftsSection, safetySection, qualityHoldSection, energySection, workOrdersSection, maintenanceFormSection, lineFocusSection, andonSection, exportSection])
header = CardHeader("Factory Floor Supervisor Console", "Live view — updated every 30 seconds")
oeeSection = Card([oeeTitle, oeeGauges], "sunk", "row", "l")
oeeTitle = Heading("Overall Equipment Effectiveness", "h3")
oeeGauges = Card([availabilityGauge, performanceGauge, qualityGauge, oeeOverallGauge], "clear", "row", "m", "center")
availabilityGauge = RadialChart(["Available", "Unavailable"], [87, 13])
performanceGauge = RadialChart(["At Rate", "Below Rate"], [92, 8])
qualityGauge = RadialChart(["Good", "Defect"], [96, 4])
oeeOverallGauge = RadialChart(["OEE", "Loss"], [77, 23])
productionTargetSection = Card([prodTitle, prodProgress, prodDetail], "sunk")
prodTitle = Heading("Units Produced vs Today's Target", "h3")
prodProgress = Progress(84, "8,432 / 10,000 units")
prodDetail = TextContent("**Line A:** 3,210  |  **Line B:** 2,845  |  **Line C:** 2,377  |  **Pace:** +4% ahead of schedule")
linesSection = Card([linesTitle, linesTable], "sunk")
linesTitle = Heading("Production Lines — Rate & Status", "h3")
linesTable = Table([lineCol, rateCol, statusCol, targetCol, actualCol, oeeCol])
lineCol = Col("Line", ["Line A", "Line B", "Line C", "Line D"])
rateCol = Col("Rate (units/hr)", [420, 380, 310, 290], "number")
statusCol = Col("Status", ["Running", "Running", "Slow", "Setup"])
targetCol = Col("Target Today", [4200, 3800, 3100, 2900], "number")
actualCol = Col("Actual", [3580, 3120, 2450, 280], "number")
oeeCol = Col("OEE %", [82, 79, 71, 12], "number")
defectsSection = Card([defectsTitle, defectsChart], "sunk")
defectsTitle = Heading("Defect Rate — Past 30 Days", "h3")
defectsChart = LineChart(defectLabels, [defectSeries], "natural", "Day", "Defect %")
defectLabels = ["D1", "D2", "D3", "D4", "D5", "D6", "D7", "D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15", "D16", "D17", "D18", "D19", "D20", "D21", "D22", "D23", "D24", "D25", "D26", "D27", "D28", "D29", "D30"]
defectSeries = Series("Defect %", [2.1, 1.8, 2.3, 2.0, 1.9, 2.2, 2.5, 1.7, 2.0, 2.1, 1.8, 2.4, 2.2, 1.9, 2.0, 2.3, 2.1, 1.8, 2.2, 2.0, 1.9, 2.1, 2.4, 1.8, 2.0, 2.2, 1.9, 2.1, 2.3, 2.0])
downtimeSection = Card([downtimeTitle, downtimeChart], "sunk")
downtimeTitle = Heading("Downtime Split by Cause (This Week)", "h3")
downtimeChart = PieChart(downtimeLabels, downtimeValues, "donut")
downtimeLabels = ["Mechanical", "Electrical", "Tooling", "Material", "Changeover", "Planned Maint", "Other"]
downtimeValues = [4.2, 2.8, 1.5, 3.1, 2.4, 1.8, 0.9]
maintenanceDueSection = Card([maintTitle, maintTable], "sunk")
maintTitle = Heading("Machines Due for Maintenance", "h3")
maintTable = Table([mMachineCol, mTypeCol, mDueCol, mPriorityCol])
mMachineCol = Col("Machine", ["CNC-04", "Press-02", "Injection-07", "Packer-03", "Laser-01"])
mTypeCol = Col("Type", ["Preventive", "Corrective", "Preventive", "Preventive", "Calibration"])
mDueCol = Col("Due Date", ["2025-01-18", "2025-01-19", "2025-01-20", "2025-01-21", "2025-01-22"])
mPriorityCol = Col("Priority", ["High", "Critical", "Medium", "Medium", "Low"])
stockSection = Card([stockTitle, stockTable], "sunk")
stockTitle = Heading("Raw Material Stock", "h3")
stockTable = Table([matCol, onHandCol, minCol, maxCol, daysCol, statusCol2])
matCol = Col("Material", ["Steel Coil (tons)", "Resin (kg)", "Packaging (units)"])
onHandCol = Col("On Hand", [42.5, 18500, 240000], "number")
minCol = Col("Min", [15, 5000, 50000], "number")
maxCol = Col("Max", [60, 25000, 300000], "number")
daysCol = Col("Days Cover", [18, 22, 28], "number")
statusCol2 = Col("Status", ["OK", "OK", "OK"])
deliveriesSection = Card([delTitle, delTable], "sunk")
delTitle = Heading("Supplier Deliveries Due This Week", "h3")
delTable = Table([supCol, matCol2, qtyCol, dueCol, statusCol3])
supCol = Col("Supplier", ["Apex Steel", "PolyChem", "BoxCorp", "Fastener Inc", "LubeTech"])
matCol2 = Col("Material", ["Steel Coil 15t", "Resin 5000kg", "Cartons 50k", "Bolts 10k", "Lubricant 200L"])
qtyCol = Col("Qty", [15, 5000, 50000, 10000, 200], "number")
dueCol = Col("Due", ["Mon", "Tue", "Wed", "Thu", "Fri"])
statusCol3 = Col("Status", ["Confirmed", "Confirmed", "Pending", "Confirmed", "At Risk"])
shiftsSection = Card([shiftsTitle, shiftsChart], "sunk")
shiftsTitle = Heading("Shift Output Comparison (This Week)", "h3")
shiftsChart = BarChart(shiftLabels, [shift1Series, shift2Series, shift3Series], "grouped", "Day", "Units")
shiftLabels = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
shift1Series = Series("Shift 1 (06-14)", [3200, 3350, 3180, 3420, 3290, 2800, 0])
shift2Series = Series("Shift 2 (14-22)", [2950, 3100, 3020, 3180, 3050, 2600, 0])
shift3Series = Series("Shift 3 (22-06)", [1800, 1920, 1850, 1980, 1890, 1600, 0])
safetySection = Card([safetyTitle, safetyStats], "sunk", "row", "l", "center")
safetyTitle = Heading("Safety", "h3")
safetyStats = Card([incidentsCard, daysCard, ltirCard], "clear", "row", "l")
incidentsCard = Callout("info", "Incidents YTD", "3 recordable incidents")
daysCard = Callout("success", "Days Since Last Incident", "127 days")
ltirCard = Callout("neutral", "LTIR (Year)", "0.42")
qualityHoldSection = Card([qualityTitle, qualityTable], "sunk")
qualityTitle = Heading("Batches on Quality Hold", "h3")
qualityTable = Table([batchCol, lineCol2, reasonCol, qtyCol2, sinceCol, dispositionCol])
batchCol = Col("Batch", ["B-2025-0142", "B-2025-0155", "B-2025-0161"])
lineCol2 = Col("Line", ["Line B", "Line C", "Line A"])
reasonCol = Col("Reason", ["Dimensional", "Surface finish", "Weight variance"])
qtyCol2 = Col("Units", [450, 320, 280], "number")
sinceCol = Col("Held Since", ["2025-01-15", "2025-01-16", "2025-01-17"])
dispositionCol = Col("Disposition", ["Pending review", "Rework", "Scrap"])
energySection = Card([energyTitle, energyProgress, energyDetail], "sunk")
energyTitle = Heading("Energy Use Today", "h3")
energyProgress = Progress(67, "2,415 kWh / 3,600 kWh target")
energyDetail = TextContent("**Peak:** 08:00-12:00 (1,120 kWh)  |  **Cost:** $314  |  **vs Yesterday:** -3%")
workOrdersSection = Card([woTitle, woTable], "sunk")
woTitle = Heading("Open Work Orders", "h3")
woTable = Table([woIdCol, woMachineCol, woDescCol, woPriorityCol, woAssignedCol, woDueCol])
woIdCol = Col("WO #", ["WO-4821", "WO-4835", "WO-4840", "WO-4847", "WO-4852", "WO-4858"])
woMachineCol = Col("Machine", ["CNC-04", "Press-02", "Conveyor-07", "Injection-07", "Packer-03", "HVAC-02"])
woDescCol = Col("Description", ["Spindle bearing replace", "Hydraulic leak repair", "Belt alignment", "Nozzle clean/inspect", "Sealer jaw adjust", "Filter replacement"])
woPriorityCol = Col("Priority", ["Critical", "High", "Medium", "High", "Medium", "Low"])
woAssignedCol = Col("Assigned", ["M. Torres", "J. Kim", "R. Patel", "A. Singh", "L. Chen", "D. Brown"])
woDueCol = Col("Due", ["Today", "Today", "Tomorrow", "Tomorrow", "2025-01-20", "2025-01-22"])
maintenanceFormSection = Card([maintFormTitle, maintForm], "sunk")
maintFormTitle = Heading("Schedule Maintenance", "h3")
maintForm = Form("schedule-maint", maintButtons, [machineField, typeField, dateField, notesField])
machineField = FormControl("Machine", machineSelect, "Select equipment")
machineSelect = Select("machine", machineOptions, "Choose machine")
machineOptions = [optCnc04, optPress02, optInj07, optPacker03, optLaser01, optConv07, optHvac02]
optCnc04 = SelectItem("CNC-04", "CNC-04 (Machining)")
optPress02 = SelectItem("Press-02", "Press-02 (Stamping)")
optInj07 = SelectItem("Injection-07", "Injection-07 (Molding)")
optPacker03 = SelectItem("Packer-03", "Packer-03 (Packaging)")
optLaser01 = SelectItem("Laser-01", "Laser-01 (Cutting)")
optConv07 = SelectItem("Conveyor-07", "Conveyor-07 (Material Handling)")
optHvac02 = SelectItem("HVAC-02", "HVAC-02 (Facilities)")
typeField = FormControl("Maintenance Type", typeSelect)
typeSelect = Select("maint_type", typeOptions, "Select type")
typeOptions = [optPrev, optCorr, optCal, optInsp, optOther]
optPrev = SelectItem("preventive", "Preventive")
optCorr = SelectItem("corrective", "Corrective")
optCal = SelectItem("calibration", "Calibration")
optInsp = SelectItem("inspection", "Inspection")
optOther = SelectItem("other", "Other")
dateField = FormControl("Scheduled Date", datePicker)
datePicker = DatePicker("schedule_date", "single")
notesField = FormControl("Notes", notesArea, "Scope, parts needed, special instructions")
notesArea = TextArea("notes", "Enter details...", 3)
maintButtons = Buttons([scheduleBtn, cancelMaintBtn])
scheduleBtn = Button("Schedule", null, "primary")
cancelMaintBtn = Button("Cancel", null, "tertiary")
lineFocusSection = Card([focusTitle, focusTabs], "sunk")
focusTitle = Heading("Focus on Production Line", "h3")
focusTabs = Tabs([tabLineA, tabLineB, tabLineC, tabLineD])
tabLineA = TabItem("line-a", "Line A", [lineADetail])
tabLineB = TabItem("line-b", "Line B", [lineBDetail])
tabLineC = TabItem("line-c", "Line C", [lineCDetail])
tabLineD = TabItem("line-d", "Line D", [lineDDetail])
lineADetail = Card([lineAHeader, lineAMetrics, lineAStatus], "clear")
lineAHeader = CardHeader("Line A — Machining", "Primary production line")
lineAMetrics = Card([lineARate, lineAOee, lineAOutput, lineADowntime], "clear", "row", "m")
lineARate = Callout("info", "Current Rate", "420 units/hr")
lineAOee = Callout("success", "OEE", "82%")
lineAOutput = Callout("neutral", "Today's Output", "3,580 / 4,200")
lineADowntime = Callout("warning", "Downtime Today", "42 min")
lineAStatus = TextContent("**Status:** Running  |  **Active Job:** JOB-2025-0892  |  **Operator:** M. Torres  |  **Next Changeover:** 14:30")
lineBDetail = Card([lineBHeader, lineBMetrics, lineBStatus], "clear")
lineBHeader = CardHeader("Line B — Stamping", "High-volume stamping")
lineBMetrics = Card([lineBRate, lineBOee, lineBOutput, lineBDowntime], "clear", "row", "m")
lineBRate = Callout("info", "Current Rate", "380 units/hr")
lineBOee = Callout("success", "OEE", "79%")
lineBOutput = Callout("neutral", "Today's Output", "3,120 / 3,800")
lineBDowntime = Callout("warning", "Downtime Today", "58 min")
lineBStatus = TextContent("**Status:** Running  |  **Active Job:** JOB-2025-0895  |  **Operator:** J. Kim  |  **Next Changeover:** 15:00")
lineCDetail = Card([lineCHeader, lineCMetrics, lineCStatus], "clear")
lineCHeader = CardHeader("Line C — Injection Molding", "Multi-cavity molding")
lineCMetrics = Card([lineCRate, lineCOee, lineCOutput, lineCDowntime], "clear", "row", "m")
lineCRate = Callout("warning", "Current Rate", "310 units/hr (target 340)")
lineCOee = Callout("warning", "OEE", "71%")
lineCOutput = Callout("warning", "Today's Output", "2,450 / 3,100")
lineCDowntime = Callout("error", "Downtime Today", "2h 15m")
lineCStatus = TextContent("**Status:** **SLOW** — Cooling water pressure low  |  **Active Job:** JOB-2025-0898  |  **Operator:** R. Patel  |  **Maintenance dispatched**")
lineDDetail = Card([lineDHeader, lineDMetrics, lineDStatus], "clear")
lineDHeader = CardHeader("Line D — Packaging", "End-of-line packaging")
lineDMetrics = Card([lineDRate, lineDOee, lineDOutput, lineDDowntime], "clear", "row", "m")
lineDRate = Callout("error", "Current Rate", "0 units/hr")
lineDOee = Callout("error", "OEE", "12%")
lineDOutput = Callout("neutral", "Today's Output", "280 / 2,900")
lineDDowntime = Callout("error", "Downtime Today", "5h 40m")
lineDStatus = TextContent("**Status:** **SETUP** — Changeover to new SKU  |  **Active Job:** JOB-2025-0901  |  **Operator:** L. Chen  |  **ETA to run:** 11:00")
andonSection = Card([andonTitle, andonAlerts], "sunk")
andonTitle = Heading("Live Andon Alerts", "h3")
andonAlerts = Card([alert1, alert2, alert3, alert4], "clear", "column", "s")
alert1 = Alert("Line C — Cooling Pressure Low", "Cooling water pressure dropped below 2.5 bar. Maintenance en route.", "warning")
alert2 = Alert("Line D — Changeover Overdue", "Changeover started 06:15, estimated 08:00. Now 1h behind schedule.", "warning")
alert3 = Alert("Press-02 — Hydraulic Leak", "Minor leak detected on cylinder 3. WO-4835 created, priority HIGH.", "destructive")
alert4 = Alert("Raw Material — Resin Delivery At Risk", "PolyChem delivery scheduled Tue, tracking shows 4h delay. Buffer: 22 days.", "info")
exportSection = Card([exportTitle, exportButtons], "sunk", "row", "l", "center")
exportTitle = Heading("Export Shift Report", "h3")
exportButtons = Buttons([exportPdfBtn, exportCsvBtn, emailBtn])
exportPdfBtn = Button("Export PDF", null, "primary")
exportCsvBtn = Button("Export CSV", null, "secondary")
emailBtn = Button("Email Report", null, "tertiary")