/* Registration form, staff panel and QR scanner. Builds on styles.css (same colours and type). */

:root {
  --ok: #1a7f4b;
  --ok-soft: #e7f5ec;
  --bad: #a4161a;
  --bad-soft: #fbeaea;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
}

/* ================= Registration page ================= */
.reg { background: var(--mist); padding-block: clamp(32px, 6vw, 80px) clamp(56px, 8vw, 112px); min-height: calc(100dvh - var(--nav-h) - 120px); }
.reg-grid { display: grid; gap: clamp(24px, 4vw, 64px); align-items: start; }
@media (min-width: 940px) {
  .reg-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 520px); }
  .reg-intro { position: sticky; top: calc(var(--nav-h) + 40px); padding-top: 12px; }
}
.reg-intro h1 {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(2.1rem, 1.3rem + 3.4vw, 3.6rem); line-height: 1.07;
  margin-top: 10px; text-wrap: balance;
}
.reg-intro .lead { margin-top: 16px; max-width: 42ch; }
.nav-cta--keep { display: inline-flex !important; }

.reg-form { gap: 20px; box-shadow: 0 18px 50px rgba(6, 13, 24, 0.07); }
.field legend { font-size: 0.9rem; font-weight: 600; padding: 0; margin-bottom: 8px; }
.field select { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23060d18' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 14px center; }
.field input[readonly] { color: var(--muted); }
.field select[aria-invalid="true"] { border-color: var(--bad); }

.input-row { display: flex; flex-wrap: wrap; gap: 8px; }
.input-row > .btn { flex: 0 0 auto; }
.prefixed {
  flex: 1 1 200px; display: flex; align-items: center; min-width: 0;
  border: 1px solid #aab3c5; border-radius: 4px; background: #fff;
}
.prefixed span { padding: 0 2px 0 12px; font-weight: 600; color: var(--muted); }
.field .prefixed input { border: 0; background: transparent; min-height: 46px; padding-left: 8px; outline: none; }
.prefixed:focus-within { outline: 2px solid var(--royal); outline-offset: 3px; }
.prefixed:has(input[aria-invalid="true"]) { border-color: var(--bad); }
@media (max-width: 460px) { .input-row > .btn { flex: 1 1 100%; } .otp-box .input-row > .btn { flex: 0 0 auto; } }

.verified { display: flex; align-items: center; gap: 7px; color: var(--ok); font-weight: 600; font-size: 0.92rem; }
.otp-box { display: grid; gap: 8px; padding: 14px; background: var(--mist); border: 1px solid var(--line); border-radius: 4px; }
.field .otp-input {
  flex: 1 1 120px; width: auto; max-width: 180px; text-align: center;
  font-size: 1.25rem; font-weight: 600; letter-spacing: 0.45em; font-variant-numeric: tabular-nums;
}
.linkbtn { border: 0; background: none; padding: 0; font-weight: 600; color: var(--royal); text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:disabled { color: var(--muted); text-decoration: none; cursor: default; }

/* Tick boxes for the referral question */
.ticks { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 8px; }
.field .tick {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 1px solid #aab3c5; border-radius: 4px;
  font-size: 1rem; font-weight: 500; cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
.field .tick input {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto;
  width: 22px; height: 22px; min-height: 0; padding: 0; margin: 0;
  border: 1.5px solid #8c97ad; border-radius: 4px; background: #fff; cursor: pointer;
}
.field .tick input:checked {
  border-color: var(--royal);
  background: var(--royal) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M5.5 11.5l3.6 3.6 7.4-7.8' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
}
.tick:has(input:checked) { border-color: var(--royal); background: #f2f6fe; }
.form-error { color: var(--bad); font-size: 0.92rem; }

/* Thank-you message */
.reg-done { justify-items: center; text-align: center; gap: 14px; padding-block: clamp(36px, 6vw, 60px); box-shadow: 0 18px 50px rgba(6, 13, 24, 0.07); }
.reg-done:focus { outline: none; }
.reg-done h2 { font-family: var(--display); font-weight: 400; font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem); line-height: 1.15; text-wrap: balance; }
.done-tick { margin-bottom: 6px; }
.done-tick circle { fill: var(--ok-soft); stroke: var(--ok); stroke-width: 3; stroke-dasharray: 208; stroke-dashoffset: 208; animation: tick-draw 0.6s var(--ease) forwards; }
.done-tick path { fill: none; stroke: var(--ok); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 44; stroke-dashoffset: 44; animation: tick-draw 0.4s 0.5s var(--ease) forwards; }
@keyframes tick-draw { to { stroke-dashoffset: 0; } }
.done-pass { display: grid; gap: 14px; width: 100%; margin-top: 8px; padding: 18px; background: var(--mist); border-radius: 4px; font-size: 0.98rem; }

/* ================= Staff pages (admin + scanner) ================= */
.staff { background: var(--mist); min-height: 100dvh; }
.staff-bar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 50; }
.staff-bar-in { display: flex; align-items: center; gap: 12px 24px; min-height: 60px; flex-wrap: wrap; padding-block: 8px; }
.staff-brand { display: flex; align-items: center; gap: 12px; margin-right: auto; text-decoration: none; }
.staff-brand img { height: 24px; width: auto; }
.staff-brand span { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255, 255, 255, 0.7); padding-left: 12px; border-left: 1px solid var(--line-dark); }
.staff-tabs { display: flex; gap: 4px; }
.staff-tabs button, .staff-bar a.bar-link, .staff-bar button.bar-link {
  border: 0; background: none; color: rgba(255, 255, 255, 0.78);
  font-weight: 600; font-size: 0.95rem; padding: 9px 14px; border-radius: 4px; text-decoration: none;
}
.staff-tabs button:hover, .staff-bar .bar-link:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.staff-tabs button[aria-selected="true"] { background: #fff; color: var(--ink); }
.staff-bar :focus-visible { outline-color: var(--sky); }

.staff-main { padding-block: clamp(20px, 3vw, 36px) 72px; }
.staff-main .wrap { width: min(100% - 2 * var(--gutter), 1360px); }
.staff h1 { font-family: var(--display); font-weight: 400; font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.2rem); line-height: 1.15; }
.staff-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }

.notice { padding: 10px 14px; border-radius: 4px; font-size: 0.92rem; background: var(--warn-soft); color: var(--warn); border: 1px solid #ecd9a6; margin-bottom: 16px; }

/* Login card */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--ink); }
.login-card { width: min(100%, 400px); }
.login-card img { width: 150px; height: auto; margin-bottom: 4px; }
.login-card h1 { font-family: var(--display); font-weight: 400; font-size: 1.6rem; }

/* Counters */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 12px 16px; }
.stat b { display: block; font-size: 1.9rem; font-weight: 700; font-stretch: 88%; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.86rem; color: var(--muted); }

/* Filters */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-bottom: 14px; }
.toolbar .chips { margin-right: auto; }
.search { min-height: 42px; padding: 8px 12px; border: 1px solid #aab3c5; border-radius: 4px; background: #fff; width: min(100%, 280px); }

/* Registrations table */
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 4px; overflow-x: auto; }
.regs { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
.regs th { text-align: left; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfd; }
.regs td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.regs tr:last-child td { border-bottom: 0; }
.regs .who b { display: block; font-size: 1rem; font-weight: 600; }
.regs small { display: block; color: var(--muted); font-size: 0.84rem; }
.regs a { color: var(--royal); font-weight: 600; text-underline-offset: 3px; }
.regs .num { white-space: nowrap; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

.decide-row { display: flex; gap: 6px; }
.decide {
  min-height: 38px; padding: 6px 14px; border-radius: 4px; font-weight: 600; font-size: 0.9rem; white-space: nowrap;
  border: 1.5px solid; background: #fff; transition: background-color 0.2s, color 0.2s;
}
.decide--yes { border-color: var(--ok); color: var(--ok); }
.decide--no { border-color: var(--bad); color: var(--bad); }
.decide--yes:hover, .decide--yes[aria-pressed="true"] { background: var(--ok); color: #fff; }
.decide--no:hover, .decide--no[aria-pressed="true"] { background: var(--bad); color: #fff; }
.decide:disabled { opacity: 0.55; cursor: not-allowed; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.pill--pending { background: var(--warn-soft); color: var(--warn); }
.pill--approved, .pill--sent, .pill--in { background: var(--ok-soft); color: var(--ok); }
.pill--denied, .pill--failed { background: var(--bad-soft); color: var(--bad); }
.pill--test { background: #e9edf5; color: var(--muted); }
.pass-cell { display: grid; gap: 4px; justify-items: start; }

@media (max-width: 899px) {
  /* Each registration becomes a card on phones. */
  .table-wrap { background: none; border: 0; overflow: visible; }
  .regs thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .regs, .regs tbody, .regs tr, .regs td { display: block; }
  .regs tr { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 6px 0; margin-bottom: 10px; }
  .regs td { border: 0; padding: 6px 14px; }
  .regs td:empty { display: none; }
  .staff-bar { position: static; }
  .regs td[data-label]:not(:empty)::before { content: attr(data-label); display: block; font-size: 0.74rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
}

/* Referral codes */
.card { background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: clamp(16px, 2.4vw, 24px); }
.card + .card { margin-top: 12px; }
.gen { display: grid; gap: 12px; align-items: end; }
@media (min-width: 640px) { .gen { grid-template-columns: minmax(0, 1fr) auto; } }
.gen-out { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 14px; padding: 14px 16px; background: var(--ok-soft); border-radius: 4px; }
.gen-out strong, .code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; letter-spacing: 0.08em; }
.gen-out strong { font-size: 1.5rem; }
.ref-list { margin-top: 20px; display: grid; gap: 10px; }
.ref summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; cursor: pointer; list-style: none; }
.ref summary::-webkit-details-marker { display: none; }
.ref .code { font-size: 1.1rem; }
.ref .count { margin-left: auto; font-size: 0.88rem; font-weight: 600; color: var(--royal); white-space: nowrap; }
.ref ul { margin-top: 12px; border-top: 1px solid var(--line); }
.ref li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.94rem; }
.ref li:last-child { border-bottom: 0; padding-bottom: 0; }
.ref li b { font-weight: 600; margin-right: auto; }

/* ================= QR scanner ================= */
.scan { background: var(--ink); color: #fff; min-height: 100dvh; }
.scan-main { width: min(100% - 32px, 520px); margin-inline: auto; padding-block: 20px 48px; display: grid; gap: 16px; }
.scan-count { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 0.95rem; color: rgba(255, 255, 255, 0.72); }
.scan-count b { font-size: 1.5rem; color: #fff; font-variant-numeric: tabular-nums; }
.viewfinder { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: #000; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; }
.viewfinder::after { /* aiming frame */
  content: ""; position: absolute; inset: 14%; border-radius: 10px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 100vmax rgba(6, 13, 24, 0.35);
  pointer-events: none;
}
.viewfinder.is-paused::after { border-color: rgba(255, 255, 255, 0.3); }
.cam-msg { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; gap: 12px; padding: 24px; text-align: center; background: var(--ink-2); }
.result { border-radius: 8px; padding: 18px 20px; min-height: 124px; display: grid; align-content: center; gap: 4px; background: var(--ink-2); border: 1px solid var(--line-dark); }
.result h2 { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.result p { color: rgba(255, 255, 255, 0.8); }
.result .big { font-family: var(--display); font-size: 1.7rem; color: #fff; line-height: 1.15; }
.result--ok { background: #12693d; border-color: #2aa568; }
.result--used { background: #8a4b00; border-color: #d48a1c; }
.result--bad { background: #8f1418; border-color: #d4474b; }
.scan-actions { display: grid; gap: 10px; }
.scan .btn-ghost { border-color: rgba(255, 255, 255, 0.5); color: #fff; }
.scan .btn-ghost:hover { background: #fff; color: var(--ink); }
.scan .note { color: rgba(255, 255, 255, 0.6); text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .done-tick circle, .done-tick path { stroke-dashoffset: 0; }
}
