:root {
  --color-marca: #be0f2e;
  --color-texto: #1f2328;
  --color-fondo: #ffffff;
  --color-borde: #c9ced6;
  --color-error-fondo: #fdecee;
  --color-info-fondo: #eef4fb;
  --color-ok-fondo: #e9f6ec;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--color-texto);
  background: var(--color-fondo);
  line-height: 1.5;
}

.cabecera {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--color-marca);
  color: #fff;
}
.cabecera .marca { display: block; height: 40px; width: auto; }
.idiomas a { color: #fff; margin-left: 0.75rem; text-decoration: none; }
.idiomas a.activo { text-decoration: underline; font-weight: 600; }

.contenido { max-width: 34rem; margin: 2rem auto; padding: 0 1rem; }

.formulario { display: flex; flex-direction: column; gap: 0.4rem; margin: 1.5rem 0; }
.formulario label { font-weight: 600; margin-top: 0.6rem; }
.formulario input {
  padding: 0.6rem; font-size: 1rem;
  border: 1px solid var(--color-borde); border-radius: 4px;
}
.formulario input:focus { outline: 3px solid #8ab4f8; outline-offset: 1px; }
.formulario button {
  margin-top: 1rem; padding: 0.7rem; font-size: 1rem; font-weight: 600;
  color: #fff; background: var(--color-marca); border: 0; border-radius: 4px; cursor: pointer;
}
.formulario button:disabled { background: #9aa0a6; cursor: not-allowed; }
/* Indicador de carga mientras el servidor procesa el cambio (js/contrasena.js). */
.formulario button.cargando, .formulario button.cargando:disabled {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.6rem;
  background: var(--color-marca); opacity: 0.85; cursor: progress;
}
.formulario button.cargando::before {
  content: ""; width: 1.1em; height: 1.1em; flex: none; box-sizing: border-box;
  border: 2px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%;
  animation: girar 0.8s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .formulario button.cargando::before { animation-duration: 2.4s; }
}
.solo-lectores { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.acciones-contrasena { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.6rem; }
.formulario .acciones-contrasena button {
  margin-top: 0; padding: 0.4rem 0.8rem; font-size: 0.9rem; font-weight: 600;
  color: var(--color-marca); background: #fff; border: 1px solid var(--color-marca);
}
.formulario .acciones-contrasena button:hover { background: var(--color-error-fondo); }
#estado-copia { font-size: 0.9rem; color: #1a7f37; }
.nota { font-size: 0.85rem; color: #6b7280; margin: 0.2rem 0 0; }
.acciones-contrasena[hidden] + .nota { display: none; }

.aviso { padding: 0.75rem 1rem; border-radius: 4px; }
.aviso p { margin: 0; }
.aviso ul { margin: 0.5rem 0 0; }
.aviso.error { background: var(--color-error-fondo); border-left: 4px solid var(--color-marca); }
.aviso.info { background: var(--color-info-fondo); }
.aviso.ok { background: var(--color-ok-fondo); }

.temporizador { display: flex; align-items: center; gap: 1rem; margin: 1rem 0; }
.temporizador p { margin: 0.15rem 0; }
.temporizador .intentos { font-weight: 600; }
.anillo { width: 2.75rem; height: 2.75rem; flex: none; transform: rotate(-90deg); }
.anillo-fondo { fill: none; stroke: #e5e7eb; stroke-width: 4; }
.anillo-progreso { fill: none; stroke: #1a7f37; stroke-width: 4; stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s; }
.anillo text { transform: rotate(90deg); transform-origin: 22px 22px; font-size: 9px; font-weight: 700;
  fill: var(--color-texto); font-variant-numeric: tabular-nums; }
.poco-tiempo .anillo-progreso { stroke: var(--color-marca); }
.agotado .anillo-progreso { stroke: transparent; }

.politica { font-size: 0.9rem; }
.politica h2 { font-size: 1rem; margin-bottom: 0.4rem; }
/* Requisitos cortos en dos columnas; los largos (.ancha) ocupan la fila entera. */
.reglas { list-style: none; padding-left: 0; margin: 0;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1rem; row-gap: 0.15rem; }
.reglas li { padding-left: 1.6rem; position: relative; margin: 0; }
.reglas li.ancha { grid-column: 1 / -1; }
@media (max-width: 30rem) { .reglas { grid-template-columns: minmax(0, 1fr); } }
.reglas li::before { content: "•"; position: absolute; left: 0.4rem; color: #6b7280; }
.reglas li.cumple { color: #1a7f37; }
.reglas li.cumple::before { content: "✓"; color: #1a7f37; font-weight: 700; left: 0.2rem; }
.reglas li.no-cumple { color: var(--color-marca); }
.reglas li.no-cumple::before { content: "✗"; color: var(--color-marca); font-weight: 700; left: 0.2rem; }
.reglas small { color: #6b7280; }
/* El texto "Cumple"/"No cumple" es para lectores de pantalla; la marca visual es el icono. */
.reglas .estado { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Normativa de seguridad: pregunta en el formulario (sin JavaScript) y ventana (con JavaScript). */
.normativa { border: 1px solid var(--color-borde); border-radius: 4px; margin: 1rem 0 0; padding: 0.5rem 1rem 0.75rem; }
.normativa legend { font-weight: 600; padding: 0 0.3rem; }
.normativa p { margin: 0.4rem 0; }
.casilla { display: flex; align-items: flex-start; gap: 0.6rem; }
.casilla input { flex: none; width: 1.15rem; height: 1.15rem; margin: 0.15rem 0 0; accent-color: var(--color-marca); }
.casilla label { font-weight: 400; margin: 0; cursor: pointer; }
.formulario .normativa .casilla input { width: 1.15rem; padding: 0; }
.dialogo { max-width: 30rem; width: calc(100% - 2rem); border: 0; border-top: 4px solid var(--color-marca);
  border-radius: 6px; padding: 1.25rem 1.5rem; color: var(--color-texto); background: var(--color-fondo);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); }
.dialogo::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialogo h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
.dialogo p { margin: 0.5rem 0; }
.dialogo-botones { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.5rem; margin-top: 1.25rem; }
.dialogo-botones button { font: inherit; padding: 0.55rem 1.1rem; border-radius: 4px; cursor: pointer;
  color: #fff; background: var(--color-marca); border: 1px solid var(--color-marca); }
.dialogo-botones button.secundario { color: var(--color-marca); background: #fff; }
.dialogo-botones button:disabled { cursor: not-allowed; opacity: 0.45; }
.dialogo-botones button:focus { outline: 3px solid #8ab4f8; outline-offset: 1px; }

.pie { max-width: 34rem; margin: 2rem auto; padding: 0 1rem; }

/* Enlace con aspecto de botón secundario (p. ej. «Solicitar un código nuevo»). */
.boton-secundario {
  display: inline-block; padding: 0.55rem 1.1rem; font-weight: 600; text-decoration: none;
  color: var(--color-marca); background: #fff; border: 1px solid var(--color-marca); border-radius: 4px;
}
.boton-secundario:hover { background: var(--color-error-fondo); }
.boton-secundario:focus { outline: 3px solid #8ab4f8; outline-offset: 1px; }
