* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #eef2ec;
    color: #1f261f;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.print-actions {
    width: min(920px, calc(100% - 28px));
    margin: 18px auto -10px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.print-actions a,
.print-actions button {
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid #2f7d4f;
    border-radius: 8px;
    background: #2f7d4f;
    color: #fff;
    text-decoration: none;
    font: inherit;
    font-weight: 900;
    cursor: pointer;
}

.print-shell,
.delivery-sheet {
    width: min(920px, calc(100% - 28px));
    margin: 24px auto;
    background: #fff;
    border: 1px solid #d9e0d2;
    border-radius: 8px;
}

.print-shell {
    padding: 28px;
}

.delivery-sheet {
    display: grid;
    gap: 0;
    padding: 12px;
}

.delivery-copy {
    min-height: 132mm;
    padding: 12px 14px;
    border: 1px solid #263a2a;
}

.delivery-copy + .delivery-copy {
    margin-top: 6px;
}

.compact-head,
.print-head,
.farmer-receipt header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    padding-bottom: 14px;
    border-bottom: 2px solid #213d2b;
}

.eyebrow {
    margin: 0 0 4px;
    color: #4c6b55;
    font-size: 0.82rem;
    font-weight: 800;
    letter-spacing: 0;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: clamp(2rem, 7vw, 3rem);
}

h2 {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.doc-no,
.copy-box {
    padding: 9px 11px;
    border: 1px solid #cfd8c8;
    border-radius: 6px;
    color: #324238;
    font-weight: 800;
    white-space: nowrap;
}

.copy-box {
    display: grid;
    gap: 4px;
    text-align: right;
}

.copy-box span {
    color: #607066;
    font-size: 0.82rem;
}

.info-grid,
.compact-info,
.receipt-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 16px 0;
}

.info-grid div,
.compact-info div,
.compact-address,
.address-block,
.note-block,
.error-card,
.farmer-receipt,
.amount-summary div {
    padding: 12px;
    border: 1px solid #dde4d7;
    border-radius: 8px;
    background: #fbfcfa;
}

.info-grid span,
.compact-info span,
.compact-address span,
.amount-summary span,
.receipt-grid span,
.delivery-footer span {
    display: block;
    margin-bottom: 5px;
    color: #607066;
    font-size: 0.78rem;
    font-weight: 800;
}

.info-grid strong,
.compact-info strong,
.compact-address strong,
.receipt-grid strong {
    overflow-wrap: anywhere;
}

.address-block,
.note-block {
    margin-bottom: 18px;
}

.address-block p,
.note-block p,
.delivery-footer p {
    margin-bottom: 4px;
    line-height: 1.45;
}

.print-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #cfd8c8;
    font-size: 0.92rem;
}

.print-table th,
.print-table td {
    padding: 7px 8px;
    border: 1px solid #dbe3d6;
    text-align: left;
    vertical-align: top;
}

.print-table th {
    color: #34433a;
    background: #eef3ea;
    font-size: 0.8rem;
}

.print-table .num {
    text-align: right;
    white-space: nowrap;
}

.empty-cell {
    color: #667568;
    text-align: center;
}

.delivery-table th:nth-child(2),
.delivery-table td:nth-child(2) {
    max-width: 120px;
    overflow-wrap: anywhere;
}

.amount-table {
    font-size: 0.86rem;
}

.delivery-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 190px;
    gap: 10px;
    margin-top: 10px;
}

.delivery-footer > div {
    min-height: 54px;
    padding: 10px;
    border: 1px solid #dbe3d6;
    border-radius: 8px;
}

.signature-box {
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.amount-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.amount-summary strong {
    display: block;
    text-align: right;
    font-size: 1.15rem;
}

.amount-summary .total {
    color: #183d2a;
    border-color: #a9c5ad;
    background: #eef7ef;
}

.farmer-receipt {
    margin-top: 22px;
    break-inside: avoid;
}

.farmer-receipt header {
    margin-bottom: 14px;
    padding-bottom: 10px;
}

.farmer-receipt h2 {
    margin: 0;
    font-size: 1.7rem;
}

.receipt-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
}

.receipt-grid .wide {
    grid-column: 1 / -1;
}

.receipt-table {
    margin-top: 12px;
    font-size: 0.84rem;
}

.monthly-statement-shell {
    width: min(980px, calc(100% - 28px));
}

.statement-total {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.statement-detail-row > td {
    background: #fbfcfa;
    padding: 8px;
}

.nested-table {
    font-size: 0.82rem;
    background: #fff;
}

.receipt-total-line {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid #cfd8c8;
    border-radius: 8px;
    background: #fbfcfa;
}

.receipt-total-line span {
    color: #607066;
    font-size: 0.82rem;
    font-weight: 800;
}

.receipt-total-line strong {
    font-size: 1.08rem;
}

.receipt-total-line em {
    font-style: normal;
    font-weight: 900;
}

.receipt-note {
    margin: 14px 0;
    color: #33433a;
    font-size: 0.8em;
}

.receipt-signatures {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.receipt-signatures div {
    min-height: 58px;
    padding: 30px 10px 10px 10px;
    border: 1px solid #cfd8c8;
    border-radius: 8px;
    color: #607066;
    font-weight: 800;
}
.receipt-signatures div.first {
    min-height: 6em;
    padding: 10px 10px 10px 10px;
}

.receipt-signatures .double {
    grid-column: span 2;
}

.error-card {
    text-align: center;
}

@media (max-width: 720px) {
    .print-shell,
    .delivery-sheet {
        width: 100%;
        min-height: 100vh;
        margin: 0;
        padding: 12px;
        border: 0;
        border-radius: 0;
    }

    .compact-head,
    .print-head,
    .delivery-footer,
    .farmer-receipt header {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .info-grid,
    .compact-info,
    .amount-summary,
    .receipt-grid,
    .receipt-signatures {
        grid-template-columns: 1fr 1fr;
    }

    .delivery-footer {
        display: grid;
    }

    .print-table {
        font-size: 0.82rem;
    }
}

@page {
    size: A4;
    margin: 6mm;
}

@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    body {
        background: #fff;
    }

    .print-actions {
        display: none;
    }

    .print-shell,
    .delivery-sheet {
        width: 100%;
        height: 285mm;
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        display: grid;
        grid-template-rows: 1fr 1fr;
        gap: 0;
    }

    .delivery-copy {
        min-height: 0;
        height: 142.5mm;
        padding: 5mm;
        page-break-inside: avoid;
        overflow: hidden;
    }

    .delivery-copy + .delivery-copy {
        margin-top: 0;
        border-top: 1px dashed #263a2a;
    }

    .compact-head {
        padding-bottom: 8px;
    }

    .compact-info {
        margin: 9px 0;
    }

    .compact-info div,
    .compact-address {
        padding: 7px;
    }

    .delivery-table {
        font-size: 9.5pt;
    }

    .delivery-table th,
    .delivery-table td {
        padding: 4px 5px;
    }

    .delivery-footer {
        margin-top: 6px;
    }

    .delivery-footer > div {
        min-height: 38px;
        padding: 6px;
    }

    .statement-shell {
        font-size: 11pt;
    }
}
