:root {
  --bg: #f3f4f8;
  --card: #ffffff;
  --card2: #f1f2f6;
  --line: #e7e9ef;
  --txt: #1b1e27;
  --muted: #8a8f9c;
  --accent: #2563EB;
  --accent2: #3B82F6;
  --green: #15a05a;
  --red: #e5484d;
  /* colores por medio de pago (branding) */
  --m-credito: #2563EB;
  --m-debito: #06B6D4;
  --m-transferencia: #F59E0B;
  --m-efectivo: #15a05a;
  --shadow: 0 1px 2px rgba(20,22,35,.04), 0 6px 20px rgba(20,22,35,.06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
.wrap { max-width: 720px; margin: 0 auto; padding: 20px 16px 110px; }
h1 { font-size: 20px; font-weight: 700; margin: 4px 0 18px; letter-spacing: -.3px; }
.muted { color: var(--muted); }

/* Próximo mes hero */
.hero { background: linear-gradient(135deg, #3B82F6 0%, #2563EB 55%, #1E40AF 100%);
  color: #fff; border-radius: 22px; padding: 22px 20px; margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(37,99,235,.32); }
.hero .navrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hero .navrow button { background: rgba(255,255,255,.18); border: none; color: #fff;
  width: 42px; height: 42px; border-radius: 13px; font-size: 22px; cursor: pointer;
  transition: background .15s; display: flex; align-items: center; justify-content: center; }
.hero .navrow button:active { background: rgba(255,255,255,.32); }
.hero .mes { font-size: 13px; opacity: .85; text-transform: capitalize; font-weight: 500;
  letter-spacing: .3px; }
.hero .total { font-size: 40px; font-weight: 800; margin: 8px 0 4px; letter-spacing: -1.5px; }
.hero .var { font-size: 12.5px; font-weight: 500; min-height: 16px; opacity: .95; }

/* listas por tarjeta */
.persona-tit { display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700;
  color: var(--muted); margin: 22px 6px 10px; }
.persona-tit .persona-sub { font-size: 14px; letter-spacing: 0; color: var(--txt);
  font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 13px; background: var(--card);
  border-radius: 15px; padding: 14px 16px; margin-bottom: 9px; box-shadow: var(--shadow); }
.row .dot { width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto; }
.row .nombre { flex: 1; font-size: 15px; font-weight: 500; line-height: 1.3; }
.row .ciclo { font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 3px; }
.row .monto { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px; }
.row .monto.cero { color: var(--muted); font-weight: 400; }

/* estados de pago (Próximo pago) */
.row.estado-pronto { background: #fff5e9; box-shadow: inset 3px 0 0 #f59e0b, var(--shadow); }
.row.estado-vence { background: #fdeeee; box-shadow: inset 3px 0 0 #ef4444, var(--shadow); }
.row.estado-pagado { background: #eaf8f0; box-shadow: inset 3px 0 0 #15a05a, var(--shadow); }
.btn-pago { flex: 0 0 auto; background: var(--card2); border: none; color: var(--muted);
  padding: 9px 14px; border-radius: 11px; font-weight: 700; font-size: 12.5px; cursor: pointer; }
.btn-pago.pagado { background: var(--green); color: #fff; }

.btn-cal { display: block; text-align: center; text-decoration: none; background: var(--card2);
  color: var(--accent); border: 1.5px dashed var(--accent); border-radius: 12px; padding: 11px;
  font-size: 13px; font-weight: 700; margin: 0 0 16px; }

/* banner de avisos de vencimiento */
#banner { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
#banner:empty { display: none; }
.banner-item { padding: 11px 14px; border-radius: 13px; font-size: 13px; font-weight: 600; }
.banner-item.aviso { background: #fff4e6; color: #92400e; }
.banner-item.pronto { background: #ffe6d1; color: #9a3412; }
.banner-item.vence { background: #fdecec; color: #b91c1c; }

/* botón flotante */
.fab { position: fixed; right: 20px; bottom: 26px; background: var(--accent); color: white;
  border: none; border-radius: 50%; width: 60px; height: 60px; font-size: 30px; cursor: pointer;
  box-shadow: 0 10px 28px rgba(37,99,235,.5); transition: transform .12s; z-index: 5; }
.fab:active { transform: scale(.92); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,22,35,.45); backdrop-filter: blur(2px);
  display: none; align-items: flex-end; justify-content: center; z-index: 10; }
.modal-bg.open { display: flex; }
.modal { background: var(--card); width: 100%; max-width: 720px; border-radius: 24px 24px 0 0;
  padding: 22px 18px 28px; animation: up .22s ease; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal h2 { font-size: 17px; font-weight: 700; margin: 2px 0 16px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; font-weight: 500; }
input, select { width: 100%; background: var(--card2); border: 1.5px solid transparent; color: var(--txt);
  padding: 12px 13px; border-radius: 12px; font-size: 16px; transition: border-color .15s, background .15s; }
input:focus, select:focus { outline: none; border-color: var(--accent); background: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.hint { font-size: 12px; color: var(--muted); background: var(--card2); border-radius: 10px;
  padding: 9px 11px; margin-top: 12px; line-height: 1.4; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1 1 auto; min-width: 70px; background: var(--card2); border: 1.5px solid transparent;
  color: var(--muted); padding: 10px 8px; border-radius: 11px; cursor: pointer; font-size: 12.5px;
  font-weight: 600; transition: all .14s; }
.seg button.active { background: var(--accent); color: white; }
.btn-primary { width: 100%; margin-top: 18px; background: var(--accent); color: white; border: none;
  padding: 15px; border-radius: 14px; font-size: 16px; font-weight: 700; cursor: pointer;
  transition: transform .1s, filter .1s; box-shadow: 0 6px 18px rgba(37,99,235,.32); }
.btn-primary:active { transform: scale(.98); filter: brightness(.96); }
.btn-ghost { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; }

/* charts */
.charts { margin-top: 6px; }
.chartcard { background: var(--card); border-radius: 17px; padding: 16px 16px 12px; margin-bottom: 11px;
  box-shadow: var(--shadow); }
.chartcard .head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.chartcard .head .nm { font-size: 14px; font-weight: 700; }
.chartcard .head .tot { font-size: 12px; color: var(--muted); font-weight: 500; }
.bars { display: flex; align-items: flex-end; gap: 7px; height: 96px; }
.bars .b { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%;
  justify-content: flex-end; }
.bars .b .barval { font-size: 9px; font-weight: 700; color: var(--txt); min-height: 11px; line-height: 1; }
.bars .b .bar { width: 100%; border-radius: 6px 6px 3px 3px; min-height: 3px; transition: height .3s; }
.bars .b .lbl { font-size: 9.5px; color: var(--muted); font-weight: 600; text-transform: capitalize; }

/* selector de moneda */
.moneda-sel { display: flex; gap: 4px; background: var(--card); border-radius: 999px; padding: 4px;
  box-shadow: var(--shadow); flex: 0 0 auto; }
.moneda-sel button { background: none; border: none; color: var(--muted); padding: 7px 14px;
  border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 700; white-space: nowrap; }
.moneda-sel button.active { background: var(--accent); color: #fff; }

/* tabs */
.tabs { display: flex; gap: 8px; margin: 16px 0; overflow-x: auto; padding-bottom: 2px;
  scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: var(--card); border: none; color: var(--muted); white-space: nowrap;
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow); transition: all .14s; }
.tabs button.active { background: var(--txt); color: #fff; }

/* grilla */
.tablewrap { overflow-x: auto; border-radius: 16px; box-shadow: var(--shadow); background: var(--card); }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; white-space: nowrap; }
th, td { padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); font-weight: 500; }
thead th { background: #fafbfc; color: var(--muted); font-weight: 700; text-transform: capitalize; }
tr.total td { font-weight: 800; border-top: 2px solid var(--line); background: #fafbfc; }
tr.var td { color: var(--muted); font-size: 11px; }

/* chat */
#chat-log { min-height: 120px; display: flex; flex-direction: column; }
.fijo-input { width: 120px !important; text-align: right; }

.hidden { display: none; }

/* pagina de ayuda */
.ayuda { padding: 4px 6px 40px; line-height: 1.55; }
.ayuda h3 { margin: 22px 0 6px; font-size: 16px; color: var(--txt); }
.ayuda p { color: var(--muted); margin: 6px 0; }
.ayuda ul { margin: 6px 0; padding-left: 20px; }
.ayuda li { margin: 5px 0; color: var(--txt); }
.ayuda li ul li { color: var(--muted); }
.ayuda b { color: var(--txt); }

/* ===== Navegación tipo app: barra inferior ===== */
.tabs { display: none !important; }           /* reemplazadas por la barra inferior */
.fab { display: none !important; }            /* el ＋ ahora vive en la barra */
#appnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-around;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 16px rgba(20,22,35,.06); }
#appnav .navitem { background: none; border: none; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px;
  font-weight: 600; padding: 6px 10px; border-radius: 12px; min-width: 56px; }
#appnav .navitem .ic { font-size: 21px; line-height: 1; }
#appnav .navitem.active { color: var(--accent); }
#appnav .navadd { background: var(--accent); color: #fff; border: none; cursor: pointer;
  width: 52px; height: 52px; border-radius: 50%; font-size: 30px; line-height: 1;
  display: flex; align-items: center; justify-content: center; margin-top: -22px;
  box-shadow: 0 6px 18px rgba(37,99,235,.45); }
#appnav .navadd:active { transform: scale(.92); }

/* menú flotante del ＋ reubicado sobre la barra */
#fab-menu { right: 50% !important; transform: translateX(50%); bottom: 84px !important; align-items: center !important; }

/* panel inferior "Más" */
.sheet-bg { position: fixed; inset: 0; z-index: 80; background: rgba(20,22,35,.4);
  display: none; align-items: flex-end; }
.sheet-bg.open { display: flex; }
.sheet { width: 100%; background: var(--card); border-radius: 20px 20px 0 0; padding: 10px 14px calc(20px + env(safe-area-inset-bottom));
  max-width: 720px; margin: 0 auto; animation: sheetUp .18s ease; }
@keyframes sheetUp { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet .grab { width: 40px; height: 4px; border-radius: 99px; background: var(--line); margin: 4px auto 12px; }
.sheet-item { width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  font-size: 15.5px; font-weight: 600; color: var(--txt); padding: 14px 8px; border-radius: 12px;
  display: flex; align-items: center; gap: 12px; }
.sheet-item:active { background: var(--card2); }
.sheet hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; }
/* dejamos los botones de invitar/salir del header ocultos (van al panel Más) */
#invitar, #logout { display: none !important; }
