ter.operator;
  });
  
  // Restore focus after re-rendering
  restoreFocus();
}

// Save current focused element
function saveCurrentFocus() {
  const activeElement = document.activeElement;
  if (activeElement && activeElement.closest('.filter-badge')) {
    lastFocusedElementId = activeElement.id || 
                           activeElement.closest('[id]')?.id ||
                           activeElement.closest('[data-id]')?.dataset.id;
  }
}

// Restore focus to the previously focused element
function r