/* Inventario MP - Module Styles (normalizado a tokens --pv-*) */

/* Escala exacta de la tabla de Historico OC (.ho-table-container table / .ho-th / .ho-td) */
#inventario-mp-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.73rem;
    margin-top: 0;
}

#inventario-mp-table th,
#inventario-mp-table td {
    padding: 5px 8px;
    font-size: 0.73rem;
    line-height: 1.22;
    vertical-align: middle;
    border-bottom: 1px solid rgba(51, 65, 85, 0.15);
}

#inventario-mp-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #1e293b;
    color: #94a3b8;
    text-transform: uppercase;
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 7px 8px;
    border-bottom: 2px solid rgba(51, 65, 85, 0.4);
}

#inventario-mp-table .ho-th {
    padding: 7px 8px;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.15;
}

#inventario-mp-table .ho-td {
    padding: 5px 8px;
    font-size: 0.73rem;
    line-height: 1.22;
    color: #cbd5e1;
}

#inventario-mp-table .mp-col-codigo { width: 5%; }
#inventario-mp-table .mp-col-lote { width: 5%; text-align: center; }
#inventario-mp-table .mp-col-material { width: 26%; }
#inventario-mp-table .mp-col-inv { width: 7%; }
#inventario-mp-table .mp-col-unidad { width: 4%; }
#inventario-mp-table .mp-col-cad { width: 6.5%; }
#inventario-mp-table .mp-col-maquila { width: 7%; }
#inventario-mp-table .mp-col-transito { width: 7%; }
#inventario-mp-table .mp-col-reservado { width: 6.5%; }
#inventario-mp-table .mp-col-valor { width: 8%; }
#inventario-mp-table .mp-col-disp { width: 7%; }
#inventario-mp-table .mp-col-action { width: 4%; text-align: center; }

#inventario-mp-table .mp-col-material,
#inventario-mp-table .mp-col-codigo,
#inventario-mp-table .mp-col-unidad {
    min-width: 0;
}

#inventario-mp-table .mp-col-material {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#inventario-mp-table .ho-td.text-success {
    color: var(--pv-green-text) !important;
}

#inventario-mp-table .ho-td.text-danger {
    color: #ef4444 !important;
}

#inventario-mp-table .ho-td.text-muted {
    color: #64748b !important;
}

#inventario-mp-table .ho-td.text-info {
    color: #60a5fa !important;
}

#inventario-mp-table .text-xs {
    font-size: 0.68rem !important;
    line-height: 1.2;
}

#inventario-mp-table tr:hover {
    background: rgba(59, 130, 246, 0.06);
}

#inventario-mp-table .inv-mp-empty-cell {
    padding: 28px 12px;
    text-align: center;
    color: #94a3b8;
}

#inv-mp-tabs {
    display: none !important;
}

/* La toolbar de Inventario MP usa el patron .ho-toolbar de Historico OC (ver HTML). */

.inv-mp-view-btn {
    min-height: 30px;
    padding: 0 12px;
    border: 1px solid var(--pv-card-border);
    border-radius: 0.45rem;
    background: var(--pv-card-surface-solid);
    color: var(--pv-text-secondary);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.78rem;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.inv-mp-view-btn.active {
    border-color: var(--pv-accent);
    background: rgba(59, 130, 246, 0.16);
    color: #93c5fd;
}

.inv-mp-view-count {
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    color: #cbd5e1;
    font-size: 0.68rem;
}

.inv-mp-filter {
    position: relative;
}

.inv-mp-filter-btn {
    min-height: 30px;
    padding: 0 12px;
    border: 1px solid var(--pv-card-border);
    border-radius: 0.45rem;
    background: var(--pv-card-surface-solid);
    color: var(--pv-text-primary);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
}

.inv-mp-filter-btn:hover {
    border-color: rgba(96, 165, 250, 0.42);
    background: rgba(59, 130, 246, 0.12);
}

.inv-mp-filter-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.inv-mp-filter-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 12;
    min-width: 190px;
    padding: 8px;
    border: 1px solid rgba(51, 65, 85, 0.8);
    border-radius: 8px;
    background: #0f172a;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.36);
}

.inv-mp-filter-menu.open {
    display: grid;
    gap: 4px;
}

.inv-mp-filter-option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 28px;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--pv-text-secondary);
    font-size: 0.74rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.inv-mp-filter-option:hover {
    background: rgba(148, 163, 184, 0.08);
    color: var(--pv-text-primary);
}

.inv-mp-filter-option input {
    width: 14px;
    height: 14px;
    accent-color: var(--pv-accent);
}

/* La toolbar (patron ho-*) envuelve cuando el espacio es estrecho, en vez de desbordar */
#inv-mp-ho-toolbar {
    flex-wrap: wrap;
    row-gap: 8px;
}

#sub-inventarios-mp .ho-table-container {
    overflow-x: hidden;
    max-height: calc(100vh - 142px);
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.inv-mp-parent-row {
    background: rgba(18, 24, 40, 0.55);
    cursor: pointer;
}

.inv-mp-parent-row .ho-td {
    padding-top: 7px;
    padding-bottom: 7px;
    background: rgba(18, 24, 40, 0.55);
}

.inv-mp-parent-row:hover {
    background: rgba(59, 130, 246, 0.07) !important;
}

.inv-mp-parent-row:hover .ho-td {
    background: rgba(59, 130, 246, 0.07);
}

.inv-mp-child-row {
    background: rgba(10, 14, 26, 0.5);
    cursor: pointer;
}

.inv-mp-child-row .ho-td {
    padding-top: 5px;
    padding-bottom: 5px;
    background: rgba(10, 14, 26, 0.5);
}

.inv-mp-child-row:hover {
    background: rgba(59, 130, 246, 0.06) !important;
}

.inv-mp-child-row:hover .ho-td {
    background: rgba(59, 130, 246, 0.06);
}

.inv-mp-child-row .ho-td:first-child {
    border-left: 3px solid rgba(59, 130, 246, 0.45);
}

.inv-mp-group-arrow {
    display: inline-flex;
    width: 14px;
    color: var(--pv-accent);
    font-weight: 800;
    font-size: 0.68rem;
    line-height: 1;
}

.inv-mp-material-main {
    color: var(--pv-text-primary);
    font-weight: 600;
    font-size: 0.78rem;
    line-height: 1.18;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inv-mp-material-meta {
    min-height: 0;
    margin-top: 2px;
    line-height: 1.1;
}

.inv-mp-provider {
    margin-top: 2px;
    color: #94a3b8;
    font-size: 0.64rem;
    font-weight: 500;
    line-height: 1.15;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inv-mp-negative-pill {
    display: inline-flex;
    align-items: center;
    padding: 1px 6px;
    border-radius: 999px;
    border: 1px solid rgba(239, 68, 68, 0.38);
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
    font-size: 0.62rem;
    font-weight: 700;
}

.inv-mp-lot-warning {
    margin-top: 2px;
    color: #f87171;
    font-size: 0.62rem;
    font-weight: 700;
}

.inv-mp-adjust-btn {
    width: 26px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid var(--pv-accent);
    border-radius: 6px;
    color: #93c5fd;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.inv-mp-adjust-btn .material-symbols-outlined {
    font-size: 15px;
    line-height: 1;
}

.inv-mp-adjust-btn:hover {
    background: rgba(59, 130, 246, 0.28);
}

.inv-mp-adjust-btn.danger {
    background: rgba(239, 68, 68, 0.16);
    border-color: #ef4444;
    color: #fca5a5;
}

.inv-mp-adjust-btn.danger:hover {
    background: rgba(239, 68, 68, 0.28);
}

.inv-mp-tag {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: var(--pv-text-xs);
}

/* Tag de acento (antes morado, ahora azul del sistema) */
.inv-mp-tag-purple {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
}

.inv-mp-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    font-size: var(--pv-text-sm);
    font-weight: 700;
}

.inv-mp-icon-blue {
    color: #60a5fa;
}

.inv-mp-icon-red {
    color: #f87171;
}

/* Inventory Status Colors */
.inv-positive {
    color: var(--pv-green);
    font-weight: 600;
}

.inv-negative {
    color: #ef4444;
    font-weight: 700;
}

.inv-zero {
    color: var(--pv-text-secondary);
}

/* Detail Drawer - right-anchored slide-in */
#inv-mp-detail-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: min(1100px, calc(100vw - 220px));
    height: 100vh;
    background: var(--pv-card-surface-solid);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.6);
    z-index: 3000;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#inv-mp-detail-drawer.active {
    transform: translateX(0);
}

#inv-mp-detail-drawer .drawer-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#inv-mp-entradas-table th,
#inv-mp-entradas-table td,
#inv-mp-salidas-table th,
#inv-mp-salidas-table td,
#inv-mp-ajustes-table th,
#inv-mp-ajustes-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--pv-card-border);
}

#inv-mp-entradas-table tr:hover,
#inv-mp-salidas-table tr:hover,
#inv-mp-ajustes-table tr:hover {
    background: rgba(59, 130, 246, 0.06);
}

/* Drawer table header cells */
.drawer-th {
    padding: 8px 12px;
    text-align: left;
    color: var(--pv-text-secondary);
    font-weight: 500;
    font-size: var(--pv-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.drawer-th-right {
    padding: 8px 12px;
    text-align: right;
    color: var(--pv-text-secondary);
    font-weight: 500;
    font-size: var(--pv-text-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Drawer section container */
.drawer-section {
    background: var(--pv-card-surface-solid);
    border-radius: 12px;
    overflow: hidden;
}

.drawer-section-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-section-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.drawer-section-title {
    margin: 0;
    font-size: var(--pv-text-base);
    font-weight: 600;
}

.inv-mp-reg-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(2, 6, 23, 0.74);
}

.inv-mp-reg-dialog {
    width: min(1080px, 96vw);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--pv-card-surface-solid);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.inv-mp-reg-header,
.inv-mp-reg-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--pv-card-border);
}

.inv-mp-reg-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--pv-card-border);
    border-bottom: 0;
}

.inv-mp-reg-eyebrow {
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.inv-mp-reg-header h3 {
    margin: 4px 0 0;
    color: var(--pv-text-primary);
    font-size: var(--pv-text-lg);
}

.inv-mp-reg-subtitle {
    margin-top: 4px;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-sm);
}

.inv-mp-reg-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--pv-text-secondary);
    cursor: pointer;
}

.inv-mp-reg-body {
    padding: 16px 18px;
    overflow: auto;
}

.inv-mp-reg-mode-tabs {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    width: min(560px, 100%);
    margin-bottom: 14px;
    padding: 4px;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius, 10px);
    background: var(--pv-bg-base);
}

.inv-mp-reg-mode-tab {
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-sm);
    font-weight: 800;
    cursor: pointer;
    transition: color var(--pv-duration-fast, 150ms) var(--pv-ease-out, ease),
        border-color var(--pv-duration-fast, 150ms) var(--pv-ease-out, ease),
        background var(--pv-duration-fast, 150ms) var(--pv-ease-out, ease);
}

.inv-mp-reg-mode-tab:hover,
.inv-mp-reg-mode-tab:focus-visible {
    color: var(--pv-text-primary);
    outline: none;
}

.inv-mp-reg-mode-tab.is-active {
    border-color: var(--pv-accent);
    background: var(--pv-accent-soft, rgba(59, 130, 246, 0.16));
    color: var(--pv-text-primary);
}

.inv-mp-reg-mode-panel[hidden],
.inv-mp-reg-footer-actions[hidden] {
    display: none;
}

.inv-mp-reg-footer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.inv-mp-alloc-validation-hint {
    max-width: 360px;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 700;
    line-height: 1.35;
}

.inv-mp-reg-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.inv-mp-reg-summary>div {
    padding: 11px 12px;
    background: rgba(15, 23, 42, 0.66);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 8px;
}

.inv-mp-reg-summary span {
    display: block;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 800;
    text-transform: uppercase;
}

.inv-mp-reg-summary strong {
    display: block;
    margin-top: 4px;
    color: var(--pv-text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--pv-text-base);
}

.inv-mp-reg-material-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.inv-mp-reg-material-summary small { display: block; margin-top: 7px; color: var(--pv-text-secondary); font-size: var(--pv-text-xs); line-height: 1.45; }
.inv-mp-reg-material-summary strong { font-size: var(--pv-text-lg); overflow-wrap: anywhere; }
.inv-mp-reg-summary-link { padding: 0; margin-top: 8px; border: 0; background: none; color: var(--pv-accent); font: inherit; font-size: var(--pv-text-xs); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.inv-mp-reg-material-status { margin: 0 0 12px; color: var(--pv-text-secondary); font-size: var(--pv-text-sm); line-height: 1.5; }
.inv-mp-reg-material-status.is-warning { color: #fde68a; }
.inv-mp-reg-material-status .inv-mp-reg-summary-link { margin: 0 0 0 8px; }
.inv-mp-reg-material-status[hidden], .inv-mp-reg-adjustment-details[hidden] { display: none; }
.inv-mp-reg-adjustment-details { margin-bottom: 12px; }
.inv-mp-reg-adjustment-details > summary { cursor: pointer; color: var(--pv-text-secondary); font-size: var(--pv-text-sm); margin-bottom: 8px; }

.inv-mp-reg-warnings {
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(251, 191, 36, 0.28);
    border-radius: 8px;
    background: rgba(113, 63, 18, 0.14);
    color: #fde68a;
    font-size: var(--pv-text-sm);
}

.inv-mp-reg-warnings div+div {
    margin-top: 5px;
}

.inv-mp-alloc-intro {
    margin-bottom: 12px;
    padding: 11px 12px;
    border: 1px solid var(--pv-card-border);
    border-left: 3px solid var(--pv-amber, #f59e0b);
    border-radius: 8px;
    background: var(--pv-bg-base);
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-sm);
    line-height: 1.55;
}

.inv-mp-alloc-intro strong,
.inv-mp-alloc-intro b {
    color: var(--pv-text-primary);
}

.inv-mp-alloc-plan-row {
    display: grid;
    grid-template-columns: auto minmax(240px, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.inv-mp-alloc-plan-row label {
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-sm);
    font-weight: 800;
}

.inv-mp-alloc-summary[hidden],
.inv-mp-alloc-impact-summary[hidden],
.inv-mp-alloc-bulk-tools[hidden],
.inv-mp-alloc-state[hidden],
.inv-mp-alloc-table-wrap[hidden],
#mp-alloc-form[hidden],
#mp-alloc-stock-action[hidden],
.inv-mp-alloc-preview[hidden],
#mp-alloc-warnings[hidden] {
    display: none;
}

.inv-mp-alloc-impact-summary {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    margin: -2px 0 12px;
    padding: 9px;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
    background: var(--pv-bg-base);
}

.inv-mp-alloc-impact-summary>div {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.inv-mp-alloc-impact-summary span {
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 800;
    text-transform: uppercase;
}

.inv-mp-alloc-impact-summary strong {
    overflow: hidden;
    color: var(--pv-text-primary);
    font-family: 'JetBrains Mono', monospace;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inv-mp-alloc-bulk-tools {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    padding: 8px 10px;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
    background: var(--pv-bg-base);
}

.inv-mp-alloc-check-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--pv-text-primary);
    font-size: var(--pv-text-sm);
    font-weight: 700;
    cursor: pointer;
}

.inv-mp-alloc-check-label input,
.mp-alloc-select {
    accent-color: var(--pv-accent);
}

.inv-mp-alloc-selected-count {
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 700;
}

.inv-mp-alloc-bulk-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.inv-mp-alloc-state {
    padding: 28px 16px;
    border: 1px dashed var(--pv-card-border);
    border-radius: 8px;
    color: var(--pv-text-secondary);
    text-align: center;
    font-size: var(--pv-text-sm);
}

.inv-mp-reg-table-wrap.inv-mp-alloc-table-wrap {
    max-height: none;
}

.inv-mp-alloc-table {
    min-width: 880px;
}
.inv-mp-alloc-table td { vertical-align: top; }
.inv-mp-alloc-impact-summary.is-summary-only { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.inv-mp-alloc-impact-summary.is-summary-only .inv-mp-alloc-change-metric { display: none; }
.inv-mp-alloc-summary .inv-mp-alloc-equation { grid-column: 1 / -1; color: var(--pv-text-secondary); font-size: var(--pv-text-xs); }

.inv-mp-alloc-overview {
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
    background: var(--pv-bg-base);
    color: var(--pv-text-primary);
}

.inv-mp-alloc-overview[hidden] { display: none; }
.inv-mp-alloc-overview p { margin: 7px 0; font-size: var(--pv-text-sm); color: var(--pv-text-secondary); }
.inv-mp-alloc-overview-scroll { overflow: auto; max-height: 240px; }
.inv-mp-alloc-overview table { min-width: 650px; }
.inv-mp-alloc-overview small, .inv-mp-alloc-segments small, .inv-mp-alloc-edit-cell small { display: block; color: var(--pv-text-secondary); white-space: normal; margin: 4px 0; }
.inv-mp-alloc-overview .is-selected { background: var(--pv-accent-soft, rgba(59, 130, 246, 0.08)); }
.inv-mp-alloc-segments { margin-top: 8px; font-size: var(--pv-text-xs); white-space: normal; }
.inv-mp-alloc-segments summary { cursor: pointer; color: var(--pv-accent); }
.inv-mp-alloc-segments div { padding: 6px 0; border-bottom: 1px solid var(--pv-card-border); }
.inv-mp-alloc-edit-cell { min-width: 160px; }
.inv-mp-alloc-classification-note { display: block; margin-top: 6px; color: var(--pv-amber, #f59e0b); white-space: normal; }
.inv-mp-alloc-edit-cell .inv-mp-alloc-row-actions { margin-top: 6px; }
.inv-mp-alloc-summary { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.inv-mp-alloc-lot-editor-row > td { padding: 0 12px 16px; }
.inv-mp-alloc-lot-editor { border: 1px solid var(--pv-accent); border-radius: 8px; padding: 12px; background: var(--pv-bg-base); white-space: normal; }
.inv-mp-alloc-lot-heading { display: grid; gap: 5px; margin-bottom: 10px; }
.inv-mp-alloc-lot-editor small { display: block; font-size: var(--pv-text-xs); color: var(--pv-text-secondary); margin-top: 4px; white-space: normal; }
.inv-mp-alloc-lot-editor .inv-mp-alloc-overview-scroll { max-height: none; }
.inv-mp-alloc-lot-table { min-width: 650px; }
.inv-mp-alloc-lot-table input { min-width: 150px; }
.inv-mp-alloc-lot-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 16px; margin-top: 12px; font-size: var(--pv-text-sm); }
.inv-mp-alloc-lot-actions .inv-mp-reg-summary-link { margin-top: 0; }
.inv-mp-alloc-lot-validation { color: #fbbf24; font-size: var(--pv-text-sm); margin: 10px 0 0; }
.inv-mp-alloc-lot-validation.is-valid { color: #86efac; }

.inv-mp-alloc-table tbody tr.is-changed {
    background: var(--pv-accent-soft, rgba(59, 130, 246, 0.08));
}

.inv-mp-alloc-table tbody tr.is-selected {
    box-shadow: inset 3px 0 0 var(--pv-accent);
}

.inv-mp-alloc-check-col {
    width: 36px;
    text-align: center;
}

.inv-mp-alloc-product {
    display: grid;
    gap: 3px;
    min-width: 190px;
}

.inv-mp-alloc-product strong {
    color: var(--pv-text-primary);
    font-size: var(--pv-text-sm);
}

.inv-mp-alloc-product span {
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
}

.inv-mp-alloc-qty {
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
}

.inv-mp-alloc-purchase-badge {
    display: block;
    width: fit-content;
    margin: 3px 0 0 auto;
    padding: 2px 5px;
    border-radius: 4px;
    background: var(--pv-amber-soft, rgba(245, 158, 11, 0.1));
    color: var(--pv-amber, #f59e0b);
    font-family: inherit;
    font-size: var(--pv-text-xs);
    font-weight: 800;
}

.inv-mp-alloc-status-detail {
    display: block;
    margin-top: 4px;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    white-space: nowrap;
}

.mp-alloc-target {
    min-width: 125px;
}

.mp-alloc-target[aria-invalid="true"] {
    border-color: var(--pv-red);
    box-shadow: 0 0 0 2px var(--pv-red-soft, rgba(239, 68, 68, 0.12));
}

.inv-mp-alloc-row-actions {
    display: flex;
    gap: 6px;
    white-space: nowrap;
}

.inv-mp-alloc-row-actions button {
    min-height: 28px;
    padding: 0 8px;
    border: 1px solid var(--pv-card-border);
    border-radius: 6px;
    background: transparent;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 800;
    cursor: pointer;
}

.inv-mp-alloc-row-actions button:hover,
.inv-mp-alloc-row-actions button:focus-visible {
    border-color: var(--pv-accent);
    color: var(--pv-text-primary);
    outline: none;
}

.inv-mp-alloc-row-actions button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.inv-mp-alloc-stock-action {
    min-inline-size: 0;
    margin: 12px 0 0;
    padding: 12px;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
    background: var(--pv-bg-base);
}

.inv-mp-alloc-stock-action legend {
    padding: 0 5px;
    color: var(--pv-text-primary);
    font-size: var(--pv-text-sm);
    font-weight: 800;
}

.inv-mp-alloc-stock-action>p {
    margin: 0 0 10px;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
}

.inv-mp-alloc-stock-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.inv-mp-alloc-stock-option {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px;
    padding: 11px;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
    background: var(--pv-card-surface);
    cursor: pointer;
    transition: border-color var(--pv-duration-fast) var(--pv-ease-out),
        background var(--pv-duration-fast) var(--pv-ease-out);
}

.inv-mp-alloc-stock-option:hover,
.inv-mp-alloc-stock-option:focus-within,
.inv-mp-alloc-stock-option:has(input:checked) {
    border-color: var(--pv-accent);
    background: var(--pv-accent-soft);
}

.inv-mp-alloc-stock-option:focus-within {
    outline: 2px solid var(--pv-accent);
    outline-offset: 2px;
}

.inv-mp-alloc-stock-option input {
    margin-top: 2px;
    accent-color: var(--pv-accent);
}

.inv-mp-alloc-stock-option span {
    display: grid;
    gap: 4px;
}

.inv-mp-alloc-stock-option strong {
    color: var(--pv-text-primary);
    font-size: var(--pv-text-sm);
}

.inv-mp-alloc-stock-option small {
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    line-height: 1.45;
}

.inv-mp-alloc-preview {
    display: grid;
    gap: 8px;
    margin-top: 12px;
    padding: 12px;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
    background: var(--pv-bg-base);
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-sm);
}

.inv-mp-alloc-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.inv-mp-alloc-preview-result {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--pv-card-border);
    border-radius: var(--pv-input-radius);
    background: var(--pv-card-surface);
}

.inv-mp-alloc-preview-grid>div,
.inv-mp-alloc-preview-result>div {
    display: grid;
    gap: 3px;
}

.inv-mp-alloc-preview-grid span,
.inv-mp-alloc-preview-result span,
.inv-mp-alloc-preview-action>span {
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
    font-weight: 800;
    text-transform: uppercase;
}

.inv-mp-alloc-preview-grid strong,
.inv-mp-alloc-preview-result strong {
    color: var(--pv-text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.inv-mp-alloc-preview-action {
    display: grid;
    gap: 4px;
    padding: 10px;
    border-left: 3px solid var(--pv-accent);
    background: var(--pv-accent-soft);
}

.inv-mp-alloc-preview-action strong {
    color: var(--pv-text-primary);
}

.inv-mp-alloc-preview-action small {
    color: var(--pv-text-secondary);
    line-height: 1.45;
}

.inv-mp-alloc-confirmation {
    display: grid;
    gap: 8px;
    text-align: left;
}

.inv-mp-alloc-preview-impact {
    padding: 9px 10px;
    border-left: 3px solid var(--pv-amber, #f59e0b);
    background: var(--pv-amber-soft, rgba(245, 158, 11, 0.1));
    color: var(--pv-text-primary);
}

.inv-mp-alloc-preview-warning {
    color: var(--pv-amber, #f59e0b);
}

.inv-mp-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.inv-mp-reg-add-row,
.inv-mp-reg-form-row {
    display: grid;
    grid-template-columns: 0.85fr auto 1.1fr 0.75fr auto;
    gap: 10px;
    margin-bottom: 12px;
}

.inv-mp-reg-form-row {
    grid-template-columns: 1fr 1fr;
    margin-top: 12px;
    margin-bottom: 0;
}

.inv-mp-reg-form-row label {
    display: grid;
    gap: 5px;
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-sm);
    font-weight: 700;
}

.inv-mp-reg-input {
    min-height: 34px;
    width: 100%;
    padding: 0 10px;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
    background: #0f172a;
    color: var(--pv-text-primary);
    outline: none;
}

.inv-mp-reg-input:focus {
    border-color: var(--pv-accent);
}

.inv-mp-reg-table-wrap {
    max-height: 360px;
    overflow: auto;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
}

.inv-mp-reg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--pv-text-sm);
}

.inv-mp-reg-table th,
.inv-mp-reg-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--pv-card-border);
}

.inv-mp-reg-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #111827;
    color: var(--pv-text-secondary);
    text-align: left;
    text-transform: uppercase;
    font-size: var(--pv-text-xs);
    font-weight: 800;
}

.inv-mp-reg-status {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 8px;
    border-radius: 4px;
    background: rgba(148, 163, 184, 0.12);
    color: #cbd5e1;
    font-size: var(--pv-text-xs);
    font-weight: 700;
}

.inv-mp-reg-status.warn {
    background: rgba(251, 191, 36, 0.14);
    color: #fde68a;
}

.inv-mp-reg-status.danger {
    background: rgba(239, 68, 68, 0.14);
    color: #fca5a5;
}

.inv-mp-reg-primary-btn,
.inv-mp-reg-secondary-btn,
.inv-mp-reg-auto-btn,
.inv-mp-reg-danger-btn {
    min-height: 34px;
    padding: 0 14px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
}

.inv-mp-reg-primary-btn {
    border: 1px solid rgba(59, 130, 246, 0.5);
    background: rgba(59, 130, 246, 0.18);
    color: #bfdbfe;
}

.inv-mp-reg-secondary-btn {
    border: 1px solid var(--pv-card-border);
    background: rgba(148, 163, 184, 0.08);
    color: var(--pv-text-secondary);
}

.inv-mp-reg-auto-btn {
    border: 1px solid rgba(59, 130, 246, 0.45);
    background: rgba(59, 130, 246, 0.14);
    color: #bfdbfe;
    white-space: nowrap;
}

.inv-mp-reg-danger-btn {
    border: 1px solid rgba(34, 197, 94, 0.46);
    background: rgba(34, 197, 94, 0.16);
    color: #bbf7d0;
}

.inv-mp-reg-danger-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.inv-mp-reg-primary-btn:disabled,
.inv-mp-reg-secondary-btn:disabled,
.inv-mp-reg-auto-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

@media (max-width: 900px) {
    .inv-mp-reg-summary,
    .inv-mp-reg-add-row,
    .inv-mp-reg-form-row,
    .inv-mp-alloc-plan-row,
    .inv-mp-alloc-impact-summary,
    .inv-mp-alloc-stock-options,
    .inv-mp-alloc-preview-grid,
    .inv-mp-alloc-preview-result {
        grid-template-columns: 1fr;
    }

    .inv-mp-reg-mode-tabs {
        display: grid;
        width: 100%;
    }

    .inv-mp-alloc-bulk-tools {
        align-items: stretch;
        flex-direction: column;
    }

    .inv-mp-alloc-bulk-actions {
        display: grid;
        grid-template-columns: 1fr;
        margin-left: 0;
    }

    .inv-mp-reg-footer {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .inv-mp-reg-footer-actions {
        display: grid;
        flex: 1 1 100%;
        grid-template-columns: 1fr;
    }
}

/* ════════════════════════════════════════════════════════════════
   Mejoras UX/responsivas: colapso de agotados, paleta calmada por
   columna y comportamiento responsivo de la tabla. (solo presentacion)
   ════════════════════════════════════════════════════════════════ */

/* Encabezados: tinte sutil que comunica la categoria sin saturar el cuerpo */
#inventario-mp-table th.mp-col-maquila { color: #5fb89a; }
#inventario-mp-table th.mp-col-transito { color: #d3a05f; }
#inventario-mp-table th.mp-col-reservado { color: #8aa6d8; }
#inventario-mp-table th.mp-col-valor { color: #cdb06a; }
#inventario-mp-table th.mp-col-disp { color: var(--pv-accent); }

/* Datos de columnas secundarias en tono neutro: la tabla se lee tranquila.
   Inventario y Disp. Programar conservan su color semantico (no se tocan). */
#inventario-mp-table td.mp-col-maquila,
#inventario-mp-table td.mp-col-transito,
#inventario-mp-table td.mp-col-reservado { color: var(--pv-text-secondary); }
#inventario-mp-table td.mp-col-valor { color: var(--pv-text-primary); font-weight: 500; }

.mp-na { color: var(--pv-text-secondary); opacity: 0.4; }

/* Resumen de lotes en la fila padre: verde = positivos, rojo = negativos */
.inv-mp-lote-summary { white-space: nowrap; }

.inv-mp-lot-count {
    color: var(--pv-text-primary);
    font-weight: 700;
    font-size: 0.68rem;
    line-height: 1.15;
}

.inv-mp-lot-breakdown {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    margin-top: 0;
}

.inv-mp-lot-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 17px;
    padding: 0 5px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.64rem;
    font-weight: 600;
    line-height: 1;
}

.inv-mp-lot-chip.pos { background: rgba(34, 197, 94, 0.12); color: #86efac; border-color: rgba(34, 197, 94, 0.28); }
.inv-mp-lot-chip.neg { background: rgba(239, 68, 68, 0.12); color: #fca5a5; border-color: rgba(239, 68, 68, 0.30); }
.inv-mp-lot-chip.zero { background: rgba(148, 163, 184, 0.11); color: #cbd5e1; border-color: rgba(148, 163, 184, 0.24); }

/* ── Responsivo ── */
.inv-mp-count-controls {
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--pv-card-border);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.4);
}

.inv-mp-count-toolbar {
    display: flex;
    align-items: end;
    flex-wrap: wrap;
    gap: 14px 20px;
}

.inv-mp-count-toolbar label {
    display: grid;
    gap: 7px;
    font-size: var(--pv-text-sm);
    color: var(--pv-text-primary);
    font-weight: 700;
}

.inv-mp-count-toolbar input { width: 250px; max-width: 100%; }
.inv-mp-count-recorded { display: grid; gap: 9px; color: var(--pv-text-secondary); font-size: var(--pv-text-xs); padding-bottom: 8px; }
.inv-mp-count-recorded strong { color: var(--pv-text-primary); font-size: var(--pv-text-sm); font-variant-numeric: tabular-nums; }
.inv-mp-count-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.inv-mp-count-balance { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 12px; font-size: var(--pv-text-sm); }
#mp-count-validation { color: #fbbf24; }
#mp-count-validation.is-valid { color: #86efac; }
.inv-mp-count-note, .inv-mp-count-warning { margin: 10px 0 0; font-size: var(--pv-text-xs); line-height: 1.5; color: var(--pv-text-secondary); }
.inv-mp-count-warning { color: #fbbf24; }
.inv-mp-count-table { min-width: 640px; table-layout: fixed; }
.inv-mp-count-table th:nth-child(1) { width: 38%; }
.inv-mp-count-table th:nth-child(2) { width: 18%; }
.inv-mp-count-table th:nth-child(3) { width: 20%; }
.inv-mp-count-table th:nth-child(4) { width: 24%; }
.inv-mp-count-table td { vertical-align: middle; }
.inv-mp-count-table td:first-child { min-width: 0; }
.inv-mp-count-table td strong { display: block; line-height: 1.4; }
.inv-mp-count-table td small { display: block; color: var(--pv-text-secondary); line-height: 1.4; margin-top: 3px; }
.inv-mp-count-table .mp-count-lot-input { width: 100%; min-width: 100px; font-variant-numeric: tabular-nums; }
.inv-mp-count-table .mp-count-fill { padding: 3px 0; margin-top: 3px; border: 0; background: transparent; color: #93c5fd; cursor: pointer; font-size: var(--pv-text-xs); }
.inv-mp-count-table .mp-count-add-lot { display: block; width: auto; max-width: 100%; min-height: 26px; margin-top: 5px; padding: 2px 5px; font-size: var(--pv-text-xs); color: #93c5fd; background: transparent; border-color: transparent; }

@media (max-width: 1100px) {
    /* En pantallas medianas ocultamos columnas secundarias; el detalle por lote
       sigue disponible al abrir el drawer. Quedan las columnas clave. */
    #inventario-mp-table .mp-col-secondary { display: none; }
}

@media (max-width: 720px) {
    #inv-mp-ho-toolbar .ho-toolbar-left,
    #inv-mp-ho-toolbar .ho-toolbar-right { flex-wrap: wrap; }
    #inv-mp-ho-toolbar .ho-search-input { min-width: 0; }
}

/* ════════════════════════════════════════════════════════════════
   Congruencia estructural con Historico OC: seccion plana (sin la
   tarjeta envolvente) y banner de formula discreto.
   ════════════════════════════════════════════════════════════════ */

/* La seccion MP va plana, igual que Historico OC e Inventario PT */
#sub-inventarios-mp > .card {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0;
}

/* Banner de formula -> linea discreta (Historico OC no usa banners llamativos) */
.inv-mp-formula-hint {
    margin-bottom: 10px;
    padding: 6px 12px;
    border-left: 2px solid var(--pv-accent);
    border-radius: 4px;
    background: rgba(59, 130, 246, 0.06);
    color: var(--pv-text-secondary);
    font-size: var(--pv-text-xs);
}

.inv-mp-formula-hint strong {
    color: var(--pv-text-primary);
    font-weight: 600;
}
