/* Ported from freight2setup src/app/globals.css (portal + splash; lab static page). */
:root {
  --background: #0b1f3a;
  --foreground: #f8fafc;
  --portal-accent: #ea580c;
  --portal-accent-hover: #c2410c;
}

body {
  background: var(--background);
  color: var(--foreground);
  min-height: 100vh;
  font-family: "Segoe UI", "Source Sans 3", system-ui, sans-serif;
  margin: 0;
}

body.portal-session {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

.font-display,
.portal-panel h2,
.portal-cta {
  font-family: Sora, "Segoe UI", system-ui, sans-serif;
}

.portal-shell {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem;
  transition: opacity 0.55s ease;
  box-sizing: border-box;
}

.portal-shell.app-visible {
  opacity: 1;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding: max(0.5rem, env(safe-area-inset-top, 0px)) 1rem
    max(0.5rem, env(safe-area-inset-bottom, 0px));
}

.portal-content--fit {
  max-height: calc(100dvh - 1rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.panel-reveal {
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  transition:
    opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.panel-reveal.panel-reveal-active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.panel-reveal-out {
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  transition:
    opacity 0.28s ease,
    transform 0.32s ease;
}

.portal-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: linear-gradient(165deg, #061222 0%, #0b1f3a 55%, #08162a 100%);
}

.portal-bg img {
  object-fit: cover;
  width: 100%;
  height: 100%;
}

@keyframes portal-bg-drift {
  from { transform: scale(1.08); }
  to { transform: scale(1); }
}

.portal-bg-animate {
  animation: portal-bg-drift 8s ease-out both;
  will-change: transform;
}

@keyframes portal-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes portal-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes portal-scale-in {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes portal-check-pop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  70% { transform: scale(1.08); }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.portal-fade-in {
  animation: portal-fade-in 0.6s ease-out both;
}

.portal-rise {
  animation: portal-rise 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.portal-scale-in {
  animation: portal-scale-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.portal-stagger-1 {
  animation: portal-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.05s both;
}

.portal-stagger-2 {
  animation: portal-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both;
}

.portal-stagger-3 {
  animation: portal-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.24s both;
}

.portal-stagger-4 {
  animation: portal-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) 0.34s both;
}

.portal-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom right,
    rgba(6, 18, 34, 0.78) 0%,
    rgba(11, 31, 58, 0.55) 45%,
    rgba(15, 23, 42, 0.4) 100%
  );
}

.portal-content {
  position: relative;
  z-index: 10;
  width: min(42rem, calc(100vw - 2rem));
  max-width: 42rem;
  margin: 0 auto;
}

.portal-content.portal-content--search {
  width: min(46rem, calc(100vw - 2rem));
  max-width: 46rem;
}

#phaseSearch.portal-panel {
  width: 100%;
}

.portal-panel {
  position: relative;
  isolation: isolate;
  background: linear-gradient(
    145deg,
    rgba(15, 36, 66, 0.94) 0%,
    rgba(11, 31, 58, 0.9) 55%,
    rgba(8, 22, 42, 0.92) 100%
  );
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  box-shadow:
    0 0 0 1px rgba(11, 31, 58, 0.65),
    0 32px 64px rgba(0, 0, 0, 0.55),
    0 2px 0 rgba(255, 255, 255, 0.06) inset;
}

.portal-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(234, 88, 12, 0.12) 0%, transparent 45%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 18%);
  pointer-events: none;
  z-index: 0;
  border-radius: inherit;
}

.portal-panel-inner {
  position: relative;
  z-index: 1;
}

.portal-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.875rem 1rem 0.875rem 2.75rem;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid transparent;
  border-radius: 2px;
  color: #0b1f3a;
  font-size: 1rem;
}

.portal-input:focus {
  outline: none;
  border-color: #ea580c;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.28);
}

.portal-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: rgba(253, 186, 116, 0.9);
  margin-bottom: 0.5rem;
}

.portal-cta {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  background: #ea580c;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(194, 65, 12, 0.35);
}

.portal-cta:hover:not(:disabled) {
  background: #c2410c;
}

.portal-cta:disabled {
  background: #64748b;
  opacity: 1;
  cursor: not-allowed;
  box-shadow: none;
}

.portal-cta.is-loading {
  opacity: 1;
  pointer-events: none;
  gap: 0.65rem;
}

.btn-spinner {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.portal-search-progress {
  position: relative;
  overflow: hidden;
  height: 2px;
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 1px;
  margin-bottom: 1rem;
}

.portal-search-progress::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 42%;
  margin-left: -21%;
  background: linear-gradient(90deg, transparent, #ea580c, #fdba74, transparent);
  animation: portal-progress 1.1s ease-in-out infinite;
}

@keyframes portal-progress {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(130%); }
}

.portal-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: rgba(148, 163, 184, 0.75);
  margin-bottom: 0.8rem;
  line-height: 1.4;
}

.portal-search-steps {
  margin-top: 1.35rem;
  padding: 0.5rem 0 0.25rem;
}

.portal-step.is-active {
  color: #fdba74;
  animation: portal-step-pulse 2.1s ease-in-out infinite;
}

.portal-step.is-done {
  color: #86efac;
  animation: none;
}

.portal-step.is-done .portal-step-dot {
  animation: portal-check-pop 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes portal-step-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.portal-step-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  background: currentColor;
  flex-shrink: 0;
}

.portal-splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(90% 70% at 50% 40%, rgba(234, 88, 12, 0.12) 0%, transparent 55%),
    linear-gradient(165deg, #061222 0%, #0b1f3a 55%, #08162a 100%);
  opacity: 1;
  transition: opacity 0.45s ease;
}

.portal-splash.is-exiting {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.portal-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 2rem 1.5rem;
  animation: portal-splash-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.portal-splash-spacer {
  display: block;
  flex: 0 0 1.375rem;
  width: 100%;
  max-width: 1px;
  min-height: 1.375rem;
}

.portal-splash-spacer--caption {
  flex-basis: 1.125rem;
  min-height: 1.125rem;
}

.portal-splash-logo {
  animation: portal-splash-logo 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.08s both;
  margin: 0;
  line-height: 0;
}

.portal-logo-svg {
  display: block;
  width: min(90vw, 340px);
  height: 44px;
  margin: 0 auto;
}


@keyframes portal-splash-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes portal-splash-logo {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.portal-splash-bar {
  position: relative;
  width: min(220px, 55vw);
  height: 2px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  flex-shrink: 0;
  margin: 0 auto;
}

.portal-splash-bar-fill {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  transform-origin: center center;
  background: linear-gradient(90deg, #c2410c, #ea580c, #fdba74);
  animation: portal-splash-fill 2s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes portal-splash-fill {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.portal-splash-caption {
  margin: 0;
  padding: 0 1rem;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.9);
  text-align: center;
  animation: portal-fade-in 0.5s ease 0.25s both;
}

.hidden { display: none !important; }

.sr-cache {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  overflow: hidden;
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.meta-grid p.label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #64748b;
  margin: 0 0 0.25rem;
}

.meta-grid p.value {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.stats-row .rate { color: #fdba74; font-weight: 600; }

.panel-pad { padding: 2rem 2.5rem; }

#phaseSearch .panel-pad {
  padding: 2rem 2.25rem 1.75rem;
}

.portal-panel--combined {
  width: 100%;
  max-height: calc(100dvh - 1rem);
}

#phaseAccess.portal-panel--combined .panel-pad-compact {
  padding: 1.5rem 2rem 1.25rem;
}

.panel-pad-compact {
  padding: 1rem 1.25rem 0.85rem;
}

.portal-combined-layout {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.portal-combined-top {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  width: 100%;
  min-height: 0;
  margin: 0 0 -0.15rem;
}

#phaseAccess .portal-combined-top .portal-link-back {
  margin: 0;
  padding: 0.15rem 0.35rem 0.15rem 0;
}

.portal-combined-logo {
  text-align: center;
}

.portal-combined-logo .portal-logo-svg {
  display: block;
  width: 100%;
  max-width: 17rem;
  height: auto;
  margin: 0 auto;
}

.load-summary {
  padding: 1rem 1.1rem;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 2px;
}

.load-route {
  margin: 0 0 0.75rem;
  font-size: 1.0625rem;
  font-weight: 600;
  color: #e2e8f0;
  line-height: 1.35;
}

.access-gate {
  margin: 0;
}

.doc-action {
  margin: 0;
}

.portal-input--plain {
  padding-left: 1rem;
}

.hint-tight {
  margin-top: 0.35rem;
}

.access-verify-panel {
  margin-top: 0.85rem;
  padding: 0.15rem 0 0.1rem;
}

.access-verify-bar {
  position: relative;
  overflow: hidden;
  height: 4px;
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-bottom: 0.7rem;
}

.access-verify-bar-fill {
  display: block;
  height: 100%;
  width: 42%;
  background: linear-gradient(90deg, transparent, #ea580c 35%, #fdba74 65%, transparent);
  border-radius: 2px;
  animation: access-verify-slide 1.15s ease-in-out infinite;
}

@keyframes access-verify-slide {
  0% { transform: translateX(-130%); }
  100% { transform: translateX(330%); }
}

.access-verify-status {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #fdba74;
  text-align: center;
  letter-spacing: 0.02em;
  transition: opacity 0.25s ease;
}

#accessCode.is-verifying {
  border-color: rgba(234, 88, 12, 0.55);
  box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.22);
  animation: access-input-glow 1.8s ease-in-out infinite;
}

@keyframes access-input-glow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(234, 88, 12, 0.18); }
  50% { box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.38); }
}

.portal-access-actions {
  margin-top: 0.65rem;
}

.portal-access-actions .portal-cta {
  width: 100%;
  margin-top: 0;
  padding: 0.72rem 0.85rem;
  font-size: 0.9375rem;
}

.portal-link-back {
  flex: 0 0 auto;
  background: none;
  border: none;
  color: #94a3b8;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.45rem 0.35rem;
  white-space: nowrap;
}

.portal-link-back:hover {
  color: #fdba74;
}

.load-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.65rem;
  margin-bottom: 0.4rem;
}

.load-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-family: Sora, "Segoe UI", sans-serif;
  color: #fff;
  font-weight: 600;
}

.load-head .badge-available {
  margin: 0;
}

.stats-row-compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem 0.75rem;
  padding: 0;
  margin-bottom: 0;
  background: none;
  border: none;
  font-size: 0.875rem;
}

.stats-row-compact p.label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
  margin: 0 0 0.2rem;
}

.stats-row-compact p.value {
  font-size: 0.9375rem;
  line-height: 1.3;
}

#phaseAccess .portal-input--plain {
  padding: 0.95rem 1.1rem;
  font-size: 1.0625rem;
}

#phaseAccess .portal-access-actions .portal-cta,
#phaseAccess .portal-cta-compact {
  padding: 0.9rem 1rem;
  font-size: 1rem;
}

.portal-cta-compact {
  padding: 0.72rem 0.85rem;
  font-size: 0.9375rem;
}

.doc-expiry-hint {
  text-align: center;
  margin-top: 0.4rem;
  margin-bottom: 0;
  font-size: 0.6875rem;
}

.footer-note-compact {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  font-size: 10px;
}

@media (max-width: 520px) {
  .stats-row-compact {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-height: 720px) {
  .panel-pad-compact {
    padding: 0.75rem 1rem 0.65rem;
  }

  .portal-combined-layout {
    gap: 0.5rem;
  }

  .portal-combined-logo .portal-logo-svg {
    max-width: 11.5rem;
  }

  .load-summary {
    padding: 0.5rem 0.55rem;
  }

  .portal-step {
    margin-bottom: 0.35rem;
    font-size: 0.75rem;
  }

  .doc-expiry-hint {
    display: none;
  }
}

.badge-available {
  color: #34d399;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.input-wrap {
  position: relative;
  border-radius: 2px;
  overflow: hidden;
}

.input-wrap .icon {
  position: absolute;
  left: 0.875rem;
  top: 0;
  bottom: 0;
  margin: auto 0;
  width: 1rem;
  height: 1rem;
  opacity: 0.5;
  pointer-events: none;
}

.input-wrap.is-searching .icon {
  opacity: 0.85;
  color: #ea580c;
}

.portal-input-load-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: rgba(234, 88, 12, 0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.input-wrap.is-searching .portal-input-load-line {
  opacity: 1;
}

.portal-input-load-line::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 38%;
  left: 50%;
  margin-left: -19%;
  background: linear-gradient(90deg, transparent, #ea580c, #fdba74, transparent);
  animation: portal-input-shimmer 1.1s ease-in-out infinite;
}

@keyframes portal-input-shimmer {
  0% { transform: translateX(-140%); }
  100% { transform: translateX(140%); }
}

.hint { font-size: 0.75rem; color: #94a3b8; margin-top: 0.5rem; }

.footer-note {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  font-size: 11px;
  color: #64748b;
}

@media (prefers-reduced-motion: reduce) {
  .flow-overlay,
  .overlay-dialog,
  .panel-reveal,
  .portal-shell,
  .portal-splash,
  .portal-fade-in,
  .portal-rise,
  .portal-scale-in,
  .portal-stagger-1,
  .portal-stagger-2,
  .portal-stagger-3,
  .portal-stagger-4,
  .portal-bg-animate,
  .portal-search-progress::after,
  .portal-input-load-line::after,
  .portal-step.is-active,
  .portal-step.is-done .portal-step-dot,
  .portal-splash-inner,
  .portal-splash-logo,
  .portal-splash-bar-fill,
  .portal-splash-caption {
    transition: none !important;
    animation: none !important;
  }
  .panel-reveal,
  .overlay-dialog {
    opacity: 1;
    transform: none;
  }
}
