*, *::before, *::after { box-sizing: border-box; }

.rectification-main [hidden] { display: none !important; }

.rectification-main {
    --rect-blue: #0849df;
    --rect-blue-soft: #edf4ff;
    --rect-ink: #172554;
    --rect-muted: #667085;
    --rect-line: #dbe4f1;
    display: grid;
    gap: 12px;
}

.report-setup,
.editor-shell,
.report-actions,
.report-preview-wrap,
.judgment-note {
    background: #fff;
    border: 1px solid var(--rect-line);
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(44, 72, 130, .06);
}

.report-setup { padding: 16px; }
.section-heading,
.issue-editor-head,
.issue-sidebar-head,
.report-actions,
.preview-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.section-heading h2,
.issue-editor-head h2,
.report-actions h2,
.judgment-note h2 { margin: 0; color: var(--rect-ink); font-size: 18px; }
.section-heading p,
.report-actions p { margin: 5px 0 0; color: var(--rect-muted); }
.save-state { color: #32715d; font-size: 13px; white-space: nowrap; }
.save-state.error { color: #b42318; }
.setup-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.setup-actions .tool-button { white-space: nowrap; }

.template-tabs { margin-top: 12px; }
.template-tabs .tool-step { min-height: 56px; }

.base-section { margin-top: 12px; }
.section-title { display: flex; align-items: center; gap: 9px; color: var(--rect-ink); font-weight: 700; }
.section-title i { color: var(--rect-blue); }
.section-title span { color: var(--rect-muted); font-size: 13px; font-weight: 400; }
.professional-caption { margin: 14px 0 0; color: var(--rect-muted); font-size: 13px; }

.base-grid,
.professional-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding-top: 10px;
}

.base-grid label,
.professional-grid label,
.full-field {
    display: grid;
    gap: 7px;
    color: #344054;
    font-size: 14px;
    font-weight: 700;
}

.base-grid input,
.professional-grid input,
.professional-grid select,
.professional-grid textarea,
.core-form textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cfd9e8;
    border-radius: 9px;
    background: #fff;
    color: #172554;
    font: inherit;
    font-weight: 400;
}

.base-grid input,
.professional-grid input,
.professional-grid select { min-height: 38px; padding: 8px 11px; }
.professional-grid textarea,
.core-form textarea { min-height: 88px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.base-grid input:focus,
.professional-grid input:focus,
.professional-grid select:focus,
.professional-grid textarea:focus,
.core-form textarea:focus { outline: 0; border-color: var(--rect-blue); box-shadow: 0 0 0 3px rgba(8, 73, 223, .1); }

.editor-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); overflow: hidden; }
.issue-sidebar { background: #f8faff; border-right: 1px solid var(--rect-line); min-width: 0; }
.issue-sidebar-head { padding: 12px 14px; border-bottom: 1px solid var(--rect-line); }
.issue-sidebar-head > div { display: grid; gap: 3px; }
.issue-sidebar-head strong { color: var(--rect-ink); }
.issue-sidebar-head span { color: var(--rect-muted); font-size: 12px; }
.icon-text-button { border: 0; background: transparent; color: var(--rect-blue); font-weight: 700; white-space: nowrap; cursor: pointer; }
.issue-list { display: grid; gap: 6px; padding: 10px; max-height: 780px; overflow-y: auto; }
.issue-tab { width: 100%; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 9px; align-items: start; padding: 11px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: #344054; text-align: left; cursor: pointer; }
.issue-tab:hover { background: #fff; border-color: var(--rect-line); }
.issue-tab.active { background: #fff; border-color: #9db9ff; box-shadow: 0 4px 12px rgba(8, 73, 223, .08); }
.issue-tab-number { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: #e7efff; color: var(--rect-blue); font-weight: 800; font-size: 12px; }
.issue-tab.active .issue-tab-number { background: var(--rect-blue); color: #fff; }
.issue-tab-copy { min-width: 0; }
.issue-tab-copy strong { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.issue-tab-copy span { display: block; margin-top: 4px; color: var(--rect-muted); font-size: 11px; }

.issue-editor { min-width: 0; padding: 16px; }
.issue-editor-head { padding-bottom: 12px; border-bottom: 1px solid #e8edf5; }
.issue-editor-head > div > span { color: var(--rect-blue); font-size: 13px; font-weight: 800; }
.issue-editor-head h2 { margin-top: 3px; }
.danger-text { border: 0; background: transparent; color: #b42318; font-weight: 700; cursor: pointer; }
.core-form { display: grid; gap: 12px; padding-top: 14px; }
.required-marker { color: #b42318; font-size: 14px; }

.photo-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.photo-panel { min-width: 0; padding: 10px 12px; border: 1px solid var(--rect-line); border-radius: 10px; background: #fbfcff; }
.photo-title { display: flex; justify-content: space-between; gap: 12px; color: var(--rect-ink); font-weight: 700; }
.photo-title small { color: var(--rect-muted); font-weight: 400; }
.photo-upload { width: 100%; min-height: 52px; margin-top: 8px; border: 1px dashed #92abe1; border-radius: 9px; background: #f4f7ff; color: var(--rect-blue); cursor: pointer; }
.photo-upload:disabled { border-style: solid; border-color: var(--rect-line); background: #f2f4f9; color: var(--rect-muted); cursor: not-allowed; }
.photo-upload i { margin-right: 7px; }
.photo-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 9px; }
.photo-item { position: relative; overflow: hidden; min-width: 0; border: 1px solid var(--rect-line); border-radius: 8px; background: #fff; }
.photo-item img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-item figcaption { padding: 5px 6px; overflow: hidden; color: var(--rect-muted); font-size: 11px; white-space: nowrap; text-overflow: ellipsis; }
.photo-controls { position: absolute; top: 4px; right: 4px; display: flex; gap: 3px; }
.photo-controls button { display: grid; place-items: center; width: 25px; height: 25px; padding: 0; border: 0; border-radius: 6px; background: rgba(15, 23, 42, .78); color: #fff; cursor: pointer; }

.professional-grid label.wide { grid-column: span 3; }

.attachment-panel { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--rect-line); border-radius: 10px; background: #fbfcff; }
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 9px; }
.attachment-item { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 6px 9px; border: 1px solid var(--rect-line); border-radius: 8px; background: #fff; color: #344054; font-size: 12px; }
.attachment-item img { width: 28px; height: 28px; object-fit: cover; border-radius: 4px; }
.attachment-item > i { color: var(--rect-blue); }
.attachment-item span { max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.attachment-item button { color: var(--rect-muted); }
.attachment-hint { margin: 12px 0 0; color: var(--rect-muted); font-size: 13px; line-height: 1.6; }

.measure-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.measure-actions-note { color: var(--rect-muted); font-size: 12px; }
.gate-row { display: grid; grid-template-columns: auto 110px minmax(0, 1fr); gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px solid #edf1f7; color: #475467; line-height: 1.6; }
.gate-row:last-child { border-bottom: 0; }
.gate-row b { color: var(--rect-ink); }
.gate-row .pass { color: #147a55; }
.gate-row .warning { color: #9a4d00; }
.gate-row .fail { color: #b42318; }
.report-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.form-error { margin-top: 8px; padding: 10px 12px; border-radius: 8px; background: #fff0ee; color: #b42318; }

.gate-point { margin-top: 4px; padding-left: 10px; border-left: 2px solid #f3cdc8; color: #475467; font-size: 13px; line-height: 1.55; }

.history-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 10px 0; border-bottom: 1px solid #edf1f7; }
.history-row:last-child { border-bottom: 0; }
.history-row b { color: var(--rect-ink); grid-column: 1 / -1; }
.history-row > span { color: #475467; font-size: 13px; }
.history-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }

.report-actions { padding: 14px 16px; }
.report-preview-wrap { padding: 14px; }
.preview-toolbar { margin-bottom: 12px; }
.report-paper { width: 210mm; max-width: 100%; margin: 0 auto; background: #fff; color: #000; border: 1px solid #d9dee8; box-shadow: 0 12px 36px rgba(23,37,84,.12); font-family: "FangSong", "仿宋", serif; font-size: 16pt; line-height: 28.95pt; overflow-wrap: anywhere; }
.report-cover, .report-body { box-sizing: border-box; padding: 37mm 26mm 35mm 28mm; }
.report-cover { min-height: 297mm; border-bottom: 1px solid #d9dee8; }
.report-paper h1 { color: #000; font-family: "SimSun", "宋体", serif; font-size: 22pt; font-weight: 700; line-height: 1.5; margin: 0 0 28.95pt; text-align: center; break-after: avoid; }
.report-cover h1 { margin-top: 52.8mm; font-size: 32pt; line-height: 44.8pt; }
.report-paper p { margin: 0; text-indent: 2em; text-align: justify; orphans: 2; widows: 2; }
.report-cover p { text-align: center; text-indent: 0; }
.report-cover .report-cover-company { margin-top: 70.5mm; }
.report-cover .report-cover-date { margin-top: 10pt; }
.report-paper h2, .report-paper h3 { margin: 0; font-size: 16pt; line-height: inherit; text-indent: 2em; font-weight: 400; break-after: avoid; }
.report-paper h2 { font-family: "SimHei", "黑体", serif; }
.report-paper h3 { font-family: "KaiTi", "楷体", serif; }
.report-paper .report-recipient { text-indent: 0; }
.report-paper .report-attachment-list { text-indent: 4em; }
.report-paper .report-attachment-list-first { margin-top: 28.95pt; text-indent: 2em; }
.report-paper .report-sign { margin: 28.95pt 0 0 auto; width: 100%; break-inside: avoid; }
.report-sign p { text-indent: 0; }
.report-sign .report-sign-person { text-align: right; padding-right: 32pt; }
.report-sign .report-sign-company { text-align: center; width: 55.1%; margin: 28.95pt 0 0 auto; }
.report-sign .report-sign-date { text-align: right; padding-right: 4em; }
.report-sign .report-sign-stamp { text-align: center; width: 55.1%; margin-left: auto; font-size: 12pt; line-height: 18pt; }
.report-closing { break-inside: avoid; }
.report-paper .report-attachment-heading { margin-top: 37mm; break-before: page; }
.report-record-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14pt; line-height: 22pt; }
.report-record-table td { padding: 5pt; border: .5pt solid #d9d9d9; vertical-align: top; color: #000 !important; }
.report-record-table td:first-child { width: 23%; }
.report-photo-group { margin-bottom: 28.95pt; }
.report-paper .evidence-grid { display: table; width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 14pt; line-height: 22pt; }
.report-paper .evidence-grid figure { display: table-cell; width: 50%; padding: 5pt; margin: 0; vertical-align: top; border: .5pt solid #d9d9d9; text-align: center; }
.report-paper .evidence-grid p { text-align: center; text-indent: 0; }
.report-photo { display: block; max-width: 100%; max-height: 50.3mm; width: auto; height: auto; margin: 5pt auto; }
.report-attachment-page { text-align: center; break-inside: avoid; }
.report-attachment-image { max-width: 100%; max-height: 185.2mm; width: auto; height: auto; }
.report-new-page { break-before: page; }
.judgment-note { padding: 12px 14px; }
.judgment-note p { margin: 6px 0 0; color: var(--rect-muted); line-height: 1.7; }

@media (max-width: 980px) {
    .editor-shell { grid-template-columns: 1fr; }
    .issue-sidebar { border-right: 0; border-bottom: 1px solid var(--rect-line); }
    .issue-list { display: flex; overflow-x: auto; }
    .issue-tab { min-width: 190px; }
    .base-grid,
    .professional-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .professional-grid label.wide { grid-column: span 2; }
    .report-actions { align-items: flex-start; flex-direction: column; }
    .report-buttons { justify-content: flex-start; }
}

@media (max-width: 640px) {
    .section-heading { align-items: flex-start; }
    .setup-actions { align-items: flex-end; flex-direction: column; gap: 8px; }
    .report-setup,
    .issue-editor { padding: 16px; }
    .base-grid,
    .professional-grid,
    .photo-pair { grid-template-columns: 1fr; }
    .professional-grid label.wide { grid-column: span 1; }
    .photo-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .issue-editor-head { align-items: flex-start; }
    .danger-text { font-size: 12px; }
    .report-buttons { width: 100%; }
    .report-buttons button { width: 100%; justify-content: center; }
    .report-cover, .report-body { padding: 24px 18px; }
    .report-cover { min-height: 850px; }
}

@media print {
    body { margin: 0 !important; background: #fff !important; }
    .rectification-page > .header,
    .rectification-main > :not(.report-preview-wrap),
    .preview-toolbar,
    .rectification-page > .footer,
    .rectification-page > .tool-meta { display: none !important; }
    .main,
    .rectification-main,
    .report-preview-wrap { display: block !important; width: 100% !important; max-width: none !important; margin: 0 !important; padding: 0 !important; border: 0 !important; box-shadow: none !important; }
    .report-paper { width: 100%; min-height: 0; margin: 0; padding: 0; border: 0; box-shadow: none; }
    .report-cover { page: rectification-cover; width: 210mm; min-height: 297mm; border: 0; padding: 37mm 26mm 35mm 28mm; break-after: page; }
    .report-body { page: rectification-body; padding: 0; }
    .report-paper .report-attachment-heading { margin-top: 0; }
    .report-preview-wrap[hidden] { display: none !important; }

}

@page rectification-cover { size: A4; margin: 0; counter-reset: page 0; }
@page rectification-body {
    size: A4; margin: 37mm 26mm 35mm 28mm;
    @top-left { content: none; }
    @top-center { content: none; }
    @top-right { content: none; }
    @bottom-left { content: none; }
    @bottom-center { content: none; }
    @bottom-right { content: none; }
}
/* 封面占第一个物理页，正文第 1 页位于物理左页。 */
@page rectification-body:left {
    @bottom-right { content: "— " counter(page) " —　"; font: 14pt "SimSun", "宋体", serif; color: #000; vertical-align: top; padding-top: 4.3mm; padding-right: 14pt; }
}
@page rectification-body:right {
    @bottom-left { content: "　— " counter(page) " —"; font: 14pt "SimSun", "宋体", serif; color: #000; vertical-align: top; padding-top: 4.3mm; }
}
