.received-search [hidden] {
    display: none !important;
}

/* En-tête */
.received-header {
    margin-bottom: 1.25rem;
}

/* Onglets de Numéros à expédier et de la page Commandes d'une institution */
.received-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--portal-border);
}

.received-tab {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: -1px;
    padding: .6rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--portal-radius) var(--portal-radius) 0 0;
    color: var(--portal-primary-dark);
    font-weight: 600;
    text-decoration: none;
}

.received-tab:hover,
.received-tab:focus-visible {
    background: var(--portal-soft);
    color: var(--portal-ink);
}

.received-tab--active {
    border-color: var(--portal-border);
    border-bottom-color: var(--portal-surface);
    background: var(--portal-surface);
    color: var(--portal-ink);
}

.received-tab__count {
    min-width: 1.6rem;
    padding: .05rem .5rem;
    border-radius: 999px;
    background: var(--portal-soft);
    color: var(--portal-ink);
    font-size: .85rem;
    text-align: center;
}

/* Bordereaux et confirmation de l'expédition, à droite de la barre des résultats */
.received-print-slips,
.received-confirm-shipping {
    margin-left: auto;
}

.received-print-slips + .received-confirm-shipping {
    margin-left: 0;
}

/* Recherche et outils */
.received-search-form {
    margin-bottom: 1.25rem;
    padding: 1rem;
    overflow: visible;
}

.received-search-main {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: .6rem;
}

.received-search-query {
    position: relative;
    flex: 1 1 20rem;
    margin: 0;
}

.received-search-query svg {
    position: absolute;
    top: 50%;
    left: .85rem;
    color: var(--portal-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.received-search input:not([type="checkbox"]):not([type="hidden"]),
.received-search select {
    max-width: 100%;
}

.received-search-query input {
    width: 100%;
    padding-left: 2.6rem !important;
}

.received-search-scope {
    display: flex;
    flex: 0 0 auto;
    white-space: nowrap;
    align-items: center;
    gap: .5rem;
    margin: 0;
    color: var(--portal-muted);
    font-size: .9rem !important;
    font-weight: 500;
}

.received-search-main .portal-button {
    min-height: 2.75rem;
    padding-inline: 1.4rem;
}

.received-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .6rem 1rem;
    margin-top: .85rem;
    padding-top: .85rem;
    border-top: 1px solid var(--portal-border);
    /* Le thème donne z-index: 2 aux div et aux p ; le panneau Colonnes doit passer au-dessus. */
    z-index: 10;
}

.received-toolbar__group:first-child {
    z-index: 3;
}

.received-toolbar__group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.received-tool-button {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-height: 2.5rem;
    padding: .45rem .9rem;
    border: 1px solid #cdd4ce;
    border-radius: 999px;
    background: #fff;
    color: var(--portal-primary-dark);
    font-size: .9rem !important;
    font-weight: 600;
    line-height: 1.2 !important;
    cursor: pointer;
    list-style: none;
    transition: border-color 160ms ease, background-color 160ms ease;
}

.received-tool-button::-webkit-details-marker {
    display: none;
}

.received-tool-button:hover,
details[open] > .received-tool-button {
    border-color: var(--portal-primary);
    background: var(--portal-soft);
    color: var(--portal-ink);
}

.received-page-size {
    margin: 0;
}

.received-columns {
    position: relative;
}

.received-columns__panel {
    position: absolute;
    z-index: 20;
    top: calc(100% + .4rem);
    left: 0;
    width: 15rem;
    margin: 0;
    padding: .85rem 1rem;
    border: 1px solid var(--portal-border);
    border-radius: 12px;
    background: var(--portal-surface);
    box-shadow: var(--portal-shadow);
}

.received-columns__panel legend {
    float: none;
    width: 100%;
    margin-bottom: .35rem;
    color: var(--portal-ink);
    font-size: .85rem;
    font-weight: 700;
}

.received-choice {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin: .4rem 0;
    font-size: .9rem !important;
    line-height: 1.4 !important;
    cursor: pointer;
}

.received-choice input {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: var(--portal-primary);
}

.received-choice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
}

.received-choice-actions button {
    border: 0;
    padding: .25rem 0;
    color: var(--portal-primary-dark);
    background: transparent;
    text-decoration: underline;
    font-size: .8rem;
}

.received-search :focus-visible {
    outline: 2px solid var(--portal-primary);
    outline-offset: 3px;
}

/* Résultats et filtres actifs */
.received-results-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem 1rem;
    margin-bottom: .75rem;
}

.received-result-count {
    margin: 0;
    color: var(--portal-muted);
    font-size: .95rem !important;
}

.received-result-count strong {
    color: var(--portal-ink);
}

.received-active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
}

.received-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .3rem .7rem;
    border: 1px solid #b8c7a1;
    border-radius: 999px;
    background: var(--portal-soft);
    color: var(--portal-ink);
    font-size: .85rem !important;
    line-height: 1.3;
    text-decoration: none;
}

.received-filter-chip:hover {
    border-color: var(--portal-primary);
    color: var(--portal-ink);
}

.received-filter-chip span {
    font-size: 1rem;
    line-height: 1;
}

.received-clear-all {
    margin-left: .25rem;
    color: var(--portal-primary-dark);
    font-size: .85rem !important;
    text-underline-offset: .2em;
}

/* Tableau */
.woocommerce-account .portal-table-wrap table.received-orders-table {
    min-width: 760px;
    margin: 0 !important;
}

.received-orders-table th[data-received-column],
.received-orders-table td[data-received-column="id"],
.received-orders-table td[data-received-column="date"],
.received-orders-table td[data-received-column="total"],
.received-orders-table td[data-received-column="quantity"] {
    white-space: nowrap;
}

.woocommerce-account .portal-table-wrap table.received-orders-table > thead th {
    padding: .8rem .6rem !important;
    color: var(--portal-ink);
    font-size: .8rem !important;
    letter-spacing: 0;
    text-transform: none;
}

.woocommerce-account .portal-table-wrap table.received-orders-table td {
    padding: .85rem .6rem !important;
    font-size: .9rem !important;
    line-height: 1.45 !important;
}

.received-orders-table td[data-received-column="id"] {
    font-weight: 600;
}

.received-orders-table td[data-received-column="client"],
.received-orders-table td[data-received-column="articles"] {
    min-width: 6rem;
}

.received-orders-table td[data-received-column="total"] {
    color: var(--portal-ink);
    font-weight: 600;
}

.received-orders-table td small {
    color: var(--portal-muted);
    font-size: .8rem;
}

.received-orders-table .received-order-row {
    cursor: pointer;
}

.received-orders-table .received-order-row:hover > td,
.received-orders-table .received-order-row:focus-within > td,
.received-orders-table .received-order-row--expanded > td {
    background: #f7f9f3;
}

.received-orders-table .received-order-row--expanded > td {
    border-bottom: 0 !important;
}

.received-orders-table .sodep-order-link {
    color: var(--portal-ink);
    font-weight: inherit;
    text-decoration: none;
}

.received-orders-table .sodep-order-link:hover {
    text-decoration: underline;
}

.woocommerce-account .portal-table-wrap table.received-orders-table .received-toggle-cell {
    width: 2.75rem;
    padding-right: 0 !important;
    padding-left: .5rem !important;
}

.received-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--portal-primary);
}

.received-toggle:hover {
    background: #e6ece3;
}

.received-toggle svg {
    transition: transform 160ms ease;
}

.received-toggle[aria-expanded="true"] svg {
    transform: rotate(90deg);
}

.received-address-summary {
    display: block;
    min-width: 7rem;
    max-width: 12.5rem;
}

/* États de paiement et d'expédition */
.received-status--payment-payee,
.received-status--shipping-expediee {
    border-color: #b8c7a1;
    background: var(--portal-soft);
    color: #2f4a22;
}

.received-status--payment-facturee,
.received-status--shipping-a-expedier,
.received-status--shipping-partielle {
    border-color: #f2c1a9;
    background: #fdf0e9;
    color: #8a3d1c;
}

.received-status--payment-attente,
.received-status--shipping-attente-paiement,
.received-status--shipping-sans-envoi {
    border-color: #d5dadc;
    background: #f1f3f4;
    color: var(--sodep-slate-dark);
}

.received-status--payment-echec,
.received-status--payment-remboursee,
.received-status--payment-annulee,
.received-status--shipping-annulee {
    border-color: #efc2bc;
    background: #fbeceb;
    color: #8f2e24;
}

.received-orders-table td .received-status {
    white-space: normal;
}

.sodep-order-states,
.sodep-order-states-line {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .375rem;
}

/* Détail d'une commande */
.woocommerce-account .portal-table-wrap table.received-orders-table .received-order-details > td {
    padding: .25rem 1rem 1.25rem 3.25rem !important;
    border-top: 0 !important;
    background: #f7f9f3;
}

.received-details-content {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(12rem, 1fr);
    gap: 1rem 1.5rem;
    max-width: 60rem;
}

.received-details-content h3 {
    margin: 0 0 .6rem;
    color: var(--portal-primary);
    font-size: .75rem !important;
    font-weight: 700;
    letter-spacing: .055em;
    line-height: 1.3 !important;
    text-transform: uppercase;
}

.received-destination {
    margin-bottom: .6rem;
    padding: .75rem 1rem .5rem;
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    background: #fff;
}

.received-destination--match {
    border-color: var(--portal-primary);
}

.received-destination__address {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: .45rem;
    margin: 0 0 .35rem;
    color: var(--portal-ink);
    font-size: .9rem !important;
    font-weight: 500;
    line-height: 1.45 !important;
}

.received-destination__address svg {
    flex: 0 0 auto;
    margin-top: .15rem;
    color: var(--portal-primary);
}

.received-destination__address span:first-of-type {
    flex: 1 1 12rem;
}

.received-match-label {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    background: var(--portal-soft);
    font-size: .75rem;
    font-weight: 600;
}

.received-items {
    width: 100%;
    border-collapse: collapse;
}

.received-orders-table .received-items thead {
    background: transparent;
}

.woocommerce-account .portal-table-wrap table.received-orders-table .received-items th {
    padding: .35rem 0 !important;
    color: var(--portal-muted);
    font-size: .7rem;
    white-space: normal;
}

.woocommerce-account .portal-table-wrap table.received-orders-table .received-items td {
    padding: .45rem 0 !important;
    font-size: .875rem !important;
}

.received-orders-table .received-items th:not(:first-child),
.received-orders-table .received-items td:not(:first-child) {
    width: 7rem;
    text-align: right !important;
}

.received-allocation-warning {
    display: inline-block;
    margin-left: .5rem;
    padding: .05rem .45rem;
    border-radius: 999px;
    background: #fdf0e9;
    color: #8a3d1c;
    font-size: .75rem;
    font-weight: 600;
    cursor: help;
}

.received-details-aside p {
    margin: 0 0 .5rem;
    overflow-wrap: anywhere;
    font-size: .9rem !important;
    line-height: 1.5 !important;
}

.received-details-aside a {
    color: var(--portal-primary-dark);
    text-underline-offset: .2em;
}

.received-details-aside .received-details-link {
    margin-top: .5rem;
    color: var(--portal-primary-dark);
    text-decoration: none;
}

/* Commentaires d'expédition */
.received-details-comments {
    grid-column: 1 / -1;
}

.received-comments {
    margin: 0 0 .75rem;
    padding: 0;
    list-style: none;
}

.received-comments li {
    padding: .6rem .85rem;
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    background: #fff;
}

.received-comments li + li {
    margin-top: .5rem;
}

.received-comment__meta,
.received-comments__empty,
.received-comment-form__help {
    margin: 0 0 .25rem;
    color: var(--portal-muted);
    font-size: .8rem !important;
    line-height: 1.4 !important;
}

.received-comment__meta strong {
    color: var(--portal-ink);
}

.received-comment__content {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: .9rem !important;
    line-height: 1.5 !important;
}

.received-comments__empty {
    margin-bottom: .75rem;
}

.received-comment-form {
    display: grid;
    gap: .35rem;
    max-width: 40rem;
}

.received-comment-form label {
    font-size: .85rem;
    font-weight: 600;
}

.received-comment-form .portal-button {
    justify-self: start;
}

.received-comment-summary {
    overflow-wrap: anywhere;
}

/* Pagination */
.received-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    margin: 1.25rem 0 0;
}

.received-pagination__link {
    display: inline-flex;
    align-items: center;
    min-height: 2.4rem;
    padding: .4rem .85rem;
    border: 1px solid #cdd4ce;
    border-radius: 999px;
    background: #fff;
    color: var(--portal-primary-dark);
    font-size: .9rem !important;
    font-weight: 600;
    text-decoration: none;
}

a.received-pagination__link:hover {
    border-color: var(--portal-primary);
    background: var(--portal-soft);
    color: var(--portal-ink);
}

span.received-pagination__link {
    opacity: .4;
}

.received-pagination__current {
    padding: 0 .75rem;
    color: var(--portal-muted);
    font-size: .9rem !important;
}

/* Rapport par numéro */
.received-report {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1.25rem;
    overflow: visible;
}

.received-report__intro {
    flex: 1 1 22rem;
}

.received-report__intro h3 {
    margin: 0 0 .25rem;
    color: var(--portal-ink);
    font-size: 1.05rem !important;
    font-weight: 700;
}

.received-report__intro p {
    margin: 0;
    color: var(--portal-muted);
    font-size: .9rem !important;
    line-height: 1.5 !important;
}

.received-report .received-legacy-report {
    margin: 0;
}

.received-report .received-legacy-report[open] {
    flex-basis: 100%;
}

.received-report .portal-report-selector > form {
    margin-top: .85rem;
}

/* Menus de filtre des colonnes */
.received-column-trigger {
    display: flex;
    align-items: center;
    gap: .45rem;
    border: 0;
    padding: .35rem 0;
    background: transparent;
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    white-space: nowrap;
}

.received-column-trigger:hover,
.received-column-trigger--active {
    color: var(--portal-ink);
}

.received-filter-indicator {
    width: .45rem;
    height: .45rem;
    border-radius: 50%;
    background: var(--portal-accent);
}

.received-column-menu {
    width: 19rem;
    max-width: calc(100vw - 2rem);
    max-height: min(32rem, calc(100vh - 3rem));
    overflow-y: auto;
    z-index: var(--sodep-z-column-menu);
    padding: 1rem;
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    box-shadow: var(--portal-shadow);
    background: var(--portal-surface);
    color: var(--portal-text);
    font-size: .9rem;
    font-weight: 400;
    text-align: left;
    letter-spacing: normal;
    text-transform: none;
    white-space: normal;
}

.received-column-menu fieldset {
    border: 0;
    padding: 0;
    margin: 0;
}

.received-column-menu legend {
    color: var(--portal-ink);
    float: none;
    width: 100%;
    line-height: 1.4;
    text-transform: none;
    letter-spacing: normal;
    margin-bottom: .8rem;
    font-size: .95rem;
    font-weight: 700;
}

.received-column-menu label:not(.received-choice) {
    display: block;
    margin: .6rem 0 .3rem;
    font-size: .85rem;
    font-weight: 600;
}

.received-column-menu-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-top: 1rem;
}

.received-column-menu-actions .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: .55rem 1rem;
    border: 1px solid var(--portal-primary);
    border-radius: 999px;
    background: var(--portal-primary);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    text-transform: none;
    font-size: .85rem;
}

.received-column-sort {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin-top: 1rem;
    padding-top: .8rem;
    border-top: 1px solid var(--portal-border);
}

.received-column-sort a {
    color: var(--portal-primary-dark);
}

.received-column-menu :focus-visible {
    outline: 2px solid var(--portal-primary);
    outline-offset: 3px;
}

@media (max-width: 767px) {
    .received-search-form {
        padding: .85rem;
    }
    .received-search-main .portal-button,
    .received-search-scope {
        flex: 1 1 auto;
    }
    .received-search .portal-table-wrap {
        overflow-x: auto !important;
    }
    .woocommerce-account .portal-table-wrap table.received-orders-table {
        display: table !important;
    }
    .received-orders-table > tbody {
        display: table-row-group !important;
    }
    .received-orders-table thead {
        display: table-header-group !important;
    }
    .received-orders-table tr {
        display: table-row !important;
    }
    .received-orders-table td:not([hidden]) {
        display: table-cell !important;
        text-align: left !important;
    }
    .received-orders-table td::before {
        display: none !important;
    }
    .woocommerce-account .portal-table-wrap table.received-orders-table .received-order-details > td {
        padding-left: 1rem !important;
    }
    .received-details-content {
        grid-template-columns: minmax(0, 1fr);
    }
}

.received-column-menu .received-choice {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--portal-text);
    font-size: .9rem;
    font-weight: 400;
    line-height: 1.5;
    text-transform: none;
    letter-spacing: normal;
}

.received-column-menu .received-choice input {
    flex: 0 0 1.1rem;
}

.received-column-menu-actions .btn-outline-secondary {
    background: #fff;
    color: var(--portal-primary-dark);
}

.received-column-menu-actions .btn:hover {
    background: var(--portal-soft);
    border-color: var(--portal-primary);
    color: var(--portal-ink);
}

.received-column-menu .received-choice-actions button {
    font-family: inherit;
    line-height: 1.5;
}
