/* ============================================================
   FiscalView — Sistema visual «Azul noche»
   Marca: azul noche #0F1B35 (estructura y tinta) + índigo #5046E3
   (acción). Papel frío, filetes finos, cifras en monoespaciada.
   Firma: el resumen del comprobante se dibuja como un ticket.
   Fuentes auto-alojadas (OFL): Figtree e IBM Plex Mono.
   ============================================================ */
@font-face { font-family: "Figtree"; src: url("fonts/figtree-latin.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/plexmono-400-latin.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("fonts/plexmono-500-latin.woff2") format("woff2"); font-weight: 500 700; font-style: normal; font-display: swap; }

:root {
  /* Marca */
  --noche: #0F1B35;
  --noche-2: #17264A;
  --indigo: #5046E3;
  --indigo-hondo: #3F36C8;
  --indigo-tinta: #3A31B8;
  --indigo-velo: #EFEEFD;
  --indigo-borde: #CFCBF7;

  /* Papel y tinta (un solo matiz: el azul noche, solo cambia la luz) */
  --papel: #F4F5F9;
  --hoja: #FFFFFF;
  --hoja-2: #F8F9FC;
  --tinta: #0F1B35;
  --tinta-2: #3B4563;
  --tinta-3: #646D88;
  --tinta-4: #9A9FB4;
  --filete: rgba(15, 27, 53, .09);
  --filete-2: rgba(15, 27, 53, .15);
  --filete-3: rgba(15, 27, 53, .24);

  /* Campos: un punto más hundidos que la hoja */
  --campo: #FAFBFD;
  --campo-borde: rgba(15, 27, 53, .17);

  /* Estados de la constancia (CDR) */
  --ok: #0A6B43;  --ok-velo: #E9F6EF;  --ok-punto: #13A062;  --ok-borde: #BFE3CF;
  --obs: #865000; --obs-velo: #FFF5E1; --obs-punto: #DE9000; --obs-borde: #F3D9A6;
  --rech: #AE2216; --rech-velo: #FDEEEC; --rech-punto: #DF3B2A; --rech-borde: #F4C5BF;

  /* Forma */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
  --sombra-hoja: 0 1px 2px rgba(15, 27, 53, .04);
  --sombra-flota: 0 0 0 1px rgba(15, 27, 53, .06), 0 12px 24px -6px rgba(15, 27, 53, .16), 0 32px 64px -16px rgba(15, 27, 53, .22);
  --anillo: 0 0 0 3px rgba(80, 70, 227, .24);
  --ease: cubic-bezier(.23, 1, .32, 1);
  --ease-io: cubic-bezier(.77, 0, .175, 1);

  --sb-w: 248px; --tb-h: 64px; --bn-h: 64px;
  --font: "Figtree", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--papel);
  color: var(--tinta);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.012em; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.num { font-variant-numeric: tabular-nums; }
.dec { opacity: .55; }
.muted { color: var(--tinta-3); }
b, strong { font-weight: 600; }
svg.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::selection { background: rgba(80, 70, 227, .18); }
mark { background: rgba(80, 70, 227, .15); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: var(--r-sm);
  border: 1px solid var(--filete-2); background: var(--hoja); color: var(--tinta);
  font-size: 13.5px; font-weight: 600; line-height: 1; cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: 0 1px 2px rgba(15, 27, 53, .05);
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease, transform .12s var(--ease);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.btn .ic { width: 16px; height: 16px; }
.btn:hover { background: var(--hoja-2); border-color: var(--filete-3); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.primary { background: var(--indigo); border-color: var(--indigo); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 1px 2px rgba(31, 24, 140, .28); }
.btn.primary:hover:not(:disabled) { background: var(--indigo-hondo); border-color: var(--indigo-hondo); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--tinta-2); box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: rgba(15, 27, 53, .05); color: var(--tinta); }
.btn.danger { color: var(--rech); border-color: var(--rech-borde); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn.lg { height: 46px; font-size: 15px; padding: 0 18px; }
.btn.block { width: 100%; }
.btn.icon { width: 36px; height: 36px; padding: 0; }
.btn .cnt { font-family: var(--mono); font-size: 12px; font-weight: 500; background: rgba(255, 255, 255, .2); border-radius: 5px; padding: 3px 6px; margin-left: 1px; }

/* ---------- Campos ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .cli-set > legend { font-size: 12.5px; font-weight: 600; color: var(--tinta-2); }
.opt { font-weight: 500; color: var(--tinta-4); }
.input, .select {
  width: 100%; height: 40px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--campo-borde); background: var(--campo); color: var(--tinta);
  font-size: 14px; outline: none; min-width: 0;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.input::placeholder { color: var(--tinta-4); opacity: 1; }
.input:hover, .select:hover { border-color: var(--filete-3); }
.input:focus, .select:focus { border-color: var(--indigo); background: var(--hoja); box-shadow: var(--anillo); }
.input:disabled, .select:disabled { opacity: .6; cursor: not-allowed; }
.input.mono { font-family: var(--mono); font-size: 14px; }
.input.r { text-align: right; }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23646D88' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.hint { font-size: 12.5px; color: var(--tinta-3); line-height: 1.45; }
.hint.center { text-align: center; margin-top: 12px; }
.btn:focus-visible, .input-cell:focus-visible, .toggle:focus-visible, .chip:focus-visible, .dropzone:focus-visible,
.a-link:focus-visible, .doc-link:focus-visible, .nav a:focus-visible, .bottom-nav a:focus-visible, .confirm-dup input:focus-visible {
  outline: none; box-shadow: var(--anillo);
}
fieldset.cli-set { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
.cli-set > legend { padding: 0; margin-bottom: 6px; }

/* ---------- Pills de estado (constancia) ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px;
  border-radius: var(--r-xs); font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--hoja-2); color: var(--tinta-2); box-shadow: inset 0 0 0 1px var(--filete);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--tinta-4); flex: none; }
.pill.ok   { background: var(--ok-velo); color: var(--ok); box-shadow: inset 0 0 0 1px var(--ok-borde); }
.pill.ok .dot { background: var(--ok-punto); }
.pill.warn { background: var(--obs-velo); color: var(--obs); box-shadow: inset 0 0 0 1px var(--obs-borde); }
.pill.warn .dot { background: var(--obs-punto); }
.pill.err  { background: var(--rech-velo); color: var(--rech); box-shadow: inset 0 0 0 1px var(--rech-borde); }
.pill.err .dot { background: var(--rech-punto); }
.pill.info { background: var(--indigo-velo); color: var(--indigo-tinta); box-shadow: inset 0 0 0 1px var(--indigo-borde); }
.pill.info .dot { background: var(--indigo); }
.pill.idle .dot { background: var(--tinta-4); }

/* ---------- Ambiente ---------- */
.env-tag {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .02em;
  color: var(--obs); background: var(--obs-velo); box-shadow: inset 0 0 0 1px var(--obs-borde); white-space: nowrap;
}
.env-tag .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--obs-punto); box-shadow: 0 0 0 3px rgba(222, 144, 0, .18); }

/* ============================================================
   LOGIN
   ============================================================ */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(380px, 42%) 1fr; }
.auth-side {
  position: relative; overflow: hidden; background: var(--noche); color: #fff;
  display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding: 48px 56px;
}
.auth-side::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, .07) 1px, transparent 1.2px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(160deg, #000 0%, transparent 70%); mask-image: linear-gradient(160deg, #000 0%, transparent 70%);
}
.auth-side::after {
  content: ""; position: absolute; width: 520px; height: 520px; right: -220px; bottom: -200px; border-radius: 50%;
  border: 56px solid rgba(80, 70, 227, .16); pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }
.auth-logo { width: 196px; height: auto; }
.auth-claim { max-width: 400px; }
.auth-kicker { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #A9A3FF; margin-bottom: 14px; }
.auth-lead { font-size: 28px; line-height: 1.22; font-weight: 600; letter-spacing: -.02em; color: #fff; }
.auth-ticket {
  list-style: none; margin: 0; padding: 18px 20px; max-width: 360px;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .09); border-radius: var(--r-md);
}
.auth-ticket li { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; font-size: 13px; color: rgba(255, 255, 255, .72); }
.auth-ticket li + li { border-top: 1px dashed rgba(255, 255, 255, .14); }
.auth-ticket .mono { color: #fff; font-size: 12.5px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-logo-m { display: none; width: 168px; height: auto; margin-bottom: 32px; }
.auth-title { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.auth-sub { color: var(--tinta-3); margin: 6px 0 28px; }
.auth form { display: flex; flex-direction: column; gap: 18px; }
.auth .input { height: 44px; }
.auth .input.totp { letter-spacing: .32em; font-size: 15px; }
.auth form .btn { margin-top: 6px; }
.auth-foot { margin-top: 32px; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--tinta-3); }

/* ============================================================
   SHELL
   ============================================================ */
.shell { display: grid; grid-template-columns: var(--sb-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  background: var(--noche); color: rgba(255, 255, 255, .72);
  display: flex; flex-direction: column; padding: 20px 14px 14px;
}
.sb-brand { padding: 4px 10px 22px; }
.sb-brand img { width: 150px; height: auto; }
.ruc-selector {
  margin: 0 2px 22px; padding: 12px 14px; border-radius: var(--r-md);
  background: rgba(255, 255, 255, .045); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.ruc-selector .lab { font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: rgba(255, 255, 255, .45); }
.ruc-selector .razon { margin: 3px 0 2px; color: #fff; font-weight: 600; font-size: 13.5px; line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.ruc-selector .ruc { font-size: 12px; color: rgba(255, 255, 255, .6); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav .group { font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: rgba(255, 255, 255, .38); padding: 14px 12px 6px; }
.nav .group:first-child { padding-top: 0; }
.nav a {
  position: relative; display: flex; align-items: center; gap: 11px; height: 40px; padding: 0 12px;
  border-radius: var(--r-sm); color: rgba(255, 255, 255, .7); text-decoration: none; font-weight: 500; font-size: 14px;
  transition: background-color .15s ease, color .15s ease;
}
.nav a .ic { width: 18px; height: 18px; opacity: .8; }
.nav a:hover { background: rgba(255, 255, 255, .055); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .09); color: #fff; font-weight: 600; }
.nav a.active .ic { opacity: 1; color: #A9A3FF; }
.nav a.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--indigo); }
.sb-foot { display: flex; align-items: center; gap: 10px; padding: 12px 6px 4px; margin-top: 16px; border-top: 1px solid rgba(255, 255, 255, .08); }
.avatar { width: 32px; height: 32px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--indigo); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.sb-foot .who { flex: 1; min-width: 0; line-height: 1.25; }
.sb-foot .who b { display: block; color: #fff; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-foot .who span { font-size: 12px; color: rgba(255, 255, 255, .5); text-transform: capitalize; }
.sb-foot .btn.ghost { color: rgba(255, 255, 255, .6); }
.sb-foot .btn.ghost:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--tb-h);
  display: flex; align-items: center; gap: 12px; padding: 0 32px;
  background: var(--papel);
  border-bottom: 1px solid var(--filete);
}
.topbar .tb-tit { min-width: 0; }
.topbar .title { font-size: 18px; font-weight: 650; letter-spacing: -.015em; line-height: 1.2; }
.topbar .sub { font-size: 12.5px; color: var(--tinta-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.menu-btn, .tb-emblema { display: none; }
.tb-emblema { width: 28px; height: 28px; }
.canvas { padding: 28px 32px 56px; min-width: 0; }

/* Entrada suave al cambiar de sección */
.canvas.entrando > * { animation: entra .32s var(--ease) both; }
.canvas.entrando > *:nth-child(2) { animation-delay: .04s; }
.canvas.entrando > *:nth-child(3) { animation-delay: .08s; }
.canvas.entrando > *:nth-child(n+4) { animation-delay: .12s; }
@keyframes entra { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Tarjetas ---------- */
.card { background: var(--hoja); border: 1px solid var(--filete); border-radius: var(--r-md); box-shadow: var(--sombra-hoja); min-width: 0; }
.card-h { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 16px 20px; border-bottom: 1px solid var(--filete); min-height: 60px; }
.card-h h3 { font-size: 15px; font-weight: 650; }
.card-h .sub { font-size: 12.5px; color: var(--tinta-3); }
.card-h .sub.busy { display: inline-flex; align-items: center; gap: 6px; }
.card-h .spacer { flex: 1; }
.card-b { padding: 20px; }
.card-b.flush { padding: 0; }
.section-gap { margin-bottom: 20px; }
.divider { height: 1px; background: var(--filete); margin: 20px 0; }

/* ============================================================
   BOLETEADOR
   ============================================================ */
/* Inicio: carga del Excel + reglas al lado */
.inicio-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.inicio-grid > .card { margin-bottom: 0; }
.inicio-grid .reglas { grid-template-columns: 1fr; gap: 0; }
.inicio-grid .regla { padding: 14px 0; border-top: 1px solid var(--filete); }
.inicio-grid .regla:first-child { padding-top: 0; border-top: 0; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 44px 24px 36px; border-radius: var(--r-md); cursor: pointer;
  border: 1.5px dashed var(--filete-3); background: var(--hoja-2);
  transition: border-color .18s ease, background-color .18s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--indigo); background: #F6F5FE; }
.dropzone.drag .dz-hoja { transform: translateY(-4px) rotate(-2deg); }
.dropzone h4 { font-size: 18px; font-weight: 650; letter-spacing: -.015em; margin-top: 14px; }
.dropzone p { color: var(--tinta-3); font-size: 13.5px; }
.dropzone.busy { cursor: progress; padding: 64px 24px; }
.dz-hoja {
  position: relative; width: 60px; height: 74px; border-radius: 8px; background: var(--hoja);
  box-shadow: 0 0 0 1px var(--filete-2), 0 8px 18px -8px rgba(15, 27, 53, .3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--indigo);
  transition: transform .25s var(--ease);
}
.dz-hoja .ic { width: 24px; height: 24px; }
.dz-hoja span { font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: .06em; color: var(--tinta-3); }
.dz-btn { margin-top: 14px; pointer-events: none; }
.dz-cols { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 22px; }
.dz-cols span { font-size: 11.5px; padding: 3px 8px; border-radius: var(--r-xs); background: var(--hoja); color: var(--tinta-2); box-shadow: inset 0 0 0 1px var(--filete); }
.dz-nota { margin-top: 14px; }

/* Resumen del lote: tira tipo libro contable */
.stats {
  position: relative; display: grid; grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  background: var(--hoja); border: 1px solid var(--filete); border-radius: var(--r-md); box-shadow: var(--sombra-hoja);
  margin-bottom: 20px; overflow: hidden;
}
.stat { padding: 18px 20px; min-width: 0; }
.stat .lab { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--tinta-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .val { font-size: 24px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; margin: 6px 0 3px; font-variant-numeric: tabular-nums; }
.stat .val .de { font-size: 15px; font-weight: 500; color: var(--tinta-4); margin-left: 2px; }
.stat .stat-sub { font-size: 12px; color: var(--tinta-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.lead { background: var(--noche); color: #fff; display: flex; flex-direction: column; justify-content: center; }
.stat.lead .lab { color: rgba(255, 255, 255, .55); }
.stat.lead .val { font-size: 30px; margin: 8px 0 4px; }
.stat.lead .stat-sub { color: rgba(255, 255, 255, .62); }
.stat.lead .afect { color: #fff; font-weight: 600; }
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-grid .stat + .stat { box-shadow: inset 1px 0 0 var(--filete); }
.stat.pend .val { color: var(--indigo-tinta); }
.stat.bad .val { color: var(--rech); }
.stat.warn .val { color: var(--obs); }
.stat-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--filete); }
.stat-bar span { display: block; height: 100%; background: var(--indigo); transition: width .5s var(--ease); }
.por-fecha { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.por-fecha .lab { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--tinta-3); margin-right: 4px; }

/* Reglas */
.reglas { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; }
.regla { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.regla .hint { padding-left: 46px; }
.toggle {
  display: inline-flex; align-items: center; gap: 10px; min-height: 32px; padding: 0; border: 0; background: none;
  font-size: 14px; font-weight: 600; color: var(--tinta); cursor: pointer; text-align: left; border-radius: var(--r-sm);
}
.toggle[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.toggle .sw { position: relative; width: 36px; height: 20px; border-radius: 999px; background: #CDD1DD; flex: none; transition: background-color .2s ease; }
.toggle .sw::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(15, 27, 53, .3); transition: transform .22s var(--ease);
}
.toggle.on .sw { background: var(--indigo); }
.toggle.on .sw::after { transform: translateX(16px); }
.toggle:hover:not([aria-disabled="true"]) .sw { background: #BEC3D2; }
.toggle.on:hover:not([aria-disabled="true"]) .sw { background: var(--indigo-hondo); }
.regla-nota { display: flex; gap: 10px; align-items: flex-start; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--filete); font-size: 12.5px; color: var(--tinta-2); line-height: 1.5; }
.regla-nota .ic { width: 16px; height: 16px; color: var(--indigo); margin-top: 1px; }

/* Avisos */
.banners { display: flex; flex-direction: column; gap: 10px; }
.banner {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 10px;
  background: var(--hoja); color: var(--tinta); font-size: 13.5px; line-height: 1.5; box-shadow: inset 0 0 0 1px var(--filete-2);
}
.banner > .ic { width: 18px; height: 18px; margin-top: 1px; color: var(--tinta-3); }
.banner .banner-txt { flex: 1; min-width: 0; }
.banner .banner-det { margin-top: 4px; font-size: 12.5px; color: var(--tinta-2); overflow-wrap: anywhere; }
.banner b { font-weight: 650; }
.banner.info { background: var(--indigo-velo); box-shadow: inset 0 0 0 1px var(--indigo-borde); }
.banner.info > .ic { color: var(--indigo); }
.banner.warn { background: var(--obs-velo); box-shadow: inset 0 0 0 1px var(--obs-borde); }
.banner.warn > .ic { color: var(--obs-punto); }
.banner.err { background: var(--rech-velo); box-shadow: inset 0 0 0 1px var(--rech-borde); }
.banner.err > .ic { color: var(--rech-punto); }
.banner.ok { background: var(--ok-velo); box-shadow: inset 0 0 0 1px var(--ok-borde); }
.banner.ok > .ic { color: var(--ok-punto); }
.banner .btn.ghost { margin: -6px -6px -6px 0; color: var(--tinta-3); }
.banner .btn.sm:not(.ghost) { margin-left: 6px; height: 28px; }
.banner ul.avisos { margin: 0; padding-left: 18px; }
.banner ul.avisos li + li { margin-top: 2px; }

/* Lote */
.lote-tit { display: flex; align-items: center; gap: 10px; }
.lote-tit h3 .mono { font-weight: 500; }
.lote-arch { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lote-arch .arch { color: var(--tinta-2); font-weight: 500; }
.lote-acc { display: flex; align-items: center; gap: 8px; }
.emit-help { display: flex; align-items: flex-start; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--filete); background: var(--hoja-2); font-size: 12.5px; color: var(--tinta-2); }
.emit-help .ic { width: 15px; height: 15px; color: var(--obs-punto); margin-top: 1px; }
.emit-progress { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 20px; border-bottom: 1px solid var(--indigo-borde); background: var(--indigo-velo); font-size: 13px; font-weight: 600; color: var(--indigo-tinta); }
.emit-progress .muted { font-weight: 500; }
.lote-nota { padding: 12px 20px; border-bottom: 1px solid var(--filete); }
.lote-nota .nota-dni { display: inline-flex; align-items: center; gap: 6px; color: var(--obs); font-weight: 600; }
.lote-nota .nota-dni svg { width: 15px; height: 15px; flex: none; }
.sub-dato.sin-doc { color: var(--tinta-3); }
.cdr { font-size: 12.5px; color: var(--tinta-2); white-space: nowrap; }
.cdr.sin { color: var(--tinta-3); }
.mc-linea { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mc-cdr { font-size: 12px; color: var(--tinta-3); }

/* Tablas */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl thead th {
  position: sticky; top: 0; z-index: 1; text-align: left; white-space: nowrap;
  padding: 10px 14px; background: var(--hoja-2); border-bottom: 1px solid var(--filete);
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tinta-3);
}
.tbl thead th.r, .tbl td.r { text-align: right; }
.tbl tbody td { padding: 12px 14px; border-bottom: 1px solid var(--filete); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background-color .12s ease; }
.tbl tbody tr:hover { background: #FAFAFD; }
.tbl tbody tr > td:first-child { box-shadow: inset 3px 0 0 transparent; }
.tbl tbody tr.row-err { background: #FFFBFA; }
.tbl tbody tr.row-err > td:first-child { box-shadow: inset 3px 0 0 var(--rech-punto); }
.tbl tbody tr.row-warn > td:first-child { box-shadow: inset 3px 0 0 var(--obs-punto); }
.tbl tbody tr.row-done > td:first-child { box-shadow: inset 3px 0 0 var(--ok-punto); }
.tbl td.mono, .tbl td .mono { font-size: 12.5px; }
.tbl td.prod { min-width: 160px; max-width: 280px; font-weight: 500; }
.tbl.lote td { white-space: nowrap; }
.tbl.lote td.prod, .tbl.lote td:nth-child(9), .tbl.lote td:nth-child(10), .tbl.lote td.estado-celda { white-space: normal; }
.tbl .sub-dato, .mcard .sub-dato { font-size: 11.5px; color: var(--tinta-3); margin-top: 2px; }
.col-idx { width: 40px; color: var(--tinta-4); font-family: var(--mono); font-size: 12px; }
.cli-nom { font-weight: 500; min-width: 140px; max-width: 220px; }
.estado-celda { min-width: 170px; }
.est-num { margin-top: 6px; font-weight: 500; }
.est-msg { margin-top: 4px; font-size: 12px; color: var(--tinta-3); max-width: 260px; }
.estado-celda .row-actions, .mc-estado .row-actions { margin-top: 6px; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; }
.a-link {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 8px; border-radius: var(--r-xs);
  color: var(--indigo-tinta); font-size: 12.5px; font-weight: 600; text-decoration: none; white-space: nowrap;
  background: none; border: 0; cursor: pointer; transition: background-color .12s ease;
}
.a-link .ic { width: 14px; height: 14px; }
.a-link:hover { background: var(--indigo-velo); }
button.a-link { font-family: inherit; }

/* Marcas */
.marks { display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--filete-2); background: var(--hoja); color: var(--tinta-2); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip.mark {
  height: auto; min-height: 22px; padding: 2px 7px; border-radius: var(--r-xs); font-size: 11.5px; font-weight: 600; cursor: default;
  white-space: normal; line-height: 1.35; background: var(--hoja-2); border-color: var(--filete);
}
.chip.mark.warn { background: var(--obs-velo); border-color: var(--obs-borde); color: var(--obs); }
.chip.mark.err  { background: var(--rech-velo); border-color: var(--rech-borde); color: var(--rech); }
.chip.mark.info { background: var(--indigo-velo); border-color: var(--indigo-borde); color: var(--indigo-tinta); }
.chip.mark.anul { gap: 5px; background: #EEF0F5; border-color: var(--filete-2); color: var(--tinta-2); }
.chip.mark.anul .ic { width: 13px; height: 13px; }
.chip.mark.anul b { color: var(--tinta); font-weight: 500; }
.mark-det { margin-top: 4px; font-size: 11.5px; color: var(--tinta-3); }
.confirm-dup { display: inline-flex; align-items: center; gap: 8px; margin-top: 6px; min-height: 32px; padding: 0 10px 0 8px; border-radius: var(--r-sm); font-size: 12.5px; font-weight: 600; color: var(--tinta); cursor: pointer; white-space: nowrap; background: var(--hoja); box-shadow: inset 0 0 0 1px var(--filete-2); }
.confirm-dup:hover { box-shadow: inset 0 0 0 1px var(--indigo); }
.confirm-dup input { width: 16px; height: 16px; margin: 0; accent-color: var(--indigo); cursor: pointer; }
.confirm-dup input:disabled { cursor: not-allowed; }

/* Documento del cliente (edición en la tabla) */
.doc-link {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; height: 26px; padding: 0 6px 0 4px; border-radius: var(--r-xs);
  border: 0; background: none; color: var(--indigo-tinta); font-size: 12px; font-weight: 600; cursor: pointer;
}
.doc-link:hover:not(:disabled) { background: var(--indigo-velo); }
.doc-link:disabled { opacity: .45; cursor: not-allowed; }
.doc-link .ic, .doc-btn .ic { width: 14px; height: 14px; }
.btn.doc-btn.urgente { margin-top: 6px; color: var(--rech); border-color: var(--rech-borde); background: var(--rech-velo); }
.btn.doc-btn.urgente:hover:not(:disabled) { background: #FBE2DE; border-color: var(--rech-punto); }
.doc-edit { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; min-width: 190px; }
.doc-edit .input { height: 34px; }
.doc-edit .input[aria-invalid="true"] { border-color: var(--rech-punto); box-shadow: 0 0 0 3px rgba(223, 59, 42, .14); }
.doc-acc { display: flex; gap: 6px; }
.doc-err { font-size: 12px; color: var(--rech); font-weight: 600; }
.doc-ayuda { font-size: 11.5px; color: var(--tinta-3); }

/* ============================================================
   EMISIÓN UNITARIA (POS) y NOTA DE CRÉDITO
   ============================================================ */
.pos-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; max-width: 1180px; }
.resumen { position: sticky; top: calc(var(--tb-h) + 20px); }
.pos-top { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.pos-serie-ayuda { margin: -12px 0 20px; text-align: right; }
.serie-field { width: 120px; }
.serie-field .input { text-transform: uppercase; text-align: center; letter-spacing: .06em; }

/* Control segmentado del tipo de comprobante */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips.seg { display: inline-flex; flex-wrap: nowrap; gap: 2px; padding: 3px; border-radius: 10px; background: #ECEEF4; box-shadow: inset 0 0 0 1px var(--filete); max-width: 100%; }
.chips.seg .chip { height: 34px; padding: 0 14px; border: 0; border-radius: 7px; background: transparent; color: var(--tinta-3); font-weight: 600; transition: background-color .18s ease, color .18s ease, box-shadow .18s ease; }
.chips.seg .chip:hover:not(.on) { color: var(--tinta); }
.chips.seg .chip.on { background: var(--hoja); color: var(--tinta); box-shadow: 0 1px 2px rgba(15, 27, 53, .12), 0 0 0 1px var(--filete); }

.cli-row { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 8px; }
#pos-ruc-nota { margin-top: 6px; min-height: 18px; }
.ruc-nota { display: inline-flex; align-items: center; gap: 6px; }
.ruc-nota .ic { width: 14px; height: 14px; }
.ruc-nota.ok { color: var(--ok); }
.ruc-nota.warn { color: var(--obs); }

.items { border-top: 1px solid var(--filete); padding-top: 16px; }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr) 84px 128px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.item-row.item-head { margin-bottom: 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tinta-3); }
.item-row.item-head .r { text-align: right; }
.item-row .m-lab { display: none; }
.item-row .btn.icon { color: var(--tinta-3); }
.item-row .btn.icon:hover:not(:disabled) { color: var(--rech); background: var(--rech-velo); }
.add-item { margin-top: 2px; color: var(--indigo-tinta); }
.add-item:hover:not(:disabled) { background: var(--indigo-velo) !important; color: var(--indigo-hondo) !important; }

/* Firma: el resumen se imprime como un ticket térmico */
.ticket {
  position: relative; padding: 18px 18px 26px; background: var(--hoja-2);
  border-radius: 10px 10px 0 0; box-shadow: inset 0 0 0 1px var(--filete);
  -webkit-mask: radial-gradient(circle 5px at 50% 100%, transparent 96%, #000 100%) 0 0 / 14px 100% repeat-x;
  mask: radial-gradient(circle 5px at 50% 100%, transparent 96%, #000 100%) 0 0 / 14px 100% repeat-x;
}
.ticket.vacio { padding: 22px 18px 30px; }
.totbox .ln { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 4px 0; font-size: 13.5px; color: var(--tinta-2); }
.totbox .ln .mono { color: var(--tinta); font-size: 13.5px; }
.totbox .ln.grand { margin-top: 10px; padding-top: 14px; border-top: 1px dashed var(--filete-3); align-items: center; }
.totbox .ln.grand > span:first-child { font-size: 11.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--tinta); }
.totbox .ln.grand .mono { font-size: 26px; font-weight: 500; letter-spacing: -.03em; }
.regla-pos { margin: 4px 0 14px; }
.aviso-exo { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 14px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--obs-velo); color: var(--obs); box-shadow: inset 0 0 0 1px var(--obs-borde); font-size: 12.5px; line-height: 1.45; animation: entra .24s var(--ease) both; }
.aviso-exo .ic { width: 16px; height: 16px; margin-top: 1px; }
.aviso-exo.err { background: var(--rech-velo); color: var(--rech); box-shadow: inset 0 0 0 1px var(--rech-borde); }

/* Nota de crédito */
.nc-q-row { display: flex; gap: 8px; }
.nc-q-row .input { max-width: 240px; text-transform: uppercase; letter-spacing: .04em; }
.nc-vacio { padding: 36px 16px !important; }
.nc-orig { padding: 16px; border-radius: var(--r-md); background: var(--hoja-2); box-shadow: inset 0 0 0 1px var(--filete); }
.nc-orig-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px dashed var(--filete-2); }
.nc-orig-h b.mono { font-size: 18px; font-weight: 500; }
.mc-k { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tinta-3); }
.nc-orig .kv dd { min-width: 0; overflow-wrap: anywhere; }
.nc-nota { margin: 10px 0 12px; }
.nc-items { display: flex; flex-direction: column; border-top: 1px solid var(--filete); }
.nc-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--filete); }
.nc-item:last-child { border-bottom: 0; padding-bottom: 0; }
.nc-desc { font-weight: 500; }
.nc-imp { white-space: nowrap; }
.nc-campos { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 14px; margin-top: 20px; }
.nc-campos .full { grid-column: 1 / -1; }
.nc-campos .serie-field { width: auto; }

.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 8px 14px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--tinta-3); }
.kv dd { margin: 0; color: var(--tinta); min-width: 0; }
.dl-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ============================================================
   HISTORIAL y EMPRESAS
   ============================================================ */
.filters-bar { border-bottom: 1px solid var(--filete); padding: 14px 20px; }
.filters { display: grid; grid-template-columns: minmax(0, 1fr) 200px 220px; gap: 8px; }
.search-box { position: relative; display: block; min-width: 0; }
.search-box .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--tinta-4); pointer-events: none; }
.search-box .input { padding-left: 38px; }
.hist-tbl td.sn, .mcard .sn { font-weight: 500; font-size: 13px; }
.hist-tbl td { white-space: nowrap; }
.hist-tbl td.monto { font-weight: 500; }
.est-pila { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
tr.anulado .monto, .mcard.anulado .monto { text-decoration: line-through; text-decoration-color: var(--tinta-4); color: var(--tinta-3); }
.hist-more { display: flex; flex-direction: column; align-items: center; gap: 6px; border-top: 1px solid var(--filete); padding: 14px 20px; }
.hist-more:empty { display: none; }

.emp-busca { display: flex; flex-direction: column; gap: 8px; border-bottom: 1px solid var(--filete); }
.emp-busca .search-box .input { height: 46px; font-size: 15px; }
.emp-busca .search-box .ic { width: 19px; height: 19px; left: 13px; }
.emp-tbl td { vertical-align: middle; }
.emp-ruc { white-space: nowrap; }
.emp-ruc .chip.mark, .emp-m .chip.mark { margin-left: 8px; }
.emp-razon { font-weight: 500; }
.emp-m { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; }

/* Vacíos */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 56px 24px; text-align: center; color: var(--tinta-2); font-size: 13.5px; }
.empty > .ic { width: 22px; height: 22px; padding: 14px; box-sizing: content-box; border-radius: 50%; background: var(--hoja-2); color: var(--tinta-3); box-shadow: inset 0 0 0 1px var(--filete); }

/* ---------- Tarjetas móviles ---------- */
.mobile-cards { display: none; }
.mcard { padding: 14px; border-radius: var(--r-md); background: var(--hoja); box-shadow: inset 0 0 0 1px var(--filete), var(--sombra-hoja); position: relative; overflow: hidden; }
.mcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; }
.mcard.row-err::before { background: var(--rech-punto); }
.mcard.row-warn::before { background: var(--obs-punto); }
.mcard.row-done::before { background: var(--ok-punto); }
.mcard .mc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.mcard .mc-top > div { min-width: 0; }
.mcard .mc-top b { display: block; margin-top: 2px; font-size: 14.5px; overflow-wrap: anywhere; }
.mcard .mc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--filete-2); }
.mcard .mc-grid .mono { font-size: 13.5px; }
.mcard .mc-marcas { margin-top: 10px; }
.mcard .mc-estado { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--filete); }
.mcard .mc-anulado { margin-top: 8px; }
.mcard .dl-row { margin-top: 10px; gap: 2px 4px; }
.mcard .emp-razon { margin-top: 8px; overflow-wrap: anywhere; }

/* ============================================================
   CAPAS: panel lateral, cortina, avisos flotantes
   ============================================================ */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15, 27, 53, .42); animation: fade .2s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sidepanel {
  position: fixed; top: 0; right: 0; z-index: 61; width: 460px; max-width: 100vw; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; background: var(--hoja); box-shadow: var(--sombra-flota);
  animation: slidein .32s var(--ease) both;
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sidepanel .sp-h { display: flex; align-items: center; gap: 12px; padding: 16px 16px 16px 24px; border-bottom: 1px solid var(--filete); }
.sidepanel .sp-h h3 { flex: 1; font-size: 16px; }
.sidepanel .sp-b { flex: 1; overflow-y: auto; padding: 24px; }
.emitido-h { display: flex; flex-direction: column; gap: 4px; margin-bottom: 18px; }
.emitido-h b.mono { font-size: 28px; font-weight: 500; letter-spacing: -.03em; }

.toast-stack { position: fixed; right: 24px; bottom: 24px; z-index: 90; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; max-width: 420px; padding: 12px 16px; border-radius: 10px;
  background: var(--noche); color: #fff; font-size: 13.5px; font-weight: 500; line-height: 1.45; box-shadow: var(--sombra-flota);
  pointer-events: auto; animation: toastin .3s var(--ease) both;
}
.toast .ic { width: 17px; height: 17px; margin-top: 1px; color: #A9A3FF; }
.toast.ok .ic { color: #5BD69B; }
.toast.err .ic { color: #FF8A7A; }
@keyframes toastin { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* Indicadores de carga */
.spin { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: sp .7s linear infinite; flex: none; vertical-align: -2px; }
.spin.dark { border-color: rgba(80, 70, 227, .2); border-top-color: var(--indigo); }
.spin.big { width: 30px; height: 30px; border-width: 3px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- Navegación inferior (celular) ---------- */
.bottom-nav { display: none; }

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 1240px) {
  .stats { grid-template-columns: 1fr; }
  .stat.lead { flex-direction: row; flex-wrap: wrap; align-items: baseline; justify-content: flex-start; column-gap: 16px; }
  .stat.lead .lab { flex-basis: 100%; }
  .stat.lead .val { margin: 6px 0 0; }
  .stat-grid { box-shadow: inset 0 1px 0 var(--filete); }
}
@media (max-width: 1100px) {
  .inicio-grid { grid-template-columns: 1fr; }
  .inicio-grid .reglas { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; }
  .inicio-grid .regla { padding: 0; border-top: 0; }
  .pos-grid { grid-template-columns: minmax(0, 1fr) 320px; }
}

@media (max-width: 920px) {
  :root { --tb-h: 56px; }
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 70; left: 0; top: 0; width: 288px; max-width: 86vw; transform: translateX(-100%); transition: transform .3s var(--ease); }
  .sidebar.open { transform: none; box-shadow: var(--sombra-flota); }
  .nav a.active::before { left: -14px; }
  .menu-btn { display: inline-flex; margin-left: -8px; }
  .tb-emblema { display: block; }
  .topbar { padding: 0 16px; gap: 10px; }
  .topbar .title { font-size: 16.5px; }
  .topbar .sub { display: none; }
  .env-tag .env-x { display: none; }
  .canvas { padding: 20px 16px calc(var(--bn-h) + 32px + env(safe-area-inset-bottom)); }
  .reglas, .inicio-grid .reglas { grid-template-columns: 1fr; gap: 16px; }
  .pos-grid { grid-template-columns: 1fr; }
  .resumen { position: static; }
  .sidepanel { width: 100vw; }
  .toast-stack { left: 16px; right: 16px; bottom: calc(var(--bn-h) + 12px + env(safe-area-inset-bottom)); align-items: stretch; }
  .toast { max-width: none; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .search-box { grid-column: 1 / -1; }

  .bottom-nav {
    display: flex; position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
    height: calc(var(--bn-h) + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: #fff;
    border-top: 1px solid var(--filete);
  }
  .bottom-nav a {
    position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    color: var(--tinta-3); text-decoration: none; font-size: 11.5px; font-weight: 600; border-radius: var(--r-sm);
    -webkit-user-select: none; user-select: none; touch-action: manipulation;
  }
  .bottom-nav a .ic { width: 22px; height: 22px; transition: transform .2s var(--ease); }
  .bottom-nav a:active .ic { transform: scale(.92); }
  .bottom-nav a.active { color: var(--indigo); }
  .bottom-nav a.active::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--indigo); }

  /* Blancos táctiles de al menos 44 px */
  .btn, .btn.sm, .btn.icon { min-height: 44px; }
  .btn.icon { width: 44px; height: 44px; }
  .btn.sm { height: 44px; padding: 0 14px; font-size: 13.5px; }
  .input, .select { height: 44px; font-size: 16px; }
  .input.mono { font-size: 16px; }
  .toggle { min-height: 44px; }
  .chips.seg .chip { height: 44px; }
  .a-link { min-height: 44px; padding: 0 10px; font-size: 13px; }
  .doc-link { min-height: 44px; padding: 0 10px 0 6px; margin-top: 2px; font-size: 13px; }
  .confirm-dup { min-height: 44px; padding: 0 14px 0 12px; font-size: 13px; }
  .confirm-dup input { width: 20px; height: 20px; }
  .nav a { height: 44px; }
  .doc-edit .input { height: 44px; }
  .nc-q-row .input { max-width: none; }
}

@media (max-width: 560px) {
  .canvas { padding-top: 16px; }
  .card-h { padding: 14px 16px; min-height: 0; }
  .card-b { padding: 16px; }
  .filters-bar { padding: 12px 16px; }
  .filters { grid-template-columns: 1fr; }
  .stat { padding: 14px 16px; }
  .stat.lead .val { font-size: 26px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid .stat { box-shadow: inset 0 -1px 0 var(--filete) !important; }
  .stat-grid .stat:nth-child(even) { box-shadow: inset 1px 0 0 var(--filete), inset 0 -1px 0 var(--filete) !important; }
  .stat-grid .stat:last-child { grid-column: 1 / -1; box-shadow: none !important; }
  .stat .val { font-size: 21px; }
  .dropzone { padding: 32px 16px 28px; }
  .dropzone h4 { font-size: 17px; }
  .dz-btn { width: 100%; max-width: 280px; }
  .lote-tit { width: 100%; justify-content: space-between; }
  .lote-arch { flex-basis: 100%; }
  .lote-acc { width: 100%; }
  .lote-acc .btn { flex: 1; padding: 0 10px; }
  .lote-acc #btn-emitir { flex: 1.5; }
  .card-h .spacer { display: none; }
  .emit-help, .emit-progress, .lote-nota { padding-left: 16px; padding-right: 16px; }
  .pos-top { flex-direction: column; align-items: stretch; }
  .chips.seg { display: flex; }
  .chips.seg .chip { flex: 1; padding: 0 8px; }
  .serie-field { width: 100%; }
  .serie-field .input { text-align: left; }
  .pos-serie-ayuda { margin: -12px 0 18px; text-align: left; }
  .cli-row { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; grid-template-areas: "desc desc desc" "cant precio del"; row-gap: 8px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px dashed var(--filete-2); }
  .item-row .f-desc { grid-area: desc; }
  .item-row .f-cant { grid-area: cant; }
  .item-row .f-precio { grid-area: precio; }
  .item-row .btn.icon { grid-area: del; }
  .item-row.item-head { display: none; }
  .item-row { align-items: end; }
  .item-row .field { gap: 4px; }
  .item-row .m-lab { display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tinta-3); }
  .item-row .f-cant .m-lab, .item-row .f-precio .m-lab { text-align: right; }
  .nc-campos { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 100px minmax(0, 1fr); }
  .tbl-responsive table.tbl { display: none; }
  .mobile-cards { display: grid; gap: 10px; }
  #hist-body .mobile-cards, #emp-body .mobile-cards { padding: 12px; }
  .card.tbl-responsive + .mobile-cards { margin-top: 12px; }
  .auth-foot { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-main { align-items: flex-start; padding: 56px 20px 32px; }
  .auth-logo-m { display: block; }
  .auth .input { font-size: 16px; }
}

/* Táctil sin hover: evita estados pegados */
@media (hover: none) {
  .btn:hover { background: var(--hoja); border-color: var(--filete-2); }
  .btn.ghost:hover { background: transparent; }
  .btn.primary:hover { background: var(--indigo); border-color: var(--indigo); }
  .tbl tbody tr:hover { background: inherit; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .spin { animation-duration: 1.2s !important; animation-iteration-count: infinite !important; }
  .btn:active:not(:disabled) { transform: none; }
}

/* ---------- Ajustes de densidad (tabla del lote e historial) ---------- */
.docs-pdf { display: inline-flex; align-items: center; gap: 0; margin-right: 2px; color: var(--tinta-3); }
.docs-pdf > .ic { width: 14px; height: 14px; margin-right: 4px; }
.docs-lab { font-size: 11px; font-weight: 600; letter-spacing: .06em; color: var(--tinta-3); margin-right: 2px; }
.a-link.fmt { padding: 0 6px; font-family: var(--mono); font-size: 12px; font-weight: 500; }
.hist-tbl td { vertical-align: middle; }
.hist-tbl .row-actions { flex-wrap: nowrap; }
.tbl.lote thead th, .tbl.lote tbody td { padding-left: 11px; padding-right: 11px; }
.tbl.lote td.prod { min-width: 120px; max-width: 220px; }
.tbl.lote .cli-nom { min-width: 120px; max-width: 190px; }
.tbl.lote .marks { max-width: 200px; }
.tbl.lote .estado-celda { min-width: 150px; }
@media (min-width: 921px) and (max-width: 1360px) { .canvas { padding-left: 24px; padding-right: 24px; } }
@media (max-width: 920px) { .hist-tbl .row-actions { flex-wrap: wrap; } }
@media (max-width: 920px) { .a-link.fmt { min-width: 44px; justify-content: center; } }
#pos-ruc-nota:empty { display: none; }
