:root {
  --bg: #f5f6f8; --card: #fff; --text: #16181d; --muted: #6b7280; --line: #e5e7eb;
  --acc: #1F4FD8; --ok: #0f7b3e; --err: #b42318; --wa: #1a9e54;
  --marca: #1F4FD8; --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--acc); }
h1 { font-size: 1.6rem; margin: .2em 0 .6em; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .7em; }
h3 { margin: .2em 0; }
code { font: 600 .95em ui-monospace, Consolas, monospace; letter-spacing: .05em; }
.muted { color: var(--muted); }
.small, small { font-size: .85em; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }

/* ---------- Admin ---------- */
.topbar { display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: #111827; color: #fff; flex-wrap: wrap; }
.topbar a { color: #d1d5db; text-decoration: none; }
.topbar a:hover, .topbar a.on { color: #fff; }
.topbar nav { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; }
.topbar nav a.on { border-bottom: 2px solid #60a5fa; padding-bottom: 2px; }
.brand { font-weight: 700; color: #fff !important; display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #60a5fa; box-shadow: 0 0 0 4px rgba(96,165,250,.25); display: inline-block; }
.who { display: flex; gap: 12px; align-items: center; font-size: .9em; }
.who .muted { color: #9ca3af; }
.negsel select { background: #1f2937; color: #fff; border: 1px solid #374151; padding: 4px 8px; border-radius: 8px; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
.narrow { max-width: 420px; margin: 40px auto; }
.login-title { display: flex; align-items: center; gap: 10px; justify-content: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin-bottom: 16px; }
details.card summary { cursor: pointer; }
details.card[open] summary { margin-bottom: 14px; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .9em; }

.form label { display: block; margin-bottom: 12px; font-weight: 600; font-size: .92em; }
.form label small { font-weight: 400; color: var(--muted); display: block; margin-top: 3px; }
input, select, textarea { font: inherit; width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 9px; background: #fff; color: inherit; margin-top: 4px; }
input[type=checkbox] { width: auto; margin: 3px 0 0; }
input[type=color] { height: 42px; padding: 3px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--acc) 40%, transparent); border-color: var(--acc); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row2 { grid-template-columns: 1fr; } }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.inline-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.inline-form label { margin: 0; min-width: 160px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 12px; }
.filters input, .filters select { width: auto; flex: 1 1 160px; margin: 0; }
.mini { display: inline; }
.mini select { width: auto; margin: 0; padding: 4px 6px; }

.btn { display: inline-block; font: 600 .95em/1 inherit; padding: 11px 16px; border-radius: 9px; border: 0; background: var(--acc); color: #fff; text-decoration: none; cursor: pointer; font-family: inherit; }
.btn:hover { filter: brightness(1.08); }
.btn-sm { padding: 6px 10px; font-size: .85em; }
.btn-sec { background: #eef2ff; color: #1e3a8a; }
.btn-wa { background: var(--wa); color: #fff; }
.btn-danger { background: #fee4e2; color: var(--err); }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 6px 0; font: inherit; font-size: .85em; }

.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; }
.flash-ok { background: #e7f6ec; color: var(--ok); }
.flash-err { background: #fdecea; color: var(--err); }

.scroll-x { overflow-x: auto; padding: 0; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .8em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.card:not(.scroll-x) .tbl th, .card:not(.scroll-x) .tbl td { padding-left: 0; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.baja td { opacity: .5; }
.tbl tr.hl td { background: #fff8db; }
.tbl td a { text-decoration: none; }
.tag { font-size: .78em; padding: 2px 8px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.tag-libre { background: #eef2ff; color: #3730a3; }
.tag-asignada { background: #e7f6ec; color: var(--ok); }
.tag-baja, .tag-off { background: #f3f4f6; color: var(--muted); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 8px; vertical-align: -1px; }
.pager { display: flex; gap: 18px; justify-content: center; align-items: center; }
.sorteo h3 { font-size: 1.15rem; }
.sorteo form { margin-top: 8px; }
dialog { border: 0; border-radius: 16px; padding: 24px; text-align: center; max-width: 340px; }
dialog::backdrop { background: rgba(0,0,0,.5); }
#qrBox svg { width: 240px; height: 240px; }

/* ---------- Público (lo que ve el cliente en el celular) ---------- */
body.pub { background: #f2f3f5; min-height: 100vh; display: flex; flex-direction: column; }
.pub-head { background: var(--marca); color: #fff; padding: 22px 20px 56px; text-align: center; }
.pub-club { font-size: .75rem; letter-spacing: .35em; font-weight: 700; opacity: .85; }
.pub-neg { font-size: 1.35rem; font-weight: 800; margin-top: 2px; }
.pub-main { width: 100%; max-width: 480px; margin: -40px auto 0; padding: 0 14px 30px; flex: 1; }
.pub-hero, .pub-card, .pub-ok { background: #fff; border-radius: 18px; padding: 20px; margin-bottom: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.07); }
.pub-hero h1 { margin: 0 0 6px; font-size: 1.7rem; }
.pub-hero p { margin: 0; color: #374151; }
.pub-ok { background: #e7f6ec; color: var(--ok); font-weight: 600; box-shadow: none; }
.pub .btn { background: var(--marca); }
.pub .btn-wa { background: var(--wa); }
.pub .btn-sec { background: #f3f4f6; color: #111827; }
.btn-big { display: block; width: 100%; text-align: center; padding: 16px; font-size: 1.05rem; border-radius: 12px; margin-top: 10px; }
.pub .form label { font-size: .95em; }
.pub input, .pub select { font-size: 16px; padding: 12px; }
em.err { display: block; color: var(--err); font-style: normal; font-weight: 500; font-size: .88em; margin-top: 4px; }
.premio { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.premio:first-of-type { border-top: 0; }
.premio .ico { font-size: 1.6rem; width: 44px; height: 44px; display: grid; place-items: center; background: #f3f4f6; border-radius: 12px; flex: none; }
.premio small { display: block; color: var(--muted); }
.ganador { padding: 6px 0; }
.legal ol { padding-left: 1.2em; }
.legal li { margin-bottom: 8px; }
.pub-foot { text-align: center; color: #9ca3af; font-size: .8rem; padding: 14px; }

.socio-card { background: linear-gradient(135deg, var(--marca), color-mix(in srgb, var(--marca) 60%, #000)); color: #fff; border-radius: 18px; padding: 20px; margin-bottom: 14px; aspect-ratio: 85.6 / 54; display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.sc-top, .sc-foot { display: flex; justify-content: space-between; font-size: .85rem; opacity: .9; }
.sc-top span:first-child { letter-spacing: .3em; font-weight: 700; }
.sc-name { font-size: 1.8rem; font-weight: 800; }

/* ---------- v2: agentes, ficha, seguimiento ---------- */
.agente-row { display: flex; align-items: center; gap: 12px; }
.agente-row.big { align-items: flex-start; margin-bottom: 12px; }
.avatar-xs, .avatar-lg, .pub-avatar { border-radius: 50%; overflow: hidden; display: grid; place-items: center; flex: none; font-weight: 700; background: #e0e7ff; color: #3730a3; }
.avatar-xs { width: 36px; height: 36px; font-size: .85rem; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.8rem; }
.avatar-xs img, .avatar-lg img, .pub-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-prev { display: block; width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin: 6px 0; }
.stat-warn { border-color: #fbbf24; background: #fffbeb; }
a.stat { text-decoration: none; color: inherit; }
.tag-warn { background: #fef3c7; color: #92400e; margin-left: 6px; }
.alerta { color: #b45309; font-weight: 600; }
.tbtns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tcard .tstats { display: flex; gap: 14px; margin: 12px 0 4px; flex-wrap: wrap; font-size: .9em; color: var(--muted); }
.tcard .tstats b { color: var(--text); font-size: 1.15em; }
a.b { font-weight: 700; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: -4px 0 12px; }
.chip { border: 1px solid var(--line); background: #f9fafb; border-radius: 99px; padding: 5px 11px; font: inherit; font-size: .85em; cursor: pointer; }
.chip:hover { background: #eef2ff; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.tl-ico { width: 32px; height: 32px; border-radius: 10px; background: #f3f4f6; display: grid; place-items: center; flex: none; }
.mi-tarjeta { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.qr-inline svg { width: 180px; height: 180px; margin: 8px 0; }
.center { text-align: center; }
.logo-prev { display: block; background: #fafaf8; border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin: 6px 0; }
.logo-prev.dark { background: #151516; }
.logo-prev img { display: block; max-width: 100%; max-height: 60px; }

/* Público v2: encabezado con el agente */
.pub-head { padding-bottom: 60px; }
.pub-avatar { width: 88px; height: 88px; margin: 0 auto 10px; border: 3px solid rgba(255,255,255,.9); background: rgba(255,255,255,.18); color: #fff; font-size: 1.9rem; }
.pub-avatar.sm { width: 52px; height: 52px; margin: 0; border: 0; background: #e0e7ff; color: #3730a3; font-size: 1.1rem; }
.pub-sub { font-size: .9rem; opacity: .85; margin-top: 2px; }
.pub .btn-gw { background: #111; }
.pub .btn-aw { background: #000; }
.pub .guardar h2 { margin-bottom: .2em; }
.pub .contacto .agente-row { margin-bottom: 6px; }
.sc-name { font-size: 1.5rem; line-height: 1.15; }

/* ---------- v3: compras, premios, cumpleaños ---------- */
.alerta-premio { display: flex; gap: 14px; align-items: flex-start; background: #fff7e6; border: 2px solid #f5b83d; border-radius: 14px; padding: 16px 18px; margin-bottom: 16px; animation: pop .5s cubic-bezier(.2,.9,.3,1.3); }
.alerta-premio .ap-ico { font-size: 2rem; line-height: 1; }
.alerta-premio .ap-t { font-weight: 800; font-size: 1.15rem; color: #7a4a00; }
.alerta-premio .ap-s { color: #6b4a14; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.card-alerta { border-color: #f5b83d; background: #fffbf2; }
.prog { padding: 10px 0; border-top: 1px solid var(--line); }
.prog:first-of-type { border-top: 0; }
.prog-top { display: flex; justify-content: space-between; font-size: .9em; }
.prog-top b { font-variant-numeric: tabular-nums; }
.dots { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #cfcfca; background: transparent; }
.dots i.on { background: var(--marca, #1F4FD8); border-color: var(--marca, #1F4FD8); }
.admin .dots i.on { background: #111827; border-color: #111827; }
.sumar { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.sumar input { width: 64px; margin: 0; text-align: center; }
.sumar .btn { flex: 1; }
.caja-buscar .row-in { display: flex; gap: 8px; margin-top: 6px; }
.caja-buscar .row-in input { margin: 0; font-size: 17px; padding: 12px; }
.caja-socio strong { font-size: 1.05rem; }
.premio-pend { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fff7e6; border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.datos-chips { display: flex; flex-wrap: wrap; gap: 6px 10px; margin: -4px 0 10px; font-size: .92em; }
.datos-chips span { color: var(--muted); }
.cumple { display: grid; grid-template-columns: 80px 1fr 1fr; gap: 8px; }
.cumple select, .cumple input { margin-top: 4px; }

/* Público: premios y modo caja */
.pub-premio { background: #fff7e6; border: 2px solid #f5b83d; color: #6b4a14; border-radius: 16px; padding: 16px; margin-bottom: 14px; text-align: center; line-height: 1.5; }
.qr-caja { text-align: center; border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.qr-caja svg { width: 170px; height: 170px; }
.pub-card.staff { border: 2px solid #111827; }
.staff-t { font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #111827; margin-bottom: 10px; }
.staff-row { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.staff-row span { flex: 1; font-weight: 600; }
.staff-row input { width: 58px; margin: 0; text-align: center; padding: 10px 6px; }
.staff-row .btn { white-space: nowrap; }
.pub .alerta-premio .ap-t { font-size: 1rem; }

/* =====================================================================
   Tema Club Fidi — geométrico, minimalista, oscuro (panel y login)
   ===================================================================== */
@font-face { font-family: "Jost"; font-weight: 300; font-display: swap; src: url(fonts/jost-latin-300-normal.woff2) format("woff2"); }
@font-face { font-family: "Jost"; font-weight: 400; font-display: swap; src: url(fonts/jost-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Jost"; font-weight: 500; font-display: swap; src: url(fonts/jost-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Jost"; font-weight: 600; font-display: swap; src: url(fonts/jost-latin-600-normal.woff2) format("woff2"); }

body.admin {
  --bg: #121315; --card: #18191c; --card-2: #1e1f23; --text: #ecebe6; --muted: #9a9890; --line: #2a2b30;
  --acc: #c8ad7f; --brass: #c8ad7f; --ok: #7fc79a; --err: #f08f84; --wa: #1f9d55; --r: 16px;
  --warn-bg: #2a2418; --warn-line: #6b5530;
  color-scheme: dark;
  font: 400 15.5px/1.55 "Jost", "Futura", "Century Gothic", system-ui, sans-serif;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
.admin a { color: var(--brass); }
.admin h1 { font-weight: 300; font-size: 2.1rem; letter-spacing: -.015em; margin: .3em 0 .8em; }
.admin h2 { font-weight: 500; font-size: .78rem; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-bottom: 1.1em; }
.admin h3 { font-weight: 500; }
.admin .muted { color: var(--muted); }

/* Barra superior */
.admin .topbar { background: var(--bg); border-bottom: 1px solid var(--line); padding: 16px 24px; gap: 28px; }
.admin .topbar a { color: var(--muted); font-size: .95rem; }
.admin .topbar a:hover, .admin .topbar a.on { color: var(--text); }
.admin .topbar nav { gap: 22px; }
.admin .topbar nav a.on { border-bottom: 1px solid var(--brass); padding-bottom: 4px; }
.admin .brand { font-weight: 500; font-size: .95rem; letter-spacing: .28em; text-transform: uppercase; color: var(--text) !important; gap: 0; }
.admin .brand i { font-style: normal; font-weight: 300; color: var(--brass); }
.admin .dot { display: none; }
.admin .who { gap: 18px; }
.admin .negsel select { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: .9rem; }

/* Tarjetas y números */
.admin .wrap { padding-top: 34px; }
.admin .card, .admin .stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); }
.admin .card { padding: 24px; }
.admin .stats { gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.admin .stats .stat { border: 0; border-radius: 0; background: var(--bg); padding: 20px 22px; }
.admin .stat b { font-weight: 300; font-size: 2.4rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.admin .stat span { font-size: .85rem; }
.admin a.stat:hover { background: var(--card); }
.admin .stat-warn { background: var(--warn-bg) !important; }
.admin .stat-warn b { color: var(--brass); }

/* Formularios */
.admin input, .admin select, .admin textarea { background: var(--bg); border: 1px solid var(--line); color: var(--text); border-radius: 12px; padding: 10px 13px; }
.admin input::placeholder, .admin textarea::placeholder { color: #66655f; }
.admin input:focus, .admin select:focus, .admin textarea:focus { outline: 1px solid var(--brass); border-color: var(--brass); }
.admin .form label { font-weight: 500; }

/* Botones */
.admin .btn { background: var(--text); color: var(--bg); border-radius: 999px; font-weight: 500; padding: 12px 20px; letter-spacing: .01em; }
.admin .btn:hover { background: var(--brass); filter: none; }
.admin .btn-sm { padding: 7px 14px; }
.admin .btn-sec { background: transparent; color: var(--text); border: 1px solid var(--line); }
.admin .btn-sec:hover { border-color: var(--brass); background: transparent; color: var(--brass); }
.admin .btn-wa { background: var(--wa); color: #fff; }
.admin .btn-wa:hover { background: #24b462; }
.admin .btn-danger { background: transparent; color: var(--err); border: 1px solid #4a2a27; }
.admin .linkbtn { color: var(--muted); }

/* Avisos */
.admin .flash-ok { background: #17261d; color: var(--ok); }
.admin .flash-err { background: #2d1a18; color: var(--err); }
.admin .alerta-premio, .admin .card-alerta, .admin .premio-pend { background: var(--warn-bg); border-color: var(--warn-line); }
.admin .alerta-premio .ap-t { color: var(--brass); font-weight: 500; }
.admin .alerta-premio .ap-s { color: var(--text); }
.admin .alerta { color: var(--brass); }

/* Tablas, etiquetas, chips */
.admin .tbl th { color: var(--muted); font-weight: 500; letter-spacing: .14em; font-size: .72rem; }
.admin .tbl th, .admin .tbl td { border-bottom-color: var(--line); }
.admin .tbl tr.hl td { background: var(--warn-bg); }
.admin .tbl td a { color: var(--text); }
.admin .tbl td a:hover { color: var(--brass); }
.admin .tag { font-weight: 500; letter-spacing: .02em; }
.admin .tag-libre { background: #23242a; color: var(--text); }
.admin .tag-asignada { background: #17261d; color: var(--ok); }
.admin .tag-baja, .admin .tag-off { background: #202125; color: var(--muted); }
.admin .tag-warn { background: var(--warn-bg); color: var(--brass); }
.admin .chip { background: transparent; border-color: var(--line); color: var(--text); }
.admin .chip:hover { border-color: var(--brass); background: transparent; }
.admin .tl-ico, .admin .premio .ico { background: var(--card-2); }
.admin .avatar-xs, .admin .avatar-lg { background: var(--card-2); color: var(--brass); font-weight: 500; }
.admin .dots i { border-color: #45464c; }
.admin .dots i.on { background: var(--text); border-color: var(--text); }
.admin .tcard .tstats b { color: var(--text); font-weight: 500; }
.admin dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.admin .qr-inline svg, .admin #qrBox svg { background: #fff; padding: 10px; border-radius: 12px; }
.admin .logo-prev { background: #f3f1ec; }
.admin .logo-prev.dark { background: #0d0e0f; }
.admin .login-title { gap: 0; }
.admin h1.login-title { font-size: 1.4rem; margin: 10px 0 26px; }

/* Club Fidi: tipografía geométrica también en lo que ve el cliente */
body.pub { font-family: "Jost", "Futura", "Century Gothic", system-ui, sans-serif; }
.pub-neg { font-weight: 500; letter-spacing: .02em; }
.pub-club { font-weight: 500; letter-spacing: .32em; }
.pub-hero h1 { font-weight: 400; letter-spacing: -.01em; }
.pub .btn { border-radius: 999px; font-weight: 500; }

/* Clientes: tachito y selección múltiple */
.tbl th.chk, .tbl td.chk { width: 34px; padding-right: 0; }
.tbl .chk input { width: 16px; height: 16px; margin: 0; accent-color: var(--acc); }
.tacho { background: none; border: 1px solid transparent; border-radius: 999px; padding: 6px; margin-left: 4px; color: var(--muted); cursor: pointer; vertical-align: middle; line-height: 0; }
.tacho:hover, .tacho:focus-visible { color: var(--err); border-color: currentColor; }
.sel-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card); border: 1px solid var(--err); border-radius: var(--r); padding: 10px 16px; margin-bottom: 12px; }
.sel-bar[hidden] { display: none; }
