:root {
  --ink: #1C1640;
  --ink-soft: #5A5476;
  --paper: #F6F3FB;
  --surface: #FFFFFF;
  --line: #DCD6EA;
  --rosa: #C4145F;
  --maiz: #FFC72C;
  --ok: #0A6F52;
  --ok-bg: #DDF3EA;
  --error: #A5123F;
  --error-bg: #FBE3EB;
  --brand: var(--rosa);
  --on-brand: #FFFFFF;
  --display: 'Bricolage Grotesque', 'Trebuchet MS', sans-serif;
  --body: 'Atkinson Hyperlegible', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--body);
}

h1, h2, h3 { font-family: var(--display); line-height: 1.1; margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.3rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--rosa); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--maiz); outline-offset: 2px; }
img { max-width: 100%; }

.muted { color: var(--ink-soft); }
.small { font-size: 0.875rem; }
.nowrap { white-space: nowrap; }

/* Formularios */
label { display: block; font-weight: 700; margin-bottom: 0.3rem; }
.hint { display: block; font-weight: 400; font-size: 0.875rem; color: var(--ink-soft); margin-top: 0.25rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], input[type=url], input[type=date], textarea, select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
input[type=color] { width: 4rem; height: 2.75rem; padding: 0.2rem; border: 1.5px solid var(--line); border-radius: 8px; background: var(--surface); }
input[type=file] { font: inherit; max-width: 100%; }
textarea { min-height: 5.5rem; resize: vertical; }
.field { margin-bottom: 1.1rem; }
fieldset.field { border: 0; padding: 0; margin-inline: 0; min-width: 0; }
fieldset.field legend { font-weight: 700; margin-bottom: 0.5rem; padding: 0; }
fieldset.field .choice { margin-bottom: 0.4rem; }
.choice { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 400; margin-bottom: 0.9rem; cursor: pointer; }
.choice input { margin-top: 0.35rem; accent-color: var(--rosa); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; }

.btn {
  display: inline-block;
  padding: 0.65rem 1.15rem;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font: 700 1rem var(--body);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
.btn:hover { background: var(--rosa); border-color: var(--rosa); }
.btn-quiet { background: transparent; color: var(--ink); }
.btn-quiet:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-small { padding: 0.3rem 0.8rem; font-size: 0.875rem; }
.btn-block { display: block; width: 100%; }
.inline { display: inline; }

.demo-banner { background: var(--maiz); color: var(--ink); padding: 0.45rem 1rem; text-align: center; font-size: 0.875rem; font-weight: 700; }

/* Avisos */
.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1.25rem; font-weight: 700; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--error-bg); color: var(--error); }

/* Acceso y errores */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.login { width: min(400px, 100%); }
.login h1 { margin-bottom: 1.5rem; }
.brandmark { display: flex; align-items: center; gap: 0.6rem; font: 800 1.35rem var(--display); margin-bottom: 2rem; }
.brandmark::before {
  content: '';
  width: 1.5rem; height: 1.5rem;
  border-radius: 50%;
  border: 3px solid var(--rosa);
  box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 9px var(--rosa);
  transform: rotate(-8deg);
}

/* Estructura del panel */
.shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--ink); color: #fff; padding: 1.5rem 1rem; display: flex; flex-direction: column; }
.sidebar .brandmark { padding: 0 0.6rem; margin-bottom: 1.75rem; }
.sidebar .brandmark::before { border-color: var(--maiz); box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 9px var(--maiz); }
.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; flex: 1; }
.sidebar nav a { color: #E6E2F4; text-decoration: none; padding: 0.55rem 0.7rem; border-radius: 8px; }
.sidebar nav a:hover { background: #2E2760; }
.sidebar nav a[aria-current=page] { background: var(--maiz); color: var(--ink); font-weight: 700; }
.sidebar-foot { margin-top: 1.5rem; padding: 0 0.6rem; font-size: 0.875rem; color: #C9C3E0; overflow-wrap: anywhere; }
.sidebar-foot button { margin-top: 0.5rem; background: none; border: 0; color: #fff; font: inherit; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; }
.main { padding: 2.25rem clamp(1rem, 4vw, 3rem) 4rem; max-width: 1120px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.75rem; }
.page-head p { margin-top: 0.4rem; color: var(--ink-soft); max-width: 62ch; }

.section { margin-bottom: 2.5rem; }
.section > h2 { margin-bottom: 0.9rem; }
.panel { background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 1.35rem; }
.split { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 1.75rem; align-items: start; }

/* Cifras del resumen: una sola tira, como un comprobante */
.tally { display: flex; flex-wrap: wrap; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; margin-bottom: 2.25rem; }
.tally a { flex: 1 1 150px; padding: 1rem 1.2rem; color: inherit; text-decoration: none; border-right: 1.5px dashed var(--line); }
.tally a:last-child { border-right: 0; }
.tally a:hover { background: var(--paper); }
.tally strong { display: block; font: 700 2rem/1.1 var(--display); }
.tally span { font-size: 0.9rem; color: var(--ink-soft); }

/* Tablas */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.7rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.875rem; color: var(--ink-soft); font-weight: 700; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td a { font-weight: 700; color: var(--ink); }

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1rem; align-items: center; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.chip { padding: 0.35rem 0.85rem; border: 1.5px solid var(--line); border-radius: 999px; color: var(--ink); text-decoration: none; background: var(--surface); font-size: 0.9rem; }
.chip[aria-current=true] { background: var(--ink); border-color: var(--ink); color: #fff; }
.pagination { display: flex; gap: 0.6rem; margin-top: 1rem; }

/* Progreso de sellos en tablas */
.dots { display: inline-flex; flex-wrap: wrap; gap: 3px; max-width: 120px; vertical-align: middle; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--ink-soft); }
.dots i.on { background: var(--rosa); border-color: var(--rosa); }
.tag { display: inline-block; font-size: 0.8rem; font-weight: 700; padding: 0.1rem 0.55rem; border-radius: 999px; background: var(--paper); color: var(--ink-soft); }
.tag-ready { background: var(--maiz); color: var(--ink); }
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-error { background: var(--error-bg); color: var(--error); }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }

.empty { padding: 2rem 1.35rem; text-align: center; color: var(--ink-soft); }

.promo-list { display: grid; gap: 0.9rem; }
.promo-row { display: flex; gap: 1rem; align-items: start; background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px; padding: 1rem; }
.promo-row img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; }
.promo-row > div { flex: 1; min-width: 0; }
.promo-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }

.qr-sheet { display: grid; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); gap: 2rem; align-items: start; }
.qr-sheet img { display: block; width: 100%; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; }
.url-box { overflow-wrap: anywhere; padding: 0.6rem 0.75rem; background: var(--paper); border-radius: 8px; font-size: 0.9rem; margin: 0.75rem 0 1.25rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.current-logo { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.6rem; }
.current-logo img { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; }

/* Cartel imprimible */
.poster { width: min(560px, 100%); margin: 0 auto; text-align: center; background: var(--brand); color: var(--on-brand); padding: 2.5rem 2rem; border-radius: 14px; }
.poster img.logo { width: 96px; height: 96px; object-fit: contain; }
.poster h1 { margin: 0.75rem 0 0.5rem; }
.poster .code { background: #fff; padding: 1rem; border-radius: 12px; margin: 1.5rem auto; width: min(340px, 100%); }
.poster .code img { display: block; width: 100%; }
.poster-tools { text-align: center; padding: 1rem; }

/* Pantalla del mostrador */
.screen { min-height: 100vh; background: var(--brand); color: var(--on-brand); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(1.5rem, 5vw, 4rem); align-items: center; padding: clamp(1.25rem, 5vw, 4rem); }
.screen-copy > img { width: clamp(72px, 10vw, 120px); height: clamp(72px, 10vw, 120px); object-fit: contain; border-radius: 18px; background: #fff; padding: 6px; }
.screen-copy h1 { font-size: clamp(2.6rem, 7vw, 5.5rem); margin: 1rem 0 0.75rem; }
.screen-copy p { font-size: clamp(1.1rem, 2.4vw, 1.75rem); line-height: 1.3; max-width: 22ch; }
.screen-copy .screen-reward { font-weight: 700; margin-top: 1.25rem; }
.screen-code { background: #fff; border-radius: 18px; padding: clamp(0.75rem, 2vw, 1.5rem); text-align: center; max-width: min(78vh, 100%); width: 100%; justify-self: center; }
.screen-code img { display: block; width: 100%; aspect-ratio: 1; }
.screen-code img[hidden] { display: none; }
.screen-timer { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 0.5rem 0; }
.screen-timer i { display: block; height: 100%; background: var(--ink); transform-origin: left; }

/* Experiencia del cliente */
.customer { min-height: 100vh; background: var(--paper); padding-bottom: 3rem; }
.customer-top { background: var(--brand); color: var(--on-brand); padding: 1.75rem 1rem 4.5rem; text-align: center; }
.customer-top img { width: 72px; height: 72px; object-fit: contain; border-radius: 16px; background: #fff; padding: 4px; }
.customer-top h1 { font-size: 1.7rem; margin-top: 0.6rem; }
.customer-top p { opacity: 0.92; margin-top: 0.25rem; }
.customer-body { width: min(480px, 100%); margin: -3.25rem auto 0; padding: 0 1rem; }
.customer-sheet { background: var(--surface); border-radius: 16px; border: 1.5px solid var(--line); padding: 1.35rem; margin-bottom: 1rem; }
.customer-sheet h2 { margin-bottom: 0.6rem; }
.count { font: 800 2.6rem/1 var(--display); letter-spacing: -0.02em; }
.count small { font: 400 1rem var(--body); letter-spacing: 0; color: var(--ink-soft); }
.outcome { font-weight: 700; margin-bottom: 1rem; padding: 0.7rem 0.9rem; border-radius: 10px; background: var(--ok-bg); color: var(--ok); }
.outcome-wait { background: var(--paper); color: var(--ink); }
.outcome-full { background: var(--maiz); color: var(--ink); }

/* La pieza central: sellos entintados */
.stamps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.55rem; margin: 1.1rem 0 1rem; }
.stamp { aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; font: 700 0.95rem var(--display); }
.stamp-empty { border: 2px dashed var(--line); color: var(--ink-soft); }
.stamp-prize { border-color: var(--brand); color: var(--brand); }
.stamp-prize svg { width: 50%; height: 50%; }
.stamp-on {
  color: var(--brand);
  border: 3px solid var(--brand);
  box-shadow: inset 0 0 0 3px var(--surface), inset 0 0 0 4.5px var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  transform: rotate(var(--r, -6deg));
}
.stamp-on svg { width: 48%; height: 48%; }
.stamp-new { animation: thud 520ms cubic-bezier(0.2, 0.9, 0.3, 1.2) 250ms both; }
@keyframes thud {
  0% { transform: rotate(calc(var(--r, -6deg) - 12deg)) scale(2.4); opacity: 0; }
  55% { transform: rotate(var(--r, -6deg)) scale(0.92); opacity: 1; }
  100% { transform: rotate(var(--r, -6deg)) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .stamp-new { animation: none; }
}

.wallet-buttons { display: grid; gap: 0.6rem; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-brand:hover { background: var(--ink); border-color: var(--ink); color: #fff; }
.customer-promo + .customer-promo { border-top: 1px solid var(--line); margin-top: 0.9rem; padding-top: 0.9rem; }
.customer-promo img { display: block; width: 100%; border-radius: 10px; margin-bottom: 0.6rem; }
.customer-promo h3 { font-size: 1.1rem; margin-bottom: 0.2rem; }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { padding: 0.9rem 1rem; min-width: 0; }
  .sidebar .brandmark { margin-bottom: 0.6rem; padding: 0; }
  .sidebar nav { flex-direction: row; overflow-x: auto; }
  .sidebar nav a { white-space: nowrap; }
  .sidebar-foot { margin-top: 0.5rem; padding: 0; }
  .split, .qr-sheet, .screen { grid-template-columns: minmax(0, 1fr); }
  .screen-copy { text-align: center; }
  .screen-copy p { margin-inline: auto; }
  .tally a { border-right: 0; border-bottom: 1.5px dashed var(--line); }
  .tally a:last-child { border-bottom: 0; }
}

@media print {
  .poster-tools { display: none; }
  body { background: #fff; }
  .poster { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Código de recuperación: grande para escanearlo desde el otro lado del mostrador. */
.recovery { display: grid; grid-template-columns: minmax(0, 320px) minmax(0, 1fr); gap: 1.5rem; align-items: center; }
.recovery-qr { width: 100%; max-width: 320px; aspect-ratio: 1; border-radius: 8px; }
.recovery-link { overflow-wrap: anywhere; font-family: var(--body); }
@media (max-width: 640px) { .recovery { grid-template-columns: minmax(0, 1fr); justify-items: center; } }

/* Mi cuenta: enlace del pie de la barra lateral y panel angosto. */
.sidebar-foot a { display: inline-block; margin-top: 0.5rem; color: #fff; text-underline-offset: 3px; }
.sidebar-foot a[aria-current="page"] { font-weight: 700; }
.narrow { max-width: 34rem; }

/* Sellos dados a mano o anulados en el historial del cliente. */
.feed .voided span:first-child { text-decoration: line-through; color: var(--ink-soft); }
.stamp-adjust { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }
.stamp-adjust .field { margin: 0; flex: 1 1 6rem; }
.danger-zone { border-color: var(--error-bg); }
.btn-danger { background: var(--error); color: #fff; border-color: var(--error); }
