/* ===========================================================================
   app.css — Gajeto loyalty demo

   Palette notes, because the brand red is a trap:
   #FF0000 is a pure primary. It is right for the logo and for large display
   numerals, and it vibrates unpleasantly at body size and fails contrast on
   white (4.0:1) for small text. So:
     --brand   #FF0000  logo, big numerals, thick rules only
     --action  #D40000  buttons, links, any red at text size (5.9:1 on white)
     --on-dark #FF3B30  red on the near-black chrome, where #D40000 is muddy
   Nothing loads from a CDN and no web font is fetched: the demo has to work
   from a folder, on a hotel wifi, in front of a client.
   ========================================================================= */

:root {
  --brand: #FF0000;
  --action: #D40000;
  --action-dk: #A80000;
  --on-dark: #FF3B30;

  --ink: #0B0B0C;
  --ink-2: #3A3A3E;
  --ink-3: #6B7280;
  --line: #E4E4E8;
  --line-2: #EFEFF2;
  --paper: #FFFFFF;
  --wash: #F6F6F8;
  --wash-2: #FAFAFB;

  --good: #12783F;
  --good-bg: #E9F7EE;
  --warn: #8A5A00;
  --warn-bg: #FFF6E5;
  --bad: #B01030;
  --bad-bg: #FDECEF;

  --r: 14px;
  --r-s: 10px;
  --r-l: 22px;
  --shadow: 0 1px 2px rgba(11,11,12,.05), 0 8px 24px -12px rgba(11,11,12,.16);
  --shadow-l: 0 2px 4px rgba(11,11,12,.06), 0 24px 56px -20px rgba(11,11,12,.26);

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--wash);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -.011em; }
p { margin: 0; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--action); text-underline-offset: 2px; }
a:hover { color: var(--action-dk); }

:focus-visible {
  outline: 3px solid var(--action);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── the demo bar ─────────────────────────────────────────────────────────
   Deliberately looks like scaffolding rather than product: a client should
   never wonder whether the role switcher ships. */

.demobar {
  position: sticky; top: 0; z-index: 60;
  background: var(--ink); color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.demobar__in {
  max-width: 1180px; margin: 0 auto; padding: 8px 18px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.demobar__tag {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--on-dark); white-space: nowrap;
}
.demobar__tag span { color: rgba(255,255,255,.5); font-weight: 600; }

.roles { display: flex; gap: 4px; background: rgba(255,255,255,.08); padding: 3px; border-radius: 999px; }
.roles button {
  appearance: none; border: 0; background: transparent; color: rgba(255,255,255,.72);
  padding: 6px 15px; border-radius: 999px; cursor: pointer;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  transition: background .16s, color .16s;
}
.roles button:hover { color: #fff; }
.roles button[aria-selected="true"] { background: #fff; color: var(--ink); }

.demobar__sp { flex: 1 1 auto; }
.linkish {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  color: rgba(255,255,255,.72); font-size: 13px; padding: 6px 8px; border-radius: 8px;
}
.linkish:hover { color: #fff; background: rgba(255,255,255,.1); }

/* ── shell ──────────────────────────────────────────────────────────────── */

.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 18px 64px; }
.view { display: none; }
.view.is-on { display: block; }

.vhead { margin-bottom: 20px; }
.vhead h1 { font-size: clamp(22px, 3.4vw, 29px); }
.vhead p { color: var(--ink-3); margin-top: 5px; font-size: 15px; max-width: 62ch; }

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow);
}
.card__h {
  padding: 15px 18px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card__h h2, .card__h h3 { font-size: 15.5px; }
.card__h .sp { flex: 1 1 auto; }
.card__b { padding: 18px; }

.muted { color: var(--ink-3); }
.small { font-size: 13.5px; }
.tiny { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* ── buttons ────────────────────────────────────────────────────────────── */

.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: var(--r-s);
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font-size: 15px; font-weight: 600; text-decoration: none;
  transition: background .15s, border-color .15s, transform .08s, box-shadow .15s;
}
.btn:hover { background: var(--wash); border-color: #D7D7DD; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

.btn--go { background: var(--action); border-color: var(--action); color: #fff; }
.btn--go:hover { background: var(--action-dk); border-color: var(--action-dk); }
.btn--dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--dark:hover { background: #22222A; border-color: #22222A; }
.btn--wide { width: 100%; }
.btn--lg { padding: 14px 22px; font-size: 16.5px; }
.btn--sm { padding: 7px 12px; font-size: 13.5px; border-radius: 8px; }

/* ── fields ─────────────────────────────────────────────────────────────── */

.field { margin-bottom: 14px; }
.field > label, .lbl {
  display: block; font-size: 13px; font-weight: 650; color: var(--ink-2);
  margin-bottom: 6px; letter-spacing: .005em;
}
.inp {
  width: 100%; padding: 12px 13px; border-radius: var(--r-s);
  border: 1px solid #D7D7DD; background: var(--paper);
  transition: border-color .15s, box-shadow .15s;
}
/* Focus is deliberately NOT red. The error state below is red, and a red
   focus ring made a perfectly valid amount field look like it had been
   rejected — which is exactly the wrong signal at a till. */
.inp:focus { outline: 0; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(11,11,12,.12); }
.inp::placeholder { color: #A8A8B2; }
.inp--big { font-size: 20px; padding: 14px; font-family: var(--mono); letter-spacing: .04em; }
.inp--err { border-color: var(--bad); }
.hint { font-size: 12.5px; color: var(--ink-3); margin-top: 5px; }
.err { font-size: 13px; color: var(--bad); margin-top: 6px; font-weight: 600; }

.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input { margin: 3px 0 0; width: 17px; height: 17px; accent-color: var(--action); flex: 0 0 auto; }
.check span { font-size: 14.5px; }

/* ── notes and banners ──────────────────────────────────────────────────── */

.note {
  border-radius: var(--r-s); padding: 12px 14px; font-size: 14px;
  border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.note b { font-weight: 700; }
.note--ok   { background: var(--good-bg); border-color: #BFE4CD; color: #0B5B2F; }
.note--warn { background: var(--warn-bg); border-color: #F0DCAE; color: #6B4600; }
.note--bad  { background: var(--bad-bg);  border-color: #F2C4CE; color: #850C24; }
.note--info { background: var(--wash); border-color: var(--line); color: var(--ink-2); }

.spec {
  margin-top: 26px; padding: 14px 16px; border-radius: var(--r-s);
  background: #FFFDF5; border: 1px dashed #E0CE9A; color: #5C4A12;
  font-size: 13.5px; line-height: 1.5;
}
.spec b { color: #3F3208; }

/* ── the member phone ───────────────────────────────────────────────────── */

.stage { display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 28px; align-items: start; }

.phone {
  background: var(--ink); border-radius: 34px; padding: 10px;
  box-shadow: var(--shadow-l); position: sticky; top: 74px;
}
.phone__scr {
  background: var(--paper); border-radius: 26px; overflow: hidden;
  min-height: 600px; display: flex; flex-direction: column;
}
.phone__bar {
  background: var(--brand); color: #fff; padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
}
.phone__bar img { height: 20px; width: auto; }
.phone__bar .sp { flex: 1 1 auto; }
.phone__body { padding: 16px; flex: 1 1 auto; }

/* ── tier badge and progress ────────────────────────────────────────────── */

.tierbadge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px 5px 9px; border-radius: 999px;
  font-size: 13px; font-weight: 700; letter-spacing: .01em;
  color: #fff; background: var(--ink-3);
}
.tierbadge i {
  width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.85);
  display: inline-block; flex: 0 0 auto;
}
.tierbadge--lg { font-size: 15px; padding: 7px 16px 7px 12px; }

.prog { margin-top: 14px; }
.prog__track {
  height: 10px; border-radius: 999px; background: var(--line-2);
  overflow: hidden; position: relative;
}
.prog__fill {
  height: 100%; border-radius: 999px; background: var(--action);
  width: 0; transition: width .7s cubic-bezier(.2,.7,.2,1);
}
.prog__lab { display: flex; justify-content: space-between; margin-top: 7px; font-size: 12.5px; color: var(--ink-3); }

.ladder { display: grid; gap: 8px; margin-top: 4px; }
.rung {
  display: grid; grid-template-columns: 26px 1fr auto; gap: 11px; align-items: center;
  padding: 10px 12px; border-radius: var(--r-s);
  border: 1px solid var(--line); background: var(--paper);
}
.rung--have { background: var(--wash-2); }
.rung--now { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.rung__dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 800;
  background: var(--line); color: var(--ink-3);
}
.rung--have .rung__dot, .rung--now .rung__dot { color: #fff; }
.rung__n { font-weight: 650; font-size: 14.5px; }
.rung__p { font-size: 12.5px; color: var(--ink-3); }
.rung__at { font-size: 13px; color: var(--ink-3); text-align: right; white-space: nowrap; }

/* ── the rotating QR ────────────────────────────────────────────────────── */

.qrbox { text-align: center; }
.qrframe {
  display: inline-block; padding: 12px; border-radius: var(--r);
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
  position: relative;
}
.qrframe svg { display: block; width: 216px; height: 216px; }
.qrframe--stale svg { opacity: .28; filter: grayscale(1); transition: opacity .2s; }
.qrframe__over {
  position: absolute; inset: 12px; display: none; place-items: center;
  border-radius: var(--r-s); background: rgba(255,255,255,.82); text-align: center;
  font-size: 13.5px; font-weight: 650; color: var(--ink-2); padding: 12px;
}
.qrframe--stale .qrframe__over { display: grid; }

.ring { display: inline-flex; align-items: center; gap: 9px; margin-top: 12px; font-size: 13px; color: var(--ink-3); }
.ring svg { width: 22px; height: 22px; transform: rotate(-90deg); flex: 0 0 auto; }
.ring circle { fill: none; stroke-width: 3; }
.ring .bg { stroke: var(--line); }
.ring .fg { stroke: var(--action); stroke-linecap: round; transition: stroke-dashoffset .95s linear; }

.codeline {
  margin-top: 14px; padding: 11px 13px; border-radius: var(--r-s);
  background: var(--wash); border: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px; justify-content: center;
}
.codeline b { font-family: var(--mono); font-size: 17px; letter-spacing: .06em; }

/* ── referral ───────────────────────────────────────────────────────────── */

.refcode {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px; border-radius: var(--r-s);
  background: var(--ink); color: #fff;
}
.refcode b {
  font-family: var(--mono); font-size: clamp(22px, 5vw, 28px); letter-spacing: .12em;
  color: #fff; line-height: 1;
}
.refcode .sp { flex: 1 1 auto; }
.refcode .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #fff; }
.refcode .btn:hover { background: rgba(255,255,255,.2); }

.reflist { display: grid; gap: 8px; }
.refrow {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-s); background: var(--wash-2);
  border: 1px solid var(--line-2); font-size: 14px;
}
.refrow .sp { flex: 1 1 auto; }

/* ── stats and tables ───────────────────────────────────────────────────── */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 14px; }
.kpi {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 16px; box-shadow: var(--shadow);
}
.kpi__k { font-size: 12.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .01em; }
.kpi__v {
  font-size: clamp(23px, 3.2vw, 29px); font-weight: 700; letter-spacing: -.02em;
  margin-top: 3px; line-height: 1.1;
}
.kpi__v--red { color: var(--brand); }
.kpi__n { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-3); font-weight: 700; padding: 9px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--wash-2);
}
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--wash-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tblwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.av {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff; font-size: 12.5px; font-weight: 700;
  background: var(--ink-3);
}
.who__n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who__e { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap;
}

/* ── the weekly bar chart ───────────────────────────────────────────────── */

.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.chart__col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; min-width: 0; }
.chart__bar {
  background: var(--action); border-radius: 5px 5px 2px 2px; min-height: 3px;
  transition: height .6s cubic-bezier(.2,.7,.2,1), background .15s;
  position: relative;
}
.chart__col:hover .chart__bar { background: var(--ink); }
.chart__x { display: flex; gap: 6px; margin-top: 7px; }
.chart__x span { flex: 1 1 0; text-align: center; font-size: 10.5px; color: var(--ink-3); min-width: 0; }

/* ── counter (staff) ────────────────────────────────────────────────────── */

.counter { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 24px; align-items: start; }

.scanbox {
  border: 2px dashed #D7D7DD; border-radius: var(--r);
  padding: 20px; text-align: center; background: var(--wash-2);
  transition: border-color .2s, background .2s;
}
.scanbox--live { border-color: var(--action); background: #FFF7F7; }

.readout {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;
  font-size: 14.5px; margin-top: 4px;
}
.readout dt { color: var(--ink-3); font-size: 13px; }
.readout dd { margin: 0; font-weight: 600; }

.bill { display: grid; gap: 7px; font-size: 15px; }
.bill__r { display: flex; justify-content: space-between; gap: 14px; }
.bill__r span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; }
.bill__r--off { color: var(--good); }
.bill__r--tot {
  border-top: 1px solid var(--line); margin-top: 5px; padding-top: 9px;
  font-size: 19px; font-weight: 700;
}

.celebrate {
  border-radius: var(--r); padding: 18px; text-align: center;
  background: linear-gradient(180deg, #1A1A20, #0B0B0C); color: #fff;
}
.celebrate .big { font-size: 25px; font-weight: 750; letter-spacing: -.02em; margin-top: 4px; }
.celebrate .tierbadge { margin-top: 10px; }

/* ── toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 18px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow-l);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 90; max-width: calc(100vw - 32px); text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ── reveal, attached from JS only ──────────────────────────────────────── */

.rv { opacity: 0; transform: translateY(12px); }
.rv.is-in { opacity: 1; transform: none; transition: opacity .5s ease, transform .5s cubic-bezier(.2,.7,.2,1); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .rv { opacity: 1; transform: none; }
}

/* ── narrow ─────────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .stage, .counter { grid-template-columns: minmax(0, 1fr); }
  .phone { position: static; border-radius: 0; padding: 0; background: none; box-shadow: none; }
  .phone__scr { border-radius: var(--r); border: 1px solid var(--line); box-shadow: var(--shadow); min-height: 0; }
  .wrap { padding: 18px 14px 56px; }
}

@media (max-width: 560px) {
  body { font-size: 15.5px; }
  .card__b, .phone__body { padding: 14px; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 10px; }
  /* On a phone the bar has to wrap. Reordered so it takes two rows rather than
     three: the label and the reset share the first, the role switcher gets the
     second. Scaffolding should not eat a third of the screen. */
  .demobar__in { padding: 7px 14px; gap: 8px 9px; }
  .demobar__tag { order: 1; }
  .demobar__sp { order: 2; flex: 1 1 auto; }
  .demobar .linkish { order: 3; }
  .roles { order: 4; width: 100%; }
  .roles button { flex: 1 1 0; padding: 7px 8px; font-size: 13px; }
  .chart { height: 116px; }
  .chart__x span:nth-child(even) { visibility: hidden; }
}
