/* Autofactura · Zero Latency VR (Monterrey). Modo claro, móvil primero. */
:root {
  --bg: #F3F6FA;
  --card: #FFFFFF;
  --ink: #0F1A2A;
  --ink-2: #44526A;
  --ink-3: #5F6C82;          /* 5.3:1 sobre blanco */
  --line: #DCE3EC;
  --line-2: #C6D0DD;
  --brand: #0E7490;          /* botón: blanco encima da 5.4:1 */
  --brand-press: #155E75;
  --brand-soft: #E3F5FA;
  --brand-line: #7FD0E3;
  --glow: #22C5E8;           /* el cian del logo, solo decorativo */
  --ok: #047857;
  --ok-soft: #E3F6EE;
  --crit: #B42318;
  --crit-soft: #FDECEA;
  --r: 18px;
  --shadow: 0 1px 2px rgba(15, 26, 42, .06), 0 8px 24px rgba(15, 26, 42, .06);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--brand); font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding: 0 16px; }

/* ─── barra superior ─── */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0 10px; }
.top-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.back {
  width: 48px; height: 48px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.back svg { width: 22px; height: 22px; }
.back:active { transform: scale(.96); }
.back[hidden] { display: none; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand img { width: 40px; height: 40px; border-radius: 11px; flex: none; }
.brand b { font-size: 16px; line-height: 1.15; display: block; }
.brand span { font-size: 13px; color: var(--ink-3); display: block; }
.step-count { margin-left: auto; font-size: 15px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { height: 6px; border-radius: 99px; background: var(--line); margin-top: 12px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--glow)); transform-origin: left center; transform: scaleX(0); transition: transform .45s cubic-bezier(.22, 1, .36, 1); }
.bar[hidden] { display: none; }

/* ─── pantallas ─── */
main { flex: 1; display: flex; flex-direction: column; padding-bottom: 24px; }
.screen { flex: 1; display: flex; flex-direction: column; animation: entra .35s cubic-bezier(.2, .8, .2, 1); }
.screen.atras { animation-name: entra-atras; }
@keyframes entra { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes entra-atras { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen, .bar i, .check-anim * { animation: none !important; transition: none !important; } }

h1 { font-size: 30px; line-height: 1.15; letter-spacing: -.02em; margin: 18px 0 8px; }
.lead { font-size: 18px; color: var(--ink-2); margin: 0 0 22px; }
.lead b { color: var(--ink); }
.grow { flex: 1; }

/* ─── inicio ─── */
.hero { margin-top: 18px; border-radius: 26px; padding: 28px 22px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(120% 90% at 100% 0%, rgba(34, 197, 232, .55), transparent 60%), linear-gradient(160deg, #0F1A2A, #12334A); }
.hero h1 { color: #fff; font-size: 34px; margin: 0 0 8px; }
.hero p { margin: 0; color: #C9E6F0; font-size: 18px; }
.hero .mark { position: absolute; right: -18px; bottom: -22px; width: 140px; opacity: .16; }
.pasos { list-style: none; padding: 0; margin: 22px 0 8px; display: grid; gap: 10px; }
.pasos li { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; font-size: 17px; }
.pasos .ico { width: 44px; height: 44px; border-radius: 13px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.pasos .ico svg { width: 22px; height: 22px; }
.pasos small { display: block; color: var(--ink-3); font-size: 14px; }

/* ─── campos ─── */
.field { margin-bottom: 18px; }
.field label, .field .label { display: block; font-weight: 650; font-size: 16px; margin-bottom: 8px; }
.field .hint { font-size: 14px; color: var(--ink-3); margin-top: 6px; }
.input, .select {
  width: 100%; min-height: 60px; border-radius: 16px; border: 1.5px solid var(--line-2); background: var(--card);
  padding: 14px 16px; font-size: 20px; outline: none; transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.select { padding-right: 48px; font-size: 17px; line-height: 1.3;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%2344526A' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 8 5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; }
.input:focus, .select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(14, 116, 144, .16); }
.input.mayus { text-transform: uppercase; letter-spacing: .04em; }
.input.err { border-color: var(--crit); }
.codigo { text-align: center; font-size: 34px; letter-spacing: .5em; padding-left: calc(16px + .5em); font-variant-numeric: tabular-nums; font-weight: 700; min-height: 76px; }

.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 650; padding: 5px 11px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-press); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.gris { background: #EDF1F6; color: var(--ink-2); }

.check { display: flex; gap: 14px; align-items: flex-start; padding: 16px; border-radius: var(--r); background: var(--card); border: 1.5px solid var(--line); cursor: pointer; font-size: 16px; color: var(--ink-2); }
.check input { width: 26px; height: 26px; margin: 0; accent-color: var(--brand); flex: none; }
.check:has(input:checked) { border-color: var(--brand-line); background: #F6FCFE; }

/* ─── opciones grandes (radio) ─── */
.opciones { display: grid; gap: 10px; }
.opcion { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: var(--r); border: 1.5px solid var(--line-2); background: var(--card); cursor: pointer; min-height: 68px; text-align: left; width: 100%; }
.opcion .dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; display: grid; place-items: center; }
.opcion[aria-checked="true"] { border-color: var(--brand); background: #F3FBFD; box-shadow: 0 0 0 3px rgba(14, 116, 144, .12); }
.opcion[aria-checked="true"] .dot { border-color: var(--brand); }
.opcion[aria-checked="true"] .dot::after { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); }
.opcion b { display: block; font-size: 18px; }
.opcion small { display: block; color: var(--ink-3); font-size: 14px; line-height: 1.35; }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dos .opcion { justify-content: center; text-align: center; flex-direction: column; gap: 6px; padding: 18px 10px; }
.dos .opcion svg { width: 30px; height: 30px; color: var(--brand); }

/* ─── compras ─── */
.compras { display: grid; gap: 12px; }
.compra { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 14px 16px; border-radius: 20px; background: var(--card); border: 1.5px solid var(--line); box-shadow: var(--shadow); cursor: pointer; text-align: left; width: 100%; }
.compra:active { transform: scale(.985); }
.compra:focus-visible, .opcion:focus-visible, .btn:focus-visible, .back:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.cal { width: 64px; border-radius: 14px; overflow: hidden; text-align: center; border: 1px solid var(--line); background: #fff; }
.cal span { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: #fff; background: var(--brand); padding: 3px 0; }
.cal b { display: block; font-size: 26px; line-height: 1.3; }
.compra .det b { display: block; font-size: 17px; }
.compra .det small { display: block; color: var(--ink-3); font-size: 14px; }
.compra .monto { font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; text-align: right; }
.compra .monto small { display: block; font-size: 13px; font-weight: 500; color: var(--ink-3); }
.compra[disabled] { opacity: .62; box-shadow: none; cursor: default; }

/* ─── resumen ─── */
.resumen { background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.resumen .total { padding: 20px; background: linear-gradient(160deg, #0F1A2A, #12334A); color: #fff; }
.resumen .total small { color: #B9D8E4; font-size: 14px; display: block; }
.resumen .total b { font-size: 36px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.resumen .total .sub { color: #B9D8E4; font-size: 14px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.fila { display: flex; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--line); align-items: flex-start; }
.fila:first-of-type { border-top: 0; }
.fila .k { width: 108px; flex: none; color: var(--ink-3); font-size: 15px; padding-top: 1px; }
.fila .v { flex: 1; font-size: 17px; font-weight: 600; word-break: break-word; }
.fila .v small { display: block; font-weight: 400; color: var(--ink-3); font-size: 14px; }
.fila button { background: none; border: 0; color: var(--brand); font-weight: 650; font-size: 15px; padding: 2px 0 2px 8px; cursor: pointer; }

/* ─── botones ─── */
.acciones { position: sticky; bottom: 0; padding: 14px 0 calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--bg) 70%, rgba(243, 246, 250, 0)); margin-top: 20px; display: grid; gap: 10px; }
.btn { width: 100%; min-height: 60px; border-radius: 16px; border: 0; font-size: 19px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px; transition: transform .08s, background .15s, opacity .15s; }
.btn:active { transform: scale(.985); }
.btn.primario { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(14, 116, 144, .28); }
.btn.primario:active { background: var(--brand-press); }
.btn.secundario { background: var(--card); color: var(--ink); border: 1.5px solid var(--line-2); }
.btn.texto { background: none; color: var(--brand); min-height: 48px; font-size: 17px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn .spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

.aviso { display: flex; gap: 12px; padding: 14px 16px; border-radius: 16px; font-size: 16px; margin-bottom: 16px; align-items: flex-start; }
.aviso svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.aviso.error { background: var(--crit-soft); color: var(--crit); }
.aviso.info { background: var(--brand-soft); color: var(--brand-press); }
.aviso.prueba { background: #FFF4D6; color: #7A4B00; }

.vacio { text-align: center; padding: 28px 12px; }
.vacio .circ { width: 76px; height: 76px; border-radius: 50%; background: #EAF0F6; display: grid; place-items: center; margin: 8px auto 14px; color: var(--ink-3); }
.vacio .circ svg { width: 34px; height: 34px; }
.vacio p { color: var(--ink-2); margin: 0 0 6px; }

/* ─── listo ─── */
.listo { text-align: center; padding-top: 28px; }
.check-anim { width: 104px; height: 104px; margin: 6px auto 8px; border-radius: 50%; background: var(--ok-soft); display: grid; place-items: center; animation: pop .5s cubic-bezier(.22, 1, .36, 1); }
.check-anim svg { width: 56px; height: 56px; color: var(--ok); }
.check-anim path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: traza .45s .25s ease-out forwards; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes traza { to { stroke-dashoffset: 0; } }
.folio { display: inline-block; margin: 6px 0 18px; font-size: 15px; color: var(--ink-3); }
.folio b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ─── hoja (confirmación y aviso) ─── */
.velo { position: fixed; inset: 0; background: rgba(15, 26, 42, .45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: aparece .2s; }
.velo[hidden] { display: none; }
@keyframes aparece { from { opacity: 0; } }
.hoja { background: var(--card); width: 100%; max-width: 520px; border-radius: 26px 26px 0 0; padding: 10px 20px calc(20px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow: auto; animation: sube .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes sube { from { transform: translateY(40px); opacity: .5; } }
.hoja .asa { width: 44px; height: 5px; border-radius: 99px; background: var(--line-2); margin: 0 auto 12px; }
.hoja h2 { font-size: 24px; margin: 6px 0 8px; letter-spacing: -.01em; }
.hoja p { color: var(--ink-2); margin: 0 0 12px; }
.hoja .rfc-grande { font-size: 26px; font-weight: 750; letter-spacing: .06em; text-align: center; padding: 14px; border-radius: 16px; background: var(--brand-soft); color: var(--ink); margin: 8px 0 16px; word-break: break-all; }
.hoja.texto-largo { font-size: 16px; }
.hoja.texto-largo h3 { font-size: 17px; margin: 18px 0 6px; }
.hoja.texto-largo p, .hoja.texto-largo li { color: var(--ink-2); }
.hoja.texto-largo ul { padding-left: 20px; margin: 6px 0; }

footer.pie { text-align: center; font-size: 13px; color: var(--ink-3); padding: 8px 0 18px; }
footer.pie a { font-weight: 500; }

@media (min-width: 640px) {
  .app { padding: 0 24px; }
  h1 { font-size: 34px; }
  .velo { align-items: center; }
  .hoja { border-radius: 26px; }
}

/* ajustes tras revisar en 390 px */
h1:focus, h2:focus { outline: none; }
.hero .mark { width: 96px; right: 14px; bottom: auto; top: 14px; opacity: .22; border-radius: 22px; }
.brand span, .brand b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .k { width: 92px; }
.fila .v { word-break: normal; overflow-wrap: anywhere; }
.fila .v.rfc { letter-spacing: .02em; white-space: nowrap; }
.hero .mark { display: none; }
.fila .v { min-width: 0; }
.fila button { flex: none; }
.fila .v.rfc { font-size: 16px; letter-spacing: 0; }
