@media print {
  /* Hide interactive elements */
  .toolbar,
  .gantt-bar-handle,
  .gantt-bar-connector,
  .context-menu,
  .modal-overlay,
  .toast,
  .task-list-add,
  .task-list-resize,
  .task-list-footer,
  .zoom-controls,
  .save-indicator,
  .btn-primary,
  .btn-secondary,
  .task-detail-toggle,
  .task-detail-panel,
  .task-list-multi-select,
  .empty-state {
    display: none !important;
  }

  /* ---- Base reset ---- */
  html, body {
    height: auto !important;
    overflow: visible !important;
    background: white !important;
    font-size: 9pt;
    color: #000;
  }

  /* Force color printing and prevent browser grayscale conversion */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    transition: none !important;
    animation: none !important;
  }

  /* ---- App shell ---- */
  .app-shell {
    height: auto !important;
    overflow: visible !important;
    display: block !important;
  }

  /* ---- Print header ---- */
  .print-header {
    display: block !important;
    padding: 3mm 0;
    border-bottom: 1.5pt solid #000;
    margin-bottom: 2mm;
  }

  .print-header-title {
    font-size: 14pt;
    font-weight: 700;
  }

  .print-header-date {
    font-size: 8pt;
    color: #666;
    margin-top: 1mm;
  }

  /* ================================================================
     CORE: Vector-based print output.
     Uses CSS zoom (not transform) to scale the content while keeping
     text as real vector glyphs. This avoids the rasterization that
     CSS transform: scale() causes in many browsers' print pipelines.
     JS sets --print-scale on .main-content before window.print().
     ================================================================ */
  .main-content {
    display: flex !important;
    flex-direction: row !important;
    overflow: visible !important;
    height: auto !important;
    width: max-content;
    /* Use zoom instead of transform for vector text rendering.
       zoom preserves text as font outlines in the print pipeline,
       while transform: scale() often triggers rasterization. */
    zoom: var(--print-scale, 0.5);
  }

  /* ---- Task list panel ---- */
  .task-list-panel {
    flex: none !important;
    width: var(--task-list-width) !important;
    min-width: 0 !important;
    max-width: none !important;
    border-right: 0.75pt solid #999 !important;
    overflow: visible !important;
    height: auto !important;
  }

  .task-list-header {
    position: static !important;
    background: #f5f5f5 !important;
    border-bottom: 0.75pt solid #999 !important;
    font-size: 9px;
  }

  .task-list-body {
    overflow: visible !important;
    height: auto !important;
  }

  .task-list-item {
    page-break-inside: avoid;
    border-bottom-color: #ddd !important;
    font-size: 10px;
  }

  .task-list-item.group {
    font-weight: 600;
    background: #f8f8f8 !important;
  }

  /* ---- Timeline panel ---- */
  .timeline-panel {
    flex: none !important;
    width: auto !important;
    overflow: visible !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .timeline-header {
    position: static !important;
    overflow: visible !important;
    height: auto !important;
  }

  .timeline-header-content {
    /* Remove scroll transform for print */
    transform: none !important;
  }

  .timeline-header-cell {
    font-size: 9px;
    border-color: #ccc !important;
  }

  .timeline-header-cell.primary {
    font-size: 10px;
    background: #f5f5f5 !important;
  }

  .timeline-body {
    overflow: visible !important;
    height: auto !important;
  }

  .timeline-grid {
    transform: none !important;
  }

  /* Bars and milestones */
  .gantt-bar-layer {
    position: absolute;
    top: 0;
    left: 0;
  }

  .gantt-bar {
    border-radius: 3px;
  }

  .gantt-bar-label {
    font-size: 9px;
    text-shadow: none;
    color: white;
  }

  .gantt-bar-label.external {
    color: #333;
    font-size: 8px;
  }

  .gantt-bar.group {
    background: #666 !important;
  }

  .gantt-bar.group::before,
  .gantt-bar.group::after {
    border-color: transparent #666 transparent transparent !important;
  }

  .gantt-bar.group::after {
    border-color: transparent transparent #666 transparent !important;
  }

  /* Collapsed group summary */
  .gantt-bar.group.collapsed-summary {
    border-color: #999 !important;
  }

  .gantt-bar-collapse-label {
    font-size: 8px;
    text-shadow: none;
  }

  /* Today line */
  .gantt-today-line {
    opacity: 0.6;
    width: 1.5px;
  }

  .gantt-today-label {
    font-size: 7px;
  }

  /* Dependency arrows — SVG vector rendering */
  .dependency-overlay {
    position: absolute;
    top: 0;
    left: 0;
  }

  .dependency-overlay,
  .dependency-overlay svg {
    shape-rendering: geometricPrecision;
  }

  .dependency-path {
    vector-effect: non-scaling-stroke;
    stroke-width: 1px;
  }

  .dependency-arrow {
    fill: #666;
  }

  /* Non-working day columns */
  .gantt-non-working {
    opacity: 0.25;
  }

  /* Row backgrounds */
  .gantt-row-bg {
    border-bottom-color: #eee !important;
  }

  .gantt-row-bg:nth-child(even) {
    background: rgba(0, 0, 0, 0.02) !important;
  }

  .gantt-row-bg.selected {
    background: transparent !important;
  }

  /* Column lines */
  .gantt-col-line {
    background: #e0e0e0 !important;
  }

  /* Personnel badges */
  .gantt-bar-personnel {
    display: none;
  }

  /* Staffing bars */
  .gantt-bar.staffing-summary-bar {
    opacity: 0.8;
  }

  /* ================================================================
     Vector quality: Ensure text is rendered as real font outlines.
     ================================================================ */
  .gantt-bar-label,
  .gantt-bar-collapse-label,
  .timeline-header-cell,
  .task-list-item,
  .task-name,
  .task-dates,
  .task-number,
  .print-header-title,
  .print-header-date {
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
  }

  /* ---- Page setup ---- */
  @page {
    size: A3 landscape;
    margin: 10mm;
  }

  @page :first {
    margin-top: 12mm;
  }
}

/* Compact print mode — smaller rows for more content per page */
@media print {
  .print-compact .task-list-item {
    height: 28px;
    font-size: 8px;
  }

  .print-compact .gantt-bar {
    height: 18px;
  }

  .print-compact .gantt-bar-label {
    font-size: 7px;
  }

  .print-compact .gantt-row-bg {
    height: 28px !important;
  }

  .print-compact .gantt-milestone {
    width: 10px;
    height: 10px;
  }

  .print-compact .timeline-header-cell {
    font-size: 7px;
  }
}

/* Print-only elements (hidden on screen) */
.print-header {
  display: none;
}
