// Hide loading, show error
            document.getElementById('allDevicesLoading').style.display = 'none';
            document.getElementById('allDevicesError').style.display = 'block';
        });
}

function sortAllDevices(field, order) {
    currentSort = { field, order };
    currentPage = 1;
    
    // Update sort dropdown text
    const sortLabels = {
        'total_revenue': order === 'desc' ? 'Revenue (High to Low)' : 'Revenue (Low to High)',
        'deviceID': 'Device ID (A-Z)',
        'produ