                    <span>${category}${percentage}</span>
                        <span class="amount">${amount}</span>
                    </div>
                `;
                item.addEventListener('click', () => toggleCategory(category));
                legendContainer.appendChild(item);
            });

            const activeTotalExpenses = monthExpenses
                .filter(exp => exp.amount < 0 && !disabledCategories.has(exp.category))
                .reduce((sum, exp) => sum + Math.abs(exp