preview = preview.replace('{prefix}', prefix);
    preview = preview.replace('{year}', year);
    preview = preview.replace('{month}', month);
    preview = preview.replace('{sequence:4}', '0001');
    preview = preview.replace('{sequence:6}', '000001');
    
    document.getElementById('invoiceNumberPreview').textContent = preview;
}

// Update preview when prefix changes
document.getElementById('invoiceNumberPrefix').addEventListener('input', updateFormatPreview);

function submitInvoiceSettings() {
    c