function renderSidebar() {
  const sidebar = document.getElementById("sidebar");
  if (!sidebar) return;

  sidebar.innerHTML = "";

  SIDEBAR_ITEMS.forEach(item => {
    if (!item.permission || hasPermission(item.permission)) {
      const li = document.createElement("li");
      li.innerHTML = `<a href="${item.link}">${item.label}</a>`;
      sidebar.appendChild(li);
    }
  });
}

function requirePagePermission(permission) {
  if (!hasPermission(permission)) {
    alert("Access denied");
    window.location.href = "dashboard.html";
  }
}
