/* Formal payslip layout shared with the PDF; keep the paper neutral in both themes. */
html body .payslip-document.payslip-document {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    width: 76mm !important;
    min-height: 0 !important;
    height: auto;
    padding: 6mm 7mm 1mm !important;
    box-sizing: border-box;
    background: #fff !important;
    color: #111 !important;
    font: 11.33px/1.15 "Segoe UI", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    box-shadow: 0 8px 28px #172b3a14;
}
html body .payslip-document .payslip-print-notice {
    display: block;
    padding: 4pt 0;
    color: #f00 !important;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 8.5pt;
    font-weight: 700;
    font-style: italic;
    text-align: center;
    line-height: 1.15;
}
html body .payslip-document .payslip-bottom-notice {
    /* Balance the visible gaps around the notice with the screen font metrics. */
    padding-top: 7.25pt;
    padding-bottom: 6.75pt;
}
html body .payslip-document .payslip-bottom-notice + footer { margin-top: 0; }
html body .payslip-document .payslip-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5.33px;
    min-height: 0;
    margin: 0;
    padding: 0 0 9.33px;
    border-bottom: .67px solid #d9dde1;
}
html body .payslip-document .payslip-header-side,
html body .payslip-document .payslip-header img {
    width: 14mm; height: 14mm; object-fit: contain;
}
html body .payslip-document .payslip-header img { filter: grayscale(1); }
html body .payslip-document .payslip-header-center,
html body .payslip-document .payslip-header-center p,
html body .payslip-document .payslip-header-center h1 { text-align: center !important; }
html body .payslip-document .payslip-header p {
    margin: 0; color: #111 !important; font-size: 12px; line-height: 1.15; font-weight: 400;
}
html body .payslip-document .payslip-header h1 {
    margin: 9.33px 0 0 !important; font-size: 17.33px !important; line-height: 1.15;
    font-weight: 700; letter-spacing: .03em; color: #111 !important;
}
html body .payslip-document .payslip-identity {
    margin: 0; padding: 5.33px 0; background: transparent; border: 0;
}
html body .payslip-document .payslip-identity div {
    display: grid; grid-template-columns: 15mm 3mm minmax(0, 1fr); gap: 0; margin: 0 0 2.67px;
}
html body .payslip-document .payslip-identity div:last-child { margin: 0; }
html body .payslip-document .payslip-identity div::before { content: ':'; grid-column: 2; grid-row: 1; }
html body .payslip-document .payslip-identity dt { grid-column: 1; grid-row: 1; font-weight: 700; color: #111 !important; }
html body .payslip-document .payslip-identity dd { grid-column: 3; grid-row: 1; font-weight: 400; color: #111 !important; }
html body .payslip-document h2 {
    margin: 6.67px 0 1.33px; padding: 4px 6.67px; border: 0; background: #fff;
    color: #111 !important; font-size: 13.33px; font-weight: 700; line-height: 1.15; text-transform: uppercase;
}
html body .payslip-document .payslip-identity + h2 { position: relative; margin-top: 12pt; }
html body .payslip-document .payslip-net + h2 { position: relative; margin-top: 13pt; }
/* Draw solid rules within the existing spaces before the two section headings. */
html body .payslip-document .payslip-identity + h2::before,
html body .payslip-document .payslip-net + h2::before {
    content: '';
    display: block;
    position: absolute;
    top: -6pt;
    left: 0;
    right: 0;
    border-top: .5pt solid #000;
}
html body .payslip-document h3 { margin: 2.67px 0 1.33px; color: #111 !important; font-size: 11.33px; font-weight: 700; line-height: 1.15; }
html body .payslip-document h3.payslip-less { margin-top: 4px; }
html body .payslip-document h3.payslip-loans-heading { margin-top: 10.67px; padding-top: 0; border: 0; }
html body .payslip-document h4 { margin: 5.33px 0 1.33px; padding-left: 4mm; color: #111 !important; font-size: 11.33px; font-weight: 700; }
html body .payslip-document .payslip-row {
    grid-template-columns: minmax(0, 1fr) 24mm; gap: 0; padding: 1.33px 0;
    font-size: 11.33px; line-height: 1.15; color: #111 !important;
}
html body .payslip-document .payslip-row span:first-child { padding-left: 2mm; }
html body .payslip-document .payslip-indented-row span:first-child { padding-left: 4mm; }
html body .payslip-document .payslip-loan-row span:first-child { padding-left: 7mm; }
html body .payslip-document .payslip-row span:last-child { width: auto; font-family: "Segoe UI", system-ui, sans-serif; font-variant-numeric: tabular-nums; }
html body .payslip-document .payslip-total-row {
    padding: 5.33px 0; background: #fff; font-weight: 700; border: 0;
}
html body .payslip-document .payslip-total-row span:first-child { padding: 0; }
html body .payslip-document .payslip-net {
    display: flex; justify-content: space-between; align-items: center; gap: 6px;
    margin: 8px 0; padding: 8px 0 8px 8px; border: 0;
    background: #fff !important; color: #111 !important;
}
html body .payslip-document .payslip-net > strong {
    width: auto; font-size: 14.67px; font-family: "Segoe UI", system-ui, sans-serif; font-variant-numeric: tabular-nums; color: #111 !important;
}
html body .payslip-document footer { margin-top: 12px; padding-top: 12px; border: 0; border-top: .67px solid #b8bdc4; color: #656b72 !important; font-size: 10px; line-height: 1.15; }
@media (max-width: 400px) {
    html body .payslip-preview-page { padding: 12px 4px !important; }
    html body .payslip-document.payslip-document { max-width: 100%; }
}
@media print {
    @page payslip-preview { size: auto; margin: 0; }
    body:has(.payslip-document) { page: payslip-preview; }
    /* The shared report stylesheet reserves an A4-wide root. Roll printing must
       reset that width and the app containers before laying out the payslip. */
    html:has(.payslip-document),
    html body:has(.payslip-document) {
        width: 76mm !important;
        min-width: 0 !important;
        max-width: none !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        background: #fff !important;
    }
    html body:has(.payslip-document) :is(.page.page, main, .content.content, .payslip-preview-page) {
        display: block !important;
        position: static !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        transform: none !important;
        box-shadow: none !important;
        background: #fff !important;
    }
    html body:has(.payslip-document) :is(.payslip-preview-toolbar, .sidebar, .top-row, .employee-mobile-tabbar, .pwa-install-notice, .internal-chat) { display: none !important; }
    html body .page:has(.payslip-document) .employee-mobile-tabbar { display: none !important; }
    html body .payslip-document.payslip-document { min-height: 0 !important; height: auto !important; margin: 0 !important; box-shadow: none; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}

/* Opaque ink on white paper avoids gray halftone backgrounds. */
@media print {
    html body .payslip-document.payslip-document,
    html body .payslip-document :is(h1, h2, h3, h4, p, dt, dd, span, strong, footer, .payslip-row, .payslip-net) {
        color: #000 !important;
        font-family: Arial, Helvetica, sans-serif !important;
    }
    html body .payslip-document :is(h2, .payslip-net, .payslip-total-row) { background: #fff !important; }
    html body .payslip-document :is(.payslip-header, footer) { border-color: #000 !important; }
    html body .payslip-document .payslip-header img { filter: grayscale(1) contrast(1000); }
    html body .payslip-document .payslip-bottom-notice { padding-top: 6.5pt; padding-bottom: 7.5pt; }
}
