     </div>
                `;
            });
    }

    function closeAddDeviceToCaseModal() {
        document.getElementById('addDeviceToCaseModal').style.display = 'none';
        // Clear selection state
        window.selectedDevicesForCase = [];
        window.availableDevicesForCase = [];
        window.currentCaseID = null;
    }

    // Multi-select device functions for case assignment
    function renderAvailableDevicesForCase() {
        const container = document.getElementById('devicesList');