        legendContainer.insertAdjacentHTML('beforeend', totalsHtml);
        }

        function toggleCategory(category) {
            if (disabledCategories.has(category)) {
                disabledCategories.delete(category);
            } else {
                disabledCategories.add(category);
            }
            updateChartAndLegend();
        }

        async function initialize() {
            try {
                const configResponse = await fetch('/config');
                if (!configRespo