/* 报告文档：白底、一个强调色、细线、8px 间距体系的克制版面。屏幕与打印共用同一份样式。 */
.report-paper {
  --report-ink: #2c343b;
  --report-muted: #6b767d;
  --report-line: #e6e9ea;
  --report-accent: #d96543;
  --report-space: 8px;
  box-sizing: border-box;
  width: min(960px, calc(100% - 32px));
  padding: 22px 34px 26px;
  margin: 18px auto;
  background: #fff;
  color: var(--report-ink);
  box-shadow: 0 14px 70px #46382412;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 13.5px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}
.report-paper *, .report-paper *::before, .report-paper *::after { box-sizing: border-box; }
.report-paper h1, .report-paper h2, .report-paper h3, .report-paper h4, .report-paper p, .report-paper dl, .report-paper dd { margin: 0; }
.report-paper h2, .report-paper h3, .report-paper h4 { break-after: avoid; }
.report-paper p, .report-paper li { orphans: 3; widows: 3; }
.report-paper ul, .report-paper ol { margin: 4px 0 0; padding-left: 1.15em; }
.report-paper li + li { margin-top: 3px; }
.report-paper li::marker { color: #c4735a; }

/* 顶部操作条：品牌 + 状态 + 两个紧凑按钮，吸顶（T-001 的吸顶与 × 避让保持不变）。 */
.report-paper-actions { position: sticky; z-index: 5; top: 0; display: flex; align-items: center; gap: var(--report-space); min-height: 40px; margin: -22px -34px 14px; padding: 6px 58px 6px 12px; border-bottom: 1px solid var(--report-line); background: #f6f8f9; }
.report-actions-brand { flex: 0 0 auto; color: var(--report-accent); font-size: 13px; font-weight: 700; letter-spacing: .08em; white-space: nowrap; }
.report-actions-state { flex: 1 1 auto; min-width: 0; color: var(--report-muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.report-action-button { flex: 0 0 auto; padding: 6px 12px; border: 1px solid #d6ddd9; border-radius: 6px; background: #fff; color: #40544f; font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.report-action-button[data-print-report] { border-color: #b4552f; background: #ad5838; color: #fff; }
.report-action-button.ghost { background: #fff; }
.report-action-button:disabled { opacity: .5; cursor: wait; }

/* 打印页眉：屏幕上不出现，纸面第一页顶部一条细页眉（品牌、报告编号、版本）。 */
.report-print-head { display: none; }

.report-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 14px; padding: 2px 0 10px; border-bottom: 1px solid var(--report-line); }
.report-head h1 { color: var(--report-accent); font-size: 21px; font-weight: 650; line-height: 1.3; letter-spacing: -.01em; }
.report-head-meta { display: flex; flex-wrap: wrap; gap: 12px; color: var(--report-muted); font-size: 11.5px; }

.report-section { padding: 12px 0 10px; border-top: 1px solid var(--report-line); }
.report-head + .report-section { border-top: 0; padding-top: 10px; }
.report-section h2 { display: flex; align-items: baseline; gap: var(--report-space); margin-bottom: 8px; color: var(--report-ink); font-size: 18px; font-weight: 650; line-height: 1.35; letter-spacing: -.01em; }
.report-section-no { flex: 0 0 auto; min-width: 30px; color: var(--report-accent); font-size: 12px; font-weight: 700; letter-spacing: .06em; }
.report-section h2 small { margin-left: auto; color: var(--report-muted); font-size: 11.5px; font-weight: 400; }
.report-section h3 { color: var(--report-ink); font-size: 14px; font-weight: 650; line-height: 1.5; }
.report-section h4 { color: var(--report-ink); font-size: 12px; font-weight: 650; line-height: 1.5; }
.report-section p { margin: 4px 0 0; }
.report-caption, .report-section-intro { color: var(--report-muted); font-size: 11.5px; line-height: 1.65; }
.report-section-intro { margin: 0 0 4px; }

/* 03 本次观察：左患者（窄）、右主图（宽），下面是摘要。 */
.report-observe-grid { display: grid; grid-template-columns: 30% minmax(0, 1fr); gap: 18px; align-items: start; }
.report-observe-grid.report-observe-plain { grid-template-columns: minmax(0, 1fr); }
.report-patient { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; align-content: start; }
.report-patient > div { min-width: 0; }
/* R3：档案号、检查编号这类长编号占满一整行，不在字符串中间折断。 */
.report-patient-wide { grid-column: 1 / -1; }
.report-patient-wide dd { font-size: 12px; white-space: nowrap; }
.report-patient dt { color: var(--report-muted); font-size: 10.5px; }
.report-patient dd { margin-top: 1px; color: var(--report-ink); font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; }
.report-observe-plain .report-patient { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px 12px; }
.report-hero { margin: 0; }
.report-hero-stage { position: relative; width: 100%; border-radius: 8px; overflow: hidden; background: #0d1a1f; }
.report-hero-stage img { display: block; width: 100%; height: auto; }
.report-hero-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.report-hero figcaption { margin-top: 6px; color: var(--report-muted); font-size: 11.5px; }
.report-summary { margin-top: 12px; padding: 9px 12px; border-left: 3px solid var(--report-accent); background: #fdf8f6; }
.report-summary h3 { color: #a2553a; font-size: 12px; letter-spacing: .02em; }
.report-summary h3 span { margin-left: 6px; color: var(--report-muted); font-size: 11px; font-weight: 400; }
.report-summary p { margin-top: 3px; font-size: 13px; }

/* 04 代表影像与观察解读：每张卡左图右文，细线分隔。 */
.report-evidence { padding: 10px 0; border-top: 1px dashed var(--report-line); break-inside: avoid; }
.report-evidence:first-of-type { padding-top: 6px; border-top: 0; }
.report-evidence-header { display: flex; align-items: baseline; gap: 8px; }
.report-evidence-marker { flex: 0 0 auto; color: var(--report-accent); font-size: 19px; font-weight: 600; line-height: 1; }
.report-evidence-header h3 { flex: 1 1 auto; min-width: 0; font-size: 14px; }
.report-evidence-scope { flex: 0 0 auto; color: var(--report-muted); font-size: 11px; }
.report-evidence-hero { flex: 0 0 auto; color: #2f5d8a; font-size: 11px; white-space: nowrap; }
.report-evidence-body { display: grid; grid-template-columns: 34% minmax(0, 1fr); gap: 14px; margin-top: 6px; align-items: start; }
.report-evidence figure { margin: 0; }
.report-evidence canvas, .report-evidence img { display: block; width: auto; max-width: 100%; max-height: 200px; margin: 0 auto; border-radius: 6px; background: #0d1a1f; object-fit: contain; }
.report-evidence figcaption { margin-top: 5px; color: var(--report-muted); font-size: 11px; line-height: 1.6; }
.report-interpretation { min-width: 0; }
/* 2026-10-17 Owner："解读的内容文字过小、行距过小"：正文 13→14.5px、行距 1.85。 */
.report-interpretation > h4 { color: #a2553a; font-size: 13px; }
.report-interpretation p { margin-top: 3px; font-size: 14.5px; line-height: 1.85; }
.report-care-link { margin-top: 10px; padding-left: 10px; border-left: 2px solid #efaa6e; }
.report-care-link h4 { color: #a2553a; font-size: 13px; }
.report-care-link p { margin-top: 3px; font-size: 14px; line-height: 1.85; }
.report-care-link .report-caption { margin-top: 3px; font-size: 12.5px; }
.report-evidence .report-card-limit { margin-top: 10px; color: var(--report-muted); font-size: 12.5px; line-height: 1.75; }
.report-reference { color: #637d79; font-size: .92em; }

/* 05 医生意见与安排：标题旁一行小字，两列字段，未记录的合并成一行。 */
.report-doctor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 22px; }
.report-doctor-grid dt { color: var(--report-muted); font-size: 11.5px; }
.report-doctor-grid dd { margin-top: 1px; font-size: 13px; }
.report-doctor .report-caption { margin-top: 8px; }
.report-signature { display: flex; justify-content: space-between; gap: 16px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--report-line); color: var(--report-muted); font-size: 12px; break-inside: avoid; }

/* 06 日常护理与健康理解：两列，护理行动用带序号的紧凑清单。 */
.report-reading-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 22px; }
.report-reading-block > h3 { color: #a2553a; font-size: 12.5px; }
.report-reading-block ol, .report-reading-block ul { padding-left: 1.1em; }
.report-reading-block li { font-size: 13px; }
.report-action-grid ol { list-style: none; padding-left: 0; counter-reset: care; }
.report-action-grid ol > li { position: relative; padding-left: 20px; counter-increment: care; }
.report-action-grid ol > li::before { content: counter(care); position: absolute; left: 0; top: 1px; display: grid; width: 15px; height: 15px; place-items: center; border-radius: 4px; background: #fdece4; color: #b4552f; font-size: 10px; font-weight: 700; }

/* 07 专业解读：标题左、正文右的紧凑两列。 */
.report-professional { break-inside: avoid; }
.report-insight { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-top: 1px dashed var(--report-line); break-inside: avoid; }
.report-insight:first-of-type { border-top: 0; padding-top: 2px; }
.report-insight h3 { color: #5d4a8a; font-size: 12.5px; }
.report-insight p { margin-top: 0; font-size: 13px; }

/* 08 历史观察记录：紧凑列表 + 两个说明块。 */
.report-comparison ul { margin-top: 4px; }
.report-comparison li { font-size: 13px; }
.report-comparison-notes { margin-top: 8px; padding: 8px 10px; border: 1px solid #dbe6f1; border-radius: 6px; background: #f6f9fc; break-inside: avoid; }
.report-comparison-notes h3, .report-ai-note h3 { color: #2f5d8a; font-size: 12.5px; }
.report-comparison-notes ul { margin-top: 3px; }
.report-comparison-notes li { font-size: 12.5px; }
.report-ai-note { margin-top: 8px; padding: 8px 10px; border: 1px dashed #b9cde3; border-radius: 6px; background: #fbfdff; break-inside: avoid; }
.report-ai-note p { margin-top: 3px; font-size: 12.5px; }

/* 检查信息与附记：小字、多列，放在最后。 */
.report-exam-info .report-conditions { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px 14px; }
.report-exam-info dt { color: var(--report-muted); font-size: 11px; }
.report-exam-info dd { margin-top: 1px; font-size: 12.5px; }
.report-exam-info .report-caption { margin-top: 8px; }
.report-method p { margin-top: 3px; font-size: 12.5px; }
.report-method .report-safety { margin-top: 8px; padding: 8px 10px; border-radius: 6px; background: #fdfaf3; color: #6f5f45; font-size: 12px; line-height: 1.7; }
.report-paper-footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--report-line); color: var(--report-muted); font-size: 11px; }

@media screen and (max-width: 650px) {
  .report-paper { width: 100%; margin: 0; padding: 16px 16px 20px; }
  .report-paper-actions { margin: -16px -16px 10px; padding: 6px 52px 6px 10px; }
  .report-observe-grid { grid-template-columns: minmax(0, 1fr); }
  .report-observe-plain .report-patient { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-evidence-body, .report-doctor-grid, .report-reading-grid, .report-insight { grid-template-columns: minmax(0, 1fr); }
  .report-insight { gap: 2px; }
  .report-exam-info .report-conditions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-head-meta, .report-signature, .report-paper-footer { flex-direction: column; gap: 2px; }
}

@page {
  size: A4 portrait;
  margin: 15mm 16mm 17mm;
  @bottom-left { content: "微观智诊  /  口腔显微观察"; font: 8.5pt sans-serif; color: #6b767d; }
  @bottom-right { content: "第 " counter(page) " 页 / 共 " counter(pages) " 页"; font: 8.5pt sans-serif; color: #6b767d; }
}
@media print {
  html, body { margin: 0; padding: 0; background: #fff; }
  .report-paper { width: auto; min-height: 0; margin: 0; padding: 0; box-shadow: none; font-size: 10.5pt; line-height: 1.65; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .report-paper-actions { display: none !important; }
  .report-print-head { display: flex; justify-content: space-between; gap: 5mm; margin-bottom: 3mm; padding-bottom: 2mm; border-bottom: .5pt solid #cfd6d8; color: var(--report-muted); font-size: 8.5pt; }
  .report-head { padding: 0 0 3mm; }
  .report-head h1 { font-size: 15pt; }
  .report-head-meta { font-size: 8.5pt; gap: 4mm; }
  .report-section, .report-head + .report-section { padding: 4mm 0 3mm; }
  .report-section h2 { margin-bottom: 2.5mm; font-size: 12pt; }
  .report-section-no { min-width: 12mm; font-size: 9pt; }
  .report-section h2 small { font-size: 8.5pt; }
  .report-section h3 { font-size: 10.5pt; }
  .report-section h4 { font-size: 9pt; }
  .report-section p, .report-section li { font-size: 9.5pt; }
  .report-caption, .report-section-intro, .report-paper-footer, .report-method p, .report-method .report-safety { font-size: 8.5pt; }
  .report-observe-grid { grid-template-columns: 32% minmax(0, 1fr); gap: 5mm; }
  .report-patient { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2mm 4mm; }
  .report-patient dt { font-size: 8pt; }
  .report-patient dd { font-size: 9pt; }
  .report-patient-wide dd { font-size: 8.5pt; white-space: nowrap; }
  .report-hero { break-inside: avoid; }
  .report-hero-stage { max-height: 66mm; }
  .report-hero-stage img, .report-hero-stage canvas { max-height: 66mm; }
  .report-hero figcaption { font-size: 8.5pt; }
  .report-summary { padding: 2.5mm 3mm; }
  .report-summary p { font-size: 9.5pt; }
  .report-evidence { padding: 3mm 0; break-inside: avoid; }
  .report-evidence-body { grid-template-columns: 36% minmax(0, 1fr); gap: 4mm; }
  .report-evidence canvas, .report-evidence img { max-height: 42mm; }
  .report-evidence figcaption, .report-evidence .report-card-limit { font-size: 8pt; }
  .report-interpretation p, .report-care-link p { font-size: 9.5pt; line-height: 1.7; }
  .report-evidence-marker { font-size: 14pt; }
  .report-doctor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2mm 6mm; }
  .report-doctor-grid dt { font-size: 8.5pt; }
  .report-doctor-grid dd { font-size: 9.5pt; }
  .report-reading-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3mm 6mm; }
  .report-reading-block { break-inside: avoid; }
  .report-reading-block li { font-size: 9.5pt; }
  .report-insight { grid-template-columns: 32mm minmax(0, 1fr); gap: 3mm; padding: 2mm 0; }
  .report-insight p, .report-comparison li, .report-comparison-notes li, .report-ai-note p { font-size: 9pt; }
  .report-comparison-notes, .report-ai-note { padding: 2mm 3mm; break-inside: avoid; }
  .report-exam-info .report-conditions { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1mm 3mm; }
  .report-exam-info dt { font-size: 8pt; }
  .report-exam-info dd { font-size: 8.5pt; }
  .report-method .report-safety, .report-summary, .report-signature, .report-paper-footer { break-inside: avoid; }
  /* R4：医生意见（字段 + 签名行）整体不跨页；附记与页脚连在一起，避免最后一页只剩一行页脚。 */
  .report-doctor { break-inside: avoid; }
  .report-method { break-inside: avoid; }
  .report-method + .report-paper-footer { break-before: avoid; }
  body:has(#report-dialog[open]) > :not(#report-dialog) { display: none !important; }
  #report-dialog[open] { position: static; display: block; width: auto; height: auto; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; overflow: visible; box-shadow: none; background: #fff; }
  #report-dialog > .viewer-close { display: none; }
}

/* 2026-10-26 T-039：v6「前后对比」固定一节 */
.report-comparison-run .report-section-intro { margin-bottom: 6px; }
.report-comparison-run h3 { margin: 10px 0 4px; color: #2f5d8a; font-size: 13px; }
.report-comparison-run-timeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; }
.report-comparison-run-shot { margin: 0; min-width: 0; break-inside: avoid; }
.report-comparison-run-shot canvas { display: block; width: 100%; max-height: 130px; object-fit: contain; background: #f3f6f8; border: 1px solid #dbe6f1; border-radius: 4px; }
.report-comparison-run-shot figcaption { font-size: 10.5px; color: #657980; margin-top: 2px; line-height: 1.35; }
.report-comparison-run-shot-empty div { padding: 10px 6px; border: 1px dashed #cfdae3; color: #7a8b94; font-size: 11px; }
.report-comparison-run-shots { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.report-comparison-run-shots .report-comparison-run-shot { width: 132px; }
.report-comparison-run-point { break-inside: avoid; margin: 5px 0; padding-top: 4px; border-top: 1px solid #eef2f5; }
.report-comparison-run-point header { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; }
.report-comparison-run-point header span { color: #657980; }
.report-comparison-run-point p { margin: 2px 0; font-size: 12.5px; }
.report-table-wrap { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 11.5px; margin: 3px 0 5px; }
.report-table th, .report-table td { border: 1px solid #dbe6f1; padding: 4px 5px; text-align: left; vertical-align: top; }
.report-table th { background: #f1f6fa; color: #3f6178; font-weight: 600; }
.report-quantity-overall { font-size: 12px; font-weight: 600; color: #2f5d8a; margin: 2px 0; }
.report-comparison-final { margin-top: 8px; }
@media print {
  .report-comparison-run-timeline { grid-template-columns: repeat(3, 1fr); }
  .report-comparison-run-shot canvas { max-height: 34mm; }
  .report-table { font-size: 8.5pt; }
  .report-table th, .report-table td { padding: 2px 3px; }
}

/* T-039 R9：每个时间点 AI 标注总图 + 细菌计数图 */
.report-comparison-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: start; margin: 6px 0; }
.report-comparison-pair .report-hero { margin: 0; }
.report-count-overlay { margin: 0; min-width: 0; }
.report-count-overlay canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: fill; border: 1px solid #dbe6f1; border-radius: 4px; background: #111; }
.report-count-overlay figcaption { font-size: 10.5px; color: #657980; margin-top: 3px; line-height: 1.4; }
.report-count-overlay figcaption strong { display: block; color: #2f5d8a; margin-top: 2px; }
.report-count-legend { display: flex; flex-wrap: wrap; gap: 2px 8px; }
.report-count-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 2px; }
.report-comparison-description { font-size: 12.5px; margin: 4px 0 8px; }
.report-comparison-timepoint { break-inside: avoid; }
@media print {
  .report-comparison-pair { grid-template-columns: 1fr 1fr; gap: 3mm; }
  .report-count-overlay canvas { max-height: 38mm; }
}
