/* 单据纸张预览与编辑 */

.paper-viewer { background: var(--surface-2); }
.paper-stack { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 22px 16px 28px; }
.paper-zoom { zoom: var(--zoom, 1); width: 176mm; flex: 0 0 auto; }
.doc-paper {
    width: 176mm;
    min-height: 250mm;
    background: #ffffff;
    color: #111827;
    padding: 8mm 8mm 7mm;
    box-sizing: border-box;
    font-family: var(--font-doc);
    box-shadow: 0 20px 50px -24px rgba(9, 20, 44, .4), 0 2px 6px rgba(9, 20, 44, .1);
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    position: relative;
}
.doc-title { text-align: center; font-size: 17.5px; font-weight: 700; letter-spacing: 1.2px; padding: 1px 0 6px; color: #0b1220; }
.doc-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 11px; padding: 4px 2px 6px; flex-wrap: wrap; color: #111827; }
.doc-meta-item { display: inline-flex; align-items: center; gap: 3px; min-width: 0; }
.doc-meta-item .party { max-width: 74mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 10.5px; }
.doc-table th, .doc-table td { border: 1px solid #1f2937; padding: 3.2px 4px; line-height: 1.36; vertical-align: middle; word-break: break-word; }
.doc-table th { background: #f4f5f7; font-weight: 700; text-align: center; height: 22px; font-size: 10.5px; }
.doc-table td.center { text-align: center; }
.doc-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.doc-table td.remark { font-size: 9.5px; line-height: 1.45; }
.doc-table tfoot td { font-weight: 700; background: #fafafa; }
.doc-table tfoot .total-label { text-align: center; letter-spacing: 2px; }
.doc-col-seq { width: 6%; }
.doc-col-name { width: 22%; }
.doc-col-spec { width: 18%; }
.doc-col-unit { width: 6%; }
.doc-col-qty { width: 8%; }
.doc-col-price { width: 12%; }
.doc-col-amount { width: 13%; }
.doc-col-fob { width: 10%; }
.doc-col-remark { width: 15%; }
.doc-sign { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-size: 11px; padding: 12px 8px 2px; }
.doc-sign .maker { min-width: 22mm; border-bottom: 1px solid #6b7280; text-align: center; padding: 0 6px 1px; }
.doc-note { font-size: 9.5px; color: #374151; padding: 7px 4px 0; white-space: pre-line; line-height: 1.55; }
.doc-foot { margin-top: auto; padding-top: 6px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.doc-page-no { font-size: 9px; color: #6b7280; letter-spacing: .3px; }
.doc-brand-mark { font-size: 8.5px; color: #9ca3af; letter-spacing: .6px; }

/* 查看器弹窗 */
.viewer-modal { max-width: 1120px; }
.viewer-head-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 4px; }
.viewer-body { padding: 0; background: var(--surface-2); }
.paper-scroll { max-height: calc(100vh - 210px); overflow: auto; background-image: radial-gradient(color-mix(in srgb, var(--text-3) 12%, transparent) 1px, transparent 1px); background-size: 16px 16px; }
.viewer-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* 编辑单据 */
.edit-doc { display: flex; flex-direction: column; gap: 16px; }
.edit-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.edit-items-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: auto; max-height: 430px; }
.edit-items { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 840px; font-size: 12px; }
.edit-items th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--text-3); font-size: 10.5px; font-weight: 650; padding: 9px 6px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.edit-items td { padding: 5px 5px; border-bottom: 1px solid var(--border); vertical-align: top; }
.edit-items tr:last-child td { border-bottom: 0; }
.edit-items .input { height: 32px; min-height: 32px; padding: 4px 8px; font-size: 12px; border-radius: 7px; }
.edit-items .cell-seq { width: 42px; text-align: center; color: var(--text-3); font-size: 11px; padding-top: 11px; }
.edit-items .col-name { min-width: 190px; }
.edit-items .col-spec { min-width: 150px; }
.edit-items .col-unit { width: 70px; }
.edit-items .col-qty { width: 80px; }
.edit-items .col-price { width: 100px; }
.edit-items .col-amount { width: 110px; }
.edit-items .col-fob { width: 100px; }
.edit-items .col-remark { min-width: 150px; }
.row-del { width: 28px; height: 28px; border-radius: 7px; border: 0; background: transparent; color: var(--text-3); display: grid; place-items: center; margin-top: 2px; }
.row-del:hover { background: var(--danger-soft); color: var(--danger); }
.row-del svg { width: 14px; height: 14px; }
.edit-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.edit-total { display: flex; align-items: center; gap: 18px; font-size: 12px; color: var(--text-3); }
.edit-total strong { color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.edit-total .amount { color: var(--primary); font-size: 18px; font-weight: 750; }
.viewer-loading { display: grid; place-items: center; min-height: 420px; color: var(--text-3); font-size: 12.5px; gap: 12px; }
.viewer-loading .spinner { width: 26px; height: 26px; border-width: 3px; color: var(--primary); }

@media (max-width: 860px) {
    .edit-grid { grid-template-columns: 1fr 1fr; }
    .edit-grid .field:first-child { grid-column: span 2; }
    .paper-stack { padding: 14px 8px 22px; }
}
@media (max-width: 560px) {
    .edit-grid { grid-template-columns: 1fr; }
    .edit-grid .field:first-child { grid-column: auto; }
    .doc-sign { font-size: 10px; }
}

/* 打印 */
@media print {
    @page { size: B5 portrait; margin: 0; }
    html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
    .print-root { display: block !important; }
    .print-root .paper-zoom { zoom: 1 !important; width: 176mm; }
    .print-root .doc-paper {
        box-shadow: none !important;
        border-radius: 0 !important;
        margin: 0 !important;
        width: 176mm;
        min-height: 250mm;
        page-break-after: always;
        break-after: page;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    .print-root .doc-paper:last-child { page-break-after: auto; break-after: auto; }
    .print-root .paper-stack { gap: 0; padding: 0; }
}
