// Global JSON fetch helper — redirects to /login on 401 async function api(url, options = {}) { const res = await fetch(url, { headers: {'Content-Type': 'application/json'}, ...options, }); if (res.status === 401) { window.location.href = '/login?next=' + encodeURIComponent(window.location.pathname); return null; } return res; } document.addEventListener('DOMContentLoaded', () => { document.querySelectorAll('[data-bs-toggle="tooltip"]').forEach(el => new bootstrap.Tooltip(el) ); });