:root {
  --bg: #142c39;
  --bg-soft: #1d3944;
  --panel: rgba(255, 255, 255, 0.98);
  --panel-alt: #f5f8f8;
  --text: #172b37;
  --muted: #667780;
  --primary: #225b56;
  --primary-dark: #194742;
  --primary-soft: #e8f1ef;
  --border: #dbe4e7;
  --success: #20765d;
  --error: #ad4545;
  --shadow: 0 16px 38px rgba(20, 44, 57, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Manrope", sans-serif;
  color: var(--text);
}

body.login-page {
  min-height: 100vh;
  background: #eef2f3;
}

button,
input,
a {
  font: inherit;
}

svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-shell {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 36px 20px;
}

.background-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.3;
}

.glow-one {
  width: 360px;
  height: 360px;
  background: rgba(34, 91, 86, 0.13);
  top: 8%;
  left: 12%;
}

.glow-two {
  width: 420px;
  height: 420px;
  background: rgba(99, 137, 145, 0.12);
  right: 9%;
  bottom: 11%;
}

.login-card {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  width: min(980px, 100%);
  min-height: 600px;
  background: #fff;
  border: 1px solid #dfe7e9;
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.brand-panel {
  position: relative;
  isolation: isolate;
  padding: 58px 52px;
  overflow: hidden;
  background: #173c43 url("/images/login-video-poster.jpg") center / cover no-repeat;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-video {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: url("/images/login-video-poster.jpg") center / cover no-repeat;
  object-fit: cover;
  object-position: center;
}

.brand-video-overlay {
  position: absolute;
  z-index: 1;
  inset: 0;
  background: linear-gradient(90deg, rgba(15, 39, 44, 0.82), rgba(20, 54, 58, 0.48));
}

.brand-content {
  position: relative;
  z-index: 2;
}

.eyebrow {
  margin: 0 0 18px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.8);
}

.brand-panel h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.06em;
}

.brand-copy {
  margin-top: 18px;
  max-width: 420px;
  font-size: 1.02rem;
  line-height: 1.7;
  color: rgba(246, 249, 249, 0.8);
}

.form-panel {
  padding: 48px 46px;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  font-weight: 800;
  font-size: 1.18rem;
  color: var(--text);
}

.logo-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--primary);
  color: white;
  font-weight: 700;
}

form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

label {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-alt);
  color: var(--text);
  padding: 0 14px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:focus {
  outline: none;
  border-color: rgba(34, 91, 86, 0.65);
  background: white;
  box-shadow: 0 0 0 3px rgba(34, 91, 86, 0.1);
}

.password-input-wrap {
  position: relative;
}

.password-input-wrap input {
  padding-right: 82px;
}

.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 6px 8px;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.link {
  appearance: none;
  display: inline;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font: inherit;
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: inherit;
  cursor: pointer;
}

.link:hover {
  text-decoration: underline;
}

.options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.checkbox-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.checkbox-wrap input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  height: 52px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: none;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--primary-dark);
  box-shadow: none;
}

.primary-btn:active:not(:disabled) {
  transform: translateY(0);
}

.primary-btn:disabled {
  cursor: wait;
  opacity: 0.82;
}

.button-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: white;
  border-radius: 50%;
  animation: button-spinner-rotate 0.7s linear infinite;
}

.button-spinner[hidden] {
  display: none;
}

.access-code-group {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, #f8fbfa, #eef5f2);
}

.access-code-entry {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.access-code-digit {
  width: 100%;
  height: 58px;
  border: 1.5px solid rgba(19, 94, 78, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--primary);
  letter-spacing: 0.08em;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.access-code-digit:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(18, 94, 78, 0.12);
  transform: translateY(-1px);
}

.access-code-help,
.access-code-expiry {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.access-code-expiry {
  color: var(--primary);
  font-weight: 700;
}

.access-code-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.access-code-actions .link {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.82rem;
  cursor: pointer;
}

.access-code-actions .link:disabled {
  cursor: wait;
  opacity: 0.6;
}

@keyframes button-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

.auth-toast {
  position: fixed;
  z-index: 10;
  right: 24px;
  bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(420px, calc(100vw - 32px));
  min-height: 64px;
  padding: 14px 12px 14px 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--error);
  border-radius: 8px;
  background: white;
  box-shadow: 0 12px 32px rgba(20, 44, 57, 0.18);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  animation: toast-enter 0.2s ease-out;
}

.floating-help-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  border: 1px solid rgba(34, 91, 86, 0.18);
  border-radius: 999px;
  background: linear-gradient(135deg, #1d4f51, #2d6f6d);
  color: white;
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 18px 32px rgba(23, 63, 68, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.floating-help-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 38px rgba(23, 63, 68, 0.28);
}

.floating-help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
}

.floating-help-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.auth-toast[hidden] {
  display: none;
}

.confirmation-panel {
  padding: 8px 0 4px;
}

.confirmation-panel[hidden] {
  display: none;
}

.login-card[hidden] {
  display: none;
}

.registration-confirmation-screen {
  width: min(480px, 100%);
  padding: 40px;
  border: 1px solid #dfe7e9;
  border-radius: 14px;
  background: white;
  box-shadow: var(--shadow);
}

.confirmation-icon {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 20px;
  place-items: center;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.confirmation-icon::after {
  width: 12px;
  height: 7px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  content: "";
  transform: translateY(-2px) rotate(-45deg);
}

.confirmation-panel h1 {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 1.6rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.confirmation-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.confirmation-panel strong {
  color: var(--text);
}

.auth-toast.success {
  border-left-color: var(--success);
}

.toast-icon {
  position: relative;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border: 2px solid currentColor;
  border-radius: 50%;
  color: var(--error);
}

.success .toast-icon {
  color: var(--success);
}

.toast-icon::before {
  position: absolute;
  top: 1px;
  left: 6px;
  content: "!";
  font-size: 14px;
  font-weight: 800;
  line-height: 16px;
}

.success .toast-icon::before {
  top: 5px;
  left: 5px;
  width: 8px;
  height: 5px;
  border-bottom: 2px solid currentColor;
  border-left: 2px solid currentColor;
  content: "";
  transform: rotate(-45deg);
}

.toast-dismiss {
  position: relative;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  margin-left: auto;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.toast-dismiss:hover {
  background: var(--panel-alt);
  color: var(--text);
}

.toast-dismiss::before,
.toast-dismiss::after {
  position: absolute;
  top: 13px;
  left: 8px;
  width: 12px;
  height: 2px;
  background: currentColor;
  content: "";
  transform: rotate(45deg);
}

.toast-dismiss::after {
  transform: rotate(-45deg);
}

@keyframes toast-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  .auth-toast {
    right: 16px;
    bottom: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .button-spinner,
  .auth-toast {
    animation-duration: 0.01ms;
    animation-iteration-count: 1;
  }
}

.signup-text {
  margin-top: 18px;
  text-align: center;
  font-size: 0.95rem;
  color: var(--muted);
}

.password-toggle:focus-visible,
.link:focus-visible,
.primary-btn:focus-visible {
  outline: 3px solid rgba(34, 91, 86, 0.25);
  outline-offset: 3px;
}

@media (max-width: 768px) {
  .page-shell {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
  }

  .login-card {
    display: block;
    width: min(440px, 100%);
    min-height: 0;
    overflow: visible;
    border: 0;
    border-radius: 12px;
    background: transparent;
    box-shadow: none;
  }

  .registration-confirmation-screen {
    width: min(440px, 100%);
    padding: 30px 24px;
    border-radius: 12px;
  }

  .brand-panel {
    position: fixed;
    z-index: -1;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding: 0;
    background-position: center;
  }

  .brand-video-overlay {
    background: rgba(15, 39, 44, 0.54);
  }

  .brand-content {
    display: none;
  }

  .form-panel {
    position: relative;
    z-index: 1;
    padding: 30px 24px;
    border: 1px solid rgba(223, 231, 233, 0.9);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 18px 44px rgba(20, 44, 57, 0.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .brand-video {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
