/* =====================================================================
 * Explicación Remanente / Excedente — tab educativo del Inventario MP
 * Convención: consumido − teórico
 *   excedente > 0  → consumió más que el teórico (verde)
 *   remanente < 0  → sobró peso teórico (rojo)
 * ===================================================================== */

.erx-wrap {
    padding: 1.25rem 1.5rem 2rem;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 280px);
    border-radius: 12px;
    min-height: 70vh;
}

/* ---------- Header del tab ---------- */
.erx-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.erx-header-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.erx-header-title h3 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
}

.erx-header-title .erx-badge-edu {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.erx-header-title-sub {
    color: #64748b;
    font-size: 0.85rem;
    margin-top: 0.2rem;
}

/* ---------- Selector de período ---------- */
.erx-period-picker {
    display: flex;
    align-items: flex-end;
    gap: 0.65rem;
    flex-wrap: wrap;
    background: #fff;
    padding: 0.7rem 0.9rem;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.erx-period-picker label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.2rem;
}

.erx-period-picker input[type="date"] {
    height: 36px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    padding: 0.25rem 0.55rem;
    font-size: 0.9rem;
    color: #0f172a;
    min-width: 145px;
}

.erx-period-picker input[type="date"]:focus {
    border-color: #6366f1;
    outline: 2px solid rgba(99, 102, 241, 0.12);
}

.erx-btn-cargar {
    height: 36px;
    background: #6366f1;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: background 0.15s;
}

.erx-btn-cargar:hover { background: #4f46e5; }
.erx-btn-cargar:disabled { background: #94a3b8; cursor: not-allowed; }

/* ---------- Hero: explicación visual de la convención ---------- */
.erx-hero {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.erx-hero-title {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.erx-hero-formula {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.95rem;
    color: #1e293b;
    display: inline-block;
    margin: 0.4rem 0 1rem;
    border: 1px dashed #94a3b8;
}

.erx-hero-cases {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
    margin-top: 0.5rem;
}

.erx-hero-case {
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    border-left: 4px solid;
    background: #f8fafc;
}

.erx-hero-case.is-exc { border-left-color: #16a34a; background: #f0fdf4; }
.erx-hero-case.is-rem { border-left-color: #dc2626; background: #fef2f2; }

.erx-hero-case .erx-hero-case-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.erx-hero-case.is-exc .erx-hero-case-label { color: #16a34a; }
.erx-hero-case.is-rem .erx-hero-case-label { color: #dc2626; }

.erx-hero-case .erx-hero-case-formula {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.78rem;
    color: #475569;
    margin-top: 0.15rem;
}

.erx-hero-case .erx-hero-case-meaning {
    font-size: 0.85rem;
    color: #1e293b;
    margin-top: 0.3rem;
    font-weight: 500;
}

/* ---------- Cards de las 3 métricas ---------- */
.erx-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.erx-metric-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
    position: relative;
    overflow: hidden;
}

.erx-metric-card.is-ini { border-top: 3px solid #0ea5e9; }
.erx-metric-card.is-fin { border-top: 3px solid #10b981; }
.erx-metric-card.is-per { border-top: 3px solid #8b5cf6; }

.erx-metric-card .erx-mc-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.erx-metric-card .erx-mc-date {
    font-size: 0.75rem;
    color: #94a3b8;
    font-family: 'Roboto Mono', monospace;
    margin-top: 0.15rem;
    margin-bottom: 0.85rem;
}

.erx-metric-card .erx-mc-rows {
    display: grid;
    grid-template-columns: 1fr auto;
    row-gap: 0.35rem;
    column-gap: 0.85rem;
    font-size: 0.9rem;
}

.erx-metric-card .erx-mc-row-label {
    color: #475569;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.erx-metric-card .erx-mc-row-val {
    text-align: right;
    font-family: 'Roboto Mono', monospace;
    font-weight: 600;
    color: #0f172a;
}

.erx-metric-card .erx-mc-row-val.is-exc { color: #16a34a; }
.erx-metric-card .erx-mc-row-val.is-rem { color: #dc2626; }
.erx-metric-card .erx-mc-row-val.is-zero { color: #94a3b8; }

.erx-metric-card .erx-mc-neto {
    margin-top: 0.7rem;
    padding-top: 0.55rem;
    border-top: 1px dashed #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.erx-metric-card .erx-mc-neto-key { color: #64748b; }
.erx-metric-card .erx-mc-neto-val {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.05rem;
}

.erx-metric-card .erx-mc-helper {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 0.6rem;
    line-height: 1.35;
    border-left: 2px solid #e2e8f0;
    padding-left: 0.5rem;
}

/* ---------- Verificación de cuadre ---------- */
.erx-verif {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.1rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.erx-verif-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.85rem;
    font-weight: 700;
    color: #0f172a;
}

.erx-verif-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.85rem;
    padding: 0.55rem 0;
    border-bottom: 1px dashed #e2e8f0;
    font-size: 0.92rem;
}

.erx-verif-row:last-child { border-bottom: none; }

.erx-verif-formula {
    color: #64748b;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85rem;
}

.erx-verif-val {
    font-family: 'Roboto Mono', monospace;
    font-weight: 700;
    font-size: 1rem;
    color: #0f172a;
}

.erx-verif-result {
    margin-top: 0.55rem;
    padding-top: 0.85rem;
    border-top: 2px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.erx-verif-result-key {
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.erx-verif-result-val {
    font-family: 'Roboto Mono', monospace;
    font-weight: 800;
    font-size: 1.15rem;
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
}

.erx-verif-result-val.is-ok { color: #16a34a; background: #f0fdf4; }
.erx-verif-result-val.is-warn { color: #ca8a04; background: #fefce8; }
.erx-verif-result-val.is-err { color: #dc2626; background: #fef2f2; }

/* ---------- Sección "Por qué no cuadra" ---------- */
.erx-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.1rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.erx-section-title {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.erx-section-title small {
    font-weight: 500;
    color: #64748b;
    font-size: 0.78rem;
    margin-left: 0.25rem;
}

.erx-logic-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.erx-logic-card {
    border-radius: 10px;
    padding: 0.9rem 1.1rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.erx-logic-card.is-gen { border-left: 4px solid #0ea5e9; }
.erx-logic-card.is-per { border-left: 4px solid #8b5cf6; }

.erx-logic-card-head {
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.erx-logic-card-tag {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.erx-logic-card.is-gen .erx-logic-card-tag { background: #e0f2fe; color: #0369a1; }
.erx-logic-card.is-per .erx-logic-card-tag { background: #ede9fe; color: #6d28d9; }

.erx-logic-card-body {
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.5;
}

.erx-logic-card-body strong { color: #0f172a; }

.erx-logic-card-body ul {
    margin: 0.5rem 0 0;
    padding-left: 1.1rem;
}

.erx-logic-card-body li {
    margin-bottom: 0.25rem;
}

/* ---------- Tabla de casos ---------- */
.erx-cases-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.erx-cases-table thead th {
    background: #f1f5f9;
    color: #1e293b;
    padding: 0.55rem 0.75rem;
    font-weight: 700;
    text-align: left;
    border-bottom: 2px solid #cbd5e1;
}

.erx-cases-table tbody td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    color: #475569;
}

.erx-cases-table tbody tr:hover {
    background: #f8fafc;
}

.erx-cases-table .erx-pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

.erx-cases-table .erx-pill-yes { background: #dcfce7; color: #15803d; }
.erx-cases-table .erx-pill-no  { background: #fee2e2; color: #b91c1c; }
.erx-cases-table .erx-pill-partial { background: #fef9c3; color: #a16207; }

/* ---------- Empty state ---------- */
.erx-empty {
    text-align: center;
    padding: 3rem 2rem;
    background: #fff;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    color: #94a3b8;
}

.erx-empty i {
    font-size: 2.5rem;
    color: #cbd5e1;
    margin-bottom: 0.75rem;
}

.erx-empty h5 {
    color: #475569;
    font-weight: 600;
}

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
    .erx-metrics-grid { grid-template-columns: 1fr; }
    .erx-hero-cases { grid-template-columns: 1fr; }
    .erx-logic-grid { grid-template-columns: 1fr; }
}
