body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gray-bg);
}

.gate-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  min-height: calc(100vh - 56px);
}

/* Left panel */
.gate-hero {
  background: var(--navy-dark);
  padding: clamp(56px, 5.5vw, 84px) clamp(36px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.gate-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image:
    radial-gradient(
      ellipse 88% 72% at -2% 10%,
      rgba(4, 8, 24, 0.97) 0%,
      rgba(8, 13, 35, 0.9) 44%,
      rgba(8, 13, 35, 0.4) 67%,
      transparent 84%
    ),
    radial-gradient(
      ellipse 78% 58% at -2% 104%,
      rgba(4, 8, 24, 0.98) 0%,
      rgba(8, 13, 35, 0.9) 45%,
      rgba(8, 13, 35, 0.4) 70%,
      transparent 88%
    );
  pointer-events: none;
}

.gate-hero-video {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.gate-hero-copy,
.hero-stats {
  position: relative;
  z-index: 2;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
}

.gate-hero-copy {
  max-width: 680px;
  overflow-wrap: anywhere;
}

.hero-logo {
  display: block;
  width: clamp(230px, 30vw, 360px);
  max-width: 100%;
  height: auto;
  margin-bottom: clamp(28px, 3vw, 42px);
  filter: drop-shadow(0 2px 18px rgba(0, 0, 0, 0.22));
}

.hero-title {
  font-size: clamp(2.75rem, 4.25vw, 4.25rem);
  font-weight: 700;
  color: var(--white);
  line-height: 1.02;
  letter-spacing: -0.05em;
  margin-bottom: 24px;
}

.hero-title span {
  color: var(--crimson);
  font-weight: 800;
}

.hero-desc {
  font-size: clamp(0.98rem, 1.15vw, 1.08rem);
  color: rgba(255, 255, 255, 0.92);
  max-width: 560px;
  line-height: 1.65;
}

.hero-window-note {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  background: rgba(8, 13, 35, 0.52);
  box-shadow: 0 8px 24px rgba(4, 8, 24, 0.24);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--white);
  font-size: clamp(0.9rem, 1vw, 0.98rem);
  font-weight: 600;
  text-shadow: none;
}

.hero-window-icon {
  flex: 0 0 auto;
  color: rgba(255, 255, 255, 0.86);
}

.hero-stats {
  --hero-stat-accent: var(--color-secondary-300);
  display: inline-flex;
  align-self: flex-start;
  position: relative;
  width: min(100%, 262px);
  min-width: 238px;
  margin-top: 56px;
  padding: 14px 18px 15px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  background: rgba(8, 13, 35, 0.52);
  box-shadow: 0 8px 24px rgba(4, 8, 24, 0.24);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-shadow: none;
}

.hero-stats > div {
  position: relative;
  z-index: 1;
  width: 100%;
}

.hero-stat-telemetry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.58);
  font-family: var(--font-mono);
  font-size: 0.53rem;
  font-weight: 500;
  letter-spacing: 0.105em;
  line-height: 1;
  white-space: nowrap;
}

.hero-stat-mode {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: rgba(255, 255, 255, 0.62);
}

.hero-stat-signal {
  width: 6px;
  height: 6px;
  border-radius: 1px;
  background: currentColor;
}

.hero-stats.is-loading .hero-stat-mode {
  color: var(--color-secondary-200);
}

.hero-stats.is-loading .hero-stat-signal {
  background: var(--hero-stat-accent);
  box-shadow: 0 0 6px rgba(194, 120, 122, 0.55);
  animation: hero-signal-pulse 1.2s ease-in-out infinite;
}

.hero-stats.is-error .hero-stat-mode {
  color: #ff8c88;
}

.hero-stats.is-error .hero-stat-signal {
  background: #ff5752;
  box-shadow: 0 0 8px rgba(255, 87, 82, 0.65);
}

.hero-stat-val {
  min-height: 1em;
  font-family: var(--font-mono);
  font-size: 1.95rem;
  font-weight: 500;
  color: var(--white);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.055em;
  line-height: 1;
}

.hero-stat-visual {
  display: inline-block;
  min-width: 7ch;
  transform-origin: left center;
  transition:
    opacity 180ms ease,
    filter 180ms ease;
}

.hero-stat-loader {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 1em;
  height: 1em;
}

.hero-stat-spinner {
  position: relative;
  width: 0.78em;
  height: 0.78em;
  border: 2px solid transparent;
  border-top-color: rgba(255, 255, 255, 0.86);
  border-right-color: rgba(255, 255, 255, 0.86);
  border-radius: 50%;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.24));
  animation: hero-stat-spin 780ms linear infinite;
}

.hero-stat-val.is-ready .hero-stat-visual {
  animation: hero-number-settle 480ms cubic-bezier(0.22, 1, 0.36, 1);
}

.hero-stat-lbl {
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.72);
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

@keyframes hero-stat-spin {
  to {
    transform: rotate(1turn);
  }
}

@keyframes hero-signal-pulse {
  50% {
    opacity: 0.32;
  }
}

@keyframes hero-number-settle {
  0% {
    opacity: 0;
    filter: blur(3px);
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
  }
}

/* Right panel */
.gate-panel {
  --sidebar-gutter: 28px;
  --sidebar-stack-gap: 14px;
  align-self: start;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  height: calc(100dvh - 56px);
  min-height: 0;
  background: var(--gray-bg);
  display: flex;
  flex-direction: column;
  border-left: 1px solid rgba(38, 47, 104, 0.12);
  box-shadow: -14px 0 36px rgba(8, 13, 35, 0.08);
}

.gate-panel-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sidebar-stack-gap);
  padding: 32px var(--sidebar-gutter) 28px;
  overflow-y: auto;
}

.gate-panel-subtitle {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* Field panels */
.field-panel {
  display: none;
}
.field-panel.visible {
  display: block;
  padding: 18px;
  border: 1px solid rgba(38, 47, 104, 0.1);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 6px 20px rgba(38, 47, 104, 0.06);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.field-panel.visible:hover {
  border-color: rgba(38, 47, 104, 0.18);
  box-shadow: 0 10px 24px rgba(38, 47, 104, 0.08);
}

.gate-panel .form-group {
  gap: 8px;
}

#panelDept .form-group + .form-group {
  margin-top: 22px;
}

.gate-panel .form-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.075em;
  color: var(--text-soft);
}

.gate-panel .form-control {
  min-width: 0;
  height: 44px;
  padding: 0 13px;
  border: 1px solid var(--border-input);
  border-radius: 9px;
  background: var(--surface-panel);
  box-shadow: 0 1px 2px rgba(8, 13, 35, 0.03);
}

.gate-panel .form-control:hover {
  border-color: var(--border-input-hover);
}

.gate-panel .form-control:focus {
  border-color: var(--navy-light);
  background-color: var(--white);
  box-shadow: 0 0 0 3px rgba(38, 47, 104, 0.12);
}

.gate-panel select.form-control {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 48px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m3 6 5 5 5-5' stroke='%23262f68' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 20px center;
  background-size: 16px;
}

.field-help {
  font-size: 0.72rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.department-picker-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 7px 2px 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.department-picker-status[hidden] {
  display: none;
}

.department-picker-status-spinner {
  display: none;
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border: 2px solid rgba(38, 47, 104, 0.2);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.department-picker-status.is-loading .department-picker-status-spinner {
  display: block;
}

/* Date section */
.date-section {
  padding: 18px;
  border: 1px solid rgba(38, 47, 104, 0.1);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 6px 20px rgba(38, 47, 104, 0.06);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.date-section:hover {
  border-color: rgba(38, 47, 104, 0.18);
  box-shadow: 0 10px 24px rgba(38, 47, 104, 0.08);
}

.date-presets {
  gap: 7px;
}

.gate-panel .preset-chip {
  min-height: 32px;
  padding: 6px 11px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--surface-chip);
  color: var(--text-soft);
  font-size: 0.75rem;
  font-weight: 600;
}

.gate-panel .preset-chip:hover {
  border-color: rgba(38, 47, 104, 0.42);
  background: rgba(38, 47, 104, 0.05);
  color: var(--navy);
}

.gate-panel .preset-chip:active:not(:disabled) {
  background: rgba(38, 47, 104, 0.1);
}

.gate-panel .preset-chip.active {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
  box-shadow: 0 3px 9px rgba(38, 47, 104, 0.18);
}

.date-inputs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.date-inputs[hidden] {
  display: none;
}

.gate-actions {
  flex-shrink: 0;
  padding: 20px var(--sidebar-gutter) 24px;
  border-top: 1px solid rgba(38, 47, 104, 0.1);
  background: var(--surface-overlay);
  box-shadow: 0 -10px 28px rgba(38, 47, 104, 0.06);
  display: flex;
  flex-direction: column;
  gap: var(--sidebar-stack-gap);
}

.btn-explore {
  width: 100%;
  min-height: 48px;
  justify-content: center;
  padding: 13px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 700;
  white-space: normal;
  text-align: center;
  box-shadow: 0 8px 18px rgba(154, 30, 34, 0.2);
}

.btn-explore:hover {
  box-shadow: 0 10px 22px rgba(154, 30, 34, 0.27);
}

.compare-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--white);
  color: var(--navy);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color var(--transition),
    background var(--transition),
    box-shadow var(--transition);
  text-decoration: none;
  text-align: center;
}

.gate-actions svg {
  flex-shrink: 0;
}

.compare-link:hover {
  border-color: rgba(38, 47, 104, 0.4);
  background: rgba(38, 47, 104, 0.035);
  box-shadow: 0 4px 12px rgba(38, 47, 104, 0.07);
}

.compare-link:active {
  transform: translateY(0);
}

.compare-link:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(58, 74, 138, 0.28),
    0 4px 12px rgba(38, 47, 104, 0.07);
}

.preset-chip:focus-visible {
  outline: 3px solid rgba(58, 74, 138, 0.28);
  outline-offset: 2px;
}

.error-msg {
  padding: 10px 12px;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 9px;
  font-size: 0.78rem;
  color: var(--error-text);
  display: none;
}

.error-msg.visible {
  display: block;
}

@media (max-height: 600px) {
  .gate-actions {
    padding: 12px var(--sidebar-gutter);
    gap: 10px;
  }
}

@media (max-width: 900px) {
  html {
    scroll-padding-top: 72px;
    scroll-padding-bottom: calc(var(--gate-actions-height, 160px) + 16px);
  }
  .gate-layout {
    grid-template-columns: minmax(0, 1fr);
    /* Keep the final fields clear of the mobile action bar. */
    padding-bottom: var(--gate-actions-height, 160px);
  }
  .gate-hero {
    padding: 48px 32px;
    min-height: 520px;
  }
  .hero-title {
    font-size: clamp(2.35rem, 8vw, 3.25rem);
  }
  .hero-logo {
    width: min(300px, 78vw);
    margin-bottom: 30px;
  }
  .gate-panel {
    --sidebar-gutter: 20px;
    position: static;
    height: auto;
    border-left: none;
    border-top: 1px solid rgba(38, 47, 104, 0.12);
    box-shadow: none;
  }
  .gate-panel-inner {
    padding: 28px var(--sidebar-gutter) 24px;
    overflow: visible;
  }
  .gate-actions {
    position: fixed;
    inset: auto 0 0;
    z-index: 90;
    padding: 12px var(--sidebar-gutter) calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
    background: var(--gray-bg);
  }
}

@media (max-width: 480px) {
  .date-inputs {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .preset-chip,
  .btn,
  .compare-link {
    transition: none;
  }

  .gate-hero-video {
    display: none;
  }

  .department-picker-status-spinner {
    animation: none;
  }

  .hero-stats.is-loading .hero-stat-signal,
  .hero-stat-spinner,
  .hero-stat-val.is-ready .hero-stat-visual {
    animation: none;
  }

  .gate-hero {
    background:
      radial-gradient(
        ellipse 88% 72% at -2% 10%,
        rgba(4, 8, 24, 0.97) 0%,
        rgba(8, 13, 35, 0.9) 44%,
        rgba(8, 13, 35, 0.4) 67%,
        transparent 84%
      ),
      radial-gradient(
        ellipse 78% 58% at -2% 104%,
        rgba(4, 8, 24, 0.98) 0%,
        rgba(8, 13, 35, 0.9) 45%,
        rgba(8, 13, 35, 0.4) 70%,
        transparent 88%
      ),
      url("https://res.cloudinary.com/neris/image/upload/f_auto,q_auto:eco,w_1280/v1785450211/poster_grkjob.png")
        center / cover no-repeat #05091c;
  }

  .gate-hero::before {
    content: none;
  }
}
