getElementById('deviceCount');
        if (deviceCount) {
            deviceCount.textContent = `${visibleCount} available device${visibleCount !== 1 ? 's' : ''}`;
        }
    }

    async function addSelectedDevicesToCase() {
        if (window.selectedDevicesForCase.length === 0 || !window.currentCaseID) {
            return;
        }
        
        const addBtn = document.getElementById('addSelectedDevicesBtn');
        const originalText = addBtn.innerHTML;
        
        // Show loading state
  