/* La sidebar ampia e' riutilizzabile senza cambiare il profilo dei report. */
body.cfo-ui-touch,
body.cfo-sidebar-wide {
    --cfo-sidebar-width: min(88vw, 340px);
}

/* Shell touch: stessi dati e controller, controlli piu grandi e gesture sicure. */
body.cfo-ui-touch {
    --cfo-control-min-height: 48px;
    --cfo-touch-gap: 12px;
    -webkit-tap-highlight-color: rgba(31, 79, 159, .16);
    touch-action: manipulation;
}

body.cfo-ui-touch .btn,
body.cfo-ui-touch .form-control,
body.cfo-ui-touch .form-select,
body.cfo-ui-touch .nav-link,
body.cfo-ui-touch button,
body.cfo-ui-touch [role="button"] {
    min-height: var(--cfo-control-min-height);
}

body.cfo-ui-touch :is(
    .area-home-section-heading > .btn,
    .area-home-source-actions .btn,
    .area-home-relink-form .btn,
    .cfo-source-file-buttons .btn,
    .cfo-source-file-bar .cfo-relink-source-controls .btn
) {
    min-height: 32px;
}

body.cfo-ui-touch :is(
    .area-home-relink-form .form-control,
    .cfo-source-file-bar .cfo-relink-source-controls .form-control
) {
    min-height: 32px;
    height: 32px;
}

body.cfo-ui-touch .btn,
body.cfo-ui-touch .nav-link,
body.cfo-ui-touch button,
body.cfo-ui-touch summary,
body.cfo-ui-touch label {
    cursor: pointer;
}

body.cfo-ui-touch .app-sidebar .nav-link {
    align-items: center;
    padding-block: 11px;
}

body.cfo-ui-touch .sidebar-toggle-btn,
body.cfo-sidebar-wide .sidebar-toggle-btn {
    position: fixed !important;
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    z-index: 1060;
    width: 48px;
    height: 48px;
    touch-action: manipulation;
}

body.cfo-ui-touch:not(.sidebar-collapsed) .sidebar-toggle-btn,
body.cfo-sidebar-wide:not(.sidebar-collapsed) .sidebar-toggle-btn {
    left: calc(var(--cfo-sidebar-width) - 62px);
}

body.cfo-ui-touch.sidebar-collapsed .sidebar-toggle-btn,
body.cfo-sidebar-wide.sidebar-collapsed .sidebar-toggle-btn {
    left: max(10px, env(safe-area-inset-left));
}

body.cfo-ui-touch input,
body.cfo-ui-touch select,
body.cfo-ui-touch textarea {
    font-size: 16px;
}

body.cfo-ui-touch .table-responsive,
body.cfo-ui-touch .annual-progression-scroll,
body.cfo-ui-touch .finance-preview-table-wrap {
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
}

body.cfo-ui-touch .card,
body.cfo-ui-touch details,
body.cfo-ui-touch .page-title-card {
    scroll-margin-top: 16px;
}

@media (max-width: 1180px), (pointer: coarse) {
    body.cfo-ui-touch .app-wrapper > .main-content,
    body.cfo-ui-touch .wrapper > #content,
    body.cfo-ui-touch > .d-flex > main,
    body.cfo-ui-touch > .d-flex > .flex-grow-1 {
        margin-left: 0;
        width: 100%;
        padding: 72px 16px 24px !important;
    }

    body.cfo-ui-touch:not(.sidebar-collapsed) .sidebar-mobile-backdrop {
        position: fixed;
        inset: 0 0 0 var(--cfo-sidebar-width);
        z-index: 1020;
        display: block;
        background: rgba(15, 23, 42, .16);
        opacity: 1;
        pointer-events: auto;
    }

    body.cfo-ui-touch .page-title-card {
        grid-template-columns: 1fr;
        gap: 14px;
        padding: 16px;
    }

    body.cfo-ui-touch .page-client-context {
        justify-self: start;
        width: 100%;
        max-width: none;
        text-align: left;
    }
}

@media (max-width: 520px) {
    body.cfo-ui-touch .btn-group,
    body.cfo-ui-touch .page-actions,
    body.cfo-ui-touch .header-actions {
        align-items: stretch;
        width: 100%;
        flex-direction: column;
        gap: var(--cfo-touch-gap);
    }
}
