:root {
  --brand: #763790;
  --brand-dark: #5d267a;
  --brand-soft: #f5eff7;
  --ink: #303030;
  --muted: #6d6d6d;
  --line: #dedede;
  --surface: #ffffff;
  --danger: #a62e3b;
  --success: #317814;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #fff; }
body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  color: var(--ink);
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }

.portal-shell {
  width: min(1024px, 100%);
  min-height: 660px;
  display: grid;
  grid-template-columns: 58.3% 41.7%;
  overflow: hidden;
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 4px 24px rgba(0, 0, 0, .18);
}

.brand-visual {
  position: relative;
  min-height: 660px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: #fff;
  background: var(--brand) url("/assets/portal-background.jpg") center / cover no-repeat;
}
.brand-overlay {
  position: absolute;
  inset: 0;
  background: rgba(91, 41, 124, .72);
}
.brand-message { position: relative; z-index: 1; max-width: 480px; text-align: center; }
.brand-message h1 { margin: 0; font-size: 24px; font-weight: 400; line-height: 1.35; }
.brand-message h1 strong { font-weight: 700; }
.brand-message p { margin: 13px 0 0; font-size: 15px; line-height: 1.55; opacity: .92; }
.phase-note {
  position: absolute;
  z-index: 1;
  right: 34px;
  bottom: 28px;
  left: 34px;
  margin: 0;
  padding-top: 15px;
  border-top: 1px solid rgba(255, 255, 255, .38);
  color: rgba(255, 255, 255, .88);
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.auth-card { min-width: 0; display: flex; flex-direction: column; background: #fff; }
.portal-brand { position: relative; padding: 29px 40px 8px; text-align: center; }
.portal-brand img { width: 185px; height: auto; display: block; margin: 0 auto; }
.portal-brand p { margin: -3px 0 0; color: #666; font-size: 16px; }
.environment-badge {
  position: absolute;
  top: 17px;
  right: 17px;
  padding: 4px 7px;
  border: 1px solid #e2d6e6;
  border-radius: 4px;
  color: #8b6997;
  background: #fff;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.tabs { display: grid; grid-template-columns: 1fr 1fr; margin: 6px 40px 0; border-bottom: 1px solid #ededed; }
.tab { position: relative; padding: 12px 6px; border: 0; color: #666; background: transparent; font-size: 13px; }
.tab::after { position: absolute; right: 20%; bottom: -1px; left: 20%; height: 2px; content: ""; background: transparent; }
.tab.is-active { color: var(--brand); font-weight: 600; }
.tab.is-active::after { background: var(--brand); }

.panel { padding: 25px 40px 20px; }
.panel-heading { margin-bottom: 20px; }
.panel-heading.centered { text-align: center; }
.panel-heading h2 { margin: 0 0 8px; color: var(--brand); font-size: 22px; font-weight: 700; line-height: 1.2; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.panel-heading p strong { color: var(--brand); }
.step-label { display: block; margin-bottom: 5px; color: #8a6b96; font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }

form { display: grid; gap: 9px; }
label { margin-top: 5px; color: #333; font-size: 13px; font-weight: 400; }
input:not([type="checkbox"]) {
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid #d9d9d9;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: #767676; }
input:not([type="checkbox"]):hover { border-color: #a66bb9; }
input:not([type="checkbox"]):focus { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(118, 55, 144, .12); }
.label-row { display: flex; align-items: center; justify-content: space-between; margin-top: 5px; }
.label-row label { margin: 0; }
.text-button, .forgot-link { padding: 0; border: 0; color: var(--brand); background: transparent; font-size: 12px; }
.forgot-link { justify-self: center; margin-top: 7px; padding: 6px; text-decoration: underline; }
.field-grid { display: grid; gap: 10px; }
.field-grid > div { display: grid; gap: 9px; }
.two-columns { grid-template-columns: 1fr 1fr; }
.policy-fields { grid-template-columns: .7fr 1.3fr; }
.checkbox-row { display: flex; align-items: flex-start; gap: 9px; margin: 8px 0 2px; color: var(--muted); font-weight: 400; line-height: 1.4; }
.checkbox-row input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--brand); }

.primary-button, .secondary-button { min-height: 40px; margin-top: 10px; padding: 0 16px; border-radius: 8px; font-size: 15px; transition: background .15s ease, border-color .15s ease; }
.primary-button { border: 1px solid var(--brand); color: #fff; background: var(--brand); }
.primary-button:hover { border-color: var(--brand-dark); background: var(--brand-dark); }
.primary-button:disabled { cursor: wait; opacity: .6; }
.secondary-button { width: 100%; border: 1px solid var(--brand); color: var(--brand); background: #fff; }
.secondary-button:hover { background: var(--brand-soft); }
.secondary-button.compact { margin-top: 0; }
.separator { display: flex; align-items: center; gap: 10px; margin: 17px 0 0; color: #666; font-size: 10px; }
.separator::before, .separator::after { height: 1px; flex: 1; content: ""; background: #ededed; }

.message { margin: 16px 40px -8px; padding: 10px 12px; border: 1px solid #e0d3e4; border-radius: 5px; color: var(--brand-dark); background: var(--brand-soft); font-size: 12px; line-height: 1.4; }
.message.is-error { border-color: #e7b7bd; color: var(--danger); background: #fff1f2; }
.message.is-success { border-color: #b9d4ad; color: var(--success); background: #f2faed; }
.verification-mark, .success-mark { width: 52px; height: 52px; margin: 0 auto 17px; display: grid; place-items: center; border-radius: 50%; color: var(--brand); background: var(--brand-soft); font-size: 22px; }
.success-mark { color: var(--success); background: #eef8e9; }
.code-input { text-align: center; font-size: 22px; font-weight: 700; letter-spacing: .4em; font-variant-numeric: tabular-nums; }
.preview-card { margin: 0 0 15px; padding: 15px; border: 1px solid #e5dce8; border-left: 3px solid var(--brand); border-radius: 5px; background: #fcfafc; }
.preview-card span { color: var(--brand); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.preview-card strong { display: block; margin-top: 5px; color: var(--brand-dark); }
.preview-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.policies-list { display: grid; gap: 14px; margin-bottom: 16px; }
.policies-loading, .policies-empty { margin: 0; color: var(--muted); font-size: 13px; text-align: center; }
.policy-card { padding: 15px; border: 1px solid #e5dce8; border-left: 3px solid var(--brand); border-radius: 6px; background: #fcfafc; }
.policy-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.policy-heading strong { color: var(--brand-dark); font-size: 14px; }
.policy-heading span { padding: 3px 7px; border-radius: 999px; color: var(--success); background: #eef8e9; font-size: 10px; font-weight: 700; }
.policy-details { display: grid; gap: 8px; }
.policy-details > div { display: grid; grid-template-columns: 96px 1fr; gap: 8px; font-size: 11px; line-height: 1.35; }
.policy-details span { color: var(--muted); }
.policy-details strong { color: var(--ink); font-weight: 600; }
.policy-download { display: grid; place-items: center; margin-top: 15px; text-decoration: none; }
.card-footer { margin-top: auto; padding: 12px 22px; border-top: 1px solid #eee; color: #666; text-align: center; font-size: 9px; }

:focus-visible { outline: 3px solid #763790; outline-offset: 2px; }
[hidden] { display: none !important; }

@media (max-width: 820px) {
  body { padding: 0; place-items: stretch; }
  .portal-shell { width: 100%; min-height: 100vh; grid-template-columns: 1fr; border-radius: 0; box-shadow: none; }
  .brand-visual { min-height: 220px; padding: 34px 24px 62px; }
  .brand-message h1 { font-size: 22px; }
  .phase-note { right: 22px; bottom: 18px; left: 22px; }
  .auth-card { min-height: calc(100vh - 220px); }
}

@media (max-width: 480px) {
  .brand-visual { min-height: 190px; background-position: 58% center; }
  .brand-message p { display: none; }
  .phase-note { font-size: 9px; }
  .portal-brand { padding: 23px 24px 7px; }
  .portal-brand img { width: 165px; }
  .environment-badge { top: 10px; right: 10px; }
  .tabs { margin-right: 24px; margin-left: 24px; }
  .panel { padding: 24px; }
  .message { margin-right: 24px; margin-left: 24px; }
  .two-columns, .policy-fields { grid-template-columns: 1fr; }
}

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