@media (min-width: 1024px) {
    .fi-main-sidebar.fi-sidebar-open {
        flex: 0 0 var(--sidebar-width);
        width: var(--sidebar-width) !important;
        min-width: var(--sidebar-width);
    }

    .fi-main-sidebar:not(.fi-sidebar-open) {
        flex: 0 0 var(--collapsed-sidebar-width);
        width: var(--collapsed-sidebar-width) !important;
        min-width: var(--collapsed-sidebar-width);
    }

    .fi-main-ctn.fi-main-ctn-sidebar-open {
        flex: 1 1 calc(100vw - var(--sidebar-width));
        width: calc(100vw - var(--sidebar-width)) !important;
        max-width: calc(100vw - var(--sidebar-width));
    }

    .fi-main-ctn:not(.fi-main-ctn-sidebar-open) {
        flex: 1 1 calc(100vw - var(--collapsed-sidebar-width));
        width: calc(100vw - var(--collapsed-sidebar-width)) !important;
        max-width: calc(100vw - var(--collapsed-sidebar-width));
    }

    .fi-main {
        min-width: 0;
    }

    .fi-topbar nav {
        position: relative;
    }

    .fi-centered-brand-hook {
        position: absolute;
        inset-block: 0;
        left: 50%;
        display: flex;
        align-items: center;
        transform: translateX(-50%);
        pointer-events: auto;
        z-index: 10;
    }

    .fi-centered-brand-hook img {
        height: 2rem;
    }

    .fi-sidebar-header > div:first-child {
        display: none;
    }
}

@media (max-width: 1023.98px) {
    .fi-centered-brand-hook {
        display: none;
    }

    .fi-topbar nav {
        position: static;
    }

    .fi-sidebar-header > div:first-child {
        display: flex;
    }

    /* Lists: allow horizontal scroll when table is wider than viewport */
    .fi-ta-ctn {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .fi-ta-ctn::-webkit-scrollbar {
        height: 6px;
    }

    .fi-ta-ctn::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.5);
        border-radius: 3px;
    }

    /* Prevent table cells from wrapping so columns stay aligned when scrolling */
    .fi-ta-table .fi-ta-cell,
    .fi-ta-table .fi-ta-header-cell {
        white-space: nowrap;
    }

    /* Sticky first column (checkbox/id) — keeps selection & row anchor visible when scrolling */
    .fi-ta-table tr > *:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: inherit;
    }

    .fi-ta-table thead tr > *:first-child {
        background: rgb(249 250 251);
    }

    .fi-ta-table tbody tr > *:first-child {
        background: #fff;
    }

    .fi-ta-table tbody tr:hover > *:first-child {
        background: rgb(249 250 251);
    }

    /* Sticky bottom CTA bar (Сохранить/Отмена/Удалить) on forms */
    .fi-form-actions {
        position: sticky;
        bottom: 0;
        z-index: 15;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        margin-inline: -1rem;
        border-top: 1px solid rgba(228, 228, 231, 1);
        box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.06);
    }

    .fi-form-actions .fi-ac {
        justify-content: center;
        gap: 0.5rem;
    }

    .fi-form-actions .fi-btn {
        flex: 1;
        min-height: 44px; /* Apple HIG touch target */
        justify-content: center;
    }

    /* Extra bottom padding so form content doesn't hide under sticky bar */
    .fi-form {
        padding-bottom: 1rem;
    }

    /* Safe-area for iPhone notch/Dynamic Island in standalone PWA */
    .fi-topbar {
        padding-top: env(safe-area-inset-top, 0px);
    }

    .fi-main {
        padding-left: max(1rem, env(safe-area-inset-left, 0px));
        padding-right: max(1rem, env(safe-area-inset-right, 0px));
    }
}

@media (max-width: 1535.98px) {
    .fi-page-sub-navigation-scroll-shell {
        position: relative;
    }

    .fi-page-sub-navigation-tabs {
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        padding-bottom: 0.25rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .fi-page-sub-navigation-scroll-shell.is-scrollable .fi-page-sub-navigation-tabs {
        padding-inline: 1.75rem;
    }

    .fi-page-sub-navigation-tabs > * {
        flex: none;
    }

    .fi-page-sub-navigation-scroll-arrow {
        position: absolute;
        top: 50%;
        z-index: 20;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 1.75rem;
        height: 1.75rem;
        margin-top: -0.875rem;
        border: 1px solid rgba(228, 228, 231, 1);
        border-radius: 9999px;
        background: rgba(255, 255, 255, 0.96);
        color: rgba(82, 82, 91, 1);
        box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
        transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    }

    .fi-page-sub-navigation-scroll-arrow:hover:not(:disabled) {
        color: rgba(29, 78, 216, 1);
        border-color: rgba(147, 197, 253, 1);
        transform: translateY(-1px);
    }

    .fi-page-sub-navigation-scroll-arrow:disabled {
        opacity: 0;
        pointer-events: none;
    }

    .fi-page-sub-navigation-scroll-arrow--left {
        left: 0.25rem;
    }

    .fi-page-sub-navigation-scroll-arrow--right {
        right: 0.25rem;
    }

    .fi-page-sub-navigation-scroll-arrow svg {
        width: 1rem;
        height: 1rem;
    }
}

.fi-page-sub-navigation-tabs {
    gap: 0.125rem !important;
}

.fi-page-sub-navigation-tabs .fi-tabs-item {
    gap: 0.25rem !important;
    padding-inline: 0.375rem !important;
}

.fi-page-sub-navigation-tabs .fi-tabs-item,
.fi-page-sub-navigation-tabs .fi-tabs-item-label {
    font-size: 11px !important;
    line-height: 1.2 !important;
}
