:root {
    --ebitda2-primary: #c00d32;
    --ebitda2-bg: #f7f7f8;
    --ebitda2-border: #d8d8dd;
    --ebitda2-muted: #6b7280;
}
body {
    background: var(--ebitda2-bg);
}


.ebitda2-wrap {
    max-width: 1800px;
}

.ebitda2-subtitle {
    font-size: 14px;
    color: var(--ebitda2-muted);
    margin: 0 0 8px;
}

.ebitda2-accent {
    color: var(--ebitda2-primary);
}

.ebitda2-card-global {
    border: 2px solid var(--ebitda2-primary);
    box-shadow: 0 2px 8px rgba(192, 13, 50, 0.1);
}

.form-container {
    background: #fff;
    padding: 15px;
    margin: 10px auto;
    border-radius: 8px;
    border: 1px solid var(--ebitda2-border);
}

h1, h2 {
    margin: 0 0 12px;
}

h2 {
    color: var(--ebitda2-primary);
    font-size: 1.25rem;
}

.nota {
    font-size: 12px;
    color: var(--ebitda2-muted);
}

.btn-mes {
    padding: 6px 12px;
    border: 1px solid var(--ebitda2-border);
    border-radius: 4px;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
}

.btn-mes.selected {
    background: var(--ebitda2-primary);
    color: #fff;
    border-color: var(--ebitda2-primary);
    font-weight: 600;
}

.ebitda2-meses-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ebitda2-kpi {
    background: #fafafa;
    border: 1px solid var(--ebitda2-border);
    border-radius: 8px;
    padding: 12px 14px;
    height: 100%;
}

.ebitda2-kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ebitda2-muted);
    margin-bottom: 4px;
}

.ebitda2-kpi-value {
    font-size: 1.1rem;
    font-weight: 600;
}

.ebitda2-chart-wrap {
    position: relative;
    min-height: 320px;
    background: #fff;
    border: 1px solid var(--ebitda2-border);
    border-radius: 8px;
    padding: 12px;
}

.ebitda2-details summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--ebitda2-primary);
    font-weight: 600;
}

.ebitda2-tabla {
    font-size: 12px;
}

.ebitda2-tabla .scope-truncated {
    color: #b45309;
    font-weight: 600;
}

.ebitda2-tabla .row-anomalia {
    background: #fee2e2 !important;
}

.ebitda2-placeholder {
    opacity: 0.85;
    border-style: dashed;
}

.ebitda2-loading {
    opacity: 0.5;
    pointer-events: none;
}

/* ── Sección 2 tabla ─────────────────────────────────── */
#ebitda2-s2-tabla-wrap {
    overflow-x: auto;
}

.s2-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    /* Borde exterior igual al de las cards de la sección 1 */
    border: 1px solid var(--ebitda2-border);
    border-radius: 4px;
}

/* Grilla neutral — igual que Bootstrap table en S1 */
.s2-tabla th,
.s2-tabla td {
    border: 1px solid var(--ebitda2-border);
}

.s2-tabla th {
    background: #f3f4f6;
    padding: 7px 10px;
    white-space: nowrap;
    border-bottom: 2px solid var(--ebitda2-primary);
}

.s2-th-cat {
    min-width: 220px;
    text-align: left;
}

.s2-th-mes {
    text-align: right;
    min-width: 120px;
}

/* Grupos: acento rojo fuerte — 2px inferior marca separación clara */
.s2-grupo-row {
    background: #1f2937;
    color: #fff;
    cursor: pointer;
    user-select: none;
}

.s2-grupo-row td {
    border-color: #374151;
    border-bottom: 2px solid var(--ebitda2-primary);
}

.s2-grupo-row:hover {
    background: #374151;
}

.s2-grupo-nombre {
    padding: 7px 10px;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.03em;
}

.s2-grupo-val {
    padding: 7px 10px;
    text-align: right;
    font-weight: 700;
    white-space: nowrap;
}

/* Categorías: grilla gris estándar, hover rojo suave */
.s2-cat-row {
    cursor: pointer;
    background: #fff;
}

.s2-cat-row td {
    border-bottom: 1px solid var(--ebitda2-border);
}

.s2-cat-row:hover {
    background: #fef2f4;
}

.s2-cat-nombre {
    padding: 6px 10px 6px 22px;
    font-weight: 600;
}

.s2-cat-val {
    padding: 6px 10px;
    text-align: right;
    white-space: nowrap;
}

/* Detalle: borde más fino y tenue — claramente subordinado */
.s2-detalle-row td {
    vertical-align: top;
    background: #fafafa;
    border: 1px solid #eaecef;
}

.s2-det-label {
    padding: 0;
    min-width: 0;
    width: 0;
}

.s2-det-cel {
    padding: 5px 10px;
    text-align: left;
    min-width: 120px;
    vertical-align: top;
    white-space: normal;
}

.s2-det-concepto {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #374151;
    line-height: 1.3;
}

.s2-det-linea {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 1px;
}

.s2-det-ref {
    font-size: 10px;
    color: var(--ebitda2-muted);
}

.s2-det-monto {
    font-size: 11px;
    font-weight: 600;
    color: #374151;
    margin-left: auto;
}

.s2-tgl {
    font-size: 9px;
    display: inline-block;
    width: 12px;
    margin-right: 4px;
    color: #9ca3af;
}

/* ── Sección 3 ───────────────────────────────────────── */
#ebitda2-s3-tabla-wrap,
#ebitda2-s3-iva-wrap {
    overflow-x: auto;
}

.s3-iva-tabla .s2-cat-nombre {
    padding-left: 10px;
}

/* IVA neto calculado: fila intermedia resaltada */
.s3-iva-calc td {
    background: #f3f4f6;
    font-weight: 600;
    border-top: 2px solid var(--ebitda2-border);
}

.s3-iva-f29 td {
    background: #fff;
    font-style: italic;
}

/* Fila diferencia: acento, igual que grupo */
.s3-iva-dif-row {
    background: #1f2937;
    color: #fff;
}

.s3-iva-dif-row td {
    border-bottom: 2px solid var(--ebitda2-primary);
}

.s3-dif-pos {
    color: #fca5a5;
    font-weight: 700;
}

.s3-dif-neg {
    color: #86efac;
    font-weight: 700;
}

/* ── Sección 4 ───────────────────────────────────────── */
.s4-tabla-wrap {
    overflow-x: auto;
    margin-bottom: 18px;
}

.s4-subtitulo {
    font-size: 1.05rem;
    color: var(--ebitda2-primary);
    margin: 6px 0 10px;
}

/* Grid de diagnósticos por mes */
.s4-diag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.s4-diag {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 8px;
    border: 1px solid var(--ebitda2-border);
    border-left-width: 6px;
    background: #fff;
}

.s4-diag-success { border-left-color: #16a34a; background: #f0fdf4; }
.s4-diag-info    { border-left-color: #0ea5e9; background: #f0f9ff; }
.s4-diag-warning { border-left-color: #d97706; background: #fffbeb; }
.s4-diag-danger  { border-left-color: var(--ebitda2-primary); background: #fef2f2; }

.s4-diag-icono {
    font-size: 1.8rem;
    line-height: 1;
}

.s4-diag-cuerpo {
    flex: 1;
}

.s4-diag-mes {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ebitda2-muted);
    font-weight: 600;
}

.s4-diag-top {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.s4-diag-margen {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
}

.s4-diag-estado {
    margin-left: auto;
    font-size: 12px;
}

.s4-diag-msg {
    margin: 6px 0 0;
    font-size: 12px;
    color: #374151;
}

/* Tabla de cálculo */
.s4-calc-tabla .s2-th-mes,
.s4-kpi-tabla .s2-th-mes {
    text-align: right;
}

.s4-calc-tabla td:first-child {
    white-space: nowrap;
}

.s4-calc-ingresos td {
    border-bottom: 1px solid var(--ebitda2-border);
}

.s4-calc-total td {
    border-top: 1px solid var(--ebitda2-border);
    font-weight: 600;
}

.s4-calc-ebitda td {
    background: #1f2937;
    color: #fff;
    font-weight: 700;
    border-bottom: 2px solid var(--ebitda2-primary);
}

.s4-calc-margen td {
    background: #f3f4f6;
    font-weight: 700;
}

/* Tabla de KPIs */
.s4-kpi-row td {
    border-bottom: 1px solid var(--ebitda2-border);
}

.s4-kpi-destacado td {
    background: #f3f4f6;
    font-weight: 700;
    border-top: 2px solid var(--ebitda2-border);
}

.s4-pct {
    font-weight: 600;
    margin-right: 4px;
}

.s4-rango {
    color: var(--ebitda2-muted);
    font-size: 11px;
    font-weight: 400;
}
