/* Matches layout.php / dashboard design tokens */
:root {
  --bg: #f9fbf9;
  --surface: rgba(255, 255, 255, 0.92);
  --text: #0b1220;
  --muted: rgba(11, 18, 32, 0.62);
  --brand: #1b4332;
  --brand-700: #05261e;
  --accent: #14b07a;
  --accent-2: #31c793;
  --ring: rgba(20, 176, 122, 0.26);
  --border: rgba(11, 18, 32, 0.1);
  --shadow-soft: 0 16px 40px rgba(2, 6, 23, 0.08);
  --panel-bg: #ffffff;
  --field-bg: rgba(255, 255, 255, 0.86);
  --btn-from: rgba(20, 176, 122, 0.98);
  --btn-to: rgba(11, 47, 36, 0.96);
  --btn-glow: rgba(20, 176, 122, 0.22);
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(900px 540px at 12% 8%, rgba(20, 176, 122, 0.1), transparent 60%),
    radial-gradient(860px 520px at 88% 18%, rgba(49, 199, 147, 0.08), transparent 62%),
    radial-gradient(860px 520px at 22% 92%, rgba(11, 59, 46, 0.06), transparent 60%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before,
body::after {
  display: none;
}

/* Ambient page atmosphere — subtle when full video is active */
body.login-page .login-ambient {
  display: none;
}

.login-ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: orbDrift 18s ease-in-out infinite;
}

.login-orb--1 {
  width: 320px;
  height: 320px;
  top: 8%;
  left: 5%;
  background: rgba(49, 199, 147, 0.35);
}

.login-orb--2 {
  width: 280px;
  height: 280px;
  bottom: 10%;
  right: 8%;
  background: rgba(20, 176, 122, 0.25);
  animation-delay: -6s;
  animation-duration: 22s;
}

.login-orb--3 {
  width: 200px;
  height: 200px;
  top: 45%;
  right: 22%;
  background: rgba(27, 67, 50, 0.15);
  animation-delay: -12s;
  animation-duration: 20s;
}

@keyframes orbDrift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(24px, -18px) scale(1.05); }
  66% { transform: translate(-16px, 22px) scale(0.96); }
}

body.is-embed { background: transparent; }
body.is-embed::before,
body.is-embed::after { display: none; }

body.login-page {
  background: #0a1210;
}

body.is-embed .login-ambient { display: none; }
body.is-embed .login-backdrop { display: none; }
body.is-embed .login-page-bg { display: none; }
body.is-embed .login-stage { width: 100%; }

body.is-embed .login-app {
  min-height: 100%;
  padding: 0;
}

body.is-embed .login-shell {
  width: 100%;
  min-height: 100%;
  max-height: none;
  border-radius: 20px;
}

/* Full-viewport video background */
.login-page-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.login-page-bg video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}

.login-page-bg-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 85% 75% at 50% 45%, rgba(249, 251, 249, 0.06) 0%, rgba(27, 67, 50, 0.28) 100%),
    linear-gradient(180deg, rgba(249, 251, 249, 0.1) 0%, rgba(11, 18, 32, 0.06) 100%);
}

.login-app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  position: relative;
  z-index: 1;
}

/* Decorative frame behind the login card */
.login-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(1100px, 92vw);
}

.login-backdrop {
  position: absolute;
  inset: -56px -64px;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: 36px;
}

.login-backdrop-grid {
  position: absolute;
  inset: 0;
  z-index: 2;
  background-image:
    linear-gradient(rgba(20, 176, 122, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 176, 122, 0.07) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse 85% 75% at 50% 50%, #000 20%, transparent 72%);
  opacity: 0.85;
}

.login-backdrop-dots {
  position: absolute;
  inset: 0;
  z-index: 2;
  background-image: radial-gradient(rgba(27, 67, 50, 0.12) 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 50%, #000 10%, transparent 70%);
}

.login-backdrop-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: min(1100px, 98%);
  height: min(760px, 92%);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(20, 176, 122, 0.18);
  box-shadow:
    0 0 0 24px rgba(20, 176, 122, 0.04),
    0 0 0 48px rgba(20, 176, 122, 0.025),
    inset 0 0 80px rgba(49, 199, 147, 0.06);
  animation: ringPulse 8s ease-in-out infinite;
}

@keyframes ringPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.9; }
  50% { transform: translate(-50%, -50%) scale(1.02); opacity: 1; }
}

.login-watermark {
  position: absolute;
  z-index: 2;
  font-family: var(--serif);
  font-weight: 700;
  line-height: 1;
  color: rgba(27, 67, 50, 0.06);
  user-select: none;
  pointer-events: none;
}

.login-watermark--1 {
  font-size: clamp(180px, 28vw, 280px);
  top: -10%;
  left: -6%;
  transform: rotate(-12deg);
}

.login-watermark--2 {
  font-size: clamp(150px, 24vw, 240px);
  bottom: -8%;
  right: -4%;
  transform: rotate(8deg);
  color: rgba(20, 176, 122, 0.08);
}

.login-watermark--3 {
  font-size: clamp(130px, 20vw, 200px);
  top: 36%;
  right: 4%;
  transform: rotate(-6deg);
  color: rgba(11, 59, 46, 0.06);
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(1000px, 68vw);
  min-height: min(62vh, 640px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  background: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow:
    0 0 0 1px var(--border),
    0 28px 70px rgba(2, 6, 23, 0.1),
    var(--shadow-soft);
  animation:
    shellIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards,
    cardFloat 7s ease-in-out 1.1s infinite;
  will-change: transform;
  transform-style: preserve-3d;
}

.login-shell-glow {
  position: absolute;
  inset: -4px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent), var(--accent-2));
  opacity: 0.35;
  filter: blur(14px);
  z-index: -1;
  animation: glowPulse 5s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.28; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.02); }
}

@keyframes shellIn {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* Left: library showcase */
.login-welcome {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 28px;
  min-height: 240px;
  flex: 1 1 auto;
  overflow: hidden;
}

.login-welcome-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 90% 70% at 50% 20%, rgba(49, 199, 147, 0.22) 0%, transparent 58%),
    linear-gradient(160deg, var(--brand-700) 0%, #0a2e24 48%, var(--brand) 100%);
}

.login-light-beam {
  position: absolute;
  top: -5%;
  left: 50%;
  width: 42%;
  height: 75%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(49, 199, 147, 0.45) 0%, rgba(255, 255, 255, 0.08) 40%, transparent 100%);
  filter: blur(18px);
  z-index: 1;
  pointer-events: none;
  animation: beamPulse 6s ease-in-out infinite;
}

@keyframes beamPulse {
  0%, 100% { opacity: 0.65; }
  50% { opacity: 1; }
}

.login-particles {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.login-particle {
  position: absolute;
  left: var(--x);
  top: var(--y);
  font-family: var(--serif);
  font-size: clamp(22px, 3.5vw, 38px);
  font-weight: 600;
  color: rgba(236, 253, 245, 0.22);
  text-shadow: 0 0 20px rgba(49, 199, 147, 0.35);
  animation: particleFloat var(--dur, 14s) ease-in-out var(--d, 0s) infinite;
}

.login-particle--dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(49, 199, 147, 0.5);
  box-shadow: 0 0 12px rgba(49, 199, 147, 0.6);
  font-size: 0;
}

@keyframes particleFloat {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.15;
  }
  50% {
    transform: translateY(-28px) rotate(8deg);
    opacity: 0.45;
  }
}

.login-welcome-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse 80% 55% at 50% 18%, rgba(20, 176, 122, 0.35) 0%, transparent 58%),
    radial-gradient(ellipse 100% 100% at 50% 50%, transparent 25%, rgba(5, 38, 30, 0.55) 100%),
    linear-gradient(180deg, rgba(27, 67, 50, 0.45) 0%, rgba(5, 38, 30, 0.88) 100%);
}

.login-welcome::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 55%;
  height: 65%;
  background: radial-gradient(ellipse at 50% 0%, rgba(49, 199, 147, 0.28) 0%, transparent 70%);
  z-index: 1;
  pointer-events: none;
}

.login-welcome-inner {
  position: relative;
  z-index: 2;
  max-width: 100%;
  text-align: center;
  color: #ecfdf5;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-emblem {
  position: relative;
  width: clamp(160px, 22vw, 220px);
  height: clamp(160px, 22vw, 220px);
  margin: 0 auto 28px;
  border-radius: 50%;
  padding: 6px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(49, 199, 147, 0.5), rgba(20, 176, 122, 0.35));
  border: 2px solid rgba(49, 199, 147, 0.45);
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.15),
    0 0 36px rgba(20, 176, 122, 0.45),
    0 20px 48px rgba(0, 0, 0, 0.35);
  animation: emblemFloat 5s ease-in-out 1.1s infinite;
}

.login-emblem::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px dashed rgba(49, 199, 147, 0.35);
  animation: ringSpin 24s linear infinite;
  pointer-events: none;
}

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

.login-emblem img {
  display: block;
  width: 100%;
  height: 100%;
  margin: auto;
  border-radius: 50%;
  object-fit: contain;
  object-position: center center;
  background: transparent;
}

@keyframes emblemFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.login-welcome-title {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: clamp(2.1rem, 4.5vw, 3.1rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: #ecfdf5;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.35);
}

.login-welcome-title em {
  font-style: italic;
  background: linear-gradient(120deg, #ecfdf5 0%, var(--accent-2) 40%, var(--accent) 70%, #ecfdf5 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(49, 199, 147, 0.4));
  animation: titleShine 6s ease-in-out infinite;
}

@keyframes titleShine {
  0%, 100% { background-position: 0% center; }
  50% { background-position: 100% center; }
}

.login-reveal {
  opacity: 0;
  transform: translateY(18px);
  animation: revealUp 0.75s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.login-reveal--1 { animation-delay: 0.15s; }
.login-reveal--2 { animation-delay: 0.25s; }
.login-reveal--3 { animation-delay: 0.35s; }
.login-reveal--4 { animation-delay: 0.2s; }
.login-reveal--5 { animation-delay: 0.35s; }

.login-emblem.login-reveal {
  animation:
    revealFade 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.05s forwards,
    emblemFloat 5s ease-in-out 1.1s infinite;
}

@keyframes revealFade {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes revealUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.login-welcome-text {
  margin: 0 auto 24px;
  font-size: 14px;
  line-height: 1.75;
  color: rgba(236, 253, 245, 0.9);
  font-weight: 500;
  max-width: 34ch;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

.login-trust-badge {
  display: inline-flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  padding: 14px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(49, 199, 147, 0.35);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}

.login-trust-ic {
  color: var(--accent-2);
  flex-shrink: 0;
  margin-top: 2px;
}

.login-trust-badge strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 3px;
  color: #ecfdf5;
}

.login-trust-badge span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.88);
  font-weight: 500;
  line-height: 1.45;
}

.login-curve { display: none !important; }

/* Right: form panel */
.login-panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  padding: 32px 40px 28px;
  flex: 1 1 auto;
  overflow-y: auto;
}

.login-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--accent) 50%, var(--accent-2) 100%);
  background-size: 200% 100%;
  animation: barSlide 8s ease-in-out infinite;
}

.login-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(20, 176, 122, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

.login-panel-top,
.login-panel-body {
  position: relative;
  z-index: 1;
}

@keyframes barSlide {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.login-panel-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 4px;
}

.login-back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-family: var(--sans);
  transition: color 0.2s, background 0.2s;
}

.login-back-link svg {
  flex-shrink: 0;
  transition: transform 0.2s;
}

.login-back-link:hover {
  color: var(--brand);
  background: rgba(20, 176, 122, 0.1);
}

.login-back-link:hover svg {
  transform: translateX(-3px);
}

.help-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 10px;
  font-family: var(--sans);
  transition: color 0.2s, background 0.2s;
}

.help-link:hover {
  color: var(--brand);
  background: rgba(20, 176, 122, 0.1);
}

.login-panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  padding: 8px 0 0;
}

.login-panel-intro {
  margin-bottom: 28px;
}

.login-eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.login-brand {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--brand);
}

.login-sub {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
}

.login-error {
  background: linear-gradient(135deg, rgba(254, 226, 226, 0.9), rgba(254, 242, 242, 0.95));
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: #b91c1c;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.login-error[hidden] { display: none !important; }

.login-notice {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 16px;
}

.login-notice[hidden] { display: none !important; }

.login-notice--ok {
  background: linear-gradient(135deg, rgba(209, 250, 229, 0.9), rgba(236, 253, 245, 0.95));
  border: 1px solid rgba(20, 176, 122, 0.22);
  color: #047857;
}

.login-form { display: grid; gap: 18px; }

.field-group { display: grid; gap: 8px; }

.field-label {
  font-size: 12px;
  font-weight: 800;
  color: rgba(15, 23, 42, 0.7);
  letter-spacing: 0.02em;
}

.field-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 16px 4px 6px;
  min-height: 50px;
  border-radius: 14px;
  border: 1px solid rgba(11, 18, 32, 0.14);
  background: var(--field-bg);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.field-box:focus-within {
  border-color: rgba(31, 122, 85, 0.35);
  box-shadow: 0 0 0 4px var(--ring);
  background: #fff;
}

.field-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(20, 176, 122, 0.12), rgba(27, 67, 50, 0.06));
  color: var(--brand);
  flex-shrink: 0;
}

.field-input {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
}

.field-input::placeholder {
  color: #8fa89e;
  font-weight: 400;
}

.field-eye {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}

.field-eye:hover {
  color: var(--brand);
  background: rgba(20, 176, 122, 0.1);
}

.login-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: -2px;
}

.login-row--between {
  justify-content: space-between;
  margin-top: 0;
  margin-bottom: 4px;
}

.link-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
  font-family: var(--sans);
  transition: color 0.15s;
}

.link-btn:hover {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--btn-from) 0%, var(--btn-to) 100%);
  color: #fff;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 16px 34px var(--btn-glow);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  margin-top: 6px;
  position: relative;
  overflow: hidden;
}

.btn-login::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.15) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

.btn-login:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 48px rgba(20, 176, 122, 0.26);
}

.btn-login:hover::before {
  transform: translateX(100%);
}

.btn-login:active { transform: translateY(0); }

.btn-login.is-loading {
  opacity: 0.9;
  cursor: wait;
  pointer-events: none;
}

.btn-login.is-loading::after {
  content: "";
  width: 16px;
  height: 16px;
  margin-left: 4px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.login-staff-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 26px 0 0;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
  font-weight: 600;
  background: rgba(31, 122, 85, 0.08);
  border-radius: 12px;
  border: 1px solid rgba(31, 122, 85, 0.15);
}

.login-staff-note svg {
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 1px;
}

.login-copy {
  margin: 14px 0 0;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  font-weight: 500;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(5, 38, 30, 0.45);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay[hidden] { display: none !important; }

.modal-card {
  background: var(--panel-bg);
  color: var(--text);
  border-radius: 20px;
  padding: 28px 26px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 32px 80px rgba(12, 74, 62, 0.2);
  position: relative;
  border: 1px solid var(--border);
}

.modal-card--scroll { max-height: 80vh; overflow-y: auto; }

.modal-card h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--brand);
}

.modal-card p,
.modal-card li {
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
}

.modal-card ul {
  margin: 12px 0;
  padding-left: 20px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.modal-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
}

.modal-btn--primary {
  background: linear-gradient(135deg, var(--btn-from), var(--btn-to));
  color: #fff;
  border-color: transparent;
  width: 100%;
  margin-top: 8px;
}

/* Forgot password wizard */
.modal-overlay:not([hidden]) .modal-card--forgot {
  animation: fpModalIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes fpModalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-card--forgot {
  position: relative;
  max-width: 480px;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(11, 18, 32, 0.07);
  box-shadow:
    0 4px 6px rgba(12, 74, 62, 0.04),
    0 24px 64px rgba(12, 74, 62, 0.18);
}

.modal-card--forgot .modal-close--forgot {
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(11, 18, 32, 0.04);
  border: 1px solid rgba(11, 18, 32, 0.06);
  font-size: 20px;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  z-index: 2;
}

.modal-card--forgot .modal-close--forgot:hover {
  background: rgba(20, 176, 122, 0.1);
  border-color: rgba(20, 176, 122, 0.2);
  color: var(--brand);
}

.fp-accent {
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--brand) 55%, rgba(11, 47, 36, 0.85) 100%);
}

.fp-shell {
  padding: 26px 28px 28px;
}

.fp-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(11, 18, 32, 0.06);
}

.fp-head-icon-wrap {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: linear-gradient(145deg, rgba(20, 176, 122, 0.14) 0%, rgba(20, 176, 122, 0.06) 100%);
  border: 1px solid rgba(20, 176, 122, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.fp-head-copy {
  min-width: 0;
  padding-right: 28px;
}

.fp-title {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: clamp(1.32rem, 2.8vw, 1.5rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: #0f172a;
}

.fp-title--sm {
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.fp-eyebrow {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(20, 176, 122, 0.92);
}

.fp-lead {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.6;
  color: rgba(11, 18, 32, 0.58);
}

.fp-field-label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.78);
  letter-spacing: 0;
  line-height: 1.35;
}

.fp-field-group {
  gap: 9px;
}

.modal-card--forgot .login-eyebrow {
  margin-bottom: 5px;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(20, 176, 122, 0.95);
}

.fp-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: #f8fafb;
  border: 1px solid rgba(11, 18, 32, 0.06);
}

.fp-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.fp-step-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: rgba(11, 18, 32, 0.45);
  background: #fff;
  border: 2px solid rgba(11, 18, 32, 0.08);
  transition: all 0.22s ease;
}

.fp-step-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  color: rgba(11, 18, 32, 0.46);
  transition: color 0.22s ease;
}

.fp-step.is-active .fp-step-num {
  color: #fff;
  background: linear-gradient(135deg, var(--btn-from), var(--btn-to));
  border-color: transparent;
  box-shadow: 0 4px 14px var(--btn-glow);
}

.fp-step.is-active .fp-step-label {
  color: var(--brand);
}

.fp-step.is-done .fp-step-num {
  color: var(--accent);
  border-color: rgba(20, 176, 122, 0.32);
  background: rgba(20, 176, 122, 0.1);
}

.fp-step.is-done .fp-step-label {
  color: rgba(20, 176, 122, 0.95);
}

.fp-step-line {
  flex: 0 0 28px;
  height: 2px;
  margin-bottom: 20px;
  border-radius: 999px;
  background: rgba(11, 18, 32, 0.08);
  transition: background 0.22s ease;
}

.fp-step.is-done + .fp-step-line {
  background: linear-gradient(90deg, var(--accent), rgba(20, 176, 122, 0.35));
}

.modal-card--forgot .login-error,
.modal-card--forgot .login-notice {
  margin-bottom: 14px;
}

.fp-form-well {
  padding: 20px;
  border-radius: 16px;
  background: linear-gradient(180deg, #fafbfc 0%, #f6f8f9 100%);
  border: 1px solid rgba(11, 18, 32, 0.06);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.fp-body {
  gap: 16px;
}

.fp-email-group {
  gap: 10px;
}

.field-box--modal-email {
  min-height: 54px;
  padding: 6px 14px 6px 6px;
  gap: 10px;
  background: #fff;
  border: 1px solid rgba(11, 18, 32, 0.12);
  border-radius: 12px;
  box-shadow:
    0 1px 2px rgba(2, 6, 23, 0.04),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.field-box--modal-email:focus-within {
  border-color: rgba(20, 176, 122, 0.42);
  box-shadow:
    0 0 0 4px var(--ring),
    0 1px 2px rgba(2, 6, 23, 0.04);
  background: #fff;
}

.field-box--modal-email .field-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(20, 176, 122, 0.12) 0%, rgba(20, 176, 122, 0.05) 100%);
  border: 1px solid rgba(20, 176, 122, 0.14);
  color: var(--brand);
}

.field-input--modal-email {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  padding: 10px 2px;
  color: #0f172a;
}

.field-input--modal-email::placeholder {
  color: rgba(11, 18, 32, 0.36);
  font-weight: 400;
}

.fp-panel[hidden] {
  display: none !important;
}

.fp-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
  color: rgba(11, 59, 46, 0.75);
  background: rgba(20, 176, 122, 0.06);
  border: 1px solid rgba(20, 176, 122, 0.12);
}

.fp-hint-ico {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  font-style: normal;
  color: var(--brand);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(20, 176, 122, 0.2);
}

.btn-login--modal {
  margin-top: 6px;
  min-height: 48px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

.fp-sent-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 15px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(209, 250, 229, 0.55), rgba(236, 253, 245, 0.75));
  border: 1px solid rgba(20, 176, 122, 0.2);
}

.fp-sent-ico {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--brand);
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(20, 176, 122, 0.16);
}

.fp-sent-label {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: rgba(15, 23, 42, 0.82);
}

.fp-sent-email {
  margin: 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: rgba(11, 18, 32, 0.55);
}

.fp-sent-email strong {
  color: var(--text);
  font-weight: 700;
  word-break: break-all;
}

.fp-otp {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(11, 18, 32, 0.12);
  background: #fff;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-align: center;
  color: #0f172a;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 1px 2px rgba(2, 6, 23, 0.04);
}

.fp-otp:focus {
  outline: none;
  border-color: rgba(31, 122, 85, 0.4);
  box-shadow: 0 0 0 4px var(--ring);
}

.fp-otp::placeholder {
  color: rgba(11, 18, 32, 0.32);
  letter-spacing: 0.06em;
  font-weight: 500;
  font-family: var(--sans);
  font-size: 14px;
}

.fp-success {
  text-align: center;
  padding: 8px 0 12px;
}

.fp-success-ico {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: linear-gradient(135deg, rgba(209, 250, 229, 0.9), rgba(236, 253, 245, 0.95));
  border: 1px solid rgba(20, 176, 122, 0.22);
  box-shadow: 0 8px 24px rgba(20, 176, 122, 0.12);
}

.fp-success .fp-lead {
  max-width: 280px;
  margin: 0 auto;
}

.modal-card--forgot .link-btn,
.link-btn--modal {
  font-size: 13px;
  font-weight: 600;
  color: rgba(11, 59, 46, 0.88);
}

.fp-link-row {
  margin-top: -4px;
}

@media (max-width: 520px) {
  .fp-shell {
    padding: 22px 20px 24px;
  }

  .fp-form-well {
    padding: 16px;
  }

  .fp-step-line {
    flex-basis: 16px;
  }

  .fp-step-label {
    font-size: 10px;
  }
}

@media (min-width: 768px) {
  .login-shell {
    flex-direction: row;
    min-height: min(62vh, 680px);
  }

  .login-welcome {
    flex: 0 0 42%;
    width: 42%;
    min-height: 0;
    padding: 44px 32px;
  }

  .login-panel {
    flex: 0 0 58%;
    width: 58%;
    padding: 40px 48px 36px;
    min-height: 0;
  }

  .login-emblem {
    width: 200px;
    height: 200px;
  }
}

@media (max-width: 767px) {
  .login-app {
    padding: 8px 6px;
  }

  .login-backdrop {
    inset: -28px -20px;
  }

  .login-watermark--1 { font-size: 130px; top: -6%; left: -4%; }
  .login-watermark--2 { font-size: 115px; bottom: -4%; right: -2%; }
  .login-watermark--3 { display: none; }

  .login-shell {
    width: min(100%, 92vw);
    min-height: auto;
    max-height: none;
  }

  .login-panel {
    padding: 28px 24px 32px;
  }
}

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

  body.login-page {
    background: var(--bg);
  }

  .login-shell,
  .login-emblem,
  .login-welcome-bg,
  .login-orb,
  .login-particle,
  .login-light-beam,
  .login-shell-glow,
  .login-reveal,
  .login-welcome-title em,
  .login-panel::before,
  .login-backdrop-ring {
    animation: none !important;
  }

  .login-reveal {
    opacity: 1;
    transform: none;
  }

  .btn-login::before { display: none; }

  *, *::before, *::after {
    transition: none !important;
  }
}

@media (hover: hover) {
  .login-shell {
    transition: box-shadow 0.35s ease;
  }

  .login-shell:hover {
    box-shadow:
      0 0 0 1px rgba(20, 176, 122, 0.12),
      0 40px 72px rgba(2, 6, 23, 0.12),
      var(--shadow-soft);
  }
}
