/* ============================================================
   paper.css — A4 纸质版预览
   ============================================================ */

.dz-btn-paper {
    border-color: rgba(34, 211, 238, 0.55);
    color: #0e7490;
    background: rgba(236, 254, 255, 0.9);
}
.dz-btn-paper:hover {
    background: #ecfeff;
    border-color: #06b6d4;
}

.pp-root {
    max-width: 1560px;
    margin: 0 auto;
    padding: 22px 22px 40px;
    color: var(--text);
}

.pp-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.pp-head-left {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
}

.pp-back {
    margin-top: 3px;
    white-space: nowrap;
}

.pp-title-wrap h1 {
    margin: 0;
    font-size: 24px;
    line-height: 1.25;
    color: var(--primary-dark);
    letter-spacing: 0.2px;
}

.pp-sub {
    margin: 7px 0 0;
    color: var(--text-light);
    font-size: 13px;
    line-height: 1.65;
    word-break: break-all;
}

.pp-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.pp-btn {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    transition: all .18s ease;
    white-space: nowrap;
}
.pp-btn:hover:not(:disabled) {
    border-color: var(--primary-light);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(44, 62, 122, .10);
}
.pp-btn-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
.pp-btn-primary:hover:not(:disabled) {
    background: var(--primary-light);
    color: #fff;
}
.pp-btn-cyan {
    border-color: #0891b2;
    background: #ecfeff;
    color: #0e7490;
}
.pp-btn-danger {
    border-color: #fca5a5;
    background: #fef2f2;
    color: #b91c1c;
}
.pp-btn:disabled,
.pp-btn[aria-disabled="true"] {
    opacity: .48;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.pp-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    border-radius: 999px;
    padding: 5px 10px;
    border: 1px solid transparent;
    margin-top: 8px;
}
.pp-badge-ok {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}
.pp-badge-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}
.pp-badge-warn {
    background: #fffbeb;
    border-color: #fde68a;
    color: #b45309;
}

/* ---- 顶部异常提示 ---- */
.pp-alert {
    border-radius: 12px;
    padding: 14px 16px;
    margin: 0 0 16px;
    border: 1px solid transparent;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .04);
}
.pp-alert-error {
    background: #fff1f2;
    border-color: #fecdd3;
}
.pp-alert-warn {
    background: #fffbeb;
    border-color: #fde68a;
}
.pp-alert-ok {
    background: #ecfdf5;
    border-color: #a7f3d0;
}
.pp-alert-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-weight: 700;
    font-size: 14px;
    color: #7f1d1d;
}
.pp-alert-warn .pp-alert-head { color: #92400e; }
.pp-alert-ok .pp-alert-head { color: #047857; }
.pp-alert-note {
    margin: 6px 0 0;
    font-size: 12px;
    color: #7f1d1d;
    opacity: .8;
}
.pp-issue-list {
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 6px;
    max-height: 165px;
    overflow: auto;
}
.pp-issue {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    text-align: left;
    border: 1px solid rgba(185, 28, 28, .14);
    background: rgba(255, 255, 255, .72);
    border-radius: 8px;
    padding: 7px 9px;
    cursor: pointer;
    color: #7f1d1d;
    font-size: 12px;
    line-height: 1.45;
}
.pp-issue:hover { background: #fff; border-color: rgba(185, 28, 28, .35); }
.pp-issue-code {
    flex: 0 0 auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10.5px;
    background: rgba(185, 28, 28, .08);
    border-radius: 4px;
    padding: 2px 5px;
}
.pp-issue-page {
    flex: 0 0 auto;
    font-size: 11px;
    opacity: .75;
}

/* ---- 主体布局 ---- */
.pp-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 18px;
    align-items: start;
}
.pp-stage-card {
    background: linear-gradient(180deg, #f8fbff 0%, #eef5fb 100%);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.pp-stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 15px;
    background: rgba(255, 255, 255, .84);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.pp-page-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.pp-page-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 9px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
}
.pp-page-btn:hover:not(:disabled) { border-color: var(--primary-light); color: var(--primary); }
.pp-page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.pp-page-btn:disabled { opacity: .4; cursor: not-allowed; }
.pp-zoom-label {
    font-size: 12px;
    color: var(--text-light);
    min-width: 42px;
    text-align: right;
}
.pp-stage-hint {
    font-size: 12px;
    color: var(--text-light);
}
.pp-sheet-area {
    display: flex;
    justify-content: center;
    padding: 22px 18px 26px;
    min-height: 520px;
    overflow: auto;
    background-image:
        linear-gradient(rgba(44, 62, 122, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(44, 62, 122, .035) 1px, transparent 1px);
    background-size: 22px 22px;
}
.pp-sheet-scaler {
    position: relative;
    flex: 0 0 auto;
    margin: 0 auto;
}
.pp-paper {
    position: absolute;
    left: 0;
    top: 0;
    width: 210mm;
    height: 297mm;
    background: #fff;
    color: #111;
    box-shadow: 0 14px 40px rgba(15, 23, 42, .22), 0 0 0 1px rgba(15, 23, 42, .10);
    transform-origin: top left;
    overflow: hidden;
    font-family: "Source Han Sans SC", "Source Han Sans CN", "DengXian", "Microsoft YaHei", "Noto Sans SC", "PingFang SC", sans-serif;
}
.pp-layer {
    position: absolute;
    box-sizing: border-box;
    pointer-events: none;
}

/* ---- 安全边距 ---- */
.pp-safe {
    border: 0.32mm dashed #ef4444;
    background: rgba(239, 68, 68, .018);
    z-index: 1;
}
.pp-safe::after {
    content: "safe_margin 10mm";
    position: absolute;
    right: 1.5mm;
    top: -4.4mm;
    font-size: 6.5pt;
    color: #dc2626;
    background: #fff;
    padding: 0 1mm;
}

/* ---- ArUco / QR ---- */
.pp-aruco {
    border: 0.25mm solid #020617;
    background:
        repeating-linear-gradient(45deg, #111827 0, #111827 1.55mm, #f8fafc 1.55mm, #f8fafc 3.1mm);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9;
    font-size: 7pt;
    font-weight: 700;
}
.pp-aruco span {
    background: rgba(15, 23, 42, .82);
    border-radius: 1mm;
    padding: 0.3mm 1mm;
}
.pp-qr {
    border: 0.3mm dashed #2563eb;
    background:
        repeating-linear-gradient(90deg, rgba(37, 99, 235, .12) 0, rgba(37, 99, 235, .12) 1.2mm, transparent 1.2mm, transparent 2.4mm),
        repeating-linear-gradient(0deg, rgba(37, 99, 235, .10) 0, rgba(37, 99, 235, .10) 1.2mm, transparent 1.2mm, transparent 2.4mm),
        rgba(239, 246, 255, .75);
    color: #1d4ed8;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9;
    font-size: 7pt;
    font-weight: 700;
    letter-spacing: .4px;
}
.pp-qr span { background: rgba(255, 255, 255, .88); padding: 0.3mm 1mm; border-radius: 1mm; }

/* ---- 题目 / 选项 ---- */
.pp-qbox {
    border: 0.22mm dashed rgba(124, 58, 237, .65);
    background: rgba(124, 58, 237, .025);
    z-index: 2;
}
.pp-qbox::before {
    content: attr(data-qid);
    position: absolute;
    left: 1mm;
    top: -3.9mm;
    font-size: 6.2pt;
    line-height: 1;
    color: #7c3aed;
    background: #fff;
    padding: 0 0.8mm;
}
.pp-marker {
    border: 0.3mm solid #111;
    background: transparent;
    z-index: 5;
}
.pp-label {
    z-index: 6;
    color: #111;
    font-size: 9.5pt;
    line-height: 4.5mm;
    white-space: pre;
    word-break: keep-all;
    overflow: visible;
}
.pp-anchor {
    z-index: 6;
    color: #333;
    font-size: 7.5pt;
    line-height: 3.8mm;
    white-space: nowrap;
    overflow: visible;
    width: max-content;
    transform: translateX(-50%);
    text-align: center;
}
.pp-roi {
    border: 0.24mm solid rgba(5, 150, 105, .92);
    background: rgba(16, 185, 129, .12);
    z-index: 7;
    pointer-events: auto;
    cursor: crosshair;
    transition: background .12s ease, box-shadow .12s ease;
}
.pp-roi:hover {
    background: rgba(16, 185, 129, .26);
    box-shadow: 0 0 0 0.7mm rgba(16, 185, 129, .18);
}
.pp-title {
    z-index: 4;
    color: #111;
    font-size: 9.5pt;
    line-height: 5mm;
    font-weight: 600;
    white-space: pre;
    word-break: keep-all;
    overflow: visible;
}
.pp-desc {
    z-index: 4;
    color: #374151;
    font-size: 7.5pt;
    line-height: 3.6mm;
    white-space: pre;
    word-break: keep-all;
    overflow: visible;
}
.pp-text-region {
    border: 0.3mm dashed #f59e0b;
    background: rgba(245, 158, 11, .08);
    z-index: 6;
    color: #b45309;
    font-size: 6.8pt;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 1.2mm;
}
.pp-print-header,
.pp-print-footer {
    position: absolute;
    left: 25mm;
    z-index: 4;
    color: #374151;
    font-size: 7pt;
    line-height: 1;
    pointer-events: none;
}
.pp-print-header { top: 28mm; font-size: 8pt; }
.pp-qid { position: absolute; left: 25mm; top: 24mm; font-size: 7pt; color: #111; }
.pp-paper-meta { position: absolute; left: 25mm; top: 29mm; width: 124mm; color: #111; }
.pp-paper-scale { font-size: 8pt; }
.pp-paper-title { font-size: 11pt; font-weight: 600; margin-top: 1mm; }
.pp-paper-inst { font-size: 7.5pt; color: #333; margin-top: 1mm; line-height: 1.35; }
.pp-paper-section { position: absolute; left: 25mm; top: 48mm; width: 160mm; color: #111; }
.pp-reverse-mark { position: absolute; right: 25mm; font-size: 7pt; color: #9a3412; background: #ffedd5; border: 1px solid #fed7aa; border-radius: 2mm; padding: 0.5mm 1.5mm; }
.pp-question-image { background-size: contain; background-repeat: no-repeat; background-position: center; }
.pp-matrix-head { display: flex; align-items: center; justify-content: center; font-size: 6.5pt; line-height: 3.2mm; text-align: center; white-space: normal; overflow: hidden; }
.pp-matrix-head-text { display: block; width: 100%; min-width: 0; white-space: normal; word-break: break-all; overflow-wrap: anywhere; text-align: center; }
.pp-matrix-title { display: flex; align-items: center; justify-content: center; font-size: 8pt; line-height: 4mm; white-space: normal; text-align: center; }
.pp-matrix-head-fill { background: #f2f6fa; }
.pp-matrix-grid { border: 0.22mm solid #aeb8c4; }
.pp-matrix-vline { border-left: 0.16mm solid #c4ccd6; }
.pp-matrix-rowline { border-top: 0.16mm solid #c4ccd6; }
.pp-section-title { font-size: 11pt; font-weight: 600; }
.pp-section-inst { font-size: 8pt; color: #333; margin-top: 1mm; line-height: 1.35; }
.pp-print-footer { top: 274.5mm; color: #6b7280; }

.pp-focus {
    animation: pp-focus-pulse 1.4s ease-in-out 2;
    outline: 0.8mm solid rgba(239, 68, 68, .75);
    outline-offset: 0.7mm;
}
@keyframes pp-focus-pulse {
    0%, 100% { outline-color: rgba(239, 68, 68, .22); }
    50% { outline-color: rgba(239, 68, 68, .95); }
}

/* ---- 右侧 ---- */
.pp-side {
    display: grid;
    gap: 12px;
    position: sticky;
    top: 82px;
}
.pp-panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .04);
    padding: 14px;
}
.pp-panel h3 {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--primary-dark);
    letter-spacing: .2px;
}
.pp-legend {
    display: grid;
    gap: 7px;
}
.pp-legend-row {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    color: #475569;
    line-height: 1.4;
}
.pp-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex: 0 0 auto;
    box-sizing: border-box;
}
.pp-swatch-safe { border: 2px dashed #ef4444; background: #fef2f2; }
.pp-swatch-aruco { background: #111827; }
.pp-swatch-qr { border: 2px dashed #2563eb; background: #eff6ff; }
.pp-swatch-qbox { border: 2px dashed #7c3aed; background: #f5f3ff; }
.pp-swatch-marker { border: 2px solid #111; background: #fff; }
.pp-swatch-roi { border: 2px solid #059669; background: rgba(16, 185, 129, .22); }
.pp-swatch-text { border: 2px dashed #f59e0b; background: rgba(245, 158, 11, .12); }
.pp-swatch-labels { border: 2px solid #334155; background: #f8fafc; }

.pp-toggles {
    display: grid;
    gap: 6px;
}
.pp-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #334155;
    padding: 4px 2px;
    cursor: pointer;
}
.pp-toggle input { width: 15px; height: 15px; accent-color: var(--primary); }
.pp-toggle .pp-swatch { width: 12px; height: 12px; }

.pp-pages {
    display: grid;
    gap: 5px;
    max-height: 230px;
    overflow: auto;
}
.pp-page-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 9px;
    border-radius: 7px;
    border: 1px solid transparent;
    background: #f8fafc;
    color: #334155;
    cursor: pointer;
    font-size: 12px;
}
.pp-page-link:hover { border-color: #bae6fd; background: #f0f9ff; }
.pp-page-link.active { border-color: #7dd3fc; background: #e0f2fe; color: #075985; }
.pp-page-link small { color: #94a3b8; font-size: 11px; }

.pp-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.pp-stat {
    background: #f8fafc;
    border: 1px solid #edf2f7;
    border-radius: 8px;
    padding: 8px 9px;
}
.pp-stat b { display: block; font-size: 18px; color: var(--primary-dark); line-height: 1.2; }
.pp-stat span { font-size: 11px; color: #64748b; }

/* ---- 提示 / 加载 / 致命错误 ---- */
.pp-tooltip {
    position: fixed;
    z-index: 99999;
    width: max-content;
    max-width: 340px;
    padding: 9px 11px;
    border-radius: 9px;
    background: #0f172a;
    color: #e2e8f0;
    font-size: 11.5px;
    line-height: 1.55;
    box-shadow: 0 12px 32px rgba(2, 6, 23, .30);
    pointer-events: none;
}
.pp-tooltip b { color: #fff; display: block; margin-bottom: 4px; font-size: 12.5px; }
.pp-tooltip code {
    color: #a5f3fc;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 10.5px;
    word-break: break-all;
}
.pp-tip-row { display: flex; gap: 7px; margin-top: 2px; }
.pp-tip-row span:first-child { color: #94a3b8; flex: 0 0 54px; }

.pp-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 480px;
    color: #64748b;
    font-size: 14px;
    gap: 10px;
}
.pp-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #cbd5e1;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: pp-spin .8s linear infinite;
}
@keyframes pp-spin { to { transform: rotate(360deg); } }

.pp-fatal {
    background: #fff;
    border: 1px solid #fecaca;
    border-radius: 14px;
    padding: 26px;
    box-shadow: var(--shadow);
}
.pp-fatal h2 { margin: 0 0 8px; color: #b91c1c; font-size: 20px; }
.pp-fatal p { color: #475569; line-height: 1.7; font-size: 13px; }
.pp-fatal code {
    display: inline-block;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    padding: 2px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11.5px;
}
.pp-fatal-issues {
    margin: 12px 0;
    padding-left: 18px;
    color: #7f1d1d;
    font-size: 12px;
    line-height: 1.7;
}

/* ---- PDF 对话框 ---- */
.pp-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.pp-modal {
    width: min(600px, 96vw);
    max-height: 92vh;
    overflow: auto;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 25px 80px rgba(2, 6, 23, .38);
    padding: 20px;
}
.pp-modal h2 {
    margin: 0 0 6px;
    font-size: 19px;
    color: var(--primary-dark);
}
.pp-modal-desc {
    margin: 0 0 14px;
    color: #64748b;
    font-size: 12.5px;
    line-height: 1.65;
}
.pp-field { margin-top: 13px; }
.pp-field > label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}
.pp-file-row {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap;
}
.pp-file-status {
    font-size: 11.5px;
    color: #64748b;
}
.pp-ids-textarea,
.pp-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 12.5px;
    color: #0f172a;
    background: #fff;
    outline: none;
}
.pp-ids-textarea {
    min-height: 120px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    line-height: 1.6;
}
.pp-ids-textarea:focus,
.pp-input:focus { border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56, 189, 248, .15); }
.pp-hint {
    font-size: 11.5px;
    color: #94a3b8;
    line-height: 1.55;
    margin-top: 6px;
}
.pp-count-row { display: flex; align-items: center; gap: 8px; }
.pp-count-row .pp-input { width: 150px; text-align: right; }
.pp-count-unit { font-size: 12px; color: #64748b; }
.pp-summary {
    margin-top: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 12px;
    color: #475569;
}
.pp-summary b { color: #0f172a; }
.pp-dialog-error {
    display: none;
    margin-top: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
}
.pp-dialog-error.show { display: block; }
.pp-dialog-status {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    color: #0369a1;
    font-size: 12px;
}
.pp-dialog-status.show { display: flex; }
.pp-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
    padding-top: 13px;
    border-top: 1px solid #eef2f7;
}

@media (max-width: 1120px) {
    .pp-body { grid-template-columns: 1fr; }
    .pp-side { position: static; grid-template-columns: 1fr 1fr; }
    .pp-panel:first-child { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
    .pp-root { padding: 14px 10px 28px; }
    .pp-head { display: block; }
    .pp-actions { justify-content: flex-start; margin-top: 12px; }
    .pp-title-wrap h1 { font-size: 20px; }
    .pp-side { grid-template-columns: 1fr; }
    .pp-sheet-area { padding: 14px 8px 20px; }
}
