:root {
  --navy: #0f2747;
  --navy-deep: #081a33;
  --green: #2bb673;
  --green-light: #6dd49a;
  --green-dark: #1a7f50;
  --bg: #f4f7fb;
  --text: #0f2747;
  --muted: #5e6f87;
  --border: rgba(15, 39, 71, 0.08);
  --shadow: 0 24px 60px -20px rgba(15, 39, 71, 0.25);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Inter", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding: max(24px, env(safe-area-inset-top))
           max(24px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom))
           max(24px, env(safe-area-inset-left));
  position: relative;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* Decorative background orbs */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}
.bg-orb-1 {
  width: 380px; height: 380px;
  background: radial-gradient(circle, var(--green-light), transparent 70%);
  top: -120px; right: -80px;
}
.bg-orb-2 {
  width: 460px; height: 460px;
  background: radial-gradient(circle, var(--navy), transparent 70%);
  bottom: -180px; left: -120px;
  opacity: 0.35;
}
.bg-orb-3 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, var(--green), transparent 70%);
  top: 40%; left: 40%;
  opacity: 0.18;
}

.card {
  position: relative;
  z-index: 1;
  background: #ffffff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px 28px;
  width: 100%;
  max-width: 440px;
  border: 1px solid var(--border);
  animation: fadeUp 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.logo {
  width: 168px;
  height: 168px;
  object-fit: contain;
  border-radius: 12px;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.subtitle {
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0 0 28px;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"] {
  width: 100%;
  padding: 12px 14px;
  /* 16px prevents iOS Safari from auto-zooming when the field is focused */
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: #f8fafd;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus {
  border-color: var(--green);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(43, 182, 115, 0.12);
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0 24px;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--green);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox a {
  color: var(--green-dark);
  text-decoration: underline;
  font-weight: 500;
}

.btn-primary {
  width: 100%;
  position: relative;
  background: linear-gradient(135deg, var(--green-dark), var(--green) 60%, var(--green-light));
  color: white;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  padding: 14px 18px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 6px 16px -4px rgba(43, 182, 115, 0.5);
  overflow: hidden;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px -6px rgba(43, 182, 115, 0.6);
}

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

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-primary.loading .btn-text { opacity: 0; }
.btn-primary.loading .btn-spinner { opacity: 1; }

.btn-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -9px;
  margin-left: -9px;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: spin 0.7s linear infinite;
}

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

/* Success state */
.success {
  text-align: center;
  padding: 16px 0;
  animation: fadeUp 0.4s ease both;
}

.success-icon {
  display: inline-flex;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green-dark), var(--green-light));
  color: white;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  box-shadow: 0 8px 22px -6px rgba(43, 182, 115, 0.55);
}

.success h2 {
  font-size: 22px;
  margin: 0 0 8px;
  font-weight: 700;
}

.success p {
  color: var(--muted);
  font-size: 14.5px;
  margin: 0;
}

.card-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.card-footer strong {
  color: var(--navy);
  font-weight: 600;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 26, 51, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  animation: fadeIn 0.2s ease both;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: white;
  border-radius: 14px;
  padding: 28px;
  max-width: 460px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-card h3 {
  margin: 0 0 14px;
  font-size: 18px;
  color: var(--navy);
}

.modal-body {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 18px;
}

.modal-body p { margin: 0 0 12px; }
.modal-body p:last-child { margin: 0; }

.btn-secondary {
  background: var(--navy);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: var(--navy-deep); }

/* ----- Mobile (≤ 600 px) — phones in portrait ----- */
@media (max-width: 600px) {
  body { padding: 16px;
    padding: max(16px, env(safe-area-inset-top))
             max(16px, env(safe-area-inset-right))
             max(16px, env(safe-area-inset-bottom))
             max(16px, env(safe-area-inset-left));
  }
  .card { padding: 28px 20px 20px; border-radius: 16px; }
  .logo-wrap { margin-bottom: 18px; }
  .logo { width: 120px; height: 120px; }
  h1 { font-size: 22px; }
  .subtitle { font-size: 14px; margin-bottom: 22px; }
  .field { margin-bottom: 14px; }
  .checkbox { margin: 14px 0 20px; }
  .btn-primary { padding: 14px 16px; }
  .modal-card { padding: 22px 18px; max-height: 88vh; max-height: 88dvh; border-radius: 12px; }
  .card-footer { margin-top: 22px; padding-top: 14px; }

  /* Lighter background on phones — heavy blur is expensive */
  .bg-orb { filter: blur(60px); opacity: 0.4; }
  .bg-orb-1 { width: 260px; height: 260px; }
  .bg-orb-2 { width: 320px; height: 320px; opacity: 0.3; }
  .bg-orb-3 { display: none; }
}

/* ----- Very small screens (≤ 360 px) — old/budget phones ----- */
@media (max-width: 360px) {
  .card { padding: 22px 16px 18px; }
  .logo { width: 96px; height: 96px; }
  h1 { font-size: 20px; }
}

/* ----- Short viewports (landscape phones, captive-portal mini-browsers) ----- */
@media (max-height: 560px) {
  body { align-items: flex-start; padding-top: 12px; padding-bottom: 12px; }
  .card { padding: 18px 22px 16px; }
  .logo-wrap { margin-bottom: 10px; }
  .logo { width: 64px; height: 64px; }
  h1 { font-size: 18px; margin-bottom: 4px; }
  .subtitle { font-size: 13px; margin-bottom: 14px; }
  .field { margin-bottom: 10px; }
  .checkbox { margin: 10px 0 14px; }
  .card-footer { margin-top: 14px; padding-top: 10px; }
}

/* ----- Touch devices: drop the hover lift so taps don't look stuck ----- */
@media (hover: none) {
  .btn-primary:hover:not(:disabled) {
    transform: none;
    box-shadow: 0 6px 16px -4px rgba(43, 182, 115, 0.5);
  }
}

/* HIDDEN_FIX: ensure HTML hidden attr beats display:flex on .modal */
[hidden] { display: none !important; }
