/* =====================================================================
   Análisis MP → PT
   ===================================================================== */

.ampt-kpi {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #cbd5e1;
    border-radius: 8px;
    padding: .75rem .9rem;
    height: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.ampt-kpi-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #64748b;
    margin-bottom: .25rem;
}
.ampt-kpi-value {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.4rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.1;
}
.ampt-kpi-sub {
    font-size: .7rem;
    color: #94a3b8;
    margin-top: .25rem;
}
.ampt-kpi-mp      { border-left-color: #4f46e5; }
.ampt-kpi-consumo { border-left-color: #0ea5e9; }
.ampt-kpi-delta   { border-left-color: #f59e0b; }
.ampt-kpi-eff     { border-left-color: #10b981; }

.ampt-kpi-value-positive { color: #16a34a; }
.ampt-kpi-value-negative { color: #dc2626; }
.ampt-kpi-value-warn     { color: #f59e0b; }

/* =====================================================================
   Desglose del consumo — barras horizontales con tabla alineada
   ===================================================================== */
.ampt-desglose {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.ampt-desglose-row {
    display: grid;
    grid-template-columns: 180px 1fr 200px 80px;
    column-gap: 1.25rem;
    align-items: center;
    padding: .75rem .5rem;
    border-bottom: 1px solid #f1f5f9;
    transition: background .15s ease;
}
.ampt-desglose-row:not(.ampt-desglose-total):hover {
    background: #fafafa;
}
.ampt-desglose-row:last-child { border-bottom: none; }

/* Label con icono pegado al texto */
.ampt-desglose-label {
    font-weight: 600;
    color: #1e293b;
    font-size: .95rem;
    display: flex;
    align-items: center;
    gap: .35rem;
    white-space: nowrap;
}
.ampt-desglose-label i { font-size: 1.05rem; }

/* Barra con altura más prominente */
.ampt-bar-track {
    background: #f1f5f9;
    border-radius: 999px;
    height: 22px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
.ampt-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width .4s cubic-bezier(.4,0,.2,1);
    min-width: 4px;  /* siempre visible aunque sea 0.01% */
}
.ampt-bar-fill-primera  { background: linear-gradient(90deg, #4f46e5 0%, #6366f1 100%); }
.ampt-bar-fill-segunda  { background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%); }
.ampt-bar-fill-chatarra { background: linear-gradient(90deg, #dc2626 0%, #ef4444 100%); }

/* Valor numérico: peso ton + sub-info en líneas separadas, todo alineado a la derecha */
.ampt-desglose-value {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}
.ampt-desglose-value-main {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}
.ampt-desglose-value-main small {
    font-size: .65rem;
    font-weight: 500;
    color: #94a3b8;
    margin-left: .25rem;
}
.ampt-desglose-value-sub {
    font-size: .72rem;
    color: #94a3b8;
    margin-top: .15rem;
    white-space: nowrap;
}

/* % a la derecha — sin grilla extra */
.ampt-desglose-pct {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: #64748b;
    font-size: .95rem;
}

/* ─── Fila TOTAL destacada ─── */
.ampt-desglose-row.ampt-desglose-total {
    margin-top: .5rem;
    padding: 1rem .5rem;
    border-top: 2px solid #16a34a;
    border-bottom: none;
    background: linear-gradient(90deg, rgba(34,197,94,.08), rgba(22,163,74,.12));
    border-radius: 0 0 8px 8px;
}
.ampt-desglose-row.ampt-desglose-total:hover { background: linear-gradient(90deg, rgba(34,197,94,.08), rgba(22,163,74,.12)); }
.ampt-desglose-row.ampt-desglose-total .ampt-desglose-label {
    color: #166534;
    font-size: 1.05rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.ampt-desglose-row.ampt-desglose-total .ampt-desglose-value-main {
    color: #166534;
    font-size: 1.2rem;
}
.ampt-desglose-row.ampt-desglose-total .ampt-desglose-value-main small {
    color: #16a34a;
    font-weight: 600;
}
.ampt-desglose-row.ampt-desglose-total .ampt-desglose-pct {
    color: #166534;
    font-weight: 800;
    font-size: 1.05rem;
}
.ampt-desglose-row.ampt-desglose-total .ampt-bar-fill {
    background: linear-gradient(90deg, #16a34a 0%, #22c55e 100%);
    box-shadow: 0 2px 4px rgba(22,163,74,.3);
}

/* Fórmula MP usado (Saldo inicial + Entradas - Saldo final - Dañadas) */
.ampt-formula {
    display: flex;
    flex-direction: column;
    gap: .25rem;
}
.ampt-formula-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .35rem .5rem;
    border-bottom: 1px dashed #f1f5f9;
    font-size: .95rem;
}
.ampt-formula-row:last-child { border-bottom: none; }
.ampt-formula-op {
    font-weight: 500;
    color: #475569;
}
.ampt-formula-val {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: #1e293b;
}
.ampt-formula-val small {
    font-size: .65rem;
    color: #94a3b8;
    margin-left: .25rem;
}
.ampt-formula-row.ampt-formula-total {
    margin-top: .35rem;
    padding: .65rem .5rem;
    background: linear-gradient(90deg, rgba(79,70,229,.06), rgba(99,102,241,.1));
    border-top: 2px solid #4f46e5;
    border-bottom: none;
    border-radius: 6px;
}
.ampt-formula-row.ampt-formula-total .ampt-formula-op {
    color: #3730a3;
    font-size: 1rem;
}
.ampt-formula-row.ampt-formula-total .ampt-formula-val {
    color: #3730a3;
    font-size: 1.1rem;
}

/* Responsive: en pantallas chicas, valor + % se apilan debajo */
@media (max-width: 768px) {
    .ampt-desglose-row {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "label pct"
            "bar bar"
            "value value";
        gap: .5rem;
        padding: .75rem .25rem;
    }
    .ampt-desglose-label { grid-area: label; }
    .ampt-bar-track { grid-area: bar; }
    .ampt-desglose-value { grid-area: value; text-align: left; }
    .ampt-desglose-value-sub { text-align: left; }
    .ampt-desglose-pct { grid-area: pct; }
}

/* Origen del excedente */
.ampt-origen-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
.ampt-origen-card {
    background: #fafafa;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
}
.ampt-origen-card-title {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: .5rem;
}
.ampt-origen-card-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
}
.ampt-origen-card-pct {
    font-size: .8rem;
    color: #94a3b8;
    margin-top: .25rem;
}

/* Tablas comunes */
.ampt-table {
    width: 100%;
    font-size: .85rem;
}
.ampt-table thead th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-size: .72rem;
    text-transform: uppercase;
    color: #475569;
    letter-spacing: .03em;
    padding: .5rem .6rem;
}
.ampt-table tbody td {
    padding: .4rem .6rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}
.ampt-table tbody tr:hover { background: #fefce8; }
.ampt-num {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
}
.ampt-num-neg  { color: #dc2626; font-weight: 600; }
.ampt-num-pos  { color: #16a34a; font-weight: 600; }
.ampt-num-warn { color: #f59e0b; font-weight: 600; }

/* Tabs por dimensión */
#amptDimension .nav-tabs .nav-link { font-size: .85rem; padding: .35rem .8rem; }
#amptDimension .nav-tabs .nav-link.active { font-weight: 700; }

/* =====================================================================
   Card 'PRODUCCIÓN' estilo Despacho/Conciliación
   ===================================================================== */
.ampt-prod-card {
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.ampt-prod-header {
    font-size: .85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #991b1b;
    margin-bottom: .75rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid #fecaca;
}
.ampt-prod-header i  { color: #dc2626; }
.ampt-prod-header small {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #64748b;
    font-size: .75rem;
}
.ampt-prod-body { display: flex; flex-direction: column; gap: 0; }
.ampt-prod-row {
    display: grid;
    grid-template-columns: 1fr auto 40px;
    gap: .5rem;
    align-items: baseline;
    padding: .35rem 0;
    font-size: .9rem;
}
.ampt-prod-label {
    color: #475569;
    font-size: .85rem;
}
.ampt-prod-val {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: #1e293b;
    text-align: right;
    white-space: nowrap;
}
.ampt-prod-unit {
    font-size: .65rem;
    color: #94a3b8;
    text-align: left;
}
.ampt-prod-row.ampt-prod-total {
    margin-top: .35rem;
    padding: .65rem 0;
    border-top: 2px solid #dc2626;
    background: linear-gradient(90deg, rgba(220,38,38,.06), transparent);
}
.ampt-prod-row.ampt-prod-total .ampt-prod-label { color: #991b1b; font-size: .95rem; }
.ampt-prod-row.ampt-prod-total .ampt-prod-val   { color: #991b1b; font-size: 1.05rem; }

/* Subtotal intermedio (Destinado a venta) — azul violeta como Despacho */
.ampt-prod-row.ampt-prod-subtotal {
    margin-top: .35rem;
    padding: .5rem 0;
    border-top: 1.5px solid #4f46e5;
    background: linear-gradient(90deg, rgba(79,70,229,.05), transparent);
}
.ampt-prod-row.ampt-prod-subtotal .ampt-prod-label { color: #3730a3; font-size: .92rem; }
.ampt-prod-row.ampt-prod-subtotal .ampt-prod-val   { color: #3730a3; font-size: 1rem; }

/* Ícono de info (popover) en cada fila de la card PRODUCCIÓN */
.ampt-info-icon {
    margin-left: .35rem;
    font-size: .8rem;
    cursor: pointer;
    opacity: .55;
    transition: opacity .15s ease, transform .15s ease;
}
.ampt-info-icon:hover {
    opacity: 1;
    transform: scale(1.15);
}
.ampt-info-icon:focus {
    outline: 2px solid rgba(14,165,233,.5);
    outline-offset: 2px;
    border-radius: 50%;
    opacity: 1;
}

/* Popover personalizado: más espacio, contenido legible */
.popover {
    max-width: 360px;
    font-size: .85rem;
}
.popover-header {
    font-weight: 700;
    background: #f0f9ff;
    color: #0c4a6e;
    border-bottom: 1px solid #bae6fd;
}
.popover-body {
    line-height: 1.5;
    color: #334155;
}
.popover-body strong { color: #0c4a6e; }
.popover-body em     { color: #1e293b; font-style: italic; }

/* =====================================================================
   Spinner de carga (se muestra mientras se procesa el análisis)
   ===================================================================== */
.ampt-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    min-height: 280px;
    background: linear-gradient(180deg, #fafafa, #ffffff);
    border-radius: 8px;
    border: 1px dashed #e2e8f0;
}
.ampt-loading .spinner-border {
    animation-duration: .85s;
}
.ampt-loading.text-danger {
    border-color: rgba(220,38,38,.3);
    background: linear-gradient(180deg, #fef2f2, #ffffff);
}

/* =====================================================================
   Diagnóstico MP — fix hover Bootstrap deja texto ilegible
   =====================================================================
   Bootstrap aplica --bs-table-hover-color sobre TODO el <td>, lo cual
   vuelve invisible el texto secundario (text-muted, badge bg-light) en
   nuestras filas clickeables. Forzamos colores legibles en hover y un
   fondo amarillo suave (mismo tono que usa el módulo Despacho). */
.dmp-table {
    --bs-table-hover-bg: #fef3c7;
    --bs-table-hover-color: #1e293b;
}
.dmp-table tbody tr.dmp-row:hover {
    background-color: #fef3c7 !important;
}
.dmp-table tbody tr.dmp-row:hover td,
.dmp-table tbody tr.dmp-row:hover td * {
    color: #1e293b !important;
}
.dmp-table tbody tr.dmp-row:hover td .text-muted,
.dmp-table tbody tr.dmp-row:hover td small.text-muted,
.dmp-table tbody tr.dmp-row:hover td .text-muted * {
    color: #475569 !important;
}
.dmp-table tbody tr.dmp-row:hover td.text-danger,
.dmp-table tbody tr.dmp-row:hover td.text-danger * {
    color: #991b1b !important;
}
.dmp-table tbody tr.dmp-row:hover td.text-warning,
.dmp-table tbody tr.dmp-row:hover td.text-warning * {
    color: #92400e !important;
}
/* Badges no deben perder su contraste con hover */
.dmp-table tbody tr.dmp-row:hover .badge.bg-danger,
.dmp-table tbody tr.dmp-row:hover .badge.bg-warning,
.dmp-table tbody tr.dmp-row:hover .badge.bg-success,
.dmp-table tbody tr.dmp-row:hover .badge.bg-secondary {
    color: inherit !important;
}
.dmp-table tbody tr.dmp-row:hover .badge.bg-light {
    color: #1e293b !important;
}
.dmp-table tbody tr.dmp-row {
    transition: background-color .12s ease-out;
}

/* =====================================================================
   Sub-bloque "Etiquetas válidas emitidas en el período"
   ===================================================================== */
/* La fila Σ usa la clase ampt-desglose-total que tiene uppercase +
   letter-spacing. Como nuestro label "ETIQUETAS VÁLIDAS" es largo, la
   columna de 180px no le alcanza y la barra de relleno lo tapa.
   Le damos una clase específica con más espacio y sin uppercase. */
.ampt-desglose-row.ampt-desglose-total.ampt-etiq-total {
    grid-template-columns: 240px 1fr 200px 80px;
    border-top-color: #0891b2;
    background: linear-gradient(90deg, rgba(8,145,178,.06), rgba(6,182,212,.10));
}
.ampt-desglose-row.ampt-desglose-total.ampt-etiq-total:hover {
    background: linear-gradient(90deg, rgba(8,145,178,.06), rgba(6,182,212,.10));
}
.ampt-desglose-row.ampt-desglose-total.ampt-etiq-total .ampt-desglose-label {
    color: #155e75;
    text-transform: none;
    letter-spacing: 0;
    font-size: 1rem;
    font-weight: 700;
}
.ampt-desglose-row.ampt-desglose-total.ampt-etiq-total .ampt-desglose-value-main {
    color: #155e75;
}
.ampt-desglose-row.ampt-desglose-total.ampt-etiq-total .ampt-desglose-value-main small {
    color: #0891b2;
}
.ampt-desglose-row.ampt-desglose-total.ampt-etiq-total .ampt-desglose-pct {
    color: #155e75;
}
.ampt-desglose-row.ampt-desglose-total.ampt-etiq-total .ampt-bar-fill {
    background: linear-gradient(90deg, #0891b2 0%, #06b6d4 100%) !important;
    box-shadow: 0 2px 4px rgba(8,145,178,.3);
}

/* Filas internas del sub-bloque: alinear el grid igual de ancho que
   el Σ para que las barras queden lineares. */
.ampt-desglose-bloque-etiq .ampt-desglose-row:not(.ampt-desglose-total) {
    grid-template-columns: 240px 1fr 200px 80px;
}

/* Header del sub-bloque con icono clickeable */
.ampt-etiq-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .5rem;
    flex-wrap: wrap;
}
.ampt-etiq-header-title {
    font-size: .75rem;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .04em;
    display: flex;
    align-items: center;
    gap: .35rem;
}
.ampt-etiq-info-btn {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: #0891b2;
    padding: .15rem .5rem;
    border-radius: 6px;
    font-size: .75rem;
    cursor: pointer;
    transition: all .15s ease;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}
.ampt-etiq-info-btn:hover {
    background: #ecfeff;
    border-color: #0891b2;
    transform: translateY(-1px);
}

/* Comparación con / sin origen — chips */
.ampt-origen-comp {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .5rem;
    margin-top: .5rem;
}
.ampt-origen-card {
    border-radius: 8px;
    padding: .65rem .8rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}
.ampt-origen-card.is-con-origen {
    border-color: #86efac;
    background: linear-gradient(135deg, rgba(34,197,94,.08), rgba(34,197,94,.02));
}
.ampt-origen-card.is-sin-origen {
    border-color: #fca5a5;
    background: linear-gradient(135deg, rgba(248,113,113,.08), rgba(248,113,113,.02));
}
.ampt-origen-card-label {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #475569;
    display: flex;
    align-items: center;
    gap: .25rem;
    margin-bottom: .2rem;
}
.ampt-origen-card.is-con-origen .ampt-origen-card-label { color: #166534; }
.ampt-origen-card.is-sin-origen .ampt-origen-card-label { color: #991b1b; }
.ampt-origen-card-value {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.1;
}
.ampt-origen-card-sub {
    font-size: .72rem;
    color: #64748b;
    margin-top: .15rem;
}

@media (max-width: 768px) {
    .ampt-desglose-row.ampt-desglose-total.ampt-etiq-total,
    .ampt-desglose-bloque-etiq .ampt-desglose-row:not(.ampt-desglose-total) {
        grid-template-columns: 1fr 1fr;
    }
    .ampt-origen-comp { grid-template-columns: 1fr; }
}

/* =====================================================================
   Producción dual — cards rediseñados
   =====================================================================
   Diseño propio para el tab "Producción dual": Mass balance vs Consumo
   registrado. Reemplaza el uso de dp-rec-card (despacho) por una vista
   sectorizada con jerarquía visual clara. */
.ampt-dual-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #cbd5e1;
    border-radius: 10px;
    padding: 0;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.ampt-dual-card-mass     { border-left-color: #4f46e5; }
.ampt-dual-card-consumo  { border-left-color: #0ea5e9; }
.ampt-dual-card.is-cuadra { box-shadow: 0 1px 3px rgba(22,163,74,.18); }
.ampt-dual-card.is-warn   { box-shadow: 0 1px 3px rgba(245,158,11,.20); }
.ampt-dual-card.is-err    { box-shadow: 0 1px 3px rgba(220,38,38,.20); }

.ampt-dual-head {
    padding: .75rem 1rem;
    background: linear-gradient(180deg, #fafbff, #fff);
    border-bottom: 1px solid #eef2f7;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.ampt-dual-card-mass    .ampt-dual-head { background: linear-gradient(180deg, rgba(79,70,229,.06), #fff); }
.ampt-dual-card-consumo .ampt-dual-head { background: linear-gradient(180deg, rgba(14,165,233,.06), #fff); }
.ampt-dual-head-icon {
    width: 28px; height: 28px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    background: #eef2ff; color: #4f46e5; font-size: .9rem;
}
.ampt-dual-card-consumo .ampt-dual-head-icon { background: #e0f2fe; color: #0369a1; }
.ampt-dual-head-title {
    font-size: .82rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #1e293b;
}
.ampt-dual-head-sub {
    font-size: .7rem;
    color: #94a3b8;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

.ampt-dual-body { padding: .75rem 1rem 1rem; }

.ampt-dual-section {
    padding: .25rem 0 .5rem;
    border-bottom: 1px dashed #eef2f7;
}
.ampt-dual-section:last-child { border-bottom: none; padding-bottom: 0; }
.ampt-dual-section + .ampt-dual-section { padding-top: .5rem; }
.ampt-dual-section-label {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #94a3b8;
    margin-bottom: .15rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}

.ampt-dual-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .2rem 0;
    font-size: .88rem;
    line-height: 1.35;
}
.ampt-dual-line.is-muted { color: #94a3b8; }
.ampt-dual-line.is-muted .ampt-dual-line-val { color: #94a3b8; }
.ampt-dual-line-key {
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    min-width: 0;
}
.ampt-dual-line-key small { color: #94a3b8; font-weight: 500; }
.ampt-dual-line-val {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}
.ampt-dual-line-val small {
    font-size: .65rem;
    font-weight: 500;
    color: #94a3b8;
    margin-left: .2rem;
}

/* Líneas con operador: "+ Compras", "− Inv. final MP" — el operador se
   pinta con un chip neutro a la izquierda del texto. */
.ampt-dual-op {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: #64748b;
    margin-right: .25rem;
    font-size: .85rem;
}
.ampt-dual-op-add { color: #0891b2; }
.ampt-dual-op-sub { color: #b45309; }

/* Totales y subtotales */
.ampt-dual-total {
    margin-top: .35rem;
    padding: .55rem .65rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    background: linear-gradient(90deg, rgba(79,70,229,.07), rgba(99,102,241,.03));
    border: 1px solid rgba(79,70,229,.18);
}
.ampt-dual-total-key {
    font-weight: 800;
    font-size: .85rem;
    color: #3730a3;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.ampt-dual-total-val {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    font-size: 1.05rem;
    color: #3730a3;
}
.ampt-dual-total-val small {
    font-size: .65rem;
    color: #6366f1;
    font-weight: 600;
    margin-left: .2rem;
}

/* Variante "destinado" (subtotal después de PT) */
.ampt-dual-total.is-destinado {
    background: linear-gradient(90deg, rgba(15,118,110,.07), rgba(20,184,166,.03));
    border-color: rgba(15,118,110,.18);
}
.ampt-dual-total.is-destinado .ampt-dual-total-key,
.ampt-dual-total.is-destinado .ampt-dual-total-val { color: #0f766e; }
.ampt-dual-total.is-destinado .ampt-dual-total-val small { color: #14b8a6; }

/* Variante "consumo" para Card B */
.ampt-dual-total.is-consumo {
    background: linear-gradient(90deg, rgba(14,165,233,.10), rgba(56,189,248,.03));
    border-color: rgba(14,165,233,.22);
}
.ampt-dual-total.is-consumo .ampt-dual-total-key,
.ampt-dual-total.is-consumo .ampt-dual-total-val { color: #0369a1; }
.ampt-dual-total.is-consumo .ampt-dual-total-val small { color: #0ea5e9; }

/* Fila de comparación final (Δ vs Ventas) */
.ampt-dual-diff {
    margin-top: .35rem;
    padding: .5rem .65rem;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}
.ampt-dual-diff.is-cuadra { background: #f0fdf4; border-color: #bbf7d0; }
.ampt-dual-diff.is-warn   { background: #fffbeb; border-color: #fde68a; }
.ampt-dual-diff.is-err    { background: #fef2f2; border-color: #fecaca; }
.ampt-dual-diff-key {
    font-weight: 700;
    font-size: .82rem;
    color: #475569;
}
.ampt-dual-diff-val {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    font-size: 1rem;
}
.ampt-dual-diff.is-cuadra .ampt-dual-diff-val { color: #16a34a; }
.ampt-dual-diff.is-warn   .ampt-dual-diff-val { color: #b45309; }
.ampt-dual-diff.is-err    .ampt-dual-diff-val { color: #b91c1c; }

/* Bloque de Rem./Exced. — header con switch + radios */
.ampt-dual-aj-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .15rem 0 .3rem;
}
.ampt-dual-aj-head .form-check { min-height: auto; margin-bottom: 0; }
.ampt-dual-aj-head .form-check-input { cursor: pointer; }
.ampt-dual-aj-head-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}
.ampt-dual-aj-head.is-off .ampt-dual-aj-head-title { color: #94a3b8; }

/* Valores rem/exc con coloreado semántico (paleta bobinas) */
.ampt-dual-line-val.is-excedente { color: #16a34a; }   /* + verde: consumió más */
.ampt-dual-line-val.is-remanente { color: #b91c1c; }   /* − rojo:  sobró */
.ampt-dual-line-val.is-neutro    { color: #475569; }

/* Sub-total Neto dentro del bloque rem/exc */
.ampt-dual-aj-neto {
    margin-top: .15rem;
    padding-top: .3rem;
    border-top: 1px dotted #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: .82rem;
}
.ampt-dual-aj-neto-key { color: #475569; font-weight: 700; }
.ampt-dual-aj-neto-val {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

/* Toggle Per/Gen segmentado más compacto */
.ampt-dual-pergen .btn { padding: .1rem .45rem; font-size: .7rem; font-weight: 700; }

/* Banner explicativo arriba de los cards */
.ampt-dual-banner {
    border-radius: 10px;
    background: linear-gradient(135deg, #f0f9ff 0%, #ffffff 100%);
    border: 1px solid #bae6fd;
    padding: .65rem .85rem;
    font-size: .82rem;
    color: #0c4a6e;
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    margin-bottom: .75rem;
}
.ampt-dual-banner i { margin-top: .15rem; color: #0284c7; }
.ampt-dual-banner strong { color: #0c4a6e; }
.ampt-dual-banner em { font-style: italic; color: #155e75; }

/* Resumen comparativo abajo */
.ampt-dual-summary {
    margin-top: .85rem;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    padding: .65rem 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}
.ampt-dual-summary-item-label {
    font-size: .65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #94a3b8;
}
.ampt-dual-summary-item-val {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    font-size: 1.1rem;
    color: #1e293b;
    margin-top: .15rem;
}

@media (max-width: 768px) {
    .ampt-dual-summary { grid-template-columns: 1fr; }
}

/* =====================================================================
   Cuadre del Cierre — tab comparativo de bases de Producción vs Ventas
   ===================================================================== */
.ampt-cuadre-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    display: flex;
    flex-direction: column;
    transition: transform .15s ease, box-shadow .15s ease;
}
.ampt-cuadre-card.is-winner {
    border: 2px solid #16a34a;
    box-shadow: 0 4px 12px rgba(22,163,74,.20);
    transform: translateY(-2px);
}
.ampt-cuadre-card-head {
    padding: .65rem .9rem;
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .02em;
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
}
.ampt-cuadre-card-sub {
    padding: .35rem .9rem;
    font-size: .72rem;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #eef2f7;
    font-style: italic;
}
.ampt-cuadre-card-body { padding: .75rem .9rem 1rem; }
.ampt-cuadre-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: .25rem 0;
    font-size: .85rem;
    color: #475569;
}
.ampt-cuadre-key   { font-weight: 500; }
.ampt-cuadre-val {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: #1e293b;
    white-space: nowrap;
}
.ampt-cuadre-val small {
    font-size: .65rem;
    font-weight: 500;
    color: #94a3b8;
    margin-left: .15rem;
}
.ampt-cuadre-line-dest {
    margin-top: .35rem;
    padding: .5rem .65rem;
    border-radius: 8px;
    background: linear-gradient(90deg, rgba(15,118,110,.08), rgba(20,184,166,.02));
    border: 1px solid rgba(15,118,110,.18);
}
.ampt-cuadre-line-dest .ampt-cuadre-key,
.ampt-cuadre-line-dest .ampt-cuadre-val { color: #0f766e; font-weight: 800; font-size: .9rem; }
.ampt-cuadre-diff {
    margin-top: .4rem;
    padding: .5rem .65rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: .9rem;
}

/* Veredicto box */
.ampt-cuadre-veredicto {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid #e2e8f0;
    background: #fff;
}
.ampt-cuadre-veredicto.is-ok   { background: #f0fdf4; border-color: #86efac; }
.ampt-cuadre-veredicto.is-warn { background: #fffbeb; border-color: #fde68a; }
.ampt-cuadre-veredicto.is-err  { background: #fef2f2; border-color: #fca5a5; }
.ampt-cuadre-veredicto-icon {
    font-size: 2rem;
    flex-shrink: 0;
}
.ampt-cuadre-veredicto.is-ok   .ampt-cuadre-veredicto-icon { color: #16a34a; }
.ampt-cuadre-veredicto.is-warn .ampt-cuadre-veredicto-icon { color: #d97706; }
.ampt-cuadre-veredicto.is-err  .ampt-cuadre-veredicto-icon { color: #dc2626; }
.ampt-cuadre-veredicto-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: .15rem;
}
.ampt-cuadre-veredicto-detalle {
    font-size: .85rem;
    color: #475569;
}

/* Bloque explicativo del efecto del rezago de impresión */
.ampt-cuadre-explica {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.ampt-cuadre-explica h6 { font-size: 1rem; color: #1e293b; }
.ampt-cuadre-explica code {
    font-size: .75rem;
    background: #f1f5f9;
    color: #0f172a;
    padding: .05rem .3rem;
    border-radius: 4px;
}

/* Ejemplo con tres pasos */
.ampt-cuadre-ejemplo {
    background: linear-gradient(135deg, #eff6ff, #f8fafc);
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    padding: .85rem 1rem;
    margin: .75rem 0;
}
.ampt-cuadre-ejemplo-title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #1e40af;
    margin-bottom: .6rem;
}
.ampt-cuadre-ejemplo-flow {
    display: grid;
    grid-template-columns: 1fr auto 1fr auto 1fr;
    gap: .5rem;
    align-items: stretch;
}
.ampt-cuadre-ejemplo-paso {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .5rem .65rem;
    font-size: .78rem;
    color: #475569;
    line-height: 1.35;
}
.ampt-cuadre-paso-label {
    font-weight: 700;
    color: #0f172a;
    font-size: .8rem;
    margin-bottom: .25rem;
}
.ampt-cuadre-paso-detalle code { font-size: .68rem; }
.ampt-cuadre-ejemplo-arrow {
    align-self: center;
    color: #94a3b8;
    font-weight: 700;
    font-size: 1.1rem;
}

/* Bloque de impacto (qué pasa en cada cierre) */
.ampt-cuadre-impacto {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 6px;
    padding: .65rem .9rem;
    margin-top: .75rem;
}
.ampt-cuadre-impacto.is-after {
    background: #eff6ff;
    border-left-color: #3b82f6;
}
.ampt-cuadre-impacto-titulo {
    font-weight: 700;
    color: #92400e;
    font-size: .85rem;
    margin-bottom: .35rem;
}
.ampt-cuadre-impacto.is-after .ampt-cuadre-impacto-titulo { color: #1e40af; }
.ampt-cuadre-impacto ul { color: #475569; line-height: 1.5; }
.ampt-cuadre-impacto code {
    font-size: .72rem;
    background: rgba(0,0,0,.05);
    padding: .05rem .25rem;
    border-radius: 3px;
}

@media (max-width: 768px) {
    .ampt-cuadre-ejemplo-flow {
        grid-template-columns: 1fr;
    }
    .ampt-cuadre-ejemplo-arrow {
        transform: rotate(90deg);
        text-align: center;
    }
}

/* =====================================================================
   Verificación PP ↔ Etiqueta
   ===================================================================== */
.ampt-verif-kpi {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .65rem .75rem;
    height: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.ampt-verif-kpi-total { border-top: 3px solid #4f46e5; }
.ampt-verif-kpi-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #475569;
    display: flex;
    align-items: center;
    gap: .3rem;
    margin-bottom: .3rem;
}
.ampt-verif-kpi-label i { color: #64748b; }
.ampt-verif-kpi-value {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}
.ampt-verif-kpi-value small {
    font-size: .65rem;
    color: #94a3b8;
    font-weight: 500;
    margin-left: .15rem;
}
.ampt-verif-kpi-sub {
    font-size: .72rem;
    color: #64748b;
    margin-top: .15rem;
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
}
.ampt-verif-kpi-desc {
    font-size: .7rem;
    color: #94a3b8;
    margin-top: .25rem;
    line-height: 1.3;
}

/* Resumen de rezago en cabecera */
.ampt-verif-rezago-resumen {
    background: linear-gradient(135deg, #1e293b, #334155);
    color: #fff;
    border-radius: 10px;
    padding: .85rem 1.1rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.ampt-verif-rezago-titulo {
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #cbd5e1;
    margin-bottom: .65rem;
}
.ampt-verif-rezago-stats {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}
.ampt-verif-rezago-stats > div { display: flex; align-items: baseline; gap: .5rem; }
.ampt-verif-rezago-stats .label {
    font-size: .8rem;
    color: #94a3b8;
}
.ampt-verif-rezago-stats .value {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
}
.ampt-verif-rezago-stats .value.text-danger { color: #fca5a5 !important; }
.ampt-verif-rezago-stats .value small {
    font-size: .7rem;
    color: #cbd5e1;
    font-weight: 500;
}

/* KPIs compactos del nuevo tab unificado (Verif PP↔Etiq) */
.ampt-vf-kpi {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .55rem .75rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    height: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.ampt-vf-kpi-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}
.ampt-vf-kpi-body { flex: 1; min-width: 0; }
.ampt-vf-kpi-label {
    font-size: .7rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.ampt-vf-kpi-value {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}
.ampt-vf-kpi-sub {
    font-size: .68rem;
    color: #94a3b8;
    margin-top: .1rem;
}

/* Fila de etiqueta anulada: leve sombreado rojo */
tr.ampt-vf-row-anulada {
    background: rgba(220, 38, 38, 0.04) !important;
}
tr.ampt-vf-row-anulada:hover {
    background: rgba(220, 38, 38, 0.08) !important;
}

/* Fila externa (turno fuera del rango pero etiqueta dentro): tinte ámbar */
tr.ampt-vf-row-externa {
    background: rgba(217, 119, 6, 0.06) !important;
    border-left: 3px solid #d97706;
}
tr.ampt-vf-row-externa:hover {
    background: rgba(217, 119, 6, 0.12) !important;
}

/* Items de la columna "Producciones de origen" en el modal de historial */
.ampt-vf-origen-item {
    padding: .25rem .35rem;
    border-radius: 4px;
    font-size: .78rem;
    line-height: 1.35;
    margin-bottom: .25rem;
}
.ampt-vf-origen-item + .ampt-vf-origen-item { border-top: 1px dashed #e2e8f0; padding-top: .35rem; }
.ampt-vf-origen-item.is-current {
    background: rgba(79, 70, 229, 0.06);
    border-left: 2px solid #4f46e5;
    padding-left: .5rem;
}
.ampt-vf-origen-item .ms-3 { margin-left: 1.1rem !important; }

/* Tarjeta comparativa PP vs Etiquetas (peso calculado vs peso directo) */
.ampt-vf-compara {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    background: linear-gradient(135deg, #fafbff 0%, #ffffff 100%);
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.1rem 1.4rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.ampt-vf-compara-col {
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.ampt-vf-compara-label {
    font-size: .82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #1e293b;
    margin-bottom: .35rem;
}
.ampt-vf-compara-label small {
    font-weight: 500;
    color: #64748b;
    text-transform: none;
    letter-spacing: 0;
    font-size: .72rem;
    margin-left: .2rem;
}
.ampt-vf-compara-value {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.7rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
}
.ampt-vf-compara-value small {
    font-size: .7rem;
    color: #94a3b8;
    font-weight: 500;
    margin-left: .15rem;
}
.ampt-vf-compara-value-ton {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.05rem;
    font-weight: 700;
    color: #475569;
    line-height: 1.1;
}
.ampt-vf-compara-value-ton small {
    font-size: .65rem;
    color: #94a3b8;
    margin-left: .15rem;
}
.ampt-vf-compara-foot {
    font-size: .7rem;
    color: #94a3b8;
    margin-top: .35rem;
    line-height: 1.3;
}
.ampt-vf-compara-arrow {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 .5rem;
    border-left: 1px dashed #cbd5e1;
    border-right: 1px dashed #cbd5e1;
    min-width: 120px;
}
.ampt-vf-compara-arrow-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #94a3b8;
    margin-bottom: .25rem;
}
.ampt-vf-compara-arrow-ud,
.ampt-vf-compara-arrow-ton {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    line-height: 1.15;
}
.ampt-vf-compara-arrow-ud { font-size: 1.1rem; }
.ampt-vf-compara-arrow-ton { font-size: .85rem; }
.ampt-vf-compara-arrow-ud small,
.ampt-vf-compara-arrow-ton small {
    font-size: .65rem;
    font-weight: 500;
    opacity: .7;
    margin-left: .15rem;
}

@media (max-width: 768px) {
    .ampt-vf-compara { grid-template-columns: 1fr; }
    .ampt-vf-compara-arrow {
        border-left: none;
        border-right: none;
        border-top: 1px dashed #cbd5e1;
        border-bottom: 1px dashed #cbd5e1;
        padding: .65rem 0;
    }
}

/* =====================================================================
   Diagnóstico de Fechas — coherencia pp.fecha vs turno y fechat vs turno
   ===================================================================== */
.ampt-fechas-check {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: .9rem 1.1rem;
    height: 100%;
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.ampt-fechas-check-title {
    font-size: .9rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: .6rem;
}
.ampt-fechas-check-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: .65rem;
    padding: .35rem 0;
    border-top: 1px dashed #e2e8f0;
    border-bottom: 1px dashed #e2e8f0;
    margin-bottom: .55rem;
}
.ampt-fechas-stat-label {
    font-size: .7rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
    margin-bottom: .15rem;
}
.ampt-fechas-stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.1;
}
.ampt-fechas-stat-value small {
    font-size: .7rem;
    font-weight: 600;
    margin-left: .15rem;
}
.ampt-fechas-check-desc {
    font-size: .78rem;
    color: #64748b;
    line-height: 1.4;
}

.ampt-fechas-buckets {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #fff;
    border-radius: 10px;
    padding: .85rem 1.1rem;
}
.ampt-fechas-buckets-title {
    font-size: .85rem;
    font-weight: 700;
    color: #cbd5e1;
    margin-bottom: .65rem;
}
.ampt-fechas-buckets-title strong { color: #fff; }
.ampt-fechas-buckets-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: .5rem;
}
.ampt-fechas-bucket {
    background: rgba(255,255,255,.06);
    border-radius: 6px;
    border-top: 3px solid #64748b;
    padding: .5rem .65rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.ampt-fechas-bucket .lbl {
    font-size: .7rem;
    color: #cbd5e1;
    font-weight: 600;
}
.ampt-fechas-bucket .val {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
}

@media (max-width: 768px) {
    .ampt-fechas-check-grid { grid-template-columns: 1fr; }
    .ampt-fechas-buckets-grid { grid-template-columns: 1fr 1fr; }
}
