@media print {
  /* Hide top navigation, sidebars, and footers */
  header, aside, nav, footer, button, .pt-1\.5, .has-\[\>svg\]\:px-2\.5:has(>svg) {
    display: none !important;
  }
  
  /* Expand the main content to fit the paper */
  main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  pre, pre code, .highlight {
    overflow: visible !important;
    white-space: pre-wrap !important;
    word-break: break-all !important;
    overflow-wrap: break-word !important;
    max-height: none !important;
    height: auto !important;
  }

  /* Prevent code blocks from being split awkwardly across two printed pages */
  pre {
    page-break-inside: avoid;
  }

  /* Prevent ECharts containers from collapsing in print layouts */
  [_echarts_instance_], .echarts {
    width: 100% !important;
    min-width: 700px !important;
    page-break-inside: avoid;
  }

  /* 1. Remove scroll constraints from table wrappers */
  .overflow-x-auto, 
  .overflow-hidden,
  .w-full {
    overflow: visible !important;
    max-width: 100% !important;
  }

  /* 2. Force the table to expand and text to wrap */
  table {
    width: 100% !important;
    table-layout: fixed !important; /* Forces columns to respect boundaries */
    page-break-inside: auto;
  }
  
  th, td {
    white-space: normal !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
  }

  /* 3. Prevent rows from splitting across pages */
  tr {
    page-break-inside: avoid;
    page-break-after: auto;
  }

  /* 4. Repeat table headers at the top of a new printed page */
  thead {
    display: table-header-group;
  }
}
