:root {
  --page-bg: #12091f;
  --page-bg-2: #24123f;
  --card: rgba(29, 17, 49, 0.84);
  --card-strong: rgba(22, 12, 39, 0.96);
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #ffffff;
  --muted: #d7c7ef;
  --soft: #aa95ca;
  --ecocash: #f59e0b;
  --ecocash-strong: #f97316;
  --whatsapp: #25d366;
  --whatsapp-strong: #128c7e;
  --brand: #8b5cf6;
  --brand-2: #06b6d4;
  --danger: #fb7185;
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.36);
  --radius-xl: 30px;
  --radius-lg: 24px;
  --radius-md: 18px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--page-bg); }

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background:
    radial-gradient(circle at 12% 0%, rgba(6, 182, 212, 0.24), transparent 26rem),
    radial-gradient(circle at 95% 16%, rgba(139, 92, 246, 0.34), transparent 24rem),
    linear-gradient(145deg, #12091f 0%, #24123f 52%, #090511 100%);
  overflow-x: hidden;
}

button, input, a { font: inherit; }
a { color: inherit; text-decoration: none; }
button { border: 0; }
[hidden], .hide { display: none !important; }

.body-loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
}

.body-loading img { width: 210px; height: auto; }

.portal-page {
  min-height: 100vh;
  padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
}

.portal-shell {
  width: min(100%, 500px);
  margin: 0 auto;
}

.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 44px 1fr 48px;
  align-items: center;
  gap: 8px;
  margin: -2px -2px 12px;
  padding: 10px 4px 12px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: linear-gradient(180deg, rgba(18, 9, 31, 0.96), rgba(18, 9, 31, 0.76));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.back-button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}

.back-button span {
  display: block;
  transform: translateY(-1px);
  font-size: 36px;
  line-height: 1;
  font-weight: 500;
}

.topbar-title h1 {
  margin: 0;
  font-size: clamp(1.34rem, 5.8vw, 1.92rem);
  line-height: 1.06;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.topbar-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  box-shadow: 0 14px 34px rgba(6, 182, 212, 0.22);
}

.intro-card,
.voucher-card,
.token-card,
.portal-footer {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(42, 26, 70, 0.82), rgba(15, 8, 27, 0.94));
  box-shadow: var(--shadow);
}

.intro-card {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 16px;
  border-radius: var(--radius-lg);
}

.eyebrow {
  margin: 0 0 6px;
  color: #67e8f9;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.intro-card h2,
.section-title h2,
.token-card h2 {
  margin: 0;
  font-size: clamp(0.96rem, 3.9vw, 1.16rem);
  line-height: 1.24;
  letter-spacing: -0.02em;
  font-weight: 650;
}

.intro-note,
.token-card p,
.portal-footer p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 2px 8px;
}

.section-title h2 { font-size: clamp(1.02rem, 4.4vw, 1.32rem);
  font-weight: 700; }

.voucher-list {
  display: grid;
  gap: 8px;
}

.voucher-card {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border-radius: var(--radius-lg);
}

.voucher-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 0% 0%, rgba(6, 182, 212, 0.16), transparent 13rem),
    linear-gradient(90deg, rgba(255,255,255,0.04), transparent 52%);
}

.voucher-main,
.voucher-actions,
.ussd-panel {
  position: relative;
  z-index: 1;
}

.voucher-main {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.voucher-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 182, 212, 0.13);
  border: 1px solid rgba(103, 232, 249, 0.16);
}

.voucher-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #67e8f9;
  stroke-width: 1.7;
}

.voucher-heading {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.voucher-price {
  font-size: clamp(1.26rem, 5.8vw, 1.64rem);
  line-height: 1;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.voucher-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 21px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
}

.voucher-badge.popular { background: linear-gradient(135deg, #06b6d4, #2563eb); }
.voucher-badge.value { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.voucher-badge.family { background: linear-gradient(135deg, #a855f7, #7c3aed); }

.voucher-copy p {
  margin: 2px 0 0;
  color: var(--soft);
  font-size: clamp(0.82rem, 3.5vw, 0.92rem);
  font-weight: 560;
  line-height: 1.34;
}

.voucher-copy p span { color: #fff; }

.voucher-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.voucher-button {
  min-width: 0;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 11px;
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  font-size: clamp(0.72rem, 3vw, 0.84rem);
  font-weight: 650;
  line-height: 1.1;
  text-align: center;
  white-space: normal;
  transition: transform 150ms ease, filter 150ms ease;
}

.voucher-button:active { transform: translateY(1px) scale(0.99); }
.voucher-button.ecocash { background: linear-gradient(135deg, var(--ecocash), var(--ecocash-strong)); }
.voucher-button.whatsapp { background: linear-gradient(135deg, var(--whatsapp), var(--whatsapp-strong)); }

.ussd-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed rgba(103, 232, 249, 0.48);
  border-radius: var(--radius-md);
  background: rgba(7, 5, 15, 0.48);
}

.ussd-label {
  display: block;
  color: #67e8f9;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.ussd-code {
  display: block;
  margin-top: 2px;
  color: #fff;
  font-size: clamp(0.82rem, 3.6vw, 0.98rem);
  line-height: 1.24;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  user-select: all;
}

.copy-ussd {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  font-weight: 650;
}

.token-card {
  display: grid;
  gap: 16px;
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-lg);
}

.token-label {
  display: block;
  margin-bottom: 8px;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 650;
}

.rj-input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  outline: none;
  background: rgba(5, 3, 10, 0.52);
  color: #fff;
  font-size: 0.94rem;
  font-weight: 600;
}

.rj-input:focus {
  border-color: rgba(103, 232, 249, 0.72);
  box-shadow: 0 0 0 4px rgba(6, 182, 212, 0.16);
}

.rj-input::placeholder { color: rgba(215, 199, 239, 0.62); }

.login-msg {
  min-height: 20px;
  margin: 6px 0 8px;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.35;
}

.connect-button {
  width: 100%;
  min-height: 48px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.connect-button:disabled {
  opacity: 0.68;
  cursor: wait;
}

.portal-footer {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  text-align: center;
}

.portal-footer a {
  color: #67e8f9;
  font-weight: 700;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 70;
  max-width: calc(100% - 28px);
  transform: translate(-50%, 20px);
  opacity: 0;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(10, 5, 18, 0.96);
  box-shadow: 0 20px 60px rgba(0,0,0,0.32);
  color: #fff;
  font-weight: 650;
  text-align: center;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.dropdown.language-select,
.other-btn-wrapper,
.login-split-line,
.login-form-title,
.content-decoration-wrapper,
.content-logo-wrapper,
.content-logo,
.body-wrapper,
.body-background,
.body-background-mask,
.body-content-wrapper,
.body-content {
  display: none !important;
}

@media (min-width: 720px) {
  .portal-page { padding: 18px; }
  .portal-shell { width: min(100%, 700px); }
  .intro-card {
    grid-template-columns: 1.1fr 0.9fr;
    align-items: center;
    padding: 18px;
  }
  .voucher-card,
  .token-card { padding: 18px; }
}

@media (min-width: 980px) {
  body.desktop-package .portal-shell { width: min(100%, 980px); }
  body.desktop-package .portal-topbar { grid-template-columns: 46px 1fr 48px; }
  body.desktop-package .voucher-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.desktop-package .token-card {
    grid-template-columns: 0.85fr 1fr;
    align-items: center;
  }
  body.desktop-package .portal-topbar { margin-bottom: 18px; }
}

@media (min-width: 1220px) {
  body.desktop-package .portal-shell { width: min(100%, 1100px); }
  body.desktop-package .voucher-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  body.desktop-package .voucher-actions { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .portal-page { padding-left: 10px; padding-right: 10px; }
  .portal-topbar { grid-template-columns: 36px 1fr 40px; gap: 7px; }
  .brand-logo { width: 38px; height: 38px; }
  .back-button { width: 36px; height: 36px; }
  .voucher-card { padding: 13px; }
  .voucher-main { grid-template-columns: 42px 1fr; }
  .voucher-icon { width: 42px; height: 42px; }
  .voucher-actions { gap: 8px; }
  .voucher-button { min-height: 40px; padding-left: 8px; padding-right: 8px; }
}


/* v3 refinement: smaller scale + lighter typography */
.portal-topbar { grid-template-columns: 40px 1fr 42px; }
.topbar-title h1 { font-size: clamp(1.34rem, 5.8vw, 1.92rem); font-weight: 700; }
.topbar-title p { font-size: 0.8rem; font-weight: 600; }
.intro-card h2, .section-title h2, .token-card h2 { font-weight: 650; }
.intro-note, .token-card p, .portal-footer p { font-size: 0.84rem; }
.voucher-main { grid-template-columns: 46px 1fr; gap: 10px; margin-bottom: 12px; }
.voucher-icon { width: 46px; height: 46px; border-radius: 14px; }
.voucher-price { font-size: clamp(1.26rem, 5.8vw, 1.64rem); font-weight: 700; }
.voucher-copy p { font-size: clamp(0.82rem, 3.5vw, 0.92rem); font-weight: 560; }
.voucher-actions { gap: 8px; }
.voucher-button { min-height: 42px; padding: 9px 11px; font-size: clamp(0.72rem, 3vw, 0.84rem); font-weight: 650; }
.token-card { gap: 14px; margin-top: 14px; padding: 16px; }
.token-label { font-size: 0.8rem; font-weight: 650; }
.login-msg { font-size: 0.82rem; font-weight: 600; }
.portal-footer a, .connect-button, .copy-ussd { font-weight: 700; }
.toast { font-weight: 650; }
@media (max-width: 390px) {
  .portal-page { padding-left: 10px; padding-right: 10px; }
  .portal-topbar { grid-template-columns: 36px 1fr 38px; gap: 7px; }
  .brand-logo { width: 38px; height: 38px; }
  .back-button { width: 36px; height: 36px; }
  .voucher-main { grid-template-columns: 42px 1fr; }
  .voucher-icon { width: 42px; height: 42px; }
  .voucher-button { min-height: 40px; padding-left: 8px; padding-right: 8px; }
}
@media (min-width: 720px) {
  .portal-page { padding: 22px; }
  .portal-shell { width: min(100%, 700px); }
  .intro-card { padding: 18px; }
  .voucher-card, .token-card { padding: 18px; }
}
@media (min-width: 980px) {
  body.desktop-package .portal-shell { width: min(100%, 980px); }
  body.desktop-package .portal-topbar { grid-template-columns: 46px 1fr 48px; }
}
@media (min-width: 1220px) {
  body.desktop-package .portal-shell { width: min(100%, 1100px); }
}

/* v4 reliable proof delivery: app-first WhatsApp with SMS fallback */
.proof-sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  background: rgba(4, 2, 10, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.proof-sheet-card {
  width: min(100%, 520px);
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(42, 26, 70, 0.96), rgba(12, 7, 22, 0.98));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.5);
  padding: 16px;
}

.proof-sheet-header {
  display: grid;
  grid-template-columns: 1fr 36px;
  gap: 12px;
  align-items: start;
}

.proof-sheet-header h2 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.22;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.proof-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  font-weight: 500;
}

.proof-copy,
.proof-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.proof-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.proof-action {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 10px;
  color: #fff;
  cursor: pointer;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.15;
  font-weight: 650;
}

.proof-action.whatsapp { background: linear-gradient(135deg, var(--whatsapp), var(--whatsapp-strong)); }
.proof-action.sms { background: linear-gradient(135deg, var(--brand), #4f46e5); }
.proof-action.copy { background: rgba(255, 255, 255, 0.12); }
.proof-action.web { background: rgba(255, 255, 255, 0.08); color: var(--muted); }

@media (min-width: 720px) {
  .proof-sheet { align-items: center; }
  .proof-sheet-card { padding: 18px; }
}

.payment-modal{position:fixed;inset:0;background:rgba(13,17,28,.72);display:grid;place-items:center;padding:18px;z-index:9999}.payment-modal[hidden]{display:none}.payment-modal-card{position:relative;width:min(460px,100%);background:#fff;border-radius:22px;padding:28px;box-shadow:0 24px 80px #0006;text-align:center}.payment-modal-close{position:absolute;right:14px;top:12px;border:0;background:transparent;font-size:28px;cursor:pointer}.payment-modal-card .rj-input{width:100%;box-sizing:border-box;margin:8px 0 14px}.payment-spinner{width:54px;height:54px;border:5px solid #ece7f4;border-top-color:#5b2a86;border-radius:50%;margin:10px auto 22px;animation:paySpin 1s linear infinite}@keyframes paySpin{to{transform:rotate(360deg)}}.payment-countdown{font-size:44px;font-weight:800;margin:18px}.token-result{background:#f4f0fa;border-radius:14px;padding:18px;margin:18px 0}.token-result span{display:block;color:#666}.token-result strong{display:block;font-size:26px;letter-spacing:1px;margin-top:7px;word-break:break-all}.small-note{font-size:12px;color:#777}.voucher-actions .ecocash{width:100%}

.portal-support-link{display:block;margin-top:14px;text-align:center;font-weight:800;color:#5b2a86;text-decoration:underline}.small-note{font-size:12px;color:#667085;line-height:1.45}

/* Payment modal accessibility and contrast fix */
.payment-modal-card {
  background: #ffffff;
  color: #172033;
  border: 1px solid rgba(15, 23, 42, 0.10);
}

.payment-modal-card h2,
.payment-modal-card p,
.payment-modal-card label {
  color: #172033;
}

.payment-modal-card .eyebrow {
  color: #087f98;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.payment-modal-card .token-label {
  margin-top: 12px;
  margin-bottom: 6px;
  color: #263248;
  text-align: left;
  font-size: 0.86rem;
  font-weight: 750;
}

.payment-modal-card .rj-input {
  min-height: 52px;
  background: #f8fafc;
  border: 1px solid #aeb8c8;
  color: #111827;
  caret-color: #111827;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.payment-modal-card .rj-input::placeholder {
  color: #667085;
  opacity: 1;
}

.payment-modal-card .rj-input:hover {
  border-color: #7b879b;
}

.payment-modal-card .rj-input:focus {
  background: #ffffff;
  border-color: #0891b2;
  box-shadow: 0 0 0 4px rgba(8, 145, 178, 0.16);
}

.payment-modal-card .small-note {
  color: #526078;
}

.payment-modal-card .login-msg {
  color: #b42318;
}

.payment-modal-close {
  color: #172033;
  border-radius: 999px;
  width: 40px;
  height: 40px;
  line-height: 36px;
}

.payment-modal-close:hover,
.payment-modal-close:focus-visible {
  background: #eef2f6;
  outline: 2px solid #0891b2;
  outline-offset: 2px;
}

.payment-modal-card .connect-button {
  color: #ffffff;
  text-shadow: 0 1px 1px rgba(0,0,0,.18);
}

.payment-countdown,
#payment_reference,
#voucher_time_left,
#voucher_data,
#payment_failed_text {
  color: #172033;
}

@media (max-width: 520px) {
  .payment-modal-card {
    padding: 24px 20px 22px;
  }
}
