/* Recepción — estética mínima: papel, tinta, un acento. Pantalla completa. */
:root {
  --paper: #FAFAF8;
  --panel: #FFFFFF;
  --ink: #1A1C1E;
  --muted: #6E7277;
  --line: #E4E3DF;
  --accent: #31536B;
  --ok: #3E6B4F;
  --error: #8A3B2E;
  --ambar: #8A5A2B;        /* semántico: contacto sin verificar */
  --ambar-suave: #FBF3E7;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex; flex-direction: column;
  height: 100dvh; overflow: hidden;
  user-select: none; -webkit-user-select: none;
  /* Kiosco: sin doble-tap-zoom ni auto-resize de texto en iOS */
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

.oculto { display: none !important; }

/* Pulido: transiciones sutiles, sin espectáculo (Bloque 9) */
.pantalla { animation: pantalla-entra 0.18s ease; }
@keyframes pantalla-entra {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.btn, .tecla, .chip, .accion, .persona-card, .bulto-card, .stepper-btn {
  transition: background-color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
:where(button, input):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sello-ok { animation: sello-entra 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3); }
@keyframes sello-entra { from { transform: scale(0.7); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .pantalla, .sello-ok { animation: none; }
  .btn, .tecla, .chip, .accion, .persona-card, .bulto-card, .stepper-btn { transition: none; }
}
.oculto-total { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }

.icono { width: 24px; height: 24px; }
.icono-chico { width: 18px; height: 18px; }
.icono-grande { width: 44px; height: 44px; }
.icono-accion { width: 40px; height: 40px; }

/* ---------- Barra superior ---------- */
.barra {
  display: flex; align-items: center; gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-height: 54px;
}
.barra-volver {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 10px; width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
}
.barra-titulo { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
#barraEdificio { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-sub { font-size: 12px; color: var(--muted); }
.barra-estado {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.punto { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.punto.cola { background: var(--accent); }
.punto.mal { background: var(--error); }
.barra-operador {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
}

/* ---------- Aviso de error ---------- */
.aviso {
  background: var(--error); color: #FFF;
  padding: 10px 18px; font-size: 14px; text-align: center;
}

/* ---------- Layout de pantallas ---------- */
#app { flex: 1; display: flex; overflow: hidden; }
.pantalla { flex: 1; display: flex; overflow-y: auto; }
.centrado {
  margin: auto; display: flex; flex-direction: column; align-items: center;
  gap: 18px; padding: 24px; width: 100%; max-width: 640px; text-align: center;
}
.angosto { max-width: 420px; }
.col {
  display: flex; flex-direction: column; gap: 14px;
  padding: 20px 24px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 760px; margin: 0 auto;
}
h1 { font-size: 24px; font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; }
.sub { font-size: 15px; color: var(--muted); max-width: 46ch; }

/* ---------- Botones ---------- */
.btn {
  border: 1.5px solid var(--ink); background: var(--panel); color: var(--ink);
  border-radius: 12px; padding: 16px 24px;
  font-size: 17px; font-weight: 600; font-family: inherit;
  min-height: 56px; cursor: pointer;
}
.btn.primario { background: var(--ink); color: var(--panel); }
.btn.grande { min-height: 64px; font-size: 18px; width: 100%; }
.btn.fantasma { border-color: var(--line); color: var(--muted); font-weight: 500; }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn:not(:disabled):active { transform: scale(0.985); }
.botonera { display: flex; gap: 12px; margin-top: auto; }
.botonera .primario { flex: 1; }

/* ---------- Inicio ---------- */
.acciones { display: flex; gap: 18px; width: 100%; }
.accion {
  flex: 1; border: 1.5px solid var(--ink); border-radius: 14px;
  background: var(--panel); color: var(--ink); font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 40px 16px;
}
.accion.primario { background: var(--ink); color: var(--panel); }
.accion:disabled { opacity: 0.35; cursor: default; }
.accion-titulo { font-size: 22px; font-weight: 650; }
.accion-sub { font-size: 13px; opacity: 0.75; }

/* ---------- Teclado numérico ---------- */
.teclado {
  display: grid; grid-template-columns: repeat(3, minmax(76px, 96px));
  gap: 12px; justify-content: center;
}
.tecla {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  color: var(--ink); font-family: inherit;
  font-size: 26px; font-weight: 500; height: 68px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.tecla:active { background: var(--paper); }
.tecla.accion-tecla { font-size: 15px; color: var(--muted); }
.tecla.ok { background: var(--ink); color: var(--panel); border-color: var(--ink); font-size: 17px; font-weight: 600; }

.display-wrap { position: relative; display: inline-block; }
.display {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  font-size: 34px; font-weight: 650; letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  padding: 10px 56px; min-width: 220px; text-align: center; min-height: 62px;
}
.display-limpiar {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--paper); color: var(--muted); font-size: 24px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.display-limpiar:active { background: var(--line); color: var(--ink); }
.pin-puntos { display: flex; gap: 14px; min-height: 16px; align-items: center; }
.pin-puntos span {
  width: 14px; height: 14px; border-radius: 50%; background: var(--ink);
}
.pin-puntos span.nuevo { animation: pin-aparece 0.13s ease; }
@keyframes pin-aparece { from { transform: scale(0.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .pin-puntos span.nuevo { animation: none; } }

.residente {
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 10px; background: var(--panel);
  padding: 12px 18px; font-size: 16px; cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.residente:active { background: var(--paper); }
.residente:hover { border-color: var(--accent); }
.residente b { font-weight: 650; }
.residente .residente-extra { color: var(--muted); font-size: 13px; }

/* ---------- Cantidad ---------- */
.stepper { display: flex; align-items: center; gap: 22px; }
.stepper-btn {
  width: 84px; height: 84px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 40px; font-weight: 400; cursor: pointer; font-family: inherit;
}
.stepper-btn:active { background: var(--paper); }
.stepper-num {
  font-size: 64px; font-weight: 650; min-width: 110px; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- Foto ---------- */
.foto-encabezado { display: flex; align-items: baseline; justify-content: space-between; }
.foto-progreso { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.foto-zona {
  flex: 1; min-height: 240px;
  border: 1.5px dashed var(--line); border-radius: 14px; background: var(--panel);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.btn-foto {
  border: none; background: none; color: var(--ink); font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font-size: 17px; font-weight: 600; padding: 40px;
}
#fotoPreview { width: 100%; height: 100%; object-fit: contain; background: #111; }

.grupo-chips { display: flex; flex-direction: column; gap: 10px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chips::before {
  content: attr(data-titulo);
  font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em;
  width: 100%;
}
.chip {
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
  color: var(--muted); font-family: inherit; font-size: 14px; cursor: pointer;
  padding: 9px 16px; min-height: 40px;
}
.chip.activo { border-color: var(--ink); color: var(--ink); font-weight: 600; }

/* ---------- Resumen ---------- */
.miniaturas { display: flex; gap: 10px; flex-wrap: wrap; }
.miniaturas img {
  width: 92px; height: 92px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line);
}
.resumen-datos {
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: auto 1fr; column-gap: 24px;
}
.resumen-datos dt { color: var(--muted); font-size: 14px; padding: 12px 0; }
.resumen-datos dd {
  text-align: right; font-weight: 600; font-size: 15px; padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.resumen-datos dt { border-bottom: 1px solid var(--line); }

/* ---------- Éxito ---------- */
.sello-ok {
  width: 92px; height: 92px; border-radius: 50%;
  border: 2px solid var(--ok); color: var(--ok);
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Barra de retorno al inicio (pantalla de éxito) ---------- */
[data-pantalla="exito"] { position: relative; }
.retorno {
  position: absolute;
  left: 24px; right: 24px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  height: 4px; border-radius: 999px;
  background: var(--line); overflow: hidden;
}
.retorno-barra {
  height: 100%; width: 100%; border-radius: 999px;
  background: var(--ink);
  transform-origin: left; transform: scaleX(0);
}
.retorno-barra.andando { animation: retorno-llenar 3s linear forwards; }
@keyframes retorno-llenar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) {
  .retorno-barra.andando { animation: none; transform: scaleX(1); }
}

/* ---------- Config ---------- */
.campo { display: flex; flex-direction: column; gap: 6px; width: 100%; text-align: left; }
.campo span { font-size: 13px; color: var(--muted); }
.campo input {
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  font-family: inherit; font-size: 16px; padding: 14px; color: var(--ink);
}
.campo input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---------- Retiro: lista de bultos ---------- */
.lista-bultos { display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.bulto-card {
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  padding: 10px 14px; cursor: pointer; text-align: left;
  font-family: inherit; color: var(--ink); width: 100%;
}
.bulto-card.marcado { border-color: var(--accent); border-width: 1.5px; }
.bulto-check {
  width: 30px; height: 30px; border-radius: 8px; flex: none;
  border: 1.5px solid var(--line); color: transparent;
  display: flex; align-items: center; justify-content: center;
}
.bulto-card.marcado .bulto-check { background: var(--accent); border-color: var(--accent); color: #FFF; }
.bulto-foto {
  width: 76px; height: 76px; flex: none; border-radius: 8px;
  object-fit: cover; border: 1px solid var(--line); background: var(--paper);
}
.bulto-info { flex: 1; min-width: 0; }
.bulto-info b { display: block; font-size: 15px; font-weight: 600; }
.bulto-info span { font-size: 13px; color: var(--muted); }
.lista-vacia {
  border: 1.5px dashed var(--line); border-radius: 12px;
  padding: 40px 20px; text-align: center; color: var(--muted); font-size: 15px;
}

/* ---------- Retiro: personas ---------- */
.angosto-col { max-width: 560px; }
.personas { display: flex; flex-direction: column; gap: 8px; }
.persona-card {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  padding: 16px 18px; cursor: pointer; font-family: inherit; color: var(--ink);
  font-size: 16px; width: 100%; text-align: left; min-height: 56px;
}
.persona-card.marcado { border-color: var(--accent); border-width: 1.5px; }
.persona-rol { font-size: 13px; color: var(--muted); flex: none; }
.persona-card.marcado .persona-rol { color: var(--accent); font-weight: 600; }
/* Contacto sin verificación presencial (eje A) — señal ámbar (ALCANCE §10.6) */
.persona-card.no-verificado { border-left: 3px solid var(--ambar); background: var(--ambar-suave); }
.persona-card.no-verificado .persona-rol { color: var(--ambar); font-weight: 600; }
.persona-card.no-verificado.marcado { border-color: var(--ambar); }
.verificacion { display: flex; flex-direction: column; gap: 8px; }
.verificacion-estado { font-size: 14px; min-height: 20px; }
.verificacion-estado.ok { color: var(--ok); font-weight: 600; }
.verificacion-estado.mal { color: var(--error); font-weight: 600; }
.advertencia {
  font-size: 14px; color: var(--error);
  border-left: 3px solid var(--error); padding-left: 12px;
}

/* ---------- Desafío de RUT (estilo POS) ---------- */
.desafio { display: flex; flex-direction: column; gap: 12px; }
.desafio-titulo { font-size: 16px; font-weight: 600; text-align: center; }
.desafio-opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rut-opcion {
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--panel);
  color: var(--ink); font-family: inherit; cursor: pointer;
  font-size: 20px; font-weight: 600; letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums; padding: 22px 8px; min-height: 68px;
  transition: transform 0.08s ease, border-color 0.12s ease;
}
.rut-opcion:active { transform: scale(0.97); }
.rut-opcion.mal { border-color: var(--error); color: var(--error); animation: sacudir 0.3s; }
.rut-opcion:disabled { opacity: 0.4; }
@keyframes sacudir {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); }
}
@media (prefers-reduced-motion: reduce) { .rut-opcion.mal { animation: none; } }
@media (max-width: 560px) { .desafio-opciones { grid-template-columns: 1fr; } }

/* ---------- Retiro: firma ---------- */
.firma-marco {
  position: relative; flex: 1; min-height: 220px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--panel);
  overflow: hidden;
}
#firmaCanvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.firma-guia {
  position: absolute; bottom: 10px; left: 0; right: 0; text-align: center;
  font-size: 12px; color: var(--muted); pointer-events: none;
}

/* ---------- Visor de foto ---------- */
.visor {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 11, 12, 0.94);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 20px; gap: 16px;
}
.visor img { max-width: 100%; max-height: 82dvh; border-radius: 8px; }
.visor-cerrar { background: var(--panel); min-width: 160px; }

/* ---------- Menú admin del quiosco (16d-3): ícono discreto + modal ---------- */
#gearAdmin {
  position: fixed; right: 8px; bottom: 6px; z-index: 40;
  width: 32px; height: 32px; padding: 6px;
  background: transparent; border: none; color: var(--line); opacity: 0.55;
}
#gearAdmin svg { width: 100%; height: 100%; display: block; }
#gearAdmin:active { opacity: 1; color: var(--muted); }
#gearAdmin.oculto { display: none; }
.adm-ov { position: fixed; inset: 0; z-index: 60; background: rgba(10, 11, 12, 0.5);
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.adm-ov.oculto { display: none; }
.adm-cj { background: var(--panel); border-radius: 18px; padding: 24px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28); }
.adm-cj h2 { font-size: 20px; margin-bottom: 4px; }
.adm-cj p.sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.adm-cj input.pin-in { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  font-size: 24px; text-align: center; letter-spacing: 8px; font-family: inherit; }
.adm-cj .adm-acc { display: flex; gap: 10px; margin-top: 16px; }
.adm-cj .adm-err { color: var(--error); font-size: 14px; margin-top: 10px; min-height: 18px; }

/* ---------- Teléfono (pantallas angostas) ---------- */
@media (max-width: 560px) {
  .acciones { flex-direction: column; }
  .accion { padding: 26px 16px; }
  h1 { font-size: 21px; }
  .stepper-btn { width: 72px; height: 72px; }
}
