@media print {
    /* Hide everything by default via visibility */
    body * {
        visibility: hidden;
    }

    /* Show ONLY the print-area content */
    #print-area, #print-area * {
        visibility: visible;
    }

    /* Bring print-area to the top-left for clean output */
    #print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 0.5in;
        background: #fff;
    }

    /* Make shopping list table print a bit smaller */
    #print-area table,
    #print-area th,
    #print-area td {
        font-size: 0.8rem;
        padding: 0.15rem 0.25rem;
    }

    /* Still hide elements explicitly marked as "do not print" */
    .d-print-none {
        display: none !important;
    }
}
