/* ==================== A4 DOCUMENT TEMPLATES (FOR PDF & PRINT) ==================== */
.doc-page {
    width: 794px;
    min-height: auto;
    background: #ffffff;
    color: #111827;
    font-family: Arial, 'Plus Jakarta Sans', Helvetica, sans-serif;
    font-size: 11.5px;
    line-height: 1.44;
    position: relative;
    overflow: visible;
    padding: 0 40px 28px;
    box-sizing: border-box;
}

.doc-page-compact {
    min-height: auto;
    padding-bottom: 26px;
}

/* Kop Surat PT Enam Visi Anugerah (Matches Quotation PDF) */
.kop-eva {
    position: relative;
    margin: 0 -40px 12px;
    padding: 14px 40px 6px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    min-height: 94px;
}
.kop-eva-wave {
    position: absolute;
    top: 0;
    right: 0;
    width: 450px;
    height: 78px;
    pointer-events: none;
}
.kop-eva-logo-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
}
.kop-eva-logo-block img {
    height: 62px;
    width: auto;
    object-fit: contain;
}
.kop-eva-logo-block .kop-company-caption {
    margin-top: 3px;
    font-size: 10.5px;
    font-weight: 800;
    color: #374151;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

/* Quotation Layout */
.q-meta-grid {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 12px;
}
.q-to { flex: 1.15; }
.q-info { flex: 0.95; }
.q-info-table { width: 100%; border-collapse: collapse; }
.q-info-table td { padding: 1.5px 4px; vertical-align: top; }
.q-info-table td:first-child { width: 96px; font-weight: 600; }

.q-specs-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 18px;
    margin: 6px 0 10px;
    padding: 7px 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 11px;
}
.q-spec-item {
    display: flex;
    gap: 4px;
    line-height: 1.35;
}
.q-spec-item strong { color: #0f2942; white-space: nowrap; }

.q-table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 12px;
}
.q-table th, .q-table td {
    border: 1px solid #9ca3af;
    padding: 6px 8px;
    text-align: left;
    font-size: 11.2px;
}
.q-table th {
    background: #f3f4f6;
    font-weight: 700;
    color: #111827;
}
.q-table .tr { text-align: right; }
.q-table .tc { text-align: center; }

/* Bottom 2-column section: Terms (left) + Signature & Stamp (right) */
.q-bottom-split {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 22px;
    margin-top: 10px;
}
.q-bottom-terms {
    flex: 1.65;
    min-width: 0;
}
.q-bottom-sig {
    flex: 0.85;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 10px 12px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #fcfcfd;
}

.q-terms {
    margin-top: 4px;
    font-size: 10.4px;
    white-space: pre-line;
    line-height: 1.42;
    color: #1f2937;
}
.q-closing {
    margin-top: 8px;
    font-size: 10.8px;
    white-space: pre-line;
    line-height: 1.4;
    color: #374151;
}

/* Signature & Stamp Block */
.sig-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    position: relative;
    page-break-inside: avoid;
}
.sig-img-wrap {
    position: relative;
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 4px 0;
}
.sig-img-wrap img {
    height: 90px;
    width: auto;
    object-fit: contain;
}
.sig-name {
    font-weight: 700;
    font-size: 12px;
    color: #111827;
    border-top: 1px solid #374151;
    padding-top: 3px;
    min-width: 150px;
}
.sig-title {
    font-style: italic;
    font-size: 11px;
    color: #374151;
}

/* ==================== SALES INVOICE LAYOUT (Matches Sales Invoice PDF) ==================== */
.inv-page {
    padding: 34px 40px 38px;
}
.inv-top {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 16px;
}
.inv-left-col { flex: 1.1; }
.inv-right-col { width: 320px; }

.inv-company-box {
    border: 1px solid #6b7280;
    border-radius: 6px;
    padding: 8px 12px;
    margin-left: 62px;
    margin-bottom: 14px;
    position: relative;
    min-height: 66px;
}
.inv-company-logo-left {
    position: absolute;
    left: -62px;
    top: 2px;
    width: 52px;
    height: 62px;
    object-fit: contain;
}
.inv-company-box .inv-comp-name {
    font-weight: 800;
    font-size: 12.5px;
    border-bottom: 1px dotted #9ca3af;
    padding-bottom: 3px;
    margin-bottom: 4px;
    color: #111827;
}
.inv-company-box .inv-comp-addr {
    font-size: 11px;
    line-height: 1.4;
    white-space: pre-line;
    color: #1f2937;
}

.inv-party-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.inv-party-label {
    width: 62px;
    font-size: 11px;
    color: #374151;
    padding-top: 4px;
    flex-shrink: 0;
}
.inv-party-box {
    flex: 1;
    border: 1px solid #6b7280;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 11.2px;
    line-height: 1.4;
    min-height: 52px;
}
.inv-party-box strong { display: block; font-size: 11.8px; margin-bottom: 2px; }

.inv-title {
    font-size: 28px;
    font-weight: 400;
    text-align: right;
    color: #1f2937;
    margin: 0 0 6px;
    letter-spacing: 0.3px;
}
.inv-meta-box {
    border: 1px solid #6b7280;
    border-radius: 6px;
    overflow: hidden;
}
.inv-meta-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}
.inv-meta-table td {
    border-bottom: 1px dotted #9ca3af;
    border-right: 1px dotted #9ca3af;
    padding: 5px 8px;
    width: 50%;
    vertical-align: top;
}
.inv-meta-table tr:last-child td { border-bottom: none; }
.inv-meta-table td:last-child { border-right: none; }
.inv-meta-lbl { font-size: 10.5px; color: #4b5563; display: block; margin-bottom: 2px; }
.inv-meta-val { font-size: 11.5px; font-weight: 600; text-align: center; display: block; color: #111827; }

.inv-items-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #374151;
    margin-bottom: 10px;
}
.inv-items-table th {
    border: 1px solid #374151;
    padding: 6px 7px;
    font-size: 11.5px;
    font-weight: 600;
    background: #f8fafc;
    text-align: center;
}
.inv-items-table td {
    border-left: 1px solid #374151;
    border-right: 1px solid #374151;
    padding: 6px 7px;
    font-size: 11.5px;
    vertical-align: top;
}
.inv-items-spacer td {
    height: 110px;
}

.inv-bottom-grid {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}
.inv-bottom-left { flex: 1.25; }
.inv-bottom-right { width: 260px; }

.inv-say-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    margin-bottom: 12px;
}
.inv-say-lbl { font-size: 11.5px; padding-top: 6px; width: 38px; flex-shrink: 0; }
.inv-say-box {
    flex: 1;
    border: 1px solid #6b7280;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 11.5px;
    font-style: italic;
    min-height: 32px;
}

.inv-sig-desc-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.inv-sig-col {
    width: 165px;
    text-align: left;
    position: relative;
}
.inv-sig-col .inv-sig-company {
    font-size: 11.5px;
    font-weight: 600;
    margin-bottom: 2px;
}
.inv-sig-col .inv-sig-img {
    height: 94px;
    width: auto;
    object-fit: contain;
    display: block;
    margin: -6px 0 -8px -4px;
}
.inv-sig-col .inv-sig-line {
    border-top: 1px solid #374151;
    padding-top: 3px;
    font-size: 11.5px;
    font-weight: 600;
}
.inv-desc-col {
    flex: 1;
    border: 1px solid #6b7280;
    border-radius: 6px;
    padding: 8px 10px;
    min-height: 92px;
    font-size: 11px;
    white-space: pre-line;
}
.inv-desc-title {
    font-size: 10.5px;
    color: #4b5563;
    font-weight: 700;
    margin-bottom: 3px;
}

.inv-totals-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.inv-total-row {
    border: 1px solid #6b7280;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    padding: 5px 10px;
    font-size: 11.5px;
}
.inv-total-row.grand {
    border: 1.5px solid #111827;
    font-weight: 800;
    font-size: 12.5px;
    background: #f8fafc;
}
.inv-status-stamp {
    margin-top: 10px;
    display: inline-block;
    padding: 4px 12px;
    border: 2px solid #059669;
    color: #059669;
    font-weight: 800;
    font-size: 12px;
    border-radius: 6px;
    letter-spacing: 1px;
}
.inv-status-stamp.unpaid {
    border-color: #d97706;
    color: #d97706;
}

/* ==================== SURAT JALAN LAYOUT ==================== */
.sj-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #0f2942;
    padding: 24px 0 12px;
    margin-bottom: 16px;
}
.sj-brand { display: flex; align-items: center; gap: 14px; }
.sj-brand img { height: 64px; width: auto; object-fit: contain; }
.sj-brand h1 { margin: 0; font-size: 17px; font-weight: 800; color: #0f2942; }
.sj-brand p { margin: 2px 0 0; font-size: 11px; color: #4b5563; white-space: pre-line; line-height: 1.35; }
.sj-badge-title {
    text-align: right;
}
.sj-badge-title h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    color: #0f2942;
    letter-spacing: 1px;
}
.sj-badge-title span {
    display: inline-block;
    margin-top: 4px;
    background: #fff7ed;
    color: #ea580c;
    border: 1px solid #fdba74;
    padding: 2px 10px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 11.5px;
}
.sj-sign-grid {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-top: 28px;
    page-break-inside: avoid;
}
.sj-sign-col {
    width: 220px;
    text-align: center;
}
.sj-sign-col .sj-sign-space {
    height: 92px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sj-sign-col .sj-sign-space img {
    height: 90px;
    width: auto;
    object-fit: contain;
}
.sj-sign-col .sj-sign-line {
    border-top: 1px solid #374151;
    padding-top: 4px;
    font-weight: 700;
    font-size: 12px;
}

/* ==================== LAPORAN KEUANGAN PDF ==================== */
.fin-summary-pdf {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 14px 0 18px;
}
.fin-box-pdf {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 12px;
    background: #f8fafc;
}
.fin-box-pdf span { font-size: 11px; color: #475569; display: block; }
.fin-box-pdf strong { font-size: 15px; display: block; margin-top: 4px; }

/* ==================== PRINT MEDIA RULES ==================== */
.print-only-container { display: none; }

@media print {
    @page { size: A4 portrait; margin: 0; }
    body > *:not(#print-only-container) { display: none !important; }
    #print-only-container {
        display: block !important;
        width: 100%;
        background: #fff;
    }
    .doc-page {
        width: 100%;
        min-height: auto;
        box-shadow: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
