/* Mobile: responsive overrides loaded last to retain final cascade precedence. */
@media (max-width: 820px) {
    .handover-target-options {
        grid-template-columns: 1fr;
    }

    .handover-close-card-head,
    .handover-close-card-summary,
    .handover-usage-title,
    .handover-approval-chip-stack,
    .handover-reason-quick-buttons,
    .handover-approval-card-head,
    .handover-approval-metrics,
    .handover-approval-confirm-grid {
        grid-template-columns: 1fr;
        display: grid;
        align-items: stretch;
    }

    .handover-close-summary-stats {
        justify-content: flex-start;
    }

    .handover-usage-row {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 560px) {
    .storage-action-card {
        grid-template-columns: 40px minmax(0, 1fr);
    }

    .storage-action-icon {
        width: 40px;
        height: 40px;
        border-radius: 14px;
    }

    .storage-action-cta {
        grid-column: 1 / -1;
        justify-self: stretch;
        text-align: center;
    }
}
@media (max-width: 980px) {
    .workflow-panel-grid,
    .notification-card-grid,
    .notification-filter-grid,
    .settings-logo-card,
    .item-form-shell,
    .item-form-grid,
    .item-form-grid-primary,
    .item-form-grid-compact,
    .item-form-barcode-preview,
    .item-form-image-row {
        grid-template-columns: 1fr;
    }

    .item-form-section-head,
    .item-form-actions {
        align-items: flex-start;
        flex-direction: column;
    }

    .item-form-section-note {
        max-width: none;
        text-align: left;
    }

    .item-form-actions .primary-button,
    .item-form-actions .ghost-button {
        width: 100%;
        justify-content: center;
    }

    .item-summary-hero,
    .item-summary-stats,
    .item-summary-detail-list {
        grid-template-columns: 1fr;
    }

    .item-stock-position-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .item-summary-stock,
    .item-summary-actions {
        align-items: flex-start;
        text-align: left;
    }

    .movement-form-grid-locations,
    .movement-form-grid-details {
        grid-template-columns: 1fr;
    }

    .movement-form .movement-preview-grid {
        grid-template-columns: 1fr;
    }

    .settings-search-panel {
        grid-template-columns: 1fr;
    }

    .settings-search-clear {
        width: 100%;
    }

    .settings-accordion-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .settings-accordion-meta {
        margin-left: 0;
    }

    .mailer-guide-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .scan-manual-grid {
        grid-template-columns: 1fr;
    }

    .scan-manual-result-card {
        grid-template-columns: 54px 1fr;
    }

    .scan-manual-result-card em {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .manual-stock-grid,
    .manual-stock-selected-card,
    .manual-stock-draft-row {
        grid-template-columns: 1fr;
    }

    .manual-stock-draft-row .ghost-button,
    .manual-stock-actions .ghost-button,
    .manual-stock-actions .primary-button {
        width: 100%;
        justify-content: center;
    }

    .manual-stock-actions {
        display: grid;
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1180px) {
    .scan-entry-panel,
    .reports-hero-panel {
        align-items: stretch;
        grid-template-columns: 1fr;
    }

    .scan-workspace,
    .reports-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .reports-summary-filter,
    .reports-summary-metrics,
    .reports-summary-columns {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scan-workspace-empty {
        grid-template-columns: 1fr;
    }

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

    .scan-batch-controls,
    .scan-batch-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .access-summary-card,
    .item-detail-barcode,
    .access-settings-toolbar,
    .permission-toolbar {
        grid-template-columns: 1fr;
    }

    .access-summary-stats,
    .permission-group-accordion .permission-list,
    .permission-grid {
        grid-template-columns: 1fr;
    }

    .scan-entry-form,
    .scan-batch-scan,
    .scan-workspace,
    .reports-summary-filter,
    .reports-summary-metrics,
    .reports-summary-columns,
    .reports-card-grid,
    .scan-quick-grid,
    .scan-selected-head {
        grid-template-columns: 1fr;
    }

    .reports-summary-head,
    .summary-card-head {
        display: grid;
        grid-template-columns: 1fr;
    }

    .report-summary-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .summary-list,
    .summary-user-grid,
    .summary-table-scroll {
        max-height: 430px;
    }

    .scan-selected-stock {
        text-align: left;
    }

    .scan-result-card {
        grid-template-columns: 48px 1fr;
    }

    .scan-result-card em {
        grid-column: 2;
    }

    .scan-balance-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .scan-batch-controls,
    .scan-batch-row {
        grid-template-columns: 1fr;
    }

    .scan-batch-qty {
        grid-template-columns: 48px minmax(90px, 1fr) 48px;
    }

    .scan-batch-footer .primary-button {
        width: 100%;
    }
}

@media (max-width: 1100px) {
    .assets-filter-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .assets-metric-grid {
        grid-template-columns: repeat(2, minmax(180px, 1fr));
    }

    .asset-form .item-form-grid,
    .asset-form .item-form-grid-primary {
        grid-template-columns: repeat(2, minmax(220px, 1fr));
    }
}

@media (max-width: 760px) {
    .assets-filter-grid,
    .assets-metric-grid,
    .asset-form .item-form-grid,
    .asset-form .item-form-grid-primary,
    .asset-form .item-form-image-row {
        grid-template-columns: 1fr;
    }

    .asset-table {
        min-width: 0;
    }

    .asset-table td[data-label="Asset"],
    .asset-table td[data-label="Scan Code"],
    .asset-table td[data-label="Serial"],
    .asset-table td[data-label="Custody"] {
        min-width: 0;
    }

    .asset-table td[data-label="Status"],
    .asset-table td[data-label="Condition"],
    .asset-table td[data-label="Book Value"] {
        white-space: normal;
    }

    .assets-page .data-table-toolbar .button-row {
        width: 100%;
    }

    .assets-page .data-table-toolbar .button-row .ghost-button {
        width: 100%;
        justify-content: center;
    }

    .asset-form .item-form-section-note {
        max-width: none;
        text-align: left;
    }
}
/* Sidebar scroll fix: the navigation must scroll independently at every width. */
.sidebar,
.theme-clean .sidebar,
.theme-official .sidebar {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
}

.sidebar .nav-links,
.theme-clean .sidebar .nav-links,
.theme-official .sidebar .nav-links {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    align-content: start;
    padding-right: 8px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    scrollbar-gutter: stable;
    scrollbar-width: none;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.sidebar .nav-links:hover,
.theme-clean .sidebar .nav-links:hover,
.theme-official .sidebar .nav-links:hover {
    scrollbar-width: thin;
    scrollbar-color: rgba(138, 100, 48, 0.48) transparent;
}

.sidebar .nav-links::-webkit-scrollbar,
.theme-clean .sidebar .nav-links::-webkit-scrollbar,
.theme-official .sidebar .nav-links::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.sidebar .nav-links:hover::-webkit-scrollbar,
.theme-clean .sidebar .nav-links:hover::-webkit-scrollbar,
.theme-official .sidebar .nav-links:hover::-webkit-scrollbar {
    width: 8px;
}

.sidebar .nav-links::-webkit-scrollbar-track,
.theme-clean .sidebar .nav-links::-webkit-scrollbar-track,
.theme-official .sidebar .nav-links::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar .nav-links::-webkit-scrollbar-thumb,
.theme-clean .sidebar .nav-links::-webkit-scrollbar-thumb,
.theme-official .sidebar .nav-links::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(138, 100, 48, 0.28);
}

.sidebar .nav-links:hover::-webkit-scrollbar-thumb,
.theme-clean .sidebar .nav-links:hover::-webkit-scrollbar-thumb,
.theme-official .sidebar .nav-links:hover::-webkit-scrollbar-thumb {
    background: rgba(138, 100, 48, 0.48);
}

/* Tablet/mobile shell fix: collapsed desktop rail must become a drawer. */
@media (max-width: 1360px) {
    body.app-shell {
        overflow-x: hidden;
    }

    .shell,
    .shell.nav-collapsed,
    .theme-clean .shell,
    .theme-clean .shell.nav-collapsed,
    .theme-official .shell,
    .theme-official .shell.nav-collapsed {
        display: block;
        width: 100%;
        min-width: 0;
        min-height: 100dvh;
    }

    .sidebar,
    .theme-clean .sidebar,
    .theme-official .sidebar,
    .nav-collapsed .sidebar,
    .theme-clean .nav-collapsed .sidebar,
    .theme-official .nav-collapsed .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 40;
        width: min(88vw, 320px);
        max-width: 320px;
        height: 100dvh;
        max-height: 100dvh;
        padding: 20px;
        align-items: stretch;
        transform: translateX(-105%);
        transition: transform 180ms ease;
        overflow: hidden;
    }

    .shell.nav-open .sidebar,
    .theme-clean .shell.nav-open .sidebar,
    .theme-official .shell.nav-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop,
    .theme-clean .sidebar-backdrop,
    .theme-official .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 35;
        display: block;
        background: rgba(16, 12, 7, 0.46);
        opacity: 0;
        pointer-events: none;
        transition: opacity 180ms ease;
        backdrop-filter: blur(2px);
    }

    .shell.nav-open .sidebar-backdrop,
    .theme-clean .shell.nav-open .sidebar-backdrop,
    .theme-official .shell.nav-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .nav-collapsed .sidebar .brand-block > div,
    .nav-collapsed .sidebar .nav-link > span:not(.ui-icon) {
        display: block;
    }

    .has-custom-logo .nav-collapsed .sidebar .brand-logo-official,
    .theme-official .nav-collapsed .sidebar .brand-logo-official {
        display: block;
    }

    .nav-collapsed .sidebar .brand-block,
    .nav-collapsed .sidebar .sidebar-head {
        justify-content: space-between;
    }

    .nav-collapsed .sidebar .nav-link {
        justify-content: flex-start;
        padding-inline: 16px;
    }

    .main-panel,
    .theme-clean .main-panel,
    .theme-official .main-panel {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding-inline: clamp(12px, 3vw, 28px);
    }

    .content,
    .theme-clean .content,
    .theme-official .content,
    .topbar,
    .theme-clean .topbar,
    .theme-official .topbar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-inline: 0;
    }

    .content,
    .theme-clean .content,
    .theme-official .content {
        padding-inline: 0;
    }

    .menu-button,
    .theme-clean .menu-button,
    .theme-official .menu-button {
        display: inline-flex;
    }
}

@media (max-width: 760px) {
    .staff-card-grid {
        grid-template-columns: 1fr;
    }

    .staff-item-card,
    .staff-item-card * {
        min-width: 0;
    }

    .staff-item-card-head {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .staff-item-card-head .pill {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .staff-item-card-metrics span {
        overflow-wrap: anywhere;
    }
}

.metric-card-dark {
    background: #050505;
    border-color: #050505;
    color: #fff;
}

.file-card-grid,
.timeline-list {
    display: grid;
    gap: 14px;
}

.file-card-grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    margin-top: 18px;
}

.file-card,
.timeline-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) - 8px);
    background: rgba(245, 239, 229, 0.62);
}

.file-card {
    align-items: flex-start;
    justify-content: flex-start;
    flex-direction: column;
}

.file-card:hover,
.timeline-card:hover {
    background: rgba(232, 216, 190, 0.72);
}

.file-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 16px;
    background: #f5e8d4;
    color: #7b5636;
}

.timeline-card p,
.timeline-card span,
.file-card span {
    color: var(--muted);
}

.timeline-card form {
    margin: 0;
}

.info-card {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: calc(var(--radius) - 8px);
}

.soft-card {
    background: rgba(245, 239, 229, 0.62);
}

/* Desktop collapsed sidebar fix: compact rail overlays, content stays direct. */
@media (min-width: 1361px) {
    .shell.nav-collapsed,
    .theme-clean .shell.nav-collapsed,
    .theme-official .shell.nav-collapsed {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .shell.nav-collapsed .sidebar,
    .theme-clean .shell.nav-collapsed .sidebar,
    .theme-official .shell.nav-collapsed .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 30;
        width: 92px;
        max-width: 92px;
        height: 100dvh;
        max-height: 100dvh;
        padding: 28px 18px;
        align-items: center;
        transform: none;
        overflow: hidden;
    }

    .shell.nav-collapsed .main-panel,
    .theme-clean .shell.nav-collapsed .main-panel,
    .theme-official .shell.nav-collapsed .main-panel {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding-left: 112px;
    }

    .shell.nav-collapsed .content,
    .theme-clean .shell.nav-collapsed .content,
    .theme-official .shell.nav-collapsed .content,
    .shell.nav-collapsed .topbar,
    .theme-clean .shell.nav-collapsed .topbar,
    .theme-official .shell.nav-collapsed .topbar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        margin-inline: 0;
    }

    .shell.nav-collapsed .sidebar-backdrop,
    .theme-clean .shell.nav-collapsed .sidebar-backdrop,
    .theme-official .shell.nav-collapsed .sidebar-backdrop {
        display: none;
    }
}

/* Mobile flow hardening: one final layer that wins over older theme passes. */
body.app-shell {
    overflow-x: hidden;
}

.app-shell .shell,
.app-shell .main-panel,
.app-shell .content,
.app-shell .topbar,
.app-shell .panel,
.app-shell .filter-panel,
.app-shell .data-table-shell,
.app-shell .live-filter-region,
.app-shell .table-wrap,
.app-shell .data-table-toolbar,
.app-shell .table-toolbar-group,
.app-shell .page-head,
.app-shell .panel-head,
.app-shell .filter-grid,
.app-shell .field-row,
.app-shell .page-actions,
.app-shell .filter-actions,
.app-shell .inline-actions,
.app-shell .chip-row,
.app-shell .metric-grid,
.app-shell .panel-grid,
.app-shell .detail-grid,
.app-shell .dashboard-graph-grid,
.app-shell .settings-grid,
.app-shell .workflow-panel-grid,
.app-shell .movement-filter-grid,
.app-shell .movement-preview-grid,
.app-shell .reports-summary-filter,
.app-shell .reports-summary-metrics,
.app-shell .reports-summary-columns,
.app-shell .scan-workspace,
.app-shell .scan-entry-panel,
.app-shell .scan-batch-panel,
.app-shell .purchase-line-card,
.app-shell .handover-close-card,
.app-shell .access-form-panel,
.app-shell .item-form-shell,
.app-shell .item-form,
.app-shell .item-form-section,
.app-shell .item-form-grid,
.app-shell .item-form-actions,
.app-shell .item-form-barcode-preview,
.app-shell .file-card-grid,
.app-shell .timeline-list,
.app-shell .notification-filter-grid,
.app-shell .notification-card-grid,
.app-shell .report-preset-card,
.app-shell .summary-card,
.app-shell .summary-list {
    min-width: 0;
    max-width: 100%;
}

.app-shell input,
.app-shell select,
.app-shell textarea,
.app-shell button,
.app-shell img,
.app-shell canvas,
.app-shell video,
.app-shell svg {
    max-width: 100%;
}

.app-shell .nav-link,
.app-shell .global-search,
.app-shell .global-search label,
.app-shell .topbar-actions,
.app-shell .topbar-user-menu,
.app-shell .topbar-user-trigger,
.app-shell .cell-link,
.app-shell .cell-link-compact,
.app-shell .item-table-cell,
.app-shell .status-pill,
.app-shell .pill,
.app-shell .role-chip,
.app-shell .table-shell-copy,
.app-shell .muted-copy,
.app-shell .tiny-copy {
    min-width: 0;
    overflow-wrap: anywhere;
}

.app-shell .sidebar {
    max-width: 100vw;
}

.app-shell .sidebar .nav-links {
    width: 100%;
}

@media (max-width: 1360px) {
    .app-shell .shell,
    .app-shell .shell.nav-collapsed,
    .theme-clean.app-shell .shell,
    .theme-clean.app-shell .shell.nav-collapsed,
    .theme-official.app-shell .shell,
    .theme-official.app-shell .shell.nav-collapsed {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .app-shell .shell.nav-collapsed .main-panel,
    .theme-clean.app-shell .shell.nav-collapsed .main-panel,
    .theme-official.app-shell .shell.nav-collapsed .main-panel {
        padding-left: clamp(12px, 3vw, 28px);
    }

    .app-shell .sidebar,
    .app-shell .shell.nav-collapsed .sidebar,
    .theme-clean.app-shell .sidebar,
    .theme-clean.app-shell .shell.nav-collapsed .sidebar,
    .theme-official.app-shell .sidebar,
    .theme-official.app-shell .shell.nav-collapsed .sidebar {
        left: 0;
        right: auto;
        width: min(88vw, 320px);
        max-width: min(88vw, 320px);
        transform: translateX(-105%);
        pointer-events: none;
    }

    .app-shell .shell.nav-open .sidebar,
    .theme-clean.app-shell .shell.nav-open .sidebar,
    .theme-official.app-shell .shell.nav-open .sidebar {
        transform: translateX(0);
        pointer-events: auto;
    }

    .app-shell .content,
    .theme-clean.app-shell .content,
    .theme-official.app-shell .content,
    .app-shell .topbar,
    .theme-clean.app-shell .topbar,
    .theme-official.app-shell .topbar {
        width: 100%;
        max-width: 100%;
        margin-inline: 0;
        padding-inline: 0;
    }
}

@media (max-width: 900px) {
    .app-shell .topbar,
    .theme-clean.app-shell .topbar,
    .theme-official.app-shell .topbar {
        position: sticky;
        top: 0;
        z-index: 24;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        gap: 10px;
        align-items: center;
        padding: 10px 0;
    }

    .app-shell .global-search,
    .theme-clean.app-shell .global-search,
    .theme-official.app-shell .global-search {
        grid-column: 1 / -1;
        order: 3;
        width: 100%;
        max-width: none;
    }

    .app-shell .topbar-actions {
        justify-content: flex-end;
    }

    .app-shell .table-wrap,
    .app-shell .data-table-scroll,
    .app-shell .table-scroll,
    .app-shell .summary-table-scroll {
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 760px) {
    .app-shell .main-panel,
    .theme-clean.app-shell .main-panel,
    .theme-official.app-shell .main-panel {
        width: 100%;
        padding: 10px 12px calc(28px + env(safe-area-inset-bottom));
    }

    .app-shell .content,
    .theme-clean.app-shell .content,
    .theme-official.app-shell .content {
        gap: 14px;
    }

    .app-shell .panel,
    .app-shell .filter-panel,
    .theme-clean.app-shell .panel,
    .theme-clean.app-shell .filter-panel,
    .theme-official.app-shell .panel,
    .theme-official.app-shell .filter-panel {
        padding: 16px;
        border-radius: 22px;
        overflow: hidden;
    }

    .app-shell .page-head,
    .app-shell .panel-head,
    .app-shell .table-shell-head,
    .app-shell .data-table-toolbar,
    .app-shell .filter-grid,
    .app-shell .filter-actions,
    .app-shell .page-actions,
    .app-shell .button-row,
    .app-shell .inline-actions {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
        text-align: left;
        gap: 12px;
        width: 100%;
    }

    .app-shell .filter-grid > *,
    .app-shell .filter-actions > *,
    .app-shell .page-actions > *,
    .app-shell .button-row > *,
    .app-shell .inline-actions > *,
    .app-shell .data-table-toolbar > *,
    .app-shell .table-toolbar-group > * {
        width: 100%;
        max-width: 100%;
    }

    .app-shell .primary-button,
    .app-shell .ghost-button,
    .app-shell .danger-button,
    .app-shell .table-export-button {
        justify-content: center;
        white-space: normal;
    }

    .app-shell .metric-grid,
    .app-shell .compact-grid,
    .app-shell .panel-grid,
    .app-shell .detail-grid,
    .app-shell .dashboard-graph-grid,
    .app-shell .settings-grid,
    .app-shell .workflow-panel-grid,
    .app-shell .movement-filter-grid,
    .app-shell .movement-preview-grid,
    .app-shell .reports-summary-filter,
    .app-shell .reports-summary-metrics,
    .app-shell .reports-summary-columns,
    .app-shell .scan-workspace,
    .app-shell .scan-entry-panel,
    .app-shell .scan-batch-panel,
    .app-shell .purchase-line-core,
    .app-shell .purchase-line-detail-grid,
    .app-shell .handover-detail-grid,
    .app-shell .handover-value-strip,
    .app-shell .handover-compact-grid,
    .app-shell .handover-usage-row,
    .app-shell .handover-expected-usage-row,
    .app-shell .access-summary-card,
    .app-shell .access-summary-stats,
    .app-shell .permission-grid,
    .app-shell .asset-category-layout,
    .app-shell .file-card-grid {
        display: grid;
        grid-template-columns: 1fr;
    }

    .app-shell .handover-expected-usage-row input[data-expected-usage-other][hidden] + input[data-expected-usage-name="expected_usage_notes"] {
        grid-column: auto;
    }

    .app-shell .handover-expected-add,
    .app-shell .handover-expected-remove {
        width: 100%;
    }

    .app-shell .item-form-section-head,
    .app-shell .item-form-actions,
    .app-shell .item-form-barcode-preview,
    .app-shell .notification-filter-grid,
    .app-shell .notification-card-grid,
    .app-shell .report-preset-card,
    .app-shell .summary-card-head {
        display: grid;
        grid-template-columns: 1fr;
    }

    .app-shell .data-table-mobile td {
        grid-template-columns: minmax(84px, 32%) minmax(0, 1fr);
    }

    .app-shell .data-table-mobile td > *,
    .app-shell .data-table-mobile .item-table-cell,
    .app-shell .data-table-mobile .cell-link,
    .app-shell .data-table-mobile .cell-link-compact {
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
    }

    .app-shell .notification-panel,
    .app-shell .topbar-user-panel,
    .app-shell .global-search-panel,
    .theme-clean.app-shell .notification-panel,
    .theme-clean.app-shell .topbar-user-panel,
    .theme-clean.app-shell .global-search-panel,
    .theme-official.app-shell .notification-panel,
    .theme-official.app-shell .topbar-user-panel,
    .theme-official.app-shell .global-search-panel {
        position: fixed;
        top: 76px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        max-height: calc(100dvh - 96px);
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    .app-shell .summary-list,
    .app-shell .workflow-card-list,
    .app-shell .dashboard-notification-list,
    .app-shell .latest-updates,
    .app-shell [data-dashboard-notifications] {
        max-height: min(420px, 58dvh);
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .app-shell .asset-category-card {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .app-shell .asset-category-drag-handle {
        width: 100%;
    }

    .app-shell .asset-category-meta {
        justify-content: flex-start;
        text-align: left;
    }

    .app-shell .asset-category-children {
        margin-left: 10px;
        padding-left: 10px;
    }
}

@media (max-width: 420px) {
    .app-shell .data-table-mobile td {
        grid-template-columns: 1fr;
    }

    .app-shell .data-table-mobile td::before {
        margin-bottom: 4px;
    }
}

/* Mobile-first workflow cleanup: employee pages must not side-scroll or clip actions. */
html,
body.app-shell {
    max-width: 100%;
    overflow-x: clip;
}

.app-shell .main-panel,
.app-shell .content,
.app-shell .live-filter-region,
.app-shell .workflow-line-builder,
.app-shell .scan-center,
.app-shell .assets-page {
    overflow-x: clip;
}

.mobile-filter-details {
    display: grid;
    gap: 14px;
}

.mobile-filter-summary {
    display: none;
    list-style: none;
}

.mobile-filter-summary::-webkit-details-marker {
    display: none;
}

.mobile-filter-body {
    display: grid;
    gap: 14px;
}

.movement-log-table .item-table-cell {
    align-items: center;
}

.row-action-menu {
    position: relative;
}

.row-action-menu[open] {
    z-index: 80;
}

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

    .app-shell .main-panel,
    .theme-clean.app-shell .main-panel,
    .theme-official.app-shell .main-panel {
        padding-inline: 12px;
    }

    .app-shell .page-head-title {
        font-size: clamp(2rem, 11vw, 3.2rem);
        line-height: .9;
    }

    .app-shell .panel,
    .app-shell .filter-panel,
    .app-shell .data-table-shell {
        padding: 14px;
        border-radius: 22px;
    }

    .app-shell .table-wrap {
        overflow: visible;
    }

    .app-shell .data-table-toolbar {
        gap: 10px;
    }

    .app-shell .table-toolbar-group {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .app-shell .table-page-size {
        justify-content: space-between;
    }

    .app-shell .table-page-size select {
        width: min(140px, 46vw);
    }

    .app-shell .data-table-mobile tbody tr {
        padding: 10px 14px;
        border-radius: 22px;
        background: #fffaf1;
    }

    .app-shell .data-table-mobile td[data-label="Item"],
    .app-shell .data-table-mobile td[data-label="Asset"],
    .app-shell .data-table-mobile td[data-label="Notes"],
    .app-shell .data-table-mobile td[data-label="Actions"] {
        grid-template-columns: 1fr;
    }

    .app-shell .data-table-mobile .item-table-cell {
        display: grid;
        grid-template-columns: 52px minmax(0, 1fr);
        gap: 12px;
        align-items: center;
    }

    .app-shell .data-table-mobile .item-thumb {
        width: 52px;
        height: 52px;
        border-radius: 16px;
    }

    .app-shell .row-action-menu {
        width: 100%;
    }

    .app-shell .row-action-menu summary {
        width: 100%;
        min-height: 46px;
        justify-content: center;
        border-radius: 16px;
    }

    .app-shell .row-action-list,
    .app-shell .data-table-mobile .row-action-list {
        position: static;
        width: 100%;
        min-width: 0;
        margin-top: 10px;
        box-shadow: none;
        background: #fffdf8;
    }

    .app-shell .row-action-list a,
    .app-shell .row-action-list button {
        min-height: 46px;
        justify-content: flex-start;
        border: 1px solid rgba(231, 182, 74, 0.18);
        background: #fff;
    }

    .mobile-filter-summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 58px;
        padding: 14px 16px;
        border: 1px solid var(--line);
        border-radius: 18px;
        background: #fffaf1;
        cursor: pointer;
        font-weight: 900;
    }

    .mobile-filter-summary span {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-filter-summary small {
        color: var(--muted);
        font-size: .74rem;
        font-weight: 800;
        text-align: right;
    }

    .mobile-filter-details:not([open]) .mobile-filter-body {
        display: none;
    }

    .app-shell .assets-filter-grid,
    .app-shell .movement-filter-grid,
    .app-shell .filter-grid {
        grid-template-columns: 1fr;
    }

    .app-shell .assets-metric-grid {
        grid-template-columns: 1fr;
    }

    .app-shell .asset-table,
    .app-shell .movement-log-table,
    .app-shell .workflow-line-table,
    .app-shell .workflow-close-table {
        width: 100%;
        min-width: 0;
        table-layout: auto;
    }

    .app-shell .workflow-line-table thead {
        display: none;
    }

    .app-shell .workflow-line-table,
    .app-shell .workflow-line-table tbody,
    .app-shell .workflow-line-table tr,
    .app-shell .workflow-line-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .app-shell .workflow-line-table tbody {
        display: grid;
        gap: 14px;
    }

    .app-shell .workflow-line-table tr {
        padding: 14px;
        border: 1px solid var(--line);
        border-radius: 24px;
        background: #fffdf8;
        box-shadow: 0 14px 34px rgba(22, 18, 11, 0.045);
        overflow: visible;
    }

    .app-shell .workflow-line-table td {
        padding: 8px 0;
        border: 0;
        overflow: visible;
        white-space: normal;
    }

    .app-shell .workflow-line-table td:nth-child(2),
    .app-shell .workflow-line-table td:nth-child(3),
    .app-shell .workflow-line-table td:nth-child(4) {
        width: 100%;
    }

    .app-shell .workflow-line-table td > input[type="number"],
    .app-shell .workflow-line-table td > button,
    .app-shell .workflow-line-table .danger-link {
        width: 100%;
        min-width: 0;
        min-height: 48px;
    }

    .app-shell .workflow-picker-toggle {
        min-height: 64px;
        border-radius: 18px;
    }

    .app-shell .workflow-picker-panel {
        position: static;
        max-height: 58dvh;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .app-shell .workflow-picker-options {
        max-height: 44dvh;
        overflow-y: auto;
        display: grid;
        gap: 8px;
        width: 100%;
        height: auto;
        background: transparent;
        color: inherit;
    }

    .app-shell .workflow-picker-option {
        border-radius: 18px;
        padding: 12px;
        background: #fbf7ef;
        border: 1px solid #ece1d0;
    }

    .app-shell .handover-expected-usage {
        margin-top: 12px;
        border-radius: 20px;
        overflow: hidden;
    }

    .app-shell .handover-expected-usage-row,
    .app-shell .handover-usage-row {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .app-shell .handover-expected-usage-row > *,
    .app-shell .handover-usage-row > *,
    .app-shell .handover-close-card-head > *,
    .app-shell .handover-close-summary-stats > * {
        width: 100%;
        min-width: 0;
    }

    .app-shell .handover-close-card-summary {
        grid-template-columns: 1fr;
        gap: 12px;
        align-items: stretch;
    }

    .app-shell .handover-close-summary-stats {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        justify-content: stretch;
    }

    .app-shell .handover-close-chip {
        justify-content: center;
        min-width: 0;
        padding: 9px 8px;
    }

    .app-shell .handover-close-toggle {
        width: 100%;
    }

    .app-shell .handover-close-card-body,
    .app-shell .handover-close-card-head,
    .app-shell .handover-usage-title,
    .app-shell .handover-usage-summary {
        display: grid;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .app-shell .handover-usage-field {
        display: grid;
        gap: 6px;
    }

    .app-shell .handover-usage-remove,
    .app-shell .handover-add-usage,
    .app-shell .handover-expected-add,
    .app-shell .handover-expected-remove {
        min-height: 48px;
        width: 100%;
        justify-content: center;
    }

    .app-shell .scan-entry-panel {
        position: sticky;
        top: 76px;
        z-index: 12;
        box-shadow: 0 18px 44px rgba(22, 18, 11, 0.1);
    }

    .app-shell .scan-entry-form,
    .app-shell .scan-entry-actions,
    .app-shell .scan-batch-scan,
    .app-shell .scan-batch-controls,
    .app-shell .scan-batch-row,
    .app-shell .scan-batch-row-main,
    .app-shell .scan-batch-packaging,
    .app-shell .scan-batch-packaging .scan-package-controls,
    .app-shell .scan-batch-packaging .scan-custom-package-fields,
    .app-shell .scan-batch-footer {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .app-shell .scan-batch-list {
        max-height: min(520px, 58dvh);
        overflow-y: auto;
        overflow-x: hidden;
        padding-right: 2px;
    }

    .app-shell .scan-batch-row {
        padding: 14px;
        border-radius: 20px;
        background: #fffaf1;
    }

    .app-shell .scan-batch-qty {
        display: grid;
        grid-template-columns: 48px minmax(0, 1fr) 48px;
        width: 100%;
    }

    .app-shell .scan-camera,
    .app-shell .scan-batch-camera-slot .scan-camera {
        width: 100%;
        min-height: 220px;
        border-radius: 22px;
    }

    .app-shell .summary-list,
    .app-shell .workflow-card-list,
    .app-shell .dashboard-notification-list,
    .app-shell .latest-updates,
    .app-shell [data-dashboard-notifications] {
        scrollbar-width: none;
    }

    .app-shell .summary-list:hover,
    .app-shell .workflow-card-list:hover,
    .app-shell .dashboard-notification-list:hover,
    .app-shell .latest-updates:hover,
    .app-shell [data-dashboard-notifications]:hover {
        scrollbar-width: thin;
    }
}

@media (max-width: 430px) {
    .app-shell .handover-close-summary-stats {
        grid-template-columns: 1fr;
    }

    .mobile-filter-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .mobile-filter-summary small {
        text-align: left;
    }
}

/* Mobile table policy: keep tables as tables and let the table area side-scroll. */
@media (max-width: 760px) {
    .app-shell .table-wrap,
    .app-shell .data-table-scroll,
    .app-shell .table-scroll,
    .app-shell .summary-table-scroll {
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        overflow-y: visible;
        -webkit-overflow-scrolling: touch;
        scrollbar-gutter: stable;
    }

    .app-shell .table-wrap {
        margin-inline: -2px;
        padding-inline: 2px;
    }

    .app-shell .data-table-mobile,
    .app-shell .workflow-line-table,
    .app-shell .workflow-close-table {
        display: table !important;
        width: 100%;
        min-width: 920px !important;
        table-layout: auto;
    }

    .app-shell .movement-log-table {
        min-width: 1320px !important;
    }

    .app-shell .asset-table {
        min-width: 1180px !important;
    }

    .app-shell .data-table-mobile thead,
    .app-shell .workflow-line-table thead,
    .app-shell .workflow-close-table thead {
        display: table-header-group !important;
    }

    .app-shell .data-table-mobile tbody,
    .app-shell .workflow-line-table tbody,
    .app-shell .workflow-close-table tbody {
        display: table-row-group !important;
    }

    .app-shell .data-table-mobile tr,
    .app-shell .workflow-line-table tr,
    .app-shell .workflow-close-table tr {
        display: table-row !important;
        width: auto !important;
        padding: 0 !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    .app-shell .data-table-mobile tr[hidden],
    .app-shell .workflow-line-table tr[hidden],
    .app-shell .workflow-close-table tr[hidden] {
        display: none !important;
    }

    .app-shell .data-table-mobile th,
    .app-shell .data-table-mobile td,
    .app-shell .workflow-line-table th,
    .app-shell .workflow-line-table td,
    .app-shell .workflow-close-table th,
    .app-shell .workflow-close-table td {
        display: table-cell !important;
        width: auto !important;
        min-width: 0;
        padding: 12px 10px !important;
        border-bottom: 1px solid #efe7db !important;
        white-space: normal;
        vertical-align: top;
    }

    .app-shell .data-table-mobile th,
    .app-shell .workflow-line-table th,
    .app-shell .workflow-close-table th {
        white-space: nowrap;
    }

    .app-shell .data-table-mobile td::before,
    .app-shell .workflow-line-table td::before,
    .app-shell .workflow-close-table td::before {
        content: none !important;
        display: none !important;
    }

    .app-shell .data-table-mobile .item-table-cell,
    .app-shell .data-table-mobile .cell-link,
    .app-shell .data-table-mobile .cell-link-compact {
        display: flex !important;
        align-items: center;
        gap: 10px;
        min-width: max-content;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .app-shell .data-table-mobile .item-thumb {
        width: 46px;
        height: 46px;
        flex: 0 0 46px;
        border-radius: 14px;
    }

    .app-shell .data-table-mobile .table-actions-cell,
    .app-shell .data-table-mobile td[data-label="Actions"] {
        width: 1% !important;
        min-width: 76px;
        white-space: nowrap;
    }

    .app-shell .data-table-mobile .row-action-menu {
        width: auto;
        display: inline-grid;
        justify-items: center;
    }

    .app-shell .data-table-mobile .row-action-menu summary {
        width: 44px;
        min-height: 44px;
        justify-content: center;
        border-radius: 999px;
    }

    .app-shell .data-table-mobile .row-action-list {
        min-width: 180px;
    }
}

/* Searchable select dropdowns must overlay the page, not push surrounding filters/forms down. */
.panel.has-combobox-open,
.filter-panel.has-combobox-open,
[data-live-filter-region].has-combobox-open {
    overflow: visible !important;
}

.select-combobox,
.app-shell .select-combobox,
.asset-search-combobox,
.filter-search-combobox {
    position: relative !important;
    min-width: 0;
}

.select-combobox.is-open,
.app-shell .select-combobox.is-open,
.asset-search-combobox.is-open,
.filter-search-combobox.is-open {
    z-index: 560;
}

.select-combobox .select-combobox-panel,
.app-shell .select-combobox .select-combobox-panel,
.asset-search-combobox .select-combobox-panel,
.filter-search-combobox .select-combobox-panel {
    position: absolute !important;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 220;
    width: 100%;
    margin-top: 0;
    max-height: min(420px, 62dvh);
    overflow: hidden;
    display: grid;
    gap: 12px;
}

.select-combobox .select-combobox-options,
.app-shell .select-combobox .select-combobox-options,
.asset-search-combobox .select-combobox-options,
.filter-search-combobox .select-combobox-options {
    max-height: min(300px, 44dvh);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.select-combobox .select-combobox-panel[hidden],
.app-shell .select-combobox .select-combobox-panel[hidden],
.asset-search-combobox .select-combobox-panel[hidden],
.filter-search-combobox .select-combobox-panel[hidden] {
    display: none !important;
}

/* Open workflow item pickers should behave like dropdowns, not like new form sections. */
.workflow-picker.is-open {
    z-index: 620;
}

.workflow-picker.is-open > .workflow-picker-panel:not(.select-combobox-panel) {
    position: absolute !important;
    top: calc(100% + 8px);
    left: 0;
    right: auto;
    z-index: 620;
    width: min(760px, calc(100vw - 48px));
    max-width: calc(100vw - 48px);
    max-height: min(460px, 64dvh);
    margin-top: 0;
    overflow: hidden;
    box-shadow: 0 28px 70px rgba(22, 18, 11, 0.18);
}

.workflow-picker.is-open > .workflow-picker-panel:not(.select-combobox-panel) .workflow-picker-options {
    max-height: min(340px, 48dvh);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.workflow-line-table td:has(.workflow-picker.is-open) {
    position: relative;
    z-index: 620;
}

@media (max-width: 760px) {
    .workflow-picker.is-open > .workflow-picker-panel:not(.select-combobox-panel) {
        width: min(520px, calc(100vw - 32px));
        max-width: calc(100vw - 32px);
        max-height: min(420px, 58dvh);
    }
}

@media (max-width: 900px) {
    .saved-report-form,
    .saved-report-form-compact {
        grid-template-columns: 1fr;
    }

    .saved-report-filter-query,
    .saved-report-description {
        grid-column: auto;
    }

    .report-preset-actions .primary-button,
    .report-preset-actions .ghost-button,
    .saved-report-admin-actions .ghost-button {
        width: 100%;
        justify-content: center;
    }
}

/* Migrated mobile hardening from app.css during frontend modular refactor. */
/* Mobile hardening: keep overlays usable and make scan workflows reachable. */
@media (max-width: 1100px) {
    html.nav-modal-open,
    html.nav-modal-open body {
        overflow: hidden;
    }

    .sidebar,
    .theme-clean .sidebar,
    .theme-official .sidebar {
        height: 100dvh;
        max-height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(28px + env(safe-area-inset-bottom));
    }

    .sidebar .nav-links,
    .theme-clean .sidebar .nav-links,
    .theme-official .sidebar .nav-links {
        min-height: 0;
        overflow-y: visible;
        overflow-x: hidden;
        padding-right: 4px;
    }

    .sidebar-footer,
    .theme-clean .sidebar-footer,
    .theme-official .sidebar-footer {
        margin-top: 18px;
    }
}

@media (max-width: 760px) {
    .topbar,
    .theme-clean .topbar {
        position: sticky;
        top: 0;
        z-index: 25;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
    }

    .topbar .global-search,
    .theme-clean .topbar .global-search {
        grid-column: 1 / -1;
        order: initial;
        width: 100%;
        min-width: 0;
    }

    .global-search label,
    .theme-clean .global-search label {
        width: 100%;
        min-width: 0;
    }

    .notification-panel,
    .theme-clean .notification-panel,
    .topbar-user-panel,
    .theme-clean .topbar-user-panel,
    .global-search-panel,
    .theme-clean .global-search-panel {
        position: fixed;
        top: 76px;
        left: 12px;
        right: 12px;
        width: auto;
        max-width: none;
        max-height: calc(100dvh - 96px);
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    .page-head,
    .panel-head,
    .table-shell-head,
    .data-table-toolbar,
    .filter-actions,
    .page-actions,
    .button-row {
        align-items: stretch;
    }

    .page-actions > *,
    .button-row > *,
    .filter-actions > * {
        flex: 1 1 auto;
        justify-content: center;
    }

    .content,
    .theme-clean .content {
        width: 100%;
        max-width: 100%;
        padding-inline: 12px;
    }

    .panel,
    .filter-panel,
    .theme-clean .panel,
    .theme-clean .filter-panel {
        max-width: 100%;
        overflow: hidden;
    }

    .data-table-wrap,
    .data-table-scroll,
    .table-scroll,
    .responsive-table,
    .table-shell {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    input,
    select,
    textarea {
        font-size: 16px;
    }

    .scan-entry-panel,
    .scan-batch-panel,
    .scan-results-panel,
    .scan-selected-panel {
        padding: 16px;
    }

    .scan-search-field {
        min-height: 54px;
        border: 1px solid var(--border);
        border-radius: 16px;
        background: var(--paper);
    }

    .scan-camera-slot:empty {
        display: none;
    }

    .scan-batch-camera-slot {
        margin: 12px 0 16px;
    }

    .scan-batch-camera-slot .scan-camera,
    .scan-entry-panel .scan-camera {
        min-height: 260px;
    }

    .scan-camera video {
        min-height: 240px;
    }

    .scan-batch-footer {
        position: sticky;
        bottom: 0;
        z-index: 2;
        padding-top: 10px;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.76), var(--paper) 36%);
    }
}

/* Mobile-first operational polish: package-aware scans without hiding features. */
.item-package-presets {
    display: grid;
    gap: 14px;
    margin-top: 18px;
    padding: 16px;
    border: 1px solid #ece1d2;
    border-radius: 22px;
    background: #fffdf8;
}

.item-package-presets-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: start;
}

.item-package-presets-head h4,
.item-package-presets-head p {
    margin: 0;
}

.package-preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

.package-preset-card {
    display: grid;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--paper);
}

.package-preset-card.is-default {
    border-color: rgba(224, 177, 86, .62);
    box-shadow: inset 0 0 0 1px rgba(224, 177, 86, .22);
}

.package-preset-card strong,
.package-preset-card span,
.package-preset-card em {
    display: block;
}

.package-preset-card em {
    width: max-content;
    padding: 5px 9px;
    border-radius: 999px;
    background: rgba(224, 177, 86, .18);
    color: var(--accent-strong);
    font-style: normal;
    font-size: .78rem;
    font-weight: 900;
}

.package-preset-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.package-preset-actions form {
    margin: 0;
}

.package-preset-editor {
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.package-preset-editor summary {
    cursor: pointer;
    font-weight: 900;
    color: var(--accent-strong);
}

.package-preset-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(140px, .7fr) auto auto;
    gap: 12px;
    align-items: end;
    margin-top: 12px;
}

.package-default-toggle {
    align-self: stretch;
}

.scan-package-controls,
.scan-custom-package-fields {
    display: contents;
}

.scan-package-controls[hidden],
.scan-custom-package-fields[hidden] {
    display: none !important;
}

.scan-conversion-card {
    align-self: end;
    margin: 0;
    min-height: 48px;
    padding: 12px 14px;
    border: 1px solid rgba(224, 177, 86, .28);
    border-radius: 16px;
    background: rgba(255, 248, 235, .78);
    color: var(--accent-strong);
    font-weight: 800;
}

.scan-batch-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.scan-batch-row-main {
    display: grid;
    grid-template-columns: 54px minmax(180px, 1fr) minmax(170px, auto) auto;
    gap: 14px;
    align-items: center;
}

.scan-batch-packaging {
    display: grid;
    grid-template-columns: minmax(160px, .6fr) minmax(240px, 1fr) minmax(220px, 1fr);
    gap: 10px;
    align-items: end;
    padding-top: 10px;
    border-top: 1px solid rgba(224, 216, 203, .7);
}

.scan-batch-packaging .scan-package-controls {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1fr);
    gap: 10px;
}

.scan-batch-packaging .scan-custom-package-fields {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(110px, .7fr);
    gap: 10px;
}

.compact-field span {
    font-size: .78rem;
}

@media (max-width: 1100px) {
    .detail-grid,
    .scan-workspace,
    .dashboard-graph-grid,
    .workflow-panel-grid {
        grid-template-columns: 1fr;
    }

    .scan-entry-panel {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .scan-entry-form {
        grid-template-columns: 1fr;
        min-width: 0;
    }

    .scan-entry-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .scan-entry-actions > * {
        justify-content: center;
    }
}

@media (max-width: 760px) {
    .page-head {
        gap: 14px;
        padding-block: 12px;
    }

    .page-head h3 {
        font-size: clamp(30px, 9vw, 44px);
        line-height: .94;
    }

    .panel,
    .filter-panel,
    .detail-summary,
    .movement-panel {
        border-radius: 22px;
        padding: 16px;
    }

    .detail-hero,
    .item-summary-hero,
    .scan-selected-head {
        grid-template-columns: 1fr;
        text-align: left;
    }

    .detail-hero-main {
        grid-template-columns: 74px 1fr;
        gap: 12px;
    }

    .item-hero-image,
    .scan-selected-image {
        width: 74px;
        height: 74px;
        border-radius: 20px;
    }

    .item-summary-stock,
    .scan-selected-stock {
        text-align: left;
    }

    .settings-logo-actions .primary-button,
    .settings-logo-actions .ghost-button {
        width: 100%;
        justify-content: center;
    }

    .item-summary-stats,
    .movement-preview-grid,
    .metric-grid,
    .dashboard-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .item-summary-stat,
    .preview-card {
        min-height: 0;
        padding: 14px;
    }

    .item-summary-stat strong,
    .preview-card strong {
        font-size: clamp(22px, 7vw, 34px);
        line-height: 1;
    }

    .item-detail-barcode,
    .package-preset-form,
    .movement-form-grid,
    .scan-quick-grid,
    .scan-batch-controls,
    .scan-batch-scan,
    .scan-batch-packaging,
    .scan-batch-packaging .scan-package-controls,
    .scan-batch-packaging .scan-custom-package-fields {
        grid-template-columns: 1fr;
    }

    .item-detail-barcode .ghost-button,
    .package-preset-form .primary-button,
    .scan-quick-form .primary-button,
    .scan-batch-footer .primary-button {
        width: 100%;
        justify-content: center;
    }

    .item-detail-barcode-box .barcode-svg {
        max-width: 100%;
    }

    .item-package-presets-head {
        display: grid;
    }

    .scan-batch-row-main {
        grid-template-columns: 54px 1fr auto;
    }

    .scan-batch-row-main .danger-link {
        grid-column: 1 / -1;
        width: 100%;
        justify-content: center;
    }

    .scan-batch-qty {
        grid-column: 1 / -1;
        grid-template-columns: 48px 1fr 48px;
    }

    .scan-conversion-card {
        min-height: auto;
    }

    .dashboard-notifications,
    .workflow-card-list,
    .latest-updates,
    [data-dashboard-notifications] {
        max-height: min(420px, 58dvh);
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

}

/* Mobile operations pass: scanner, sidebar, OCR review, and dense dashboard cards. */
@media (max-width: 1100px) {
    .sidebar,
    .theme-clean .sidebar,
    .theme-official .sidebar {
        display: flex;
        min-height: 100dvh;
        height: 100dvh;
        overflow: hidden;
    }

    .sidebar-head,
    .theme-clean .sidebar-head,
    .theme-official .sidebar-head {
        flex: 0 0 auto;
    }

    .nav-links,
    .theme-clean .nav-links,
    .theme-official .nav-links {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        overflow-x: hidden;
        align-content: start;
        padding-right: 6px;
        padding-bottom: calc(28px + env(safe-area-inset-bottom));
        -webkit-overflow-scrolling: touch;
    }

    .scan-batch-panel,
    .scan-entry-panel {
        scroll-margin-top: 92px;
    }

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

@media (max-width: 760px) {
    body.app-shell {
        overflow-x: hidden;
    }

    .main-panel,
    .theme-clean .main-panel,
    .theme-official .main-panel {
        padding: 10px;
    }

    .content,
    .theme-clean .content,
    .theme-official .content {
        gap: 14px;
        padding-inline: 8px;
        padding-bottom: calc(36px + env(safe-area-inset-bottom));
    }

    .topbar,
    .theme-clean .topbar,
    .theme-official .topbar {
        margin-bottom: 14px;
    }

    .scan-entry-panel,
    .reports-hero-panel {
        gap: 14px;
    }

    .scan-entry-copy p:not(.eyebrow),
    .scan-batch-panel .panel-head .muted-copy {
        font-size: .9rem;
        line-height: 1.45;
    }

    .scan-entry-actions,
    .theme-clean .scan-entry-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .scan-entry-actions > *,
    .scan-selected-actions > *,
    .report-preset-actions > * {
        width: 100%;
        justify-content: center;
    }

    .scan-batch-panel .panel-head {
        gap: 12px;
    }

    .scan-batch-panel .panel-head .button-row {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

    .scan-batch-row {
        padding: 12px;
        border-radius: 18px;
    }

    .scan-batch-row-main {
        grid-template-columns: 48px minmax(0, 1fr);
    }

    .scan-batch-row-main .scan-batch-qty,
    .scan-batch-row-main .danger-link {
        grid-column: 1 / -1;
    }

    .scan-batch-packaging {
        padding-top: 12px;
        gap: 12px;
    }

    .scan-conversion-card {
        font-size: .84rem;
        line-height: 1.4;
    }

    .ocr-review-summary {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .ocr-review-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .purchase-document-preview-card {
        width: 100%;
    }

    .reports-hero-panel {
        grid-template-columns: 1fr;
    }

    .reports-hero-stat {
        width: 100%;
        min-width: 0;
        border-radius: 20px;
        padding: 18px;
    }

    .reports-card-grid {
        grid-template-columns: 1fr;
    }

    .report-preset-card {
        border-radius: 20px;
        padding: 16px;
    }

    .workflow-card-list,
    .dashboard-notification-list {
        max-height: min(420px, 56dvh);
        overflow-y: auto;
        padding-right: 2px;
    }
}

@media (max-width: 420px) {
    .ocr-review-metrics,
    .metric-grid,
    .item-summary-stats,
    .movement-preview-grid,
    .dashboard-summary-grid {
        grid-template-columns: 1fr;
    }
}

/* Responsive viewport matrix: compact phone, phone, tablet, compact desktop, desktop, and wide desktop. */
@media (max-width: 430px) {
    .app-shell .main-panel,
    .theme-clean.app-shell .main-panel,
    .theme-official.app-shell .main-panel {
        padding-inline: 8px;
    }

    .app-shell .content,
    .theme-clean.app-shell .content,
    .theme-official.app-shell .content {
        padding-inline: 4px;
    }

    .app-shell .panel,
    .app-shell .filter-panel,
    .app-shell .data-table-shell {
        padding: 12px;
        border-radius: 18px;
    }

    .app-shell .topbar {
        gap: 8px;
    }

    .app-shell .reports-summary-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 431px) and (max-width: 760px) {
    .app-shell .main-panel,
    .theme-clean.app-shell .main-panel,
    .theme-official.app-shell .main-panel {
        padding-inline: 14px;
    }

    .app-shell .content,
    .theme-clean.app-shell .content,
    .theme-official.app-shell .content {
        padding-inline: 0;
    }

    .app-shell .reports-summary-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 761px) and (max-width: 1024px) {
    .app-shell .main-panel,
    .theme-clean.app-shell .main-panel,
    .theme-official.app-shell .main-panel {
        padding: 18px 20px 34px;
    }

    .app-shell .content,
    .theme-clean.app-shell .content,
    .theme-official.app-shell .content {
        gap: 18px;
    }

    .app-shell .filter-grid,
    .app-shell .movement-filter-grid,
    .app-shell .assets-filter-grid,
    .app-shell .settings-grid,
    .app-shell .panel-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .app-shell .filter-actions,
    .app-shell .page-actions,
    .app-shell .button-row {
        flex-wrap: wrap;
    }

    .app-shell .reports-summary-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1025px) and (max-width: 1180px) {
    .app-shell .reports-summary-metrics {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1025px) and (max-width: 1360px) {
    .app-shell .main-panel,
    .theme-clean.app-shell .main-panel,
    .theme-official.app-shell .main-panel {
        padding-inline: clamp(22px, 3vw, 36px);
    }
}

@media (max-width: 1360px) {
    .app-shell .table-wrap,
    .app-shell .data-table-scroll,
    .app-shell .table-scroll,
    .app-shell .summary-table-scroll {
        width: 100%;
        max-width: 100%;
        overflow-x: auto !important;
        overscroll-behavior-inline: contain;
        -webkit-overflow-scrolling: touch;
    }
}

@media (min-width: 1361px) and (max-width: 1599px) {
    .app-shell .main-panel,
    .theme-clean.app-shell .main-panel,
    .theme-official.app-shell .main-panel {
        padding-inline: clamp(24px, 2.4vw, 42px);
    }
}

@media (min-width: 1600px) {
    .theme-clean.app-shell .content,
    .theme-official.app-shell .content,
    .app-shell .content {
        width: min(100%, 1840px);
        margin-inline: auto;
    }

    .app-shell .main-panel,
    .theme-clean.app-shell .main-panel,
    .theme-official.app-shell .main-panel {
        padding-inline: clamp(36px, 3vw, 64px);
    }

    .app-shell .panel,
    .app-shell .filter-panel,
    .app-shell .data-table-shell {
        scroll-margin-top: 110px;
    }
}

@media (max-width: 360px) {
    .app-shell .reports-summary-metrics {
        grid-template-columns: 1fr;
    }
}
