:root {
  --cream: #FBF8F3;
  --cream-2: #F3EDE3;
  --gold: #D7AE61;
  --gold-dark: #B8922E;
  --charcoal: #373435;
  --muted: #8A8486;
  --rose: #F7D5DE;
  --line: #E9E1D4;
  --white: #FFFFFF;
  --ok: #3F7D5A;
  --danger: #B4473F;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* si no, .icon-btn (display: grid) enseña la flecha de volver en el acceso */
html, body { margin: 0; }
body {
  background: var(--cream);
  color: var(--charcoal);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
}
button { font: inherit; cursor: pointer; color: inherit; }
input, select { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--charcoal); color: var(--cream);
}
.brand { font-family: 'Playfair Display', serif; font-weight: 700; font-size: 21px; flex: 1; }
.brand span { color: var(--gold); font-style: italic; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.18); background: transparent; color: var(--cream);
  display: grid; place-items: center;
}
.loc-chip {
  border: 1px solid var(--gold); background: transparent; color: var(--gold);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 500; white-space: nowrap;
}
.demo-banner { background: var(--rose); padding: 8px 16px; font-size: 13px; text-align: center; }

main { max-width: 620px; margin: 0 auto; padding: 20px 16px 60px; }

h1, h2 { font-family: 'Playfair Display', serif; margin: 0; }
h1 { font-size: 26px; }
.section-title {
  font-size: 13px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  color: var(--muted); margin: 28px 4px 10px;
}
.muted { color: var(--muted); }

/* Buscar */
.search-row { display: flex; gap: 10px; margin-top: 16px; }
.search-input {
  flex: 1; min-width: 0; height: 54px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--white); padding: 0 16px; font-size: 17px;
}
.search-input:focus { outline: none; border-color: var(--gold); }
.scan-btn {
  width: 54px; height: 54px; border-radius: 14px; border: 0;
  background: var(--charcoal); color: var(--cream); display: grid; place-items: center;
}
.results { margin-top: 14px; display: grid; gap: 8px; }
.result {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
}
.result .meta { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .who { min-width: 0; }
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: var(--charcoal); color: var(--cream);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.avatar.big { width: 64px; height: 64px; font-size: 22px; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; }

/* Botones */
.btn {
  border: 0; border-radius: 999px; height: 50px; padding: 0 22px;
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-gold { background: var(--gold); color: var(--charcoal); }
.btn-dark { background: var(--charcoal); color: var(--cream); }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Ficha */
.profile { display: flex; align-items: center; gap: 16px; }
.profile .since { font-size: 14px; color: var(--muted); margin-top: 4px; }
.card {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-top: 14px;
}
.card-head { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 16px; }
.badge {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--cream-2); color: var(--gold-dark); font-weight: 700;
}
.card-main { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.big-num { font-size: 44px; font-weight: 700; line-height: 1; }
.round {
  width: 58px; height: 58px; border-radius: 50%; border: 0; display: grid; place-items: center;
  font-size: 28px; line-height: 1;
}
.round.plus { background: var(--charcoal); color: var(--cream); }
.round.minus { background: var(--cream-2); color: var(--muted); }
.round.small { width: 44px; height: 44px; font-size: 22px; }
.round.outline { background: var(--white); border: 1.5px solid var(--line); color: var(--charcoal); }
.round:disabled { opacity: .35; cursor: not-allowed; }
.adjust {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line); margin-top: 16px; padding-top: 12px; color: var(--muted);
}
.adjust .pair { display: flex; gap: 10px; }
.stamps { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.stamp { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--gold); }
.stamp.on { background: var(--gold); }

.reward { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.reward + .reward { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.reward .title { font-weight: 700; }
.reward .sub { font-size: 14px; color: var(--muted); margin-top: 2px; }
.reward.ready { }
.ready-card { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(215,174,97,.18); }

.contact-row { display: flex; align-items: center; gap: 14px; }
.contact-row + .contact-row { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 12px; }
.contact-row .label { font-size: 13px; color: var(--muted); }
.contact-row .value { font-size: 17px; word-break: break-all; }

.history { font-size: 14px; }
.history-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; }
.history-row + .history-row { border-top: 1px solid var(--line); }
.pos { color: var(--ok); font-weight: 700; }
.neg { color: var(--danger); font-weight: 700; }

/* Formularios */
.field { display: grid; gap: 6px; margin-top: 14px; }
.field label { font-size: 14px; color: var(--muted); }
.field input, .field select {
  height: 50px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--white); padding: 0 14px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold); }
.check { display: flex; gap: 10px; align-items: center; margin-top: 16px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--gold-dark); }
.error { color: var(--danger); font-size: 14px; margin-top: 10px; min-height: 1em; }
.amount-input { font-size: 32px !important; height: 70px !important; text-align: center; font-weight: 700; }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 20; background: rgba(55,52,53,.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal[hidden] { display: none; }
.sheet {
  background: var(--cream); width: 100%; max-width: 620px; max-height: 92vh; overflow: auto;
  border-radius: 22px 22px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
}
.sheet h2 { font-size: 22px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }
#reader { width: 100%; border-radius: 14px; overflow: hidden; margin-top: 14px; background: #000; min-height: 240px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--charcoal); color: var(--cream); padding: 12px 18px; border-radius: 14px;
  z-index: 30; max-width: calc(100% - 32px); font-size: 15px; box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

.login { max-width: 400px; margin: 40px auto 0; }
.loc-list { display: grid; gap: 10px; margin-top: 16px; }

@media (min-width: 700px) {
  .modal { align-items: center; }
  .sheet { border-radius: 22px; }
}
.reward .btn { flex: none; white-space: nowrap; }
.reward > div:first-child { min-width: 0; }
