:root {
  color-scheme: light;
  --bg: #faf7f2;
  --surface: #ffffff;
  --field: #ffffff;
  --text: #1c1c1c;
  --muted: #5c534b;
  --faint: #9a8f84;
  --line: #e7e0d6;
  /* --brand y --brand-bar los fija la app con los colores de cada cafetería. */
  --bar: var(--brand-bar, #1c1c1c);
  --bar-text: #faf7f2;
  --accent: var(--brand, #8b4513);
  --accent-press: color-mix(in srgb, var(--accent) 80%, #000);
  --on-accent: #ffffff;
  --stamp: var(--brand, #8b4513);
  --on-stamp: #faf7f2;
  --gold: #d9a441;
  --gold-soft: #fbf1d8;
  --on-gold: #1c1c1c;
  --ok: #4f7a4a;
  --error: #a3301f;
  --error-soft: #f8dcd5;
  --error-bg: #a3301f;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(28, 28, 28, .06), 0 8px 24px rgba(28, 28, 28, .08);
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  /* Curvas de nivel, como las líneas topográficas del logo. */
  --topo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420' fill='none' stroke='%231c1c1c' stroke-opacity='.07'%3E%3Cdefs%3E%3Cpath id='b' vector-effect='non-scaling-stroke' d='M0-80c40-5 75 25 78 65s-20 80-62 88-85-15-92-58 30-90 76-95z'/%3E%3C/defs%3E%3Cg transform='translate(120 130)'%3E%3Cuse href='%23b'/%3E%3Cuse href='%23b' transform='scale(.72)'/%3E%3Cuse href='%23b' transform='scale(.46)'/%3E%3Cuse href='%23b' transform='scale(.22)'/%3E%3C/g%3E%3Cg transform='translate(310 300) rotate(140)'%3E%3Cuse href='%23b' transform='scale(1.1)'/%3E%3Cuse href='%23b' transform='scale(.8)'/%3E%3Cuse href='%23b' transform='scale(.5)'/%3E%3Cuse href='%23b' transform='scale(.25)'/%3E%3C/g%3E%3C/svg%3E");
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161412;
  --surface: #23201d;
  --field: #1b1917;
  --text: #f2ede6;
  --muted: #b9afa4;
  --faint: #7d746b;
  --line: #3a3531;
  --bar: #0e0d0c;
  --bar-text: #f2ede6;
  --accent: color-mix(in srgb, var(--brand, #8b4513) 88%, #fff);
  --stamp: color-mix(in srgb, var(--brand, #8b4513) 55%, #fff);
  --on-stamp: #161412;
  --gold: #e0b055;
  --gold-soft: #3a2c14;
  --on-gold: #1c1c1c;
  --topo: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420' fill='none' stroke='%23faf7f2' stroke-opacity='.06'%3E%3Cdefs%3E%3Cpath id='b' vector-effect='non-scaling-stroke' d='M0-80c40-5 75 25 78 65s-20 80-62 88-85-15-92-58 30-90 76-95z'/%3E%3C/defs%3E%3Cg transform='translate(120 130)'%3E%3Cuse href='%23b'/%3E%3Cuse href='%23b' transform='scale(.72)'/%3E%3Cuse href='%23b' transform='scale(.46)'/%3E%3Cuse href='%23b' transform='scale(.22)'/%3E%3C/g%3E%3Cg transform='translate(310 300) rotate(140)'%3E%3Cuse href='%23b' transform='scale(1.1)'/%3E%3Cuse href='%23b' transform='scale(.8)'/%3E%3Cuse href='%23b' transform='scale(.5)'/%3E%3Cuse href='%23b' transform='scale(.25)'/%3E%3C/g%3E%3C/svg%3E");
  --ok: #4f7a4a;
  --error: #ff9c8a;
  --error-soft: #4a1f18;
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  height: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg) var(--topo) center top / 420px 420px;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

h1, h2 { font-family: var(--font-display); margin: 0; line-height: 1.15; letter-spacing: -.01em; }

/* Logo real (PNG en tinta oscura sobre transparente); se invierte sobre fondos oscuros. */
.logo-full { display: block; width: min(230px, 72%); height: auto; margin: 0 auto; }
.logo-wordmark { display: block; height: 28px; width: auto; max-width: 160px; object-fit: contain; padding: 2px 6px; border-radius: 6px; background: #fff; }
/* Logos monocromos propios (tinta oscura sobre transparente): se muestran en blanco. */
.logo-wordmark.is-mono { padding: 0; border-radius: 0; background: none; filter: invert(1); }
.tenant-name { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root[data-theme="dark"] .logo-full { filter: invert(1); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon, .stamp-cup {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon { width: 22px; height: 22px; flex-shrink: 0; }

/* Las vistas entran con un fundido corto (sin transform: el dock usa position: fixed). */
.view {
  min-height: 100%;
  transition: opacity 220ms var(--ease-out);
}
@starting-style { .view { opacity: 0; } }

.view-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  min-height: 100vh;
  min-height: 100dvh;
}

.muted { color: var(--muted); margin: 0; }

/* Spinner */
.spinner {
  width: 40px; height: 40px;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Formularios */
.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

input {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  font: inherit;
  color: var(--text);
  background: var(--field);
  border: 2px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border-color 150ms ease;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { border-color: var(--accent); }

select {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--field);
  border: 2px solid var(--line);
  border-radius: 12px;
  outline: none;
}
input[type="checkbox"] { width: 24px; min-height: 24px; height: 24px; padding: 0; flex-shrink: 0; accent-color: var(--accent); }
input[type="color"] { padding: 4px; cursor: pointer; }

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 14px; cursor: pointer; }
.fieldset { margin: 0 0 14px; padding: 12px 14px 0; border: 2px dashed var(--line); border-radius: 14px; min-width: 0; }
.fieldset legend { padding: 0 6px; font-size: .85rem; font-weight: 700; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 12px; }
@media (min-width: 560px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-full { grid-column: 1 / -1; }
}
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  transition: transform 140ms var(--ease-out), background-color 150ms ease, opacity 150ms ease;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, .tab:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.btn-block { width: 100%; }
.btn-big { min-height: 68px; font-size: 1.25rem; border-radius: 18px; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active:not(:disabled) { background: var(--accent-press); }
.btn-secondary { background: var(--stamp); color: var(--on-stamp); }
.btn-reward { background: var(--gold); color: var(--on-gold); }
.btn-ghost { background: transparent; color: var(--muted); min-width: 44px; min-height: 44px; padding: 6px 12px; }
.btn-ghost-light.btn-icon { background: transparent; opacity: .8; }
.btn-ghost-light { background: rgba(255, 255, 255, .12); color: var(--bar-text); min-height: 44px; padding: 6px 14px; }
.btn-icon { min-width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.btn-link { background: none; color: var(--muted); text-decoration: underline; min-height: 44px; padding: 6px 4px; font-weight: 500; }

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) { background: var(--accent-press); }
  .btn-ghost:hover { background: var(--line); }
  .btn-ghost-light:hover { background: rgba(255, 255, 255, .2); }
  .tab:hover { opacity: 1; }
}

/* Mantener presionado para canjear: la capa se llena de izquierda a derecha. */
.btn-hold { position: relative; overflow: hidden; }
.btn-hold > * { position: relative; }
.btn-hold::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(28, 28, 28, .2);
  clip-path: inset(0 100% 0 0);
  transition: clip-path 200ms var(--ease-out);
}
.btn-hold.is-holding::before {
  clip-path: inset(0 0 0 0);
  transition: clip-path 800ms linear;
}

.msg { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; font-size: .92rem; background: var(--surface); }
.msg-error { background: var(--error-soft); color: var(--error); }
.msg-ok { background: color-mix(in srgb, var(--ok) 16%, var(--surface)); color: var(--text); border: 1px solid color-mix(in srgb, var(--ok) 45%, transparent); }

/* Tema */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.theme-text { margin: 10px auto 0; gap: 6px; font-size: .88rem; text-decoration: none; color: var(--faint); }
.theme-text .icon { width: 16px; height: 16px; }

/* Estado vacío de la caja */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 40px 16px 0;
  text-align: center;
}
.empty-state img { width: 120px; height: auto; margin-bottom: 12px; opacity: .85; }
:root[data-theme="dark"] .empty-state img { filter: invert(1); }
.empty-title { margin: 0; font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
#new-customer:not([hidden]) ~ .empty-state,
#customer-card:not([hidden]) ~ .empty-state { display: none; }

/* Login */
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: 24px;
  padding: 32px 24px 24px;
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform 300ms var(--ease-out), opacity 300ms var(--ease-out);
}
@starting-style { .login-card { opacity: 0; transform: translateY(12px); } }
.login-card form { text-align: left; margin-top: 24px; }
.brand-title { line-height: 0; }
.brand-sub { margin: 14px 0 0; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; font-size: .78rem; font-weight: 700; }

/* Barra superior y pestañas */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--bar);
  color: var(--bar-text);
}
.topbar-brand { display: flex; flex-direction: column; min-width: 0; }
.topbar-title { padding: 2px 0 4px; }
.topbar-user { font-size: .78rem; opacity: .75; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* Con varias pestañas la fila se desliza de lado en vez de apretarse. */
.tabs { display: flex; background: var(--bar); padding: 0 12px; gap: 4px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto;
  min-height: 48px;
  padding: 4px 12px;
  white-space: nowrap;
  font: inherit;
  font-size: .92rem;
  line-height: 1.15;
  font-weight: 700;
  color: var(--bar-text);
  opacity: .65;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.tab.is-active { opacity: 1; border-bottom-color: var(--accent); }

.panel { max-width: 560px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom, 0px)); }
/* Deja espacio para el dock fijo de acciones. */
#panel-cashier { padding-bottom: calc(210px + env(safe-area-inset-bottom, 0px)); }

/* Escanear QR */
#scan-btn { margin-bottom: 16px; }
.scanner {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(16px + env(safe-area-inset-bottom, 0px));
  background: #0e0d0c;
  color: #faf7f2;
  transition: opacity 200ms var(--ease-out);
}
@starting-style { .scanner { opacity: 0; } }
.scanner-title { margin: 0; text-align: center; font-family: var(--font-display); font-size: 1.3rem; font-weight: 700; }
.scanner-view { width: 100%; max-width: 420px; margin: 0 auto; border-radius: 16px; overflow: hidden; background: #000; min-height: 240px; }
.scanner-view video { display: block; width: 100% !important; }
.scanner .btn { max-width: 420px; margin: 0 auto; }

/* Códigos QR: siempre sobre blanco, también en modo oscuro */
.qr-card { text-align: center; }
.qr-box {
  width: min(260px, 100%);
  margin: 16px auto 10px;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid var(--line);
  color: #1c1c1c;
}
.qr-box canvas, .qr-box img { display: block; width: 100% !important; height: auto !important; }
.qr-box-local { width: min(320px, 100%); padding: 6px; }
.qr-print .card-title { margin-top: 14px; }
.qr-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.plan-note { margin: -4px 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--line); font-size: .85rem; }
.plan-locked { margin: 0 0 14px; font-size: .85rem; }
.logo-upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .85rem; }
.logo-upload .btn { min-height: 44px; }
.logo-upload [role="status"].is-busy::before {
  content: ''; display: inline-block; width: 14px; height: 14px; margin-right: 8px; vertical-align: -2px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
.logo-preview { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: .85rem; }
/* Igual que en la página del cliente: fondo crema y multiply. El fondo va en
   la caja y no en la imagen, porque multiply mezcla con lo que hay detrás. */
/* Mismas medidas que la caja real del cliente (#r-logo-wrap): 200×140. */
#tf-logo-preview-wrap {
  flex: none;
  width: 200px;
  height: 140px;
  background: #FAF7F2;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--line);
  isolation: isolate;
}
#tf-logo-preview-wrap:has(#tf-logo-preview[hidden]) { display: none; }

#tf-logo-preview {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
  display: block;
}

/* Al imprimir desde "QR del local" solo sale el nombre, el QR y la instrucción. */
@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  .qr-print, .qr-print * { visibility: visible; }
  .qr-print { position: absolute; top: 0; left: 0; width: 100%; text-align: center; color: #000; }
  .qr-print .qr-box { width: 12cm; margin: 1cm auto 0; border: 0; }
}
.qr-url { margin: 0 0 14px; font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; user-select: all; }

/* Página pública de registro */
.r-page {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 16px calc(32px + env(safe-area-inset-bottom, 0px));
}
.r-brand { display: flex; justify-content: center; align-items: center; min-height: 72px; margin-bottom: 16px; }
/* Espacio fijo para el logo: horizontal, vertical o cuadrado ocupa siempre la
   misma caja sin deformarse. position: relative es para las partículas de vapor. */
#r-logo-wrap {
  position: relative;
  width: 200px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Si el logo no carga se muestra el nombre: la caja vacía no debe ocupar lugar. */
#r-logo-wrap:has(#r-logo[hidden]) { display: none; }

/* multiply: el fondo blanco de un logo se funde con la página */
#r-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}
.r-name { margin: 0; font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.r-lead { margin-top: 10px; }
.r-qr-hint { margin: 0 0 8px; font-weight: 600; }
.field-hint { display: block; margin-top: 6px; color: var(--muted); font-size: .82rem; }
.r-terms { align-items: flex-start; font-size: .88rem; line-height: 1.4; }
.r-terms a { color: var(--accent); }
#r-carta { margin-bottom: 10px; text-decoration: none; }
.c-card, .c-join { margin-bottom: 20px; }
.c-join .btn, .c-card .btn { text-decoration: none; }
.c-join .btn { margin-top: 12px; }
.form-divider { margin: 20px 0 6px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 1.2rem; }
.bday-badge { display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 0; padding: 4px 12px; border-radius: 999px; background: var(--gold); color: var(--on-gold); font-size: .9rem; font-weight: 700; }
.r-prize { margin: -4px 0 12px; text-align: center; color: var(--accent); font-size: .85rem; font-weight: 600; overflow-wrap: anywhere; }
.r-motiv { margin: -6px 0 14px; text-align: center; color: var(--muted); font-size: .95rem; }
/* La tarjeta del cliente aparece con fundido + escala. */
#r-card { transition: transform 300ms var(--ease-out), opacity 300ms var(--ease-out), border-color 300ms ease; }
@starting-style { #r-card { opacity: 0; transform: scale(.96); } }
.r-push-status { text-align: center; font-size: .9rem; margin: 4px 0; }

/* Campañas */
textarea {
  display: block;
  width: 100%;
  min-height: 96px;
  padding: 10px 14px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--field);
  border: 2px solid var(--line);
  border-radius: 12px;
  outline: none;
  resize: vertical;
}
textarea:focus { border-color: var(--accent); }
.people .meta { flex-shrink: 0; text-align: right; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.people .btn { flex-shrink: 0; min-height: 44px; padding: 6px 12px; font-size: .9rem; }
.section-head .count { color: var(--muted); font-family: system-ui, sans-serif; font-size: .9rem; font-weight: 600; }
.camp-note { font-size: .85rem; margin: 0 0 16px; }

/* Búsqueda */
.search-row { display: flex; gap: 8px; align-items: stretch; }
.search-row input { flex: 1; min-width: 0; min-height: 56px; font-size: 1.35rem; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.search-row .btn { min-height: 56px; flex-shrink: 0; }
.prefix {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 12px;
  flex-shrink: 0;
}

/* Tarjeta de cliente */
.card {
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-top: 4px;
  transition: transform 240ms var(--ease-out), opacity 240ms var(--ease-out), border-color 300ms ease;
}
@starting-style { .card { opacity: 0; transform: translateY(10px) scale(.98); } }
.card.is-complete { border-color: var(--gold); }
.card-title { font-size: 1.5rem; overflow-wrap: anywhere; }
.card > .muted { margin: 6px 0 14px; }

.customer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.customer-head > div { min-width: 0; }

/* Tarjeta de sellos */
.stamp-card {
  margin: 16px 0 12px;
  padding: 14px 12px 12px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: var(--bg) var(--topo) center / 300px 300px;
}
.stamp-card-title {
  margin: 0 0 12px;
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}
.stamps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.stamp {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 2px dashed var(--faint);
  border-radius: 50%;
  color: var(--muted);
  font-weight: 700;
  font-size: .95rem;
  font-variant-numeric: tabular-nums;
  transition: background-color 220ms var(--ease-out), border-color 220ms var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.stamp-num, .stamp-cup {
  grid-area: 1 / 1;
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
  transition-delay: var(--d, 0ms);
}
.stamp-cup { width: 62%; height: 62%; color: var(--on-stamp); opacity: 0; transform: scale(.9); }
.stamp:last-child { border-color: var(--gold); }
.stamp.is-filled { border-style: solid; border-color: var(--stamp); background: var(--stamp); }
.stamp.is-filled:last-child { border-color: var(--gold); }
.stamp.is-filled .stamp-num { opacity: 0; }
.stamp.is-filled .stamp-cup { opacity: 1; transform: none; }

.stamps-label { text-align: center; font-weight: 700; margin: 0 0 12px; font-variant-numeric: tabular-nums; }

.reward {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
  padding: 12px;
  margin-bottom: 4px;
  border-radius: 12px;
  background: var(--gold-soft);
  border: 2px solid var(--gold);
  transition: transform 260ms var(--ease-out), opacity 260ms var(--ease-out);
}
@starting-style { .reward { opacity: 0; transform: scale(.96); } }

.customer-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: .88rem;
}

/* Dock de acciones: al alcance del pulgar */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  transition: transform 300ms var(--ease-drawer), opacity 300ms var(--ease-drawer);
}
@starting-style { .dock { opacity: 0; transform: translateY(100%); } }
.dock-inner { max-width: 528px; margin: 0 auto; display: grid; gap: 10px; }

/* Confeti al completar la tarjeta: cada pieza trae su destino en --x, --y, --r. */
.confetti {
  position: fixed;
  z-index: 20;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  background: var(--accent);
  pointer-events: none;
  opacity: 0;
  animation: confetti 900ms var(--ease-out) both;
}
.confetti:nth-child(3n) { background: var(--gold); }
.confetti:nth-child(3n + 1) { background: var(--ok); border-radius: 50%; width: 9px; height: 9px; }
@keyframes confetti {
  0% { transform: translate(-50%, -50%) scale(.9); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--r)); opacity: 0; }
}

/* Check verde al canjear */
.redeem-check {
  position: fixed;
  top: 40%;
  left: 50%;
  z-index: 25;
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  margin: -56px 0 0 -56px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: var(--shadow);
  pointer-events: none;
  opacity: 0;
}
.redeem-check svg { width: 64px; height: 64px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 20; stroke-dashoffset: 20; }
.redeem-check.is-on { animation: check-pop 1100ms var(--ease-out) both; }
.redeem-check.is-on svg { animation: check-draw 320ms 140ms var(--ease-out) both; }
@keyframes check-pop {
  0% { opacity: 0; transform: scale(.9); }
  18% { opacity: 1; transform: none; }
  75% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: none; }
}
@keyframes check-draw { to { stroke-dashoffset: 0; } }

/* Admin */
.summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
.summary-item:last-child { grid-column: 1 / -1; }
.summary-4 .summary-item:last-child { grid-column: auto; }
.summary-item span { text-align: center; }

/* Superadmin y equipo */
.panel-wide { max-width: 880px; }
.panel-wide .card { margin-bottom: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.section-head h2 { font-size: 1.3rem; }
.section-actions { display: flex; gap: 8px; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--line);
  color: var(--text);
}
.badge-ok { background: var(--ok); color: #fff; }
.badge-off { background: var(--error-soft); color: var(--error); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }

.info-list { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 14px 0 0; font-size: .92rem; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; overflow-wrap: anywhere; }

.people { list-style: none; margin: 0 0 16px; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.people li { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.people li:last-child { border-bottom: 0; }
.people .who { flex: 1; min-width: 0; }
.people .who strong { display: block; overflow-wrap: anywhere; }
.people .who small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.people .empty { justify-content: center; color: var(--muted); }
.table .btn { min-height: 44px; padding: 6px 14px; }
.summary-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 18px 12px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.summary-item strong { font-family: var(--font-display); font-size: 2.1rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.summary-item span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

.admin-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.admin-tools input { flex: 1; min-width: 0; }
.admin-tools .btn { flex-shrink: 0; }

.table-wrap { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; overscroll-behavior-x: contain; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .cell-name { font-weight: 700; overflow-wrap: anywhere; }
.table .cell-phone { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.table .has-reward { color: var(--accent); font-weight: 700; }
:root[data-theme="dark"] .table .has-reward { color: var(--gold); }
.table .empty { text-align: center; color: var(--muted); padding: 24px 12px; }

/* Toast: entra y sale por arriba, para no tapar el dock */
.toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 16px;
  right: 16px;
  width: fit-content;
  max-width: calc(100% - 32px);
  margin: 0 auto;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--bar);
  color: #faf7f2;
  font-weight: 600;
  text-align: center;
  box-shadow: var(--shadow);
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-150%);
  transition: transform 200ms var(--ease-out), opacity 200ms var(--ease-out);
}
.toast[data-open] { opacity: 1; transform: none; transition-duration: 320ms; }
:root[data-theme="dark"] .toast { background: #3a3531; }
.toast.is-error, :root[data-theme="dark"] .toast.is-error { background: var(--error-bg); }
.toast.is-ok, :root[data-theme="dark"] .toast.is-ok { background: var(--ok); }

/* Movimiento reducido: se mantienen los fundidos, se quita el desplazamiento. */
@media (prefers-reduced-motion: reduce) {
  .btn:active:not(:disabled) { transform: none; }
  .toast { transform: none; }
  .stamp-cup { transform: none; }
  .redeem-check.is-on svg { animation: none; stroke-dashoffset: 0; }
  @starting-style {
    .login-card, .card, #r-card, .reward, .dock { transform: none; }
  }
  .r-logo { animation: none !important; filter: none !important; }
  .vapor-particle { display: none; }
}

/* ---- Animaciones de logo (registro.html) ---- */
@keyframes logo-pulso {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes logo-brillo {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.4); }
}
@keyframes vapor-rise {
  0%   { opacity: 0;   transform: translateY(0); }
  20%  { opacity: 0.7; }
  100% { opacity: 0;   transform: translateY(-30px); }
}

/* Partículas SVG de vapor que flotan sobre el logo */
.vapor-particle {
  position: absolute;
  bottom: 78%; /* parte desde el borde de la taza, sin tapar la cara */
  width: 10px;
  height: 30px;
  pointer-events: none;
  /* Invisible hasta que empieza su turno; si no, las partículas con retraso
     se ven quietas y opacas al cargar. */
  opacity: 0;
  color: var(--accent);
  animation: vapor-rise 2s ease-out infinite;
  animation-delay: var(--vdelay, 0s);
}

/* ---- Carta digital: página pública /carta ---- */
.c-page { max-width: 560px; }
.c-title { margin: 0 0 12px; font-size: 2rem; text-align: center; }
.c-nav { display: flex; gap: 8px; margin: 0 -16px 8px; padding: 4px 16px 8px; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.c-nav::-webkit-scrollbar { display: none; }
.c-chip { flex-shrink: 0; display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border: 1.5px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); font-size: .92rem; font-weight: 600; text-decoration: none; white-space: nowrap; }
.c-section { scroll-margin-top: 12px; }
.c-cat { margin: 22px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--accent); font-size: 1.45rem; overflow-wrap: anywhere; }
.c-item { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 10px; padding: 12px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.c-photo { flex-shrink: 0; width: 84px; height: 84px; border-radius: 12px; object-fit: cover; background: var(--line); }
.c-photo-empty { display: grid; place-items: center; background: #8b4513; color: #faf7f2; font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; line-height: 1; }
.c-body { flex: 1; min-width: 0; }
.c-name { margin: 0; font-family: system-ui, sans-serif; font-size: 1.05rem; font-weight: 700; overflow-wrap: anywhere; }
.c-desc { margin: 4px 0 0; color: var(--muted); font-size: .92rem; overflow-wrap: anywhere; text-wrap: pretty; }
.c-price { margin: 8px 0 0; color: var(--accent); font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.c-empty { margin-top: 24px; text-align: center; }
@media (min-width: 480px) {
  .c-photo { width: 104px; height: 104px; }
}

/* ---- Carta digital: pestaña del admin ---- */
.menu-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.menu-actions .btn:first-child { grid-column: 1 / -1; }
.menu-form { margin-bottom: 16px; }
.menu-photo-preview { display: block; width: 104px; height: 104px; margin-top: 10px; border-radius: 12px; object-fit: cover; background: var(--line); }
.menu-item { flex-wrap: wrap; }
.menu-item.is-off .who, .menu-item.is-off .menu-thumb { opacity: .5; }
.menu-thumb { flex-shrink: 0; width: 52px; height: 52px; border-radius: 10px; object-fit: cover; background: var(--line); }
.menu-thumb-empty { display: grid; place-items: center; background: #8b4513; color: #faf7f2; font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; }
.menu-move { flex-shrink: 0; display: flex; gap: 2px; }
.menu-move .btn { min-width: 44px; padding: 6px; font-size: 1.2rem; line-height: 1; }
.menu-item-actions { flex-basis: 100%; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.menu-item-actions .check { margin: 0 auto 0 0; font-size: .9rem; }
.btn-danger-text { background: transparent; color: var(--error); }

/* ---- Mi plan, aviso de límite y modal de mejora (panel del admin) ---- */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.limit-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; background: var(--gold-soft); color: var(--text); border-bottom: 1px solid var(--gold); }
.limit-banner p { flex: 1; min-width: 200px; margin: 0; font-size: .95rem; font-weight: 600; }
.limit-banner .btn { min-height: 44px; padding: 6px 16px; background: var(--gold); color: var(--on-gold); }
.plan-card { margin-bottom: 20px; }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.plan-name { font-family: var(--font-display); font-size: 1.5rem; }
.plan-usage { margin: 14px 0 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.plan-bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.plan-bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--ok); transition: width 300ms var(--ease-out); }
.plan-bar.is-high span { background: var(--gold); }
.plan-bar.is-full span { background: var(--error); }
.plan-renewal { margin: 12px 0 0; }
.plan-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.plan-actions:empty, .plan-actions:not(:has(.btn:not([hidden]))) { display: none; }
.plan-actions .btn { flex: 1; min-width: 150px; }
.upgrade-modal { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 22px 20px 12px; border: 0; border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .35); overflow-y: auto; overscroll-behavior: contain; }
.upgrade-modal::backdrop { background: rgba(28, 28, 28, .55); }
.up-period { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 14px 0 0; padding: 4px; border: 0; border-radius: 14px; background: var(--line); min-width: 0; }
.up-period label { position: relative; cursor: pointer; }
.up-period input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.up-period span { display: grid; place-items: center; min-height: 44px; border-radius: 10px; font-weight: 700; }
.up-period input:checked + span { background: var(--accent); color: var(--on-accent); }
.up-period input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.up-plan { margin-top: 14px; padding: 16px; border: 2px solid var(--line); border-radius: 14px; }
.up-plan h3 { margin: 0; font-family: var(--font-display); font-size: 1.3rem; }
.up-prices { margin: 4px 0 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.up-prices strong { color: var(--accent); }
.up-plan ul { margin: 10px 0 14px; padding-left: 20px; }
.up-plan li { padding: 2px 0; }
.up-empty { margin: 16px 0 4px; text-align: center; }
