:root {
  --fondo: #f3f4f6;
  --superficie: #ffffff;
  --texto: #111827;
  --texto-suave: #4b5563;
  --borde: #e5e7eb;
  --primario: #0f766e;
  --primario-oscuro: #115e59;
  --exito: #15803d;
  --exito-fondo: #dcfce7;
  --peligro: #b91c1c;
  --peligro-fondo: #fee2e2;
  --aviso-fondo: #fef3c7;
  --aviso-texto: #92400e;
  --radio: 14px;
}

* {
  box-sizing: border-box;
}

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

.contenedor {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
}

.contenedor-admin {
  max-width: 960px;
}

.encabezado {
  text-align: center;
  margin-bottom: 16px;
}

.encabezado h1 {
  margin: 4px 0 6px;
  font-size: 1.65rem;
}

.encabezado-admin {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.etiqueta-suave {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primario);
}

.texto-secundario {
  margin: 4px 0 12px;
  color: var(--texto-suave);
  font-size: 0.96rem;
}

.texto-aviso-fijo {
  margin: 6px auto 0;
  padding: 8px 12px;
  background: #e6fffa;
  border: 1px solid #99f6e4;
  border-radius: 10px;
  color: #134e4a;
  font-size: 0.9rem;
  font-weight: 600;
}

.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(17, 24, 39, 0.04);
}

.tarjeta-centrada {
  text-align: center;
}

.subtitulo {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.grilla-deptos {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.boton-depto {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 12px;
  min-height: 92px;
  background: #f9fafb;
  border: 2px solid var(--borde);
  border-radius: 12px;
  color: var(--texto);
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s, transform 0.08s;
}

.boton-depto:hover,
.boton-depto:focus-visible {
  border-color: var(--primario);
  background: #f0fdfa;
  outline: none;
}

.boton-depto:active {
  transform: scale(0.98);
}

.depto-etiqueta {
  font-size: 0.85rem;
  color: var(--texto-suave);
  font-weight: 600;
}

.depto-numero {
  font-size: 1.65rem;
  font-weight: 800;
}

.fila-superior {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.insignia {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  background: #e6fffa;
  color: var(--primario-oscuro);
}

.formulario {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.campo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.campo label {
  font-weight: 700;
  font-size: 0.98rem;
}

.obligatorio {
  color: var(--peligro);
}

.campo input,
.campo select {
  width: 100%;
  padding: 13px 14px;
  font-size: 1rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  color: var(--texto);
}

.campo input:focus,
.campo select:focus {
  border-color: var(--primario);
  outline: 2px solid rgba(15, 118, 110, 0.2);
}

.ayuda {
  color: var(--texto-suave);
  font-size: 0.85rem;
  margin: 4px 0 0;
}

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 13px 18px;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.08s;
}

.boton:active {
  transform: scale(0.98);
}

.boton:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.boton-ancho {
  width: 100%;
}

.boton-grande {
  min-height: 54px;
  font-size: 1.1rem;
}

.boton-chico {
  padding: 8px 12px;
  font-size: 0.88rem;
}

.boton-primario {
  background: var(--primario);
  color: #ffffff;
}

.boton-secundario {
  background: #e5e7eb;
  color: var(--texto);
}

.boton-exito {
  background: var(--exito);
  color: #ffffff;
}

.boton-peligro {
  background: var(--peligro);
  color: #ffffff;
}

.boton-enlace {
  background: transparent;
  border: none;
  color: var(--primario);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
}

.alerta {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.alerta p {
  margin: 4px 0;
}

.alerta-error {
  background: var(--peligro-fondo);
  color: var(--peligro);
}

.alerta-exito {
  background: var(--exito-fondo);
  color: var(--exito);
}

.alerta-aviso {
  background: var(--aviso-fondo);
  color: var(--aviso-texto);
}

.pulso-timbre {
  width: 72px;
  height: 72px;
  margin: 8px auto 16px;
  border-radius: 50%;
  background: var(--primario);
  animation: pulso 1.4s infinite ease-in-out;
}

.pulso-detenido {
  animation: none;
  background: #6b7280;
}

@keyframes pulso {
  0% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.55);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 22px rgba(15, 118, 110, 0);
  }
  100% {
    transform: scale(0.92);
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0);
  }
}

.contador-segundos {
  font-weight: 700;
  color: var(--texto-suave);
  margin: 0 0 18px;
}

.estado-conexion {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-bottom: 10px;
}

.punto-estado {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #9ca3af;
}

.punto-activo {
  background: #16a34a;
}

.punto-error {
  background: #dc2626;
}

.tarjeta-entrante {
  border: 3px solid var(--primario);
  background: #f0fdfa;
  text-align: center;
}

.etiqueta-entrante {
  margin: 0;
  color: var(--primario-oscuro);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.9rem;
}

.nombre-entrante {
  margin: 8px 0;
  font-size: 1.75rem;
  word-break: break-word;
}

.detalle-entrante {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  color: var(--texto-suave);
  font-weight: 600;
}

.acciones-vecino {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lista-historial {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-historial {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--borde);
  border-radius: 10px;
  background: #f9fafb;
}

.item-historial-info strong {
  display: block;
}

.item-historial-info small {
  color: var(--texto-suave);
}

.fila-botones {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-en-linea {
  display: inline-block;
  margin: 0;
}

.qr-bloque-principal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
}

.qr-imagen-marco img {
  display: block;
  border: 1px solid var(--borde);
  border-radius: 12px;
  background: #ffffff;
}

.qr-info {
  flex: 1;
  min-width: 240px;
}

.enlace-monoespacio {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

.grilla-admin-deptos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.tarjeta-depto-admin {
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  background: #f9fafb;
}

.tarjeta-depto-admin h3 {
  margin: 0 0 10px;
}

.qr-mini img {
  display: block;
  margin: 0 auto 8px;
  border: 1px solid var(--borde);
  border-radius: 8px;
  background: #ffffff;
}

.acciones-depto-admin {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.tabla-responsiva {
  overflow-x: auto;
}

.tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.tabla th,
.tabla td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--borde);
}

.lista-checks {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lista-checks li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
}

.check-ok {
  background: var(--exito-fondo);
  color: #14532d;
}

.check-fail {
  background: var(--peligro-fondo);
  color: #7f1d1d;
}

.lista-checks small {
  display: block;
}

.lista-enlaces {
  padding-left: 18px;
  line-height: 1.7;
}

.oculto {
  display: none !important;
}

@media print {
  body {
    background: #ffffff;
  }
  .no-imprimir {
    display: none !important;
  }
  .tarjeta-qr-imprimir {
    border: 2px solid #111827;
    box-shadow: none;
    text-align: center;
    padding: 32px;
  }
  .qr-bloque-principal {
    flex-direction: column;
    justify-content: center;
  }
}
