/* ============================================================
   paper-scan.css — 纸质问卷识别（扫描件上传 / 归组 / 任务）
   ============================================================ */

.ps-root {
    max-width: 1440px;
    margin: 0 auto;
    padding: 22px 22px 42px;
    color: var(--text);
}
.ps-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.ps-head-left { display: flex; gap: 14px; align-items: flex-start; min-width: 0; }
.ps-title h1 {
    margin: 0;
    font-size: 24px;
    color: var(--primary-dark);
    letter-spacing: .2px;
}
.ps-title p { margin: 7px 0 0; font-size: 13px; color: var(--text-light); line-height: 1.65; }
.ps-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.ps-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;
}
.ps-btn:hover:not(:disabled) { border-color: var(--primary-light); color: var(--primary); transform: translateY(-1px); }
.ps-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.ps-btn-primary:hover:not(:disabled) { background: var(--primary-light); color: #fff; }
.ps-btn-cyan { background: #ecfeff; border-color: #67e8f9; color: #0e7490; }
.ps-btn-danger { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.ps-btn:disabled { opacity: .48; cursor: not-allowed; transform: none !important; }

.ps-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}
.ps-stat {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, .035);
}
.ps-stat b { display: block; font-size: 22px; color: var(--primary-dark); line-height: 1.2; }
.ps-stat span { font-size: 12px; color: #64748b; }

.ps-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; align-items: start; }
.ps-main { min-width: 0; display: grid; gap: 14px; }
.ps-side { display: grid; gap: 12px; position: sticky; top: 82px; }
.ps-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 13px;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.ps-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 16px;
    border-bottom: 1px solid #eef2f7;
    background: linear-gradient(180deg, #fff, #fbfdff);
}
.ps-card-head h2 { margin: 0; font-size: 15px; color: var(--primary-dark); }
.ps-card-head p { margin: 4px 0 0; font-size: 12px; color: #94a3b8; }
.ps-card-body { padding: 15px 16px; }

.ps-drop {
    border: 2px dashed #a5d8f5;
    background: linear-gradient(180deg, #f8fdff, #effaff);
    border-radius: 12px;
    padding: 28px 18px;
    text-align: center;
    transition: all .18s ease;
    cursor: pointer;
}
.ps-drop:hover, .ps-drop.drag {
    border-color: #06b6d4;
    background: #ecfeff;
    transform: translateY(-1px);
}
.ps-drop-icon { font-size: 34px; line-height: 1; }
.ps-drop h3 { margin: 9px 0 5px; font-size: 15px; color: #155e75; }
.ps-drop p { margin: 0; font-size: 12px; color: #64748b; line-height: 1.65; }
.ps-drop-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.ps-hidden-file { display: none; }

.ps-queue-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 16px 0 8px;
    font-size: 12px;
    color: #64748b;
}
.ps-queue { display: grid; gap: 7px; max-height: 360px; overflow: auto; }
.ps-file {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #eef2f7;
    border-radius: 9px;
    padding: 7px;
    background: #fbfdff;
}
.ps-file-thumb {
    width: 46px;
    height: 58px;
    flex: 0 0 auto;
    border-radius: 5px;
    border: 1px solid #e2e8f0;
    background: #f1f5f9;
    object-fit: cover;
}
.ps-file-info { min-width: 0; flex: 1; }
.ps-file-name { font-size: 12px; color: #334155; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-file-meta { margin-top: 3px; font-size: 11px; color: #94a3b8; }
.ps-file-status { font-size: 11px; padding: 3px 7px; border-radius: 999px; white-space: nowrap; }
.ps-file-status.pending, .ps-file-status.parsing { background: #f1f5f9; color: #64748b; }
.ps-file-status.ready { background: #eff6ff; color: #1d4ed8; }
.ps-file-status.uploading { background: #fef3c7; color: #92400e; }
.ps-file-status.uploaded { background: #ecfdf5; color: #047857; }
.ps-file-status.duplicate { background: #f5f3ff; color: #6d28d9; }
.ps-file-status.failed { background: #fef2f2; color: #b91c1c; }
.ps-file-x {
    border: 0;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 3px 5px;
}
.ps-file-x:hover { color: #b91c1c; }

.ps-empty { padding: 26px 16px; text-align: center; color: #94a3b8; font-size: 13px; }
.ps-group-list { display: grid; gap: 12px; }
.ps-group {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}
.ps-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 13px;
    background: #f8fafc;
    border-bottom: 1px solid #eef2f7;
}
.ps-group-id { font-size: 14px; font-weight: 700; color: #0f172a; word-break: break-all; }
.ps-group-sub { margin-top: 3px; font-size: 11px; color: #94a3b8; }
.ps-badge { font-size: 11px; padding: 4px 8px; border-radius: 999px; white-space: nowrap; }
.ps-badge.complete { background: #ecfdf5; color: #047857; }
.ps-badge.missing_pages { background: #fff7ed; color: #c2410c; }
.ps-badge.duplicate_pages { background: #fef3c7; color: #92400e; }
.ps-badge.template_mismatch { background: #fef2f2; color: #b91c1c; }
.ps-badge.review_required { background: #fef2f2; color: #b91c1c; }
.ps-badge.failed { background: #fef2f2; color: #991b1b; }
.ps-group-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: #64748b; padding: 8px 13px; border-bottom: 1px solid #f1f5f9; }
.ps-group-meta b { color: #334155; }
.ps-pages { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 8px; padding: 11px 13px; }
.ps-page {
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    overflow: hidden;
    background: #fff;
}
.ps-page img { width: 100%; height: 104px; object-fit: cover; background: #f1f5f9; display: block; }
.ps-page-body { padding: 7px; }
.ps-page-title { font-size: 12px; color: #334155; display: flex; justify-content: space-between; gap: 5px; }
.ps-page-meta { margin-top: 3px; font-size: 10.5px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-page-actions { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.ps-mini {
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 5px;
    padding: 3px 5px;
    font-size: 10.5px;
    color: #475569;
    cursor: pointer;
}
.ps-mini:hover { border-color: #7dd3fc; color: #0369a1; }
.ps-mini-danger:hover { border-color: #fca5a5; color: #b91c1c; }

.ps-anomaly-list { display: grid; gap: 7px; max-height: 420px; overflow: auto; }
.ps-anomaly {
    border: 1px solid #fecaca;
    background: #fff7f7;
    border-radius: 8px;
    padding: 8px 9px;
    font-size: 12px;
    color: #7f1d1d;
    line-height: 1.5;
}
.ps-anomaly code { font-size: 10.5px; background: #fee2e2; padding: 1px 4px; border-radius: 3px; }
.ps-anomaly small { display: block; margin-top: 2px; color: #9f1239; }

.ps-filter { display: flex; align-items: center; gap: 8px; padding: 0 0 10px; flex-wrap: wrap; }
.ps-filter label { font-size: 12px; color: #64748b; }
.ps-filter select { border: 1px solid var(--border); border-radius: 7px; padding: 6px 8px; font-size: 12px; background: #fff; }
.ps-task-table { width: 100%; min-width: 320px; border-collapse: collapse; font-size: 12px; }
.ps-task-table th, .ps-task-table td { border-bottom: 1px solid #eef2f7; padding: 7px 6px; text-align: left; vertical-align: top; white-space: nowrap; }
.ps-task-table th { color: #64748b; font-weight: 600; background: #f8fafc; }
.ps-task-table td { color: #334155; }
.ps-task-table .ps-task-actions { white-space: nowrap; }
.ps-empty-small { padding: 14px; text-align: center; color: #94a3b8; font-size: 12px; }

/* ---- OMR ---- */
.ps-select {
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 7px 8px;
    font-size: 12px;
    background: #fff;
    color: #475569;
}
.ps-omr-counts { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: #64748b; margin-bottom: 8px; }
.ps-omr-counts b { font-size: 15px; color: #334155; }
.ps-progress { height: 9px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.ps-progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #0891b2, #22c55e); transition: width .25s ease; }
.ps-omr-status { margin-top: 8px; min-height: 17px; font-size: 11.5px; color: #64748b; }
.ps-ocr-warning { margin-top: 8px; padding: 7px 9px; border: 1px solid #fde68a; background: #fffbeb; color: #92400e; border-radius: 7px; font-size: 11px; line-height: 1.5; }
.ps-omr-preview-head { margin: 13px 0 7px; font-size: 12px; font-weight: 600; color: #475569; border-top: 1px solid #eef2f7; padding-top: 11px; }
.ps-omr-result-list { display: grid; gap: 7px; max-height: 300px; overflow: auto; }
.ps-omr-result { border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 9px; background: #fbfdff; }
.ps-omr-result.review { border-color: #fecaca; background: #fff8f8; }
.ps-omr-result-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 12px; color: #334155; }
.ps-omr-answers { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.ps-answer { display: inline-flex; align-items: baseline; gap: 3px; background: #f1f5f9; border-radius: 5px; padding: 3px 6px; font-size: 11px; color: #334155; }
.ps-answer b { color: #0f172a; }
.ps-answer small { color: #64748b; }
.ps-omr-warnings { margin-top: 5px; font-size: 10.5px; color: #b91c1c; word-break: break-all; }

.ps-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(15, 23, 42, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.ps-modal {
    width: min(460px, 96vw);
    background: #fff;
    border-radius: 13px;
    box-shadow: 0 25px 80px rgba(2, 6, 23, .38);
    padding: 19px;
}
.ps-modal h2 { margin: 0 0 6px; font-size: 18px; color: var(--primary-dark); }
.ps-modal p { margin: 0 0 13px; color: #64748b; font-size: 12px; line-height: 1.6; }
.ps-field { margin-top: 10px; }
.ps-field label { display: block; font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 5px; }
.ps-input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 8px 9px;
    font-size: 13px;
    outline: none;
}
.ps-input:focus { border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56, 189, 248, .15); }
.ps-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid #eef2f7; }
.ps-dialog-error { display: none; margin-top: 9px; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 7px; padding: 8px 9px; font-size: 12px; line-height: 1.5; }
.ps-dialog-error.show { display: block; }
.ps-loading { min-height: 420px; display: flex; align-items: center; justify-content: center; gap: 9px; color: #64748b; font-size: 13px; }
.ps-spinner { width: 17px; height: 17px; border: 2px solid #cbd5e1; border-top-color: var(--primary); border-radius: 50%; animation: ps-spin .8s linear infinite; }
@keyframes ps-spin { to { transform: rotate(360deg); } }
.ps-help { font-size: 11.5px; line-height: 1.65; color: #94a3b8; }
.ps-help b { color: #475569; }
.ps-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 13px;
    padding: 10px 13px;
    border: 1px solid #bae6fd;
    background: #f0f9ff;
    border-radius: 10px;
    color: #0f172a;
    font-size: 12px;
}
.ps-context b { color: #0369a1; }
.ps-context-id { margin-left: 5px; color: #64748b; font-family: monospace; font-size: 11px; }
.ps-context-hint { color: #64748b; font-size: 11px; }
.ps-context .ps-mini { flex: 0 0 auto; background: #fff; }
.ps-list-tools { display: flex; align-items: center; margin-bottom: 10px; }
.ps-search { max-width: 340px; }
.ps-pager { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 12px; color: #64748b; }
.ps-pager .ps-mini { background: #fff; }
.ps-pager span { flex: 1; text-align: center; }
.ps-upload-progress { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.ps-upload-track { flex: 1; height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.ps-upload-bar { height: 100%; background: #2563eb; border-radius: 999px; transition: width .2s; }
.ps-upload-text { flex: 0 0 auto; font-size: 12px; color: #64748b; }
/* 大量条目时跳过屏幕外渲染（近似虚拟滚动） */
.ps-group { content-visibility: auto; contain-intrinsic-size: 1px 180px; }
.ps-group.collapsed { contain-intrinsic-size: 1px 96px; }
.ps-file { content-visibility: auto; contain-intrinsic-size: 1px 64px; }
.ps-workflow { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.ps-steps { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 8px; }
.ps-step { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px; border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; text-align: left; cursor: pointer; }
.ps-step:hover { border-color: #93c5fd; }
.ps-step.active { border-color: #2563eb; background: #eff6ff; box-shadow: 0 0 0 1px #2563eb inset; }
.ps-step-no { flex: 0 0 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #e2e8f0; color: #475569; font-weight: 700; font-size: 13px; }
.ps-step.active .ps-step-no { background: #2563eb; color: #fff; }
.ps-step-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ps-step-text b { font-size: 14px; color: #0f172a; }
.ps-step-text small { font-size: 11px; color: #64748b; }
.ps-step-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ps-review-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.ps-review-num { padding: 14px; border: 1px solid #e2e8f0; border-radius: 12px; background: #f8fafc; display: flex; flex-direction: column; gap: 3px; }
.ps-review-num b { font-size: 24px; color: #0f172a; }
.ps-review-num span { font-size: 12px; color: #64748b; }
.ps-review-num.warn b { color: #c2410c; }
.ps-review-list { border: 1px solid #eef2f7; border-radius: 10px; overflow: hidden; }
.ps-review-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid #eef2f7; font-size: 12px; }
.ps-review-row:last-child { border-bottom: 0; }
.ps-review-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #334155; }
.ps-review-actions { margin-top: 14px; text-align: right; }

@media (max-width: 1100px) {
    .ps-grid { grid-template-columns: 1fr; }
    .ps-workflow { grid-template-columns: 1fr; }
    .ps-steps { position: static; flex-direction: row; overflow-x: auto; }
    .ps-step { flex: 0 0 auto; min-width: 150px; }
    .ps-side { position: static; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
    .ps-root { padding: 14px 10px 28px; }
    .ps-head { display: block; }
    .ps-actions { justify-content: flex-start; margin-top: 12px; }
    .ps-stats { grid-template-columns: 1fr 1fr; }
    .ps-side { grid-template-columns: 1fr; }
    .ps-pages { grid-template-columns: 1fr 1fr; }
}
