@media print {
    /* 1. Ocultar absolutamente toda la interfaz interactiva */
    header,
    .catalog-ribbon,
    .top-controls,
    .budget-botones,
    .modal-overlay,
    .editor-overlay,
    .floating-list-overlay,
    .archivos-panel,
    .app-footer,
    .main-view-nav,
    .print-hide,
    .project-data-editor, /* Editor de datos del proyecto */
    .gantt-modal-overlay:not(.print-gantt-mode), /* Ocultar el modal de Gantt por defecto en impresión */
    .btn-delete,
    .btn-details-inline,
    .btn-details-sm,
    .btn-list-scroll,
    .category-label-mini {
        display: none !important;
    }

    /* 2. Resetear el fondo y los márgenes del cuerpo */
    body {
        background: white !important;
        color: black !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* 3. Forzar que el contenedor use el 100% del ancho del papel */
    .container, 
    main.budget {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: none !important;
        box-shadow: none !important;
        border: none !important;
        background: transparent !important;
    }

    /* 4. Estilizar la Ficha Técnica para que se vea como un encabezado de documento */
    .project-info-bar {
        border: 1px solid #eee !important;
        margin-bottom: 30px !important;
        box-shadow: none !important;
        background: #fafafa !important;
        page-break-inside: avoid;
    }

    /* 5. Asegurar que la tabla sea legible y ocupe todo el ancho */
    .budget-table {
        width: 100% !important;
        border-collapse: collapse !important;
    }

    .budget-table th {
        background-color: #f1f5f9 !important;
        color: #000 !important;
        border: 1px solid #ccc !important;
    }

    .budget-table td {
        border: 1px solid #eee !important;
    }

    /* Reglas específicas para imprimir el Gantt */
    body.print-gantt-mode .gantt-modal-overlay {
        display: flex !important; /* Mostrar solo el modal de Gantt */
        position: static !important; /* Permitir que fluya en el documento */
        width: 100% !important;
        height: auto !important;
        max-width: none !important;
        max-height: none !important;
        background: none !important;
        backdrop-filter: none !important;
    }
    body.print-gantt-mode #app > *:not(.gantt-modal-overlay) {
        display: none !important; /* Ocultar todo lo demás en el cuerpo */
    }

    .analysis-host,
    .analysis-container,
    .analysis-dashboard-container {
        box-shadow: none !important;
        margin: 0 !important;
        max-width: none !important;
        padding: 0 !important;
        width: 100% !important;
    }

    .kpi-card-new,
    .chart-box,
    .planning-summary-band,
    .materials-head,
    .materials-table-wrap,
    .supply-risk-alert {
        box-shadow: none !important;
        break-inside: avoid;
    }

    .dashboard-charts-layout,
    .kpi-grid-premium,
    .planning-summary-band {
        grid-template-columns: 1fr 1fr !important;
    }

    .material-risk-print {
        display: inline !important;
        font-weight: 700;
    }

    .mat-list-table {
        min-width: 0 !important;
        width: 100% !important;
    }

    .mat-list-table th,
    .mat-list-table td {
        border: 1px solid #ddd !important;
        padding: 8px !important;
    }
}
