@media print {
    /* 1. Configuración de página */
    @page {
        size: A4 portrait;
        margin: 1.5cm;
    }

    body, main, section {
        background-color: white !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
        margin-top: 1rem;
    }

    /* 2. Repetición de Encabezados de Tabla */
    table {
        border-collapse: collapse !important;
        width: 100% !important;
        /* Forzamos el comportamiento de tabla estándar */
        display: table !important; 
    }

    thead {
        /* Este es el truco clave para repetir el encabezado */
        display: table-header-group !important; 
    }

    tr {
        /* Evita que una fila se parta entre dos páginas */
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* 3. Control de Widgets (Cards y Stats) */
    .card {
        /* Si el widget no cabe, salta a la siguiente página completo */
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        display: block !important;
        margin-bottom: 20px !important;
        border: 1px solid #e5e7eb !important; /* Borde gris suave para el papel */
    }

    /* 4. Forzar visibilidad de textos y fondos */
    .text-success { color: #16a34a !important; }
    .text-error { color: #dc2626 !important; }
    .badge { border: 1px solid #000 !important; }

    /* 5. Limpieza de interfaz */
    .btn, 
    .drawer-button,
    footer,
    #info_muestreo,
    #listado-registros,
    #modalCron,
    #loading-overlay,
    #filter-header,
    .map-status,
     #nav-buttons {
        display: none !important;
    }

    input[type="date"] {
        display: none !important;
    }

    #nav-filter-info {display: block !important;}
}