:root { --fondo:#f4f7fa; --tinta:#102a43; --azul:#1f6feb; --ok:#1b873f; --ko:#c62828; --borde:#c5d0db; }
* { box-sizing: border-box; }
html, body { margin:0; min-height:100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size:18px; line-height:1.4;
  background:var(--fondo); color:var(--tinta); overflow-x:hidden; }
main { max-width:560px; margin:0 auto; padding:20px 16px 32px; }
h1 { font-size:1.6rem; margin:.2em 0 .5em; }
h2 { font-size:1.2rem; margin:1.2em 0 .3em; }
p { margin:.4em 0 1em; }
.vista { display:flex; flex-direction:column; gap:12px; }
.btn { display:block; width:100%; min-height:56px; padding:14px 18px; font:inherit; font-weight:600; color:#fff;
  background:var(--azul); border:0; border-radius:12px; cursor:pointer; }
.btn.sec { background:#fff; color:var(--tinta); border:2px solid var(--borde); min-height:48px; }
.btn:disabled, .ocupado .btn { opacity:.55; cursor:wait; }
select, input[type=text] { width:100%; min-height:56px; padding:12px 14px; font:inherit; background:#fff;
  border:2px solid var(--borde); border-radius:12px; color:var(--tinta); }
.aviso { min-height:1.4em; margin:0; color:var(--ko); font-weight:600; }
.cargando { text-align:center; margin-top:30vh; }
.enlace { display:inline-block; padding:12px 0; color:var(--azul); font-weight:600; }
.casilla { display:flex; gap:12px; align-items:flex-start; padding:12px; margin-bottom:8px; background:#fff;
  border:2px solid var(--borde); border-radius:12px; }
.casilla input { flex:0 0 28px; width:28px; height:28px; margin-top:2px; }
.ctexto { display:flex; flex-direction:column; gap:4px; min-width:0; overflow-wrap:anywhere; }
.ctexto small { color:#486581; }
canvas.firma { display:block; width:100%; height:180px; background:#fff; border:2px dashed var(--borde);
  border-radius:12px; touch-action:none; }
.grande { min-height:80vh; display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; border-radius:20px; padding:24px; color:#fff; }
.grande h1 { font-size:2.2rem; margin:.2em 0; }
.grande.ok { background:var(--ok); }
.grande.ko { background:var(--ko); }
.grande.neutro { background:#334e68; }
.tick { font-size:5rem; line-height:1; }
.nombre { font-size:1.6rem; font-weight:600; }

/* tablet */
body.tablet { background:#102a43; color:#fff; height:100vh; overflow:hidden; }
.t-qr, .t-granted { height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:3vmin; padding:3vmin; text-align:center; }
.t-qr[hidden], .t-granted[hidden] { display:none; }
.t-instr { font-size:5vmin; font-weight:600; margin:0; }
#qr { width:70vmin; height:70vmin; background:#fff; padding:3vmin; border-radius:3vmin; image-rendering:pixelated; }
.t-granted { background:var(--ok); }
#foto { max-height:50vh; max-width:80vw; border-radius:3vmin; object-fit:contain; }
#foto[hidden] { display:none; }
.t-adelante { font-size:9vmin; font-weight:700; }
.t-nombre { font-size:7vmin; }

/* cámara del documento (autoencuadre del tótem) */
.doccam { position:relative; width:100%; aspect-ratio:3/4; max-height:62vh; background:#000; border-radius:14px; overflow:hidden; }
.doccam video { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; }
.docframe { position:absolute; left:9%; right:9%; top:50%; aspect-ratio:1.586; transform:translateY(-50%);
  border:3px dashed rgba(255,255,255,.7); border-radius:12px; box-shadow:0 0 0 999px rgba(0,0,0,.35); pointer-events:none; }
.docframe[data-state="hold"], .docframe[data-state="focus"], .docframe[data-state="far"], .docframe[data-state="near"],
.docframe[data-state="center"], .docframe[data-state="straight"], .docframe[data-state="glare"], .docframe[data-state="fingers"] { border-style:solid; border-color:#f5a623; }
.docframe[data-state="ready"], .docframe[data-state="done"] { border-style:solid; border-color:#2ecc71; }
.docquad { position:absolute; inset:0; width:100%; height:100%; pointer-events:none; }
.docquad[hidden] { display:none; }
.docquad polygon { fill:rgba(245,166,35,.10); stroke:#f5a623; stroke-width:3; stroke-linejoin:round; }
.docquad[data-state="glare"] polygon, .docquad[data-state="fingers"] polygon, .docquad[data-state="focus"] polygon { stroke:#ff5a5f; fill:rgba(255,90,95,.10); }
.docquad[data-state="ready"] polygon { stroke:#2ecc71; fill:rgba(46,204,113,.14); }
.pista { font-weight:700; text-align:center; min-height:1.4em; margin:0; }
.btn[hidden] { display:none; }
