/* ClubRut — sistema de diseno. Minimalista, profesional, mucho blanco.
   Un solo azul de acento. Paleta fija (no inventar tonos nuevos). */
:root {
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-deep: #1e3a8a;
  --blue-tint: #eff4ff;
  --blue-tint-2: #dbe7ff;
  --canvas: #f5f7fb;      /* fondo general (no blanco puro) */
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #e5e7eb;
  --ink: #111827;
  --muted: #6b7280;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, 0.08);

  /* --- Sistema de diseño mobile-first (Parte 0). Aditivo: no cambia la marca. --- */
  /* Escala de espaciado (base 4px) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 20px;
  --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px; --s-16: 64px;
  /* Tipografía responsiva */
  --fs-xs: clamp(.7rem, 1.8vw, .8rem);
  --fs-sm: clamp(.85rem, 2vw, .9rem);
  --fs-base: clamp(.95rem, 2.2vw, 1rem);
  --fs-lg: clamp(1.05rem, 2.5vw, 1.15rem);
  --fs-xl: clamp(1.2rem, 3vw, 1.4rem);
  --fs-2xl: clamp(1.4rem, 4vw, 1.9rem);
  --fs-3xl: clamp(1.75rem, 5vw, 2.5rem);
  /* Transiciones */
  --t-fast: 150ms ease; --t-base: 220ms ease; --t-slow: 350ms ease;
  /* Capas */
  --z-dropdown: 100; --z-sticky: 200; --z-nav: 1090; --z-topbar: 1100; --z-modal: 1300; --z-toast: 1400;
  /* Layout */
  --navbar-h: 56px; --bottomnav-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
a { color: var(--blue); text-decoration: none; }

.hidden { display: none !important; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; font-weight: 800; font-size: 19px; letter-spacing: -0.02em; color: var(--ink); }
.brand .dot { color: var(--blue); }
.brand .blogo { width: 26px; height: 26px; border-radius: 7px; margin-right: 8px; box-shadow: 0 3px 9px rgba(37,99,235,0.35); }
.topbar .brand { color: #fff; }
.topbar .brand .dot { color: #bfd3ff; }
.auth-card .brand .blogo { width: 34px; height: 34px; border-radius: 9px; margin-right: 10px; }

/* ---------- Layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  background: linear-gradient(90deg, var(--blue-deep), var(--blue));
  color: #fff;
  z-index: 1100;
  box-shadow: var(--shadow);
}
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: rgba(255,255,255,0.85); }
.topbar .who .badge.promo { background: rgba(255,255,255,0.18); color: #fff; border: 0; }
.topbar .btn.ghost { background: rgba(255,255,255,0.12); color: #fff; border: 1px solid rgba(255,255,255,0.25); }
.topbar .btn.ghost:hover { background: rgba(255,255,255,0.22); border-color: #fff; }

.nav {
  display: flex;
  gap: 8px;
  padding: 14px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  position: sticky;
  top: 56px;
  z-index: 1090;
}
.nav button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.nav button:hover { color: var(--blue-hover); background: var(--blue-tint); }
.nav button.active { color: #fff; background: var(--blue); }

.page { max-width: 1080px; margin: 0 auto; padding: 26px 24px 64px; }
.page.narrow { max-width: 560px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card h2 { font-size: 16px; margin-bottom: 4px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin: 14px 0 6px; }
label .opt { font-weight: 400; color: var(--muted); }
.help { font-size: 12px; color: var(--muted); margin-top: 6px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"], select {
  width: 100%;
  min-height: 48px; /* touch target */
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--ink);
  background: #fff;
  outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }
input.big { font-size: 22px; font-weight: 600; letter-spacing: 0.02em; min-height: 56px; padding: 14px; }

/* Emitir puntos: preview de puntos en vivo bajo el monto */
.pts-preview { margin: 8px 0 0; font-size: 15px; font-weight: 700; color: var(--muted); min-height: 22px; }
.pts-preview.on { color: var(--blue); }
.pts-preview b { color: var(--blue); }
.pts-preview.redeem { color: var(--ok); }
.pts-preview.redeem b { color: var(--ok); }
.pts-max { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.pts-max b { color: var(--blue); }
.pts-max.off { color: var(--err); }
/* Preset de canje seleccionado */
#sm_redquick .btn.ghost.sm.sel { background: var(--blue); color: #fff; border-color: var(--blue); }

/* CTA grande (cajero): botón full-width, alto 56px */
.btn.cta { width: 100%; min-height: 56px; font-size: 17px; font-weight: 700; border-radius: 13px; margin-top: 6px; }
.btn.cta.green { background: var(--ok); }
.btn.cta.green:hover { background: #03684a; }

/* Pantalla de éxito (cajero) */
.sale-ok { text-align: center; padding: 8px 0 4px; }
.sale-ok .check {
  width: 72px; height: 72px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--ok-bg); color: var(--ok); display: flex; align-items: center; justify-content: center;
  animation: pop .4s cubic-bezier(.2,.9,.3,1.4);
}
.sale-ok .check svg { width: 40px; height: 40px; }
.sale-ok h3 { font-size: 22px; }
.sale-ok .ok-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.field-ok input { border-color: var(--ok); }
.field-err input { border-color: var(--err); }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--blue); flex: none; }
.check span { font-size: 13px; color: var(--ink); }
.check span small { display: block; color: var(--muted); font-weight: 400; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  margin-top: 16px;
  padding: 13px 16px;
  background: var(--blue);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}
.btn:hover { background: var(--blue-hover); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.sec { background: var(--blue-tint); color: var(--blue); }
.btn.sec:hover { background: #e0eaff; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn.ghost:hover { color: var(--ink); border-color: var(--ink); }
.btn.sm { width: auto; margin: 0; padding: 8px 14px; font-size: 13px; }
.btn.danger { background: var(--err-bg); color: var(--err); }
.btn.danger:hover { background: var(--err); color: #fff; }

/* ---------- Feedback ---------- */
.note { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.err { background: var(--err-bg); color: var(--err); }
.note.info { background: var(--blue-tint); color: var(--blue-hover); }

/* ---------- Member card (caja) ---------- */
.member {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--blue-tint);
}
.member .rut { font-size: 15px; font-weight: 700; }
.member .balance { font-size: 40px; font-weight: 800; color: var(--blue); line-height: 1.1; margin: 6px 0 2px; }
.member .balance small { font-size: 15px; font-weight: 600; color: var(--muted); }
.member .next { font-size: 13px; color: var(--muted); }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.badge.new { background: var(--blue); color: #fff; }
.badge.tier-oro { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge.tier-plata { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge.tier-bronce { background: #fdf0e6; color: #9a5b2c; border: 1px solid #e7c3a3; }
.badge.promo { background: #fff; color: var(--ok); border: 1px solid var(--ok); }

/* result of a sale: big readable numbers */
.result { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 8px; }
.result .blk .n { font-size: 30px; font-weight: 800; color: var(--blue); }
.result .blk .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--blue);
}
.kpi .n { font-size: 28px; font-weight: 800; color: var(--blue-deep); }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
/* KPI destacado (acento lleno) */
.kpi.accent { background: linear-gradient(160deg, var(--blue), var(--blue-hover)); border-color: transparent; }
.kpi.accent .n { color: #fff; }
.kpi.accent .l { color: rgba(255,255,255,0.85); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tr.clickable { cursor: pointer; transition: background 0.12s ease; }
tr.clickable:hover td { background: var(--blue-tint); }
.pill { cursor: pointer; transition: filter 0.12s ease, transform 0.05s ease; }
.pill:hover { filter: brightness(0.96); }
.pill:active { transform: translateY(1px); }
summary { transition: color 0.12s ease; }
input, select, textarea { transition: border-color 0.12s ease, box-shadow 0.12s ease; }
.pos { color: var(--ok); font-weight: 600; }
.neg { color: var(--err); font-weight: 600; }
.muted { color: var(--muted); }

/* ---------- Auth screen ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card .brand { font-size: 26px; justify-content: center; margin-bottom: 4px; }
.auth-card .tagline { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.switcher { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.switcher a { cursor: pointer; font-weight: 600; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.spinner { font-size: 13px; color: var(--muted); }

/* ---------- Campo de contraseña con ojito ---------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap > input { width: 100%; padding-right: 44px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; cursor: pointer; color: var(--muted); padding: 6px; display: flex; align-items: center; }
.pw-eye:hover { color: var(--blue); }
.pw-eye svg { width: 20px; height: 20px; }

/* ---------- Toggle / switch ---------- */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch > input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider { flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--border); position: relative; transition: background .2s; margin-top: 1px; }
.switch .slider::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .2s; }
.switch > input:checked + .slider { background: var(--blue); }
.switch > input:checked + .slider::after { transform: translateX(18px); }
.switch .switch-txt { font-size: 14px; color: var(--ink); font-weight: 600; }
.switch .switch-txt small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- Ingresos (módulo dashboard) ---------- */
.seg { display: inline-flex; background: var(--blue-tint); border-radius: 999px; padding: 3px; gap: 2px; flex: none; }
.seg button { border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: 13px; padding: 7px 14px; border-radius: 999px; cursor: pointer; }
.seg button:hover { color: var(--blue-deep); }
.seg button.active { background: #fff; color: var(--blue-deep); box-shadow: var(--shadow); }
.rev-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 6px; }
@media (max-width: 560px) { .rev-kpis { grid-template-columns: 1fr; gap: 8px; } }
.rev-kpis .rk { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: linear-gradient(180deg, #fbfcff, #fff); }
.rev-kpis .rk .n { font-size: 24px; font-weight: 800; color: var(--blue-deep); letter-spacing: -.02em; }
.rev-kpis .rk .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; font-weight: 600; }

/* barras horizontales (mejores días / horarios) */
.hbar { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.hbar-l { width: 96px; flex: none; font-size: 13px; color: var(--ink); font-weight: 600; }
.hbar-track { flex: 1; height: 12px; background: var(--blue-tint); border-radius: 999px; overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, #7aa6ff, var(--blue)); border-radius: 999px; }
.hbar.best .hbar-fill { background: linear-gradient(90deg, #34d399, var(--ok)); }
.hbar-v { width: 88px; flex: none; text-align: right; font-size: 13px; font-weight: 700; color: var(--blue-deep); }
.hbar.best .hbar-v { color: var(--ok); }
@media (max-width: 560px) { .hbar-l { width: 70px; font-size: 12px; } .hbar-v { width: 70px; font-size: 12px; } }

/* ---------- Saludo de bienvenida (manager y cajero) ---------- */
.greet {
  background: linear-gradient(100deg, var(--blue-deep), var(--blue));
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 0 0 18px;
  box-shadow: var(--shadow-md);
}
.greet-hi { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.greet-sub { font-size: 14px; color: rgba(255, 255, 255, 0.92); margin-top: 4px; }
.greet-stat { color: rgba(255, 255, 255, 0.7); }

/* ---------- Sucursales: insights + heatmap ---------- */
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; margin-top: 14px; }
.insight { background: var(--blue-tint); border: 1px solid var(--blue-tint-2); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--ink); line-height: 1.4; }
.heatrow { display: flex; align-items: center; gap: 3px; margin-bottom: 3px; }
.heatlbl { width: 32px; flex: none; font-size: 11px; color: var(--muted); font-weight: 600; }
.heatcell { flex: 1; min-width: 12px; height: 24px; border-radius: 4px; }
.heataxis { display: flex; gap: 3px; margin: 4px 0 0 35px; }
.heataxis span { flex: 1; min-width: 12px; text-align: left; font-size: 9px; color: var(--muted); }

/* ---------- Map (owner) ---------- */
/* position+z-index+isolation: confina los z-index altos de Leaflet (panes/controles
   llegan a 1000) dentro del mapa, para que no se monten sobre la barra superior al hacer scroll. */
#map { height: 380px; border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; position: relative; z-index: 0; isolation: isolate; }
.map-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px; }
.map-legend .leg-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.map-legend .leg-item i { width: 13px; height: 13px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); display: inline-block; flex: none; box-shadow: inset 0 0 0 2px #fff; }
/* Pin (alfiler) del mapa: sin la caja blanca por defecto de Leaflet + sombra suave. */
.pin-marker { background: none; border: 0; }
.pin-marker svg { filter: drop-shadow(0 3px 4px rgba(0,0,0,.35)); display: block; }
/* Leads: mensaje truncado a 2 líneas (el texto completo va en el title). */
.lead-msg { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 13px; color: #475569; }
select.lead-seg { min-width: 150px; width: 100%; padding: 7px 30px 7px 10px; font-size: 13px; border-radius: 8px; }
/* Reporte del comercio (detalle owner): mini-barras de evolución mensual. */
.repbars { display: flex; align-items: flex-end; gap: 8px; height: 96px; margin: 10px 0 4px; }
.repbars .rb { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.repbars .rb .bar { width: 100%; max-width: 34px; background: linear-gradient(180deg, var(--blue), var(--blue-deep)); border-radius: 6px 6px 0 0; min-height: 3px; }
.repbars .rb .lbl { font-size: 11px; color: var(--muted); }
.repbars .rb .val { font-size: 11px; font-weight: 700; color: var(--blue-deep); }
.map-legend .leg-item small { color: var(--muted); font-weight: 600; }
.leaflet-popup-content { font: 13px system-ui; }
.leaflet-popup-content b { color: var(--blue); }

/* ---------- Status pill ---------- */
.pill { display:inline-block; font-size:11px; font-weight:700; padding:3px 9px; border-radius:999px; }
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.off { background: var(--err-bg); color: var(--err); }
.pill.plan { background: var(--blue-tint); color: var(--blue-hover); text-transform: capitalize; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; text-align: left; }
.linklike:hover { text-decoration: underline; }

textarea { font: inherit; }

/* ---------- Selector de banners de campaña ---------- */
.banners { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 4px; }
@media (max-width: 560px) { .banners { grid-template-columns: 1fr; } }
.bsel { border: 2px solid var(--border); background: #fff; border-radius: 14px; padding: 6px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.bsel:hover { border-color: var(--blue); }
.bsel.on { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-tint); }

/* ---------- Modal ---------- */
.modal-ov { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 460px; box-shadow: var(--shadow-md); max-height: 90vh; overflow-y: auto; }
.modal h2 { font-size: 19px; }

/* ---------- Dashboard: gráfico y donut (estilo landing) ---------- */
/* align-items:start: cada tarjeta mide lo suyo (el mapa de 380px no estira a su vecina). */
.charts2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-top: 18px; align-items: start; }
@media (max-width: 760px) { .charts2 { grid-template-columns: 1fr; } }
.chart-ct { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 18px; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 130px; }
.bars .b { flex: 1; background: linear-gradient(180deg, #7aa6ff, var(--blue)); border-radius: 6px 6px 0 0; position: relative; min-height: 4px; }
.bars .b::after { content: attr(data-m); position: absolute; bottom: -22px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.bars .b .v { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: 11px; font-weight: 700; color: var(--blue-deep); }
.bars .b.peak { background: linear-gradient(180deg, #34d399, var(--ok)); }
.chart-card { padding-bottom: 36px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut { width: 140px; height: 140px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center; }
.donut .hole { width: 104px; height: 104px; background: #fff; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut .hole b { font-size: 32px; color: var(--blue-deep); }
.donut .hole span { font-size: 11px; color: var(--muted); }

/* ---------- Confirmación antes de emitir ---------- */
.confirm {
  margin-top: 16px;
  border: 2px solid var(--blue);
  background: var(--blue-tint);
  border-radius: var(--radius);
  padding: 18px;
}
.confirm-h { font-weight: 800; color: var(--blue-deep); margin-bottom: 12px; font-size: 15px; }
.confirm-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid #dbe7ff; font-size: 14px;
}
.confirm-row:last-of-type { border-bottom: 0; }
.confirm-row span { color: var(--muted); }
.confirm .btn { margin-top: 0; }

/* ---------- Shell mobile: nombre del negocio + bottom tab bar + hoja "Más" ---------- */
.tb-name { display: none; }
.bottomnav { display: none; }
.sheet-ov {
  position: fixed; inset: 0; z-index: var(--z-modal); background: rgba(16,24,40,.45);
  display: flex; align-items: flex-end; opacity: 0; transition: opacity var(--t-base);
}
.sheet-ov.open { opacity: 1; }
.sheet {
  width: 100%; background: var(--bg); border-radius: 20px 20px 0 0;
  padding: 8px 16px calc(16px + var(--safe-b)); transform: translateY(100%);
  transition: transform var(--t-base); max-height: 85dvh; overflow-y: auto;
}
.sheet-ov.open .sheet { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 999px; background: var(--border); margin: 6px auto 14px; }
.sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sheet-item {
  border: 1px solid var(--border); background: var(--bg); border-radius: var(--radius-sm); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 14px 6px;
  color: var(--ink); font: inherit; font-size: 12px; font-weight: 600; min-height: 72px; text-align: center;
}
.sheet-item svg { width: 24px; height: 24px; color: var(--blue); }
.sheet-sep { height: 1px; background: var(--border); margin: 14px 0; }
.sheet-row {
  width: 100%; border: 0; background: none; cursor: pointer; display: flex; align-items: center; gap: 12px;
  padding: 14px 6px; color: var(--ink); font: inherit; font-size: 15px; font-weight: 600; min-height: 48px;
}
.sheet-row svg { width: 22px; height: 22px; color: var(--muted); }
.sheet-row.danger, .sheet-row.danger svg { color: var(--err); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: var(--z-toast); top: calc(12px + env(safe-area-inset-top,0px)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; background: var(--ink); color: #fff; border-radius: 12px; padding: 13px 16px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 10px; position: relative; overflow: hidden; cursor: pointer;
  opacity: 0; transform: translateY(-12px); transition: opacity var(--t-base), transform var(--t-base); }
.toast.in { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--ok); }
.toast.error { background: var(--err); }
.toast.warning { background: var(--warning, #d97706); }
.toast .toast-bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: rgba(255,255,255,.5);
  transform-origin: left; animation: toastbar linear forwards; }
@keyframes toastbar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (min-width: 761px) { .toasts { left: auto; right: 18px; transform: none; } }

/* ---------- Diálogo de confirmación (bottom sheet mobile / modal desktop) ---------- */
.cd-ov { position: fixed; inset: 0; z-index: var(--z-modal); background: rgba(16,24,40,.5);
  display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity var(--t-base); }
.cd-ov.open { opacity: 1; }
.cd { width: 100%; background: var(--bg); border-radius: 20px 20px 0 0; padding: 8px 20px calc(20px + var(--safe-b));
  transform: translateY(100%); transition: transform var(--t-base); }
.cd-ov.open .cd { transform: translateY(0); }
.cd h3 { font-size: 19px; margin: 6px 0 6px; }
.cd p { color: var(--muted); font-size: 14.5px; margin: 0 0 16px; }
.btn.cta.danger { background: var(--err); color: #fff; }
.btn.cta.danger:hover { background: #b91c1c; color: #fff; }
@media (min-width: 561px) {
  .cd-ov { align-items: center; }
  .cd { max-width: 420px; border-radius: var(--radius); transform: scale(.95); }
  .cd-ov.open .cd { transform: scale(1); }
  .cd .sheet-handle { display: none; }
}

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty .ic { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; background: var(--blue-tint); color: var(--blue);
  display: flex; align-items: center; justify-content: center; }
.empty .ic svg { width: 28px; height: 28px; }
.empty h3 { font-size: 16px; color: var(--ink); margin-bottom: 4px; }
.empty p { font-size: 14px; margin: 0 0 14px; }

/* ---------- Skeleton (shimmer) ---------- */
.skel { background: linear-gradient(90deg, var(--border) 25%, #eef1f5 37%, var(--border) 63%); background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite; border-radius: 8px; }
.skel-row { height: 56px; margin-bottom: 10px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } .toast .toast-bar { animation: none; } }

/* Tabla -> tarjetas en mobile (patrón reutilizable: clase .cardify + data-label en cada td) */
@media (max-width: 700px) {
  table.cardify { display: block; overflow: visible; white-space: normal; }
  table.cardify thead { display: none; }
  table.cardify tbody { display: block; }
  table.cardify tr {
    display: block; border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px 14px; margin-bottom: 10px; background: var(--bg);
  }
  table.cardify tr.clickable { cursor: pointer; }
  table.cardify td {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    padding: 5px 0; border: 0 !important; white-space: normal; text-align: right;
  }
  table.cardify td::before {
    content: attr(data-label); color: var(--muted); font-weight: 600; font-size: 13px;
    text-align: left; flex: none;
  }
  table.cardify td:empty { display: none; }
  /* la 1ª celda (normalmente nombre/RUT) como título de la tarjeta */
  table.cardify td:first-child { font-size: 15px; font-weight: 700; padding-bottom: 8px; }
  table.cardify td:first-child::before { display: none; }
}

/* ---------- Responsive (mobile) ---------- */
@media (max-width: 640px) {
  .card { padding: 18px; }
  /* tablas (no cardify): scroll horizontal en vez de cortarse */
  table:not(.cardify) { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .kpi .n { font-size: 24px; }
  input.big { font-size: 19px; }
  #map { height: 300px; }
  .boleta-frame { height: 600px; }
}

/* Shell mobile-first: bottom tab bar (≤760px) */
@media (max-width: 760px) {
  .topbar { padding: 0 14px; height: var(--navbar-h); }
  .topbar .who { display: none; }
  .tb-name { display: block; flex: 1; text-align: center; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; padding: 0 8px; font-weight: 800; font-size: 15px; color: #fff; }
  .nav { display: none; }
  .page { padding: 16px 16px calc(var(--bottomnav-h) + var(--safe-b) + 20px); }

  .bottomnav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-topbar);
    align-items: center; justify-content: space-around; gap: 2px;
    background: var(--bg); border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + var(--safe-b)); box-shadow: 0 -2px 12px rgba(16,24,40,.06);
  }
  .bn-item {
    flex: 1; min-width: 0; border: 0; background: none; cursor: pointer; font: inherit;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; color: var(--muted); font-size: 11px; font-weight: 600; border-radius: 12px; min-height: 48px;
    -webkit-tap-highlight-color: transparent;
  }
  .bn-item svg { width: 23px; height: 23px; }
  .bn-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bn-item.active { color: var(--blue); }
  .bn-fab {
    flex: 0 0 auto; border: 0; background: none; cursor: pointer; font: inherit;
    display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 0 2px;
    color: var(--muted); font-size: 11px; font-weight: 700; -webkit-tap-highlight-color: transparent;
  }
  .bn-fab svg {
    width: 30px; height: 30px; color: #fff; background: linear-gradient(135deg, var(--blue), var(--blue-deep));
    border-radius: 16px; padding: 9px; box-sizing: content-box; box-shadow: 0 6px 16px rgba(37,99,235,.45);
    margin-top: -22px; border: 3px solid var(--bg);
  }
  .bn-fab.active { color: var(--blue); }
}

/* ---------- Boleta HTML (preview email) ---------- */
.boleta-frame {
  width: 100%;
  height: 560px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  background: #f5f7fb;
}

/* ---------- Boleta (texto, fallback) ---------- */
.boleta {
  margin-top: 10px;
  background: #fcfcfd;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font: 12.5px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-x: auto;
}

/* ---- Hoja de ruta del vendedor (módulo F) ---- */
.rt-num {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  background: var(--brand, #2563eb); color: #fff; flex: none;
}
.rt-num.on { background: var(--ok, #16a34a); }
.card.rt-done { opacity: .72; }
.rt-pin {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff;
  background: #2563eb; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.rt-pin.done { background: #16a34a; }
.rt-home {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  font-size: 18px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.4));
}

/* Botón basura (eliminar cajero): minimal, rojo al pasar el cursor */
.btn-trash { padding: 6px 9px; color: var(--muted); }
.btn-trash:hover { color: #dc2626; background: #fef2f2; border-color: #fecaca; }
.btn-trash svg { display: block; }

/* Reglas de puntos dentro de Emitir (sección plegable del manager) */
.sm-rules summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
.sm-rules summary::-webkit-details-marker { display: none; }
.sm-rules summary .chev { margin-left: auto; transition: transform .2s ease; color: var(--muted); }
.sm-rules details[open] summary .chev { transform: rotate(180deg); }
.sm-rules .sub { margin-top: 4px; }

/* ---------- Tour interactivo (tutorial guiado) ---------- */
.tour-ov { position: fixed; inset: 0; z-index: 1500; } /* sobre topbar (1100) y nav (1090) */
.tour-ov.dim { background: rgba(8, 15, 35, 0.62); }
.tour-spot {
  position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(8, 15, 35, 0.62), 0 0 0 3px rgba(255, 255, 255, 0.95), 0 0 26px rgba(37, 99, 235, 0.6);
  transition: top .22s cubic-bezier(.2,.7,.2,1), left .22s cubic-bezier(.2,.7,.2,1),
              width .22s cubic-bezier(.2,.7,.2,1), height .22s cubic-bezier(.2,.7,.2,1);
  animation: tourpulse 2s ease-in-out infinite;
}
@keyframes tourpulse {
  0%, 100% { box-shadow: 0 0 0 9999px rgba(8,15,35,.62), 0 0 0 3px rgba(255,255,255,.95), 0 0 26px rgba(37,99,235,.6); }
  50%      { box-shadow: 0 0 0 9999px rgba(8,15,35,.62), 0 0 0 5px rgba(255,255,255,1), 0 0 38px rgba(79,134,255,.85); }
}
.tour-pop {
  position: fixed; z-index: 1501; background: #fff; border-radius: 16px; padding: 18px 20px;
  width: min(340px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(8, 15, 35, 0.35);
  animation: tourpop .18s cubic-bezier(.2,.8,.2,1);
  max-height: calc(100dvh - 32px); overflow-y: auto; /* nunca mas alto que la ventana */
}
@keyframes tourpop { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }
.tour-pop.center { left: 50%; top: 50%; transform: translate(-50%, -50%); }
.tour-pop h3 { margin: 4px 0 8px; font-size: 18px; }
.tour-pop p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.55; }
.tour-prog { font-size: 11px; font-weight: 700; color: var(--blue); letter-spacing: .04em; }
.tour-foot { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.tour-skip { margin-right: auto; font-size: 13px; color: var(--muted); }
.tour-skip:hover { color: var(--ink); }
.tour-btn { width: 34px; padding: 6px 0; font-weight: 800; border-radius: 50%; }
@media (max-width: 640px) {
  .tour-pop, .tour-pop.center {
    left: 16px !important; right: 16px; width: auto; transform: none;
    top: auto !important; bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    /* hoja inferior: si el texto es largo, scrollea adentro en vez de salirse por arriba */
    max-height: calc(100dvh - 120px - env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- Chatbot de feedback 💬 (flotante, cuentas de comercio) ---------- */
#fbchat_btn {
  position: fixed; right: 18px; bottom: 18px; z-index: 1200;
  width: 54px; height: 54px; border-radius: 50%; border: 0; cursor: pointer;
  background: linear-gradient(150deg, var(--brand, #2563eb), #1e3a8a); color: #fff; font-size: 24px;
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.45);
  transition: transform .15s ease, box-shadow .2s ease;
}
#fbchat_btn:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 14px 34px rgba(37,99,235,.55); }
#fbchat_btn.open { transform: scale(.92); }
#fbchat {
  position: fixed; right: 18px; bottom: 84px; z-index: 1200;
  width: min(360px, calc(100vw - 32px)); height: min(480px, calc(100dvh - 120px));
  background: #fff; border-radius: 18px; box-shadow: 0 24px 60px rgba(8,15,35,.35);
  display: none; flex-direction: column; overflow: hidden;
}
#fbchat.open { display: flex; animation: tourpop .18s cubic-bezier(.2,.8,.2,1); }
.fb-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px;
  background: linear-gradient(150deg, var(--brand, #2563eb), #1e3a8a); color: #fff; }
.fb-head .fb-sub { font-size: 12px; opacity: .85; }
.fb-x { background: none; border: 0; color: #fff; font-size: 18px; cursor: pointer; padding: 4px 8px; }
.fb-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #f7f9fd; }
.fb-msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.fb-msg.bot { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 4px; align-self: flex-start; }
.fb-msg.me { background: var(--brand, #2563eb); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.fb-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; background: #f7f9fd; }
.fb-chips button { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 7px 12px;
  font: inherit; font-size: 13px; cursor: pointer; transition: all .12s; }
.fb-chips button:hover { border-color: var(--brand, #2563eb); color: var(--brand, #2563eb); }
.fb-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: #fff; }
.fb-input input { flex: 1; min-height: 42px; }
@media (max-width: 760px) {
  /* sobre el bottom tab bar */
  #fbchat_btn { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  #fbchat { bottom: calc(148px + env(safe-area-inset-bottom, 0px)); height: min(440px, calc(100dvh - 220px)); }
}

/* ---------- Mascota ClubRut 👀 (el globo del buzón, con ojos) ----------
   Guía el tutorial paso a paso. Parpadea y flota suavecito. */
.mascota {
  position: relative; width: 46px; height: 40px; flex: none;
  background: linear-gradient(150deg, var(--brand, #2563eb), #1e3a8a);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35);
  display: flex; align-items: center; justify-content: center; gap: 7px;
  animation: mascota-bob 2.6s ease-in-out infinite;
}
.mascota .m-eye {
  width: 9px; height: 12px; background: #fff; border-radius: 50%;
  position: relative; overflow: hidden;
  animation: mascota-blink 3.4s ease-in-out infinite;
}
.mascota .m-eye::after {
  content: ""; position: absolute; left: 50%; top: 55%; transform: translate(-50%, -50%);
  width: 5px; height: 6px; background: #0f172a; border-radius: 50%;
}
.mascota .m-mouth {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 12px; height: 6px; border: 2px solid rgba(255,255,255,.95); border-top: 0;
  border-radius: 0 0 12px 12px;
}
.mascota.big { width: 84px; height: 72px; border-radius: 26px 26px 26px 6px; gap: 13px; margin: 4px auto 10px; }
.mascota.big .m-eye { width: 16px; height: 21px; }
.mascota.big .m-eye::after { width: 9px; height: 11px; }
.mascota.big .m-mouth { bottom: 13px; width: 22px; height: 10px; border-width: 3px; }
@keyframes mascota-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes mascota-blink { 0%, 91%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.08); } }
.tour-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
@media (prefers-reduced-motion: reduce) { .mascota, .mascota .m-eye { animation: none; } }

/* ---------- QR de auto-inscripción (Configuración) ---------- */
.qr-card { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qr-svg { width: 168px; height: 168px; flex: none; border: 1px solid var(--border); border-radius: 14px; padding: 10px; background: #fff; }
.qr-svg svg { width: 100%; height: 100%; display: block; }
.qr-side { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.qr-side .btn { align-self: stretch; }
.qr-hint { font-size: 13px; color: var(--muted); }
