:root {
  --accent: #16a34a;
  --bg: #0b1220;
  --bg2: #111a2e;
  --panel: #152038;
  --line: #243252;
  --text: #e8eefc;
  --muted: #93a3c4;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #22c55e;
  --radius: 16px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 480px; margin: 0 auto; padding: 16px; }
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.panel + .panel { margin-top: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stack > * + * { margin-top: 12px; }

/* Formularios */
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  min-height: 48px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input[type=checkbox] { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }
input[type=color] { padding: 4px; height: 48px; }
.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); font-size: .95rem; }
.field + .field { margin-top: 12px; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: #fff; border: 0; border-radius: 12px;
  padding: 12px 18px; min-height: 48px; font: inherit; font-weight: 650;
  cursor: pointer; text-decoration: none; transition: transform .05s, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.warn { background: var(--warn); color: #1a1200; }
.btn.ghost { background: transparent; color: var(--muted); padding: 8px 10px; min-height: 36px; }
.btn.big { font-size: 1.15rem; min-height: 60px; padding: 14px 22px; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }

/* Avisos */
.toast-host { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1000; display: grid; gap: 8px; width: min(92vw, 440px); }
.toast { background: #1e2b48; border: 1px solid var(--line); border-left: 5px solid var(--accent); padding: 14px 16px; border-radius: 12px; box-shadow: 0 10px 30px #0008; animation: pop .2s ease-out; }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.alert { padding: 12px 14px; border-radius: 12px; background: #3b1d1d; border: 1px solid #7f1d1d; color: #fecaca; }
.alert.ok { background: #12301f; border-color: #166534; color: #bbf7d0; }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--bg2); border: 1px solid var(--line); color: var(--muted); }
.badge.accent { background: var(--accent); color: #fff; border-color: transparent; }
.badge.warn { background: var(--warn); color: #1a1200; border-color: transparent; }

/* Tarjeta de fidelización */
.loyalty {
  position: relative; overflow: hidden;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #0b1220));
  border-radius: 22px; padding: 22px; color: #fff;
  box-shadow: 0 18px 50px color-mix(in srgb, var(--accent) 35%, transparent);
}
.loyalty::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
  border: 18px solid #ffffff1a;
}
.loyalty .club { font-weight: 800; font-size: 1.3rem; letter-spacing: .3px; }
.loyalty .holder { opacity: .92; margin-top: 2px; }
.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 20px 0 8px; position: relative; z-index: 1; }
.stamp {
  aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center;
  background: #ffffff22; border: 2px dashed #ffffff66; font-weight: 700; font-size: .9rem; color: #ffffffaa;
}
.stamp.on { background: #fff; border: 2px solid #fff; color: var(--accent); }
.stamp.on svg { width: 70%; height: 70%; }
.stamp.new { animation: stampin .6s cubic-bezier(.2,1.6,.4,1); }
.stamp.goal { border-style: solid; border-color: #fde047; color: #fde047; }
.stamp.goal.on { background: #fde047; color: #1a1200; }
@keyframes stampin { 0% { transform: scale(2.2) rotate(-25deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.progress-text { font-size: 1.02rem; position: relative; z-index: 1; }
.reward-ready {
  margin-top: 14px; background: #fde047; color: #1a1200; border-radius: 14px; padding: 14px; font-weight: 700; text-align: center;
  animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 #fde04788; } 50% { box-shadow: 0 0 0 10px #fde04700; } }
.qr-box { background: #fff; border-radius: 16px; padding: 14px; text-align: center; color: #0b1220; }
.qr-box img { width: 100%; max-width: 240px; display: block; margin: 0 auto; image-rendering: pixelated; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 1.5rem; letter-spacing: 4px; font-weight: 800; }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 12px 4px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: center; }
.list li:last-child { border-bottom: 0; }
.list li.click { cursor: pointer; border-radius: 10px; padding-left: 8px; padding-right: 8px; }
.list li.click:hover { background: var(--bg2); }
.list .voided { text-decoration: line-through; opacity: .5; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; flex: 0 0 auto; }
.mini-bar { height: 6px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.mini-bar > span { display: block; height: 100%; background: var(--accent); }

/* Admin */
.topbar { position: sticky; top: 0; z-index: 50; background: #0b1220ee; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.brand { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; max-width: 1040px; margin: 0 auto; scrollbar-width: none; }
.tabs button { background: transparent; border: 1px solid transparent; color: var(--muted); padding: 10px 14px; border-radius: 10px; font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; min-height: 44px; }
.tabs button.active { background: var(--panel); color: var(--text); border-color: var(--line); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat .n { font-size: 1.9rem; font-weight: 800; }
.stat .l { color: var(--muted); font-size: .88rem; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 10px; }
.chart > div { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .85; position: relative; }
.scanner { position: relative; background: #000; border-radius: 16px; overflow: hidden; aspect-ratio: 1; max-width: 420px; margin: 0 auto; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; inset: 15%; border: 3px solid #fff; border-radius: 18px; box-shadow: 0 0 0 999px #0007; }
.quick-stamps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: #000a; z-index: 200; display: grid; place-items: end center; padding: 0; animation: fade .15s; }
@media (min-width: 640px) { .modal-bg { place-items: center; padding: 16px; } }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg); border: 1px solid var(--line); width: min(100%, 560px); max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 20px; }
@media (min-width: 640px) { .modal { border-radius: 20px; } }
.modal .close { float: right; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--line); font-size: .93rem; }
th { color: var(--muted); font-weight: 600; }

/* Landing */
.hero { padding: 64px 16px 40px; text-align: center; background: radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--accent) 40%, transparent), transparent); }
.hero h1 { font-size: clamp(2rem, 6vw, 3.4rem); max-width: 860px; margin: 0 auto 16px; }
.hero p { font-size: 1.15rem; color: var(--muted); max-width: 680px; margin: 0 auto 26px; }
.features { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.feature { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.feature .ico { font-size: 1.8rem; }
.price { text-align: center; }
.price .amount { font-size: 2.4rem; font-weight: 800; }
.section { padding: 40px 0; }
.section h2 { text-align: center; font-size: 1.7rem; margin-bottom: 24px; }
.steps { counter-reset: s; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.steps > div { counter-increment: s; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; }
.steps > div::before { content: counter(s); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 800; margin-bottom: 10px; }
footer { color: var(--muted); text-align: center; padding: 30px 16px; font-size: .9rem; }

/* Afiche imprimible */
.poster { background: #fff; color: #0b1220; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.poster-inner { max-width: 640px; text-align: center; }
.poster h1 { font-size: 2.6rem; color: var(--accent); }
.poster .big-qr { width: min(80vw, 380px); margin: 20px auto; display: block; }
.poster .steps-p { text-align: left; font-size: 1.2rem; }
@media print {
  .no-print { display: none !important; }
  .poster { min-height: auto; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 520px) { #who { display: none; } }
.grid > .panel + .panel { margin-top: 0; }

/* Botones de Wallet */
.wallet-btns { display: grid; gap: 10px; margin-top: 16px; }
.wallet-btn {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: #000; color: #fff; border: 1px solid #3a3a3a; border-radius: 14px;
  min-height: 58px; padding: 10px 18px; text-decoration: none; font-weight: 650; font-size: 1.05rem;
  -webkit-tap-highlight-color: transparent; transition: transform .05s;
}
.wallet-btn:active { transform: scale(.98); }
.wallet-btn svg { width: 30px; height: 30px; flex: 0 0 auto; }
.wallet-btn small { display: block; font-weight: 500; font-size: .75rem; opacity: .75; line-height: 1.1; }
.wallet-btn .txt { text-align: left; line-height: 1.15; }
.welcome { margin-top: 14px; background: #12301f; border: 1px solid #166534; color: #dcfce7; border-radius: 14px; padding: 14px 16px; }
.club-logo { width: 44px; height: 44px; border-radius: 12px; background: #fff; object-fit: contain; padding: 3px; flex: 0 0 auto; }
.logo-preview { width: 96px; height: 96px; border-radius: 16px; background: #fff; object-fit: contain; padding: 6px; }
