:root {
  --crestline-blue: #1d4ed8;
  --crestline-ink: #0f172a;
  --crestline-muted: #52657d;
  --crestline-line: #bfdbfe;
  --crestline-soft: #eff6ff;
  --crestline-ready: #16a34a;
  --header-height: 76px;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #ffffff;
  color: var(--crestline-ink);
  font-family: Arial, Helvetica, sans-serif;
}

.portal-shell {
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 34rem),
    linear-gradient(135deg, #f8fbff 0%, #eef6ff 48%, #ffffff 100%);
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(16px, 3vw, 34px);
  border-bottom: 1px solid rgba(191, 219, 254, 0.92);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  backdrop-filter: blur(16px);
  z-index: 3;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1d4ed8, #0ea5e9 54%, #4ade80);
  box-shadow: 0 10px 28px rgba(37, 99, 235, 0.28);
  position: relative;
  flex: 0 0 auto;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 10px 7px 12px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  transform: skewX(-18deg);
}

.brand-title { min-width: 0; }

.brand-eyebrow {
  color: var(--crestline-blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-name {
  margin-top: 2px;
  overflow: hidden;
  color: var(--crestline-ink);
  font-size: clamp(17px, 2.2vw, 23px);
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.help-link,
.secure-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 9px 13px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.help-link {
  border: 1px solid rgba(29, 78, 216, 0.24);
  background: #ffffff;
  color: #1e3a8a;
  text-decoration: none;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

.help-link:hover,
.help-link:focus {
  border-color: rgba(29, 78, 216, 0.48);
  background: #eff6ff;
  outline: none;
}

.secure-pill {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.secure-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--crestline-ready);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
}

.portal-frame-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.portal-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

.loading-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 12%, rgba(37, 99, 235, 0.11), transparent 32rem),
    linear-gradient(180deg, rgba(248, 251, 255, 0.98), rgba(255, 255, 255, 0.96));
  z-index: 2;
  transition: opacity 360ms ease, visibility 360ms ease;
}

.loading-panel.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  width: min(720px, 100%);
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(191, 219, 254, 0.96);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.16);
}

.loading-label {
  color: var(--crestline-blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.loading-title {
  margin: 9px 0 0;
  color: var(--crestline-ink);
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.loading-copy {
  max-width: 620px;
  margin: 18px 0 0;
  color: var(--crestline-muted);
  font-size: 16px;
  line-height: 1.55;
}

.loading-steps {
  display: grid;
  gap: 10px;
  margin-top: 22px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
}

.loading-step {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #2563eb;
  box-shadow: 0 0 0 5px rgba(37, 99, 235, 0.10);
}

.loading-step:nth-child(2) .step-dot { background: #0ea5e9; }
.loading-step:nth-child(3) .step-dot { background: #16a34a; }

.loading-bar {
  height: 8px;
  margin-top: 26px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbeafe;
}

.loading-bar-fill {
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #0ea5e9, #16a34a);
  animation: loading-slide 1.8s ease-in-out infinite alternate;
}

.error-box {
  display: none;
  margin-top: 18px;
  padding: 13px 14px;
  border: 1px solid #fecaca;
  border-radius: 14px;
  background: #fef2f2;
  color: #991b1b;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.error-box.is-visible { display: block; }

@keyframes loading-slide {
  from { width: 34%; }
  to { width: 98%; }
}

@media (max-width: 720px) {
  :root { --header-height: 68px; }
  .portal-header { padding: 10px 13px; }
  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 12px;
  }
  .brand-eyebrow { font-size: 9.5px; }
  .brand-name { font-size: 17px; }
  .secure-pill { display: none; }
  .help-link {
    min-height: 34px;
    padding: 8px 11px;
    font-size: 11.5px;
  }
  .loading-card { border-radius: 22px; }
}
