/* ==========================================================================
   App Clientes Netlatin — estilos
   Tokens de color arriba (claro / oscuro); todo lo demás sale de ellos.
   ========================================================================== */
:root {
  --prim: #204080; --marca: #204080; --marca-2: #2c56a8; --acento: #38C6E8; --noche: #0E1F3D;
  --fondo: #F2F5FA; --sup: #FFFFFF; --sup-2: #F7F9FC; --tinta: #13213B; --tenue: #5B6B85; --borde: #DCE3EE;
  --ok: #15803d; --ok-fondo: #dcfce7; --alerta: #b45309; --alerta-fondo: #fef3c7; --mal: #b91c1c; --mal-fondo: #fee2e2;
  --sombra: 0 1px 2px rgba(14,31,61,.06), 0 6px 20px rgba(14,31,61,.06);
  --r: 18px; --r-chico: 12px;
  --barra: 64px;
  font-family: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --prim: #1d3a78; --marca: #7aa2f7; --marca-2: #7aa2f7; --acento: #4fd1ee; --noche: #07101f;
  --fondo: #0A1528; --sup: #12213C; --sup-2: #172a4b; --tinta: #E7EDF7; --tenue: #93A3BE; --borde: #22355A;
  --ok: #4ade80; --ok-fondo: #0f2e1d; --alerta: #fbbf24; --alerta-fondo: #33270b; --mal: #f87171; --mal-fondo: #3a1515;
  --sombra: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark; } }
:root[data-theme="dark"] {
  --prim: #1d3a78; --marca: #7aa2f7; --marca-2: #7aa2f7; --acento: #4fd1ee; --noche: #07101f;
  --fondo: #0A1528; --sup: #12213C; --sup-2: #172a4b; --tinta: #E7EDF7; --tenue: #93A3BE; --borde: #22355A;
  --ok: #4ade80; --ok-fondo: #0f2e1d; --alerta: #fbbf24; --alerta-fondo: #33270b; --mal: #f87171; --mal-fondo: #3a1515;
  --sombra: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--fondo); color: var(--tinta); font-size: 16px; line-height: 1.45; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--marca); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--acento); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Estructura ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }
.arranque { flex: 1; min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; background: var(--prim); color: #fff; }
.marca-txt { font-weight: 800; font-size: 2.1rem; letter-spacing: -.02em; }
.marca-txt b { color: var(--acento); font-weight: 800; }
.girando { width: 28px; height: 28px; border-radius: 50%; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; animation: gira .8s linear infinite; }
.girando.oscuro { border-color: var(--borde); border-top-color: var(--marca); }
@keyframes gira { to { transform: rotate(360deg); } }

.pantalla { flex: 1; display: flex; flex-direction: column; padding-bottom: calc(var(--barra) + env(safe-area-inset-bottom, 0px) + 12px); }
.cab { padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px 18px; display: flex; align-items: center; gap: 12px; }
.cab h1 { margin: 0; font-size: 1.45rem; font-weight: 800; letter-spacing: -.01em; text-wrap: balance; }
.cab .sub { color: var(--tenue); font-size: .9rem; }
.cab-marca { background: var(--prim); color: #fff; padding-bottom: 56px; border-radius: 0 0 28px 28px; }
.cab-marca .sub { color: rgba(255,255,255,.78); }
.cab-marca .marca-txt { font-size: 1.25rem; }
.cuerpo { padding: 0 16px; display: flex; flex-direction: column; gap: 14px; }
.cab-marca + .cuerpo { margin-top: -40px; }

/* ---------- Tarjetas ---------- */
.tarjeta { background: var(--sup); border: 1px solid var(--borde); border-radius: var(--r); padding: 16px; box-shadow: var(--sombra); min-width: 0; }
.tarjeta h2 { margin: 0 0 6px; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tenue); }
.monto { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.fila { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fila.sep { justify-content: space-between; }
.mt { margin-top: 12px; }
.tenue { color: var(--tenue); }
.chico { font-size: .86rem; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.chip.ok { background: var(--ok-fondo); color: var(--ok); }
.chip.alerta { background: var(--alerta-fondo); color: var(--alerta); }
.chip.mal { background: var(--mal-fondo); color: var(--mal); }
.chip.neutro { background: var(--sup-2); color: var(--tenue); }
.punto { width: 9px; height: 9px; border-radius: 50%; background: currentColor; flex: none; }
.punto.late { animation: late 1.6s ease-in-out infinite; }
@keyframes late { 50% { opacity: .35; } }

/* ---------- Botones ---------- */
.btn { border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; text-decoration: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.prim { background: var(--prim); color: #fff; }
.btn.sec { background: var(--sup-2); color: var(--tinta); border: 1px solid var(--borde); }
.btn.lineal { background: transparent; color: var(--marca); padding: 8px 4px; min-height: 0; }
.btn.ancho { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn .girando { width: 18px; height: 18px; border-width: 2px; }
.botones { display: flex; gap: 10px; }
.botones > * { flex: 1; }

/* ---------- Accesos rápidos ---------- */
.accesos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.acceso { text-decoration: none; background: var(--sup); border: 1px solid var(--borde); border-radius: var(--r-chico); padding: 14px 8px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; font-size: .82rem; font-weight: 600; color: var(--tinta); position: relative; min-height: 92px; }
.acceso .ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--sup-2); color: var(--marca); }
.acceso .ic svg { width: 22px; height: 22px; }
.acceso .pronto { position: absolute; top: 6px; right: 6px; font-size: .6rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--tenue); background: var(--sup-2); border-radius: 999px; padding: 2px 6px; }

/* ---------- Listas ---------- */
.lista { background: var(--sup); border: 1px solid var(--borde); border-radius: var(--r); overflow: hidden; box-shadow: var(--sombra); }
.item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid var(--borde); min-width: 0; }
.item:last-child { border-bottom: 0; }
.item .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.item .ic svg { width: 20px; height: 20px; }
.ic.factura { background: var(--alerta-fondo); color: var(--alerta); }
.ic.pago { background: var(--ok-fondo); color: var(--ok); }
.ic.otro { background: var(--sup-2); color: var(--tenue); }
.item .txt { flex: 1; min-width: 0; }
.item .tit { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .det { color: var(--tenue); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .imp { text-align: right; font-weight: 700; white-space: nowrap; }
.imp.mas { color: var(--ok); }
.btn-pdf { border: 1px solid var(--borde); background: var(--sup-2); color: var(--marca); border-radius: 10px; width: 40px; height: 40px; display: grid; place-items: center; flex: none; }
.btn-pdf svg { width: 20px; height: 20px; }
.mes { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tenue); margin: 8px 4px -4px; }
.filtros { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.filtros button { border: 1px solid var(--borde); background: var(--sup); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: .88rem; white-space: nowrap; }
.filtros button.sel { background: var(--prim); border-color: var(--prim); color: #fff; }
.vacio { text-align: center; color: var(--tenue); padding: 28px 16px; }
.esqueleto { background: linear-gradient(90deg, var(--sup-2), var(--borde), var(--sup-2)); background-size: 200% 100%; animation: brillo 1.2s linear infinite; border-radius: 8px; height: 14px; }
@keyframes brillo { to { background-position: -200% 0; } }

/* ---------- Ingreso ---------- */
.ingreso { flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.ingreso-cab { background: var(--prim); color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 56px) 28px 64px; border-radius: 0 0 36px 36px; position: relative; overflow: hidden; }
.ingreso-cab::after { content: ""; position: absolute; right: -60px; top: -40px; width: 220px; height: 220px; border-radius: 50%; border: 28px solid rgba(56,198,232,.18); }
.ingreso-cab h1 { margin: 18px 0 6px; font-size: 1.7rem; font-weight: 800; letter-spacing: -.01em; }
.ingreso-cab p { margin: 0; color: rgba(255,255,255,.8); }
.ingreso form { margin: -36px 16px 0; position: relative; display: flex; flex-direction: column; gap: 14px; }
.campo label { display: block; font-size: .85rem; font-weight: 600; color: var(--tenue); margin-bottom: 6px; }
.campo .caja { display: flex; align-items: center; background: var(--sup-2); border: 1px solid var(--borde); border-radius: 14px; }
.campo .caja:focus-within { border-color: var(--marca); box-shadow: 0 0 0 3px color-mix(in srgb, var(--marca) 18%, transparent); }
.campo input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 14px; font-size: 17px; outline: none; }
.campo .ver { border: 0; background: transparent; color: var(--tenue); padding: 0 14px; height: 48px; }
.error { background: var(--mal-fondo); color: var(--mal); border-radius: 12px; padding: 10px 12px; font-size: .9rem; }
.ayuda { text-align: center; color: var(--tenue); font-size: .88rem; padding: 18px 24px calc(env(safe-area-inset-bottom, 0px) + 24px); margin-top: auto; }

/* ---------- Barra inferior ---------- */
.barra { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--sup); border-top: 1px solid var(--borde); padding-bottom: env(safe-area-inset-bottom, 0px); }
.barra nav { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); height: var(--barra); }
.barra a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--tenue); font-size: .72rem; font-weight: 600; }
.barra a svg { width: 24px; height: 24px; }
.barra a.sel { color: var(--marca); }

/* ---------- Hoja inferior (detalle / visor) ---------- */
.hoja { position: fixed; inset: 0; z-index: 40; background: rgba(8,18,36,.5); display: flex; align-items: flex-end; justify-content: center; }
.hoja .panel { background: var(--sup); width: 100%; max-width: 560px; max-height: 92vh; border-radius: 22px 22px 0 0; padding: 10px 18px calc(env(safe-area-inset-bottom, 0px) + 18px); display: flex; flex-direction: column; gap: 12px; animation: sube .18s ease-out; }
.hoja .agarre { width: 40px; height: 5px; border-radius: 3px; background: var(--borde); margin: 2px auto 4px; }
.hoja h3 { margin: 0; font-size: 1.15rem; }
.hoja iframe { width: 100%; height: 62vh; border: 1px solid var(--borde); border-radius: 12px; background: #fff; }
@keyframes sube { from { transform: translateY(30px); opacity: .5; } }

/* ---------- Avisos ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--barra) + env(safe-area-inset-bottom, 0px) + 14px); transform: translate(-50%, 20px); background: var(--noche); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: .92rem; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100% - 32px); }
.toast.si { opacity: 1; transform: translate(-50%, 0); }

.opciones { display: flex; flex-direction: column; }
.opcion { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border: 0; border-bottom: 1px solid var(--borde); background: transparent; text-align: left; width: 100%; text-decoration: none; color: var(--tinta); }
.opcion:last-child { border-bottom: 0; }
.opcion svg { width: 22px; height: 22px; color: var(--tenue); flex: none; }
.opcion .txt { flex: 1; min-width: 0; }
.segmento { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--sup-2); border: 1px solid var(--borde); border-radius: 12px; padding: 3px; gap: 3px; }
.segmento button { border: 0; background: transparent; border-radius: 9px; padding: 8px; font-weight: 600; font-size: .88rem; color: var(--tenue); }
.segmento button.sel { background: var(--sup); color: var(--tinta); box-shadow: var(--sombra); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Chat con Tino (pantalla propia; los mensajes van a la consola) ---------- */
.chat-pant { height: 100vh; height: 100dvh; display: flex; flex-direction: column; background: var(--fondo); }
.chat-barra { display: flex; align-items: center; gap: 8px; padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 8px 4px; background: var(--sup); border-bottom: 1px solid var(--borde); }
.chat-barra .btn svg { width: 24px; height: 24px; }
.chat-barra .sub { color: var(--tenue); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-av { width: 38px; height: 38px; border-radius: 12px; background: var(--prim); color: #fff; display: grid; place-items: center; flex: none; }
.chat-av svg { width: 20px; height: 20px; }
.chat-lista { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 6px; display: flex; flex-direction: column; gap: 4px; }
.chat-dia { align-self: center; font-size: .75rem; color: var(--tenue); background: var(--sup); border: 1px solid var(--borde); border-radius: 999px; padding: 3px 10px; margin: 10px 0 4px; }
.chat-fila { display: flex; flex-direction: column; max-width: 84%; }
.chat-fila.yo { align-self: flex-end; align-items: flex-end; }
.chat-fila.el { align-self: flex-start; }
.chat-quien { font-size: .74rem; font-weight: 700; color: var(--tenue); margin: 8px 0 3px 4px; }
.chat-burbuja { border-radius: 18px; padding: 9px 12px 6px; position: relative; overflow-wrap: anywhere; box-shadow: var(--sombra); }
.chat-fila.el .chat-burbuja { background: var(--sup); border: 1px solid var(--borde); border-bottom-left-radius: 6px; }
.chat-fila.yo .chat-burbuja { background: var(--prim); color: #fff; border-bottom-right-radius: 6px; }
.chat-fila.yo .chat-burbuja a { color: #fff; }
.chat-hora { display: block; text-align: right; font-size: .68rem; opacity: .65; margin-top: 2px; }
.chat-img { display: block; max-width: 220px; max-height: 260px; border-radius: 12px; margin-bottom: 4px; }
.chat-doc { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 600; margin-bottom: 4px; }
.chat-doc svg { width: 22px; height: 22px; flex: none; }
.chat-puntos { display: flex; gap: 4px; padding: 12px 14px; }
.chat-puntos i { width: 7px; height: 7px; border-radius: 50%; background: var(--tenue); animation: punto 1.2s infinite ease-in-out; }
.chat-puntos i:nth-child(2) { animation-delay: .15s; } .chat-puntos i:nth-child(3) { animation-delay: .3s; }
@keyframes punto { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.chat-caja { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 10px); background: var(--sup); border-top: 1px solid var(--borde); }
.chat-caja textarea { flex: 1; min-width: 0; resize: none; border: 1px solid var(--borde); background: var(--sup-2); border-radius: 22px; padding: 11px 14px; font-size: 16px; line-height: 1.35; max-height: 120px; outline: none; }
.chat-caja textarea:focus { border-color: var(--marca); }
.chat-adj, .chat-enviar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 0; cursor: pointer; }
.chat-adj { background: var(--sup-2); color: var(--tenue); }
.chat-enviar { background: var(--prim); color: #fff; }
.chat-enviar[disabled] { opacity: .5; }
.chat-adj svg, .chat-enviar svg { width: 21px; height: 21px; }
