:root {
  color-scheme: light;
}

a.link {
  color: rgb(37 99 235);
}

a.link:hover {
  text-decoration: underline;
}

/* Screen helpers */
#printBtnWrap {
  position: relative;
  z-index: 10;
}

/* ---- PRINT STYLES ---- */
@media print {
  @page {
    size: A4 landscape;
    margin: 9mm;
  }

  /* Hide non-table elements */
  header,
  footer,
  nav,
  #cardView,
  #cardViewProg,
  #filtersBox,
  #filtersBoxProg,
  #viewToggles,
  #viewTogglesProg,
  #pagerWrap,
  #pagerWrapProg,
  #pagerWrapCard,
  #pagerWrapCardProg,
  #printBtnWrap,
  .toolbar-row,
  #stopped-badges-legend,
  .banner-view,
  .alert-view,
  .back-button {
    display: none !important;
  }

  /* Show unified print header only */
  #printHeaderWrap {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 4pt !important;
    /* keep a small gap below header */
    margin-bottom: 6pt !important;
  }

  /* Ensure table view prints cleanly */
  #tableView,
  #tableViewProg {
    display: block !important;
    box-shadow: none !important;
  }

  /* Only print rows we explicitly mark as visible */
  #tableView tbody tr {
    display: none !important;
  }

  #tableView tbody tr.print-show {
    display: table-row !important;
  }

  body {
    background: #fff !important;
    line-height: 1.5;
  }

  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  table {
    width: 100% !important;
    table-layout: fixed;
    border-collapse: collapse;
    margin-top: 0 !important;
  }

  thead {
    /* Do not repeat column header on every printed page */
    display: table-row-group !important;
  }

  tfoot {
    /* Do not repeat column footer on every printed page */
    display: table-row-group !important;
  }

  tr {
    page-break-inside: avoid;
  }

  th,
  td {
    border: 1px solid #e5e7eb;
    padding: 6pt 8pt;
    white-space: normal !important;
    word-break: break-word;
    vertical-align: top;
    border-radius: 0 !important;
    /* ensure square corners in print */
  }

  /* Explicitly remove rounding on edge cells that may carry rounded utility classes */
  thead th:first-child,
  thead th:last-child,
  tbody td:first-child,
  tbody td:last-child {
    border-radius: 0 !important;
  }

  /* Make column headers bolder and larger for print */
  thead th,
  #tableView thead th,
  #tableViewProg thead th {
    font-weight: 800 !important;
    /* extra-bold for visibility */
    font-size: 12pt !important;
    /* larger than body text */
  }

  /* Ensure background colors appear in print */
  html,
  body,
  *,
  *::before,
  *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Blue header background with white text */
  table thead th,
  #tableView thead th,
  #tableViewProg thead th {
    background-color: #022454 !important;
    /* Tailwind blue-600 */
    color: #ffffff !important;
  }

  /* Zebra striping for readability (gray on even rows) */
  table tbody tr:nth-child(even) td,
  #tableView tbody tr:nth-child(even) td,
  #tableViewProg tbody tr:nth-child(even) td {
    background-color: #f3f4f6 !important;
    /* Tailwind gray-100 */
  }

  mark {
    background: transparent !important;
    color: inherit !important;
  }

  /* Prevent browsers from auto-appending link URLs after anchor text in print */
  a[href]::after {
    content: "" !important;
  }

  #printLogos {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
  }

  #printLogo {
    height: 150px !important;
    width: 700px !important;
  }

  #printTitle,
  #printTime {
    text-align: center !important;
    width: 100%;
  }

  /* Reduce excessive vertical gaps coming from Tailwind spacing on wrappers */
  /* Many pages wrap content with mx-auto + my-* and space-y-*; reset for compact print */
  [class*="space-y-"] > :not([hidden]) ~ :not([hidden]) {
    margin-top: 0 !important;
  }

  [class*="my-"],
  [class*="mt-"],
  [class*="mb-"] {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }

  /* Ensure first element after our print header has no extra top margin */
  #printHeaderWrap + * {
    margin-top: 0 !important;
  }

  /* Common page width wrappers often used around the table */
  .max-w-6xl,
  .max-w-7xl,
  .container,
  main {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }
}
