/* ============================================================
   style.css - Tokens
   ============================================================ */
:root {
  /*--navy: #10243E;*/
  --navy: #0b3765ff;
  --navy-deep: #0A1930;
  --gold: #B08D57;
  --gold-light: #D6BD91;
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --text: #1A2233;
  --text-muted: #626B7A;
  --border: #E2E4EA;
  --success: #2F855A;
  --success-bg: #EAF5EF;
  --danger: #C0392B;
  --danger-bg: #FBEAE8;
  --radius: 10px;
  --font-display: 'Spectral', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-name: 'Bebas Neue', sans-serif; /* fuente condensada para el nombre del carnet */
  --shadow-card: 0 24px 48px -20px rgba(16, 36, 62, 0.35);

  /* Colores institucionales del carnet (bandera dominicana) */
  --flag-blue: #1B4B93;
  --flag-red: #CE1126;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

/* ============================================================
   Layout general
   ============================================================ */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 340px 1fr;
  align-items: start; /* que cada columna tome su propia altura, no la
                          más alta de las dos — si no, cuando el paso 3
                          crece mucho, la barra lateral se estira con
                          ella y su contenido (arriba/pasos/abajo con
                          space-between) se termina viendo centrado */
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
}

/* ---------- Panel de marca (izquierda) ---------- */
.brand-panel {
  background: linear-gradient(165deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #EDF1F7;
  padding: 48px 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* En móvil el layout pasa a una sola columna (ver @media de .app más
   arriba), así que el sticky + 100vh ya no tiene sentido — sin este
   bloque DESPUÉS de la regla base, con la misma especificidad, la
   regla base gana igual y el panel navy tapa toda la pantalla. */
@media (max-width: 860px) {
  .brand-panel { position: static; height: auto; overflow-y: visible; }
}

/* Logo institucional en círculo: el logo se ajusta al área inscrita del círculo */
.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 150px;
  height: 150px;
  box-sizing: border-box;
  padding: 20px;
  border: 2px solid rgba(214, 189, 145, 0.6);
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
  margin-bottom: 28px;
}
.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-panel__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 32px;
  line-height: 1.18;
  margin: 0 0 10px;
}

.brand-panel__subtitle {
  margin: 0;
  color: #AEB9CC;
  font-size: 14.5px;
  line-height: 1.5;
}

.brand-panel__foot {
  color: #8895AB;
  font-size: 12.5px;
  line-height: 1.6;
  max-width: 240px;
  margin: 0;
}

.steps {
  list-style: none;
  margin: 44px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.steps__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 10px;
  border-radius: 8px;
  color: #8895AB;
  transition: color 0.25s ease;
  position: relative;
}

.steps__item::before {
  content: '';
  position: absolute;
  left: 24px;
  top: 44px;
  width: 1px;
  height: calc(100% - 14px);
  background: rgba(174, 185, 204, 0.2);
}

.steps__item:last-child::before { display: none; }

.steps__index {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(174, 185, 204, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 600;
  z-index: 1;
  background: var(--navy-deep);
}

.steps__label {
  font-size: 14px;
  font-weight: 500;
}

.steps__item.is-active,
.steps__item.is-done {
  color: #EDF1F7;
}

.steps__item.is-active .steps__index {
  border-color: var(--gold-light);
  background: var(--gold);
  color: var(--navy-deep);
}

.steps__item.is-done .steps__index {
  border-color: var(--gold-light);
  color: var(--gold-light);
}

/* ---------- Panel de formulario (derecha) ---------- */
.form-panel {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 64px 32px;
}

form#formCarnet {
  width: 100%;
  max-width: 520px;
}

.step { display: none; }
.step.is-active { display: block; animation: fadeUp 0.35s ease; }

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

.step__eyebrow {
  font-size: 12.5px;
  color: var(--gold);
  font-weight: 600;
  margin: 0 0 8px;
}
.step__eyebrow--bienvenida {
  font-size: 21px;
  line-height: 1.3;
  font-weight: 700;
  margin-bottom: 14px;
}
@media (max-width: 520px) { .step__eyebrow--bienvenida { font-size: 18px; } }

.step__title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--navy);
}

.step__hint {
  color: var(--text-muted);
  font-size: 14.5px;
  line-height: 1.55;
  margin: 0 0 28px;
  max-width: 62ch;
}

/* ---------- Nota de aviso (ej. "ten tu cédula a mano") ---------- */
.alert-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px;
  margin: 0 0 24px;
  border-radius: var(--radius);
  background: #FBF6EC;
  border: 1px solid rgba(176, 141, 87, 0.35);
}

.alert-note__icon {
  flex: none;
  color: var(--gold);
  margin-top: 1px;
}

.alert-note__title {
  margin: 0 0 3px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--navy);
}

.alert-note__text {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ---------- Instrucciones cortas antes de cada captura de foto ---------- */
.photo-instructions {
  margin-top: 0px;
  margin-bottom: 18px;
}

/* ---------- Campos ---------- */
.field { margin-bottom: 20px; }

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

.field-grid .field--full { grid-column: 1 / -1; }
.field--full select { width: 100%; text-overflow: ellipsis; }
/* Cargo: caja de texto con sugerencias */
.combo { position: relative; }
.combo input { width: 100%; text-transform: uppercase; }
.combo__list {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 240px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid #c9d3e3; border-radius: 12px; box-shadow: 0 10px 28px rgba(11, 42, 91, .18);
}
.combo__list[hidden] { display: none; }
.combo__opt { padding: 10px 12px; border-radius: 8px; font-size: 14.5px; line-height: 1.3; color: var(--navy); cursor: pointer; }
.combo__opt:hover, .combo__opt.is-active { background: #e9f0fb; }
.combo__opt--nuevo { margin-top: 4px; border-top: 1px dashed #c9d3e3; border-radius: 0 0 8px 8px; color: #7a5a00; font-weight: 600; }

@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 7px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23626B7A' stroke-width='1.6' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

/* El nombre siempre se muestra y guarda en mayúscula (el JS en main.js
   fuerza el valor real del campo; esto solo asegura que se vea así desde
   el primer instante, por ejemplo al pegar texto). El título ya no lo
   necesita: es un <select> cerrado con opciones fijas en mayúscula. */
#nombres,
#apellidos {
  text-transform: uppercase;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(176, 141, 87, 0.18);
}

input[type="text"][readonly] {
  background: var(--bg);
  color: var(--text-muted);
  cursor: default;
}

input[type="text"][readonly]:focus {
  border-color: var(--border);
  box-shadow: none;
}

.field__status {
  min-height: 18px;
  font-size: 13px;
  margin: 8px 0 0;
}

.field__status.is-ok { color: var(--success); }
.field__status.is-error { color: var(--danger); }
.field__status.is-warn { color: #9a6a00; }

/* ---------- Botones ---------- */
.step__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 32px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 13px 26px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease, opacity 0.2s ease;
}

.btn:active { transform: translateY(1px); }

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

.btn--primary:hover:not(:disabled) {
  background: var(--navy-deep);
  box-shadow: 0 10px 24px -10px rgba(16, 36, 62, 0.55);
}

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

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
  padding-left: 6px;
  padding-right: 6px;
}

.btn--ghost:hover { color: var(--navy); }

/* ---------- Foto: fuente / cámara / recorte ---------- */
.photo-source {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.photo-source__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--navy);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.photo-source__btn:hover {
  border-color: var(--gold);
  background: #FBF9F5;
}

.camera-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.camera-box video {
  width: 100%;
  max-width: 360px;
  border-radius: var(--radius);
  background: #000;
  transform: scaleX(-1);
}

/* --- Foto de perfil: recuadro cuadrado único con botón de captura
   superpuesto (sin ventana de cámara + ventana de recorte separadas) --- */
.camera-square {
  position: relative;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1 / 1;
  margin: 0 auto 20px;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.camera-square video,
.camera-square img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.camera-square video[hidden],
.camera-square img[hidden] {
  display: none;
}

.camera-square video {
  transform: scaleX(-1); /* espejo, como una selfie */
}

.camera-shutter {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: rgba(255, 255, 255, 0.22);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

.camera-shutter:hover { background: rgba(255, 255, 255, 0.38); }
.camera-shutter:active { transform: translateX(-50%) scale(0.9); }

.camera-shutter[hidden] { display: none; }

.camera-switch {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: rgba(16, 36, 62, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  z-index: 2;
}

.camera-switch:hover { background: rgba(16, 36, 62, 0.75); }
.camera-switch[hidden] { display: none; }

.camera-square video.is-back-camera {
  transform: none;
}

.camera-retake {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: rgba(16, 36, 62, 0.75);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 9px 18px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.camera-retake[hidden] { display: none; }

.crop-box { margin-bottom: 20px; }

.crop-box__stage {
  max-width: 340px;
  margin: 0 auto;
}

.crop-box__stage img { max-width: 100%; display: block; }

.photo-subhead {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 4px;
}

.photo-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0 20px;
}

.doc-photo__hint {
  margin: 0 0 16px;
}

.doc-photo { margin-bottom: 8px; }

.doc-photo__frame {
  position: relative;
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1.586 / 1; /* proporción de una cédula/tarjeta, horizontal */
  margin: 0 auto 14px;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  border: 1.5px dashed var(--border);
}

.doc-photo__placeholder {
  position: absolute;
  inset: 0;
  color: var(--text-muted);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.doc-photo__placeholder[hidden] {
  display: none; /* mismo problema que con .doc-photo__preview: sin
                     esto, el placeholder se queda visible aunque el
                     JS le ponga hidden después de cargar la foto */
}

.doc-photo__placeholder-icon {
  opacity: 0.55;
}

.doc-photo__preview,
.doc-photo__frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.doc-photo__preview[hidden],
.doc-photo__frame video[hidden] {
  display: none; /* sin esto, el elemento sin foto todavía se
                     "muestra" vacío encima del placeholder */
}

.doc-photo__frame .camera-shutter {
  z-index: 2;
}

.photo-source--sm .photo-source__btn {
  padding: 16px 14px;
}

.doc-photo__retake {
  display: block;
  margin: 0 auto;
}

/* ============================================================
   AJUSTES DE POSICIÓN DEL CARNET
   ------------------------------------------------------------
   Todo lo que se ve sobre las plantillas (foto, nombre, cargo,
   ID, código de barras, datos del reverso) se ubica con estas
   variables: top/left en % del carnet, ancho/alto en % o px.
   Para mover o agrandar un elemento, cambia SOLO su variable
   aquí — no hace falta tocar el resto del CSS ni el HTML.
   0% = borde superior/izquierdo del carnet · 100% = borde
   inferior/derecho.

   Cada texto (nombre, cargo, ID, título del reverso, lista,
   nota) también tiene su propio tamaño y tipo de letra
   (-font-size / -font-family) — cámbialos igual que los demás,
   sin tocar el resto del CSS.
   ============================================================ */
:root {
  /* --- Frente: emblema institucional --- */
  --cf-emblem-display: none;    /* pon "none" para ocultar el escudo/nombre institución */
  --cf-emblem-top: 18%;
  --cf-emblem-width: 64%;
  --cf-logo-size: 56px;

  /* --- Frente: foto --- */
  --cf-photo-display: block;    /* pon "none" para ocultar la foto */
  --cf-photo-top: 46%;
  --cf-photo-size: 33%;      /* diámetro, en % del ancho del carnet */
  --cf-photo-border-width: 0px;  /* pon 0 para quitar el borde gris */
  --cf-photo-border-color: var(--border);

  /* --- Frente: nombre --- */
  --cf-nombre-display: block;   /* pon "none" para ocultar el nombre */
  --cf-nombre-top: 68.5%;
  --cf-nombre-width: 86%;
  --cf-nombre-font-size: 18px;   /* tamaño de referencia (posición base del nombre) */
  --cf-nombre-max-font-size: 32px; /* tope: el nombre crece hasta llenar el ancho sin pasar de aquí ni tocar la foto */
  --cf-nombre-font-family: var(--font-name);

  /* --- Frente: cargo --- */
  --cf-cargo-display: block;    /* pon "none" para ocultar el cargo */
  --cf-cargo-top: 73%;
  --cf-cargo-width: 90%;        /* espacio del cargo: se achica solo para caber en UNA línea */
  --cf-cargo-min-scale: 0.55;   /* tamaño mínimo (fracción del tamaño normal) */
  --cf-cargo-font-size: 12px;
  --cf-cargo-font-family: var(--font-body);

  /* --- Frente: departamento (debajo del cargo) --- */
  --cf-depto-display: block;    /* pon "none" para ocultar el departamento */
  --cf-depto-top: 76.4%;
  --cf-depto-width: 90%;        /* espacio del departamento: hasta 2 líneas; si no cabe se achica */
  --cf-depto2-ajuste: 0px;      /* con 2 líneas, cuánto más sube (-) o baja (+) la raya/ID/QR */
  --cf-depto-font-size: 10px;
  --cf-depto-font-family: var(--font-body);

  /* --- Frente: divisor --- */
  --cf-divider-display: block;  /* pon "none" para ocultar la línea roja */
  --cf-divider-top: 79.3%;
  --cf-divider-width: 36px;

  /* --- Frente: ID --- */
  --cf-id-display: block;       /* pon "none" para ocultar el texto "ID: ..." */
  --cf-id-top: 80.2%;
  --cf-id-font-size: 12.5px;
  --cf-id-font-family: var(--font-body);

  /* --- Frente: código QR --- */
  --cf-qr-display: block;  /* pon "none" para ocultar el código QR */
  --cf-qr-top: 85%;
  --cf-qr-width: 14%;      /* el QR es cuadrado: alto = ancho (aspect-ratio) */

  /* --- Reverso: título --- */
  --cb-title-display: block;    /* pon "none" para ocultar "Datos del portador" */
  --cb-title-top: 21%;
  --cb-title-font-size: 10.5px;
  --cb-title-font-family: var(--font-body);

  /* --- Reverso: lista de datos --- */
  --cb-list-display: block;     /* pon "none" para ocultar delegación/provincia/país/fechas */
  --cb-list-top: 28%;
  --cb-list-width: 78%;
  --cb-list-font-size: 11px;
  --cb-list-font-family: var(--font-body);

  /* --- Reverso: nota legal --- */
  --cb-note-display: block;     /* pon "none" para ocultar la nota legal */
  --cb-note-top: 79%;
  --cb-note-width: 78%;
  --cb-note-font-size: 9.5px;
  --cb-note-font-family: var(--font-body);
}

/* ============================================================
   Carnet (frente / reverso con flip 3D) — formato CR80 vertical
   86 x 54 mm → proporción 53.98 / 85.6 (ancho / alto)

   El frente y el reverso son PLANTILLAS DE IMAGEN completas
   (assets/img/carnet-frente-template.png y carnet-reverso-
   template.png). Para usar tu propio diseño, reemplaza esos dos
   archivos por los tuyos (mismas proporciones) — el resto del
   sistema no cambia.
   ============================================================ */
.carnet {
  width: 100%;
  max-width: 300px;
  aspect-ratio: 53.98 / 85.6;
  margin: 0 auto 24px;
  perspective: 1600px;
  cursor: pointer;
}

.carnet__inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.7s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}

.carnet.is-flipped .carnet__inner { transform: rotateY(180deg); }

.carnet__face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 18px;
  background-color: var(--surface);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: var(--text);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

/* Marca de agua de la vista previa: evita que el diseño se use o se imprima como si fuera el carnet real */
.carnet__marca {
  position: absolute;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background: url('../img/marca-agua-vista-previa.svg') center / 150px auto repeat;
  border-radius: inherit;
}
.carnet { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.carnet img { -webkit-user-drag: none; }
.preview-nota {
  max-width: 330px; margin: -8px auto 18px; padding: 9px 12px; text-align: center;
  font-size: 12.5px; line-height: 1.45; color: #7a2a24; background: #fdecea; border: 1px solid #f3c4bf; border-radius: 10px;
}
@media print {
  .carnet, .flip-hint { visibility: hidden !important; }
  .preview-nota { visibility: visible; }
}

.carnet__face--front { background-image: url('../img/carnet-frente-template.svg'); }
.carnet__face--front.carnet__face--intl { background-image: url('../img/carnet-frente-template-internacional.svg'); }   /* fuera de RD */
.carnet__face--back  { background-image: url('../img/carnet-reverso-template.svg'); transform: rotateY(180deg); }

/* --- Frente: emblema institucional --- */
.carnet__emblem {
  position: absolute;
  z-index: 1;
  top: var(--cf-emblem-top);
  left: 50%;
  width: var(--cf-emblem-width);
  transform: translateX(-50%);
  display: var(--cf-emblem-display);
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.carnet__emblem img {
  width: var(--cf-logo-size);
  height: var(--cf-logo-size);
  object-fit: contain;
}

.carnet__emblem-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--navy);
  margin: 5px 0 0;
}

.carnet__emblem-sub {
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin: 1px 0 0;
  line-height: 1.3;
}

/* --- Frente: foto ---
   El recorte circular vive en un elemento HIJO (.carnet__photo-circle)
   separado del que se mueve (.carnet__photo-wrap, con el transform de
   centrado). Si el border-radius y el transform quedan en el MISMO
   elemento dentro de una tarjeta con flip 3D, Chrome/Safari a veces no
   recortan bien las esquinas del círculo y dejan un filo oscuro visible
   — separar las dos capas evita ese glitch. */
.carnet__photo-wrap {
  position: absolute;
  z-index: 1;
  display: var(--cf-photo-display);
  top: var(--cf-photo-top);
  left: 50%;
  width: var(--cf-photo-size);
  aspect-ratio: 1 / 1;
  transform: translateX(-50%);
}

.carnet__photo-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  border: var(--cf-photo-border-width) solid var(--cf-photo-border-color);
  background: #EDEFF3;
  box-shadow: 0 6px 16px -8px rgba(16, 36, 62, 0.4);
}

.carnet__photo-circle img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* --- Frente: nombre / cargo --- */
.carnet__nombre {
  position: absolute;
  z-index: 1;
  display: var(--cf-nombre-display);
  top: var(--cf-nombre-top);
  left: 50%;
  width: var(--cf-nombre-width);
  margin: 0;
  transform: translateX(-50%);
  font-family: var(--cf-nombre-font-family);
  font-weight: 700;
  font-size: var(--cf-nombre-font-size);
  line-height: 1.25;
  white-space: nowrap;      /* el nombre nunca baja de línea: se achica para caber (carnet-fit.js) */
  color: var(--navy);
  text-align: center;
}

.carnet__cargo {
  position: absolute;
  z-index: 1;
  display: var(--cf-cargo-display);
  top: var(--cf-cargo-top);
  left: 50%;
  width: var(--cf-cargo-width);
  white-space: nowrap;
  margin: 0;
  transform: translateX(-50%);
  font-family: var(--cf-cargo-font-family);
  font-weight: 700;
  font-size: var(--cf-cargo-font-size);
  color: var(--flag-blue);
  letter-spacing: 0.01em;
  text-align: center;
}

.carnet__depto {
  position: absolute;
  z-index: 1;
  display: var(--cf-depto-display);
  top: var(--cf-depto-top);
  left: 50%;
  width: var(--cf-depto-width);
  white-space: normal;
  line-height: 1.15;
  margin: 0;
  transform: translateX(-50%);
  font-family: var(--cf-depto-font-family);
  font-weight: 600;
  font-size: var(--cf-depto-font-size);
  color: var(--navy);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
}

.carnet__divider {
  position: absolute;
  z-index: 1;
  display: var(--cf-divider-display);
  top: var(--cf-divider-top);
  left: 50%;
  width: var(--cf-divider-width);
  height: 3px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--flag-red);
}

.carnet__idlabel {
  position: absolute;
  z-index: 1;
  display: var(--cf-id-display);
  top: var(--cf-id-top);
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  font-family: var(--cf-id-font-family);
  font-weight: 700;
  font-size: var(--cf-id-font-size);
  letter-spacing: 0.02em;
  color: var(--navy);
  white-space: nowrap;
}

/* --- Frente: código QR --- */
.carnet__qr {
  position: absolute;
  z-index: 1;
  display: var(--cf-qr-display);
  top: var(--cf-qr-top);
  left: 50%;
  width: var(--cf-qr-width);
  aspect-ratio: 1 / 1;
  transform: translateX(-50%);
  background: #fff;
  border-radius: 3px;
  overflow: hidden;
}

.carnet__qr img,
.carnet__qr canvas,
.carnet__qr table {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* --- Reverso --- */
.carnet__back-label {
  position: absolute;
  z-index: 1;
  display: var(--cb-title-display);
  top: var(--cb-title-top);
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  font-family: var(--cb-title-font-family);
  font-size: var(--cb-title-font-size);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--flag-blue);
  font-weight: 700;
  white-space: nowrap;
}

.carnet__meta--back {
  position: absolute;
  z-index: 1;
  display: var(--cb-list-display);
  top: var(--cb-list-top);
  left: 50%;
  width: var(--cb-list-width);
  transform: translateX(-50%);
  margin: 0;
  font-family: var(--cb-list-font-family);
}

.carnet__meta--back div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--cb-list-font-size);
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}

.carnet__meta--back dt { color: var(--text-muted); margin: 0; }
.carnet__meta--back dd {
  margin: 0;
  color: var(--navy);
  font-weight: 600;
  text-align: right;
}

.carnet__back-note {
  position: absolute;
  z-index: 1;
  display: var(--cb-note-display);
  top: var(--cb-note-top);
  left: 50%;
  width: var(--cb-note-width);
  margin: 0;
  transform: translateX(-50%);
  font-family: var(--cb-note-font-family);
  font-size: var(--cb-note-font-size);
  color: var(--text-muted);
  line-height: 1.5;
  text-align: center;
}

/* ============================================================
   Pantalla final
   ============================================================ */
.step--done {
  text-align: center;
  padding-top: 20px;
}

.done-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.done-codigo {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: 0.03em;
  margin: 12px 0 16px;
}

.done-qr {
  display: block;
  width: 180px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto 20px;
}

.done-qr img,
.done-qr canvas,
.done-qr table {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ============================================================
   Accesibilidad / utilidades
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .step.is-active,
  .carnet__inner {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Envío de la solicitud: indicador de carga ---------- */
.spinner {
  display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: girar .7s linear infinite;
}
.spinner--lg { width: 46px; height: 46px; border-width: 4px; color: var(--navy, #0b2a5b); border-right-color: transparent; }
@keyframes girar { to { transform: rotate(360deg); } }
.envio-overlay {
  position: fixed; inset: 0; z-index: 9999; display: none;
  align-items: center; justify-content: center; padding: 16px;
  background: rgba(10, 25, 50, .55); backdrop-filter: blur(2px);
}
.envio-overlay.is-visible { display: flex; }
.envio-overlay__box {
  background: #fff; border-radius: 16px; padding: 28px 26px; max-width: 360px; width: 100%;
  text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.envio-overlay__titulo { margin: 16px 0 6px; font-size: 18px; font-weight: 700; color: var(--navy, #0b2a5b); }
.envio-overlay__texto { margin: 0; font-size: 14px; line-height: 1.45; color: #4a5568; }
body.envio-en-curso { overflow: hidden; }
#btnEnviar .spinner { margin-right: 6px; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 1.6s; } }


/* ---------- Aviso para voltear el carnet (Paso 5) ---------- */
.flip-hint { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 6px auto 10px; max-width: 340px; }
.flip-hint__btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 16px; border: 0; border-radius: 14px; cursor: pointer; text-align: left;
  background: linear-gradient(135deg, var(--navy, #0b2a5b), #1f4e9a); color: #fff;
  box-shadow: 0 8px 22px rgba(11, 42, 91, .28); font: inherit;
  animation: flipPulso 2.2s ease-in-out infinite;
}
.flip-hint__btn:hover { filter: brightness(1.08); }
.flip-hint__btn:focus-visible { outline: 3px solid #f2c14e; outline-offset: 3px; }
.flip-hint__icon { flex: none; width: 34px; height: 34px; padding: 6px; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; animation: flipGiro 2.2s ease-in-out infinite; }
.flip-hint__text { display: grid; flex: 1; line-height: 1.25; }
.flip-hint__estado { grid-area: 1 / 1; display: flex; flex-direction: column; justify-content: center; gap: 2px; transition: opacity .25s; }
.flip-hint__estado--atras,
.flip-hint.is-atras .flip-hint__estado--frente { visibility: hidden; opacity: 0; }
.flip-hint.is-atras .flip-hint__estado--atras { visibility: visible; opacity: 1; }
.flip-hint__text strong { font-size: 15px; font-weight: 700; }
.flip-hint__text small { font-size: 12.5px; opacity: .82; }
.flip-hint__arrow { width: 30px; height: 30px; color: #c8102e; animation: flipFlecha 1.1s ease-in-out infinite; }
.flip-hint.is-usado .flip-hint__btn,
.flip-hint.is-usado .flip-hint__icon { animation: none; }
.flip-hint.is-usado .flip-hint__arrow { animation: none; opacity: .55; }
.carnet:focus-visible { outline: 3px solid #f2c14e; outline-offset: 4px; border-radius: 18px; }
@keyframes flipFlecha { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(7px); } }
@keyframes flipGiro { 0%, 55% { transform: rotate(0); } 85%, 100% { transform: rotate(360deg); } }
@keyframes flipPulso { 0%, 100% { box-shadow: 0 8px 22px rgba(11,42,91,.28), 0 0 0 0 rgba(31,78,154,.35); } 50% { box-shadow: 0 8px 22px rgba(11,42,91,.28), 0 0 0 8px rgba(31,78,154,0); } }
@media (prefers-reduced-motion: reduce) { .flip-hint__btn, .flip-hint__icon, .flip-hint__arrow { animation: none; } }


/* ---------- Móvil: el panel azul se convierte en una barra fija con los pasos ---------- */
.steps-caption { display: none; }
@media (max-width: 860px) {
  .brand-panel {
    position: sticky; top: 0; z-index: 60; height: auto; overflow: visible;
    padding: 10px 16px 9px; gap: 8px; justify-content: flex-start;
    box-shadow: 0 4px 14px rgba(8, 24, 52, .25);
  }
  .brand-panel__top { display: flex; align-items: center; gap: 10px; }
  .brand-panel .brand-mark { width: 38px; height: 38px; padding: 3px; margin: 0; border-width: 1px; flex: none; }
  .brand-panel__title { font-size: 15.5px; line-height: 1.2; margin: 0; }
  .brand-panel__title br { display: none; }
  .brand-panel__subtitle, .brand-panel__foot { display: none; }

  .steps { flex-direction: row; margin: 2px 0 0; gap: 0; }
  .steps__item { flex: 1; justify-content: center; padding: 0; gap: 0; }
  .steps__item::before { left: 50%; top: 50%; width: 100%; height: 2px; background: rgba(174, 185, 204, .25); }
  .steps__item.is-done::before { background: var(--gold-light); }
  .steps__index { width: 26px; height: 26px; font-size: 12px; }
  .steps__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .steps-caption { display: block; margin: 0; text-align: center; font-size: 12.5px; font-weight: 600; color: var(--gold-light); letter-spacing: .02em; }
}


/* ---------- Móvil: botones de navegación más compactos y separados ---------- */
@media (max-width: 520px) {
  .step__actions { gap: 16px; }
  .step__actions .btn { padding: 11px 18px; font-size: 14px; white-space: nowrap; flex: 0 0 auto; width: auto; }
  .step__actions .contact-chip { font-size: 12.5px; }
}
