@media print {
  /* Hide navigation and other non-essential elements */
  header nav, 
  footer, 
  .search-container, 
  .pagination,
  button,
  .no-print {
    display: none !important;
  }
  
  /* Set page margins and size */
  @page {
    margin: 1cm;
    size: portrait;
  }
  
  /* Basic styles for printing */
  body {
    font-family: serif;
    font-size: 11pt;
    line-height: 1.3;
    background: #fff;
    color: #000;
  }
  
  /* Make sure the content takes up the full width */
  .permit-container {
    width: 100%;
    margin: 0;
    padding: 0;
  }
  
  /* Avoid breaking inside table cells */
  table, tr, td, th {
    page-break-inside: avoid;
  }
  
  /* Ensure that each h2, h3 starts on a new page if needed */
  h2, h3 {
    page-break-before: auto;
    page-break-after: avoid;
  }
  
  /* Prevent page breaks after headings */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
  
  /* Make links and text content readable in print */
  a {
    color: #000;
    text-decoration: none;
  }
  
  /* Handle large tables */
  table {
    max-width: 100%;
    width: 100%;
    border-collapse: collapse;
  }
  
  /* Make pre tags wrap properly */
  pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
  }
  
  /* Border handling */
  td[style*="border"] {
    border: 1px solid #999 !important;
  }
  
  div[style*="border"] {
    border: 1px solid #999 !important;
  }
  
  /* Set specific width for columns in tables */
  .detail-label {
    width: 30%;
  }
  
  .detail-value {
    width: 70%;
  }
  
  /* Show URL for links */
  a:after {
    content: " (" attr(href) ")";
    font-size: 80%;
  }
  
  /* Avoid splitting paragraphs */
  p {
    page-break-inside: avoid;
  }
  
  /* Handle large content better */
  .flat-table {
    width: 100%;
    font-size: 10pt;
  }
  
  /* Force background colors and images to print */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}