:root {
  --blue: #0068d8;
  --blue-dark: #003068;
  --blue-soft: #eef6ff;
  --red: #f83838;
  --red-soft: #fff1f1;
  --green: #147a52;
  --green-soft: #eefaf5;
  --ink: #17324d;
  --muted: #66788a;
  --border: #cfd9e4;
  --border-strong: #afbdcb;
  --surface: #ffffff;
  --page: #f6f8fb;
  --shadow: 0 16px 40px rgba(0, 48, 104, 0.10);
  --radius: 16px;
  --field-radius: 10px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: 'TT Norms Pro', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell {
  width: min(100%, 1080px);
  margin: 0 auto;
  padding: 20px 14px 48px;
}

/* =========================================================
   ENCABEZADO / MARCA
   Mobile-first: compacto en celular y horizontal desde tablet.
   ========================================================= */

.brand-header {
  display: block;
  padding: 0 2px 18px;
  text-align: left;
}

.brand-logo {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin: 0 0 10px;
}

.brand-logo svg {
  display: block;
  width: 172px;
  max-width: 62vw;
  height: auto;
}

.form-intro {
  padding: 24px 16px 20px;
  border-bottom: 1px solid #e7edf3;
  background: #fff;
}

.form-intro h1 {
  margin: 0;
  color: var(--blue-dark);
  font-size: clamp(1.45rem, 6vw, 2rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.form-intro p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: .96rem;
  line-height: 1.45;
}

/* Sede del registro presencial (?o=PL | MI | CH). Solo texto informativo, no interactivo. */
.form-intro-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 8px;
}

.form-intro-meta p {
  margin: 0;
}

.site-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid #cfe2fb;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.site-badge svg {
  flex: 0 0 auto;
  color: var(--blue);
}

.site-badge[hidden] {
  display: none;
}

.wizard-card,
.state-screen {
  background: var(--surface);
  border: 1px solid #e5ebf1;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.progress-shell {
  padding: 18px 16px 16px;
  border-bottom: 1px solid #e7edf3;
  background: #fff;
}

.progress-topline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.progress-count {
  color: var(--blue-dark);
  font-weight: 800;
}

.progress-current-label {
  color: var(--muted);
  font-size: .9rem;
  text-align: right;
}

.progress-track {
  height: 7px;
  border-radius: 999px;
  background: #e5ebf2;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 25%;
  background: var(--blue);
  border-radius: inherit;
  transition: width .25s ease;
}

.step-dots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: 12px;
}

.step-dot {
  min-width: 0;
  text-align: center;
  color: #8796a5;
  font-size: .72rem;
  font-weight: 600;
}

.step-dot .num {
  width: 27px;
  height: 27px;
  margin: 0 auto 4px;
  display: grid;
  place-items: center;
  border: 1px solid #c6d1dc;
  border-radius: 50%;
  background: #fff;
  color: #607286;
}

.step-dot.active,
.step-dot.done {
  color: var(--blue-dark);
}

.step-dot.active .num {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.step-dot.done .num {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  color: #fff;
}

.step-dot .label { display: none; }

.form-step { padding: 24px 16px 26px; }
.step-heading { margin-bottom: 22px; }

.step-heading h2 {
  margin: 0 0 6px;
  color: var(--blue-dark);
  font-size: clamp(1.25rem, 4.8vw, 1.65rem);
  letter-spacing: -.015em;
}

.step-heading p {
  margin: 0;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.form-grid.compact { gap: 12px; }
.field { min-width: 0; }
.field.span-2,
.field.span-3 { grid-column: 1 / -1; }

.field label,
.field-label {
  display: inline-block;
  margin-bottom: 7px;
  color: var(--ink);
  font-weight: 650;
  font-size: .95rem;
}

.required { color: var(--red); }

.field-help {
  color: var(--muted);
  font-size: .82rem;
  margin-top: 6px;
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  min-height: 52px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--field-radius);
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  font-size: 16px; /* evita zoom automatico en iOS */
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

select {
  appearance: auto;
  padding-right: 34px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 104, 216, .13);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #f2f5f8;
  color: #748493;
  cursor: not-allowed;
}

.field-error {
  min-height: 0;
  color: var(--red);
  font-size: .82rem;
  font-weight: 600;
  margin-top: 5px;
  display: flex;
  align-items: flex-start;
  gap: 5px;
}

.field-error:empty { display: none; }

.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid textarea,
.input-action.is-invalid input {
  border-color: var(--red);
  background: #fffdfd;
  box-shadow: 0 0 0 2px rgba(248, 56, 56, .08);
}

.input-action {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.input-action .btn { width: 100%; }

.radio-group,
.choice-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice-card {
  position: relative;
  min-height: 50px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: #fff;
  cursor: pointer;
}

.choice-card:has(input:checked) {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.choice-card input {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
  flex: 0 0 auto;
}

.notice {
  border-radius: 12px;
  padding: 13px 14px;
  margin: 0 0 18px;
  border: 1px solid transparent;
}

.notice strong {
  display: block;
  margin-bottom: 2px;
}

.notice.info {
  background: var(--blue-soft);
  border-color: #cfe3fb;
  color: #15476f;
}

.notice.success {
  background: var(--green-soft);
  border-color: #bee8d7;
  color: #185f47;
}

.notice.error {
  background: var(--red-soft);
  border-color: #f6c4c4;
  color: #a72525;
}

.notice.warning {
  background: #fff8e7;
  border-color: #f3df9c;
  color: #725516;
}

.notice a {
  color: inherit;
  font-weight: 800;
}

.identity-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  background: #f6f9fc;
  border: 1px solid #e0e8f0;
  border-radius: 11px;
  margin-bottom: 18px;
}

.identity-strip span {
  color: var(--blue-dark);
  font-weight: 700;
  font-size: .9rem;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
  padding: 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.section-box {
  border: 1px solid #e1e8ef;
  border-radius: 14px;
  padding: 16px;
  margin: 20px 0 0;
  background: #fbfcfe;
}

.section-box h3 {
  margin: 0 0 4px;
  color: var(--blue-dark);
  font-size: 1.05rem;
}

.section-box .section-sub {
  margin: 0 0 15px;
  color: var(--muted);
  font-size: .9rem;
}

.btn {
  min-height: 50px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 11px 18px;
  font-weight: 800;
  transition: transform .08s, background .15s, border-color .15s, opacity .15s;
}

.btn:active { transform: translateY(1px); }
.btn:focus-visible {
  outline: 3px solid rgba(0, 104, 216, .25);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover { background: #005abf; }

.btn-secondary {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--blue-dark);
}

.btn-secondary:hover { background: #f6f9fc; }

.btn-danger {
  background: #c62828;
  border-color: #c62828;
  color: #fff;
}

.btn-danger:hover {
  background: #a91f1f;
  border-color: #a91f1f;
}

.btn-ghost {
  background: transparent;
  color: var(--blue);
  border-color: transparent;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.btn.small {
  min-height: 44px;
  padding: 9px 13px;
  font-size: .9rem;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 26px;
}

.loading-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid rgba(255,255,255,.55);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.btn-secondary .spinner {
  border-color: rgba(0,48,104,.22);
  border-top-color: var(--blue-dark);
}

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

.email-status {
  margin-top: 8px;
  font-size: .88rem;
  font-weight: 700;
}

.email-status.success { color: var(--green); }
.email-status.error { color: var(--red); }

.code-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #d9e4ee;
  background: #f9fbfd;
  border-radius: 11px;
}

.code-input {
  text-align: center;
  letter-spacing: .35em;
  font-size: 1.2rem !important;
  font-weight: 800;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  border: 1px solid #dde6ef;
  border-radius: 11px;
  background: #fff;
}

.checkbox-row input {
  width: 20px;
  height: 20px;
  margin-top: 1px;
  accent-color: var(--blue);
  flex: 0 0 auto;
}

.checkbox-row label {
  margin: 0;
  cursor: pointer;
}

.details-box {
  margin-top: 10px;
  border: 1px solid #dde6ef;
  border-radius: 11px;
  background: #fff;
  overflow: hidden;
}

.details-box summary {
  padding: 12px 13px;
  cursor: pointer;
  color: var(--blue);
  font-weight: 800;
}

.details-content {
  padding: 0 13px 13px;
  color: var(--muted);
  font-size: .9rem;
}

.legal-content {
  color: var(--ink);
  line-height: 1.6;
}

.legal-content h3 {
  margin: 8px 0 14px;
  color: var(--blue-dark);
  font-size: 1.1rem;
}

.legal-content ul {
  margin: 0;
  padding-left: 22px;
}

.legal-content li {
  margin-bottom: 14px;
}

.legal-content li:last-child {
  margin-bottom: 4px;
}

.legal-content a {
  color: var(--blue);
  overflow-wrap: anywhere;
}

.summary-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 15px;
  background: #f8fafc;
  border: 1px solid #e0e8f0;
  border-radius: 12px;
  margin-bottom: 18px;
}

.summary-item small {
  display: block;
  color: var(--muted);
  margin-bottom: 2px;
}

.summary-item strong {
  color: var(--blue-dark);
  overflow-wrap: anywhere;
}

.state-screen { padding: 26px 18px; }

.state-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 1.7rem;
  font-weight: 900;
  margin-bottom: 16px;
}

.state-screen h2 {
  margin: 0 0 8px;
  color: var(--blue-dark);
}

.state-screen p {
  color: var(--muted);
  margin: 0 0 18px;
}

.success-support {
  margin-top: 6px;
  font-size: .92rem;
}

.success-support a { font-weight: 800; }

.global-status { margin: 0 16px; }
.global-status:empty { display: none; }

.confirm-dialog {
  width: min(92vw, 520px);
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: transparent;
  box-shadow: 0 22px 60px rgba(0, 32, 72, .24);
}

.confirm-dialog::backdrop {
  background: rgba(9, 29, 52, .48);
}

.confirm-dialog-card {
  background: #fff;
  border-radius: 16px;
  padding: 22px;
}

.confirm-dialog-card h3 {
  margin: 0 0 10px;
  color: var(--blue-dark);
  font-size: 1.25rem;
}

.confirm-dialog-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 20px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (min-width: 560px) {
  .app-shell {
    padding: 28px 20px 64px;
  }

  .brand-logo svg {
    width: 184px;
    max-width: none;
  }

  .form-intro {
    padding: 26px 22px 22px;
  }

  .progress-shell {
    padding: 20px 22px 18px;
  }

  .form-step {
    padding: 30px 24px 32px;
  }

  .input-action {
    grid-template-columns: 1fr auto;
  }

  .input-action .btn {
    width: auto;
    min-width: 150px;
  }

  .code-grid {
    grid-template-columns: minmax(150px, 1fr) auto;
    align-items: start;
  }

  .form-actions {
    grid-template-columns: auto 1fr auto;
    align-items: center;
  }

  .form-actions .btn-primary {
    min-width: 170px;
    justify-self: end;
  }

  .form-actions .btn-secondary {
    min-width: 130px;
  }

  .summary-card {
    grid-template-columns: 1fr 1fr;
  }

  .dialog-actions {
    grid-template-columns: 1fr 1fr;
  }
}


@media (min-width: 760px) {
  .app-shell {
    padding-top: 26px;
  }

  .brand-header {
    display: block;
    padding: 2px 4px 18px;
  }

  .brand-logo {
    margin: 0;
  }

  .brand-logo svg {
    width: 196px;
    max-width: none;
  }

  .form-intro {
    padding: 28px 30px 24px;
  }

  .form-intro h1 {
    font-size: 2rem;
  }

  .form-grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid.cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .field.span-2 {
    grid-column: span 2;
  }

  .field.span-3 {
    grid-column: span 3;
  }

  .step-dot .label {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (min-width: 980px) {
  .progress-shell {
    padding-left: 30px;
    padding-right: 30px;
  }

  .form-step {
    padding: 34px 32px 38px;
  }
}

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

.json-preview {
  margin: 0;
  padding: 16px;

  max-height: 520px;
  overflow: auto;

  background: #f6f8fb;
  border: 1px solid #d9e3ed;
  border-radius: 10px;

  color: #17324d;

  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: .86rem;
  line-height: 1.55;

  white-space: pre;
  tab-size: 2;
}
