{
        lastFocusedElementId = element.id;
      }
    }
  });

  // Add filter badge
  addFilterBadge.addEventListener('click', () => {
    const newFilter = {
      id: Date.now(),
      column: 'rowid',
      operator: 'exact',
      value: ''
    };
    
    filters.push(newFilter);
    renderFilterBadges();
    
    // Auto-focus the column select of the new filter
    setTimeout(() => {
      const columnId = `filter-column-${newFilter.id}`;
      const columnElement = document.getElementById(column