/* ORIZZONTE / shared small-screen ergonomics. Desktop Flightdeck stays intact. */
.workspace-skip { position: absolute; left: 16px; top: -100px; z-index: 11000; padding: 12px 18px; background: #eaf0e9; color: #193b4b; }
.workspace-skip:focus { top: 12px; }
.workspace-mobile-label { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mobile-current-section, #member-menu-bar { display: none; }
#navMenu[hidden], #member-navigation[hidden] { display: none !important; }
.workspace-table-scroll { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.workspace-table-scroll:focus-visible { outline: 3px solid #b48130; outline-offset: 3px; }
.member-profile-text { display: none; }
@media (max-width: 767px) {
    html { scroll-padding-top: 106px; }
    .main-content, .ma-main, .card, .ma-panel, .modal-content, .ma-page dialog,
    .main-content > *, .ma-main > *, .dashboard-grid > *, .form-row > * { min-width: 0; }
    .main-content, .ma-main { max-width: 100%; }
    .main-content { padding: 22px 14px 36px; }
    .main-content .main-content { padding: 0; margin: 0; width: 100%; }
    .main-content h1, .ma-page h1 { overflow-wrap: anywhere; }
    .main-content p, .ma-page p, .ma-check span { overflow-wrap: anywhere; }
    .main-content input:not([type=checkbox]):not([type=radio]),
    .main-content select, .main-content textarea,
    .ma-page input:not([type=checkbox]):not([type=radio]), .ma-page select, .ma-page textarea {
        max-width: 100%; min-width: 0; min-height: 46px; font-size: 16px;
    }
    .main-content input[type=file] { width: 100%; }
    .main-content button, .main-content .btn, .ma-button, .ma-nav button,
    .ma-header > a, .communication-nav__item { min-height: 44px; }
    .main-content .btn, .ma-button { white-space: normal; overflow-wrap: anywhere; }
    .main-content .page-header, .main-content .section-header { flex-wrap: wrap; gap: 14px; }
    .main-content .page-header > *, .main-content .section-header > * { min-width: 0; max-width: 100%; }
    .main-content .form-row { grid-template-columns: minmax(0, 1fr) !important; }
    .main-content .form-group { min-width: 0; }
    .main-content .filters { align-items: stretch; }
    .main-content .filters > * { min-width: 0; max-width: 100%; }
    .main-content .filters input, .main-content .filters select { flex: 1 1 140px; }
    .table-container, .table-wrapper, .table-responsive, .ma-table-wrap, .workspace-table-scroll {
        width: 100%; max-width: 100%; margin-left: 0; margin-right: 0;
        padding-left: 0; padding-right: 0; overflow-x: auto; overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }
    .ma-page .ma-table-wrap { min-width: 0; }
    .main-content .table-container .btn, .ma-table-wrap .ma-button { min-height: 44px; }
    .ma-page .ma-check { min-height: 44px; align-items: flex-start; padding: 8px 0; }
    .ma-page .ma-check input { margin-top: 3px; }
    .ma-page .ma-header { gap: 10px 16px; }
    .ma-page[data-page=admin] .ma-header > a { display: inline-flex; align-items: center; font-size: .75rem; }
    .ma-page[data-page=admin] .ma-header .ma-brand { flex: 1 0 100%; }
    .ma-page[data-page=admin] .ma-intro { margin-bottom: 22px; }
    .ma-page[data-page=admin] .ma-policy { display: grid; gap: 3px; }
    .ma-page .ma-actions { gap: 10px; }
    .ma-page .ma-actions .ma-button { flex: 1 1 130px; }
    .ma-page .ma-scopes { max-height: min(230px, 38dvh); overscroll-behavior-y: contain; }
    .ma-page .ma-scopes .ma-check { border-bottom: 1px solid #d2deda; }
    .ma-page fieldset { padding: 12px; }
    .ma-page legend { max-width: 100%; }
    .permission-section label { min-height: 44px; overflow-wrap: anywhere; }
    #activityLogsPagination { flex-wrap: wrap; gap: 12px; }
    .modal { padding: 12px; overflow-y: auto; overscroll-behavior-y: contain; }
    .modal .modal-content, .ma-page dialog {
        box-sizing: border-box;
        max-width: calc(100vw - 24px) !important;
        max-height: calc(var(--workspace-viewport-height, 100dvh) - 24px) !important;
        overflow-y: auto; overscroll-behavior-y: contain;
        scroll-padding-block: 20px;
    }
    .modal .modal-content { margin: auto; }
    .modal-header, .modal-header-simple, .modal-footer, .form-actions, .action-buttons {
        flex-wrap: wrap; gap: 10px;
    }
    .modal .modal-body, .modal .modal-body-simple, .modal .modal-header { padding: 18px 16px; }
    .modal .close, .modal .close-modal { min-width: 44px; min-height: 44px; }
    /* Shared communication sections retain their fixed 2×2 order on all pages. */
    .communication-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .communication-subnav { flex-wrap: wrap; }
    .communication-subnav .communication-nav__item { flex: 1 1 110px; min-height: 44px; }
    /* Administrative navigation: a nonmodal, in-flow disclosure, not an offscreen drawer. */
    .navbar { max-height: var(--workspace-viewport-height, 100dvh); overflow-y: auto; overscroll-behavior-y: contain; }
    .navbar .nav-container { flex-wrap: wrap; gap: 10px; padding: 12px 15px; }
    .navbar .nav-brand { flex: 1; min-width: 0; }
    .navbar .nav-brand-row { justify-content: flex-start; }
    .navbar .nav-brand-logo { max-height: 42px !important; }
    .navbar .burger-menu {
        display: flex; align-items: center; justify-content: center; flex-shrink: 0;
        width: 46px; height: 46px; padding: 11px; border-radius: 7px; z-index: auto;
    }
    .navbar .burger-menu:hover { transform: none; }
    .navbar .burger-menu span { height: 2px; width: 23px; }
    .navbar .burger-menu.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .navbar .burger-menu.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
    .mobile-current-section { display: block; color: #abcbd2; font: .62rem/1.6 var(--fd-mono); margin-top: 6px; letter-spacing: .04em; }
    .navbar #navMenu {
        position: static; display: none; flex: 1 0 100%; width: 100%; max-width: 100%;
        height: auto; max-height: none; margin: 0; padding: 12px 0 6px;
        border: 0; border-top: 1px solid #44616a; background: transparent;
        box-shadow: none; transition: none; overflow: visible;
    }
    .navbar #navMenu.active { display: flex; }
    .navbar #navMenu .nav-links { flex: none; padding: 8px 0; }
    .navbar #navMenu .nav-user-top { order: 1; border: 0; border-top: 1px solid #44616a; margin: 0; padding: 12px 0 0; gap: 4px; }
    .navbar #navMenu .nav-link { margin: 0; min-height: 46px; font-size: .9rem; padding: 11px 13px; }
    .navbar #navMenu .nav-text-user { display: inline; }
    .navbar #navMenu .company-selector-wrapper-brand,
    .navbar #navMenu .current-company-badge-brand { width: 100%; margin: 0; padding: 8px 12px; max-width: none; }
    .navbar #navMenu .current-company-badge-brand { font-size: .8rem; white-space: normal; overflow-wrap: anywhere; }
    .navbar #navMenu .workspace-mobile-label { position: static; display: block; width: auto; height: auto; clip-path: none; margin-bottom: 7px; font-size: .74rem; color: #bfd5d9; }
    .navbar #companySelectorNav { width: 100%; max-width: 100%; min-height: 46px; font-size: 16px; }
    .navbar #navMenu .company-selector-wrapper-brand { display: block; }
    /* Representative navigation: one compact top row, current section + own profile. */
    #member-menu-bar {
        display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px;
        align-items: center; gap: 10px; padding: 8px;
        background: #dce8e5; border: 1px solid #b6cdcd; border-radius: 9px;
        margin-bottom: 20px;
    }
    #member-menu-toggle, #member-profile-shortcut {
        display: inline-flex; justify-content: center; align-items: center;
        width: 44px; height: 44px; padding: 10px; color: #19495d;
        border: 1px solid #acc4c7; border-radius: 6px; background: #edf2ec; cursor: pointer;
    }
    #member-menu-toggle[aria-expanded=true], #member-profile-shortcut[aria-current=page] { background: #123c50; color: #edf4ed; }
    #member-menu-bar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
    #member-current-section { font-size: .85rem; font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
    #member-current-section::before { content: "Area iscritti"; display: block; margin-bottom: 4px; font: .56rem/1.5 var(--fd-mono); color: #607e85; text-transform: uppercase; letter-spacing: .08em; }
    .ma-page[data-page=portal] #member-navigation { display: none; margin: -9px 0 20px; padding: 7px; background: #e0eae5; border: 1px solid #b6cdcd; border-radius: 8px; }
    .ma-page[data-page=portal] #member-navigation[data-open=true] { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
    .ma-page[data-page=portal] #member-navigation button { width: 100%; text-align: left; padding: 12px 14px; }
    .ma-page[data-page=portal] #member-navigation #nav-profile { width: 100%; max-width: none; margin: 0; justify-self: stretch; justify-content: flex-start; gap: 12px; border: 0; }
    #member-navigation .member-profile-text { display: inline; }
    .ma-page[data-page=portal] .arrival-context { margin-bottom: 15px; }
    .ma-page[data-page=portal] .ma-main { margin-top: 18px; }
    /* Keep the intentionally card-shaped directory out of generic table scrolling. */
    .ma-page .ma-contact-table { overflow: visible; }
}
@media (max-width: 767px) and (max-height: 480px) {
    .navbar { position: relative; }
    .modal[style*="display: block"], .modal[style*="display: flex"] { align-items: flex-start !important; }
    .ma-page .ma-auth { margin-top: 18px; }
}
@media (max-width: 360px) {
    .permission-section > div:last-child { grid-template-columns: minmax(0, 1fr) !important; }
}
@media (max-width: 1023px) and (max-height: 480px) {
    .navbar { position: relative; }
    .modal .modal-content, .ma-page dialog { max-height: calc(var(--workspace-viewport-height, 100dvh) - 24px) !important; }
    .modal { overflow-y: auto; padding: 12px; }
}
