async function shareReceipt() {
    // 1. Generate the image using html2canvas
    const element = document.querySelector(".receipt");
    const canvas = await html2canvas(element, {
        scale: 2,
        useCORS: true
    });

    const blob = await new Promise(resolve => canvas.toBlob(resolve, "image/png"));
    const file = new File([blob], "receipt.png", { type: "image/png" });

    // 2. Mobile – supports direct file share
    if (navigator.canShare && navigator.canShare({ files: [file] })) {
        try {
            await navigator.share({
                title: "Receipt",
                text: "Here is your receipt.",
                files: [file]
            });
            return; // SUCCESS
        } catch (err) {
            alert("Sharing cancelled.");
            return;
        }
    }

    // 3. Desktop (fallback)
    alert("WhatsApp Web cannot receive images automatically.\nOpen on a phone to share the image.");
}
