/* R4.3B: shared long-text containers retain their complete content. */
body .viewer-title,
body .viewer-actions,
body .tree-label > *,
body .intervenant-header,
body .intervenant-card,
body .intervenant-card .section-header > *,
body .intervenant-form-grid > *,
body .syndic-interactions-header > * {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

body .tree-label,
body .tree-label > *,
body .intervenant-header__subtitle,
body .syndic-interactions-badge {
    overflow-wrap: anywhere;
    white-space: normal;
}

body .syndic-interactions-header { flex-wrap: wrap; }

@media (max-width: 820px) {
    body .syndic-sidebar__footer {
        display: block;
        margin-top: 10px;
    }
    body .syndic-support {
        display: grid;
        grid-template-columns: 34px minmax(0, 1fr);
        gap: 6px 12px;
        min-height: 44px;
    }
    body .syndic-support__icon { grid-row: 1 / 3; }
    body .syndic-support__title { margin: 0; }
    body .syndic-support__text { grid-column: 2; }
}

@media (max-width: 640px), (max-width: 1023px) and (max-height: 500px) and (orientation: landscape) {
    body .tree-toggle,
    body .tree-view-link,
    body .parc-analysis__filter,
    body .viewer-btn {
        min-width: 44px;
        min-height: 44px;
    }
    body .tree-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
    body .viewer-top { flex-wrap: wrap; }
    body .viewer-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 620px) {
    body .tree-row { grid-template-columns: 44px minmax(0, 1fr); }
}

/* R4.1: long business text must shrink and wrap at every viewport width. */
body .expertise-header > *,
body .expertise-heading > *,
body .expertise-row > *,
body .expertise-form-grid > *,
body .expertise-page .expertise-button,
body .expertise-access-card,
body .syndic-summary-grid > *,
body .summary-card-header > *,
body .summary-manager-note,
body .summary-manager-note-top > *,
body .summary-info-grid > *,
body .reporting-header > *,
body .syndic-reporting-hero > * {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
}

body .expertise-page .expertise-button,
body .expertise-eyebrow,
body .reporting-header__subtitle,
body .syndic-reporting-hero__title,
body .summary-manager-note p,
body .summary-info-item strong {
    overflow-wrap: anywhere;
    white-space: normal;
}

body .expertise-lot-tabs > a { flex: 0 1 auto; }

/* Phone landscape only: leave desktop and tablet landscape unchanged. */
@media (min-width: 769px) and (max-width: 1023px) and (max-height: 500px) and (orientation: landscape) {
    body .avenor-header__cta,
    body .avenor-header--main .avenor-header__navigation > .avenor-header__link {
        min-width: 44px;
        min-height: 44px;
    }
}

/* R3: shared presentation only; native dialog top-layer behavior is retained. */
body .timeline-modal:not([hidden]),
body .demandes-overlay:not([hidden]),
body .invoice-drawer.is-open {
    z-index: var(--avenor-z-overlay, 9999);
}

@media (max-width: 768px) {
    /* Keep every finance tab, with a local, keyboard-reachable scroll area. */
    .billing-app .finance-tabs {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-padding-inline: 6px;
    }
    .billing-app .finance-tab { flex: 0 0 auto; }

    .viewer-top {
        flex-direction: column;
        align-items: stretch;
    }
    .viewer-title,
    .viewer-actions {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }
    .viewer-actions .viewer-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        max-width: 100%;
        white-space: normal;
    }

    .expertise-page .expertise-button,
    .expertise-page .expertise-field,
    .expertise-page .expertise-row > *,
    .expertise-page .expertise-access-card,
    .expertise-page .expertise-access-card a {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
        white-space: normal;
    }
    .expertise-page fieldset { min-width: 0; }
    .expertise-page .expertise-lot-tabs > a { flex: 0 1 auto; }

    .general-mail__header {
        flex-direction: column;
        align-items: flex-start;
    }
    .general-mail__header > * {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }
    .general-mail__back {
        display: inline-flex;
        align-items: center;
    }
    .general-mail__classify { min-width: 0; }
    .general-mail__detail { padding: 16px; }
    .general-mail__form label,
    .general-mail__form input,
    .general-mail__form select,
    .general-mail__form textarea { min-width: 0; }

    /* Only the hit area grows; desktop and native checkbox visuals stay intact. */
    body .avenor-header__cta,
    body .avenor-header--main .avenor-header__navigation > .avenor-header__link,
    body .viewer-btn,
    body .expertise-button,
    body .expertise-tab,
    body .general-mail__back,
    body .general-mail__submit,
    body .general-mail__new-summary,
    body .finance-tab,
    body .billing-btn,
    body .period-nav,
    body .drawer-close,
    body .conversation-action,
    body .new-message-button,
    body .new-message-close,
    body .thread-note-close,
    body .conversation-note-icon,
    body .thread-action-btn,
    body .treated-toggle,
    body .sinistre-premium-edit-btn,
    body .note-edit-btn,
    body .timeline-add-main-btn,
    body .timeline-delete-btn,
    body .travaux-submit,
    body .travaux-cancel,
    body .syndic-tab,
    body .syndic-assistance-overlay__close,
    body .demandes-overlay__close,
    body .avenor-login-password-toggle,
    body .manual-invoices__number,
    body .billing-link-btn,
    body .general-mail__treated-button,
    body .sinistres-action-btn,
    body .facturation-reset,
    body .summary-validation-btn,
    body .summary-description-btn,
    body .expertise-page summary,
    body .billing-app summary {
        min-height: 44px;
        min-width: 44px;
    }
    body .timeline-toggle-form label {
        min-height: 44px;
        min-width: 44px;
    }

    /* Preserve all table rows/columns and horizontal scrolling. */
    body .sinistres-card,
    body .manual-invoices,
    body .facturation-table-wrap {
        max-width: 100%;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: auto;
        scrollbar-color: #d9a441 #172133;
        padding-bottom: 12px;
    }
    .sinistres-card:focus-visible,
    .manual-invoices:focus-visible,
    .facturation-table-wrap:focus-visible {
        outline: 2px solid #d9a441;
        outline-offset: 3px;
    }
    .sinistres-card::-webkit-scrollbar,
    .manual-invoices::-webkit-scrollbar,
    .facturation-table-wrap::-webkit-scrollbar { height: 14px; }
    .sinistres-card::-webkit-scrollbar-thumb,
    .manual-invoices::-webkit-scrollbar-thumb,
    .facturation-table-wrap::-webkit-scrollbar-thumb {
        background: #d9a441;
        border-radius: 7px;
    }
}

@media (max-width: 640px) {
    /* Two rows of 44px controls plus their existing gap and padding. */
    body:has(.avenor-header--main .avenor-header__logout-form) {
        --avenor-header-height: 120px;
    }
}
