/* Cuadra — estilos de la app (mobile-first, claro y oscuro según el sistema). */
:root {
  --brand: #0f766e; --brand-2: #14b8a6; --brand-suave: rgba(15, 118, 110, .1);
  --ok: #059669; --ok-bg: rgba(16, 185, 129, .14); --warn: #b45309; --warn-bg: rgba(245, 158, 11, .16); --bad: #dc2626; --bad-bg: rgba(220, 38, 38, .12);
  --bg: #f3f6f5; --surface: #ffffff; --surface-2: #f8faf9; --ink: #10201d; --ink-soft: #46595a; --ink-faint: #7a8b88; --line: #e1e8e6;
  --sombra: 0 8px 24px -16px rgba(16, 32, 29, .35); --radio: 16px;
  /* alias que usan los archivos compartidos (premium.js, instalar-app.js, respaldo-local.js) */
  --text: var(--ink); --text-muted: var(--ink-soft); --border: var(--line); --bg-elevated: var(--surface); --purple: var(--brand);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #2dd4bf; --brand-2: #5eead4; --brand-suave: rgba(45, 212, 191, .12);
    --ok: #34d399; --warn: #fbbf24; --bad: #f87171;
    --bg: #0a1311; --surface: #12201d; --surface-2: #172a26; --ink: #e6f1ee; --ink-soft: #a9bcb7; --ink-faint: #7f938e; --line: #233733;
    --sombra: 0 10px 28px -18px rgba(0, 0, 0, .7);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
.hidden { display: none !important; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: .85rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Botones y campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer; background: var(--brand); color: #fff; text-decoration: none; }
@media (prefers-color-scheme: dark) { .btn { color: #04201c; } }
.btn:disabled { opacity: .6; cursor: default; }
.btn.sec { background: var(--brand-suave); color: var(--brand); }
.btn.peligro { background: var(--bad-bg); color: var(--bad); }
.btn.full { width: 100%; }
.btn.chico { padding: 8px 12px; font-size: .88rem; border-radius: 10px; }
.btn-link { border: 0; background: none; color: var(--brand); font-weight: 600; cursor: pointer; padding: 6px 0; }
.campo { display: grid; gap: 5px; font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.input, input.input, select.input, textarea.input { width: 100%; padding: 12px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font-size: 1rem; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-suave); }
textarea.input { min-height: 70px; resize: vertical; }
.fila { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form { display: grid; gap: 12px; }
.error { background: var(--bad-bg); color: var(--bad); padding: 9px 12px; border-radius: 10px; font-size: .9rem; margin: 0; }
.exito { background: var(--ok-bg); color: var(--ok); padding: 9px 12px; border-radius: 10px; font-size: .9rem; margin: 0; }

/* ---------- Pantalla de carga (logo del emprendimiento + holbaph) ---------- */
.splash { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg); transition: opacity .3s; }
.splash.fuera { opacity: 0; pointer-events: none; }
.splash .marca-logo { width: 104px; height: 104px; font-size: 2.6rem; }
.splash strong { font-size: 1.3rem; }
.por-holbaph { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-faint); font-size: .78rem; text-decoration: none; }
.hb-logo { height: 14px; width: auto; color: var(--ink); }
.splash .por-holbaph { position: absolute; bottom: calc(26px + env(safe-area-inset-bottom)); }

/* Logo: imagen del emprendimiento o círculo con su inicial */
.marca-logo { display: inline-flex; align-items: center; justify-content: center; border-radius: 24%; overflow: hidden; background: var(--brand); color: #fff; font-weight: 800; flex: none; }
.marca-logo img { width: 100%; height: 100%; object-fit: cover; background: #fff; }

/* ---------- Acceso ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: 32px 20px calc(30px + env(safe-area-inset-bottom)); }
.auth-cab { text-align: center; margin-bottom: 18px; }
.auth-cab img { width: 76px; height: 76px; border-radius: 22px; box-shadow: var(--sombra); }
.auth-cab h1 { margin: 12px 0 4px; font-size: 1.6rem; }
.auth-cab p { margin: 0; color: var(--ink-soft); }
.tarjeta { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); padding: 18px; box-shadow: var(--sombra); }
.auth .tarjeta h2 { margin: 0 0 12px; font-size: 1.15rem; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.auth .por-holbaph { display: flex; justify-content: center; margin-top: 22px; }

/* ---------- Estructura de la app ---------- */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); padding: calc(10px + env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--line); }
.top-fila { display: flex; align-items: center; gap: 10px; max-width: 720px; margin: 0 auto; }
.top .marca-logo { width: 38px; height: 38px; font-size: 1.05rem; }
.top-nombre { flex: 1; min-width: 0; }
.top-nombre strong { display: block; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-nombre small { color: var(--ink-faint); font-size: .76rem; }
main { max-width: 720px; margin: 0 auto; padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 4px; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); }
.nav button { flex: 1; max-width: 180px; border: 0; background: none; color: var(--ink-faint); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px; border-radius: 12px; font-size: .74rem; font-weight: 600; cursor: pointer; }
.nav button span { font-size: 1.25rem; line-height: 1; }
.nav button.activa { color: var(--brand); background: var(--brand-suave); }
.titulo-vista { display: flex; align-items: center; gap: 8px; margin: 4px 0 12px; }
.titulo-vista h1 { font-size: 1.3rem; margin: 0; flex: 1; }
.volver { border: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; color: var(--ink); }

/* ---------- Cifras y listas ---------- */
.cifras { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.cifra { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); padding: 12px 14px; }
.cifra small { display: block; color: var(--ink-soft); font-size: .78rem; font-weight: 600; }
.cifra b { font-size: 1.35rem; }
.cifra.alerta b { color: var(--bad); }
.buscar { margin-bottom: 10px; }
.lista { display: grid; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; cursor: pointer; text-align: left; width: 100%; color: var(--ink); }
.item:active { transform: scale(.995); }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; background: var(--brand-suave); color: var(--brand); flex: none; }
.item-txt { flex: 1; min-width: 0; }
.item-txt strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-txt small { color: var(--ink-faint); font-size: .8rem; }
.item-monto { text-align: right; font-weight: 800; white-space: nowrap; }
.item-monto small { display: block; font-weight: 600; font-size: .74rem; }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--surface-2); color: var(--ink-soft); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.vacio { text-align: center; color: var(--ink-soft); padding: 30px 10px; }
.vacio .grande { font-size: 2.4rem; display: block; margin-bottom: 6px; }
.fab { position: fixed; right: max(18px, calc(50vw - 342px)); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 15; border: 0; border-radius: 18px; padding: 14px 18px; font-weight: 800; background: var(--brand); color: #fff; box-shadow: 0 12px 26px -10px rgba(15, 118, 110, .7); cursor: pointer; }
@media (prefers-color-scheme: dark) { .fab { color: #04201c; } }

/* ---------- Detalle de cliente y deudas ---------- */
.cab-cliente { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.cab-cliente .avatar { width: 52px; height: 52px; font-size: 1.2rem; }
.contacto { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--ink-soft); font-size: .88rem; }
.contacto a { text-decoration: none; }
.acciones { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.deuda { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); padding: 14px; margin-bottom: 10px; }
.deuda-cab { display: flex; gap: 8px; align-items: flex-start; }
.deuda-cab h3 { margin: 0; font-size: 1rem; flex: 1; }
.deuda-meta { color: var(--ink-faint); font-size: .8rem; margin: 2px 0 10px; }
.barra { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 8px 0; border: 1px solid var(--line); }
.barra i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.saldos { display: flex; justify-content: space-between; font-size: .88rem; }
.cuotas { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.cuotas li { display: flex; align-items: center; gap: 8px; font-size: .88rem; padding: 6px 0; border-top: 1px dashed var(--line); }
.cuotas li .n { width: 46px; color: var(--ink-faint); }
.cuotas li .f { flex: 1; }
.abonos { margin-top: 8px; font-size: .84rem; }
.abonos summary { cursor: pointer; color: var(--brand); font-weight: 600; padding: 4px 0; }
.abonos div { display: flex; gap: 8px; align-items: center; padding: 4px 0; color: var(--ink-soft); }
.abonos div span:first-child { flex: 1; }
.x { border: 0; background: none; color: var(--ink-faint); cursor: pointer; padding: 4px 6px; border-radius: 8px; }

/* ---------- Etapa 2: resumen, cobro por WhatsApp, tablas ---------- */
.btn.wa { background: #25d366; color: #05391b; }
.cifra.bien b { color: var(--ok); }
.mes-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.mes-nav strong { font-size: 1.05rem; text-transform: capitalize; }
.mes-nav .volver:disabled { opacity: .35; }
.grafico { width: 100%; height: auto; display: block; }
.grafico .g-cobrado { fill: var(--brand); } .grafico .g-pendiente { fill: #f59e0b; }
.grafico .g-mes { fill: var(--ink-faint); font-size: 11px; }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .78rem; color: var(--ink-soft); }
.leyenda span::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.leyenda .l-cobrado::before { background: var(--brand); } .leyenda .l-pendiente::before { background: #f59e0b; }
.tabla { display: grid; }
.fila-tabla { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--line); color: var(--ink); text-decoration: none; font-size: .92rem; }
.fila-tabla:first-child { border-top: 0; }
.cobro { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 0; border-top: 1px dashed var(--line); }
.cobro:first-child { border-top: 0; }
.cobro-txt { display: flex; flex-direction: column; min-width: 0; }
.cobro-txt a { font-weight: 700; text-decoration: none; color: var(--ink); }
.cobro-txt small { color: var(--ink-soft); font-size: .8rem; }
.cobro-der { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.cobro .wa { grid-column: 1 / -1; justify-self: start; }
.alerta-caja { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 12px; margin: 0; font-size: .9rem; font-weight: 600; }
.previa-msj { background: #dcf8c6; color: #0b1f14; padding: 10px 12px; border-radius: 12px 12px 12px 2px; font-size: .9rem; white-space: pre-line; }

/* ---------- Hojas (diálogos que suben desde abajo) ---------- */
dialog.hoja { border: 0; padding: 0; width: min(100%, 520px); max-height: 92vh; margin: auto auto 0; border-radius: 22px 22px 0 0; background: var(--surface); color: var(--ink); box-shadow: 0 -12px 40px rgba(0, 0, 0, .3); }
@media (min-width: 600px) { dialog.hoja { margin: auto; border-radius: 22px; } }
dialog.hoja::backdrop { background: rgba(4, 12, 10, .55); }
.hoja-cuerpo { padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); overflow: auto; max-height: 92vh; }
.hoja-cab { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.hoja-cab h2 { margin: 0; font-size: 1.15rem; flex: 1; }
.plan-previa { border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; max-height: 260px; overflow: auto; }
.plan-previa div { display: grid; grid-template-columns: 34px 1fr 1fr; gap: 6px; align-items: center; padding: 4px 0; font-size: .88rem; }
.plan-previa input { padding: 7px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); width: 100%; font-size: .9rem; }
.segmento { display: flex; flex-wrap: wrap; gap: 6px; }
.segmento button { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 7px 12px; font-size: .86rem; font-weight: 600; cursor: pointer; color: var(--ink-soft); }
.segmento button.activo { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .segmento button.activo { color: #04201c; } }

/* ---------- Ajustes ---------- */
.ajuste { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radio); padding: 16px; margin-bottom: 12px; }
.ajuste h2 { margin: 0 0 10px; font-size: 1.05rem; }
.logo-editar { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.logo-editar .marca-logo { width: 72px; height: 72px; font-size: 1.8rem; }
.plan-chip { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 800; font-size: .82rem; background: var(--surface-2); }
.plan-chip.completo { background: var(--ok-bg); color: var(--ok); }

/* ---------- Bloqueo con PIN ---------- */
.bloqueo { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.bloqueo .marca-logo { width: 72px; height: 72px; font-size: 1.8rem; }
.pin-input { width: 180px; text-align: center; font-size: 1.8rem; letter-spacing: .5em; padding: 10px; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 9999; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: .92rem; max-width: 90vw; text-align: center; }

/* ---------- Archivos compartidos: aviso de instalar y ventana Premium ---------- */
.banner-instalar { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sombra); }
.banner-instalar .bi-ico { font-size: 1.4rem; }
.banner-instalar .bi-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.banner-instalar .bi-txt strong { font-size: .95rem; }
.banner-instalar .bi-txt small { color: var(--ink-faint); font-size: .78rem; }
.banner-instalar .bi-btn { border: 0; border-radius: 10px; padding: 8px 12px; font-weight: 700; font-size: .82rem; background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.banner-instalar .bi-sec { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.banner-instalar .bi-x { border: 0; background: transparent; color: var(--ink-faint); font-size: 1rem; cursor: pointer; padding: 4px; }
.login-instalar { display: block; margin-top: 14px; text-align: center; font-size: .85rem; }
.pm-overlay { position: fixed; inset: 0; z-index: 9000; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; }
.pm-card { position: relative; width: min(100%, 460px); max-height: 94vh; overflow: auto; background: var(--surface); color: var(--ink); border-radius: 22px 22px 0 0; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0, 0, 0, .35); }
@media (min-width: 600px) { .pm-overlay { align-items: center; } .pm-card { border-radius: 22px; } }
.pm-x { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; color: var(--ink-faint); font-size: 1.2rem; cursor: pointer; padding: 6px; }
.pm-badge { display: inline-block; font-size: .74rem; font-weight: 800; letter-spacing: .04em; padding: 4px 10px; border-radius: 999px; background: var(--brand-suave); color: var(--brand); }
.pm-card h2 { margin: 10px 0 6px; font-size: 1.35rem; }
.pm-motivo { margin: 0 0 8px; color: var(--ink-soft); font-size: .92rem; }
.pm-precio { margin: 6px 0 12px; font-size: .95rem; } .pm-precio b { font-size: 1.5rem; }
.pm-lista { list-style: none; padding: 0; margin: 0 0 12px; font-size: .92rem; } .pm-lista li { padding: 5px 0; }
.pm-pasos { background: var(--brand-suave); border-radius: 12px; padding: 10px 14px; font-size: .88rem; margin-bottom: 12px; } .pm-pasos ol { margin: 6px 0 0; padding-left: 20px; } .pm-pasos li { margin: 3px 0; }
.pm-correo { font-size: .85rem; margin: 8px 0; color: var(--ink-soft); }
.pm-otro { margin-bottom: 8px; } .pm-otro.hidden { display: none; }
.pm-otro input { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); color: inherit; font-size: 1rem; }
.pm-otro small { display: block; margin-top: 6px; font-size: .78rem; color: var(--ink-faint); }
.pm-pagar { width: 100%; border: 0; border-radius: 14px; padding: 15px; font-weight: 800; font-size: 1.02rem; background: linear-gradient(135deg, #009ee3, #0070d1); color: #fff; cursor: pointer; margin-top: 4px; }
.pm-pagar:disabled { opacity: .7; }
.pm-sec { display: flex; flex-wrap: wrap; gap: 6px 16px; justify-content: center; margin-top: 14px; }
.pm-link { border: 0; background: transparent; color: var(--brand); font-weight: 600; font-size: .85rem; cursor: pointer; text-decoration: underline; padding: 4px 0; }
.pm-error, .pm-alerta, .pm-resultado { font-size: .85rem; margin: 8px 0; padding: 9px 12px; border-radius: 10px; }
.pm-error { background: var(--bad-bg); color: var(--bad); } .pm-alerta { background: var(--warn-bg); } .pm-resultado { background: var(--brand-suave); }
.pm-error.hidden, .pm-resultado.hidden { display: none; }
.pm-ayuda { text-align: center; font-size: .78rem; color: var(--ink-faint); margin: 12px 0 0; }
