@media print {
    @page {
        size: landscape;
        margin: 15mm;
    }

    body {
        font-family: Arial, sans-serif;
        font-size: 9pt;
        line-height: 1.2;
    }

    .printable-report-wrapper {
        width: 100%;
    }

    /* Remove fixed height constraints for better pagination */
    .page-section {
        width: 100%;
        position: relative;
        display: block;
    }

    /* Page break controls */
    .page-break {
        page-break-before: always;
        break-before: page;
    }

    /* Ensure tables can span multiple pages */
    .print-table {
        page-break-inside: auto;
    }

    .print-table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }

    .print-table thead {
        display: table-header-group;
    }

    /* Repeat header on each page */
    .print-header {
        position: running(header);
    }

    @page {
        @top-center {
            content: element(header);
        }
    }

    /* Header styling */
    .header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #ccc;
        padding-bottom: 5mm;
        margin-bottom: 10mm;
    }

    .header img {
        height: 10mm;
    }

    .header-text {
        text-align: right;
        font-size: 8pt;
    }

    /* Typography */
    h2 {
        font-size: 14pt;
        margin-bottom: 8mm;
    }

    h3 {
        font-size: 12pt;
        margin-bottom: 4mm;
        margin-top: 2mm;
    }

    /* Table styling */
    .mud-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 5mm;
    }

    .mud-table th, .mud-table td {
        border: 1px solid #000 !important;
        padding: 2mm 3mm !important;
        font-size: 8pt !important;
    }

    .mud-table th {
        background-color: #f2f2f2 !important;
        font-weight: bold !important;
    }

    /* Ensure charts are properly sized */
    .chart-container, .apexcharts-canvas {
        max-height: 120mm;
        width: 100% !important;
        page-break-inside: avoid;
    }

    /* Two column layout */
    .two-column {
        display: flex;
        justify-content: space-between;
    }

    .two-column > div {
        width: 48%;
    }

    /* Hide non-print elements */
    .mud-toolbar, 
    .mud-drawer,
    .mud-appbar,
    .mud-main-content > :not(.printable-report-wrapper) {
        display: none !important;
    }

    /* Remove shadows and elevation in print */
    .mud-paper {
        box-shadow: none !important;
    }

    /* Ensure content visibility */
    .printable-report,
    .printable-report * {
        visibility: visible !important;
    }

    /* Page numbering (if supported by browser) */
    @bottom-right {
        content: "Page " counter(page) " of " counter(pages);
    }
}

/* Screen-only styles for print preview */
@media screen {
    .printable-report-wrapper {
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
    }

    .page-section {
        margin-bottom: 40px;
        border: 1px solid #ddd;
        padding: 20px;
        background: white;
    }

    .page-break {
        margin-top: 40px;
        border-top: 3px dashed #999;
        padding-top: 40px;
    }
}
