/* 4Sofit Web — Mobile-first responsive (v3) */

:root {
    --mobile-header-h: 52px;
    --mobile-bottom-nav-h: 62px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    /* Shell drawer: ≤992px — see responsive-core.css for full breakpoint map */
    --shell-drawer-max: 992px;
}

/* ── Desktop: hide mobile-only UI ── */
.mobile-nav-backdrop,
.mobile-bottom-nav,
.sidebar-mobile-close {
    display: none;
}

.mobile-menu-btn {
    display: none;
}

@media (min-width: 1024px) {
    .sidebar-flyout-backdrop {
        display: none !important;
    }
}

/* لوحة التنبيهات — انظر notifications-premium.css */

/* تابلت/لمس: لوحة فرعية كاملة بدلاً من flyout عائم */
@media (pointer: coarse) {
    .sidebar-flyout-backdrop {
        display: block !important;
        z-index: 950;
        background: rgba(2, 6, 23, 0.45);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .sidebar-flyout-close {
        display: inline-flex;
    }

    .sidebar-flyout.is-side-panel {
        z-index: 980 !important;
        pointer-events: auto;
        touch-action: manipulation;
        min-width: 0 !important;
        max-width: none !important;
        border-radius: 0 !important;
        border: none !important;
        border-inline-start: 1px solid rgba(94, 234, 212, 0.12) !important;
        box-shadow: -16px 0 48px rgba(0, 0, 0, 0.35) !important;
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        animation: flyoutDrillIn 0.26s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .sidebar-shell.is-flyout-open .sidebar-groups,
    .sidebar-shell.is-flyout-open .sidebar-footer {
        visibility: hidden;
        pointer-events: none;
    }

    .sidebar-flyout-header {
        padding: 14px 14px 12px;
        padding-top: calc(14px + env(safe-area-inset-top, 0));
    }

    .sidebar-flyout-title {
        font-size: 15px;
    }

    .sidebar-flyout-items {
        padding: 8px 10px 20px;
        gap: 8px;
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-flyout-item {
        min-height: 52px;
        padding: 12px 14px;
        font-size: 14px;
        font-weight: 600;
        border-radius: 12px;
        background: rgba(19, 42, 61, 0.72);
        border: 1px solid rgba(30, 58, 79, 0.85);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .sidebar-flyout-item.is-active {
        background: rgba(13, 148, 136, 0.24);
        border-color: rgba(94, 234, 212, 0.32);
        color: #99f6e4;
    }

    .sidebar-flyout-item:active {
        background: rgba(13, 148, 136, 0.32);
        color: #99f6e4;
        transform: scale(0.985);
    }

    .sidebar-flyout-item-label {
        font-size: 14px;
    }
}

/* Tablet: 768–1023px */
@media (min-width: 768px) and (max-width: 1023px) {
    .dash-alert-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

/* ── Tablet (legacy max-width rules) ── */
@media (max-width: 1024px) {
    .topbar-meta .version-badge,
    .topbar-meta > span:last-child {
        display: none;
    }

    .page-toolbar-tools {
        flex-wrap: wrap;
    }

    .dash-alert-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ── Mobile layout (phone + small tablet) ── */
@media (max-width: 992px) {
    html, body {
        height: 100%;
        overflow: hidden;
    }

    body.mobile-scroll-lock {
        overflow: hidden;
        overscroll-behavior: none;
    }

    .app-shell {
        display: flex;
        flex-direction: row !important;
        height: 100dvh;
        min-height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
        position: relative;
        width: 100%;
    }

    /* Sidebar drawer — slides from the right (start side in RTL) */
    .sidebar-shell {
        display: none !important;
        position: fixed;
        inset-inline-start: 0;
        inset-inline-end: auto;
        top: 0;
        bottom: 0;
        width: min(88vw, 268px);
        z-index: 900;
        flex: none !important;
        max-height: none !important;
        height: auto !important;
        box-shadow: -16px 0 40px rgba(0, 0, 0, 0.26);
    }

    .app-shell.mobile-nav-open .sidebar-shell {
        display: flex !important;
        flex-direction: column;
        animation: drawerSlideInRtl 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    }

    @keyframes drawerSlideInRtl {
        from { transform: translateX(100%); opacity: 0.55; }
        to { transform: translateX(0); opacity: 1; }
    }

    .sidebar-shell .sidebar,
    .sidebar-shell.is-collapsed .sidebar,
    .sidebar-shell.is-expanded .sidebar {
        width: 100% !important;
        height: 100% !important;
        max-height: none !important;
        position: relative !important;
        top: auto !important;
        flex: 1;
    }

    .sidebar-shell.is-collapsed .sidebar-group-label,
    .sidebar-shell.is-collapsed .sidebar-quick-btn-label,
    .sidebar-shell.is-collapsed .sidebar-product-name,
    .sidebar-shell.is-collapsed .sidebar-user,
    .sidebar-shell.is-collapsed .sidebar-footer-btn--signout {
        display: inline !important;
    }

    .sidebar-shell.is-collapsed .sidebar-group-btn {
        justify-content: flex-start;
        padding: 10px 12px;
    }

    .sidebar-shell.is-collapsed .sidebar-quick-grid {
        --qa-cols: 3 !important;
    }

    .sidebar-header {
        padding-top: 52px;
    }

    .sidebar-header-inner {
        padding-top: 4px;
    }

    .sidebar-toggle-btn {
        display: none !important;
    }

    .sidebar-mobile-close {
        display: flex;
        position: absolute;
        inset-inline-start: 12px;
        inset-inline-end: auto;
        top: 14px;
        transform: none;
        width: 36px;
        height: 36px;
        align-items: center;
        justify-content: center;
        border: 1px solid rgba(148, 163, 184, 0.25);
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.06);
        color: #e2e8f0;
        cursor: pointer;
        z-index: 2;
        transition: background 0.15s, border-color 0.15s, transform 0.15s;
    }

    .sidebar-mobile-close:hover {
        background: rgba(13, 148, 136, 0.22);
        border-color: rgba(94, 234, 212, 0.35);
        transform: scale(1.05);
    }

    .mobile-nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 850;
        background: rgba(15, 23, 42, 0.5);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    /* Main area — full width */
    .main-area {
        flex: 1 1 0 !important;
        width: 100% !important;
        min-width: 0 !important;
        min-height: 0 !important;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .mobile-menu-btn {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        gap: 8px;
        flex-shrink: 0;
        height: var(--touch-min, 44px);
        min-height: var(--touch-min, 44px);
        min-width: var(--touch-min, 44px);
        padding: 0 14px 0 10px;
        margin-inline-end: 4px;
        border: 1px solid rgba(13, 148, 136, 0.22);
        border-radius: 12px;
        background: linear-gradient(165deg, #ffffff 0%, #f0fdfa 100%);
        color: var(--brand-dark);
        font-family: inherit;
        font-size: var(--text-sm, 0.875rem);
        font-weight: 700;
        cursor: pointer;
        box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 4px 14px rgba(13, 148, 136, 0.12);
        transition: border-color 0.18s, box-shadow 0.18s, transform 0.12s, background 0.18s;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .mobile-menu-btn:hover {
        border-color: rgba(13, 148, 136, 0.45);
        box-shadow: 0 2px 8px rgba(13, 148, 136, 0.18);
    }

    .mobile-menu-btn:active {
        transform: scale(0.97);
    }

    .mobile-menu-btn.is-open {
        background: linear-gradient(165deg, #0f766e 0%, #0d9488 100%);
        border-color: #0f766e;
        color: #fff;
        box-shadow: 0 4px 16px rgba(13, 148, 136, 0.35);
    }

    .mobile-menu-btn__icon {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 4px;
        width: 18px;
        height: 14px;
    }

    .mobile-menu-btn__line {
        display: block;
        width: 18px;
        height: 2px;
        border-radius: 2px;
        background: currentColor;
        transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1), opacity 0.18s, width 0.18s;
    }

    .mobile-menu-btn.is-open .mobile-menu-btn__line:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }

    .mobile-menu-btn.is-open .mobile-menu-btn__line:nth-child(2) {
        opacity: 0;
        width: 0;
    }

    .mobile-menu-btn.is-open .mobile-menu-btn__line:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }

    .mobile-menu-btn__label {
        white-space: nowrap;
    }

    .topbar-quick-actions {
        display: none !important;
    }

    .quick-fab-trigger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .topbar {
        flex-shrink: 0;
        min-height: var(--mobile-header-h);
        padding: calc(6px + var(--safe-top)) 14px 6px;
        gap: 8px;
        flex-wrap: nowrap;
        align-items: center;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
        z-index: 100;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .topbar-title {
        flex: 1 1 0;
        min-width: 0;
        font-size: 15px !important;
        font-weight: 700;
        color: var(--text) !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-align: start;
    }

    .topbar-meta {
        flex-shrink: 0;
        gap: 6px;
        flex-wrap: nowrap;
        width: auto !important;
        margin-inline-start: 8px;
        padding-inline-start: 8px;
        border-inline-start: 1px solid var(--border);
    }

    .topbar-meta .version-badge,
    .topbar-meta > span:last-child {
        display: none !important;
    }

    .topbar-overdue-link {
        font-size: var(--text-xs, 0.75rem);
        padding: 4px 8px;
        min-height: 28px;
    }

    .branch-switcher {
        gap: 4px;
    }

    .branch-switcher-label {
        display: none;
    }

    .branch-switcher-field {
        max-width: min(52vw, 200px);
    }

    .branch-switcher .search-select__control {
        min-height: 34px;
    }

    .page-content {
        flex: 1 1 0;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px 14px;
        padding-bottom: calc(var(--mobile-bottom-nav-h) + 12px + var(--safe-bottom));
    }

    /* Bottom navigation */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        inset-inline: 0;
        bottom: 0;
        z-index: 800;
        height: calc(var(--mobile-bottom-nav-h) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid rgba(226, 232, 240, 0.95);
        box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.08);
    }

    .mobile-nav-item {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-height: var(--mobile-bottom-nav-h);
        padding: 6px 4px;
        border: none;
        background: transparent;
        color: #64748b;
        text-decoration: none;
        font-family: inherit;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: color 0.15s;
    }

    .mobile-nav-item.is-active {
        color: var(--brand-dark);
    }

    .mobile-nav-item.is-menu {
        position: relative;
    }

    .mobile-nav-item.is-menu .mobile-nav-icon {
        background: linear-gradient(145deg, #0f766e 0%, #14b8a6 100%);
        color: #fff;
        width: 44px;
        height: 36px;
        border-radius: 14px;
        box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
        margin-top: -6px;
    }

    .mobile-nav-item.is-menu.is-active .mobile-nav-icon {
        background: linear-gradient(145deg, #115e59 0%, #0d9488 100%);
        box-shadow: 0 2px 10px rgba(13, 148, 136, 0.45), inset 0 0 0 2px rgba(255, 255, 255, 0.25);
    }

    .mobile-nav-item.is-menu .mobile-nav-label {
        color: var(--brand-dark);
        font-weight: 800;
    }

    .mobile-nav-item.is-active .mobile-nav-icon {
        background: var(--brand-light);
        color: var(--brand-dark);
    }

    .mobile-nav-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 28px;
        border-radius: 10px;
        transition: background 0.15s;
    }

    .mobile-nav-label {
        font-size: var(--text-xs, 0.75rem);
        font-weight: 700;
        line-height: 1.2;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sidebar-groups {
        padding: 8px 0 6px;
    }

    .sidebar-group-btn {
        min-height: 46px;
        padding: 8px 10px;
        margin: 2px 6px 0;
        border-radius: 11px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .sidebar-group-btn.is-open {
        background: rgba(13, 148, 136, 0.22);
        box-shadow: inset 0 0 0 1px rgba(94, 234, 212, 0.18);
    }

    .sidebar-group-label {
        font-size: 14px;
        font-weight: 600;
    }

    /* Flyout → drill-down panel over sidebar drawer */
    .sidebar-flyout-backdrop {
        z-index: 950;
        background: rgba(2, 6, 23, 0.45);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .sidebar-flyout.is-side-panel {
        z-index: 980 !important;
        pointer-events: auto;
        touch-action: manipulation;
        min-width: 0 !important;
        max-width: none !important;
        border-radius: 0 !important;
        border: none !important;
        border-inline-start: 1px solid rgba(94, 234, 212, 0.12) !important;
        box-shadow: -16px 0 48px rgba(0, 0, 0, 0.35) !important;
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
        animation: flyoutDrillIn 0.26s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .sidebar-shell.is-flyout-open .sidebar-groups,
    .sidebar-shell.is-flyout-open .sidebar-footer {
        visibility: hidden;
        pointer-events: none;
    }

    @keyframes flyoutDrillIn {
        from {
            opacity: 0.6;
            transform: translateX(24px);
        }
        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    .sidebar-flyout-close {
        display: inline-flex;
    }

    .sidebar-flyout-header {
        padding: 14px 14px 12px;
        padding-top: calc(14px + env(safe-area-inset-top, 0));
    }

    .sidebar-flyout-title {
        font-size: 15px;
    }

    .sidebar-flyout-items {
        padding: 8px 10px 16px;
        gap: 8px;
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-flyout-item {
        min-height: 52px;
        padding: 12px 14px;
        font-size: 14px;
        font-weight: 600;
        border-radius: 12px;
        background: rgba(19, 42, 61, 0.72);
        border: 1px solid rgba(30, 58, 79, 0.85);
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .sidebar-flyout-item.is-active {
        background: rgba(13, 148, 136, 0.24);
        border-color: rgba(94, 234, 212, 0.32);
        color: #99f6e4;
    }

    .sidebar-flyout-item:active {
        background: rgba(13, 148, 136, 0.32);
        color: #99f6e4;
        transform: scale(0.985);
    }

    /* Page toolbar — compact row on phone (details in phase-c-premium.css) */
    .page-toolbar {
        padding: 12px 14px;
        border-radius: 14px;
        margin-bottom: 4px;
    }

    .page-toolbar-row {
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .page-toolbar-brand {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
    }

    .page-toolbar-title {
        font-size: 17px !important;
        line-height: 1.3;
    }

    .page-toolbar-tools {
        width: auto;
        flex-shrink: 0;
        justify-content: flex-end;
        padding-inline-end: 0;
    }

    .toolbar-actions-cluster {
        width: auto;
        max-width: min(52vw, 220px);
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 6px;
        padding: 0;
        border-radius: 0;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .toolbar-actions-cluster::-webkit-scrollbar {
        display: none;
    }

    .toolbar-actions-cluster .toolbar-search {
        grid-column: auto;
    }

    .btn-toolbar,
    .btn-toolbar-add {
        min-height: 36px;
        padding: 6px 10px;
        font-size: 12px;
        justify-content: center;
        width: auto;
        flex-shrink: 0;
        border-radius: 10px;
        touch-action: manipulation;
        white-space: nowrap;
    }

    /* Dashboard */
    .dash-section-title {
        font-size: var(--text-sm, 0.875rem);
        margin-bottom: 8px;
    }

    .dash-alert-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 16px;
    }

    .dash-alert-card {
        padding: 14px 16px;
        border-radius: 14px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stat-card {
        padding: 12px 14px;
        border-radius: 14px;
    }

    .summary-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    /* Tables */
    .data-table-wrap {
        position: relative;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -6px;
        padding: 0 6px;
        border-radius: 12px;
    }

    .data-table {
        min-width: 600px;
        font-size: var(--text-sm, 0.875rem);
    }

    .data-table th,
    .data-table td {
        padding: 11px 8px;
    }

    .data-table thead th {
        position: sticky;
        top: 0;
        z-index: 2;
        background: #f8fafc;
    }

    .btn-table,
    .btn-table-accent {
        min-height: var(--touch-min, 44px);
        padding: 8px 12px;
        font-size: var(--text-sm, 0.875rem);
        touch-action: manipulation;
    }

    /* Forms */
    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .form-grid .span-2 {
        grid-column: span 1 !important;
    }

    .form-field .input,
    .form-field select,
    .form-field textarea {
        min-height: var(--touch-min, 44px);
        font-size: 16px;
        border-radius: 12px;
    }

    .btn-form-save,
    .btn-form-cancel,
    .add-card-footer .btn,
    .form-card-footer-actions .btn {
        min-height: var(--touch-min, 44px);
        font-size: var(--text-base, 1rem);
        touch-action: manipulation;
    }

    .toolbar-search .toolbar-search-input {
        min-height: 44px;
        font-size: 16px;
        border-radius: 12px;
    }

    /* Notifications — notifications-premium.css */
    .notification-filter-bar {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    /* Login — scrollable on mobile (register / activate forms) */
    .login-shell {
        padding: 16px;
        padding-top: calc(12px + var(--safe-top));
        padding-bottom: calc(20px + var(--safe-bottom));
        align-items: flex-start;
        justify-content: flex-start;
    }

    .login-card {
        margin-top: 0;
        padding: 28px 22px;
        border-radius: 18px;
        max-width: 100%;
    }

    .login-card:not(.login-card--long-form) {
        margin-top: 8vh;
    }

    .login-card--long-form {
        margin-bottom: calc(12px + var(--safe-bottom));
    }

    .login-card--long-form .btn-block {
        min-height: 48px;
        font-size: 16px;
    }

    .login-card .input {
        min-height: 48px;
        font-size: 16px;
    }

    .toast-host {
        right: 12px;
        left: 12px;
        bottom: calc(var(--mobile-bottom-nav-h) + 12px + var(--safe-bottom));
        max-width: none;
    }

    .pos-layout {
        flex-direction: column !important;
    }

    .panel {
        padding: 12px;
        border-radius: 14px;
    }

    .filter-bar {
        flex-direction: column;
        gap: 10px;
    }

    .calendar-cell {
        font-size: var(--text-xs, 0.75rem);
        min-height: 36px;
    }

    .page-form-stage > .page-float-card,
    .page-form-stage > .add-card-panel.page-float-card {
        width: 100%;
        max-width: 100%;
        flex: 1 1 0;
        min-height: 0;
        height: auto;
        max-height: none;
    }

    /* Responsive data list — بطاقات بدل الجداول */
    .responsive-data-list__desktop {
        display: none !important;
    }

    .responsive-data-list__mobile {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .list-card__meta {
        grid-template-columns: 1fr;
    }

    .shell-status-chips {
        display: none;
    }

    /* List + report pages — fixed header, scrollable body inside shell */
    .page-content:has(> .list-page-shell),
    .page-content:has(> .reports-center-shell),
    .page-content:has(> .report-page-shell) {
        overflow: hidden;
        display: flex;
        flex-direction: column;
        min-height: 0;
    }

    .page-content > .list-page-shell,
    .page-content > .reports-center-shell,
    .page-content > .report-page-shell {
        flex: 1 1 0;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .list-page-shell > .list-page-body,
    .list-page-shell > .page-scroll-area,
    .reports-center-shell > .page-scroll-area,
    .report-page-shell > .page-scroll-area {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: scroll;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-gutter: stable both-edges;
    }

    /* Card/form pages with direct page-scroll-area (dashboard, settings…) — page scrolls */
    .page-content:has(> .page-scroll-area:not(.list-page-shell *)) {
        overflow-y: auto;
        overflow-x: hidden;
    }

    .page-content > .page-scroll-area:not(.list-page-shell .page-scroll-area) {
        flex: 0 0 auto;
        min-height: 0;
        overflow: visible;
        padding-bottom: 0;
    }

    /* Legacy — list-page-shell with nested page-scroll-area flows on page (avoid if possible) */
    .page-content:has(> .list-page-shell > .page-scroll-area):not(:has(> .reports-center-shell)):not(:has(> .report-page-shell)) {
        overflow-y: auto;
        overflow-x: hidden;
        display: block;
    }

    .page-content > .list-page-shell:has(> .page-scroll-area):not(.reports-center-shell):not(.report-page-shell) {
        overflow: visible;
        flex: 0 0 auto;
        min-height: 0;
        display: block;
    }

    /* Uncap internal capped tables (ScrollSize compact/default/tall) so all
       rows show within the single page scroll on small screens. */
    .page-scroll-area .data-table-wrap.data-table-scroll,
    .report-page-body .data-table-wrap.data-table-scroll {
        max-height: none !important;
        overflow-y: visible;
    }

    .list-page-shell > .page-toolbar {
        flex-shrink: 0;
        z-index: 2;
    }

    .list-page-shell > .alert,
    .list-page-shell > .table-pager {
        flex-shrink: 0;
    }

    .list-page-shell > .table-pager {
        border-top: 1px solid var(--border);
        background: var(--surface);
        padding: 10px 12px;
        margin-top: 0;
    }

    .list-page-shell > .list-page-body {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-gutter: stable;
        scrollbar-width: thin;
        scrollbar-color: #94a3b8 #f1f5f9;
    }

    .list-page-shell > .list-page-body::-webkit-scrollbar {
        width: 8px;
    }

    .list-page-shell > .list-page-body::-webkit-scrollbar-track {
        background: #f1f5f9;
        border-radius: 8px;
        margin: 4px 0;
    }

    .list-page-shell > .list-page-body::-webkit-scrollbar-thumb {
        background: linear-gradient(180deg, #cbd5e1, #94a3b8);
        border-radius: 8px;
        border: 2px solid #f1f5f9;
    }

    .list-page-body .responsive-data-list {
        min-height: min-content;
    }

    .list-page-body .responsive-data-list__mobile {
        overflow: visible;
        padding: 8px 10px 12px;
    }

    .contracts-grouped-view {
        padding: 8px 10px 12px;
    }

    .contract-group {
        margin-bottom: 10px;
    }

    .contract-group-body {
        padding: 0 4px 8px;
    }

    /* Fallback: pages without ListPageBody yet */
    .list-page-shell:not(:has(> .list-page-body)) > .responsive-data-list {
        flex: 1 1 0;
        min-height: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .list-page-shell:not(:has(> .list-page-body)) .responsive-data-list__mobile {
        flex: 1 1 0;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-gutter: stable;
        scrollbar-width: thin;
        scrollbar-color: #94a3b8 #f1f5f9;
        padding: 8px 10px 12px;
    }
}

@media (max-width: 480px) {
    .stats-grid,
    .summary-row {
        grid-template-columns: 1fr;
    }

    .page-toolbar-tools {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding: 10px 12px;
        padding-bottom: calc(var(--mobile-bottom-nav-h) + 10px + var(--safe-bottom));
    }

    .data-table {
        min-width: 520px;
    }
}

@media (max-width: 992px) and (orientation: landscape) {
    .mobile-bottom-nav {
        height: calc(52px + var(--safe-bottom));
    }

    .mobile-nav-item {
        min-height: 52px;
        flex-direction: row;
        gap: 6px;
    }

    .mobile-nav-label {
        font-size: var(--text-xs, 0.75rem);
    }

    .page-content {
        padding-bottom: calc(52px + 8px + var(--safe-bottom));
    }
}
