/* Screen cards and paper tables have independent layouts. */
#print-directory { display: none; }

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  html, body, body.dark-theme {
    background: #fff !important;
    color: #171717 !important;
    font: 9pt/1.35 Arial, Helvetica, sans-serif !important;
    margin: 0 !important;
    min-width: 0 !important;
  }
  .no-print, .header, .hero, .actions, .stats, #search-results,
  #toTop, .site-footer { display: none !important; }
  body::before, body::after { display: none !important; }
  .container { width: 100% !important; max-width: none !important; margin: 0 !important; padding: 0 !important; }
  #print-directory { display: block; color: #171717; }
  .print-heading { border-bottom: 1.5pt solid #222; padding-bottom: 4mm; margin-bottom: 5mm; }
  .print-institution { font-size: 9pt; letter-spacing: .25pt; }
  .print-heading h1 { font-size: 22pt; font-weight: 700; letter-spacing: -.6pt; line-height: 1.15; margin: 2mm 0 3mm; }
  .print-meta { display: flex; justify-content: space-between; font-size: 8pt; color: #444; }
  .print-filter { margin: 2mm 0 0; font-size: 8pt; overflow-wrap: anywhere; }
  .print-table { width: 100%; table-layout: fixed; border-collapse: collapse; margin: 0 0 5mm; font-size: 9pt; }
  /* Keep only the IT department together; other departments may still split. */
  .print-table[aria-label="Отдел информационных технологий"] {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .print-person-col { width: 29%; }
  .print-room-col { width: 6%; }
  .print-work-col { width: 16%; }
  .print-internal-col { width: 12%; }
  .print-mobile-col { width: 17%; }
  .print-email-col { width: 20%; }
  .print-table thead { display: table-header-group; }
  .print-table tbody { break-inside: auto; }
  .print-table tr { break-inside: avoid; page-break-inside: avoid; }
  .print-table th, .print-table td { text-align: left; vertical-align: top; overflow-wrap: anywhere; }
  .print-table .print-department { padding: 2.5mm 0 2mm; border-bottom: 1pt solid #333; font-size: 11pt; font-weight: 700; }
  .print-columns th { padding: 2mm 1.8mm; font-size: 7.5pt; font-weight: 700; border-bottom: .7pt solid #666; }
  .print-table td { padding: 2.4mm 1.8mm; border-bottom: .5pt solid #b5b5b5; border-right: .4pt solid #d0d0d0; }
  .print-table td:last-child { border-right: 0; }
  .print-name { display: block; font-size: 9.5pt; line-height: 1.25; }
  .print-position { display: block; margin-top: 1mm; font-size: 8pt; color: #444; }
  .print-table .print-room { text-align: center; font-variant-numeric: tabular-nums; }
  .print-phone { font-size: 8.5pt; font-variant-numeric: tabular-nums; }
  .print-table .print-work { text-align: center; }
  .print-table .print-internal { font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
  .print-email { font-size: 8pt; }
  .print-footer { border-top: .5pt solid #777; margin-top: 4mm; padding-top: 2mm; font-size: 7pt; color: #555; break-inside: avoid; }
  .print-heading { break-inside: avoid; break-after: avoid; }
}
