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

:root {
  --blue:    #00205B;
  --blue-d:  #001540;
  --blue-l:  #e8edf7;
  --gray:    #C1C1C1;
  --bg:      #F9F9F9;
  --white:   #ffffff;
  --text:    #333333;
  --muted:   #6b7280;
  --border:  #e0e0e0;
  --radius:  10px;
  --shadow:  0 2px 14px rgba(0,32,91,.08);
  --ok:      #16a34a;
  --error:   #dc2626;
}

body {
  font-family: "Roboto", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

.page-wrap { max-width: 1200px; margin: 0 auto; padding: 24px 16px 80px; }

/* ── Header ─────────────────────────────────────────────────────────────────── */
.pub-header {
  background: var(--blue);
  margin: 0 0 18px;
  padding: 20px max(16px, calc((100vw - 1200px) / 2 + 28px));
  display: flex;
  align-items: center;
  gap: 20px;
}

.pub-brand-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.pub-logo {
  height: 52px;
  width: auto;
  display: block;
}

.pub-brand-sub {
  font-size: .72rem;
  font-weight: 300;
  color: var(--gray);
  letter-spacing: .02em;
  white-space: nowrap;
}

.pub-header-divider {
  width: 1.5px;
  height: 44px;
  background: var(--gray);
  opacity: .4;
  margin: 0 4px;
}

.pub-header-title {
  font-family: "Montserrat", sans-serif;
  font-size: .95rem;
  font-weight: 600;
  color: rgba(255,255,255,.9);
  line-height: 1.3;
}

.pub-header-meta {
  font-size: .73rem;
  color: var(--gray);
  margin-top: 3px;
  font-weight: 300;
}

.pub-help-link {
  margin-left: auto;
  color: rgba(255,255,255,.7);
  font-size: .8rem;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px;
  padding: 5px 12px;
  transition: background .15s, color .15s;
}
.pub-help-link:hover {
  background: rgba(255,255,255,.15);
  color: #fff;
}

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 18px;
  border: 1px solid rgba(0,32,91,.06);
}

.card h2 {
  font-family: "Montserrat", sans-serif;
  font-size: .95rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.num {
  width: 26px; height: 26px;
  background: var(--blue);
  color: var(--white);
  border-radius: 50%;
  font-size: .78rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-family: "Montserrat", sans-serif;
}

/* ── Contract preview ────────────────────────────────────────────────────────── */
.card-contract { }

.hint-text { font-size: .85rem; color: var(--muted); margin-bottom: 14px; }

.contract-body {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  max-height: 440px;
  overflow-y: auto;
  font-size: .875rem;
  line-height: 1.85;
  color: var(--text);
}

.contract-body p { margin-bottom: 8px; }

.contract-body::-webkit-scrollbar { width: 5px; }
.contract-body::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
.contract-body::-webkit-scrollbar-thumb { background: var(--blue); border-radius: 3px; }

mark.empty {
  background: rgba(0,32,91,.08);
  color: var(--blue);
  border-radius: 3px;
  padding: 1px 4px;
  font-style: italic;
  border-bottom: 1.5px dashed var(--blue);
}

mark.filled {
  background: rgba(22,163,74,.12);
  color: #15803d;
  border-radius: 3px;
  padding: 1px 4px;
  font-weight: 500;
}

/* ── Fields grid ─────────────────────────────────────────────────────────────── */
.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }

.fields-trio {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

label {
  font-size: .72rem;
  font-weight: 500;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-family: "Montserrat", sans-serif;
}
.req { color: var(--error); }

input, select, textarea {
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  font-size: .95rem;
  color: var(--text);
  font-family: "Roboto", sans-serif;
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  background: var(--white);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,32,91,.1);
}

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

@media (max-width: 640px) {
  .page-wrap { padding: 12px 12px 60px; }

  /* Cabecera pública */
  .pub-header { flex-direction: column; align-items: flex-start; gap: 10px; padding: 18px 16px; }
  .pub-header-divider { display: none; }
  .pub-brand-sub { white-space: normal; font-size: .68rem; }
  .pub-logo { height: 40px; }
  .pub-help-link { margin-left: 0; font-size: .75rem; }

  /* Formulario */
  .fields-grid { grid-template-columns: 1fr; }
  .fields-trio { grid-template-columns: 1fr; }

  /* Cards */
  .card { padding: 18px 14px; }

  /* OTP */
  .otp-send-row { flex-direction: column; align-items: stretch; }
  .otp-input-row { flex-wrap: wrap; }

  /* Submit */
  .btn-submit { width: 100%; justify-content: center; padding: 14px 20px; }

  /* Success */
  .success-box { padding: 32px 16px; }
  .success-box h2 { font-size: 1.1rem; }
}

/* ── OTP ─────────────────────────────────────────────────────────────────────── */
.card-otp { border-left: 4px solid var(--blue); }

.otp-send-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.otp-email-display {
  flex: 1;
  background: var(--blue-l);
  border: 1.5px solid rgba(0,32,91,.15);
  border-radius: 7px;
  padding: 9px 14px;
  font-size: .95rem;
  color: var(--blue);
  font-weight: 500;
  min-width: 200px;
}

.btn-otp-send {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 10px 20px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
  font-family: "Montserrat", sans-serif;
}
.btn-otp-send:hover { background: var(--blue-d); }
.btn-otp-send:disabled { opacity: .5; cursor: not-allowed; }

.otp-code-step { margin-top: 4px; }

.otp-input-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 0 8px;
}

.otp-input {
  width: 160px;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: .25em;
  text-align: center;
  font-family: monospace;
  border: 2px solid var(--blue);
  border-radius: 7px;
  padding: 10px 8px;
  color: var(--blue);
}
.otp-input:focus { outline: none; box-shadow: 0 0 0 3px rgba(0,32,91,.12); }

.btn-otp-verify {
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 10px 20px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  font-family: "Montserrat", sans-serif;
}
.btn-otp-verify:hover { background: #111; }
.btn-otp-verify:disabled { opacity: .5; cursor: not-allowed; }

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

.link-btn {
  background: none; border: none; padding: 0;
  color: var(--blue); font-size: inherit; cursor: pointer;
  text-decoration: underline;
}

.otp-error { color: var(--error); font-size: .85rem; margin-top: 8px; font-weight: 500; }

.verified-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 8px;
  font-family: "Montserrat", sans-serif;
}
.verified-badge svg { width: 18px; height: 18px; fill: #15803d; }

/* ── Firma ────────────────────────────────────────────────────────────────────── */
.sig-wrap {
  border: 2px dashed var(--border);
  border-radius: 10px;
  background: #fafafa;
  cursor: crosshair;
  overflow: hidden;
  margin-bottom: 10px;
}

#sigCanvas { display: block; width: 100%; height: 180px; touch-action: none; }

.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 7px;
  padding: 6px 16px;
  font-size: .85rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--error); color: var(--error); }

.firma-locked {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f5f7fb;
  border: 2px dashed rgba(0,32,91,.15);
  border-radius: 10px;
  padding: 20px;
  color: var(--muted);
  font-size: .9rem;
}
.firma-locked svg { width: 24px; height: 24px; fill: var(--gray); flex-shrink: 0; }

/* ── RGPD ─────────────────────────────────────────────────────────────────────── */
.card-rgpd { padding: 16px 24px; }

.rgpd-label {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  font-size: .875rem;
  color: var(--muted);
}

.rgpd-label input[type=checkbox] {
  width: 17px; height: 17px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--blue);
}

/* ── Submit ───────────────────────────────────────────────────────────────────── */
.submit-wrap { text-align: center; }

.btn-submit {
  background: var(--blue);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 15px 52px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: background .15s, transform .1s;
  font-family: "Montserrat", sans-serif;
  letter-spacing: .02em;
}
.btn-submit:hover { background: var(--blue-d); }
.btn-submit:active { transform: scale(.98); }
.btn-submit:disabled { opacity: .5; cursor: not-allowed; }

/* ── Spinner ──────────────────────────────────────────────────────────────────── */
.spin {
  width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ────────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px; left: 50%;
  transform: translateX(-50%);
  padding: 13px 26px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0,0,0,.15);
  font-family: "Montserrat", sans-serif;
}
.toast.ok    { background: var(--ok);    color: #fff; }
.toast.error { background: var(--error); color: #fff; }
.toast.hidden { display: none; }

/* ── Success box ──────────────────────────────────────────────────────────────── */
.success-box {
  background: var(--white);
  border: 2px solid #86efac;
  border-radius: 16px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: var(--shadow);
}
.success-box svg { width: 56px; height: 56px; fill: var(--ok); margin-bottom: 16px; }
.success-box h2 {
  font-family: "Montserrat", sans-serif;
  font-size: 1.4rem;
  color: var(--blue);
  margin-bottom: 8px;
}
.success-box p { color: var(--muted); margin-bottom: 6px; }
.hash-line { font-size: .8rem; margin-top: 16px; }
.hash-line code {
  display: inline-block;
  background: #f3f4f6;
  padding: 4px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: .75rem;
  color: var(--blue);
  word-break: break-all;
}

/* ── Utils ────────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
