@media print {
    body {
        margin: 0;
        padding: 0;
        font-size: 11px;
    }

    @page {
        size: A4 portrait;
        margin: 10mm 8mm;
    }

    .container {
        width: 100%;
        margin: 0 auto;
        padding: 0;
    }

    /* Main table alignment and print consistency */
    table {
        width: 100%;
        border-collapse: collapse;
        table-layout: fixed;
        font-size: 10.5px;
        margin: 0 auto;
    }

    th, td {
        border: 1px solid #000;
        padding: 6px 5px;
        text-align: left;
        vertical-align: middle;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* For top student info table — adjust width ratio */
    table:first-of-type th:nth-child(1),
    table:first-of-type th:nth-child(3) {
        width: 22%; /* Left-side labels */
    }

    table:first-of-type td:nth-child(2),
    table:first-of-type td:nth-child(4) {
        width: 28%; /* Right-side data columns get more width */
    }

    /* Make multi-column rows (like address or center) flexible */
    td[colspan="3"], td[colspan="4"], th[colspan="3"], th[colspan="4"] {
        white-space: normal;
        word-wrap: break-word;
    }

    /* Prevent row splits */
    tr, td, th {
        page-break-inside: avoid !important;
    }

    /* Hide buttons during print */
    .no-print {
        display: none;
    }
} 
