/* REDLINE · Gestión (rentabilidad, por facturar, cobros, riesgo, control de imputación, prefacturación, radar) — redline_gestion.js */
#direccion-redline-view, #rentabilidad-view, #porfacturar-view, #cobros-view, #riesgo-view, #control-imputacion-view, #prefacturacion-view, #radar-view {
    --rlg-ink: #0f172a; --rlg-mut: #64748b; --rlg-line: #e2e8f0; --rlg-rojo: var(--accent-red, #be0b1e); }
.rlg-root { display: grid; gap: 14px; min-width: 0; max-width: 1400px; padding-bottom: 70px; }
.rlg-cab { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 10px; }
.rlg-cab h2 { margin: 0; font-size: 1.35rem; color: var(--rlg-ink); display: flex; gap: 10px; align-items: center; }
.rlg-cab h2 i { color: var(--rlg-rojo); }
.rlg-cab p { margin: 4px 0 0; color: var(--rlg-mut); font-size: .86rem; max-width: 760px; }
.rlg-ctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rlg-ctl select, .rlg-ctl input { border: 1px solid var(--rlg-line); border-radius: 10px; padding: 7px 9px; font: inherit; font-size: .85rem; background: #fff; }
.rlg-ctl input[type=number] { width: 70px; }
.rlg-lbl { display: inline-flex; gap: 6px; align-items: center; font-size: .82rem; color: var(--rlg-mut); font-weight: 600; }
.rlg-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.rlg-kpi { background: #fff; border: 1px solid var(--rlg-line); border-left: 4px solid var(--c); border-radius: 14px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.rlg-kpi > i { font-size: 1.35rem; color: var(--c); width: 30px; text-align: center; }
.rlg-kpi b { display: block; font-size: 1.25rem; color: var(--rlg-ink); font-variant-numeric: tabular-nums; }
.rlg-kpi span { font-size: .76rem; color: var(--rlg-mut); font-weight: 600; display: block; }
.rlg-kpi small { font-size: .72rem; color: var(--c); font-weight: 700; }
.rlg-card { background: #fff; border: 1px solid var(--rlg-line); border-radius: 14px; padding: 14px 16px; display: grid; gap: 10px; min-width: 0; }
.rlg-card h3 { margin: 0; font-size: 1rem; color: var(--rlg-ink); display: flex; gap: 8px; align-items: center; }
.rlg-card h3 i { color: var(--rlg-rojo); }
.rlg-dos { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.rlg-g { position: relative; height: 260px; }
.rlg-aviso { display: flex; gap: 10px; align-items: flex-start; background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 10px 12px; font-size: .86rem; color: #78350f; }
.rlg-aviso i { color: #d97706; margin-top: 2px; }
.rlg-nota { background: #f8fafc; border: 1px solid var(--rlg-line); border-radius: 12px; padding: 8px 12px; font-size: .82rem; color: var(--rlg-mut); }
.rlg-nota summary { cursor: pointer; font-weight: 700; color: var(--rlg-ink); }
.rlg-nota div { margin-top: 6px; line-height: 1.5; }
.rlg-tbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rlg-buscar { position: relative; flex: 1 1 240px; }
.rlg-buscar i { position: absolute; left: 11px; top: 11px; color: var(--rlg-mut); font-size: .85rem; }
.rlg-buscar input { width: 100%; box-sizing: border-box; border: 1.5px solid var(--rlg-line); border-radius: 10px; padding: 8px 10px 8px 32px; font: inherit; font-size: .86rem; }
.rlg-cuenta { color: var(--rlg-mut); font-size: .78rem; }
.rlg-btn { border: 1px solid var(--rlg-line); background: #fff; color: var(--rlg-ink); border-radius: 10px; padding: 7px 12px; font-weight: 700; font-size: .82rem; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.rlg-btn:hover { border-color: var(--rlg-rojo); color: var(--rlg-rojo); }
.rlg-tw { overflow-x: auto; }
.rlg-t { width: 100%; border-collapse: collapse; font-size: .82rem; }
.rlg-t th { text-align: left; color: var(--rlg-mut); font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--rlg-line); white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 0; background: #fff; }
.rlg-t th.rlg-ord { color: var(--rlg-ink); }
.rlg-t td { padding: 7px 8px; border-bottom: 1px solid #f1f5f9; color: var(--rlg-ink); vertical-align: top; }
.rlg-t td small { color: var(--rlg-mut); }
.rlg-t .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rlg-t a { color: #2563eb; text-decoration: none; }
.rlg-chip { display: inline-block; font-weight: 700; font-size: .74rem; padding: 2px 8px; border-radius: 99px; white-space: nowrap; margin: 1px 0; }
.rlg-ok { background: #dcfce7; color: #166534; } .rlg-med { background: #fef3c7; color: #92400e; } .rlg-mal { background: #fee2e2; color: #991b1b; }
.rlg-rojo { color: #b91c1c; }
.rlg-vacio { color: var(--rlg-mut); font-size: .86rem; padding: 8px 2px; }
.rlg-err { background: #fff7ed; border-radius: 12px; padding: 12px; }
.rlg-spark { display: block; }
.rlg-ley { display: flex; gap: 6px; align-items: center; font-size: .76rem; color: var(--rlg-mut); }
.rlg-ley span { display: inline-block; width: 14px; height: 14px; border-radius: 4px; margin-left: 6px; }
.rlg-mapa { border-collapse: separate; border-spacing: 2px; font-size: .72rem; }
.rlg-mapa th { color: var(--rlg-mut); font-weight: 600; padding: 3px; text-align: center; white-space: nowrap; }
.rlg-mapa th:first-child, .rlg-mapa td.rlg-nom { text-align: left; white-space: nowrap; padding-right: 8px; position: sticky; left: 0; background: #fff; z-index: 1; font-size: .8rem; }
.rlg-mapa td { min-width: 26px; height: 24px; text-align: center; border-radius: 5px; font-variant-numeric: tabular-nums; color: #0f172a; }
.rlg-mapa td.n { text-align: right; padding: 0 6px; white-space: nowrap; }
.rlg-c-ok { background: #bbf7d0; } .rlg-c-par { background: #fde68a; } .rlg-c-no { background: #fecaca; }
@media (max-width: 900px) { .rlg-dos { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .rlg-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .rlg-kpi b { font-size: 1.05rem; } .rlg-kpi { padding: 10px; gap: 8px; } }
.rlg-barras { display: grid; gap: 6px; }
.rlg-barra { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 8px; align-items: center; font-size: .8rem; }
.rlg-barra span { color: var(--rlg-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rlg-barra div { background: #f1f5f9; border-radius: 99px; height: 10px; overflow: hidden; }
.rlg-barra i { display: block; height: 100%; background: linear-gradient(90deg, var(--rlg-rojo), #ef4444); border-radius: 99px; }
.rlg-barra b { font-variant-numeric: tabular-nums; color: var(--rlg-ink); white-space: nowrap; }
.rlg-chip.rlg-chip-txt { white-space: normal; }
.rlg-clic { cursor: pointer; } .rlg-clic:hover .rlg-kpi, .rlg-barra.rlg-clic:hover { background: #fff7f7; } .rlg-barra.rlg-clic { border-radius: 8px; padding: 2px 4px; }
.rlg-mapa td.rlg-clic:hover { outline: 2px solid var(--rlg-rojo); }
.rlg-btn-ok { border-color: #86efac; color: #15803d; background: #f0fdf4; white-space: nowrap; }
.rlg-t .rlg-btn { white-space: nowrap; }
.rlg-t td a { overflow-wrap: anywhere; }
