/* ====== Presupuestos — estilos propios sobre app.css ====== */

.barra-sup {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.barra-sup h1 { font-size: clamp(1.5rem, 2.6vw, 2rem); }
.barra-sup .sel { margin-left: auto; display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.campo-inline { display: flex; flex-direction: column; gap: 4px; }
.campo-inline label { font-size: .76rem; font-weight: 600; color: var(--humo); }
.campo-inline select, .campo-inline input { width: auto; }

/* ---- tabla de presupuesto con 12 meses ---- */
.scroll-x { width: 100%; overflow-x: auto; border: 1px solid var(--linea); border-radius: var(--r-l); background: var(--nieve); box-shadow: var(--sombra); }
.tabla-pre { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 1050px; }
.tabla-pre th, .tabla-pre td { padding: 9px 12px; border-bottom: 1px solid var(--linea-suave); white-space: nowrap; }
.tabla-pre thead th { position: sticky; top: 0; background: var(--fondo); font-size: .74rem; font-weight: 600; color: var(--humo); text-align: right; z-index: 2; }
.tabla-pre thead th.izq { text-align: left; }
.tabla-pre td.num, .tabla-pre th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla-pre .col-nom { text-align: left; position: sticky; left: 0; background: var(--nieve); z-index: 1; min-width: 300px; white-space: normal; }
.tabla-pre thead .col-nom { z-index: 3; background: var(--fondo); }

.fila-depto td { background: #eef6f5; font-weight: 700; border-top: 2px solid var(--linea); }
.fila-depto .col-nom { background: #eef6f5; }
.fila-concepto td { background: var(--nieve); font-weight: 600; }
.fila-linea td { color: var(--humo); }
.fila-linea .col-nom { padding-left: 28px; font-weight: 400; }
.fila-concepto .col-nom { padding-left: 16px; }
.fila-total td { background: var(--tinta); color: var(--nieve); font-weight: 800; border: none; }
.fila-total .col-nom { background: var(--tinta); color: var(--nieve); }

.cta-chip { font-size: .72rem; color: var(--humo-claro); display: block; }
.anual-col { font-weight: 700; background: var(--linea-suave); }
.tabla-pre .acc { text-align: center; }
.mini-btn { padding: 3px 9px; font-size: .76rem; }

.pill-modo { font-size: .7rem; padding: 2px 8px; border-radius: var(--r-pill); background: var(--turquesa-tenue); color: var(--turquesa-hondo); border: 1px solid #99e7de; }

/* ---- editor de meses (modo) ---- */
.modos { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.modo-op { display: flex; align-items: center; gap: 9px; font-size: .9rem; }
.modo-op input[type=radio] { width: auto; accent-color: var(--turquesa); }
.meses-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 8px; }
@media (max-width: 560px) { .meses-grid { grid-template-columns: repeat(3, 1fr); } }
.mes-celda { display: flex; flex-direction: column; gap: 3px; }
.mes-celda label { font-size: .72rem; color: var(--humo); font-weight: 600; }
.mes-celda input { width: 100%; padding: 7px 8px; font-size: .85rem; text-align: right; }
.mes-check { display: flex; align-items: center; gap: 6px; font-size: .78rem; }
.mes-check input { width: auto; accent-color: var(--turquesa); }
.resumen-anual { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--fondo); border: 1px solid var(--linea); border-radius: var(--r-m); margin-top: 6px; font-weight: 700; }

/* ---- KPIs del tablero ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--nieve); border: 1px solid var(--linea); border-radius: var(--r-l); padding: 18px 20px; box-shadow: var(--sombra); }
.kpi-fuerte { background: linear-gradient(135deg, var(--turquesa) 0%, var(--turquesa-hondo) 100%); border-color: transparent; color: var(--nieve); }
.kpi-rot { font-size: .78rem; font-weight: 600; color: var(--humo); margin-bottom: 8px; }
.kpi-fuerte .kpi-rot { color: rgba(255,255,255,.85); }
.kpi-num { font-size: 1.7rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi-pie { font-size: .8rem; margin-top: 6px; color: var(--humo); }
.kpi-fuerte .kpi-pie { color: rgba(255,255,255,.85); }

/* ---- barras por mes ---- */
.barras { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; }
.barra-col { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.barra-val { font-size: .62rem; color: var(--humo); font-variant-numeric: tabular-nums; white-space: nowrap; height: 1em; }
.barra-pista { width: 100%; height: 120px; display: flex; align-items: flex-end; background: var(--linea-suave); border-radius: 5px 5px 0 0; overflow: hidden; }
.barra-llena { width: 100%; background: linear-gradient(180deg, #2fd4c3, var(--turquesa-hondo)); border-radius: 5px 5px 0 0; min-height: 2px; transition: height .3s; }
.barra-mes { font-size: .66rem; color: var(--humo); }
@media (max-width: 680px) { .barra-val { display: none; } .barra-pista { height: 90px; } }

/* ---- árbol (toggles) ---- */
.tog { border: 1px solid var(--linea); background: var(--nieve); color: var(--tinta); width: 20px; height: 20px; border-radius: 5px; font-size: .72rem; line-height: 1; cursor: pointer; padding: 0; margin-right: 6px; }
.tog:hover { background: var(--linea-suave); }
.tog-vacio { display: inline-block; width: 20px; margin-right: 6px; }
.fila-agr td { background: #e3f0ef; font-weight: 800; border-top: 2px solid #cfe3e1; }
.fila-agr .col-nom { background: #e3f0ef; }
.fila-agr .tog { background: transparent; border-color: #b9dcd8; }

/* ---- tarjetas resumen por departamento (presentación) ---- */
.rejilla-resumen { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 24px; }
.tarjeta-resumen { background: var(--nieve); border: 1px solid var(--linea); border-left: 4px solid var(--turquesa); border-radius: var(--r-l); padding: 14px 16px; box-shadow: var(--sombra); }
.tarjeta-resumen .rr-cod { font-size: .78rem; font-weight: 700; color: var(--turquesa-hondo); }
.tarjeta-resumen .rr-nom { font-size: .84rem; color: var(--humo); margin: 2px 0 8px; min-height: 1.1em; }
.tarjeta-resumen .rr-monto { font-size: 1.25rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.bloque-carga { margin-bottom: 26px; }
.bloque-carga textarea { min-height: 120px; font-family: ui-monospace, monospace; font-size: .82rem; }
.formato { font-size: .8rem; color: var(--humo); background: var(--linea-suave); padding: 8px 12px; border-radius: var(--r-s); margin: 6px 0 10px; }
.resultado-carga { margin-top: 10px; }

/* ---- tabla de planilla (hoja completa: mes + año por concepto) ---- */
.tabla-planilla { min-width: 1500px; border-collapse: separate; border-spacing: 0; overflow: visible; border-radius: 0; }
.tabla-planilla th, .tabla-planilla td { padding: 10px 12px; white-space: nowrap; border-bottom: 1px solid var(--linea-suave); }
.tabla-planilla thead th { background: var(--fondo); font-size: .72rem; font-weight: 700; color: var(--humo); text-align: right; vertical-align: bottom; }
.tabla-planilla thead th.grp { text-align: center; border-left: 1px solid var(--linea); border-bottom: 1px solid var(--linea); font-size: .74rem; color: var(--tinta); }
.tabla-planilla thead th.sub { font-size: .68rem; font-weight: 600; }
.tabla-planilla td.num, .tabla-planilla th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla-planilla .cero { color: var(--humo-claro); opacity: .5; }

/* columnas fijas: Cód APS y Nombre */
.tabla-planilla .peg { position: sticky; box-sizing: border-box; background: var(--nieve); z-index: 1; }
.tabla-planilla .peg-1 { left: 0; width: 92px; min-width: 92px; }
.tabla-planilla .peg-2 { left: 92px; width: 190px; min-width: 190px; white-space: normal; border-right: 2px solid var(--linea); }
.tabla-planilla thead .peg { background: var(--fondo); z-index: 3; }

/* resaltado de los montos ANUALES (verde claro cubriendo toda la columna) */
.tabla-planilla .col-anual { background: var(--verde-tenue); }
.tabla-planilla thead .col-anual { background: #d9f6ea; }
.tabla-planilla td.col-anual { font-weight: 600; }

/* total anual (verde más fuerte, columna destacada) */
.tabla-planilla .col-total-anual { background: #c7f0e3; border-left: 1px solid #8fe0c8; border-right: 1px solid #8fe0c8; }
.tabla-planilla td.celda-total { font-weight: 800; color: var(--turquesa-hondo); }
.tabla-planilla thead th.col-total-anual { color: var(--turquesa-hondo); }

.tabla-planilla tbody tr:hover td { background: #fbfdff; }
.tabla-planilla tbody tr:hover .peg { background: #fbfdff; }
.tabla-planilla tbody tr:hover .col-anual { background: #e4fbf1; }
.tabla-planilla tbody tr:hover .col-total-anual { background: #bdeedd; }
.tabla-planilla .acciones { display: flex; gap: 6px; justify-content: flex-end; }

/* ---- planilla: panes congelados (cabecera + Cód/Nombre) y subtotales ---- */
.scroll-planilla { max-height: 74vh; overflow: auto; }
.tabla-planilla thead th { position: sticky; top: 0; z-index: 2; }
.tabla-planilla thead th.grp { z-index: 2; }
.tabla-planilla thead .peg { z-index: 4; }         /* esquina: cabecera + columna fija */
.tabla-planilla tbody .peg { z-index: 1; }
.tabla-planilla thead th.peg-2, .tabla-planilla tbody td.peg-2 { box-shadow: 2px 0 0 var(--linea); }

/* filas de subtotal / total */
.tabla-planilla .fila-sub td { background: #eef6f5; font-weight: 700; border-top: 2px solid var(--linea); border-bottom: 2px solid var(--linea); }
.tabla-planilla .fila-sub .peg { background: #eef6f5; }
.tabla-planilla .fila-sub .col-anual { background: #d6f0e6; }
.tabla-planilla .fila-sub .col-total-anual { background: #b6ead9; }
.tabla-planilla .sub-total td { background: var(--tinta); color: var(--nieve); }
.tabla-planilla .sub-total .peg { background: var(--tinta); color: var(--nieve); }
.tabla-planilla .sub-total .col-anual { background: #1f3a4d; }
.tabla-planilla .sub-total .col-total-anual { background: #0b3b35; color: var(--nieve); }
.tabla-planilla .sub-total .celda-total { color: var(--nieve); }

/* ---- presentación: paneles mes + reparto, donut ---- */
.rejilla-paneles { display: grid; grid-template-columns: 1fr; gap: 18px; margin-bottom: 22px; }
@media (min-width: 900px) { .rejilla-paneles { grid-template-columns: 1.6fr 1fr; } }
.reparto { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { flex: 0 0 auto; }
.donut-num { font-size: 30px; font-weight: 800; fill: var(--tinta); }
.donut-rot { font-size: 11px; fill: var(--humo); text-transform: uppercase; letter-spacing: .04em; }
.reparto-leyenda { display: flex; flex-direction: column; gap: 12px; min-width: 180px; }
.leyenda-item { display: flex; gap: 10px; align-items: center; }
.leyenda-item .punto { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; }
.leyenda-nom { font-size: .82rem; font-weight: 600; color: var(--humo); }
.leyenda-val { font-size: .95rem; color: var(--tinta); font-variant-numeric: tabular-nums; }
.leyenda-total { border-top: 1px solid var(--linea); padding-top: 10px; }

/* árbol de presupuesto con una sola columna de total */
.tabla-pre-total { min-width: 0; }
.tabla-pre-total .col-nom { min-width: 340px; }
.pill-auto { font-size: .68rem; padding: 1px 7px; border-radius: var(--r-pill); background: var(--turquesa-tenue); color: var(--turquesa-hondo); border: 1px solid #99e7de; margin-left: 6px; }

/* ---- detalle de hijos por rango (edad + mes de cumpleaños) ---- */
.hijos-lista { display: flex; flex-direction: column; gap: 3px; }
.hijo-item { font-size: .76rem; color: var(--humo); white-space: nowrap; }
.hijo-rango { display: inline-block; min-width: 42px; font-weight: 700; color: var(--turquesa-hondo); }
.hijo-prorr { color: #b45309; font-weight: 700; background: #fef3c7; border-radius: 6px; padding: 0 5px; font-size: .7rem; }

/* ---- comparativo 4 años (barras apiladas planilla/administración) ---- */
.barras-anios .barra-pista-alta { display: flex; flex-direction: column; justify-content: flex-end; height: 150px; }
.barra-llena-seg { width: 100%; transition: height .3s; }
.barras-anios .barra-llena-seg:last-child { border-radius: 0 0 0 0; }
.barras-anios .barra-llena-seg:first-child { border-radius: 5px 5px 0 0; }
.barras-anios .barra-mes { font-size: .82rem; }
.leyenda-inline { display: inline-flex; align-items: center; gap: 5px; margin-right: 12px; }
.leyenda-inline .punto { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ---- comparación de años en el árbol de presupuesto ---- */
.dif { font-variant-numeric: tabular-nums; font-weight: 600; }
.dif-mas { color: #047857; }
.dif-menos { color: #b91c1c; }
.tabla-pre-total thead th.num { white-space: nowrap; }

/* ---- documentos de sustento en el modal Montos ---- */
.mt-concepto { padding: 8px 0; border-bottom: 1px solid var(--linea-suave); }
.mt-concepto:last-child { border-bottom: none; }
.adjunto-linea { margin-top: 5px; font-size: .82rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.adjunto-linea a { font-weight: 600; }
.adj-btn { cursor: pointer; }
.pequeno { font-size: .8rem; }

/* ---- tipo jubilado + columnas de referencia (año anterior) ---- */
.etiqueta-jub { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.tabla-planilla .col-ref { background: #fffaf0; }
.tabla-planilla thead th.col-ref { background: #fdeec6; color: #8a6d1f; }
.tabla-planilla .col-ref input { background: #fffdf7; }

/* ===== ingresos ===== */
.ing-bloque { margin: 0 0 22px; }
.ing-bloque-cab { display: flex; align-items: baseline; gap: 10px; margin: 0 0 8px; }
.ing-bloque-cab h3 { margin: 0; font-size: 1.02rem; }
.ing-acciones { margin-top: 8px; }
.tabla-ing th, .tabla-ing td { padding: 7px 9px; white-space: nowrap; border-bottom: 1px solid var(--linea-suave); font-size: .86rem; }
.tabla-ing thead th { background: #eef6f5; position: sticky; top: 0; }
.tabla-ing .ing-concepto { min-width: 220px; }
.tabla-ing input[type=number] { padding: 5px 6px; }
.tabla-ing .ing-bruto td { background: #f3f8fc; font-weight: 600; }
.tabla-ing .ing-dist td { color: #8a4b1f; }
.tabla-ing .ing-menos { color: #b45309; }
.tabla-ing .ing-neto td { background: var(--verde-tenue); font-weight: 700; border-top: 2px solid var(--linea); border-bottom: 2px solid var(--linea); }
.tabla-ing .celda-total { background: #c7f0e3; font-weight: 700; }
.lnk-del { border: 0; background: none; color: #b91c1c; cursor: pointer; font-size: .9rem; margin-right: 6px; padding: 0 2px; }
.lnk-del:hover { color: #7f1010; }
.tabla-min td { padding: 5px 9px; border-bottom: 1px solid var(--linea-suave); font-size: .85rem; }
.tabla-min .fila-total td { border-top: 2px solid var(--linea); background: var(--verde-tenue); color: var(--tinta); font-weight: 700; }
.ing-resumen { background: var(--nieve); border: 1px solid var(--linea); border-radius: var(--r-l); padding: 14px 16px; box-shadow: var(--sombra); }
.ing-resumen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.ing-resumen-card { border: 1px solid var(--linea); border-radius: var(--r-m); overflow: hidden; }
.ing-resumen-cab { background: #eef6f5; padding: 8px 10px; border-bottom: 1px solid var(--linea); }
.ing-total-general { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--linea); text-align: right; font-size: 1.05rem; }
.ing-config { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 0 0 18px; padding: 10px 14px; background: var(--linea-suave); border-radius: var(--r-m); }
.ing-config label { font-size: .86rem; font-weight: 600; }
.ing-config select { padding: 5px 8px; margin-left: 4px; }

/* ===== botón de nota/archivo (+ / 👁) ===== */
.btn-nota { border: 1px solid var(--linea); background: var(--nieve); color: var(--humo); width: 22px; height: 22px; min-width: 22px; border-radius: 6px; font-size: .8rem; line-height: 1; cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn-nota:hover { background: var(--linea-suave); color: var(--tinta); }
.btn-nota.tiene { background: #fef3c7; border-color: #f0c948; color: #92400e; }
.nota-cod { display: inline-flex; align-items: center; gap: 6px; }
.ing-acc-campo { display: flex; align-items: center; gap: 8px; }

.ing-rubro-cell { display: flex; align-items: center; gap: 6px; }

.radio-inline { display: inline-flex; align-items: center; gap: 4px; font-size: .9rem; }

/* ===== barra lateral fija (siempre desplegada); solo acordeón por grupo ===== */
.admin-rail { grid-template-columns: 230px minmax(0, 1fr); gap: 18px; }
.menu-rail { width: 230px; margin-left: -14px; overflow: visible; background: var(--nieve); border: 1px solid var(--linea); border-radius: var(--r-l); padding: 8px 7px; box-shadow: var(--sombra); gap: 0; }
.menu-rail .nav-grupo { display: flex; flex-direction: column; gap: 2px; padding: 5px; margin-bottom: 10px; border: 1px solid var(--linea); border-radius: var(--r-m); }
.menu-rail .nav-grupo:last-child { margin-bottom: 0; }
.menu-rail .nav-grupo-tit { display: flex; align-items: center; gap: 10px; padding: 8px 9px; margin: -5px -5px 4px; border-radius: 9px 9px 0 0; font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; cursor: pointer; user-select: none; border-bottom: 2px solid transparent; }
/* cada grupo con su color para diferenciarlos a simple vista */
.menu-rail .nav-grupo[data-grupo="ingresos"] { border-color: #a7f3d0; }
.menu-rail .nav-grupo[data-grupo="ingresos"] .nav-grupo-tit { background: #ecfdf5; color: #047857; border-bottom-color: #34d399; }
.menu-rail .nav-grupo[data-grupo="gastos"] { border-color: #fed7aa; }
.menu-rail .nav-grupo[data-grupo="gastos"] .nav-grupo-tit { background: #fff7ed; color: #b45309; border-bottom-color: #fb923c; }
.menu-rail .nav-grupo[data-grupo="config"] { border-color: #cbd5e1; }
.menu-rail .nav-grupo[data-grupo="config"] .nav-grupo-tit { background: #f1f5f9; color: #475569; border-bottom-color: #94a3b8; }
.menu-rail .nav-grupo-tit:hover { filter: brightness(.97); }
.menu-rail .nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; font-size: .86rem; font-weight: 600; padding: 8px 7px; border: none; background: none; color: var(--humo); border-radius: var(--r-m); cursor: pointer; white-space: normal; }
.menu-rail .nav-item:hover { background: var(--linea-suave); color: var(--tinta); }
.menu-rail .nav-item.activo { background: var(--turquesa); color: var(--nieve); }
.menu-rail .nav-ic { width: 22px; min-width: 22px; text-align: center; font-size: 1.02rem; line-height: 1; }
.menu-rail .nav-lbl { opacity: 1; line-height: 1.15; word-break: break-word; }
.menu-rail .nav-chev { margin-left: auto; font-size: .7rem; color: inherit; }
.menu-rail .nav-grupo:not(.abierto) .nav-item { display: none; }   /* grupo recogido: oculta sus submódulos (acordeón) */
@media (max-width: 880px) {
  .admin-rail { grid-template-columns: 1fr; }
  .menu-rail { width: 100%; margin-left: 0; }
}

/* ===== arrastrar rubros (reordenar dentro del departamento) ===== */
.arrastre-asa { cursor: grab; color: var(--humo); margin-right: 8px; user-select: none; font-size: .95rem; }
.arrastre-asa:active { cursor: grabbing; }
.fila-concepto.arrastrando td { opacity: .45; }
.fila-concepto.drop-antes td { box-shadow: inset 0 2px 0 var(--turquesa); }
.fila-concepto.drop-despues td { box-shadow: inset 0 -2px 0 var(--turquesa); }

/* ===== ingresos: metafila (última modificación) y resumen del submódulo ===== */
.ing-metafila { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -6px 0 14px; }
.ing-meta { border: 1px solid var(--linea); background: var(--linea-suave); color: var(--tinta); padding: 5px 10px; border-radius: 999px; font-size: .8rem; cursor: pointer; }
.ing-meta:hover { background: #e3edf4; }
.ing-sub-resumen { margin-top: 14px; padding: 12px 16px; background: var(--nieve); border: 1px solid var(--linea); border-radius: var(--r-l); text-align: right; font-size: 1.02rem; box-shadow: var(--sombra); }

/* ===== materiales ===== */
.mat-etq { padding: 4px 10px; border-radius: 999px; border: 1px solid #c9a227; background: #fef3c7; color: #92400e; font-weight: 700; font-size: .8rem; }
.mat-perm-cell { white-space: nowrap; }
.mat-chk { display: inline-flex; align-items: center; gap: 3px; font-size: .78rem; margin-right: 8px; color: var(--humo); }

/* ===== desplegar/recoger árbol de gastos ===== */
.arbol-tog { border: 1px solid #059669; background: #10b981; cursor: pointer; color: #fff; font-size: .62rem; font-weight: 900; width: 17px; min-width: 17px; height: 17px; padding: 0; margin-right: 7px; line-height: 1; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; box-shadow: 0 1px 2px rgba(5,150,105,.3); }
.arbol-tog:hover { background: #047857; border-color: #047857; }
.arbol-tog-vacio { display: inline-block; width: 17px; min-width: 17px; margin-right: 7px; }
.sub-meta { display: flex; align-items: center; }
