.mobile-nav-backdrop,
.mobile-side-link {
    display: none;
}

@media (max-width: 991.98px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    body.mobile-nav-open {
        overflow: hidden;
    }

    body {
        background-attachment: scroll !important;
    }

    body::before {
        display: none;
    }

    .app-shell,
    .app-shell.sidebar-collapsed,
    .app-shell.full-view,
    .app-shell.full-view.sidebar-collapsed {
        position: relative !important;
        inset: auto !important;
        display: block !important;
        width: 100% !important;
        height: auto !important;
        min-height: 100vh;
        overflow: visible !important;
        padding: 0 !important;
        background: transparent;
    }

    body.app-full-view-active {
        overflow: auto;
    }

    .main-pane,
    .app-shell.full-view .main-pane {
        min-width: 0;
        min-height: 100vh;
        overflow: visible;
        gap: 10px;
        padding: 8px;
    }

    .side-stack,
    .app-shell.full-view .side-stack {
        position: static !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
        display: block;
    }

    .side-rail,
    .app-shell.sidebar-collapsed .side-rail,
    .app-shell.full-view .side-rail {
        position: fixed;
        inset: max(8px, env(safe-area-inset-top)) auto calc(max(8px, env(safe-area-inset-bottom)) + 64px) max(8px, env(safe-area-inset-left));
        z-index: 1090;
        display: flex;
        width: min(84vw, 310px);
        max-height: none;
        overflow-x: hidden;
        overflow-y: auto;
        touch-action: pan-y;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 12px;
        margin: 0;
        padding: 14px 12px;
        border-radius: 22px;
        transform: translateX(calc(-100% - 18px));
        visibility: hidden;
        transition: transform .22s ease, visibility .22s ease;
    }

    .app-shell.mobile-nav-open .side-rail {
        transform: translateX(0);
        visibility: visible;
    }

    .side-rail .brand-dot,
    .app-shell.sidebar-collapsed .brand-dot {
        width: 50px;
        height: 50px;
        flex: 0 0 50px;
        margin: 0 auto 2px;
    }

    .side-rail .side-group,
    .app-shell.sidebar-collapsed .side-group {
        display: flex;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 5px;
        margin: 0;
    }

    .side-account-dock,
    .app-shell.sidebar-collapsed .side-account-dock {
        display: none;
    }

    .app-shell.mobile-nav-open .side-account-dock,
    .app-shell.sidebar-collapsed.mobile-nav-open .side-account-dock {
        position: fixed;
        left: max(8px, env(safe-area-inset-left));
        bottom: max(8px, env(safe-area-inset-bottom));
        z-index: 1091;
        display: flex;
        width: min(84vw, 310px);
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 8px;
        margin: 0;
        padding: 8px 12px;
        border-radius: 999px;
        pointer-events: auto;
    }

    .side-rail .side-link,
    .app-shell.sidebar-collapsed .side-link {
        width: 100%;
        min-width: 0;
        min-height: 46px;
        justify-content: flex-start;
        padding: 0 13px;
    }

    .side-rail .side-label,
    .app-shell.sidebar-collapsed .side-label {
        display: inline;
    }

    .mobile-side-link {
        display: flex;
    }

    .mobile-nav-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1080;
        display: block;
        border: 0;
        background: rgba(4, 20, 14, .55);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        backdrop-filter: blur(3px);
        transition: opacity .2s ease, visibility .2s ease;
    }

    .app-shell.mobile-nav-open .mobile-nav-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .topbar,
    .app-shell.full-view .topbar {
        position: sticky;
        top: 8px;
        z-index: 900;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
        gap: 8px;
        padding: 11px 12px;
        border: 1px solid rgba(207, 221, 213, .92);
        border-radius: 17px;
        background: rgba(247, 251, 249, .94);
        box-shadow: 0 8px 24px rgba(12, 58, 41, .1);
        backdrop-filter: blur(14px);
    }

    .topbar > div:first-child {
        min-width: 0;
    }

    .topbar h1 {
        overflow: hidden;
        font-size: 1.18rem;
        line-height: 1.25;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar p,
    .app-shell.full-view .topbar p {
        display: -webkit-box;
        overflow: hidden;
        margin-top: 2px;
        font-size: .7rem;
        line-height: 1.35;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .branch-mode-chip {
        max-width: 100%;
        overflow: hidden;
        font-size: .68rem;
    }

    .branch-mode-chip > span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .top-tools {
        display: grid;
        grid-template-columns: repeat(auto-fit, 38px);
        justify-content: end;
        gap: 5px;
    }

    .topbar-page-tools {
        display: contents;
    }

    .tool-btn {
        width: 38px;
        height: 38px;
        box-shadow: 0 5px 14px rgba(24, 68, 50, .08);
    }

    #fullViewToggle,
    .top-tools .search-pill,
    .top-tools .login-time,
    .top-tools > a[href*="/logout"],
    .top-tools > a[href*="/profile"] {
        display: none !important;
    }

    .content-canvas,
    .app-shell.full-view .content-canvas {
        gap: 10px;
        min-height: 0;
        overflow: visible;
        padding-bottom: 78px;
    }

    .metric-grid,
    .metric-grid[style] {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px;
    }

    .metric-card {
        min-height: 88px;
        padding: 12px;
        border-radius: 16px;
    }

    .metric-card .label {
        font-size: .7rem;
    }

    .metric-card .value {
        overflow-wrap: anywhere;
        font-size: clamp(1rem, 5vw, 1.35rem);
    }

    .panel {
        max-width: 100%;
        overflow: visible;
        padding: 13px;
        border-radius: 18px;
    }

    .panel::before {
        left: 16px;
        right: 16px;
    }

    .content-canvas > .panel > .d-flex.justify-content-between,
    .content-canvas > .panel > header.d-flex.justify-content-between {
        align-items: flex-start !important;
        flex-direction: column;
        gap: 12px;
    }

    .content-canvas > .panel > .d-flex.justify-content-between > .d-flex,
    .content-canvas > .panel > header.d-flex.justify-content-between > .d-flex {
        width: 100%;
    }

    .content-canvas > .panel > .d-flex.justify-content-between > .d-flex > .btn,
    .content-canvas > .panel > header.d-flex.justify-content-between > .d-flex > .btn {
        flex: 1 1 auto;
    }

    .soft-form .form-control,
    .soft-form .form-select,
    .form-control,
    .form-select,
    .btn {
        min-height: 44px;
    }

    .input-group > .btn {
        min-height: 0;
    }

    .table-responsive {
        max-width: 100%;
        overflow-x: auto !important;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive > .table,
    .sales-register-table,
    .purchase-register-table {
        width: max-content !important;
        min-width: 680px;
        table-layout: auto !important;
    }

    .table-clean th,
    .table-clean td,
    .sales-register-table th,
    .sales-register-table td,
    .purchase-register-table th,
    .purchase-register-table td {
        white-space: nowrap !important;
        overflow-wrap: normal !important;
    }

    .sales-register-table .medicine-list-cell {
        width: 240px;
        min-width: 240px;
        white-space: normal !important;
    }

    .register-pager {
        align-items: stretch;
        flex-direction: column;
    }

    .register-page-links {
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap !important;
        padding-bottom: 3px;
    }

    .modal-dialog {
        margin: 8px;
    }

    .modal-content {
        max-height: calc(100dvh - 16px);
        border-radius: 18px;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 13px;
    }

    .data-assistant {
        right: 8px;
        bottom: 8px;
        left: 8px;
    }

    .assistant-window {
        width: 100%;
        max-height: min(70dvh, 520px);
    }

    .assistant-toggle {
        margin-left: auto;
        margin-bottom: env(safe-area-inset-bottom);
    }
}

@media (max-width: 480px) {
    .main-pane {
        padding: 6px;
    }

    .topbar {
        top: 6px;
        padding: 10px;
    }

    .topbar p {
        -webkit-line-clamp: 1;
    }

    .metric-card {
        min-height: 78px;
    }

    .panel {
        padding: 12px;
    }

    .content-canvas > .panel > .d-flex.justify-content-between > .d-flex,
    .inventory-heading-actions {
        display: grid !important;
        grid-template-columns: 1fr;
    }

    .content-canvas > .panel > .d-flex.justify-content-between > .d-flex > *,
    .inventory-heading-actions > * {
        width: 100%;
    }

    .table-responsive > .table,
    .sales-register-table,
    .purchase-register-table {
        min-width: 620px;
    }
}

@media (max-width: 991.98px) {
    .sales-register-table {
        min-width: 1120px !important;
    }

    .purchase-register-table {
        min-width: 1080px !important;
    }

    .sales-register-table .register-action-col,
    .purchase-register-table .register-action-col {
        position: sticky;
        right: 0;
        z-index: 5;
        background: #fff !important;
    }
}

@media (max-width: 340px) {
    .metric-grid,
    .metric-grid[style] {
        grid-template-columns: 1fr !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .side-rail,
    .mobile-nav-backdrop {
        transition: none !important;
    }
}
