/* A2F-IT — minimalista: azul noche, blanco y un solo acento. */
:root {
  --bg: #0f172a;
  --panel: #111c33;
  --line: #22304d;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(var(--safe-top) + 18px) 18px calc(var(--safe-bottom) + 24px);
}
button, input { font-family: inherit; }
.hidden { display: none !important; }

.brand { display: flex; align-items: center; gap: 8px; margin-bottom: 22px; font-weight: 700; letter-spacing: 1px; font-size: 15px; }
.brand svg { width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.view { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }

/* Cámara */
.camera {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 24px;
  overflow: hidden;
  background: #020617;
  border: 1px solid var(--line);
}
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame { position: absolute; inset: 18%; pointer-events: none; }
.frame i { position: absolute; width: 28px; height: 28px; border: 3px solid var(--text); }
.frame i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 10px; }
.frame i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 10px; }
.frame i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 10px; }
.frame i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 10px; }
.beam { position: absolute; left: 6%; right: 6%; height: 2px; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: beam 2.2s ease-in-out infinite; }
@keyframes beam { 0%, 100% { top: 8%; } 50% { top: 92%; } }
.camera:not([data-state="on"]) .beam { display: none; }
.cam-msg {
  position: absolute;
  left: 0; right: 0; bottom: 14px;
  margin: 0 16px;
  font-size: 14px;
  text-align: center;
  color: var(--text);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}
.camera:not([data-state="on"]) .cam-msg { top: 50%; bottom: auto; transform: translateY(-50%); color: var(--muted); text-shadow: none; line-height: 1.45; }
#retry { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); }

/* Botones */
.btn {
  width: 100%;
  padding: 15px;
  border: 0;
  border-radius: 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 10px 18px; font-size: 14px; }

/* Panel manual y resultado */
.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 18px;
  border-radius: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.label { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0.4px; text-transform: uppercase; }
.code {
  width: 100%;
  padding: 16px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 6px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.code:focus { border-color: var(--accent); }
.code::placeholder { color: #334155; }

.result { align-items: center; text-align: center; padding: 30px 18px 20px; }
.pin { font-size: 46px; font-weight: 700; letter-spacing: 3px; font-variant-numeric: tabular-nums; color: var(--text); }
.expires { font-size: 13px; color: var(--muted); }
.row { display: flex; gap: 10px; width: 100%; margin-top: 6px; }

.toast {
  position: fixed;
  left: 50%;
  top: calc(var(--safe-top) + 14px);
  transform: translate(-50%, -20px);
  padding: 10px 16px;
  border-radius: 12px;
  background: #1e293b;
  color: var(--text);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) { .beam { animation: none; top: 50%; } }
