/* ==========================================================================
   statement.css — Global Stylesheet for Financial Account Statements
   Used by DepositDocStatement, LoanDocStatementDetail, LoanDocStatementDetailGroup,
   LoanDocStatementSummary, LoanDocTransactionDetail, and related financial statement documents.
   ========================================================================== */

/* Suppress legacy print toolbar from PrintLayout only when modern statement is active */
body:has(.stmt-root) #printToolbar,
body:has(.loan-stmt-root) #printToolbar,
body:has(.depo-tx-root) #printToolbar,
body:has(.loan-tx-root) #printToolbar,
body:has(.stmt-toolbar) #printToolbar {
    display: none !important;
}

/* Neutralize legacy PrintLayout rules when modern statement is active */
.stmt-root th,
.stmt-sheet th,
.depo-tx-root th,
.loan-stmt-root th,
.loan-tx-root th {
    border: 1px solid #cbd5e1 !important;
}

/* Ensure all statement sheets and tables are ALWAYS light paper with dark text,
   regardless of whether html has .dark-theme or [data-bs-theme=dark] */
html.dark-theme .stmt-root,
html[data-bs-theme="dark"] .stmt-root,
.stmt-root {
    color: #1e293b !important;
    background-color: #f1f5f9 !important;
}

html.dark-theme .stmt-sheet,
html[data-bs-theme="dark"] .stmt-sheet,
.stmt-sheet {
    background: #ffffff !important;
    color: #0f172a !important;
}

html.dark-theme .stmt-sheet .table,
html[data-bs-theme="dark"] .stmt-sheet .table,
.stmt-sheet .table {
    --bs-table-bg: transparent !important;
    --bs-table-color: #0f172a !important;
    --bs-table-border-color: #cbd5e1 !important;
    --bs-table-striped-bg: #f8fafc !important;
    --bs-table-striped-color: #0f172a !important;
    --bs-table-hover-bg: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

html.dark-theme .stmt-sheet .table th,
html[data-bs-theme="dark"] .stmt-sheet .table th,
html.dark-theme .stmt-sheet .table td,
html[data-bs-theme="dark"] .stmt-sheet .table td,
.stmt-sheet .table th,
.stmt-sheet .table td {
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}

html.dark-theme .stmt-sheet .table thead th,
html[data-bs-theme="dark"] .stmt-sheet .table thead th,
.stmt-sheet .table thead th {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    border: 1px solid #cbd5e1 !important;
}

html.dark-theme .stmt-sheet .table-striped > tbody > tr:nth-of-type(odd) > *,
.stmt-sheet .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(241, 245, 249, 0.5) !important;
    color: #0f172a !important;
}

/* Base Typography & Background for Statement Documents */
.stmt-root,
.depo-tx-root,
.loan-stmt-root,
.loan-tx-root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1e293b;
    background-color: #f1f5f9;
    min-height: 100vh;
    padding-bottom: 40px;
}

/* Screen Action Toolbar */
.stmt-toolbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    padding: 10px 24px;
    margin-bottom: 20px;
}

.stmt-toolbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.stmt-toolbar-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #0f172a;
}

.toolbar-badge {
    font-size: 12px;
    background: #e0e7ff;
    color: #3730a3;
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 600;
    font-family: monospace;
}

.stmt-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-stmt {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    text-decoration: none;
}

.btn-stmt-print {
    background: linear-gradient(135deg, var(--primary, #00327d), var(--primary-container, #0047ab));
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 50, 125, 0.3);
}

.btn-stmt-print:hover {
    background: linear-gradient(135deg, var(--primary-container, #0047ab), var(--primary, #00327d));
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 50, 125, 0.4);
}

.btn-stmt-download {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
}

.btn-stmt-download:hover {
    background: linear-gradient(135deg, #0369a1, #075985);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.4);
}

.btn-stmt-close {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #64748b;
}

.btn-stmt-close:hover {
    background: #f8fafc;
    color: #0f172a;
}

/* Centered Paper Sheet */
.stmt-sheet {
    background: #ffffff;
    color: #0f172a;
    margin: 0 auto;
    padding: 12mm 12mm 14mm 12mm;
    box-sizing: border-box;
    border-radius: 4px;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.08), 0 2px 6px -1px rgba(0, 0, 0, 0.04);
    transition: max-width 0.2s ease, width 0.2s ease;
}

.depo-tx-root .stmt-sheet {
    padding: 24px 32px;
    border: 1px solid #e2e8f0;
}

/* Orientation Modes (Screen) */
.is-portrait .stmt-sheet,
.depo-tx-root.is-portrait .stmt-sheet,
.loan-stmt-root.is-portrait .stmt-sheet,
.loan-tx-root.is-portrait .stmt-sheet {
    width: 210mm;
    max-width: 210mm;
    min-height: 297mm;
}

.is-landscape .stmt-sheet,
.stmt-sheet.is-landscape,
.depo-tx-root.is-landscape .stmt-sheet,
.loan-stmt-root.is-landscape .stmt-sheet,
.loan-tx-root.is-landscape .stmt-sheet {
    width: 297mm;
    max-width: 100%;
    min-height: 210mm;
}

.loan-stmt-root.is-landscape .stmt-sheet,
.loan-tx-root.is-landscape .stmt-sheet {
    max-width: 285mm;
    min-height: 195mm;
    padding: 10mm 10mm 12mm 10mm;
}

.loan-stmt-root.is-portrait .stmt-sheet,
.loan-tx-root.is-portrait .stmt-sheet {
    padding: 8mm 8mm 10mm 8mm;
    min-height: 280mm;
}

/* Institutional Header / Letterhead */
.stmt-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #0f172a;
    padding-bottom: 12px;
    margin-bottom: 14px;
    gap: 16px;
}

.stmt-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}

.stmt-logo {
    max-height: 60px;
    max-width: 90px;
    object-fit: contain;
    border-radius: 4px;
}

.stmt-logo-placeholder {
    width: 52px;
    height: 52px;
    background: #f1f5f9;
    border: 1px dashed #94a3b8;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #64748b;
}

.stmt-org-name {
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.2;
    letter-spacing: -0.2px;
}

.stmt-org-address {
    font-size: 13px;
    color: #475569;
    font-weight: 500;
    margin-top: 2px;
}

.stmt-header-right {
    text-align: right;
    font-size: 11px;
    color: #475569;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.stmt-report-badge,
.stmt-title-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    margin-bottom: 4px;
}

.stmt-period {
    font-weight: 600;
    color: #1e293b;
    font-size: 12px;
}

.stmt-gen-date {
    color: #64748b;
    font-size: 11px;
}

/* 3-Panel & 2-Panel Metadata Cards Grid */
.stmt-grid,
.stmt-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stmt-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stmt-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stmt-card-header {
    font-size: 10.5px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 3px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stmt-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 6px;
    padding: 2.5px 0;
    font-size: 11.5px;
}

.stmt-meta-label {
    color: #64748b;
    font-size: 10.5px;
    white-space: nowrap;
    font-weight: 500;
}

.stmt-meta-val {
    font-weight: 600;
    color: #0f172a;
    text-align: right;
    word-break: break-word;
}

.stmt-meta-val.num {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-variant-numeric: tabular-nums;
}

.stmt-meta-val.alert-red {
    color: #dc2626;
    font-weight: 700;
}

.stmt-card-total-due {
    margin-top: 5px;
    padding: 5px 6px;
    border-top: 1px solid #cbd5e1;
    background: #eef2ff;
    border-radius: 4px;
}

/* Ledger Table */
.stmt-table-wrapper {
    margin-bottom: 14px;
    overflow-x: auto;
    width: 100%;
}

.stmt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10.5px;
    line-height: 1.35;
}

.stmt-table thead th {
    background-color: #f1f5f9;
    color: #0f172a;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 9.5px;
    letter-spacing: 0.03em;
    padding: 5px 4px;
    border: 1px solid #cbd5e1;
    vertical-align: middle;
}

.stmt-table tbody td {
    padding: 4px 5px;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    vertical-align: middle;
}

.stmt-table tbody tr:nth-child(even) {
    background-color: #fcfdfd;
}

.stmt-table tbody tr:hover {
    background-color: #f1f5f9;
}

.stmt-table .center,
.stmt-table td.center,
.stmt-table th.center {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.stmt-table .num,
.stmt-table td.num,
.stmt-table th.num {
    text-align: right;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.stmt-table .desc,
.stmt-table td.desc {
    text-align: left;
    max-width: 250px;
    word-break: break-word;
    white-space: normal;
}

/* Totals, Due Detail, & Group Rows */
.stmt-table tr.period-totals,
.stmt-table tfoot tr.period-totals {
    background: #f1f5f9;
    font-weight: 700;
    border-top: 2px solid #0f172a;
}

.stmt-table tr.period-totals td,
.stmt-table tfoot tr.period-totals td {
    padding: 5px 4px;
    border: 1px solid #cbd5e1;
}

.stmt-table tr.due-details-row {
    background: #f1f5f9;
    font-weight: 700;
    border: 2px solid #0f172a;
    page-break-inside: avoid;
    break-inside: avoid;
}

.stmt-table tr.due-details-row td {
    padding: 4px 3px;
    border: 1px solid #0f172a;
}

.stmt-table tr.group-header {
    background: #f1f5f9;
    font-weight: 700;
    color: #0f172a;
}

.stmt-table tr.group-total {
    background: #f8fafc;
    font-weight: 700;
    border-top: 1px solid #94a3b8;
}

.stmt-table tr.date-subtotal {
    background: #f1f5f9;
    font-weight: 700;
    border-top: 1px solid #94a3b8;
    border-bottom: 1px solid #94a3b8;
}

.stmt-table tr.date-subtotal td {
    padding: 4px 3px;
}

.stmt-table tr.grand-total-row {
    background: #f8fafc;
    font-weight: 700;
    border-top: 2px solid #0f172a;
    border-bottom: 2px solid #0f172a;
}

.stmt-table tr.grand-total-row td {
    padding: 4px 3px;
    border: 1px solid #0f172a;
}

/* Column Sizing: Loan Statement Detail (11 Columns) */
.th-date { width: 7.5%; text-align: center; }
.th-seq  { width: 4%; }
.th-type { width: 5.5%; }
.th-desc { width: 16%; }
.th-amt  { width: 9.4%; }
.th-tot  { width: 10%; }

/* Column Sizing: Loan Statement (10 Columns) */
.loan-stmt-root .stmt-table {
    table-layout: fixed;
}
.loan-stmt-root .col-date { width: 7.5%; text-align: center; }
.loan-stmt-root .col-desc { width: 19.5%; }
.loan-stmt-root .col-amt  { width: 9%; }
.loan-stmt-root .col-pay  { width: 9.5%; }
.loan-stmt-root .col-bal  { width: 9.5%; }

/* Column Sizing: Loan Transaction Statement (7 Columns) */
.loan-tx-root .stmt-table {
    table-layout: fixed;
}
.loan-tx-root .col-date   { width: 7.5%; }
.loan-tx-root .col-seq    { width: 8.0%; }
.loan-tx-root .col-type   { width: 7.0%; }
.loan-tx-root .col-desc   { width: 31.5%; }
.loan-tx-root .col-dr     { width: 15.0%; }
.loan-tx-root .col-cr     { width: 15.0%; }
.loan-tx-root .col-bal    { width: 16.0%; }

/* Column Sizing: Deposit Statement (7 Columns) */
.depo-tx-root .stmt-table .col-date { width: 70px; white-space: nowrap; }
.depo-tx-root .stmt-table .col-seq  { width: 55px; white-space: nowrap; }
.depo-tx-root .stmt-table .col-type { width: 60px; white-space: nowrap; }
.depo-tx-root .stmt-table .col-desc { text-align: left; }
.depo-tx-root .stmt-table .col-dr   { width: 85px; white-space: nowrap; }
.depo-tx-root .stmt-table .col-cr   { width: 85px; white-space: nowrap; }
.depo-tx-root .stmt-table .col-bal  { width: 95px; white-space: nowrap; }

/* Financial Summary KPI Cards Grid */
.stmt-kpi-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #334155;
    margin-top: 12px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stmt-kpi-grid,
.stmt-kpi-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 16px;
}

.stmt-kpi-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 16px;
}

.stmt-kpi-box {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stmt-kpi-label {
    font-size: 9.5px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
}

.stmt-kpi-val {
    font-size: 12px;
    font-weight: 700;
    color: #0f172a;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-variant-numeric: tabular-nums;
}

/* Signatures Block */
.stmt-signatures {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-top: 28px;
    padding-top: 10px;
}

.stmt-sig-box {
    text-align: center;
}

.stmt-sig-line {
    border-top: 1px solid #94a3b8;
    padding-top: 5px;
    text-align: center;
    font-size: 10px;
    color: #475569;
    font-weight: 600;
}

.stmt-sig-title {
    font-size: 10.5px;
    font-weight: 600;
    color: #475569;
}

/* Disclaimer / Footer Note */
.stmt-disclaimer,
.stmt-footer-note {
    margin-top: 18px;
    font-size: 9px;
    color: #94a3b8;
    text-align: center;
    font-style: italic;
    border-top: 1px dashed #e2e8f0;
    padding-top: 6px;
}

/* Portrait Mode Compact Overrides (Screen & Print) */
.is-portrait .stmt-sheet {
    padding: 8mm 8mm 10mm 8mm;
}
.is-portrait .stmt-header {
    padding-bottom: 6px;
    margin-bottom: 8px;
}
.is-portrait .stmt-logo {
    height: 48px;
    width: 48px;
}
.is-portrait .stmt-logo-placeholder {
    height: 42px;
    width: 42px;
    font-size: 20px;
}
.is-portrait .stmt-org-name {
    font-size: 18px;
}
.is-portrait .stmt-org-address {
    font-size: 12px;
}
.is-portrait .stmt-period {
    font-size: 11px;
    margin-top: 3px;
}
.is-portrait .stmt-gen-date {
    font-size: 10px;
}

.is-portrait .stmt-grid,
.is-portrait .stmt-grid-3,
.is-portrait .stmt-grid-2 {
    gap: 6px;
    margin-bottom: 8px;
}
.is-portrait .stmt-card {
    padding: 6px 8px;
}
.is-portrait .stmt-card-header {
    font-size: 10.5px;
    margin-bottom: 4px;
    padding-bottom: 3px;
}
.is-portrait .stmt-meta-row {
    font-size: 10.5px;
    padding: 2px 0;
}
.is-portrait .stmt-card-total-due {
    margin-top: 3px;
    padding: 3px 6px;
}

.is-portrait .stmt-table-wrapper {
    margin-bottom: 6px;
}
.is-portrait .stmt-table {
    font-size: 9.5px;
}
.is-portrait .stmt-table thead th {
    padding: 4px 2px;
    font-size: 9px;
    letter-spacing: 0;
    white-space: normal;
    word-break: normal;
    line-height: 1.15;
    vertical-align: bottom;
}
.is-portrait .stmt-table tbody td {
    padding: 3px 2px;
    font-size: 9.5px;
}
.is-portrait .stmt-table td.num,
.is-portrait .stmt-table th.num {
    padding-left: 2px;
    padding-right: 2px;
    font-size: 9.5px;
}
.is-portrait .stmt-table tr.period-totals td,
.is-portrait .stmt-table tr.due-details-row td,
.is-portrait .stmt-table tr.date-subtotal td,
.is-portrait .stmt-table tr.grand-total-row td {
    padding: 3px 2px;
    font-size: 9.5px;
}

.is-portrait .th-date { width: 7.5%; text-align: center; }
.is-portrait .th-seq  { width: 4%; }
.is-portrait .th-type { width: 5.5%; }
.is-portrait .th-desc { width: 16%; }
.is-portrait .th-amt  { width: 9.4%; }
.is-portrait .th-tot  { width: 10%; }

/* Page Orientation Support via CSS Paged Media */
@page {
    size: A4 portrait;
    margin: 8mm 6mm;
}

@page landscape-page {
    size: A4 landscape;
    margin: 8mm 6mm;
}

@page portrait-page {
    size: A4 portrait;
    margin: 8mm 6mm;
}

.is-landscape {
    page: landscape-page;
}

.is-portrait {
    page: portrait-page;
}

/* Print Overrides */
@media print {
    body {
        background: #ffffff !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .no-print,
    .stmt-toolbar,
    #printToolbar,
    .app-menu,
    .navbar-custom,
    .sidebar-overlay,
    .report-mode-banner {
        display: none !important;
    }

    .content-page {
        margin: 0 !important;
        padding: 0 !important;
    }

    .stmt-root,
    .depo-tx-root,
    .loan-stmt-root,
    .loan-tx-root {
        background: #ffffff !important;
        min-height: auto !important;
        padding: 0 !important;
    }

    .stmt-sheet {
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: auto !important;
    }

    .stmt-header {
        border-bottom: 2px solid #000000 !important;
    }

    .stmt-report-badge,
    .stmt-title-badge {
        background: #f1f5f9 !important;
        color: #000000 !important;
        border: 1px solid #475569 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .stmt-card,
    .stmt-kpi-grid,
    .stmt-kpi-grid-3,
    .stmt-kpi-grid-4,
    .stmt-kpi-box {
        border: 1px solid #94a3b8 !important;
        background: #ffffff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .stmt-card-total-due {
        background: #eef2ff !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .stmt-table-wrapper {
        overflow: visible !important;
        width: 100% !important;
    }

    .stmt-table thead {
        display: table-header-group !important;
    }

    .stmt-table thead th {
        background: #f1f5f9 !important;
        color: #000000 !important;
        border: 1px solid #475569 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        white-space: normal !important;
        word-break: normal !important;
        line-height: 1.15 !important;
        vertical-align: bottom !important;
    }

    .stmt-table tbody tr {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .stmt-table tbody td {
        border: 1px solid #94a3b8 !important;
    }

    .stmt-table tr.period-totals,
    .stmt-table tfoot tr.period-totals {
        border-top: 2px solid #000000 !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .stmt-table tr.due-details-row {
        border: 2px solid #000000 !important;
        background: #f1f5f9 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .stmt-table tr.date-subtotal {
        background: #f1f5f9 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .stmt-table tr.grand-total-row {
        border-top: 2px solid #000000 !important;
        border-bottom: 2px solid #000000 !important;
        background: #f8fafc !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .stmt-table tr.group-header,
    .stmt-table tr.group-total {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    .stmt-sig-line {
        border-top: 1px solid #000000 !important;
    }

    .is-portrait .stmt-sheet {
        padding: 0 !important;
        margin: 0 !important;
    }

    .is-portrait .stmt-table thead th {
        padding: 4px 2px !important;
        font-size: 9px !important;
    }

    .is-portrait .stmt-table tbody td {
        padding: 3px 2px !important;
        font-size: 9.5px !important;
    }

    .is-portrait .stmt-table td.num,
    .is-portrait .stmt-table th.num {
        padding-left: 2px !important;
        padding-right: 2px !important;
        font-size: 9.5px !important;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
        font-variant-numeric: tabular-nums !important;
    }

    .is-portrait .stmt-table tr.period-totals td,
    .is-portrait .stmt-table tr.due-details-row td,
    .is-portrait .stmt-table tr.date-subtotal td,
    .is-portrait .stmt-table tr.grand-total-row td {
        padding: 3px 2px !important;
        font-size: 9.5px !important;
    }
}

@media print and (orientation: landscape) {
    @page {
        size: A4 landscape;
        margin: 8mm 6mm !important;
    }
}

@media print and (orientation: portrait) {
    @page {
        size: A4 portrait;
        margin: 8mm 6mm !important;
    }
    .stmt-sheet {
        padding: 0 !important;
        margin: 0 !important;
    }
    .stmt-header {
        padding-bottom: 6px !important;
        margin-bottom: 8px !important;
    }
    .stmt-logo {
        height: 48px !important;
        width: 48px !important;
    }
    .stmt-org-name {
        font-size: 18px !important;
    }
    .stmt-org-address {
        font-size: 12px !important;
    }
    .stmt-grid,
    .stmt-grid-3,
    .stmt-grid-2 {
        gap: 6px !important;
        margin-bottom: 8px !important;
    }
    .stmt-card {
        padding: 6px 8px !important;
    }
    .stmt-card-header {
        font-size: 10.5px !important;
        margin-bottom: 4px !important;
        padding-bottom: 3px !important;
    }
    .stmt-meta-row {
        font-size: 10.5px !important;
        padding: 2px 0 !important;
    }
    .stmt-table-wrapper {
        margin-bottom: 6px !important;
        overflow: visible !important;
        width: 100% !important;
    }
    .stmt-table {
        font-size: 9.5px !important;
    }
    .stmt-table thead th {
        padding: 4px 2px !important;
        font-size: 9px !important;
        letter-spacing: 0 !important;
        white-space: normal !important;
        word-break: normal !important;
        line-height: 1.15 !important;
        vertical-align: bottom !important;
    }
    .stmt-table tbody td {
        padding: 3px 2px !important;
        font-size: 9.5px !important;
    }
    .stmt-table td.num,
    .stmt-table th.num {
        padding-left: 2px !important;
        padding-right: 2px !important;
        font-size: 9.5px !important;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
        font-variant-numeric: tabular-nums !important;
    }
    .stmt-table tr.period-totals td,
    .stmt-table tr.due-details-row td,
    .stmt-table tr.date-subtotal td,
    .stmt-table tr.grand-total-row td {
        padding: 3px 2px !important;
        font-size: 9.5px !important;
    }
    .th-date { width: 7.5% !important; text-align: center !important; }
    .th-seq  { width: 4% !important; }
    .th-type { width: 5.5% !important; }
    .th-desc { width: 16% !important; }
    .th-amt  { width: 9.4% !important; }
    .th-tot  { width: 10% !important; }
}

/* ── Force Clean Paper / Light Styling inside .stmt-sheet regardless of theme ── */
.dark-theme .stmt-sheet,
[data-bs-theme="dark"] .stmt-sheet {
    background-color: #ffffff !important;
    color: #0f172a !important;
}

.dark-theme .stmt-sheet table,
[data-bs-theme="dark"] .stmt-sheet table {
    --bs-table-bg: transparent !important;
    --bs-table-color: #0f172a !important;
    background-color: #ffffff !important;
    color: #0f172a !important;
}

.dark-theme .stmt-sheet thead th,
[data-bs-theme="dark"] .stmt-sheet thead th,
.dark-theme .stmt-sheet thead.table-light th,
[data-bs-theme="dark"] .stmt-sheet thead.table-light th {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
    --bs-table-bg: #f1f5f9 !important;
    --bs-table-color: #0f172a !important;
}

.dark-theme .stmt-sheet tbody td,
[data-bs-theme="dark"] .stmt-sheet tbody td {
    background-color: #ffffff !important;
    color: #1e293b !important;
    border-color: #e2e8f0 !important;
}

.dark-theme .stmt-sheet tbody tr:nth-child(even) td,
[data-bs-theme="dark"] .stmt-sheet tbody tr:nth-child(even) td {
    background-color: #f8fafc !important;
    color: #1e293b !important;
}

.dark-theme .stmt-sheet tfoot,
.dark-theme .stmt-sheet tfoot tr,
.dark-theme .stmt-sheet tfoot td,
.dark-theme .stmt-sheet tfoot th,
.dark-theme .stmt-sheet tfoot.table-light,
.dark-theme .stmt-sheet tfoot.table-light td,
.dark-theme .stmt-sheet .stmt-total-row,
.dark-theme .stmt-sheet .stmt-total-row td,
[data-bs-theme="dark"] .stmt-sheet tfoot,
[data-bs-theme="dark"] .stmt-sheet tfoot tr,
[data-bs-theme="dark"] .stmt-sheet tfoot td,
[data-bs-theme="dark"] .stmt-sheet tfoot th,
[data-bs-theme="dark"] .stmt-sheet tfoot.table-light,
[data-bs-theme="dark"] .stmt-sheet tfoot.table-light td,
[data-bs-theme="dark"] .stmt-sheet .stmt-total-row,
[data-bs-theme="dark"] .stmt-sheet .stmt-total-row td {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
    --bs-table-bg: #f1f5f9 !important;
    --bs-table-color: #0f172a !important;
}

