:root {
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  color: #251f31;
  background: #f7f5fb;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --brand: #3d2965;
  --accent: #8f75b8;
  --canvas: #f7f5fb;
  --surface: #ffffff;
  --text: #251f31;
  --muted: #70697c;
  --border: #e5deee;
  --success: #147a55;
  --warning: #8c5d14;
  --error: #b42318;
  --focus: #654899;
  --shadow: rgba(45, 29, 80, .14);
  color-scheme: light;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --success: #63d9a8;
  --warning: #f1c56e;
  --error: #ff9c96;
  --focus: #d8c1f6;
  --shadow: rgba(0, 0, 0, .36);
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; background: var(--canvas); }
body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 7%, color-mix(in srgb, var(--accent) 16%, transparent) 0, transparent 34%),
    radial-gradient(circle at 92% 86%, color-mix(in srgb, var(--brand) 12%, transparent) 0, transparent 35%),
    var(--canvas);
}

button, input { font: inherit; }
button { color: inherit; }
button, input { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; opacity: .58; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.skip-link {
  position: fixed;
  z-index: 100;
  inset-block-start: 8px;
  inset-inline-start: 50%;
  padding: 10px 15px;
  transform: translate(50%, -150%);
  color: #fff;
  background: #1b1428;
  border-radius: 10px;
  text-decoration: none;
}
.skip-link:focus { transform: translate(50%, 0); }

.ambient {
  position: fixed;
  z-index: 0;
  border: 1px solid color-mix(in srgb, var(--brand) 11%, transparent);
  border-radius: 50%;
  pointer-events: none;
}
.ambient::before, .ambient::after { content: ""; position: absolute; inset: 13%; border: inherit; border-radius: inherit; }
.ambient::after { inset: 27%; }
.ambient-one { width: 42vw; height: 42vw; inset-block-start: -27vw; inset-inline-end: -13vw; }
.ambient-two { width: 31vw; height: 31vw; inset-block-end: -20vw; inset-inline-start: -8vw; }

.portal-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 500px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: auto;
  padding: max(18px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
}

.utility-bar {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.secure-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .76rem; }
.secure-note svg { width: 18px; height: 18px; color: var(--brand); }
.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: 13px;
  cursor: pointer;
  transition: color .18s, border-color .18s, transform .18s;
}
.icon-button:hover { color: var(--brand); border-color: var(--brand); }
.icon-button:active { transform: translateY(1px); }
.theme-icon { width: 20px; height: 20px; }
.theme-icon-moon, :root[data-theme="dark"] .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: block; }

.portal-card {
  width: 100%;
  margin-block: 14px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--brand) 10%, var(--border));
  border-radius: 28px;
  box-shadow: 0 24px 72px var(--shadow);
}
.portal-card:focus { outline: none; }

.brand-panel {
  position: relative;
  padding: 24px 28px 21px;
  display: grid;
  justify-items: center;
  overflow: hidden;
  text-align: center;
  background:
    radial-gradient(circle at 4% 8%, color-mix(in srgb, var(--accent) 25%, transparent), transparent 38%),
    linear-gradient(145deg, color-mix(in srgb, var(--brand) 7%, var(--surface)), var(--surface) 72%);
  border-bottom: 1px solid var(--border);
}
.brand-panel::before, .brand-panel::after {
  content: "";
  position: absolute;
  border: 1px solid color-mix(in srgb, var(--brand) 10%, transparent);
  border-radius: 50%;
  pointer-events: none;
}
.brand-panel::before { width: 180px; height: 180px; inset-block-start: -115px; inset-inline-end: -58px; }
.brand-panel::after { width: 92px; height: 92px; inset-block-end: -60px; inset-inline-start: -27px; }

.brand-mark {
  position: relative;
  z-index: 1;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: #fff;
  border: 1px solid color-mix(in srgb, var(--brand) 15%, #e9e4f0);
  border-radius: 18px;
  box-shadow: 0 12px 30px color-mix(in srgb, var(--brand) 13%, transparent);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; padding: 9px; object-fit: contain; }
.brand-mark span { font-size: 1.2rem; font-weight: 700; }
.brand-mark[data-presentation="wordmark"] {
  width: min(100%, 286px);
  height: 124px;
  border: 0;
  border-radius: 20px;
}
.brand-mark[data-presentation="wordmark"] img {
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 50%;
  width: 100%;
  height: auto;
  padding: 0;
  transform: translateY(-50%);
}
.portal-content { padding: 22px 30px 28px; }
.environment-note {
  margin-bottom: 20px;
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warning) 20%, var(--border));
  border-radius: 12px;
  font-size: .68rem;
  line-height: 1.75;
}
.environment-note svg { width: 17px; height: 17px; margin-top: 1px; flex: 0 0 auto; }

.screen { display: none; }
.screen.active { display: block; animation: screen-in .24s ease both; }
.eyebrow { margin: 0 0 7px; color: var(--brand); font-size: .72rem; font-weight: 700; }
h1 { max-width: 370px; margin: 0; color: var(--text); font-size: clamp(1.35rem, 5.5vw, 1.72rem); font-weight: 700; line-height: 1.55; letter-spacing: -.025em; }
.lead { max-width: 380px; margin: 10px 0 22px; color: var(--muted); font-size: .88rem; line-height: 1.9; }
.privacy-hint {
  margin-bottom: 22px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  background: color-mix(in srgb, var(--brand) 4%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 10%, var(--border));
  border-radius: 12px;
  font-size: .68rem;
  line-height: 1.7;
}
.privacy-hint svg { width: 19px; height: 19px; flex: 0 0 auto; color: var(--brand); }

.field-heading { margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-heading label, form > label[for="otp"] { display: block; color: var(--text); font-size: .78rem; font-weight: 600; }
.field-heading span { color: var(--muted); font-size: .62rem; }
.field-heading .required-mark { color: var(--error); font-size: .85rem; }
.text-field {
  min-height: 56px;
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  color: var(--text);
  background: color-mix(in srgb, var(--canvas) 58%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color .18s, box-shadow .18s, background .18s;
  overflow: hidden;
}
.text-field:focus-within { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 13%, transparent); }
.text-field.is-invalid { border-color: var(--error); box-shadow: 0 0 0 4px color-mix(in srgb, var(--error) 10%, transparent); }
.text-field > svg { width: 20px; height: 20px; margin-inline-start: 14px; color: var(--accent); }
.text-field input { width: 100%; height: 54px; padding: 0 13px; color: var(--text); background: transparent; border: 0; outline: 0; font-size: .84rem; }
.mobile-field {
  min-height: 56px;
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  color: var(--text);
  background: color-mix(in srgb, var(--canvas) 58%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  transition: border-color .18s, box-shadow .18s, background .18s;
  overflow: hidden;
}
.mobile-field:focus-within { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 13%, transparent); }
.mobile-field.is-invalid { border-color: var(--error); box-shadow: 0 0 0 4px color-mix(in srgb, var(--error) 10%, transparent); }
.mobile-field > svg { width: 20px; height: 20px; margin-inline-start: 14px; color: var(--accent); }
.mobile-field input {
  width: 100%;
  height: 54px;
  padding: 0 14px;
  direction: ltr;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 1rem;
  letter-spacing: .035em;
}
input::placeholder { color: color-mix(in srgb, var(--muted) 68%, transparent); }
.field-hint { margin-top: 7px; display: block; color: var(--muted); font-size: .66rem; line-height: 1.65; }
.field-error { min-height: 23px; margin: 4px 0 2px; color: var(--error); font-size: .7rem; line-height: 1.65; }

.consent-block { margin-top: 5px; padding: 12px 13px 9px; background: color-mix(in srgb, var(--canvas) 50%, var(--surface)); border: 1px solid var(--border); border-radius: 13px; }
.consent-field { min-height: 34px; display: flex; align-items: flex-start; gap: 9px; color: var(--muted); cursor: pointer; font-size: .71rem; line-height: 1.8; }
.consent-field input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.custom-check {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: var(--surface);
  border: 1.5px solid color-mix(in srgb, var(--muted) 55%, var(--border));
  border-radius: 6px;
  transition: background .16s, border-color .16s, box-shadow .16s;
}
.custom-check svg { width: 14px; height: 14px; stroke-width: 2.4; opacity: 0; transform: scale(.7); transition: opacity .16s, transform .16s; }
.consent-field input:checked + .custom-check { background: var(--brand); border-color: var(--brand); }
.consent-field input:checked + .custom-check svg { opacity: 1; transform: scale(1); }
.consent-field input:focus-visible + .custom-check { box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 18%, transparent); }
.consent-error:empty { min-height: 0; margin: 0; }
.text-button { min-height: 40px; padding: 0; color: var(--brand); background: none; border: 0; font-size: .7rem; font-weight: 600; cursor: pointer; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }

.primary-button, .secondary-button {
  width: 100%;
  min-height: 54px;
  padding: 0 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 14px;
  font-size: .84rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s, filter .18s;
}
.primary-button { margin-top: 17px; color: #fff; background: linear-gradient(135deg, var(--brand), color-mix(in srgb, var(--brand) 78%, var(--accent))); border: 1px solid var(--brand); box-shadow: 0 13px 28px color-mix(in srgb, var(--brand) 25%, transparent); }
:root[data-theme="dark"] .primary-button { color: #1c1329; }
.primary-button:hover { filter: brightness(1.06); transform: translateY(-1px); }
.primary-button:active { transform: translateY(1px); }
.primary-button svg { width: 20px; height: 20px; stroke-width: 2; }
.primary-button[type="submit"] svg { transform: scaleX(-1); }
.secondary-button { margin-top: 10px; color: var(--text); background: transparent; border: 1px solid var(--border); }
.secondary-button:hover { border-color: var(--brand); color: var(--brand); }
form[aria-busy="true"] .primary-button::after { content: ""; width: 18px; height: 18px; border: 2px solid currentColor; border-inline-end-color: transparent; border-radius: 50%; animation: spin .72s linear infinite; }
form[aria-busy="true"] .primary-button > svg { display: none; }

.back-button { min-height: 42px; margin: -10px 0 14px; padding: 0; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); background: none; border: 0; font-size: .7rem; cursor: pointer; }
.back-button:hover { color: var(--brand); }
.back-button svg { width: 17px; height: 17px; transform: scaleX(-1); }
.screen-icon {
  width: 58px;
  height: 58px;
  margin: 0 0 16px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--brand) 16%, var(--border));
  border-radius: 18px;
}
.screen-icon svg { width: 28px; height: 28px; }
.otp-input {
  width: 100%;
  height: 62px;
  margin-top: 8px;
  padding: 0 14px;
  direction: ltr;
  text-align: center;
  color: var(--text);
  background: color-mix(in srgb, var(--canvas) 58%, var(--surface));
  border: 1px solid var(--border);
  border-radius: 14px;
  font-family: "Segoe UI", Consolas, monospace;
  font-size: 1.35rem;
  letter-spacing: .36em;
}
.otp-input:focus { background: var(--surface); border-color: var(--brand); outline: 4px solid color-mix(in srgb, var(--focus) 13%, transparent); }
.otp-input[aria-invalid="true"] { border-color: var(--error); }
.resend-row { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .68rem; }

.status-screen { padding-top: 9px; text-align: center; }
.status-screen h1, .status-screen .lead { margin-inline: auto; }
.status-screen .lead { margin-bottom: 24px; }
.status-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--success) 24%, var(--border));
  border-radius: 50%;
  box-shadow: 0 0 0 9px color-mix(in srgb, var(--success) 6%, transparent);
  font-size: 1.75rem;
  font-weight: 700;
}
.status-screen[data-status="expired"] .status-icon, .status-screen[data-status="revoked"] .status-icon, .status-screen[data-status="error"] .status-icon { color: var(--error); background: color-mix(in srgb, var(--error) 9%, var(--surface)); border-color: color-mix(in srgb, var(--error) 21%, var(--border)); box-shadow: 0 0 0 9px color-mix(in srgb, var(--error) 5%, transparent); }
.access-summary { margin: 0 0 24px; padding: 15px 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; background: color-mix(in srgb, var(--canvas) 58%, var(--surface)); border: 1px solid var(--border); border-radius: 14px; }
.access-summary div { padding-inline: 7px; display: grid; justify-items: center; gap: 5px; }
.access-summary div + div { border-inline-start: 1px solid var(--border); }
.access-summary svg { width: 20px; height: 20px; color: var(--brand); }
.access-summary span { color: var(--muted); font-size: .65rem; }
.access-summary strong { font-size: .8rem; font-weight: 700; }

.portal-footer { padding: 17px 28px 20px; display: grid; gap: 6px; color: var(--muted); background: color-mix(in srgb, var(--canvas) 43%, var(--surface)); border-top: 1px solid var(--border); text-align: center; font-size: .62rem; line-height: 1.7; }
.portal-footer strong { font-weight: 600; }
.powered-by { margin: 0; color: var(--muted); text-align: center; font-family: "Segoe UI", Tahoma, sans-serif; font-size: .6rem; opacity: .78; }

dialog { width: min(460px, calc(100% - 30px)); max-height: min(680px, calc(100vh - 30px)); padding: 0; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 30px 90px rgba(0, 0, 0, .28); }
dialog::backdrop { background: rgba(18, 12, 28, .7); backdrop-filter: blur(5px); }
.dialog-heading { padding: 21px 22px 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); }
.dialog-heading h2 { margin: 0; font-size: 1.05rem; }
.terms-content { max-height: 390px; padding: 21px 22px; overflow-y: auto; }
.terms-content p { margin: 0 0 15px; color: var(--muted); font-size: .78rem; line-height: 2; white-space: pre-line; }
.terms-content .terms-version { margin: 0; padding-top: 12px; border-top: 1px solid var(--border); }
.terms-content strong { color: var(--text); }
.dialog-action { width: calc(100% - 44px); margin: 0 22px 22px; }
[hidden] { display: none !important; }

@keyframes screen-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .ambient { display: none; }
  .portal-shell { padding: max(8px, env(safe-area-inset-top)) 0 0; display: block; }
  .utility-bar { padding-inline: 17px; }
  .portal-card { min-height: calc(100vh - 64px); min-height: calc(100dvh - 64px); margin: 5px 0 0; border-inline: 0; border-bottom: 0; border-radius: 24px 24px 0 0; box-shadow: 0 -10px 42px var(--shadow); }
  .brand-panel { padding: 19px 22px 18px; }
  .brand-mark[data-presentation="wordmark"] { width: min(100%, 268px); height: 118px; }
  .portal-content { padding: 19px 22px 27px; }
  .environment-note { margin-bottom: 18px; }
  .portal-footer { padding-inline: 22px; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .powered-by { display: none; }
}

@media (max-width: 350px) {
  .portal-content { padding-inline: 17px; }
  .brand-panel { padding-inline: 17px; }
  .brand-mark[data-presentation="wordmark"] { width: 248px; height: 110px; }
  .access-summary { grid-template-columns: 1fr; }
  .access-summary div + div { padding-top: 10px; border-inline-start: 0; border-top: 1px solid var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
