:root {
  --header-blue: #0872b9;
  --hero-blue: #292c67;
  --hero-blue-deep: #25295f;
  --text-main: #ffffff;
  --text-soft: #cfe7ff;
  --accent: #20d8ff;
  --accent-soft: #91eeff;
  --glass: rgba(255, 255, 255, 0.095);
  --glass-border: rgba(255, 255, 255, 0.16);
  --container: 720px;
  --radius-lg: 28px;
  --radius-md: 18px;
  --shadow-soft: 0 24px 70px rgba(8, 17, 54, 0.26);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  font-family: "Quicksand", "Nunito", "Segoe UI", system-ui, sans-serif;
  position: relative;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 36% 99%, rgba(65, 103, 204, 0.34) 0 7%, transparent 21%),
    radial-gradient(circle at 13% 10%, rgba(31, 169, 255, 0.08) 0 12%, transparent 34%),
    linear-gradient(180deg, #292961 0%, #272c68 56%, #24306a 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.74;
  background:
    linear-gradient(90deg, transparent 0 16.2%, rgba(49, 107, 182, 0.18) 16.4%, transparent 16.8%),
    linear-gradient(90deg, transparent 0 65.6%, rgba(120, 177, 255, 0.28) 66%, rgba(255,255,255,0.16) 66.3%, rgba(66, 139, 255, 0.16) 66.8%, transparent 67.2%),
    linear-gradient(90deg, transparent 0 69.1%, rgba(49, 111, 211, 0.18) 69.5%, transparent 70.2%),
    linear-gradient(90deg, transparent 0 71.8%, rgba(99, 158, 255, 0.22) 72.1%, transparent 72.8%),
    linear-gradient(0deg, rgba(9, 28, 88, 0.08), rgba(255,255,255,0.015));
}

body::after {
  content: "";
  position: fixed;
  left: 17.3%;
  bottom: -48px;
  width: 420px;
  height: 440px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.36;
  background:
    linear-gradient(50deg, transparent 0 64%, rgba(95, 154, 255, 0.55) 64.5% 65.4%, transparent 66%),
    linear-gradient(90deg, transparent 0 18%, rgba(95, 154, 255, 0.55) 18.4% 19.2%, transparent 19.8%),
    linear-gradient(0deg, transparent 0 18%, rgba(95, 154, 255, 0.42) 18.4% 19.2%, transparent 19.8%),
    radial-gradient(circle at 82% 68%, rgba(255, 255, 255, 0.16) 0 18px, transparent 19px);
  filter: blur(0.4px);
}

.background-lines {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
  background:
    radial-gradient(circle at 43% 55%, rgba(255, 255, 255, 0.2) 0 5px, transparent 6px),
    radial-gradient(circle at 62% 20%, rgba(255, 255, 255, 0.13) 0 4px, transparent 5px),
    radial-gradient(circle at 84% 88%, rgba(255, 255, 255, 0.18) 0 29px, transparent 31px),
    linear-gradient(90deg, transparent 0 61.5%, rgba(26, 50, 132, 0.33) 61.6% 62%, transparent 62.1%),
    linear-gradient(90deg, transparent 0 64.8%, rgba(23, 48, 129, 0.28) 64.9% 65.2%, transparent 65.3%);
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select {
  font: inherit;
}

/* ============================================
   Header
   ============================================ */
.site-header {
  position: relative;
  z-index: 20;
  min-height: 78px;
  background: linear-gradient(90deg, #0872b9 0%, #056db1 52%, #0471b7 100%);
}

.header-shell {
  width: min(var(--container), calc(100% - 48px));
  min-height: 78px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.brand img {
  width: 155px;
  height: auto;
  display: block;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 36px;
  margin-left: auto;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #ffffff;
  transition: color 180ms ease, transform 180ms ease;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: var(--accent-soft);
  transform: translateY(-1px);
  outline: none;
}

.nav-link--back {
  font-size: 14px;
  font-weight: 600;
  opacity: 0.7;
  margin-left: 4px;
}

.nav-link--back:hover {
  opacity: 1;
}

.nav-toggle,
.nav-toggle-button {
  display: none;
}

/* ============================================
   App Container
   ============================================ */
.app-bg {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.app {
  position: relative;
  z-index: 2;
  width: min(var(--container), calc(100% - 48px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

/* ============================================
   Card (glass morphism)
   ============================================ */
.card {
  background: linear-gradient(180deg, rgba(255,255,255,0.125), rgba(255,255,255,0.073));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.card h1 {
  font-size: 1.65rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--text-main);
  letter-spacing: -0.025em;
}

.subtitle {
  color: var(--text-soft);
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
}

.test-summary {
  color: var(--text-soft);
  font-size: 0.88rem;
  line-height: 1.55;
  margin-bottom: 1.75rem;
  font-weight: 500;
}

.test-summary a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.2s;
}

.test-summary a:hover {
  opacity: 0.8;
}

.card hr {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 1.5rem 0;
}

/* ============================================
   Form
   ============================================ */
.field {
  margin-bottom: 1.25rem;
}

.field label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.35rem;
  color: var(--text-soft);
}

.field input, .field select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 0.65rem;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  background: rgba(255,255,255,0.08);
  color: var(--text-main);
}

.field input::placeholder {
  color: rgba(255,255,255,0.45);
}

.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(32, 216, 255, 0.2);
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ffffff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}

.field select option {
  background: #1e2a5a;
  color: #fff;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.6rem;
  border: none;
  border-radius: 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--accent);
  color: #111e3f;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-soft);
  transform: translateY(-1px);
}

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

.btn-secondary {
  background: rgba(255,255,255,0.1);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.18);
}

.btn-small {
  background: var(--accent);
  color: #111e3f;
  border: none;
  padding: 0.35rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-small:hover {
  background: var(--accent-soft);
}

/* ============================================
   Progress
   ============================================ */
.progress-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
}

.progress-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 99px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5fe5ff, #adf4ff);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.progress-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-soft);
  white-space: nowrap;
}

/* ============================================
   Question
   ============================================ */
.question-card {
  margin-bottom: 1.75rem;
}

.q-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #111e3f;
  background: linear-gradient(135deg, #5fe5ff, #adf4ff);
  box-shadow: 0 8px 20px rgba(33, 218, 255, 0.15);
  padding: 0.3rem 0.8rem;
  border-radius: 99px;
  margin-bottom: 0.75rem;
}

.q-text {
  font-size: 1.15rem;
  font-weight: 500;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  color: var(--text-main);
}

/* ============================================
   Options (1-5 radio buttons)
   ============================================ */
.options {
  display: flex;
  gap: 0.65rem;
  justify-content: center;
}

.opt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  height: 3.2rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.opt span {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  pointer-events: none;
}

.opt input {
  display: none;
}

.opt:hover {
  border-color: var(--accent);
  background: rgba(32, 216, 255, 0.1);
}

.opt.active {
  border-color: var(--accent);
  background: var(--accent);
}

.opt.active span {
  color: #111e3f;
}

.scale-hint {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.45);
  margin-top: 0.65rem;
  padding: 0 0.2rem;
}

/* ============================================
   Navigation
   ============================================ */
.nav-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin-top: 0.5rem;
}

.nav-buttons .btn {
  font-size: 0.9rem;
}

/* ============================================
   Result
   ============================================ */
.result-card h1 {
  margin-bottom: 1.25rem;
}

#result-content {
  line-height: 1.75;
  font-size: 0.95rem;
  color: var(--text-main);
}

#result-content h2 {
  font-size: 1.2rem;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

#result-content h3 {
  font-size: 1rem;
  margin-top: 1rem;
  color: var(--text-soft);
}

#result-content p {
  margin-bottom: 0.75rem;
}

#result-content ul, #result-content ol {
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
}

#result-content li {
  margin-bottom: 0.35rem;
}

#result-content strong {
  color: var(--accent);
}

#result-content em {
  color: var(--text-soft);
}

#result-content hr {
  border: none;
  border-top: 1px solid var(--glass-border);
  margin: 1rem 0;
}

#restart-btn {
  width: 100%;
}

/* ============================================
   Loading overlay
   ============================================ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.overlay-box {
  background: linear-gradient(180deg, rgba(255,255,255,0.125), rgba(255,255,255,0.073));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  max-width: 420px;
  width: 90%;
}

.overlay-box p {
  margin-top: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

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

.error-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.error-message {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-main);
}

/* ============================================
   Table
   ============================================ */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 1.25rem;
}

.table-wrap table, #result-content table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table-wrap th, .table-wrap td,
#result-content th, #result-content td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

.table-wrap th, #result-content th {
  background: rgba(255,255,255,0.1);
  font-weight: 700;
  color: var(--text-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.table-wrap tr:hover,
#result-content tr:hover,
#history-table tr:hover {
  background: rgba(255,255,255,0.04);
}

.table-wrap td:last-child {
  text-align: center;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-completada {
  background: rgba(22, 163, 74, 0.25);
  color: #86efac;
}

.badge-en.curso, .badge-en curso {
  background: rgba(234, 179, 8, 0.25);
  color: #fde68a;
}

.badge-iniciada {
  background: rgba(255,255,255,0.1);
  color: var(--text-soft);
}

#history-table {
  width: 100%;
  border-collapse: collapse;
}

#history-table th, #history-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--glass-border);
}

#history-table th {
  background: rgba(255,255,255,0.1);
  font-weight: 700;
  color: var(--text-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#history-table td:last-child {
  text-align: center;
}

/* ============================================
   OTP section
   ============================================ */
.otp-info {
  font-size: 0.85rem;
  color: var(--text-soft);
  margin-bottom: 0.5rem;
}

#otp-code {
  text-align: center;
  font-size: 1.5rem;
  letter-spacing: 0.5em;
  font-weight: 700;
  color: var(--text-main);
}

/* ============================================
   Footer
   ============================================ */
.site-footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--glass-border);
  text-align: center;
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.footer-whatsapp {
  background: #25d366;
  color: #fff;
  padding: 0.55rem 1.5rem;
  border-radius: 0.65rem;
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.footer-whatsapp:hover {
  opacity: 0.85;
}

.footer-text {
  font-size: 0.8rem;
  color: var(--text-soft);
}

/* ============================================
   Utilities
   ============================================ */
.hidden {
  display: none !important;
}

/* ============================================
   Send status
   ============================================ */
.send-status {
  font-size: 0.875rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 0.75rem;
  min-height: 1.4rem;
}

.send-status.sending {
  color: var(--accent);
}

.send-status.success {
  color: #86efac;
}

.send-status.error {
  color: #fca5a5;
}

/* ============================================
   Loading message
   ============================================ */
.loading-msg {
  text-align: center;
  color: var(--text-soft);
  padding: 2rem 0;
  font-weight: 500;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 980px) {
  .site-header, .header-shell {
    min-height: 68px;
  }

  .header-shell {
    width: min(100% - 34px, 760px);
    position: relative;
    justify-content: space-between;
    gap: 14px;
  }

  .brand img {
    width: 135px;
  }

  .nav-toggle-button {
    display: inline-flex;
    width: 42px;
    height: 42px;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    border: 1px solid rgba(255,255,255,0.36);
    border-radius: 12px;
    cursor: pointer;
    flex: 0 0 auto;
  }

  .nav-toggle-button span {
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: #ffffff;
    transition: transform 180ms ease, opacity 180ms ease;
  }

  .nav-toggle:checked + .nav-toggle-button span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .nav-toggle:checked + .nav-toggle-button span:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle:checked + .nav-toggle-button span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .main-nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 68px;
    display: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    margin: 0;
    padding: 14px 18px 10px;
    background: rgba(8, 114, 185, 0.98);
    border-radius: 0 0 22px 22px;
    box-shadow: 0 24px 50px rgba(10, 23, 63, 0.24);
    z-index: 30;
  }

  .main-nav .nav-link {
    width: 100%;
    padding: 12px 4px;
    font-size: 17px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  .main-nav .nav-link:last-child {
    border-bottom: none;
  }

  .nav-link--back {
    font-size: 14px;
    margin-left: 0;
    opacity: 0.7;
  }

  .nav-toggle:checked ~ .main-nav {
    display: flex;
  }

  .app, .app-bg {
    width: 100%;
  }

  .app {
    width: min(100% - 34px, 600px);
    padding: 28px 0 40px;
  }

  .card {
    padding: 1.75rem 1.5rem;
    border-radius: 24px;
  }
}

@media (max-width: 640px) {
  body::before, body::after, .background-lines {
    opacity: 0.35;
  }

  .app {
    width: min(100% - 28px, 480px);
    padding: 24px 0 32px;
  }

  .card {
    padding: 1.5rem 1.25rem;
    border-radius: 20px;
  }

  .card h1 {
    font-size: 1.35rem;
  }

  .opt {
    width: 2.6rem;
    height: 2.6rem;
  }

  .opt span {
    font-size: 0.95rem;
  }

  .options {
    gap: 0.4rem;
  }

  .nav-buttons {
    flex-wrap: wrap;
  }

  .nav-buttons .btn {
    flex: 1;
    min-width: 0;
    font-size: 0.85rem;
    padding: 0.6rem 0.8rem;
  }

  .brand img {
    width: 120px;
  }

  .footer-whatsapp {
    font-size: 0.85rem;
    padding: 0.5rem 1.2rem;
  }

  #result-content table,
  #history-table {
    font-size: 0.8rem;
  }

  #result-content th, #result-content td,
  #history-table th, #history-table td {
    padding: 0.45rem 0.5rem;
  }
}

@media (max-width: 420px) {
  .card h1 {
    font-size: 1.2rem;
  }

  .q-text {
    font-size: 1rem;
  }
}