:root {
  --bg: #0a0b0d;
  --bg-2: #121418;
  --card: #16191e;
  --card-2: #1d2128;
  --line: #262b33;
  --text: #eef1f5;
  --muted: #8b93a1;
  --dim: #5c6370;
  --red: #ff5b5b;
  --red-bg: rgba(255, 91, 91, 0.12);
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.12);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.12);
  --blue: #60a5fa;
  --wa: #25d366;
  --radius: 16px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.red { color: var(--red); }
.green { color: var(--green); }
.amber { color: var(--amber); }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- estructura ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  padding: calc(var(--safe-t) + 10px) 16px 10px;
  background: rgba(10, 11, 13, 0.82);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  display: flex; align-items: center; gap: 10px; min-height: 52px;
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.top h1 { font-size: 20px; font-weight: 700; margin: 0; flex: 1; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .back { background: none; border: 0; color: var(--blue); font-size: 17px; padding: 6px 4px; display: flex; align-items: center; gap: 2px; }
.top .accion { background: var(--card-2); border: 0; border-radius: 999px; padding: 7px 14px; font-size: 15px; font-weight: 600; color: var(--text); }

main { padding: 6px 16px calc(var(--tab-h) + var(--safe-b) + 24px); max-width: 640px; margin: 0 auto; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(14, 15, 18, 0.88);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--line);
}
.tabs button {
  background: none; border: 0; color: var(--dim);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600;
}
.tabs button svg { width: 25px; height: 25px; }
.tabs button.on { color: var(--text); }
.tabs .mas span.circ {
  width: 44px; height: 44px; border-radius: 50%; background: var(--text); color: var(--bg);
  display: grid; place-items: center; margin-top: -2px;
}
.tabs .mas svg { width: 24px; height: 24px; }

/* ---------- tarjetas ---------- */
.hero {
  background: radial-gradient(120% 140% at 0% 0%, rgba(255, 91, 91, 0.20), transparent 55%), var(--card);
  border: 1px solid var(--line); border-radius: 22px; padding: 18px 18px 16px; margin: 8px 0 18px;
}
.hero .lbl { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.hero .big { font-size: 38px; font-weight: 800; letter-spacing: -0.03em; margin: 4px 0 12px; line-height: 1.1; }
.hero .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero .stat { background: rgba(255, 255, 255, 0.04); border-radius: 12px; padding: 10px 12px; }
.hero .stat b { display: block; font-size: 17px; }
.hero .stat small { color: var(--muted); font-size: 12px; }

.sec { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 2px 8px; }
.sec h2 { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0; font-weight: 700; }
.sec small { color: var(--dim); font-size: 13px; }

.lista { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.fila {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%;
  background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; position: relative;
}
.fila:last-child { border-bottom: 0; }
.fila:active { background: var(--card-2); }
.av {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: var(--card-2); color: var(--muted);
}
.av.debe { background: var(--red-bg); color: var(--red); }
.av.favor { background: var(--green-bg); color: var(--green); }
.fila .info { flex: 1; min-width: 0; }
.fila .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .monto { font-weight: 700; text-align: right; white-space: nowrap; }
.fila .monto small { display: block; font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: 0.04em; }
.barra { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--red); opacity: 0.55; border-radius: 0 2px 2px 0; }

.alerta { border-left: 3px solid var(--amber); }
.alerta.vencido { border-left-color: var(--red); }
.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; vertical-align: 1px;
}
.chip.vencido { background: var(--red-bg); color: var(--red); }
.chip.hoy { background: var(--amber-bg); color: var(--amber); }
.chip.proximo { background: rgba(96, 165, 250, 0.14); color: var(--blue); }
.wa-mini { background: var(--wa); color: #04210f; border: 0; border-radius: 999px; width: 36px; height: 36px; display: grid; place-items: center; flex: none; }
.wa-mini svg { width: 20px; height: 20px; }

.vacio { text-align: center; color: var(--muted); padding: 34px 20px; }
.vacio b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* ---------- búsqueda ---------- */
.buscar { position: relative; margin: 6px 0 12px; }
.buscar input {
  width: 100%; height: 42px; border-radius: 12px; border: 0; background: var(--card-2);
  padding: 0 14px 0 38px; font-size: 16px; outline: none;
}
.buscar svg { position: absolute; left: 12px; top: 12px; width: 18px; height: 18px; color: var(--dim); }
.filtros { display: flex; gap: 8px; margin: 0 0 12px; overflow-x: auto; scrollbar-width: none; }
.filtros button { flex: none; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 14px; color: var(--muted); }
.filtros button.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }

/* ---------- ficha cliente ---------- */
.ficha { text-align: center; padding: 6px 0 4px; }
.ficha .av { width: 64px; height: 64px; font-size: 24px; margin: 0 auto 10px; }
.ficha .nom { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.ficha .emp { color: var(--muted); font-size: 15px; }
.saldo-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; margin: 16px 0 12px; text-align: center; }
.saldo-card .lbl { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.saldo-card .big { font-size: 36px; font-weight: 800; letter-spacing: -0.03em; margin-top: 2px; }
.acciones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  height: 50px; border-radius: 14px; border: 0; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
}
.btn svg { width: 20px; height: 20px; }
.btn.deuda { background: var(--red); color: #2a0606; }
.btn.pago { background: var(--green); color: #032116; }
.btn.prim { background: var(--text); color: var(--bg); }
.btn.sec { background: var(--card-2); color: var(--text); }
.btn.wa { background: var(--wa); color: #04210f; }
.btn.peligro { background: var(--red-bg); color: var(--red); }
.btn:disabled { opacity: 0.5; }
.btn:active { transform: scale(0.98); }
.mini-acc { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 4px; }
.mini-acc button {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 4px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600;
}
.mini-acc button svg { width: 22px; height: 22px; color: var(--text); }
.mini-acc button.wa svg { color: var(--wa); }

.datos { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.dato { display: flex; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.dato:last-child { border-bottom: 0; }
.dato span { color: var(--muted); font-size: 14px; width: 82px; flex: none; }
.dato div { flex: 1; word-break: break-word; }

/* ---------- extracto ---------- */
.ext { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.ext-h, .ext-r {
  display: grid; grid-template-columns: 1fr 22% 22% 24%; gap: 6px; padding: 10px 12px; align-items: start;
}
.ext-h { font-size: 11px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 1px solid var(--line); background: var(--bg-2); position: sticky; }
.ext-h div:not(:first-child), .ext-r .n { text-align: right; }
.ext-r { border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; font-size: 14px; }
.ext-r:last-child { border-bottom: 0; }
.ext-r:active { background: var(--card-2); }
.ext-r .f { font-weight: 600; font-size: 13px; }
.ext-r .c { color: var(--muted); font-size: 12px; line-height: 1.3; margin-top: 1px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ext-r .v { font-size: 11px; color: var(--amber); margin-top: 2px; }
.ext-r .n { font-size: 13px; padding-top: 1px; overflow-wrap: anywhere; }
.ext-r .n.sal { font-weight: 700; }
.ext-tot { display: grid; grid-template-columns: 1fr 22% 22% 24%; gap: 6px; padding: 10px 12px; font-size: 13px; font-weight: 700; background: var(--bg-2); border-top: 1px solid var(--line); }
.ext-tot div:not(:first-child) { text-align: right; }

/* ---------- hoja inferior (sheet) ---------- */
.velo { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 40; opacity: 0; transition: opacity 0.2s; }
.velo.on { opacity: 1; }
.hoja {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 92dvh; overflow-y: auto;
  background: var(--bg-2); border-radius: 22px 22px 0 0; border-top: 1px solid var(--line);
  padding: 8px 16px calc(var(--safe-b) + 18px);
  transform: translateY(100%); transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  max-width: 640px; margin: 0 auto;
}
.hoja.on { transform: none; }
.hoja .asa { width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 10px; }
.hoja h3 { font-size: 19px; margin: 4px 0 14px; text-align: center; }
.hoja .sub { text-align: center; color: var(--muted); margin: -10px 0 14px; font-size: 14px; }

.campo { margin-bottom: 12px; }
.campo label { display: block; font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 5px 4px; }
.campo input, .campo textarea, .campo select {
  width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card);
  padding: 11px 14px; font-size: 17px; outline: none; -webkit-appearance: none; appearance: none;
}
.campo input[type="date"] { display: block; }
.campo textarea { min-height: 76px; resize: vertical; }
.campo input:focus, .campo textarea:focus, .campo select:focus { border-color: var(--muted); }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.monto-in { text-align: center; }
.monto-in input { font-size: 34px; font-weight: 800; text-align: center; border: 0; background: transparent; min-height: 60px; letter-spacing: -0.02em; }
.monto-in .mon { color: var(--muted); font-size: 14px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border-radius: 12px; padding: 3px; margin-bottom: 14px; }
.seg button { border: 0; background: none; border-radius: 10px; height: 38px; font-weight: 700; color: var(--muted); }
.seg button.on.deuda { background: var(--red); color: #2a0606; }
.seg button.on.pago { background: var(--green); color: #032116; }
.rapidos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.rapidos button { background: var(--card-2); border: 0; border-radius: 999px; padding: 5px 11px; font-size: 13px; color: var(--muted); font-weight: 600; }
.previa { background: var(--card); border-radius: 12px; padding: 10px 14px; display: flex; justify-content: space-between; margin: 4px 0 14px; font-size: 15px; }
.pila { display: grid; gap: 10px; }
.err { color: var(--red); font-size: 14px; text-align: center; min-height: 20px; margin: 4px 0; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login .logo { width: 72px; height: 72px; border-radius: 18px; margin: 0 auto 14px; display: block; }
.login h1 { text-align: center; margin: 0 0 4px; font-size: 26px; letter-spacing: -0.02em; }
.login p { text-align: center; color: var(--muted); margin: 0 0 26px; }

/* ---------- aviso ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 14px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; transition: all 0.25s;
  background: var(--text); color: var(--bg); font-weight: 600; padding: 10px 18px; border-radius: 999px; font-size: 15px;
  pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.toast.on { transform: translate(-50%, 0); opacity: 1; }

.cargando { text-align: center; color: var(--dim); padding: 40px; }

/* ---------- impresión (PDF del extracto) ---------- */
.solo-print { display: none; }
@media print {
  :root { --bg: #fff; --card: #fff; --card-2: #fff; --bg-2: #f3f4f6; --line: #d1d5db; --text: #111; --muted: #444; --dim: #555; --red: #b91c1c; --green: #047857; --amber: #92400e; }
  body { background: #fff; }
  .top, .tabs, .no-print, .toast, .velo, .hoja { display: none !important; }
  main { padding: 0; max-width: none; }
  .solo-print { display: block; margin-bottom: 14px; }
  .solo-print h2 { margin: 0; font-size: 20px; }
  .ext { border-radius: 0; }
  .ext-r, .ext-h { break-inside: avoid; }
}

.vacio.alto { padding-top: 90px; }
.fino { font-weight: 500; }
.ficha .chip { margin-top: 6px; }
.hoja .rapidos[data-venc] { margin: -4px 0 12px; }
.separado { margin-bottom: 12px; }
.nota { color: var(--muted); text-align: center; font-size: 13px; margin-top: 22px; }
.dos:has(> .hidden) { grid-template-columns: 1fr; }

/* proveedores, factura, anulados */
.hero.pagar { background: radial-gradient(120% 140% at 0% 0%, rgba(251, 191, 36, 0.16), transparent 55%), var(--card); margin-top: -6px; }
.hero.pagar .big { font-size: 32px; }
.barra.prov { background: var(--amber); }
.chip.prov { background: var(--amber-bg); color: var(--amber); }
.ficha .chip.prov { margin-top: 6px; }
.ext-r .fac { color: var(--blue); font-size: 11px; margin-top: 2px; overflow-wrap: anywhere; }
.link { background: none; border: 0; padding: 0; color: var(--blue); font-size: 13px; font-weight: 600; }
.btn.chico { height: 36px; width: auto; padding: 0 12px; font-size: 14px; border-radius: 10px; flex: none; gap: 5px; }
.btn.chico svg { width: 16px; height: 16px; }
.seg.neutro button.on { background: var(--text); color: var(--bg); }
.tabs button { font-size: 10.5px; }

/* selector de país del WhatsApp */
.paises { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.paises button { background: var(--card); border: 1px solid var(--line); border-radius: 10px; height: 40px; font-size: 13px; font-weight: 700; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 5px; }
.paises button .flag { font-size: 20px; line-height: 1; }
.paises button.on { border-color: var(--text); color: var(--text); background: var(--card-2); }
.tel-previa { font-size: 13px; margin: 6px 4px 0; min-height: 18px; font-weight: 600; }

/* ---------- jornales ---------- */
.blue { color: var(--blue); }
.top .icono { background: var(--card-2); border: 0; border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; color: var(--text); flex: none; }
.top .icono svg { width: 20px; height: 20px; }
.hero.jornal { background: radial-gradient(120% 140% at 0% 0%, rgba(96, 165, 250, 0.18), transparent 55%), var(--card); }
.hero.jornal .big { margin-bottom: 0; }
.hero .cap { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.hero.toca { display: block; width: 100%; text-align: left; position: relative; margin-top: -6px; }
.hero.toca:active { transform: scale(0.99); }
.hero.toca .big { font-size: 32px; }
.hero .ir { position: absolute; right: 14px; top: 16px; color: var(--dim); }
.hero .ir svg { width: 20px; height: 20px; }
.seg.tres { grid-template-columns: repeat(3, 1fr); }
.chip.empleado { background: rgba(96, 165, 250, 0.14); color: var(--blue); margin-top: 6px; }
.chip.liq { background: var(--green-bg); color: var(--green); }
.fila.anulada .info, .fila.anulada .monto { opacity: 0.5; text-decoration: line-through; text-decoration-thickness: 1px; }
.fila.anulada .chip { text-decoration: none; }
.mini-acc.c2 { grid-template-columns: 1fr 1fr; }
.saldo-card .semana-info { color: var(--muted); font-size: 13px; margin-top: 6px; }
.saldo-card .semana-info b { color: var(--amber); }
.ext-r .tj { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; margin-top: 1px; }
.ext-r .tj.adelanto { color: var(--amber); }
.ext-r .tj.pago { color: var(--blue); }
.ext-r .tj.jornal { color: var(--green); }
.ayuda { color: var(--muted); font-size: 13px; margin: -4px 4px 12px; text-align: center; }
.ayuda.izq { text-align: left; margin: 6px 4px 0; }
.campo .ayuda { margin: 8px 4px 0; text-align: left; }
.aviso { background: var(--amber-bg); color: var(--amber); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 0 0 12px; }
.estado-liq { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 0 0 12px; font-size: 15px; text-align: center; font-weight: 600; }
.estado-liq b { font-size: 17px; margin-left: 4px; }
.estado-liq.muted { color: var(--muted); }
.stepper { display: grid; grid-template-columns: 44px 1fr 44px; gap: 6px; }
.stepper button { border: 1px solid var(--line); background: var(--card-2); border-radius: 12px; font-weight: 700; font-size: 15px; color: var(--text); min-height: 48px; padding: 0; }
.campo .stepper input { text-align: center; padding: 11px 4px; font-weight: 700; }
.campo [data-parte] input { margin-top: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; font-size: 15px; }
.check input { width: 22px; height: 22px; flex: none; margin: 0; accent-color: var(--green); }
.resumen-liq { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px 14px; margin: 4px 0 12px; }
.resumen-liq .pr { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.resumen-liq .pr:last-child { border-bottom: 0; }
.resumen-liq .pr span { color: var(--muted); }
.resumen-liq .pr b { text-align: right; }
.resumen-liq .pr.total span { color: var(--text); font-weight: 700; }
.resumen-liq .pr.total b { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.ok-liq { width: 56px; height: 56px; border-radius: 50%; background: var(--green-bg); color: var(--green); display: grid; place-items: center; margin: 4px auto 0; }
.ok-liq svg { width: 28px; height: 28px; }
.hoja h3 .chip { vertical-align: 3px; margin-left: 4px; }
/* .btn.sec heredaba el margen de los títulos .sec y dejaba huecos dentro de las pilas de botones. */
.pila > .btn.sec { margin: 0; }
