.inventory-document {
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: scroll !important;
    scrollbar-gutter: stable;
    scrollbar-color: #6f82a0 #e6ebf2;
    scrollbar-width: auto;
}

.inventory-document::-webkit-scrollbar {
    width: 16px;
}

.inventory-document::-webkit-scrollbar-track {
    background: #e6ebf2;
}

.inventory-document::-webkit-scrollbar-thumb {
    min-height: 72px;
    border: 3px solid #e6ebf2;
    border-radius: 999px;
    background: #6f82a0;
}

.inventory-document::-webkit-scrollbar-thumb:hover {
    background: #465a78;
}

.inventory-document body.role-warehouse_worker {
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: visible !important;
}

.inventory-page-shell {
    width: min(calc(100% - 32px), 1680px);
}

.inventory-dashboard .page-stack {
    gap: 18px;
}

.inventory-dashboard .inventory-watch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.inventory-dashboard .inventory-watch h1 {
    flex: 0 0 auto;
    margin: 0;
    font-size: clamp(1.8rem, 2.6vw, 2.5rem);
    line-height: 1.1;
}

.inventory-dashboard .inventory-watch__links {
    justify-content: flex-end;
    gap: 10px;
}

.inventory-dashboard .inventory-watch__links a {
    min-height: 48px;
    padding-inline: 16px;
}

.inventory-dashboard .inventory-search {
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 15px;
    background: #f8fafc;
}

.inventory-dashboard .inventory-search__controls {
    flex-wrap: nowrap;
}

.inventory-dashboard .inventory-search input {
    flex: 1 1 360px;
    background: #fff;
}

.inventory-dashboard .inventory-search__receive {
    flex: 0 0 auto;
    background: #fff;
}

.inventory-dashboard .inventory-panels {
    gap: 16px;
}

.inventory-dashboard .inventory-panels > .panel-card {
    min-width: 0;
    padding: 16px;
}

.inventory-dashboard .inventory-panels .panel-card__header {
    min-height: 44px;
    margin-bottom: 12px;
}

.inventory-dashboard .inventory-movements .panel-card__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
}

.inventory-dashboard .inventory-history-link {
    justify-self: end;
}

.inventory-dashboard .inventory-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    font-size: 0.82rem;
}

.inventory-dashboard .inventory-table :is(th, td) {
    padding: 10px 8px;
    overflow-wrap: anywhere;
    white-space: normal;
}

.inventory-dashboard .inventory-table th {
    font-size: 0.7rem;
    letter-spacing: 0.04em;
}

.inventory-dashboard .inventory-stock-table-wrap .inventory-table :is(th, td):nth-child(1) { width: 34%; }
.inventory-dashboard .inventory-stock-table-wrap .inventory-table :is(th, td):nth-child(2) { width: 22%; }
.inventory-dashboard .inventory-stock-table-wrap .inventory-table :is(th, td):nth-child(4) { width: 22%; }
.inventory-dashboard .inventory-stock-table-wrap .inventory-table :is(th, td):nth-child(5) { width: 22%; }
.inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(1) { width: 26%; }
.inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(2) { width: 18%; }
.inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(3) { width: 18%; }
.inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(5) { width: 20%; }
.inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(6) { width: 18%; }

@media screen and (min-width: 860px) {
    .inventory-dashboard .inventory-search > label {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .inventory-dashboard .inventory-panels {
        grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.1fr);
        align-items: start;
    }

    .inventory-dashboard .inventory-stock-table-wrap .inventory-table :is(th, td):nth-child(3),
    .inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(4) {
        display: none;
    }

    .inventory-dashboard .inventory-status {
        white-space: nowrap;
        overflow-wrap: normal;
    }
}

@media screen and (max-width: 1050px) and (min-width: 860px) {
    .inventory-dashboard {
        padding: 20px;
    }

    .inventory-dashboard .inventory-watch h1 {
        font-size: 1.7rem;
    }

    .inventory-dashboard .inventory-watch__links a {
        min-height: 44px;
        padding-inline: 12px;
    }

    .inventory-dashboard .inventory-search {
        padding: 8px;
    }

    .inventory-dashboard .inventory-search__controls {
        gap: 8px;
    }

    .inventory-dashboard .inventory-search input {
        flex-basis: 220px;
    }

    .inventory-dashboard .inventory-search :is(.button-link, .inventory-search__clear, .inventory-search__receive) {
        padding-inline: 10px;
        font-size: 0.86rem;
    }

    .inventory-dashboard .inventory-table {
        font-size: 0.75rem;
    }

    .inventory-dashboard .inventory-table :is(th, td) {
        padding: 9px 6px;
    }

    .inventory-dashboard .inventory-table th {
        font-size: 0.64rem;
    }

    .inventory-dashboard .inventory-status,
    .inventory-dashboard .status-chip {
        padding-inline: 6px;
        font-size: 0.72rem;
    }
}

@media screen and (max-width: 859px) {
    .inventory-dashboard .inventory-watch {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .inventory-dashboard .inventory-watch__links {
        justify-content: flex-start;
    }

    .inventory-dashboard .inventory-search__controls {
        flex-wrap: wrap;
    }
}

@media screen and (max-width: 760px) {
    .inventory-page-shell {
        width: calc(100% - 20px);
    }

    .inventory-dashboard .page-stack {
        gap: 14px;
    }

    .inventory-dashboard .inventory-watch h1 {
        font-size: 1.7rem;
    }

    .inventory-dashboard .inventory-search {
        padding: 0;
        border: 0;
        background: transparent;
    }

    .inventory-dashboard .inventory-movements .panel-card__header {
        display: flex;
    }
}

/* Dense desktop workbench: keep stock and recent movements visible in one viewport. */
@media screen and (min-width: 860px) {
    .inventory-document:has(.inventory-dashboard) {
        overflow-y: hidden !important;
        scrollbar-gutter: auto;
    }

    .inventory-document body.role-warehouse_worker:has(.inventory-dashboard),
    .inventory-document body.role-warehouse_worker:has(.inventory-dashboard) .site-shell {
        height: 100vh;
        min-height: 0;
        overflow: hidden !important;
    }

    .inventory-page-shell {
        width: 100%;
        height: 100vh;
        margin: 0;
        padding: 10px;
        box-sizing: border-box;
    }

    .inventory-dashboard {
        height: 100%;
        padding: 12px;
        border-radius: 16px;
        box-sizing: border-box;
    }

    .inventory-dashboard .page-stack {
        display: grid;
        height: 100%;
        grid-template-rows: auto auto minmax(0, 1fr);
        gap: 8px;
    }

    .inventory-dashboard .inventory-watch {
        min-height: 44px;
        gap: 12px;
    }

    .inventory-dashboard .inventory-watch h1 {
        font-size: clamp(1.4rem, 2.2vw, 1.7rem);
        line-height: 1;
    }

    .inventory-dashboard .inventory-watch__links {
        flex-wrap: nowrap;
        gap: 6px;
    }

    .inventory-dashboard .inventory-watch__links a {
        min-height: 40px;
        padding: 6px 11px;
        border-radius: 10px;
        white-space: nowrap;
        font-size: 0.78rem;
    }

    .inventory-dashboard .inventory-watch__links strong {
        font-size: 1rem;
    }

    .inventory-dashboard .inventory-search {
        padding: 0;
        border: 0;
        border-radius: 0;
        background: transparent;
    }

    .inventory-dashboard .inventory-search__controls {
        gap: 6px;
    }

    .inventory-dashboard .inventory-search input {
        min-height: 40px;
        padding: 8px 12px;
        border-radius: 10px;
        font-size: 0.8rem;
    }

    .inventory-dashboard .inventory-search :is(.button-link, .inventory-search__clear, .inventory-search__receive) {
        min-height: 40px;
        padding: 7px 10px;
        border-radius: 10px;
        font-size: 0.74rem;
        white-space: nowrap;
    }

    .inventory-dashboard .inventory-panels {
        height: 100%;
        min-height: 0;
        grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
        align-items: stretch;
        gap: 10px;
    }

    .inventory-dashboard .inventory-panels > .panel-card {
        display: flex;
        height: 100%;
        min-height: 0;
        flex-direction: column;
        padding: 10px;
        border-radius: 14px;
        box-sizing: border-box;
    }

    .inventory-dashboard .inventory-panels .panel-card__header {
        min-height: 32px;
        flex: 0 0 auto;
        margin-bottom: 6px;
    }

    .inventory-dashboard .inventory-panels .panel-card__header h2 {
        font-size: 0.98rem;
        line-height: 1.15;
    }

    .inventory-dashboard .panel-card__meta,
    .inventory-dashboard .inventory-history-link {
        min-height: 0;
        font-size: 0.69rem;
        line-height: 1.2;
    }

    .inventory-dashboard .inventory-movements .panel-card__header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: center;
        gap: 7px;
    }

    .inventory-dashboard .table-wrap {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
        scrollbar-color: #6f82a0 #eef2f7;
        scrollbar-width: thin;
    }

    .inventory-dashboard .inventory-table {
        font-size: 0.72rem;
        line-height: 1.25;
    }

    .inventory-dashboard .inventory-table :is(th, td) {
        padding: 6px;
        overflow-wrap: normal;
        word-break: normal;
    }

    .inventory-dashboard .inventory-table th {
        position: sticky;
        top: 0;
        z-index: 2;
        padding-block: 7px;
        font-size: 0.6rem;
        line-height: 1.15;
        letter-spacing: 0.035em;
    }

    .inventory-dashboard .inventory-table td {
        height: 34px;
    }

    .inventory-dashboard .inventory-product-link {
        min-height: 28px;
        overflow-wrap: normal;
        line-height: 1.2;
    }

    .inventory-dashboard .inventory-status,
    .inventory-dashboard .status-chip {
        padding: 4px 6px;
        font-size: 0.66rem;
        line-height: 1.2;
        white-space: nowrap;
    }

    .inventory-dashboard .movement-variant {
        margin-top: 2px;
        font-size: 0.62rem;
    }

    .inventory-dashboard .inventory-stock-table-wrap .inventory-table :is(th, td):nth-child(1) { width: 38%; }
    .inventory-dashboard .inventory-stock-table-wrap .inventory-table :is(th, td):nth-child(2) { width: 22%; }
    .inventory-dashboard .inventory-stock-table-wrap .inventory-table :is(th, td):nth-child(4) { width: 20%; }
    .inventory-dashboard .inventory-stock-table-wrap .inventory-table :is(th, td):nth-child(5) { width: 20%; }

    .inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(1) { width: 32%; }
    .inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(2) { width: 19%; }
    .inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(3) { width: 23%; }
    .inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(6) { width: 26%; }
}

@media screen and (min-width: 860px) and (max-width: 1050px) {
    .inventory-dashboard .inventory-movements .inventory-table :is(th, td):nth-child(5) {
        display: none;
    }
}

/* Movement history uses the same compact desktop workbench as the stock overview. */
@media screen and (min-width: 860px) {
    .inventory-document:has(.inventory-history-page) {
        overflow-y: hidden !important;
        scrollbar-gutter: auto;
    }

    .inventory-document body.role-warehouse_worker:has(.inventory-history-page),
    .inventory-document body.role-warehouse_worker:has(.inventory-history-page) .site-shell {
        height: 100vh;
        min-height: 0;
        overflow: hidden !important;
    }

    .inventory-history-page-shell {
        width: 100%;
        height: 100vh;
        margin: 0;
        padding: 10px;
        box-sizing: border-box;
    }

    .inventory-history-page {
        display: flex;
        height: 100%;
        min-height: 0;
        flex-direction: column;
        gap: 8px;
        padding: 12px;
        border-radius: 16px;
        box-sizing: border-box;
    }

    .inventory-history-page .page-header {
        min-height: 40px;
        align-items: center;
        gap: 12px;
    }

    .inventory-history-page .page-header h1 {
        font-size: clamp(1.35rem, 2.1vw, 1.65rem);
        line-height: 1.05;
    }

    .inventory-history-page .page-header .inventory-history-link {
        min-height: 36px;
        font-size: 0.74rem;
    }

    .inventory-history-page .inventory-history-filters {
        display: grid;
        grid-template-columns: minmax(180px, 1.35fr) minmax(110px, 0.75fr) minmax(110px, 0.75fr) minmax(150px, 1fr) auto;
        align-items: end;
        gap: 7px;
        margin: 0;
    }

    .inventory-history-page .inventory-history-field label {
        margin-bottom: 3px;
        color: #40526e;
        font-size: 0.68rem;
        line-height: 1.2;
    }

    .inventory-history-page .inventory-history-field .form-control {
        min-height: 38px;
        padding: 7px 9px;
        border-radius: 10px;
        font-size: 0.78rem;
    }

    .inventory-history-page .inventory-history-actions {
        grid-column: auto;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .inventory-history-page .inventory-history-actions .button-link,
    .inventory-history-page .inventory-history-actions .inventory-history-link {
        min-height: 38px;
        padding: 7px 10px;
        border-radius: 10px;
        font-size: 0.7rem;
        white-space: nowrap;
    }

    .inventory-history-page .inventory-history-results {
        display: flex;
        min-height: 0;
        flex: 1 1 auto;
        flex-direction: column;
        gap: 5px;
    }

    .inventory-history-page .inventory-history-results > .subcopy {
        flex: 0 0 auto;
        margin: 0;
        color: #5d6c83;
        font-size: 0.72rem;
        line-height: 1.2;
    }

    .inventory-history-page .inventory-history-table-wrap {
        flex: 1 1 auto;
        min-height: 0;
        overflow: auto;
        scrollbar-color: #6f82a0 #eef2f7;
        scrollbar-width: thin;
    }

    .inventory-history-page .data-table {
        width: 100%;
        table-layout: fixed;
        font-size: 0.72rem;
        line-height: 1.25;
    }

    .inventory-history-page .data-table :is(th, td) {
        padding: 6px 7px;
        overflow-wrap: normal;
        word-break: normal;
    }

    .inventory-history-page .data-table th {
        position: sticky;
        top: 0;
        z-index: 2;
        padding-block: 7px;
        font-size: 0.6rem;
        line-height: 1.15;
        letter-spacing: 0.035em;
    }

    .inventory-history-page .data-table td {
        height: 34px;
    }

    .inventory-history-page .inventory-product-link {
        min-height: 28px;
        overflow-wrap: normal;
        line-height: 1.2;
    }

    .inventory-history-page .status-chip {
        padding: 4px 7px;
        font-size: 0.66rem;
        line-height: 1.2;
        white-space: nowrap;
    }

    .inventory-history-page .movement-variant {
        margin-top: 2px;
        font-size: 0.62rem;
    }

    .inventory-history-page .data-table :is(th, td):nth-child(1) { width: 13%; }
    .inventory-history-page .data-table :is(th, td):nth-child(2) { width: 22%; }
    .inventory-history-page .data-table :is(th, td):nth-child(3) { width: 14%; }
    .inventory-history-page .data-table :is(th, td):nth-child(4) { width: 15%; }
    .inventory-history-page .data-table :is(th, td):nth-child(5) { width: 13%; }
    .inventory-history-page .data-table :is(th, td):nth-child(6) { width: 23%; }

    .inventory-history-page .inventory-history-pagination {
        flex: 0 0 auto;
        min-height: 32px;
        margin-top: 0;
        font-size: 0.7rem;
    }
}

@media screen and (min-width: 860px) and (max-width: 1050px) {
    .inventory-history-page .data-table :is(th, td):nth-child(6),
    .inventory-history-page .data-table :is(th, td):nth-child(7) {
        display: none;
    }

    .inventory-history-page .data-table :is(th, td):nth-child(1) { width: 18%; }
    .inventory-history-page .data-table :is(th, td):nth-child(2) { width: 29%; }
    .inventory-history-page .data-table :is(th, td):nth-child(3) { width: 18%; }
    .inventory-history-page .data-table :is(th, td):nth-child(4) { width: 19%; }
    .inventory-history-page .data-table :is(th, td):nth-child(5) { width: 16%; }
}
