
:root {
  --tinta: #18242E;
  --tenue: #5A6A70;
  --fondo: #EEF1F0;
  --papel: #FFFFFF;
  --linea: #D3DAD8;
  --petroleo: #13434A;
  --petroleo-2: #1E5E66;
  --bien: #1D7A45;  --bien-s: #DDF0E4;
  --mal: #B42318;   --mal-s: #FBE4E1;
  --aviso: #8A5200; --aviso-s: #FCEFD3;
  --radio: 6px;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --cond: 'IBM Plex Sans Condensed', 'IBM Plex Sans', system-ui, sans-serif;
}
* { box-sizing: border-box; }
canvas, img, svg { max-width: 100%; }

[hidden] { display: none !important; }
html, body { margin: 0; background: var(--fondo); color: var(--tinta); font: 14px/1.45 var(--sans); }
body { min-height: 100vh; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--petroleo-2); outline-offset: 2px; }

/* Barra superior */
.barra { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 0 20px;
  background: var(--petroleo); color: #fff; min-height: 52px; flex-wrap: wrap; }
.marca { font: 600 17px/1 var(--cond); letter-spacing: .01em; }
#tabs { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
#tabs button { background: none; border: 0; color: #C9DCDD; padding: 16px 12px 14px; cursor: pointer; border-bottom: 3px solid transparent; }
#tabs button:hover { color: #fff; }
#tabs button.activo { color: #fff; border-bottom-color: #8FD3C9; }
.vista-moneda label { display: flex; align-items: center; gap: 8px; color: #C9DCDD; }
.vista-moneda select { background: var(--petroleo-2); color: #fff; border: 1px solid #3B7880; border-radius: var(--radio); padding: 5px 8px; }

main { padding: 20px; }
.vista { display: none; }
.vista.activa { display: block; }

h2 { font: 600 20px/1.2 var(--cond); margin: 0 0 4px; }
h3 { font: 600 15px/1.3 var(--sans); margin: 0 0 10px; }
.sub { color: var(--tenue); margin: 0 0 16px; }
.vacio { padding: 28px; text-align: center; color: var(--tenue); background: var(--papel); border: 1px dashed var(--linea); border-radius: var(--radio); }
.cargando { padding: 40px; color: var(--tenue); }

/* Botones */
.btn { border: 1px solid var(--linea); background: var(--papel); border-radius: var(--radio); padding: 7px 14px; cursor: pointer; }
.btn:hover { border-color: var(--petroleo-2); }
.btn.prim { background: var(--petroleo); border-color: var(--petroleo); color: #fff; }
.btn.prim:hover { background: var(--petroleo-2); }
.btn.mini { padding: 3px 9px; font-size: 13px; }
.btn.peligro { color: var(--mal); }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Filtros */
.filtros { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filtros label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--tenue); }
.filtros select, .filtros input { padding: 6px 8px; border: 1px solid var(--linea); border-radius: var(--radio); background: var(--papel); min-width: 120px; }
.filtros input[type=checkbox] { min-width: 0; }
.filtros .chk { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--tinta); padding-bottom: 6px; }

/* Opción de actualización diaria de tasas */
.opcion-diaria { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 10px 12px;
  border: 1px solid var(--linea); border-radius: var(--radio); cursor: pointer; }
.opcion-diaria input { margin-top: 3px; }
.opcion-diaria small { display: block; color: var(--tenue); font-size: 12px; }

/* Aviso de fallo de carga */
#fallo { margin: 20px; padding: 14px 16px; background: var(--mal-s); color: var(--mal); border: 1px solid var(--mal); border-radius: var(--radio); }
#fallo code { background: #fff; padding: 1px 5px; border-radius: 3px; }

/* Tarjetas de crédito en el tablero */
.tc { padding: 14px 0; border-top: 1px solid var(--linea); }
.tc:first-of-type { border-top: 0; padding-top: 4px; }
.tc header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.tc h4 { margin: 0; font: 600 15px/1.3 var(--sans); }
.tc .deuda { font: 600 17px/1.2 var(--cond); font-variant-numeric: tabular-nums; color: var(--mal); white-space: nowrap; }
.tc .deuda small { color: var(--tenue); font: 400 12px var(--sans); }
.tc-pago { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0 6px; }
.tc-pago dt { font-size: 12px; color: var(--tenue); }
.tc-pago dd { margin: 0; font-variant-numeric: tabular-nums; }
.tc .ciclo { margin: 4px 0 8px; font-size: 12px; color: var(--tenue); }
.tc .sin-meta { margin: 6px 0 0; font-size: 12px; }
.meta-tc { margin: 8px 0; }
.meta-tc .fila { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.meta-tc .fila b { font-variant-numeric: tabular-nums; }
.meta-tc .pista { height: 8px; background: var(--fondo); border-radius: 4px; overflow: hidden; }
.meta-tc .valor { height: 100%; border-radius: 4px; }
.meta-tc small { display: block; font-size: 12px; margin-top: 3px; }
.meta-tc.cumple .valor { background: var(--bien); } .meta-tc.cumple small { color: var(--bien); }
.meta-tc.falta .valor { background: var(--mal); } .meta-tc.falta small { color: var(--mal); }

/* Listas con autocompletar */
.combo { position: relative; display: flex; flex-wrap: wrap; }
.combo-lista { flex-basis: 100%; }
.combo .combo-txt { flex: 1; padding-right: 30px; }
.combo .combo-btn { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 28px; border: 0; background: none; color: var(--tenue); cursor: pointer; }
.combo-lista { position: absolute; z-index: 30; top: calc(100% + 2px); left: 0; right: 0; max-height: 240px; overflow-y: auto; margin: 0; padding: 4px 0;
  list-style: none; background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: 0 8px 24px rgba(19, 67, 74, .16); }
.combo-lista li { padding: 7px 10px; font-size: 14px; }
.combo-op { cursor: pointer; }
.combo-op.activa, .combo-op:hover { background: #E2EFEC; }
.combo-grupo { font-size: 12px !important; color: var(--tenue); text-transform: uppercase; letter-spacing: .04em; padding-top: 8px !important; }
.combo-vacio { color: var(--tenue); }
/* La lista se despliega dentro del formulario, que se desplaza si hace falta */
.dlg-cuerpo .combo-lista { position: relative; top: 2px; max-height: 200px; }
.combo-lista[hidden] { display: none; }
/* Fechas AAAA-MM-DD con calendario */
.fecha-env { position: relative; display: flex; align-items: stretch; }
.fecha-env input[data-fmt] { flex: 1; padding-right: 34px; font-variant-numeric: tabular-nums; }
.btn-cal { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 34px; display: flex; align-items: center; justify-content: center; color: var(--tenue); overflow: hidden; }
.btn-cal:hover { color: var(--petroleo-2); }
/* El selector de fecha nativo, invisible y del tamaño del ícono: tocar el ícono es tocar el selector */
.cal-oculto { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; margin: 0; font-size: 16px; overflow: hidden; max-width: 100%; }
.cal-oculto::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.fecha-env input[data-fmt] { background: var(--papel); color: var(--tinta); }
.filtros .fecha-env input[data-fmt] { min-width: 130px; }
/* Mes actual en el plan */
table.plan th.mes.actual { background: var(--petroleo) !important; color: #fff; }
table.plan .hoy-tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 9px; background: #8FD3C9; color: var(--tinta); font-size: 11px; font-weight: 600; }
table.plan td.mes-actual { background-color: rgba(19, 67, 74, .07); }
/* Encabezados del mes actual con fondo opaco: al desplazar, los valores no se ven a través */
table.plan th.mes-actual { background-color: #E3EBEA; }
table.plan td.ini.mes-actual, table.plan th.ini.mes-actual { border-left: 2px solid var(--petroleo); }
table.plan td.fin.mes-actual, table.plan th.fin.mes-actual { border-right: 2px solid var(--petroleo); }
/* Filtros del plan */
.filtros.principal { margin-bottom: 8px; }
.mas-filtros { margin-bottom: 12px; }
.mas-filtros > summary { cursor: pointer; color: var(--tenue); font-size: 13px; margin-bottom: 8px; }
.mas-filtros .filtro-activo { color: var(--petroleo-2); font-weight: 600; }
.acc-alerta { display: flex; gap: 6px; }

/* Encabezado: moneda y botón de nuevo movimiento */
.acciones-barra { display: flex; align-items: center; gap: 10px; }
.acciones-barra select { background: var(--petroleo-2); color: #fff; border: 1px solid #3B7880; border-radius: var(--radio); padding: 5px 8px; }
.btn-nuevo { width: 36px; height: 36px; border-radius: 50%; border: 0; background: #8FD3C9; color: var(--tinta); font: 600 24px/1 var(--sans); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 0 2px; }
.btn-nuevo:hover { background: #B4E4DD; }
/* Cuentas: reglas de la hoja original */
td.tachada { text-decoration: line-through; color: var(--tenue); }
td.saldo-bajo { background: #DDF0E4; }
td.saldo-medio { background: #FCEFD3; }
td.saldo-alto { background: #FBE4E1; }
.campo[data-k=Fecha] small.aviso { color: var(--aviso); font-weight: 600; }
.dlg footer { flex-wrap: wrap; }

.ambar { color: var(--aviso); }
.tc .acciones { display: flex; gap: 6px; margin-top: 8px; }

/* Plan en el celular: lista sin columnas fijas */
.plan-movil { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); }
.pm-fila { padding: 9px 12px; border-top: 1px solid #E6EAE9; }
.pm-fila:first-child { border-top: 0; }
.pm-nombre { font-size: 14px; margin-bottom: 4px; overflow-wrap: anywhere; }
.pm-grupo { background: #F1F4F3; }
.pm-grupo .pm-nombre, .pm-subgrupo .pm-nombre { font-weight: 600; }
.pm-subgrupo { background: #F8FAF9; padding-left: 22px; }
.pm-sangria { padding-left: 30px; }
.pm-total { background: #E8EEED; }
.pm-total .pm-nombre { font-weight: 600; }
.pm-vals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.pm-v { display: flex; flex-direction: column; text-align: right; min-width: 0; }
.pm-v small { font-size: 11px; color: var(--tenue); }
.pm-v b { font-weight: 500; font-variant-numeric: tabular-nums; font-size: 13px; white-space: nowrap; }
.pm-nombre .flecha { margin-right: 4px; }
.pm-v b.bien { color: var(--bien); font-weight: 600; } .pm-v b.mal { color: var(--mal); font-weight: 600; } .pm-v b.parcial { color: var(--aviso); font-weight: 600; }
.pm-v b.confirmado { text-decoration: underline dotted; text-underline-offset: 3px; }
.pm-v.vencido b { background: var(--mal-s); color: var(--mal); font-weight: 600; border-radius: 4px; padding: 0 4px; }
.pm-v.proximo b { background: var(--aviso-s); color: var(--aviso); font-weight: 600; border-radius: 4px; padding: 0 4px; }
.pm-v.clic { cursor: pointer; } .pm-v.clic b { text-decoration: underline; text-decoration-color: var(--linea); text-underline-offset: 3px; }

/* Plan: buscar, seleccionar y resaltado */
.filtros.busqueda { margin-bottom: 8px; }
.marcar-env { display: flex; align-items: center; gap: 4px; }
.marcar-env #pMarcarN { min-width: 34px; text-align: center; font-size: 12px; }
table.plan tr.marcado td, .pm-fila.marcado { background: #FFF6C7 !important; }
table.plan tr.marcado-actual td, .pm-fila.marcado-actual { background: #FFE27A !important; }
a.enlace { color: inherit; text-decoration: underline; text-decoration-color: var(--linea); text-underline-offset: 3px; }
a.enlace:hover { color: var(--petroleo-2); text-decoration-color: currentColor; }
/* Encabezado de la lista del celular: se ve solo en tamaño compacto */
/* Tamaño compacto: más datos en pantalla */
body.compacto { font-size: 12.5px; }
body.compacto table.datos { font-size: 11.5px; }
body.compacto table.datos td, body.compacto table.datos th { padding: 4px 6px; }
body.compacto .pm-fila { padding: 5px 10px; }
body.compacto .pm-nombre { font-size: 12.5px; margin-bottom: 1px; }
body.compacto .pm-v small { display: none; }
body.compacto .pm-v b { font-size: 12px; }

/* Convenciones del plan */
.convenciones { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 10px; }
.convenciones .muestra { display: inline-block; min-width: 86px; text-align: right; margin-right: 10px; padding: 1px 6px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.m-bien { color: var(--bien); font-weight: 600; } .m-mal { color: var(--mal); font-weight: 600; } .m-parc { color: var(--aviso); font-weight: 600; }
.m-venc { background: var(--mal-s); color: var(--mal); font-weight: 600; } .m-prox { background: var(--aviso-s); color: var(--aviso); font-weight: 600; }
.m-conf { text-decoration: underline dotted; text-underline-offset: 3px; font-weight: 600; }
.plan-env { margin-bottom: 0; }

/* Trabajando: barra animada bajo el encabezado mientras se consulta al servidor */
body.trabajando .barra::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, #8FD3C9, transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: trabajando 1s linear infinite; }
@keyframes trabajando { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@media (prefers-reduced-motion: reduce) { body.trabajando .barra::after { animation: none; background: #8FD3C9; opacity: .6; } }
.barra { position: sticky; }
#mTabla.actualizando { opacity: .45; transition: opacity .15s; pointer-events: none; }

/* Movimientos en el celular: dos líneas por movimiento */
.lista-movs { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); }
.lm-fila { padding: 9px 12px; border-top: 1px solid #E6EAE9; cursor: pointer; }
.lm-fila:first-child { border-top: 0; }
.lm-fila:active { background: #F1F4F3; }
.lm-l1, .lm-l2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.lm-titulo { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm-valor { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.lm-valor small { color: var(--tenue); font-weight: 400; }
.lm-l2 { font-size: 12px; color: var(--tenue); margin-top: 2px; }
.lm-l2 > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lm-l2 > span:last-child { white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.lm-dup { padding: 1px 7px; }
/* Franja de diagnóstico si algo se sale de la pantalla del teléfono */
#avisoAncho { background: var(--mal); color: #fff; font-size: 12px; padding: 6px 10px; overflow-wrap: anywhere; }

/* Plan en el celular: dos líneas por concepto, como la lista de Movimientos */
.pm2 { padding: 8px 12px; border-top: 1px solid #E6EAE9; }
.pm2:first-child { border-top: 0; }
.pm2-l1, .pm2-l2 { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; min-width: 0; }
.pm2-l2 { flex-wrap: wrap; gap: 2px 12px; font-size: 12.5px; color: var(--tenue); margin-top: 2px; }
.pm2-nombre { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm2-real { flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; }
.pm2-plan, .pm2-dif { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pm2-dif.bien { color: var(--bien); font-weight: 600; } .pm2-dif.mal { color: var(--mal); font-weight: 600; } .pm2-dif.parcial { color: var(--aviso); font-weight: 600; }
.pm2-plan.vencido { background: var(--mal-s); color: var(--mal); font-weight: 600; border-radius: 4px; padding: 0 4px; }
.pm2-plan.proximo { background: var(--aviso-s); color: var(--aviso); font-weight: 600; border-radius: 4px; padding: 0 4px; }
.pm2-plan.confirmado { text-decoration: underline dotted; text-underline-offset: 3px; }
.pm2 .clic { cursor: pointer; text-decoration: underline; text-decoration-color: var(--linea); text-underline-offset: 3px; }
.pm2-grupo { background: #F1F4F3; } .pm2-grupo .pm2-nombre { font-weight: 600; }
.pm2-subgrupo { background: #F8FAF9; padding-left: 20px; } .pm2-subgrupo .pm2-nombre { font-weight: 600; }
.pm2-sangria { padding-left: 28px; }
.pm2-total { background: #E8EEED; } .pm2-total .pm2-nombre { font-weight: 600; }
.pm2.marcado { background: #FFF6C7 !important; } .pm2.marcado-actual { background: #FFE27A !important; }
body.compacto .pm2 { padding: 5px 10px; } body.compacto .pm2-l1 { font-size: 13px; } body.compacto .pm2-l2 { font-size: 11.5px; }

/* Plan en el celular como matriz: la tabla se desliza de lado dentro de su recuadro; la página no se mueve */
body.movil #pTabla .tabla-env { overflow-x: auto; overflow-y: hidden; max-height: none !important; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
body.movil table.plan { font-size: 12px; }
body.movil table.plan td, body.movil table.plan th { padding: 5px 6px; }
body.movil table.plan .fija { width: 130px; min-width: 130px !important; max-width: 130px !important; font-size: 12px; }
body.movil table.plan td.fija.sangria { padding-left: 14px; }
body.movil table.plan tr.subgrupo td.fija { padding-left: 10px; }
body.movil table.plan th.mes { font-size: 12px; }
body.movil table.plan thead th { top: auto; }
body.movil table.plan .hoy-tag { display: none; }
body.compacto.movil table.plan { font-size: 11px; }
body.compacto.movil table.plan .fija { width: 110px; min-width: 110px !important; max-width: 110px !important; font-size: 11px; }

.plegado-env { display: flex; gap: 4px; align-self: flex-end; }
.plegado-env .btn { font-size: 16px; line-height: 1; padding: 5px 9px; }
body.movil .filtros.principal .plegado-env { align-self: center; }
body.movil .filtros.busqueda label:first-child { flex: 1 1 0; }
body.movil .filtros.busqueda label:nth-child(2) { flex: 1.6 1 0; }
body.movil .filtros.principal .plegado-env .btn { padding: 8px 9px; }

/* Encabezado: esquema y configuración */
.esquema-sel { background: #8FD3C9 !important; color: var(--tinta) !important; border-color: #8FD3C9 !important; font-weight: 600; max-width: 180px; }
.btn-config { width: 36px; height: 36px; border-radius: 50%; border: 1px solid #3B7880; background: var(--petroleo-2); color: #fff; font-size: 18px; cursor: pointer; }
.btn-config:hover { background: #2A7078; }
body.movil .esquema-sel { max-width: 120px; }
body.movil .btn-config { width: 32px; height: 32px; font-size: 16px; flex: none; }
.btn.nav.activo { background: var(--petroleo); color: #fff; border-color: var(--petroleo); }

.sub-titulo { margin: 18px 0 4px; font-size: 14px; }

.auditoria { margin: 14px 0 0; padding-top: 10px; border-top: 1px dashed var(--linea); font-size: 12px; color: var(--tenue); }

/* Tres colores de vencimiento: amarillo (dentro de los días de aviso), rojo claro (urgente), rojo fuerte (hoy o vencido) */
/* (con "tr" y "tr:hover" para que el resaltado de la fila al pasar el cursor no los tape) */
table.plan tr td.niv-amarillo, table.plan tr:hover td.niv-amarillo, .pm2-plan.niv-amarillo, .muestra.niv-amarillo { background: #FCEFC7; color: #7A5300; font-weight: 600; }
table.plan tr td.niv-naranja, table.plan tr:hover td.niv-naranja, .pm2-plan.niv-naranja, .muestra.niv-naranja { background: #F9D3CE; color: #9B1C12; font-weight: 600; }
table.plan tr td.niv-rojo, table.plan tr:hover td.niv-rojo, .pm2-plan.niv-rojo, .muestra.niv-rojo { background: #C62E22; color: #fff; font-weight: 600; }
.pm2-plan.niv-amarillo, .pm2-plan.niv-naranja, .pm2-plan.niv-rojo { border-radius: 4px; padding: 0 4px; }
.chip.niv-amarillo { background: #FCEFC7; color: #7A5300; }
.chip.niv-naranja { background: #F9D3CE; color: #9B1C12; }
.chip.niv-rojo { background: #C62E22; color: #fff; }
/* Plan: diferencia y % en sus columnas, con letra más pequeña que plan y real */
table.plan td.dif, table.plan td.pct, table.plan th.dif, table.plan th.pct { font-size: .84em; }
table.plan td.pct { opacity: .9; }
/* Plan: controles en tres filas; la primera queda fija al bajar */
.plan-fija { position: sticky; top: 0; z-index: 6; background: var(--fondo, #EEF1F0); padding: 6px 0; align-items: center; }
.plan-fija .marcar-env { flex: 1 1 260px; max-width: 420px; }
.plan-fija .marcar-env input { flex: 1; min-width: 0; }
.plan-fila2 { align-items: center; margin-bottom: 6px; }
.plan-fila3 { margin-bottom: 10px; }
.plan-fila2 .btn.activo { background: var(--petroleo); color: #fff; border-color: var(--petroleo); }
body.movil .plan-fija { flex-wrap: wrap; gap: 6px; }
/* En el celular, "Seleccionar" va en su propia línea a todo el ancho (con ▲▼ al final), sin salirse de la pantalla */
body.movil .plan-fija .marcar-env { display: flex; align-items: center; gap: 6px; flex: 1 1 100%; width: 100%; max-width: none; min-width: 0; box-sizing: border-box; }
body.movil .plan-fija .marcar-env input { flex: 1 1 auto; width: auto; min-width: 0; }
/* Favoritos al registrar un movimiento */
.favoritos { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.favoritos .fav { background: var(--papel); }
/* Tablero: las primeras 6 alertas; el resto con "Ver todas" */
ul.alertas.recortada > li:nth-child(n+7) { display: none; }
#alVerTodas { margin-top: 8px; }
.patrimonio-panel .cabecera { margin: 0; border: 0; padding: 0; }
/* Otros dominios con pagos pendientes: marca en el selector */
.esquema-sel[data-alerta="rojo"] { box-shadow: 0 0 0 3px #C62E22; }
.esquema-sel[data-alerta="naranja"] { box-shadow: 0 0 0 3px #F28B7D; }
.esquema-sel[data-alerta="amarillo"] { box-shadow: 0 0 0 3px #F2C14E; }

/* Plan: franja al inicio del concepto (no toca las celdas de valores, que llevan los colores de vencimiento) */
table.plan td.fija.suma { box-shadow: inset 4px 0 0 #2E9A5B; }
table.plan td.fija.resta { box-shadow: inset 4px 0 0 #D2554A; }
.pm2-nombre.suma { border-left: 4px solid #2E9A5B; padding-left: 6px; }
.pm2-nombre.resta { border-left: 4px solid #D2554A; padding-left: 6px; }

/* Inicio: punto en lo que vence en el mes corriente */
.aviso-alerta { display: flex; align-items: center; white-space: nowrap; }
.punto-mes { color: var(--petroleo); font-size: 10px; margin-right: 5px; }
.punto-mes.oculto-reserva { visibility: hidden; } /* reserva el espacio: los avisos quedan alineados */

/* Filtros con escribir y autocompletar */
.combo-filtro { min-width: 170px; }
/* Inicio: liquidez al cierre en la gráfica de flujo; tarjetas en cuatro datos */
.cierre-flujo { margin: 0 0 6px; font-size: 13px; }
.tc .tc-pago { grid-template-columns: repeat(2, 1fr); }

.ciclo.error-corte { color: var(--mal); font-weight: 600; }
.ciclo.error-corte small { font-weight: 400; }

.total-movs { margin: 10px 2px 0; font-size: 13px; }

.icono-btn { background: none; border: 0; padding: 6px; margin-left: 6px; color: var(--tenue); cursor: pointer; line-height: 0; border-radius: 6px; vertical-align: middle; }
.icono-btn:hover, .icono-btn:active { color: var(--tinta); background: var(--fondo); }

.aviso-dup { background: #FCEFC7; color: #6B4A00; border-left: 4px solid #E0A800; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; }
.ojo { color: inherit; }

/* Primer uso */
.inicio { max-width: 640px; margin: 24px auto; display: grid; gap: 16px; }
.inicio h2 { font-size: 28px; }
.inicio .sub { margin: 0; }
.inicio details summary { cursor: pointer; }
a { color: var(--petroleo-2); }

/* Tablero */
.cabecera { display: grid; grid-template-columns: max-content 1fr; gap: 28px; align-items: end;
  padding-bottom: 18px; border-bottom: 1px solid var(--linea); margin-bottom: 20px; }
.patrimonio .etq { display: block; color: var(--tenue); }
.patrimonio strong { font: 600 44px/1 var(--cond); letter-spacing: -.01em; white-space: nowrap; }
.patrimonio .mon { color: var(--tenue); margin-left: 6px; }
.cifras { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin: 0; }
.cifras div { border-left: 3px solid var(--linea); padding-left: 10px; }
.cifras dt { color: var(--tenue); font-size: 12px; }
.cifras dd { margin: 0; font: 600 19px/1.3 var(--cond); font-variant-numeric: tabular-nums; }
.cifras .neg dd { color: var(--mal); }

.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 20px; margin-bottom: 20px; }
.panel { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 16px 18px; min-width: 0; overflow-x: auto; }
.panel.ancho { grid-column: 1 / -1; }
@media (min-width: 900px) { .panel.alertas-panel { grid-column: span 2; } }
.alertas-panel .alertas { max-height: 520px; }
.panel.tarjetas { max-height: 600px; overflow-y: auto; }

.comparativo { width: 100%; border-collapse: collapse; }
.comparativo th { text-align: left; font-weight: 500; color: var(--tenue); font-size: 12px; padding: 4px 6px; }
.comparativo td { padding: 7px 6px; border-top: 1px solid var(--linea); }

.indicador { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 0; border-top: 1px solid var(--linea); }
.indicador:first-of-type { border-top: 0; }
.indicador b { font: 600 18px/1.2 var(--cond); font-variant-numeric: tabular-nums; text-align: right; }
.indicador small { grid-column: 1 / -1; color: var(--tenue); }
.indicador.bien b { color: var(--bien); } .indicador.mal b { color: var(--mal); } .indicador.aviso b { color: var(--aviso); }

.barra-dist { margin: 10px 0; }
.barra-dist .fila { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.barra-dist .pista { position: relative; height: 10px; background: var(--fondo); border-radius: 5px; overflow: hidden; }
.barra-dist .valor { position: absolute; inset: 0 auto 0 0; background: var(--petroleo-2); border-radius: 5px; }
.barra-dist .meta { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--tinta); }

.alertas { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
.alertas li { display: grid; grid-template-columns: 150px 1fr auto auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--linea); }
.alertas li:first-child { border-top: 0; }
.alertas .que small { display: block; color: var(--tenue); }

.alertas .chip { justify-self: start; }
.chip { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.chip.vencido { background: var(--mal-s); color: var(--mal); }
.chip.proximo { background: var(--aviso-s); color: var(--aviso); }
.chip.pendiente { background: var(--fondo); color: var(--tenue); }
.chip.realizado { background: var(--bien-s); color: var(--bien); }

/* Tablas de datos */
.tabla-env { overflow: auto; background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); max-height: calc(100vh - 210px); }
table.datos { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.datos th { position: sticky; top: 0; background: #F6F8F7; z-index: 2; text-align: left; font-weight: 600; padding: 7px 8px; border-bottom: 1px solid var(--linea); white-space: nowrap; }
table.datos td { padding: 6px 8px; border-bottom: 1px solid #E6EAE9; vertical-align: top; }
table.datos tr:hover td { background: #F8FAF9; }
table.datos td.acc { white-space: nowrap; text-align: right; }
.neg { color: var(--mal); }
.pos { color: var(--bien); }
.tenue { color: var(--tenue); }

/* Plan vs real */
.plan-env { max-height: calc(100vh - 190px); }
table.plan { font-size: 12.5px; }
table.plan th, table.plan td { border-right: 1px solid #E6EAE9; }
table.plan thead tr:nth-child(2) th { top: 31px; font-weight: 500; color: var(--tenue); text-align: right; }
table.plan th.mes { text-align: center; border-left: 2px solid var(--linea); }
table.plan th.mes.actual { background: #E2EFEC; }
table.plan th.mes.resumen { background: #E8EEED; }
table.plan .fija { position: sticky; left: 0; z-index: 3; background: var(--papel); min-width: 230px; max-width: 300px; }
/* El concepto siempre en una línea: si no cabe se corta con "…" (nombre completo al pasar el mouse); filas del mismo alto */
table.plan td.fija { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm2-nombre { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
table.plan thead .fija { z-index: 4; background: #F6F8F7; }
table.plan td.ini, table.plan th.ini { border-left: 2px solid var(--linea); }
table.plan tr.grupo td { background: #F1F4F3; font-weight: 600; }
table.plan tr.grupo td.fija { background: #F1F4F3; }
table.plan tr.subgrupo td { background: #F8FAF9; font-weight: 600; color: var(--tinta); }
table.plan tr.subgrupo td.fija { background: #F8FAF9; padding-left: 22px; }
table.plan td.fija.sangria { padding-left: 36px; }
table.plan td.plegable { cursor: pointer; user-select: none; }
table.plan td.plegable:hover { color: var(--petroleo-2); }
table.plan .flecha { display: inline-block; width: 14px; color: var(--tenue); }
table.plan tr.total td { background: #E8EEED; font-weight: 600; }
table.plan tr.total td.fija { background: #E8EEED; }
/* Solo la diferencia lleva color, en texto: verde mejor, rojo peor, ámbar pagado en parte */
/* (con "tr" para que el estilo de grupos y subgrupos no les quite el color) */
table.plan tr td.bien { color: var(--bien); font-weight: 600; }
table.plan tr td.mal { color: var(--mal); font-weight: 600; }
/* Estado del valor planeado como en el tablero: fondo rojo suave si venció sin pago, ámbar si está próximo */
table.plan td.vencido { background: var(--mal-s); color: var(--mal); font-weight: 600; }
table.plan td.proximo { background: var(--aviso-s); color: var(--aviso); font-weight: 600; }
table.plan td.clic { cursor: pointer; }
table.plan td.confirmado { text-decoration: underline dotted; text-underline-offset: 3px; font-weight: 600; }
table.plan tr td.parcial { color: var(--aviso); font-weight: 600; }
.alertas .parcial-txt { color: var(--aviso); font-weight: 600; }
.leyenda .l-conf::before { background: none; border-bottom: 2px dotted var(--tinta); border-radius: 0; }
.leyenda .l-parc::before { background: var(--aviso); }
table.plan td.clic:hover { text-decoration: underline; }
.leyenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--tenue); margin: 8px 0 0; }
.leyenda span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.leyenda .l-bien::before { background: var(--bien); }
.leyenda .l-mal::before { background: var(--mal); }
.leyenda .l-venc::before { background: var(--mal-s); border: 1px solid var(--mal); }
.leyenda .l-prox::before { background: var(--aviso-s); border: 1px solid #D99A2B; }

/* Diálogo y formularios */
dialog { border: 0; border-radius: 10px; padding: 0; width: min(760px, calc(100% - 16px)); max-height: 92vh; box-shadow: 0 18px 50px rgba(19, 67, 74, .28); }
dialog::backdrop { background: rgba(24, 36, 46, .45); }
.dlg { display: flex; flex-direction: column; max-height: 92vh; }
.dlg header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--linea); }
.dlg header h2 { font-size: 18px; margin: 0; }
.dlg .cerrar { border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--tenue); }
.dlg-cuerpo { padding: 16px 20px; overflow: auto; }
.dlg footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--linea); background: #F8FAF9; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.campo { display: flex; flex-direction: column; gap: 4px; }
.campo[hidden] { display: none; }
.campo.doble { grid-column: 1 / -1; }
.campo > span { font-size: 12px; color: var(--tenue); }
.campo input, .campo select, .campo textarea { padding: 7px 9px; border: 1px solid var(--linea); border-radius: var(--radio); background: var(--papel); width: 100%; }
.campo input[type=checkbox] { width: auto; }
.campo textarea { min-height: 60px; resize: vertical; }
.campo small { color: var(--tenue); font-size: 12px; }
.campo small.aviso { color: var(--mal); }
.campo small.nota-campo:empty { display: none; }
.campo input:disabled { background: var(--fondo); color: var(--tinta); border-style: dashed; }
.campo small.aviso:empty { display: none; }
.campo input[inputmode=decimal] { text-align: right; font-variant-numeric: tabular-nums; }
.nota { background: var(--fondo); border-radius: var(--radio); padding: 10px 12px; font-size: 13px; color: var(--tenue); margin-bottom: 12px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--tinta); color: #fff;
  padding: 10px 18px; border-radius: var(--radio); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100% - 24px); }
#toast.ver { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--mal); }

/* Celular: la clase "movil" la pone la app según la pantalla del teléfono (no según el ancho del marco de Google) */
/* Encabezado compacto: una sola fila, pestañas deslizables y sin quedar fijo (evita saltos al bajar en el celular) */
  /* Encabezado: moneda y "+" arriba a la derecha; pestañas en dos filas (nada se desplaza de lado) */
  body.movil .barra { position: static; gap: 4px 8px; padding: 6px 10px 0; min-height: 0; flex-wrap: wrap; }
  body.movil .marca { display: none; }
  body.movil .acciones-barra { flex: 1 1 100%; justify-content: flex-end; min-width: 0; }
  /* El selector de dominio toma el ancho de su opción más larga: se limita para no empujar el encabezado */
  body.movil .acciones-barra .esquema-sel { margin-right: auto; min-width: 0; max-width: 175px; flex: 0 1 auto; text-overflow: ellipsis; }
  body.movil .acciones-barra { order: 0; }
  body.movil #tabs { order: 1; flex: 1 1 100%; flex-wrap: wrap; overflow: visible; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
  body.movil #tabs button { padding: 9px 4px 8px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  body.movil .acciones-barra { gap: 6px; }
  body.movil .acciones-barra select { padding: 4px 6px; }
  body.movil .btn-nuevo { width: 32px; height: 32px; font-size: 22px; flex: none; }
  /* Alertas en dos filas: estado y valor; nombre y botón */
  body.movil .alertas li { grid-template-columns: 1fr auto !important; row-gap: 6px; }
  body.movil .alertas li .aviso-alerta { grid-row: 1; grid-column: 1; }
  body.movil .alertas li .num { grid-row: 1; grid-column: 2; font-weight: 600; }
  body.movil .alertas li .que { grid-row: 2; grid-column: 1; min-width: 0; overflow-wrap: anywhere; }
  body.movil .alertas li .acc-alerta { grid-row: 2; grid-column: 2; align-self: center; }
  body.movil main { padding: 12px; }
  /* Resumen del mes del tablero: más compacto para caber en la pantalla */
  body.movil .comparativo { table-layout: fixed; }
  body.movil .comparativo th, body.movil .comparativo td { padding: 6px 3px; font-size: 12.5px; overflow-wrap: anywhere; }
  body.movil .comparativo td.n, body.movil .comparativo th.n { white-space: nowrap; letter-spacing: -.01em; }
  body.movil .comparativo tr > :first-child { width: 30%; }
  /* Tablas como tarjetas: en el celular nada puede ser más ancho que la pantalla */
  body.movil table.datos:not(.plan) thead { display: none; }
  body.movil table.datos:not(.plan), body.movil table.datos:not(.plan) tbody, body.movil table.datos:not(.plan) tr { display: block; width: 100%; }
  body.movil table.datos:not(.plan) tr { border-bottom: 1px solid var(--linea); padding: 8px 0; }
  body.movil table.datos:not(.plan) td { display: block; border: 0; padding: 2px 12px; text-align: right; white-space: normal; overflow-wrap: anywhere; min-width: 0; }
  body.movil table.datos:not(.plan) td::after { content: ''; display: table; clear: both; }
  body.movil table.datos:not(.plan) td::before { content: attr(data-l); float: left; max-width: 42%; margin-right: 10px; color: var(--tenue); font-size: 12px; text-align: left; }
  body.movil table.datos:not(.plan) td:empty { display: none; }
  body.movil table.datos:not(.plan) td[colspan] { display: block; text-align: left; padding-top: 6px; }
  body.movil table.datos:not(.plan) td[colspan]::before { content: none; }
  body.movil table.datos:not(.plan) td.acc { padding-top: 6px; }
  body.movil table.datos:not(.plan) td.acc .btn { margin-left: 6px; }
  body.movil table.datos:not(.plan) td.acc::before { content: none; }
  body.movil table.datos:not(.plan) td.n { font-variant-numeric: tabular-nums; }
  body.movil .tabla-env { overflow: visible; max-height: none !important; }
  /* Nada puede ser más ancho que la pantalla */
  body.movil main, body.movil .vista, body.movil .panel, body.movil .filtros, body.movil .plan-movil, body.movil .tabla-env { max-width: 100%; min-width: 0; }
  body.movil .filtros select, body.movil .filtros input { min-width: 0; max-width: 100%; }
  body.movil .filtros label { min-width: 0; max-width: 100%; }
  body.movil #toast { max-width: calc(100% - 24px); }
  /* Buscar y Seleccionar en una sola fila */
  body.movil .filtros.busqueda { flex-wrap: nowrap; gap: 8px; }
  body.movil .filtros.busqueda label { flex: 1; min-width: 0; }
  body.movil .filtros.busqueda .lbl { display: none; }
  body.movil .filtros.busqueda input { min-width: 0 !important; width: 100%; }
  body.movil .marcar-env { gap: 2px; }
  body.movil .marcar-env #pMarcarN { min-width: 26px; font-size: 11px; flex: none; }
  body.movil .marcar-env input { flex: 1; }
  body.movil .marcar-env .btn.mini { padding: 4px 6px; }

  /* Plan en el celular: un mes a la vez, sin %, conceptos más angostos */
  body.movil .filtros.principal { align-items: center; flex-wrap: nowrap; gap: 6px; }
  body.movil .filtros.principal .nav { padding: 6px 10px; flex: none; }
  body.movil .mes-movil { font: 600 17px/1 var(--cond); font-variant-numeric: tabular-nums; flex: 1; min-width: 0; text-align: center; }
  body.movil .mes-movil small { display: block; font: 600 11px var(--sans); color: var(--petroleo-2); margin-top: 2px; }

  body.movil .plan-env { max-height: none; }
  body.movil .cabecera { grid-template-columns: 1fr; }
  body.movil .patrimonio strong { font-size: 28px; white-space: normal; overflow-wrap: anywhere; }
  body.movil .cabecera { grid-template-columns: minmax(0, 1fr); }
  body.movil .patrimonio, body.movil .cifras { min-width: 0; }
  body.movil .cifras { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.movil .cifras dd { font-size: 16px; overflow-wrap: anywhere; }
  body.movil .rejilla { grid-template-columns: 1fr; }
  body.movil .form { grid-template-columns: 1fr; }

@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

/* ---------- Versión web ---------- */
.ingreso { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--fondo, #EEF1F0); padding: 20px; }
.ingreso[hidden] { display: none; }
.ingreso-caja { background: var(--papel); border: 1px solid var(--linea); border-radius: 12px; padding: 32px 28px; max-width: 380px; width: 100%;
  text-align: center; display: grid; gap: 12px; justify-items: center; }
.ingreso-caja h1 { margin: 0; font: 600 24px/1.2 var(--cond); color: var(--petroleo); }
.ingreso-logo { width: 64px; height: 64px; border-radius: 16px; background: var(--petroleo); color: #8FD3C9; font: 700 38px/64px Arial, sans-serif; }
.ingreso-caja .btn { min-width: 220px; justify-content: center; }
.aviso-caja { background: var(--aviso-s); color: var(--aviso); border-radius: var(--radio); padding: 8px 10px; }

/* Solo lectura: sin botones que cambien datos (la app y las reglas de Google también lo impiden) */
body.solo-lectura #btnNuevo, body.solo-lectura #dlg:not(.libre) #dlgGuardar, body.solo-lectura #dlgBorrar, body.solo-lectura #dlgPrestamo,
body.solo-lectura #exNueva, body.solo-lectura #ctNueva, body.solo-lectura [data-bx], body.solo-lectura [data-bc],
body.solo-lectura button[data-alerta], body.solo-lectura button[data-valor], body.solo-lectura button[data-duplicar], body.solo-lectura .lm-dup,
body.solo-lectura #ocPagar, body.solo-lectura #dlgDuplicar, body.solo-lectura #prInc, body.solo-lectura [data-cajuste], body.solo-lectura #ocConfirmar, body.solo-lectura #ocQuitar, body.solo-lectura #prNuevo, body.solo-lectura #cNueva,
body.solo-lectura [data-pv], body.solo-lectura [data-cmeta], body.solo-lectura #elAgregar, body.solo-lectura [data-el-elim],
body.solo-lectura [data-el-nombre], body.solo-lectura #wImportar, body.solo-lectura .favoritos { display: none !important; }
.compartir { margin-top: 14px; }

.param-dominio { margin-top: 14px; }

/* Configuración en pestañas */
.cfg-encabezado { margin: 0 0 10px; font-size: 15px; }
.cfg-tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 14px; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.cfg-tabs button { flex: none; background: var(--papel); border: 1px solid var(--linea); border-radius: 999px; padding: 7px 14px; cursor: pointer; color: var(--tinta); font: inherit; }
.cfg-tabs button.activo { background: var(--petroleo); border-color: var(--petroleo); color: #fff; }
.cifras-cfg { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 6px 0 0; }
.cifras-cfg dt { font-size: 12px; color: var(--tenue); }
.cifras-cfg dd { margin: 0; font-weight: 600; }

/* Lista de dominios: el nombre usa el espacio; los botones, solo lo que necesitan */
table.tabla-dominios, body.movil table.tabla-dominios { width: 100%; table-layout: auto; }
table.tabla-dominios td:first-child { width: auto; overflow-wrap: break-word; word-break: normal; }
table.tabla-dominios td.acc { width: 1%; white-space: nowrap; text-align: right; }
.chip svg { margin-right: 2px; }
