.page-shell {
    display: grid;
    gap: 1rem;
}

.form-shell {
    display: grid;
    gap: 1rem;
}

.content-stage {
    width: min(1500px, 100%);
    margin: 0 auto;
    padding: 0 0.75rem;
}

.content-stage > .card {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

.almacen-carga-header h1 {
    color: var(--text-main);
}

.item-cell-stack {
    display: grid;
    gap: 0.22rem;
    min-width: 0;
    width: 100%;
}

.item-cell-stack--description {
    gap: 0.28rem;
}

.item-cell-code {
    color: var(--text-main);
    font-weight: 700;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.item-cell-text {
    color: #5b7181;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.item-field-control {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

.section-card {
    border: 1px solid #e4ebf2;
    border-radius: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    padding: 1rem 1.1rem;
    box-shadow: 0 8px 18px -18px rgba(0, 0, 0, 0.35);
    min-width: 0;
}

.section-title {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
}

.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.section-title-row .section-title {
    margin-bottom: 0;
}

.summary-bar {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 0.75rem;
}

.summary-item {
    border: 1px solid #e8eef4;
    border-radius: 12px;
    background: #f8fbfd;
    padding: 0.75rem 0.9rem;
    min-width: 0;
}

.summary-item .label {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.summary-item .value {
    color: var(--text-main);
    font-weight: 600;
    line-height: 1.25;
    overflow-wrap: anywhere;
    word-break: break-word;
}

html[data-theme='dark'] .almacen-carga-header h1,
html[data-theme='dark'] .section-card,
html[data-theme='dark'] .summary-item,
html[data-theme='dark'] .preview-item,
html[data-theme='dark'] .table-wrap,
html[data-theme='dark'] .items-empty-cell,
html[data-theme='dark'] .almacen-result-card,
html[data-theme='dark'] .operation-result {
    color: var(--theme-text) !important;
}

html[data-theme='dark'] .item-cell-code,
html[data-theme='dark'] .summary-item .value,
html[data-theme='dark'] .preview-item .value,
html[data-theme='dark'] .almacen-result-card__head strong,
html[data-theme='dark'] .almacen-result-card__grid strong {
    color: var(--theme-text) !important;
}

html[data-theme='dark'] .item-cell-text,
html[data-theme='dark'] .section-title,
html[data-theme='dark'] .summary-item .label,
html[data-theme='dark'] .preview-item .label,
html[data-theme='dark'] .almacen-result-card__description,
html[data-theme='dark'] .almacen-result-card__grid span {
    color: var(--theme-text-muted) !important;
}

html[data-theme='dark'] .item-field-control {
    background: var(--theme-surface-alt) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
}

html[data-theme='dark'] .item-field-control:focus {
    border-color: var(--theme-primary) !important;
    box-shadow: 0 0 0 0.2rem rgba(57, 166, 201, 0.18) !important;
}

html[data-theme='dark'] .items-table tr[data-item-row='true'] {
    background: var(--theme-surface) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-shadow);
}

html[data-theme='dark'] .items-table td::before {
    color: var(--theme-text-muted) !important;
}

html[data-theme='dark'] .action-icon-btn,
html[data-theme='dark'] .observation-indicator {
    background: var(--theme-surface-alt) !important;
    border-color: var(--theme-border) !important;
    color: var(--theme-primary) !important;
}

html[data-theme='dark'] .action-icon-btn:hover,
html[data-theme='dark'] .action-icon-btn:focus,
html[data-theme='dark'] .observation-indicator:hover,
html[data-theme='dark'] .observation-indicator:focus {
    background: var(--theme-primary) !important;
    border-color: var(--theme-primary) !important;
    color: #08141b !important;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.preview-item {
    border: 1px solid #e8eef4;
    border-radius: 12px;
    background: linear-gradient(180deg, #fbfdff 0%, #f7fafc 100%);
    padding: 0.7rem 0.85rem;
    min-width: 0;
}

.preview-item.full {
    grid-column: 1 / -1;
}

.preview-item .label {
    font-size: 0.76rem;
    color: #7E8080;
    margin-bottom: 0.2rem;
}

.preview-item .value {
    color: #446078;
    font-weight: 600;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.table-wrap {
    border: 1px solid #e8eef4;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
    min-width: 0;
}

.table-wrap table {
    margin-bottom: 0;
    width: 100%;
}

.items-table {
    min-width: 1040px;
}

.items-table td,
.items-table th {
    padding: 0.55rem 0.65rem;
}

.table-wrap thead th {
    background: #f7fafc;
    border-bottom-color: #e8eef4;
    font-size: 0.82rem;
    color: #446078;
}

.table-wrap td,
.table-wrap th {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    vertical-align: top;
}

.items-empty-cell {
    padding: 1.5rem 1rem !important;
    background: linear-gradient(180deg, #fbfdff 0%, #f7fafc 100%);
}

.items-empty-state {
    display: grid;
    gap: 0.25rem;
    justify-items: center;
    text-align: center;
    color: #7E8080;
}

.items-empty-state strong {
    color: #446078;
    font-size: 0.98rem;
    font-weight: 700;
}

.items-empty-state span {
    font-size: 0.88rem;
}

.content-stage .text-muted-brand {
    color: var(--text-muted);
}

.observation-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

.actions-cell {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    white-space: nowrap;
    width: auto;
}

.number-col {
    width: 48px;
    min-width: 48px;
}

.code-col {
    width: 112px;
    min-width: 112px;
}

.type-col {
    width: 126px;
    min-width: 126px;
}

.description-col {
    min-width: 240px;
    width: 240px;
}

.almacenado-col {
    width: 136px;
    min-width: 136px;
}

.stock-col {
    width: 136px;
    min-width: 136px;
}

.qty-almacen-col,
.qty-stock-col {
    width: 150px;
    min-width: 150px;
}

.obs-col {
    width: 72px;
    min-width: 72px;
    white-space: nowrap;
}

.actions-col {
    width: 96px;
    min-width: 96px;
    white-space: nowrap;
}

.item-adjust-field {
    display: block;
    min-width: 0;
}

.cantidad-almacenado-input,
.cantidad-stock-input {
    width: 100%;
    min-width: 0;
}

.action-btn {
    min-height: 40px;
    padding: 0.5rem 1rem;
    font-weight: 600;
}

.operation-result {
    border-color: rgba(7, 123, 161, 0.25);
    background: linear-gradient(180deg, #f8fcff 0%, #ffffff 100%);
    color: #446078;
}

.operation-result strong,
.operation-result .value {
    color: #077BA1;
}

.operation-result .table {
    color: #446078;
}

.operation-result .table thead th {
    background: #f2f9fd;
    color: #077BA1;
    border-bottom-color: #d9e8f2;
}

.observation-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    border: 1px solid rgba(7, 123, 161, 0.45);
    border-radius: 10px;
    background: #fff;
    color: #077BA1;
    cursor: pointer;
    flex: 0 0 auto;
}

.action-icon-btn {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(7, 123, 161, 0.45);
    border-radius: 10px;
    background: #fff;
    color: #077BA1;
}

.action-icon {
    line-height: 1;
}

.action-label {
    display: none;
}

.action-icon-btn:hover,
.action-icon-btn:focus {
    background: #077BA1;
    border-color: #077BA1;
    color: #fff;
}

.almacen-result-list {
    display: grid;
    gap: 0.85rem;
}

.almacen-result-card {
    border: 1px solid #e8eef4;
    border-radius: 14px;
    background: linear-gradient(180deg, #fbfdff 0%, #f7fafc 100%);
    padding: 0.9rem;
}

.almacen-result-card__head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 0.75rem;
}

.almacen-result-card__head strong {
    color: #446078;
}

.almacen-result-card__head span {
    color: #077BA1;
    font-weight: 700;
    white-space: nowrap;
}

.almacen-result-card__description {
    margin-top: 0.45rem;
    color: #5b7181;
}

.almacen-result-card__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
    margin-top: 0.75rem;
}

.almacen-result-card__grid span {
    display: block;
    margin-bottom: 0.22rem;
    color: #7E8080;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.almacen-result-card__grid strong {
    color: #446078;
    font-size: 0.92rem;
}

html[data-theme='dark'] .content-stage,
html[data-theme='dark'] .content-stage .card-body,
html[data-theme='dark'] .content-stage .text-muted-brand,
html[data-theme='dark'] .items-empty-state strong,
html[data-theme='dark'] .operation-result .table,
html[data-theme='dark'] .almacen-result-card__head span {
    color: var(--theme-text) !important;
}

html[data-theme='dark'] .content-stage .text-muted-brand,
html[data-theme='dark'] .items-empty-state,
html[data-theme='dark'] .items-empty-state span,
html[data-theme='dark'] .almacen-result-card__description,
html[data-theme='dark'] .almacen-result-card__grid span,
html[data-theme='dark'] .items-table td::before {
    color: var(--theme-text-muted) !important;
}

html[data-theme='dark'] .preview-item,
html[data-theme='dark'] .almacen-result-card,
html[data-theme='dark'] .items-empty-cell,
html[data-theme='dark'] .table-wrap {
    background: linear-gradient(180deg, rgba(28, 39, 49, 0.98) 0%, rgba(20, 29, 37, 0.98) 100%) !important;
}

@media (min-width: 768px) {
    .summary-bar {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .almacen-result-card__grid {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 767.98px) {
    .content-stage {
        width: 100%;
        max-width: 100%;
        padding: 0 0.2rem;
    }

    .content-stage > .card {
        width: 100%;
        max-width: 100%;
        border-radius: 16px;
    }

    .content-stage .card-body {
        padding: 0.78rem !important;
    }

    .almacen-carga-header,
    .almacen-carga-header__action,
    .section-title-row,
    .d-flex.justify-content-end.mt-3 {
        width: 100%;
    }

    .almacen-carga-header {
        gap: 0.9rem;
        margin-bottom: 1rem !important;
    }

    .almacen-carga-header h1 {
        font-size: 1.15rem;
        line-height: 1.25;
        margin-bottom: 0;
    }

    .almacen-carga-header__action,
    .section-title-row .btn,
    #actualizar-inventario-btn {
        width: 100%;
    }

    .section-card,
    .summary-item,
    .preview-item,
    .almacen-result-card {
        border-radius: 14px;
    }

    .section-card {
        padding: 0.75rem 0.7rem;
    }

    .section-title-row {
        align-items: stretch;
        gap: 0.65rem;
    }

    .summary-item,
    .preview-item,
    .almacen-result-card {
        padding: 0.72rem;
    }

    .summary-item .value,
    .preview-item .value,
    .almacen-result-card__grid strong {
        font-size: 0.95rem;
    }

    .table-wrap {
        border: 0;
        background: transparent;
        overflow-x: hidden;
        overflow-y: visible;
        width: 100%;
        max-width: 100%;
        margin: 0;
        box-sizing: border-box;
    }

    .table-wrap .table-responsive {
        overflow-x: hidden;
        overflow-y: visible;
        min-width: 0;
        width: 100%;
        max-width: 100%;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    .items-table {
        display: block;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
        overflow-x: clip;
    }

    .items-table thead {
        display: none;
    }

    .items-table,
    .items-table tbody {
        display: block;
        width: 100%;
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    .items-table tbody {
        display: grid;
        gap: 0.7rem;
        justify-items: stretch;
        min-width: 0;
        max-width: 100%;
        overflow-x: clip;
    }

    .items-table tbody,
    .items-table tr,
    .items-table td {
        display: block;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .items-table tr[data-item-row='true'] {
        width: 100%;
        max-width: 90vw;
        border: 1px solid #e8eef4;
        border-radius: 14px;
        background: #fbfdff;
        padding: 0.7rem 0.65rem;
        margin: 0;
        box-shadow: 0 8px 18px -18px rgba(0, 0, 0, 0.35);
        overflow: hidden;
        box-sizing: border-box;
        min-width: 0;
    }

    .items-table td {
        border: 0;
        padding: 0;
        margin-bottom: 0.58rem;
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
        overflow-wrap: anywhere;
        word-break: break-word;
        hyphens: auto;
    }

    .items-table td:last-child {
        margin-bottom: 0;
    }

    .items-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 0.18rem;
        color: #7E8080;
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.04em;
        text-transform: uppercase;
    }

    .items-table .description-col {
        width: 100%;
        min-width: 0;
        font-weight: 600;
        color: #446078;
        max-width: 100%;
        line-height: 1.25;
        text-wrap: pretty;
    }

    .items-table .type-col,
    .items-table .almacenado-col,
    .items-table .qty-almacen-col,
    .items-table .qty-stock-col,
    .items-table .obs-col,
    .items-table .actions-col,
    .items-table .code-col,
    .items-table .stock-col,
    .items-table .number-col {
        width: 100%;
        min-width: 0;
    }

    .items-table .description-col::before {
        margin-bottom: 0.3rem;
    }

    .items-table .item-cell-stack,
    .items-table .item-cell-code,
    .items-table .item-cell-text {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .items-table .item-cell-stack {
        display: grid;
        gap: 0.18rem;
    }

    .items-table tr[data-item-row='true'] *,
    .items-table td *,
    .items-table .item-field-control {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    .items-table .item-cell-code,
    .items-table .item-cell-text {
        font-size: 0.92rem;
        line-height: 1.22;
        overflow-wrap: anywhere;
        word-break: break-word;
        hyphens: auto;
        white-space: normal;
    }

    .items-table .item-cell-code {
        font-size: 0.94rem;
    }

    .items-table .qty-almacen-col,
    .items-table .qty-stock-col {
        overflow: visible;
    }

    .items-table .cantidad-input,
    .items-table .form-select,
    .items-table .item-field-control {
        display: block;
        width: 100%;
        min-width: 0;
        max-width: 100%;
        padding: 0.34rem 0.55rem;
        font-size: 0.89rem;
        line-height: 1.2;
    }

    .items-table .observation-cell {
        justify-content: flex-start;
    }

    .items-table .actions-cell {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        justify-content: stretch;
        width: 100%;
        gap: 0.42rem;
    }

    .items-table .actions-cell .action-icon-btn {
        width: 100%;
        min-width: 0;
        min-height: 2.4rem;
        height: auto;
        padding: 0.45rem 0.65rem;
        justify-content: center;
        gap: 0.35rem;
    }

    .items-table .actions-cell .action-label {
        display: inline;
        font-size: 0.84rem;
        font-weight: 600;
    }

    .items-table #items-empty-row,
    .items-table #items-empty-row td,
    .items-table .items-empty-cell,
    .items-table .items-empty-state {
        display: block;
        width: 100%;
    }

    .items-table .items-empty-cell {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1rem 0.75rem !important;
        margin: 0;
    }

    .items-table .items-empty-state {
        display: inline-grid;
        width: min(100%, 22rem);
        justify-items: center;
        align-content: center;
        text-align: center;
        margin: 0 auto;
        gap: 0.35rem;
    }

    .items-table .items-empty-cell::before {
        display: none;
    }
}

@media (min-width: 992px) and (max-aspect-ratio: 4/3) {
    .content-stage {
        width: min(1320px, 100%);
        padding: 0 0.5rem;
    }
}