/* Long bond paper: one geometry for preview and print. Scoped to Service Record. */
@page service-record-page {
    size: 8.5in 13in;
    margin: .5in .3in .5in;
}

.print-document.service-record-print-document {
    box-sizing: border-box;
    width: 8.5in;
    max-width: none;
    min-height: 13in;
    padding: .5in .3in .5in;
    font-size: 10pt !important;
    line-height: 1.25;
    page: service-record-page;
}

.service-record-print-document .service-record-header {
    display: block !important;
    position: relative !important;
    width: 100%;
    align-items: start !important;
    min-height: .9in !important;
    margin: 0 0 .18in !important;
    break-inside: avoid;
}

.service-record-print-document .service-record-header img {
    /* Anchor the seal to the centered text, independent of paper side margins. */
    position: absolute !important;
    left: calc(50% - 2.05in) !important;
    top: -4px !important;
    width: .8in !important;
    height: .8in !important;
    margin: 0 !important;
    justify-self: start !important;
}

.service-record-print-document .service-record-header .si-letterhead-text {
    width: 100% !important;
    text-align: center !important;
    margin: 0 !important;
}

.service-record-print-document .service-record-header .si-letterhead-text p,
.service-record-print-document .service-record-header .si-letterhead-text h3 {
    font-size: 11pt !important;
    line-height: 1.2 !important;
}

.service-record-print-document .service-record-header .si-letterhead-text h4 {
    margin: .18in 0 0 !important;
    font-size: 12pt !important;
    white-space: normal !important;
}

.service-record-print-document .service-form-no {
    margin: 0 0 .06in;
    font-size: 9pt !important;
}

.service-record-print-document h2 {
    margin: 0 0 .18in;
    font-size: 15pt !important;
    letter-spacing: .06em;
}

.service-record-print-document .service-employee-table {
    break-inside: avoid;
    margin-bottom: .1in;
}

.service-record-print-document .service-field-label,
.service-record-print-document .service-field-line {
    font-size: 11pt !important;
    line-height: 1.2;
    min-height: 1.2em;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
}

.service-record-print-document .service-employee-table small {
    font-size: 8pt !important;
    margin-top: 3px;
}

.service-record-print-document .service-cert-text,
.service-record-print-document .service-issued-text {
    font-size: 9pt !important;
    line-height: 1.35;
    margin: .1in 0;
    text-indent: .3in;
    orphans: 3;
    widows: 3;
}

.service-record-print-document .service-cert-text { break-after: avoid; }

.service-record-print-document .service-record-table {
    width: 100% !important;
    table-layout: auto !important;
    font-size: 8pt !important;
    border: .6pt solid #000;
}

.service-record-print-document .service-record-table col.service-date-col { width: 1% !important; }
.service-record-print-document .service-record-table col.service-designation-col { width: auto !important; max-width: none !important; }
.service-record-print-document .service-record-table col.service-status-col { width: 1% !important; }
.service-record-print-document .service-record-table col.service-salary-col { width: 1% !important; }
.service-record-print-document .service-record-table col.service-office-col { width: 1.75in !important; max-width: 1.75in !important; }
.service-record-print-document .service-record-table col.service-lwop-col { width: 5% !important; }
.service-record-print-document .service-record-table col.service-remarks-col { width: 1% !important; max-width: none !important; }

.service-record-print-document .service-record-table th,
.service-record-print-document .service-record-table td {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    max-height: none !important;
    padding: 1.5pt 2.5pt !important;
    border: .5pt solid #000;
    line-height: 1.1 !important;
    font-size: inherit !important;
    white-space: normal !important;
    overflow: visible !important;
    overflow-wrap: anywhere;
    word-break: normal;
    text-overflow: clip !important;
}

.service-record-print-document .service-record-table th {
    text-align: center !important;
    background: #f0f0f0 !important;
    font-size: 7.5pt !important;
    padding-block: 2pt !important;
}

.service-record-print-document .service-record-table .service-inclusive-dates {
    white-space: normal !important;
}

.service-record-print-document .service-record-table .service-designation,
.service-record-print-document .service-record-table .service-date-cell,
.service-record-print-document .service-record-table .service-status-cell,
.service-record-print-document .service-record-table .service-lwop-cell,
.service-record-print-document .service-record-table .service-office-cell,
.service-record-print-document .service-record-table .service-remarks-cell {
    text-align: center !important;
}

.service-record-print-document .service-record-table td.service-remarks-cell {
    /* Reserve content width with the minimum enforced by the inner text block. */
    width: 1% !important;
    font-size: 7pt !important;
}

.service-record-print-document .service-record-table .service-remarks-text {
    display: block;
    width: max-content;
    /* Preserve room for "LBC No. 160, 08/12/2024" at the report's 7pt font. */
    min-width: 1.05in;
    max-width: 1.65in;
    margin-inline: auto;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Share available width by content and balance office names into fewer lines.
   Never clamp or hide an official office name when additional wrapping is needed. */
.service-record-print-document .service-record-table td.service-office-cell {
    /* Bound the column itself, not only the text inside a wider auto-sized cell. */
    width: 1.75in !important;
    max-width: 1.75in !important;
    text-wrap: balance;
    overflow-wrap: break-word;
}

/* Office names must not take spare space away from short designations/remarks.
   Keep natural sizing for short names, but wrap long names within a bounded block. */
.service-record-print-document .service-record-table .service-office-text {
    display: block;
    width: max-content;
    max-width: 1.65in;
    margin-inline: auto;
    white-space: normal;
    overflow-wrap: anywhere;
    text-wrap: balance;
}

.service-record-print-document .service-record-table .service-salary {
    font-variant-numeric: tabular-nums;
    white-space: nowrap !important;
}

.service-record-print-document .service-record-table th.service-lwop-cell {
    white-space: nowrap !important;
    overflow-wrap: normal;
}

/* Compact fields take their natural content width; text columns share the rest. */
.service-record-print-document .service-record-table :is(.service-date-cell, .service-status-cell, .service-salary) {
    width: 1% !important;
    white-space: nowrap !important;
    overflow-wrap: normal;
}

.service-record-print-document .service-record-table thead { display: table-header-group; }
.service-record-print-document .service-record-table tr { break-inside: avoid; page-break-inside: avoid; }
.service-record-print-document .service-record-table tbody { break-inside: auto; }

.service-record-print-document .service-record-certification {
    break-inside: avoid;
    page-break-inside: avoid;
    padding-top: .03in;
}

.service-record-print-document .service-record-footer {
    gap: .5in;
    margin-top: .2in;
    align-items: start;
}

.service-record-print-document .service-record-footer p,
.service-record-print-document .service-record-footer strong,
.service-record-print-document .service-record-footer span,
.service-record-print-document .service-date {
    font-size: 10pt !important;
    line-height: 1.25;
}

.service-record-print-document .service-signatory strong,
.service-record-print-document .service-signatory span {
    font-size: 11pt !important;
}

.service-record-print-document .service-signatory {
    grid-template-rows: .6in auto auto;
    min-height: 0;
    width: 100%;
    justify-self: stretch;
}

.service-record-print-document .service-signatory p { margin: 0; }
.service-record-print-document .service-signatory span { font-weight: 400; }
.service-record-print-document .service-date { margin: .2in 0 0; }

@media screen {
    .print-page:has(.service-record-print-document) { overflow-x: auto; justify-items: safe center; }
}

@media print {
    /* Certificate styles set A4 widths on shared ancestors. Keep the complete
       layout inside this named page's 7.9in content area, not the sheet width.
       Apply the page to ancestors too, avoiding a leading anonymous A4 page. */
    html:has(.service-record-print-document),
    body:has(.service-record-print-document),
    .print-only-layout:has(.service-record-print-document),
    .print-page:has(.service-record-print-document) {
        page: service-record-page !important;
        box-sizing: border-box !important;
        width: 7.9in !important;
        min-width: 0 !important;
        max-width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        display: block !important;
        overflow: visible !important;
    }

    /* Named page margins supply the inset; do not apply it twice. */
    .print-document.service-record-print-document {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        min-height: 0 !important;
        height: auto !important;
        padding: 0 !important;
        margin: 0 !important;
        box-shadow: none;
        overflow: visible !important;
    }
}
