@media print {
    /* 1. CONFIGURATION DE LA PAGE EN PORTRAIT */
    @page {
        size: portrait;
        margin: 0 !important; /* Supprime l'URL du navigateur */
    }

    /* 2. RÉGLAGES DU CONTENEUR PRINCIPAL */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        background-color: white !important;
    }

    body {
        /* Marges internes pour centrer le contenu sur le A4 */
        padding: 0.7cm 1.2cm !important;
        font-size: 9pt !important; /* On remonte un peu la taille pour le portrait */
        color: black !important;
    }

    /* 3. NETTOYAGE (Zéro UI, Zéro Gris) */
    .no-print, .navbar, .btn, form, .pagination, .card-footer, .btn-group {
        display: none !important;
    }

    /* 4. LE TABLEAU : PLEINE LARGEUR SANS SCROLL */
    .table {
        width: 100% !important;
        table-layout: auto !important;
        border-collapse: collapse !important;
        margin-top: 15px !important;
    }

    .container, .container-fluid {
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .table thead th {
        border-top: 2pt solid black !important;
        border-bottom: 2pt solid black !important;
        padding: 6px 4px !important;
        text-transform: uppercase;
        font-weight: bold !important;
    }

    /* 5. EN-TÊTE ET DATE (Fix alignement) */
    .d-print-block { display: block !important; }

    .print-header {
        display: flex !important;
        justify-content: space-between !important;
        align-items: flex-end !important;
        width: 100% !important;
        border-bottom: 2pt solid black !important;
        padding-bottom: 8px !important;
    }

    .text-end-print {
        text-align: right !important;
        min-width: 220px !important;
    }

    .table td, .table th {
        padding: 3px 5px !important;
        font-size: 8pt !important;
        line-height: 1.2 !important;
    }

    /* Réduire aussi les sous-éléments dans les cellules */
    .table td div,
    .table td small,
    .table td span {
        font-size: 7.5pt !important;
        line-height: 1.1 !important;
    }

    .badge {
        font-size: 7pt !important;
        padding: 1px 4px !important;
    }
}