:root {
  --azul: #1b5e9e; --azul-osc: #14486f; --fondo: #f3f6fa; --card: #fff; --texto: #1d2733; --sec: #66758a;
  --borde: #dde4ee; --verde: #1e8e5a; --rojo: #c9372c; --ambar: #b7791f; --radio: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body { margin: 0; background: var(--fondo); color: var(--texto); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

/* encabezado */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 6px; background: var(--azul); color: #fff;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; }
.top h1 { flex: 1; margin: 0; font-size: 1.25rem; }
.sync { background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 99px; padding: 6px 10px; font-size: .75rem; white-space: nowrap; }
.sync.ok { background: rgba(255,255,255,.16); } .sync.off { background: #b7791f; } .sync.error { background: var(--rojo); } .sync.sync { background: rgba(255,255,255,.3); }
.btn-icono { background: none; border: 0; font-size: 1.3rem; min-width: 44px; min-height: 44px; border-radius: 10px; }
.btn-icono.claro { color: #fff; }

main { padding: 12px; max-width: 720px; margin: 0 auto; }

/* filtros y chips */
.filtros { display: flex; gap: 8px; margin-bottom: 10px; }
.buscar, select, input[type=date], .campo input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 12px; background: #fff; }
.filtros select { max-width: 48%; }
.campo input:disabled { background: #eef1f5; color: #9aa6b5; }
.filtros select.ancho { max-width: none; }
/* período: mes + calendarios desde/hasta */
.periodo { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.fechas { display: flex; gap: 8px; width: 100%; }
.fechas label { flex: 1; min-width: 0; }
.fechas span { display: block; font-size: .72rem; color: var(--sec); font-weight: 600; margin-bottom: 2px; }
.fechas input[type=date] { min-height: 42px; padding: 8px 10px; }
.limpiar { border: 0; background: none; color: var(--azul); font-weight: 700; font-size: .82rem; padding: 4px 2px; }
.resumen.tres b { font-size: .95rem; }
/* panel INICIO */
.cuadros { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.cuadro { text-align: left; background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio); padding: 10px 12px; min-height: 76px; }
.cuadro small { display: block; color: var(--sec); font-size: .75rem; font-weight: 600; }
.cuadro b { display: block; font-size: 1.05rem; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cuadro span { display: block; color: var(--sec); font-size: .72rem; }
.cuadro.v { box-shadow: inset 4px 0 0 #1b5e9e; } .cuadro.c { box-shadow: inset 4px 0 0 #c8642a; }
.cuadro:active { background: #eef3f9; }
.panel { background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio); padding: 12px; margin-bottom: 12px; }
.panel h3 { margin: 0 0 8px; font-size: .95rem; }
.leyenda { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; font-size: .78rem; margin-bottom: 6px; }
.leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.grafico { display: block; width: 100%; height: auto; }
.serie-v { fill: #1b5e9e; background: #1b5e9e; } .serie-c { fill: #c8642a; background: #c8642a; }
.grafico .grilla { stroke: #e6ebf2; stroke-width: 1; }
.grafico .eje { fill: var(--sec); font-size: 8px; } .grafico .eje.fuerte { fill: var(--texto); font-weight: 700; }
.grafico .toque { fill: transparent; cursor: pointer; } .grafico .toque:active { fill: rgba(27,94,158,.08); }
.grupo-cuentas { margin-bottom: 4px; } .det.cab { border-bottom-width: 2px; } .det.cab span { color: var(--texto); font-weight: 700; }
.panel .det[data-accion] { cursor: pointer; } .panel .det[data-accion] span { padding-left: 8px; }
.panel input[type=date] { width: 100%; }
.descargas { display: flex; align-items: center; gap: 8px; margin: -4px 0 12px; }
.descargas .sec { flex: 1; }
.descargas .btn.chico { margin-left: 0; }
.chips { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { flex: none; min-height: 40px; padding: 8px 14px; border-radius: 99px; border: 1px solid var(--borde); background: #fff; font-size: .85rem; font-weight: 600; color: var(--sec); }
.chip.on { background: var(--azul); border-color: var(--azul); color: #fff; }
.chip .ico { margin-right: 4px; }

/* resumen */
.resumen { display: flex; gap: 10px; margin-bottom: 12px; }
.resumen > div { flex: 1; background: var(--card); border-radius: var(--radio); padding: 10px 12px; border: 1px solid var(--borde); }
.resumen small { display: block; color: var(--sec); font-size: .75rem; }
.resumen b { font-size: 1.1rem; }

/* tarjetas */
.card { background: var(--card); border: 1px solid var(--borde); border-radius: var(--radio); padding: 12px; margin-bottom: 10px; cursor: pointer; }
.card:active { background: #eef3f9; }
.card.inactiva { opacity: .55; }
.fila { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 2px; }
.fila.sec, .sec { color: var(--sec); font-size: .82rem; }
.titulo { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.monto { font-weight: 700; white-space: nowrap; }
.pos { color: var(--verde); } .neg { color: var(--rojo); }
.vacio { text-align: center; color: var(--sec); padding: 36px 16px; }
.badge { font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: #e8eef6; color: var(--sec); }
.badge.pendiente { background: #fdf0d8; color: var(--ambar); } .badge.parcial { background: #dfeafa; color: var(--azul); }
.badge.cerrada { background: #def3e8; color: var(--verde); }

/* botones */
.btn { min-height: 46px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--azul); background: #fff; color: var(--azul); font-weight: 700; }
.btn.chico { min-height: 36px; padding: 6px 12px; background: var(--azul); color: #fff; font-size: .8rem; margin-left: auto; }
.btn.grande { display: block; width: 100%; background: var(--azul); color: #fff; margin-top: 12px; }
.btn.peligro { display: block; width: 100%; border-color: var(--rojo); color: var(--rojo); margin-top: 12px; }
.btn:disabled { opacity: .5; }
.fab { position: fixed; right: 16px; bottom: calc(88px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 50%; border: 0;
  background: var(--azul); color: #fff; font-size: 2rem; line-height: 1; box-shadow: 0 4px 12px rgba(0,0,0,.28); z-index: 9; }

/* barra inferior */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: #fff; border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; border: 0; background: none; color: var(--sec);
  font-size: .75rem; font-weight: 700; letter-spacing: .02em; min-height: 58px; }
.tab .ico { font-size: 1.60rem; line-height: 1.1; }
.tab.on { color: var(--azul); box-shadow: inset 0 3px 0 var(--azul); }

/* detalle de cuenta */
.detalle-top { display: flex; align-items: center; gap: 4px; }
.detalle-top h2 { flex: 1; margin: 0; font-size: 1.1rem; text-align: center; }
.saldo-grande { text-align: center; padding: 10px 0 14px; }
.saldo-grande small { display: block; color: var(--sec); } .saldo-grande b { font-size: 2rem; }
.acciones { display: flex; gap: 8px; margin-bottom: 14px; } .acciones .btn { flex: 1; padding: 8px 4px; font-size: .82rem; }

/* hojas emergentes */
.velo { position: fixed; inset: 0; background: rgba(15,25,40,.45); z-index: 20; }
.hoja { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.hoja-top { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff; }
.hoja-top h2 { margin: 0; font-size: 1.1rem; } .hoja h3 { margin: 16px 0 4px; font-size: .95rem; }
.campo { display: block; margin-top: 10px; } .campo span { display: block; font-size: .8rem; color: var(--sec); margin-bottom: 4px; font-weight: 600; }
.dos { display: flex; gap: 10px; } .dos .campo { flex: 1; min-width: 0; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: .9rem; }
.check input { width: 22px; height: 22px; }
.error { color: var(--rojo); font-size: .85rem; min-height: 1.2em; margin: 8px 0 0; font-weight: 600; }
.det { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--borde); font-size: .92rem; }
.det span { color: var(--sec); } .det b { text-align: right; word-break: break-word; }
.hoja .btn:not(.grande):not(.peligro) { width: 100%; margin-top: 10px; }

/* emisión de facturas */
.oculto { display: none; }
.item { border: 1px solid var(--borde); border-radius: 12px; padding: 10px; margin-top: 10px; background: #fafcff; }
.item-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.item > input, .item select { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--borde); border-radius: 10px; background: #fff; }
.item .campo input { min-height: 44px; }
.tres { display: flex; gap: 8px; } .tres .campo { flex: 1; min-width: 0; }
.emi-totales { margin-top: 14px; padding-top: 6px; border-top: 2px solid var(--borde); }
.det.total { font-size: 1.1rem; } .det.total b { color: var(--azul); }
.aviso-emision { margin: 12px 0 4px; padding: 10px 12px; border-radius: 12px; background: #eef3f9; font-size: .9rem; }
.aviso-emision.autorizada { background: #def3e8; color: #14633f; } .aviso-emision.rechazada, .aviso-emision.revisar { background: #fbe4e1; color: #8f2219; }
.aviso-emision.en_proceso, .aviso-emision.reintentable { background: #fdf0d8; color: #7a5413; }
.procesando { text-align: center; padding: 28px 12px; }
.spinner { width: 44px; height: 44px; margin: 0 auto 14px; border: 5px solid var(--borde); border-top-color: var(--azul); border-radius: 50%; animation: giro 1s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.btn small { font-weight: 400; color: var(--sec); }
.aviso-emision .btn { display: block; width: 100%; margin-top: 8px; }
details.otras { margin-top: 14px; } details.otras summary { cursor: pointer; color: var(--sec); font-size: .85rem; padding: 6px 0; }
.numeracion { margin-top: 8px; } .numeracion .btn { min-height: 38px; padding: 6px 12px; font-size: .85rem; margin-top: 6px; }
.pasos { padding-left: 20px; font-size: .9rem; } .pasos li { margin-bottom: 8px; }
textarea.csr { width: 100%; margin: 6px 0; padding: 8px; border: 1px solid var(--borde); border-radius: 10px; font-family: ui-monospace, monospace; font-size: .65rem; resize: none; }

/* pantalla de entrada (ingreso): igual que la de las otras apps de IGS, lila a pantalla completa */
.entrada { position: fixed; inset: 0; z-index: 30; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe); }
.entrada-caja { width: 100%; max-width: 420px; background: #fff; border-radius: 24px; padding: 22px 18px 20px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.entrada-caja h1 { font-size: 1.3rem; margin: 0 0 4px; text-align: center; color: var(--texto); }
.entrada-caja .sec { text-align: center; margin: 0 0 8px; }
.entrada-logo { display: block; width: 78%; max-width: 280px; height: auto; margin: 0 auto 10px; }
.entrada-caja .btn.grande { background: #6c5ce7; border-color: #6c5ce7; }
.entrada-caja .sec.centro { text-align: center; margin: 0 0 10px; }
.entrada-caja .btn.grande + .sec.centro { margin: 12px 0 0; }
.entrada-tabs { display: flex; gap: 8px; margin: 4px 0 6px; }
.entrada-tabs button { flex: 1; min-height: 44px; border-radius: 12px; border: 2px solid #e4e0f7; background: #fff; color: #2d2a4a; font-weight: 700; }
.entrada-tabs button.on { background: #6c5ce7; border-color: #6c5ce7; color: #fff; }
.entrada-caja .enlace { display: block; width: 100%; margin-top: 12px; border: 0; background: none; color: #6c5ce7; font-weight: 700; text-decoration: underline; min-height: 40px; }
.entrada-caja .ok { color: #1c7d4d; font-size: .88rem; font-weight: 600; margin: 8px 0 0; }
.entrada-caja .mensaje { margin: 8px 0; line-height: 1.4; }
.entrada-caja .error { text-align: center; }
/* aviso de la cuenta (prueba / solo lectura) arriba de cada pantalla */
.aviso-cuenta { background: #efeafd; color: #3b2f9a; border-radius: 12px; padding: 9px 12px; margin: 0 0 10px; font-size: .88rem; font-weight: 600; }
.aviso-cuenta.rojo { background: #fde8e6; color: #b3261e; }

/* aviso */
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: #1d2733; color: #fff;
  padding: 10px 18px; border-radius: 99px; font-size: .9rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 30; max-width: 90vw; }
.toast.on { opacity: 1; transform: translate(-50%, 0); } .toast.error { background: var(--rojo); }
