/* =====================================================================
   PrintEngine document styles
   Scoped to the off-screen print iframe (body.pd-body) — never affects
   the main application UI. Loaded AFTER app.css / style.css so the
   @media print overrides win at print time.
   ===================================================================== */

.pd-body {
    font-family: 'Inter', 'Hind Siliguri', 'Noto Sans Bengali', 'Segoe UI', Arial, sans-serif;
    font-size: 10pt;
    color: #0f172a;
    background: #ffffff;
    margin: 0;
    padding: 0;
}

/* ----------------------------- letterhead --------------------------- */
.pd-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2.5px solid #b91c1c;
    padding-bottom: 8px;
    margin-bottom: 10px;
}
.pd-head-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pd-monogram {
    width: 46px; height: 46px; border-radius: 10px;
    background: linear-gradient(135deg, #0f172a, #1e293b); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 15pt; letter-spacing: .5px; flex: none;
}
.pd-logo { flex: none; display: flex; align-items: center; }
.pd-logo img { height: 44px; max-width: 180px; object-fit: contain; }
.pd-org-name { font-size: 15pt; font-weight: 800; color: #0f172a; letter-spacing: .2px; }
.pd-org-sub { font-size: 8pt; color: #475569; margin-top: 2px; }
.pd-status {
    flex: none; background: #065f46; color: #fff;
    font-size: 8.5pt; font-weight: 700; letter-spacing: .6px;
    padding: 4px 12px; border-radius: 999px; text-transform: uppercase;
}
.pd-status.is-warn { background: #b45309; }

/* ----------------------------- title bar ---------------------------- */
.pd-titlebar { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.pd-title { font-size: 16pt; font-weight: 800; color: #0f172a; margin: 0; }
.pd-doctype { font-size: 9pt; color: #64748b; margin-top: 2px; }
.pd-title-side {
    font-size: 8pt; color: #475569; text-align: right; line-height: 1.7;
    display: flex; flex-direction: column; align-items: flex-end;
}
.pd-ref {
    font-weight: 800; color: #b91c1c; letter-spacing: .4px;
    font-size: 8.5pt;
}

/* ------------------------------- meta ------------------------------- */
.pd-meta { width: 100%; border-collapse: collapse; margin: 0 0 10px 0; font-size: 8.5pt; }
.pd-meta td { padding: 3px 8px; border: 1px solid #cbd5e1; }
.pd-meta-k {
    background: #0f172a; color: #fff; font-weight: 700; width: 130px;
    text-transform: uppercase; letter-spacing: .4px; font-size: 7.5pt;
}
.pd-meta-v { background: #f8fafc; }

/* --------------------------- filter chips --------------------------- */
.pd-filters { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 10px 0; }
.pd-filter-chip {
    background: #eef2ff; color: #1e40af; border: 1px solid #c7d2fe;
    font-size: 8pt; font-weight: 600; padding: 2px 9px; border-radius: 999px;
}

/* ------------------------- watermark -------------------------------- */
.pd-pagewrap { position: relative; page-break-after: always; }
.pd-pagewrap:last-child { page-break-after: auto; }
.pd-pagewrap.pd-last { display: flex; flex-direction: column; }
.pd-pagewrap.pd-last .pd-fill { flex: 1 1 auto; }
.pd-pagewrap.pd-last .pd-end-line { margin-top: 28px; }
.pd-watermark {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%) rotate(-32deg);
    font-size: 30pt; font-weight: 800; color: #0f172a; opacity: .08;
    white-space: nowrap; letter-spacing: 4px; z-index: 0;
    pointer-events: none;
}
.pd-watermark.pd-wm-fixed { position: fixed; }
.pd-pagewrap .print-table,
.pd-pagewrap .pd-summary,
.pd-running-title,
.pd-pagefoot,
.pd-continued { position: relative; z-index: 1; }

/* ------------------------------ tables ------------------------------ */
.print-table { width: 100%; border-collapse: collapse; font-size: 9pt; }
.print-table th {
    background: #0f172a; color: #fff; font-weight: 700; font-size: 8.5pt;
    padding: 6px 8px; text-align: left; letter-spacing: .2px;
}
.print-table td { padding: 5px 8px; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.print-table tbody tr:nth-child(even) { background: #f8fafc; }
.print-table tbody tr { break-inside: avoid; }
.print-table .pd-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.print-table .pd-ctr { text-align: center; white-space: nowrap; }
.print-table .pd-group td { background: #eef2ff; font-weight: 700; }

.print-table tbody tr.pd-subtotal {
    background: #fff; font-weight: 700; color: #1e3a8a;
    border-top: 1.5px solid #94a3b8; border-bottom: 1px solid #94a3b8;
}
.print-table tbody tr.pd-subtotal td { font-size: 8.5pt; text-transform: uppercase; letter-spacing: .3px; }

.print-table tfoot td { font-weight: 800; background: #b91c1c; color: #fff; padding: 7px 8px; }
.pd-empty { text-align: center; color: #94a3b8; padding: 24px !important; }

/* ----------------------- running title / footer --------------------- */
.pd-running-title {
    font-size: 7.5pt; color: #64748b; text-transform: uppercase; letter-spacing: .5px;
    display: flex; justify-content: space-between; margin: 6px 0 2px 0;
}
.pd-continued {
    font-size: 7.5pt; font-style: italic; color: #94a3b8;
    text-align: right; margin-top: 6px;
}
.pd-pagefoot {
    margin-top: 10px; padding-top: 4px; border-top: 1px solid #cbd5e1;
    display: flex; justify-content: space-between; gap: 8px;
    font-size: 7.5pt; color: #64748b;
}
.pf-brand { font-weight: 700; color: #475569; }
.pf-page { font-weight: 800; color: #0f172a; }

/* ---------------------------- summary box --------------------------- */
.pd-summary { margin-top: 14px; border: 1.5px solid #0f172a; border-radius: 8px; overflow: hidden; }
.pd-summary-title {
    background: #0f172a; color: #fff; font-weight: 800; font-size: 10pt;
    padding: 8px 12px; text-align: center; letter-spacing: .4px;
}
.sm-row { display: flex; justify-content: space-between; padding: 8px 12px; font-size: 9.5pt; border-top: 1px solid #e2e8f0; }
.sm-row span { color: #475569; }
.sm-income { background: #f0fdf4; }
.sm-expense { background: #fef2f2; }
.sm-net { background: #eff6ff; font-weight: 800; }
.sm-note { padding: 6px 12px; font-size: 7.5pt; color: #94a3b8; text-align: center; border-top: 1px solid #e2e8f0; }
.sm-net b { font-size: 11pt; }

/* ------------------------ signature block --------------------------- */
.pd-sig {
    display: flex; justify-content: space-between; gap: 24px;
    margin: 26px 0 4px 0; padding: 0 8px;
    break-inside: avoid; page-break-inside: avoid;
}
.pd-sig-item { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.pd-sig-cap { font-size: 8pt; font-weight: 800; color: #0f172a; text-transform: uppercase; letter-spacing: .5px; }
.pd-sig-dash { border-bottom: 1.5px solid #94a3b8; height: 34px; }
.pd-sig-note {
    font-size: 7pt; color: #64748b; text-align: center; padding: 0 8px; margin-bottom: 6px;
}

/* ---------------------------- end marker ---------------------------- */
.pd-end { margin-top: 20px; break-inside: avoid; page-break-inside: avoid; }
.pd-flow-foot {
    position: fixed; left: 0; right: 0; bottom: 0;
    font-size: 7.5pt; color: #94a3b8; text-align: center;
    padding: 2px 0; letter-spacing: .3px;
}
.pd-end { margin-bottom: 30px; }
.pd-end-line {
    font-size: 8pt; color: #64748b; text-align: center;
    border-top: 1px dashed #cbd5e1; padding-top: 8px;
}
.pd-conf { font-size: 7.5pt; color: #94a3b8; text-align: center; margin-top: 6px; }

/* --------------------------- print overrides ------------------------ */
.print-report-table tr, .meet-table tr, .mt tr {
    break-inside: avoid; page-break-inside: avoid;
}
@media print {
    html, body {
        background: #fff !important;
        margin: 0 !important; padding: 0 !important;
        font-size: 10pt !important;
        overflow: visible !important; height: auto !important;
    }
    .print-table tr { break-inside: avoid; }
    /* The final page holds summary/signatures with a min-height + flex fill,
       so it must stay intact; middle pages may split at row boundaries so a
       page never underfills when a block is only a few mm over a page. */
    .pd-pagewrap.pd-last { break-inside: avoid; page-break-inside: avoid; }
}

/* =====================================================================
   A5 RECEIPT / PAYMENT VOUCHER
   Rendered on A5 portrait (148 x 210 mm). Compact single-page layout
   with company letterhead, serial no., amount (figures + words) and
   two signature lines.
   ===================================================================== */
.rcpt { width: 100%; }
.rcpt-head {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    border-bottom: 3px double #b91c1c; padding-bottom: 6px; margin-bottom: 6px;
}
.rcpt-monogram {
    width: 36px; height: 36px; border-radius: 8px; flex: none;
    background: linear-gradient(135deg, #0f172a, #1e293b); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 12pt; letter-spacing: .5px;
}
.rcpt-logo { flex: none; display: flex; align-items: center; }
.rcpt-logo img { height: 34px; max-width: 130px; object-fit: contain; }
.rcpt-head-r { flex: 1; min-width: 0; }
.rcpt-org { font-size: 13pt; font-weight: 800; color: #0f172a; line-height: 1.15; }
.rcpt-sub { font-size: 6.8pt; color: #475569; margin-top: 2px; line-height: 1.35; }
.rcpt-refpill {
    flex: none; background: #b91c1c; color: #fff; font-weight: 800;
    font-size: 7.5pt; letter-spacing: .4px; padding: 3px 9px; border-radius: 999px;
}
.rcpt-title {
    text-align: center; background: #0f172a; color: #fff; font-weight: 800;
    font-size: 12pt; letter-spacing: 2px; padding: 5px 0; margin: 8px 0 10px 0; border-radius: 4px;
}
.rcpt-line {
    display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
    padding: 4.5px 0; border-bottom: 1px dotted #cbd5e1; font-size: 9.5pt;
}
.rcpt-k { color: #475569; font-weight: 600; flex: none; }
.rcpt-v { font-weight: 800; color: #0f172a; text-align: right; font-variant-numeric: tabular-nums; }
.rcpt-amount-box {
    border: 2px solid #b91c1c; border-radius: 10px; text-align: center;
    padding: 10px 8px; margin: 12px 0;
}
.rcpt-amt-label { font-size: 8pt; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: #475569; }
.rcpt-amount { font-size: 20pt; font-weight: 800; color: #b91c1c; margin-top: 2px; }
.rcpt-words { font-size: 8.5pt; font-style: italic; color: #0f172a; margin-top: 4px; font-weight: 600; }
.rcpt-balance {
    display: flex; justify-content: space-between; align-items: center; gap: 8px;
    padding: 7px 10px; border-radius: 8px; font-size: 9.5pt; margin-bottom: 4px;
}
.rcpt-balance span { color: #0f172a; font-weight: 600; }
.rcpt-balance b { font-size: 11pt; font-weight: 800; font-variant-numeric: tabular-nums; }
.rcpt-bdue { background: #fef2f2; border: 1px solid #fecaca; }
.rcpt-bdue b { color: #b91c1c; }
.rcpt-bcredit { background: #f0fdf4; border: 1px solid #bbf7d0; }
.rcpt-bcredit b { color: #047857; }
.rcpt-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 5px; }
.rcpt-sig {
    display: flex; justify-content: space-between; gap: 18px;
    margin-top: 30px; padding: 0 4px;
}
.rcpt-sig-item { flex: 1; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rcpt-sig-dash { border-bottom: 1.5px solid #94a3b8; width: 100%; max-width: 130px; height: 34px; }
.rcpt-sig span { font-size: 7pt; color: #475569; font-weight: 700; }
.rcpt-note {
    font-size: 6.5pt; color: #94a3b8; text-align: center; margin-top: 18px; line-height: 1.5;
}/* =====================================================================
   FINAL MEMBER MEETING STATEMENT - pagination override (APPENDED LAST)
   Supersedes every earlier statement print rule for .stmt-doc:
   * content flows, fills each A4 page, overflows naturally (no section
     is force-pushed onto a fresh page);
   * tables split at row boundaries and repeat their header;
   * headings/rows/totals keep together; the running head + foot repeat
     on every physical page.
   ===================================================================== */
@media print {
    /* ---- fluid pagination: never force a new page for a section ---- */
    .stmt-doc .print-section,
    .stmt-doc .st-section,
    .stmt-doc .print-section > div {
        page-break-before: auto !important;
        break-before: auto !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
    }
    .stmt-doc .print-section:first-child {
        page-break-before: auto !important;
        break-before: auto !important;
    }

    /* ---- sheet: clean continuous paper ---- */
    .stmt-doc {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        overflow: visible !important;
        background: #ffffff !important;
        font-size: 9pt;
        line-height: 1.45;
    }
    .stmt-doc * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* ---- running head / foot: repeat on every physical page ---- */
    .stmt-doc .stmt-print-head {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 11mm !important;
        padding: 0 12mm !important;
        background: #ffffff !important;
        border-bottom: 0.5pt solid #cbd5e1 !important;
        font-size: 7.5pt !important;
        color: #475569 !important;
        z-index: 20 !important;
    }
    .stmt-doc .stmt-print-head .ph-left { color: #0f172a !important; font-weight: 800 !important; text-transform: uppercase !important; letter-spacing: .04em !important; }
    .stmt-doc .stmt-print-head .ph-right { color: #334155 !important; font-weight: 700 !important; }
    .stmt-doc .stmt-print-foot {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 8px !important;
        position: fixed !important;
        bottom: 2mm !important;
        left: 20mm !important;
        right: 20mm !important;
        font-size: 6.5pt !important;
        color: #64748b !important;
        border-top: 0.5pt solid #cbd5e1 !important;
        padding-top: 2px !important;
        background: #ffffff !important;
        z-index: 20 !important;
    }
    .stmt-doc .stmt-print-foot .pf-center { text-align: center !important; }

    /* ---- vertical rhythm ---- */
    .stmt-doc .st-cover { padding: 3mm 4mm 4mm !important; }
    .stmt-doc .st-cover-band { height: 2.5pt !important; margin: 0 -4mm 3mm !important; }
    .stmt-doc .st-meta { margin: 3mm 4mm 0 !important; }
    .stmt-doc .st-section { padding: 3.5mm 4mm !important; }
    .stmt-doc .st-desc { font-size: 8pt !important; margin: -2px 0 8px !important; }
    .stmt-doc .st-note { font-size: 8pt !important; }

    /* ---- type scale ---- */
    .stmt-doc .st-title { font-size: 21pt !important; margin: 4px 0 0 !important; }
    .stmt-doc .st-subtitle { font-size: 10pt !important; }
    .stmt-doc .st-kicker { font-size: 8pt !important; }
    .stmt-doc .st-org-name { font-size: 14pt !important; }
    .stmt-doc .st-org-sub { font-size: 8.5pt !important; }
    .stmt-doc .st-org-contact { font-size: 7.5pt !important; }
    .stmt-doc .st-badge { padding: 4px 10px !important; }
    .stmt-doc .st-badge span:first-child { font-size: 6.5pt !important; }
    .stmt-doc .st-badge span:last-child { font-size: 8pt !important; }
    .stmt-doc .st-sec-label { font-size: 10.5pt !important; }
    .stmt-doc .st-sec-num { font-size: 8.5pt !important; min-width: 21px !important; height: 17px !important; }
    .stmt-doc .st-kpi-v { font-size: 11pt !important; }
    .stmt-doc .st-kpi-l { font-size: 6.8pt !important; }
    .stmt-doc .st-high-v { font-size: 10pt !important; }
    .stmt-doc .st-high-l { font-size: 6.2pt !important; }
    .stmt-doc .st-meta-cell { padding: 5.5px 10px !important; }
    .stmt-doc .st-meta-cell span { font-size: 6.8pt !important; }
    .stmt-doc .st-meta-cell b { font-size: 9pt !important; }

    /* ---- tables: repeat head, rows atomic, totals stay ---- */
    .stmt-doc table { width: 100% !important; border-collapse: collapse !important; }
    .stmt-doc thead { display: table-header-group !important; }
    .stmt-doc .st-table th,
    .stmt-doc .st-table td { padding: 2.2pt 4pt !important; font-size: 8pt !important; }
    .stmt-doc .st-table th { font-size: 7pt !important; }
    .stmt-doc .st-table-dir th,
    .stmt-doc .st-table-dir td { padding: 2pt 3.5pt !important; font-size: 7.5pt !important; }
    .stmt-doc .st-table-dir th { font-size: 6.8pt !important; }
    .stmt-doc .st-member .st-table td,
    .stmt-doc .st-member .st-table th { padding: 3pt 6pt !important; }
    .stmt-doc .st-member-head { padding: 5px 8px !important; }
    .stmt-doc .st-summary-table { font-size: 9.5pt !important; }
    .stmt-doc .st-summary-table td { padding: 6px 10px !important; }

    /* ---- keep-together ---- */
    .stmt-doc tr,
    .stmt-doc .st-row,
    .stmt-doc .st-total,
    .stmt-doc .st-total-net {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    .stmt-doc .st-sec-head,
    .stmt-doc .st-member-head,
    .stmt-doc .st-unalloc-head,
    .stmt-doc .st-col-head,
    .stmt-doc .st-panel-head {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }
    .stmt-doc .st-kpi-card,
    .stmt-doc .st-high-card,
    .stmt-doc .st-badge-pill,
    .stmt-doc .st-total-line,
    .stmt-doc .st-sig,
    .stmt-doc .st-sig-item {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    .stmt-doc .st-member,
    .stmt-doc .st-panel,
    .stmt-doc .st-unalloc,
    .stmt-doc .st-bars,
    .stmt-doc .st-rec-grid {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* ---- force intended multi-column layouts on paper ---- */
    .stmt-doc .st-cols-2 { grid-template-columns: 1fr 1fr !important; }
    .stmt-doc .st-rec-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .stmt-doc .st-kpi { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
    .stmt-doc .st-kpi-3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
    .stmt-doc .st-high { grid-template-columns: repeat(5, minmax(0, 1fr)) !important; }
    .stmt-doc .st-meta-grid { grid-template-columns: repeat(3, 1fr) !important; }
    .stmt-doc .st-sig { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; gap: 28px !important; margin-top: 6mm !important; }
    .stmt-doc .st-sig-line { height: 17mm !important; }
    .stmt-doc .st-end { margin-top: 5mm !important; }

    /* ---- restore colour accents for the new palete ---- */
    .stmt-doc .st-inc { color: #047857 !important; }
    .stmt-doc .st-exp { color: #b91c1c !important; }
    .stmt-doc .st-warn { color: #b45309 !important; }
    .stmt-doc .st-kpi-inc { color: #047857 !important; }
    .stmt-doc .st-kpi-exp { color: #b91c1c !important; }
    .stmt-doc .st-kpi-net { color: #1d4ed8 !important; }
    .stmt-doc .st-kpi-due { color: #b45309 !important; }
    .stmt-doc .st-mcode { color: #1d4ed8 !important; background: #eef4ff !important; }
}
/* Member financial position strip for print — compact and atomic. */
@media print {
    .stmt-doc .st-member-pos { grid-template-columns: 1fr 1fr 1fr !important; padding: 5px 10px 6px !important; page-break-inside: avoid !important; break-inside: avoid !important; }
    .stmt-doc .st-pos-item b { font-size: 9pt !important; margin-top: 1px !important; }
    .stmt-doc .st-pos-label { font-size: 6.4pt !important; }
    .stmt-doc .st-adv { color: #047857 !important; }
}
@media print {
    .stmt-doc .st-kpi.st-kpi-4 { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
}

/* =====================================================================
   STATEMENT - WHOLE-BLOCK PAGINATION (APPENDED LAST)
   When a logical block (cover, meta, member card, unallocated, panel,
   chart, grid, summary table, signatures) does not fit in the remaining
   page space, move the ENTIRE block to the next page instead of cutting
   it mid-way. Long tables (member directory) still split at row
   boundaries with repeating headers.
   ===================================================================== */
@media print {
    .stmt-doc .st-cover,
    .stmt-doc .st-meta,
    .stmt-doc .st-member,
    .stmt-doc .st-member-head,
    .stmt-doc .st-member-pos,
    .stmt-doc .st-unalloc,
    .stmt-doc .st-panel,
    .stmt-doc .st-bars,
    .stmt-doc .st-col,
    .stmt-doc .st-rec-grid,
    .stmt-doc .st-high,
    .stmt-doc .st-summary-table,
    .stmt-doc .st-verify,
    .stmt-doc .st-sig,
    .stmt-doc .st-end {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    .stmt-doc .st-member-head,
    .stmt-doc .st-sec-head {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }
    .stmt-doc tfoot {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    .stmt-doc td,
    .stmt-doc th,
    .stmt-doc p {
        orphans: 3 !important;
        widows: 3 !important;
    }
    .stmt-doc table,
    .stmt-doc tbody {
        -webkit-box-decoration-break: clone;
        box-decoration-break: clone;
    }
}

/* Prevent card-level overflow clipping from cutting content whenever a
   block must split across pages (member card, unallocated box, meta). */
@media print {
    .stmt-doc .st-member,
    .stmt-doc .st-member-head,
    .stmt-doc .st-unalloc,
    .stmt-doc .st-meta,
    .stmt-doc .st-panel,
    .stmt-doc .st-bars,
    .stmt-doc .st-col {
        overflow: visible !important;
    }
}
