:root {
    --teal: #4fc8a0;
    --teal-bg: #eaf7f1;
    --blue: #2563eb;
    --blue-dark: #1442b0;
    --amber: #f5c842;
    --amber-bg: #fef8e8;
    --text-primary: #0b1120;
    --text-secondary: #465065;
    --text-muted: #667089;
    --border: #d9e0ec;
    --field-bg: #f4f6fa;
    --font-display: 'Sora', sans-serif;
    --font-body: 'DM Sans', sans-serif;
  }

  * { box-sizing: border-box; }

  .ch-main-wrp {
    margin: 0;
    font-family: var(--font-body);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    padding: 3px 0px;
  }

  .page { width: 100%; max-width: 420px; }

  /* ---------- Paso 1: resultado de la oficina ---------- */
  .card-oficina {
    background: linear-gradient(180deg, #f2fbf7, #eaf7f1);
    border: 1px solid #cdeee0;
    border-radius: 20px;
    padding: 22px;
    text-align: center;
    margin-bottom: 14px;
  }

  .card-oficina h3 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.04em;
    margin: 0 0 12px;
  }

  .lote-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: rgba(79, 200, 160, 0.16);
    border-radius: 12px;
    padding: 11px;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 24.5px;
    color: #0e6b4d;
    margin-bottom: 12px;
  }

  .lote-badge svg { width: 20px; height: 20px; color: var(--teal); }

  .card-oficina .fecha { font-size: 15.5px; color: var(--text-secondary); margin-bottom: 4px; }
  .card-oficina .cita { font-weight: 700; color: var(--blue); font-size: 15.5px; margin-bottom: 16px; }

  .btn-mapa {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--amber);
    border: none;
    border-radius: 999px;
    padding: 12px 20px;
    font-weight: 700;
    font-size: 15px;
    color: #4a3a06;
    margin-bottom: 14px;
    cursor: pointer;
  }

  .btn-mapa svg { width: 17px; height: 17px; }

  .direccion { font-size: 14px; color: var(--text-secondary); display: flex; align-items: center; justify-content: center; gap: 6px; margin-bottom: 8px; }
  .credito { font-size: 13.5px; color: var(--text-muted); }
  .credito b { color: #d1495b; }

  /* ---------- Paso 2: comprobar tu lote ---------- */
  .card-check {
    background: #fff;
    outline: 3px solid #aab7cd6e;
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 14px;
  }

  .card-check h4 { font-family: var(--font-display); font-size: 17px; font-weight: 700; margin: 0 0 4px; }
  .card-check .sub { font-size: 14px; color: var(--text-secondary); margin: 0 0 14px; }

  .fila-check { display: flex; gap: 8px; }

  .fila-check input {
    flex: 1;
    min-width: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    text-align: center;
    letter-spacing: 0.05em;
    color: var(--text-primary);
    background: var(--field-bg);
    border: 1.75px dashed var(--border);
    border-radius: 12px;
    padding: 13px;
    outline: none;
  }

  .fila-check input:not(:placeholder-shown) { border-style: solid; }
  .fila-check input:focus { border-style: solid; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(37,99,235,0.12); }

  .btn-comprobar {
    flex-shrink: 0;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0 13px;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    cursor: pointer;
  }

  .ejemplo-fuente { display: block; text-align: center; font-size: 12.5px; color: var(--text-muted); margin-top: 8px; }
  .ejemplo-fuente b { color: var(--blue); font-weight: 800; }

  .error-lote-vacio {
    display: none;
    font-size: 13px;
    color: #d43f3f;
    text-align: center;
    margin-top: 8px;
  }

  .fila-check.error input { border-color: #e15b5b; }
  .fila-check.error input.shake { animation: shakeInput 0.3s ease; }
  @keyframes shakeInput { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }

  .resultado { margin-top: 14px; border-radius: 14px; padding: 15.5px 17.5px; display: none; }
  .resultado.visible { display: block; }
  .resultado.lista { background: var(--teal-bg); border: 1px solid #cdeee0; }
  .resultado.espera { background: var(--amber-bg); border: 1px solid #f2e2a8; }

  .resultado .titulo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 17px;
    margin-bottom: 6px;
  }

  .resultado.lista .titulo { color: #0e6b4d; }
  .resultado.espera .titulo { color: #8a6d1a; }
  .resultado .titulo svg { width: 20px; height: 20px; }
  .resultado .detalle { font-size: 14.5px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 4px; }

  .faltan-destacado {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 17px;
    color: var(--text-primary);
    margin-bottom: 6px;
  }

  .faltan-destacado .numero { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }

  .nota-seguro {
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 8px;
  }
  .resultado .detalle b { color: var(--text-primary); }

  .btn-seguir {
    width: 100%;
    margin-top: 12px;
    background: linear-gradient(180deg, var(--blue), var(--blue-dark));
    color: #fff;
    border: none;
    border-radius: 13px;
    padding: 12px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .btn-seguir svg { width: 24px; height: 24px; align-self: start; }

  /* ---------- Paso 3: tarjeta de pago (idéntica a la aprobada) ---------- */
  .paso3 {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
  }

  .paso3.abierto { max-height: 1400px; opacity: 1; }

  .aviso-card {
    background: linear-gradient(180deg, #ffffff, #fbfcff);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 24px 22px 22px;
    margin-top: 14px;
    position: relative;
    isolation: isolate;
  }

  

  .aviso-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

  .badge-autopilot {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: 999px;
    padding: 4.5px 10px 4.5px 7.5px;
    flex-shrink: 0;
  }

  .badge-autopilot .pulso {
    position: relative;
    width: 8px;
    height: 8px;
    flex-shrink: 0;
  }

  .badge-autopilot .pulso::before,
  .badge-autopilot .pulso::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--blue);
  }

  .badge-autopilot .pulso::before {
    animation: pulso-anillo 1.8s ease-out infinite;
  }

  @keyframes pulso-anillo {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(3.2); opacity: 0; }
  }

  .badge-autopilot span {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: var(--blue-dark);
  }

  @media (prefers-reduced-motion: reduce) {
    .badge-autopilot .pulso::before { animation: none; }
  }

  .badge-autopilot.mini {
    margin-left: 6px;
    vertical-align: middle;
    padding: 2px 7.5px 2px 5.5px;
  }

  .titulo { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }

  .aviso-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(150deg, var(--blue), var(--blue-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 8px 16px -8px rgba(37, 99, 235, 0.6);
  }

  .aviso-icon svg { width: 19px; height: 19px; }

  .aviso-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 19px;
    line-height: 1.25;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
  }

  .aviso-beneficios { display: flex; flex-wrap: nowrap; gap: 4px; margin: 0 0 16px; }
  .beneficio-chip { flex-shrink: 0; }
  .beneficio-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: var(--teal-bg); border: 1px solid #cdeee0; color: #0e6b4d;
    border-radius: 999px; padding: 6px 9px 6px 7px;
    font-family: var(--font-body); font-weight: 600; font-size: 10.5px;
    white-space: nowrap;
  }
  .beneficio-chip svg { width: 11px; height: 11px; flex-shrink: 0; }

  .manifiesto-autopilot {
    font-size: 14px;
    font-style: italic;
    color: var(--text-secondary);
    margin: 0 0 10px;
    padding-left: 1px;
  }

  .manifiesto-autopilot b { font-style: normal; color: var(--blue-dark); font-weight: 700; }

  .resumen-conocido {
    background: var(--field-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0;
    margin-bottom: 16px;
    overflow: hidden;
  }

  .resumen-conocido .fila { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 15.5px; font-size: 14px; flex-wrap: wrap; }
  .resumen-conocido .fila > span:first-child { flex-shrink: 0; padding-top: 2px; }
  .resumen-conocido .fila:not(:last-child) { border-bottom: 1px solid var(--border); }
  .resumen-conocido .fila span:first-child { color: var(--text-muted); }
  .resumen-conocido .fila span:last-child { color: var(--text-primary); font-weight: 700; font-family: var(--font-display); }

  #loteUsuarioTexto { color: var(--text-primary); font-size: 18px; }
  #loteActualTexto { color: #0e6b4d; }
  #faltanTexto { color: #8a6d1a; font-size: 17px; }

  .fila-precio { border-top: 1px dashed var(--border) !important; margin-top: 2px; padding-top: 11px !important; }
  .fila-precio span:first-child { color: var(--text-primary); font-weight: 600; }
  .fila-precio span:last-child { font-size: 17px; }
  .fila-precio .detalle-precio { font-size: 12px; font-weight: 500; color: var(--text-muted); font-family: var(--font-body); margin-left: 4px; }

  #filaLote { background: var(--amber-bg); }
  .fila-actual #loteActualTexto { color: #0e6b4d; }

  .valor-editable { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; justify-content: flex-end; flex-wrap: wrap; text-align: right; }

  .edicion-inline { display: flex; align-items: center; gap: 6px; flex: 1; justify-content: flex-end; }
  .edicion-inline.oculto { display: none; }
  .resumen-conocido .fila.editando .valor-editable { display: none; }

  .edicion-inline select, .edicion-inline input {
    font-family: var(--font-body);
    font-size: 13.5px;
    color: var(--text-primary);
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    padding: 5.5px 7.5px;
    outline: none;
    max-width: 92px;
  }

  .edicion-inline input { max-width: 60px; text-align: center; font-weight: 700; }
  .edicion-inline select:focus, .edicion-inline input:focus { border-color: var(--blue); }

  .campo { margin-bottom: 11px; }
  .campo label { display: block; font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 6px; }
  .opcional { font-size: 12px; font-weight: 500; color: var(--text-muted); }

  .campo-error { display: none; font-size: 13px; color: #d43f3f; margin-top: 5px; }
  .campo.error .campo-error { display: block; }
  .campo-error.visible { display: block; }
  #errorConsentimiento { margin-top: -8px; margin-bottom: 12px; }

  .campo input {
    width: 100%;
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--text-primary);
    background: var(--field-bg);
    border: 1.75px solid var(--border);
    border-radius: 13px;
    padding: 13px 15.5px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  }

  .campo input::placeholder { color: var(--text-muted); }
  .campo input:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14); }
  .campo.error input { border-color: #e15b5b; }

  .whatsapp-row { display: flex; align-items: stretch; gap: 8px; }

  .pais-select {
    display: flex; align-items: center; height: 47px;
    background: var(--field-bg); border: 1.75px solid var(--border);
    border-radius: 13px; padding: 0 4.5px 0 13px; font-size: 15.5px; font-weight: 600; flex-shrink: 0;
  }

  .pais-select select {
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    border: none; background: transparent; font-family: var(--font-body);
    font-size: 15.5px; color: var(--text-primary); padding: 0 4.5px; margin: 0;
    height: 100%; line-height: 1; outline: none;
  }

  .whatsapp-row input { flex: 1; height: 47px; padding-top: 0; padding-bottom: 0; }

  .consentimientos {
    background: var(--field-bg);
    border: 1.5px solid var(--border);
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    transition: border-color 0.15s ease;
  }

  .consentimiento-item {
    display: flex; align-items: flex-start; gap: 10px; padding: 12px 13px; cursor: pointer;
    transition: max-height 0.2s ease, opacity 0.2s ease, padding 0.2s ease;
  }

  .consentimiento-item:not(:last-child) { border-bottom: 1px solid var(--border); }
  .consentimiento-item input { width: 19px; height: 19px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--blue); cursor: pointer; }
  .consentimiento-item span { font-size: 12.5px; line-height: 1.4; color: var(--text-secondary); }
  .consentimiento-item a { color: var(--blue); text-decoration: underline; }
  .consentimiento-item.error { background: rgba(225, 91, 91, 0.06); }

  .consentimiento-item.oculto {
    max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0;
    border-bottom-width: 0; overflow: hidden; pointer-events: none;
  }

  .btn-activar {
    position: relative;
    overflow: hidden;
    width: 100%;
    border: none;
    border-radius: 15px;
    padding: 15.5px;
    background: linear-gradient(180deg, var(--blue), var(--blue-dark));
    color: #fff;
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 16px 28px -12px rgba(37, 99, 235, 0.65), 0 1px 0 rgba(255, 255, 255, 0.25) inset;
    transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
  }

  .btn-activar::after {
    content: '';
    position: absolute;
    top: 0; left: -60%;
    width: 40%; height: 100%;
    background: linear-gradient(115deg, transparent, rgba(255, 255, 255, 0.35), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
  }

  .btn-activar:hover::after { left: 120%; }
  .btn-activar:hover { transform: translateY(-1px); box-shadow: 0 20px 34px -12px rgba(37, 99, 235, 0.7); }
  .btn-activar:active { transform: translateY(0); }
  .btn-activar:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
  .btn-activar svg { width: 18px; height: 18px; flex-shrink: 0; }

  .aviso-metodos { display: flex; align-items: center; justify-content: center; flex-wrap: nowrap; gap: 6px; margin-top: 12px; }
  .metodo { display: flex; align-items: center; gap: 3px; font-family: var(--font-body); font-weight: 700; font-size: 13.5px; color: var(--text-muted); }
  .metodo svg { height: 16px; width: auto; flex-shrink: 0; }
  .metodo.apple { color: var(--text-primary); }
  .metodo.visa { color: #1a1f71; }
  .metodo.bizum { color: #00c1de; font-style: italic; }
  .metodo.paypal { color: #003087; font-weight: 700; }

  .aviso-disclaimer-corto { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 10px; }

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

  @keyframes campo-error-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
  }

  .shake { animation: campo-error-shake 0.3s ease; }

  @media (prefers-reduced-motion: reduce) {
    .btn-activar, .campo.error input { transition: none; animation: none; }
  }