@page {
  size: A4 portrait;
  margin: 11mm 10mm;
}

@media print {
  * {
    animation: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    transition: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  html,
  body {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }

  body {
    color: #17231f !important;
    font-size: 11.5px;
    line-height: 1.45;
  }

  .topbar,
  .mainnav,
  .scorebar-wrap,
  .drawer,
  .drawer-bg,
  .picker,
  .picker-bg,
  .form-aside,
  .rep-tools,
  .draft-top,
  .pk-fbar,
  .draft-aside,
  .empty-stage,
  .gen-status,
  footer,
  #demoBtn,
  .slot-x,
  .pcx {
    display: none !important;
  }

  .page:not(.on) {
    display: none !important;
  }

  .page.on,
  .wrap,
  .grid,
  .stage,
  .draft-grid,
  .draft-batches {
    display: block !important;
  }

  .wrap {
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .grid,
  .draft-grid {
    gap: 0 !important;
  }

  .hero,
  .qhero {
    display: none !important;
  }

  a {
    color: inherit !important;
    text-decoration: none !important;
  }

  table {
    border-collapse: collapse;
  }

  /* 只保留真正“切开会难看”的叶子为整块：图表、单个表格行、报告里的单行网格、统计块、志愿草表卡。
     报告的档位块/学校卡/楼层块(.rp-card/.b-row/.xwell/.xw-blk 等)不再整块保护——
     交由 report-print.js 的打印样式放开跨页续排，避免整块下移在页尾留大片空白。 */
  img,
  svg,
  tr,
  .stat,
  .b-row-l1,
  .v4x-row,
  .slip-card,
  .draft-form tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .dtable-scroll,
  .rk-chart-wrap,
  .pk-trend-wrap,
  .dm-tbl .dtable-scroll {
    max-height: none !important;
    overflow: visible !important;
  }
}

@media print {
  body.print-report .page[data-page="report"] {
    background: #fff !important;
  }

  body.print-report .report,
  body.print-report #reportEl,
  body.print-report .rp {
    width: 100% !important;
    max-width: none !important;
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
  }

  body.print-report .rep-head {
    padding: 0 0 5mm !important;
    border-bottom: 1px solid #d8e1dc !important;
    background: #fff !important;
    break-after: avoid;
    page-break-after: avoid;
  }

  body.print-report .rep-head h1 {
    margin: 2mm 0 3mm !important;
    font-size: 22px !important;
    line-height: 1.28 !important;
  }

  body.print-report .rep-head .kk {
    font-size: 9.5px !important;
    letter-spacing: 2px !important;
  }

  body.print-report .rep-head .seal2 {
    width: 18mm !important;
    height: 18mm !important;
    top: 0 !important;
    right: 0 !important;
    font-size: 9.5px !important;
    border-radius: 3mm !important;
  }

  body.print-report .rep-tags {
    gap: 2mm !important;
  }

  body.print-report .rtag {
    padding: 1.5mm 2.5mm !important;
    border-radius: 1.5mm !important;
    font-size: 11px !important;
  }

  body.print-report .rep-body {
    padding: 0 !important;
  }

  body.print-report .sec {
    padding: 5mm 0 !important;
    border-bottom: 1px solid #e8efeb !important;
    break-inside: auto !important;
    page-break-inside: auto !important;
  }

  body.print-report .sec:last-child {
    border-bottom: 0 !important;
  }

  body.print-report .sec-h {
    margin-bottom: 3mm !important;
    break-after: avoid;
    page-break-after: avoid;
  }

  body.print-report .sec-h .idx {
    width: 7mm !important;
    height: 7mm !important;
    border-radius: 1.5mm !important;
    font-size: 12px !important;
  }

  body.print-report .sec-h h2 {
    font-size: 16px !important;
  }

  body.print-report .stats {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 3mm !important;
  }

  body.print-report .stat {
    padding: 3mm 2.5mm !important;
    border-radius: 2mm !important;
  }

  body.print-report .stat .v {
    font-size: 20px !important;
  }

  body.print-report .stat .l {
    font-size: 10px !important;
  }

  body.print-report .rp-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 3mm !important;
  }

  body.print-report .rp-card {
    padding: 3mm !important;
    border-radius: 2mm !important;
  }

  body.print-report .rp-card-h,
  body.print-report .rp-card-b {
    font-size: 12px !important;
  }

  body.print-report .rp-card-f {
    font-size: 10.5px !important;
  }

  body.print-report .rp-v5 .b-tabs,
  body.print-report .rp-v5 .b-tab-rule,
  body.print-report .rp-fbar,
  body.print-report .v4x-ctrl {
    display: none !important;
  }

  body.print-report .rp-v5 .b-row-l1 {
    /* ★ 2026-07-15k：末列 4mm 给回 ▾（收起形态提示，与长图/页面一致）。 */
    grid-template-columns: 3mm minmax(0, 1fr) 21mm 26mm 24mm 4mm !important;
    gap: 2.5mm !important;
    padding: 2.4mm 0 !important;
    cursor: default !important;
  }

  body.print-report .rp-v5 .b-nm > b {
    white-space: normal !important;
    overflow: visible !important;
  }

  body.print-report .rp-v5 .b-line b {
    font-size: 14px !important;
  }

  body.print-report .rp-v5 .gap-badge {
    justify-self: end !important;
    padding: 0.5mm 2mm !important;
    font-size: 10.5px !important;
  }

  /* 根因修复：装学校卡的 .b-list 屏幕上是 display:flex(纵向)，而浏览器对 flex 容器的
     跨页拆分不可靠——打印时降级为 block，块流分页才能把当前页填满、余下续到下一页
     (与 js/report-print.js 注入的同名规则一致；视觉零变化)。 */
  body.print-report .rp .b-list {
    display: block !important;
  }

  /* ★ 2026-07-15k：导出 PDF 只显示学校信息行——卡片抽屉（走势图/班型表）保持收起、不再强制展开，
     页面更简洁；每档仍列出全部学校（下方「更多学校」<details> 由 report-print.js @media print 强制
     展开正文，这里隐藏其现已多余的 summary）。 */
  body.print-report .rp-v5 .b-drawer {
    display: none !important;
  }

  body.print-report details.rpm-xmore > summary,
  body.print-report details.rpm-more2 > summary,
  body.print-report details.u-more > summary {
    display: none !important;
  }

  body.print-report .rp-v5 .b-ptbl {
    font-size: 10.5px !important;
  }

  body.print-report .rp-v5 .b-ptbl th,
  body.print-report .rp-v5 .b-ptbl td {
    padding: 1.5mm 2mm !important;
  }

  body.print-report .rp-print-tier-h,
  body.print-report .rp-print-head,
  body.print-report .rp-print-banner {
    break-after: avoid;
    page-break-after: avoid;
  }

  body.print-report .rp .v4x-row,
  body.print-report .v4x-row {
    grid-template-columns: 42mm minmax(0, 1fr) 24mm !important;
    grid-template-areas: none !important;
    gap: 3mm !important;
    padding: 3mm 0 !important;
  }

  body.print-report .v4x-label,
  body.print-report .v4x-axis,
  body.print-report .v4x-v {
    grid-area: auto !important;
  }

  body.print-report .v4x-axis {
    width: 100% !important;
    min-width: 0 !important;
    height: 36px !important;
  }

  body.print-report .v4x-sch {
    max-width: none !important;
    white-space: normal !important;
  }

  body.print-report .tl-block,
  body.print-report .slip-card,
  body.print-report .xwell,
  body.print-report details.safe-more,
  body.print-report details.more-rec {
    border-radius: 2mm !important;
  }

  body.print-report #aiReportBody,
  body.print-report .prose {
    font-size: 12px !important;
    line-height: 1.62 !important;
  }

  body.print-report #aiReportBody h3,
  body.print-report #aiReportBody h4,
  body.print-report .prose h3,
  body.print-report .prose h4 {
    break-after: avoid;
    page-break-after: avoid;
  }

  body.print-report #aiReportBody .md-table,
  body.print-report .prose table,
  body.print-report .schtable,
  body.print-report .dmt {
    width: 100% !important;
    font-size: 10.5px !important;
  }
}

@media print {
  body.print-draft .page[data-page="draft"] {
    background: #fff !important;
  }

  body.print-draft .draft-grid {
    display: block !important;
    margin: 0 !important;
  }

  body.print-draft .draft-batches {
    width: 100% !important;
  }

  body.print-draft .draft-form-wrap {
    width: 100% !important;
    border: 0 !important;
    border-radius: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  body.print-draft .draft-form-title {
    padding: 3mm 4mm !important;
    font-size: 15px !important;
    line-height: 1.35 !important;
    border: 1.2px solid #222 !important;
    border-bottom: 0 !important;
  }

  body.print-draft .draft-form-title .dft-sub {
    margin-top: 1mm !important;
    font-size: 10.5px !important;
  }

  body.print-draft .draft-form {
    width: 100% !important;
    border: 1.2px solid #222 !important;
    table-layout: fixed !important;
    font-size: 11px !important;
  }

  body.print-draft .draft-form tr,
  body.print-draft .draft-form th,
  body.print-draft .draft-form td {
    break-inside: avoid-page !important;
    page-break-inside: avoid !important;
  }

  body.print-draft .draft-form th,
  body.print-draft .draft-form td {
    padding: 1.7mm 2mm !important;
    border: 0.8px solid #555 !important;
    vertical-align: middle !important;
  }

  body.print-draft .draft-form .dfp-side {
    width: 22mm !important;
  }

  body.print-draft .dfp-batch {
    width: 22mm !important;
  }

  body.print-draft .dfp-batch .dfp-bo {
    width: 6mm !important;
    height: 6mm !important;
    line-height: 6mm !important;
    margin-bottom: 1mm !important;
    font-size: 10px !important;
  }

  body.print-draft .dfp-batch .dfp-bn {
    font-size: 11px !important;
    letter-spacing: 2px !important;
  }

  body.print-draft .dfp-cat {
    width: 36mm !important;
    font-size: 10.5px !important;
    line-height: 1.35 !important;
  }

  body.print-draft .dfp-inforow .dfp-info {
    font-size: 11px !important;
    line-height: 1.45 !important;
  }

  body.print-draft .dfp-sch {
    padding: 1mm 1.4mm !important;
  }

  body.print-draft .dfp-sch .slot {
    min-height: 8mm !important;
    padding: 1mm 2mm !important;
    cursor: default !important;
  }

  body.print-draft .dfp-sch .slot.empty {
    color: #9aa39c !important;
    border: 0.6px dashed #bbb !important;
    background: #fff !important;
  }

  body.print-draft .dfp-sch .slot .slot-nm {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-size: 11px !important;
    line-height: 1.25 !important;
  }

  body.print-draft .dfp-sch .slot .slot-meta,
  body.print-draft .dfp-noterow .dfp-note {
    font-size: 9.5px !important;
    line-height: 1.4 !important;
  }
}
