/* =====================================================================
 * Análisis de Cierres — módulo comparativo
 * ===================================================================== */

.ac-page { padding-bottom: 2rem; }

/* ----- Header ----- */
.ac-header h5 { font-weight: 700; color: #0f172a; }
.ac-header small { color: #64748b; font-size: 0.85rem; }

.ac-period-picker {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.ac-period-picker label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 600;
    margin: 0;
}

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

.ac-period-picker input[type="date"]:focus {
    border-color: #f59e0b;
    outline: 2px solid rgba(245, 158, 11, 0.12);
}

/* ----- Tabs ----- */
.ac-tabs .nav-link {
    color: #475569;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: 6px 6px 0 0;
}

.ac-tabs .nav-link.active {
    color: #0f172a;
    background: #fff;
    border-color: #e2e8f0 #e2e8f0 #fff;
}

/* ----- Empty state ----- */
.ac-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}

.ac-empty i { color: #cbd5e1; }

/* ----- Loading ----- */
.ac-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #64748b;
    padding: 2.5rem;
    font-style: italic;
}

/* ----- Banner del período ----- */
.ac-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, #fef3c7, #fefce8);
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 0.7rem 1rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.ac-banner-text { color: #92400e; font-weight: 600; }
.ac-banner-meta { margin-left: auto; color: #64748b; font-size: 0.85rem; }

/* ----- Grid de cards ----- */
.ac-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.ac-cards-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

@media (max-width: 1400px) {
    .ac-cards-grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 1100px) {
    .ac-cards-grid,
    .ac-cards-grid-4 { grid-template-columns: 1fr; }
}

/* ----- Card de área ----- */
.ac-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-direction: column;
}

.ac-card-header {
    padding: 0.85rem 1.05rem;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fafc, #ffffff);
}

.ac-card-title {
    font-weight: 700;
    color: #0f172a;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.ac-card-subtitle {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.15rem;
}

.ac-card-body {
    padding: 1rem 1.05rem;
    flex: 1;
}

/* ----- Color de cada card según área ----- */
.ac-card.is-mp     .ac-card-header { background: linear-gradient(135deg, #e0f2fe, #f0f9ff); border-bottom-color: #bae6fd; }
.ac-card.is-mp     .ac-card-title  { color: #075985; }
.ac-card.is-pt     .ac-card-header { background: linear-gradient(135deg, #dcfce7, #f0fdf4); border-bottom-color: #bbf7d0; }
.ac-card.is-pt     .ac-card-title  { color: #14532d; }
.ac-card.is-despacho .ac-card-header { background: linear-gradient(135deg, #fff7ed, #ffedd5); border-bottom-color: #fed7aa; }
.ac-card.is-despacho .ac-card-title  { color: #7c2d12; }
.ac-card.is-ventas .ac-card-header { background: linear-gradient(135deg, #fce7f3, #fdf2f8); border-bottom-color: #fbcfe8; }
.ac-card.is-ventas .ac-card-title  { color: #831843; }

/* ----- Líneas del card ----- */
.ac-line {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.65rem;
    padding: 0.4rem 0;
    align-items: center;
    font-size: 0.92rem;
    border-bottom: 1px dashed #f1f5f9;
}

.ac-line:last-child { border-bottom: none; }

.ac-line-key {
    color: #475569;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.ac-line-key small {
    color: #94a3b8;
    font-size: 0.72rem;
    font-weight: 500;
}

.ac-line-op {
    display: inline-block;
    width: 1rem;
    text-align: center;
    color: #94a3b8;
    font-weight: 700;
    font-size: 0.85rem;
}

.ac-line-val {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: #0f172a;
    font-size: 0.92rem;
}

.ac-line-val small {
    color: #94a3b8;
    font-size: 0.65rem;
    font-weight: 500;
    margin-left: 0.15rem;
}

.ac-line-total {
    margin-top: 0.5rem;
    padding-top: 0.65rem;
    border-top: 2px solid #cbd5e1;
    font-weight: 700;
    font-size: 1rem;
}

.ac-line-total .ac-line-key,
.ac-line-total .ac-line-val { color: #0f172a; font-weight: 700; }

.ac-line-total .ac-line-val { font-size: 1.05rem; }

/* ----- Origen (de dónde viene) ----- */
.ac-origen {
    background: #f8fafc;
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    font-size: 0.74rem;
    color: #64748b;
    margin-top: 0.85rem;
    border-left: 3px solid #cbd5e1;
}

.ac-origen strong { color: #475569; }
.ac-origen code   { background: #e2e8f0; color: #0f172a; padding: 0.05rem 0.3rem; border-radius: 3px; font-size: 0.72rem; }

/* ----- Sección de comparaciones (entre los 3 cards) ----- */
.ac-conexiones {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem 1.15rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}

.ac-conexiones-titulo {
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 0.85rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ac-conex-row {
    display: grid;
    grid-template-columns: 1.3fr 0.9fr 1.3fr 0.9fr 1.1fr;
    align-items: center;
    gap: 0.85rem;
    padding: 0.6rem 0;
    border-bottom: 1px dashed #e2e8f0;
}

@media (max-width: 992px) {
    .ac-conex-row {
        grid-template-columns: 1fr 0.8fr;
        row-gap: 0.3rem;
    }
    .ac-conex-row .ac-conex-diff { grid-column: 1 / -1; }
}

.ac-conex-row:last-child { border-bottom: none; }

.ac-conex-label {
    font-size: 0.85rem;
    color: #475569;
}

.ac-conex-label strong { color: #0f172a; }

.ac-conex-val {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: #0f172a;
}

.ac-conex-val small {
    color: #94a3b8;
    font-size: 0.65rem;
    font-weight: 500;
}

.ac-conex-op {
    text-align: center;
    color: #94a3b8;
    font-size: 1.1rem;
}

.ac-conex-diff {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
}

.ac-conex-diff.is-ok   { color: #16a34a; background: #f0fdf4; }
.ac-conex-diff.is-warn { color: #ca8a04; background: #fefce8; }
.ac-conex-diff.is-err  { color: #dc2626; background: #fef2f2; }

.ac-conex-diff small {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    margin-top: 0.1rem;
}

/* ----- Nota inferior ----- */
.ac-nota {
    background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
    border-left: 4px solid #0ea5e9;
    border-radius: 8px;
    padding: 0.85rem 1rem;
    color: #075985;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-top: 1rem;
}

.ac-nota strong { color: #0c4a6e; }

/* ----- Etiqueta de unidades ----- */
.ac-line-val .ac-ud {
    display: block;
    font-size: 0.7rem;
    color: #94a3b8;
    font-weight: 500;
    margin-top: 0.1rem;
}

/* ----- Pill de diferencia inline ----- */
.ac-pill-diff {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
}

.ac-pill-diff.is-ok   { color: #16a34a; background: #dcfce7; }
.ac-pill-diff.is-warn { color: #ca8a04; background: #fef9c3; }
.ac-pill-diff.is-err  { color: #dc2626; background: #fee2e2; }

/* ===== Desglose del consumo MP (PT-1 / PT-2 / Chatarra) ===== */
.ac-desglose-mp {
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px dashed #e2e8f0;
}

.ac-desglose-intro {
    background: linear-gradient(135deg, #e0f2fe, #f0f9ff);
    border-left: 3px solid #0ea5e9;
    border-radius: 6px;
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
    color: #075985;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.ac-desglose-intro strong { color: #0c4a6e; }

.ac-cat-row {
    display: grid;
    grid-template-columns: 110px 1fr 110px 50px;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.ac-cat-row:last-child { border-bottom: none; }

.ac-cat-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 600;
    color: #1e293b;
    font-size: 0.82rem;
}

.ac-cat-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: #fff;
    font-size: 0.6rem;
    background: #94a3b8;
}

.ac-cat-row.is-pt1  .ac-cat-icon { background: #4f46e5; }
.ac-cat-row.is-pt2  .ac-cat-icon { background: #f59e0b; }
.ac-cat-row.is-chat .ac-cat-icon { background: #ef4444; }

.ac-cat-bar {
    height: 14px;
    background: #f1f5f9;
    border-radius: 999px;
    overflow: hidden;
}

.ac-cat-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.4s ease;
    background: #94a3b8;
}

.ac-cat-row.is-pt1  .ac-cat-bar-fill { background: linear-gradient(90deg, #4f46e5, #6366f1); }
.ac-cat-row.is-pt2  .ac-cat-bar-fill { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.ac-cat-row.is-chat .ac-cat-bar-fill { background: linear-gradient(90deg, #ef4444, #f87171); }

.ac-cat-val {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.85rem;
    color: #0f172a;
}

.ac-cat-val small {
    color: #94a3b8;
    font-size: 0.62rem;
    font-weight: 500;
    margin-left: 0.1rem;
}

.ac-cat-sub {
    display: block;
    font-size: 0.65rem;
    color: #94a3b8;
    font-weight: 500;
    margin-top: 0.1rem;
}

.ac-cat-pct {
    text-align: right;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    font-size: 0.92rem;
    color: #475569;
}

.ac-cat-row-total {
    border-top: 2px solid #cbd5e1;
    margin-top: 0.4rem;
    padding-top: 0.5rem;
    background: #f0fdf4;
    border-radius: 6px;
    padding-left: 0.4rem;
    padding-right: 0.4rem;
}

.ac-cat-row-total .ac-cat-label { color: #15803d; }
.ac-cat-row-total .ac-cat-icon  { background: #16a34a; }
.ac-cat-row-total .ac-cat-bar-fill { background: linear-gradient(90deg, #16a34a, #22c55e); }
.ac-cat-row-total .ac-cat-val,
.ac-cat-row-total .ac-cat-pct  { color: #15803d; }
