/* ==========================================================================
   El Michi — sistema de interfaz
   Tokens tomados de assets/brand/tokens/brand.css
   Mobile-first: el mostrador se usa con el celular en una mano.
   ========================================================================== */

:root {
  --rojo:    #D93A32;
  --rojo-osc:#B12F28;
  --amarillo:#F5B82E;
  --crema:   #FFF4DD;
  --cacao:   #2A211C;
  --coral:   #EF6B5E;

  --ok:    #287A4B;
  --info:  #277DA1;
  --warn:  #C96A16;
  --error: #B42318;

  --bg:        #FBF3E4;
  --superficie:#FFFFFF;
  --superficie-2:#FFFAF0;
  --texto:     var(--cacao);
  --suave:     #6B625C;
  --borde:     #E4D9C8;
  --borde-2:   #F0E7D8;

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 24px;
  --r-full: 999px;

  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  --sombra-sm: 0 1px 3px rgba(42,33,28,.08);
  --sombra:    0 4px 14px rgba(42,33,28,.10);
  --sombra-md: 0 10px 30px rgba(42,33,28,.14);
  --sombra-lg: 0 24px 60px rgba(42,33,28,.20);

  --t: 200ms cubic-bezier(.2,.8,.2,1);
  --fuente: "Nunito Sans", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;

  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    --bg: #17120F;
    --superficie: #241C18;
    --superficie-2: #2E241E;
    --texto: #FFF4DD;
    --suave: #BDB0A3;
    --borde: #45372F;
    --borde-2: #362B24;
    --sombra-sm: 0 1px 3px rgba(0,0,0,.4);
    --sombra: 0 4px 14px rgba(0,0,0,.45);
    --sombra-md: 0 10px 30px rgba(0,0,0,.5);
  }
}
:root[data-tema="oscuro"] {
  --bg: #17120F;
  --superficie: #241C18;
  --superficie-2: #2E241E;
  --texto: #FFF4DD;
  --suave: #BDB0A3;
  --borde: #45372F;
  --borde-2: #362B24;
}

@media (prefers-reduced-motion: reduce) {
  :root { --t: 0ms; }
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ------------------------------------------------------------------ base -- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--fuente);
  font-size: 16px;
  line-height: 1.5;
  color: var(--texto);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, h4 { margin: 0; font-weight: 800; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 var(--s-3); }
a  { color: var(--rojo); text-decoration: none; }
a:hover { text-decoration: underline; }

/* `height: auto` es obligatorio: sin él, el atributo height del HTML fija la
   altura y la imagen se aplasta cuando el ancho lo limita el CSS o la pantalla.
   Con esto, la proporción real del archivo siempre gana. */
img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}
svg { display: block; max-width: 100%; }

button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--rojo) 55%, transparent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: color-mix(in srgb, var(--amarillo) 55%, transparent); }

.oculto { display: none !important; }
.solo-lectores {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------- iconos --- */

.i { width: 22px; height: 22px; flex: 0 0 auto; stroke-width: 1.8; }
.i-sm { width: 18px; height: 18px; }
.i-lg { width: 28px; height: 28px; }

/* ------------------------------------------------------------- botones --- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 11px 18px;
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  background: var(--superficie);
  color: var(--texto);
  font-weight: 700; font-size: .95rem;
  cursor: pointer;
  transition: transform var(--t), background var(--t), border-color var(--t), box-shadow var(--t);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  min-height: 46px;
}
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primario { background: var(--rojo); color: #fff; box-shadow: var(--sombra-sm); }
.btn-primario:hover:not(:disabled) { background: var(--rojo-osc); }

.btn-acento { background: var(--amarillo); color: var(--cacao); }
.btn-acento:hover:not(:disabled) { filter: brightness(.95); }

.btn-borde { border-color: var(--borde); background: var(--superficie); }
.btn-borde:hover:not(:disabled) { border-color: var(--rojo); color: var(--rojo); }

.btn-fantasma { background: transparent; }
.btn-fantasma:hover:not(:disabled) { background: var(--superficie-2); }

.btn-peligro { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error); }
.btn-peligro:hover:not(:disabled) { background: var(--error); color: #fff; }

.btn-bloque { width: 100%; }
.btn-grande { min-height: 56px; font-size: 1.05rem; padding: 14px 22px; border-radius: var(--r-lg); }
.btn-chico  { min-height: 36px; padding: 6px 12px; font-size: .85rem; border-radius: var(--r-sm); }
.btn-icono  { padding: 0; width: 46px; min-height: 46px; border-radius: var(--r-md); }
.btn-icono.btn-chico { width: 36px; min-height: 36px; }

/* --------------------------------------------------------------- campos --- */

.campo { display: block; margin-bottom: var(--s-4); }
.campo > .etiqueta {
  display: block; margin-bottom: 6px;
  font-size: .82rem; font-weight: 700; color: var(--suave);
  letter-spacing: .01em;
}
.campo .ayuda { display: block; margin-top: 5px; font-size: .78rem; color: var(--suave); }
.campo .error-txt { display: block; margin-top: 5px; font-size: .8rem; color: var(--error); font-weight: 700; }

.entrada, .selector, textarea.entrada {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--borde);
  border-radius: var(--r-md);
  background: var(--superficie);
  color: var(--texto);
  transition: border-color var(--t), box-shadow var(--t);
  min-height: 48px;
}
textarea.entrada { min-height: 88px; resize: vertical; }
.entrada::placeholder { color: color-mix(in srgb, var(--suave) 70%, transparent); }
.entrada:focus, .selector:focus {
  outline: none;
  border-color: var(--rojo);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--rojo) 14%, transparent);
}
.entrada[aria-invalid="true"] { border-color: var(--error); }
.entrada-plata { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.15rem; }
.entrada-grande { min-height: 58px; font-size: 1.15rem; font-weight: 700; }

.selector {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B625C' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 38px;
}

.con-prefijo { position: relative; }
.con-prefijo .prefijo {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--suave); font-weight: 800; pointer-events: none;
}
.con-prefijo .entrada { padding-left: 32px; }

.interruptor { display: flex; align-items: center; gap: var(--s-3); cursor: pointer; padding: var(--s-2) 0; }
.interruptor input { position: absolute; opacity: 0; width: 0; height: 0; }
.interruptor .pista {
  width: 46px; height: 27px; border-radius: var(--r-full);
  background: var(--borde); position: relative; transition: background var(--t); flex: 0 0 auto;
}
.interruptor .pista::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 21px; height: 21px; border-radius: 50%; background: #fff;
  transition: transform var(--t); box-shadow: var(--sombra-sm);
}
.interruptor input:checked + .pista { background: var(--ok); }
.interruptor input:checked + .pista::after { transform: translateX(19px); }
.interruptor input:focus-visible + .pista { outline: 3px solid color-mix(in srgb, var(--rojo) 55%, transparent); outline-offset: 2px; }

.segmentado {
  display: flex; gap: 4px; padding: 4px;
  background: var(--superficie-2); border: 1.5px solid var(--borde-2);
  border-radius: var(--r-md); overflow-x: auto; scrollbar-width: none;
}
.segmentado::-webkit-scrollbar { display: none; }
.segmentado button {
  flex: 1 1 auto; white-space: nowrap;
  padding: 9px 14px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--suave); font-weight: 700; font-size: .88rem;
  cursor: pointer; transition: background var(--t), color var(--t);
}
.segmentado button[aria-selected="true"] { background: var(--superficie); color: var(--texto); box-shadow: var(--sombra-sm); }

/* -------------------------------------------------------------- tarjetas -- */

.tarjeta {
  background: var(--superficie);
  border: 1.5px solid var(--borde-2);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--sombra-sm);
}
.tarjeta-plana { box-shadow: none; }
.tarjeta-cabecera {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.tarjeta-cabecera h2, .tarjeta-cabecera h3 { margin: 0; }

.rejilla { display: grid; gap: var(--s-4); }
.rejilla-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.rejilla-auto { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
@media (min-width: 760px) {
  .rejilla-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .rejilla-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
}

/* ------------------------------------------------------------ indicadores - */

.kpi {
  background: var(--superficie);
  border: 1.5px solid var(--borde-2);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  display: flex; flex-direction: column; gap: 2px;
  position: relative; overflow: hidden;
}
.kpi::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--rojo);
}
.kpi.kpi-ok::before   { background: var(--ok); }
.kpi.kpi-warn::before { background: var(--amarillo); }
.kpi.kpi-info::before { background: var(--info); }
.kpi .kpi-titulo { font-size: .78rem; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; }
.kpi .kpi-valor  { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .kpi-pie    { font-size: .82rem; color: var(--suave); display: flex; align-items: center; gap: 5px; }

.delta { font-weight: 800; font-size: .82rem; display: inline-flex; align-items: center; gap: 3px; }
.delta.sube  { color: var(--ok); }
.delta.baja  { color: var(--error); }
.delta.igual { color: var(--suave); }

/* --------------------------------------------------------------- píldoras - */

.pildora {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-full);
  font-size: .76rem; font-weight: 800; letter-spacing: .01em;
  background: var(--superficie-2); color: var(--suave);
  border: 1px solid var(--borde-2);
}
.pildora-ok    { background: color-mix(in srgb, var(--ok) 14%, transparent);    color: var(--ok);    border-color: transparent; }
.pildora-warn  { background: color-mix(in srgb, var(--warn) 16%, transparent);  color: var(--warn);  border-color: transparent; }
.pildora-error { background: color-mix(in srgb, var(--error) 12%, transparent); color: var(--error); border-color: transparent; }
.pildora-info  { background: color-mix(in srgb, var(--info) 12%, transparent);  color: var(--info);  border-color: transparent; }
.pildora-marca { background: color-mix(in srgb, var(--amarillo) 30%, transparent); color: #7a5405; border-color: transparent; }

/* ---------------------------------------------------------------- listas -- */

.lista { display: flex; flex-direction: column; gap: var(--s-2); }
.lista-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--superficie);
  border: 1.5px solid var(--borde-2);
  border-radius: var(--r-md);
  transition: border-color var(--t), transform var(--t);
  text-align: left; width: 100%;
  cursor: pointer;
}
button.lista-item { font: inherit; color: inherit; }
.lista-item:hover { border-color: var(--rojo); }
.lista-item:active { transform: scale(.99); }
.lista-item .crece { flex: 1 1 auto; min-width: 0; }
.lista-item .titulo { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-item .sub { font-size: .82rem; color: var(--suave); }
.lista-item .plata { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }

.avatar-emoji {
  width: 42px; height: 42px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 1.3rem;
  background: var(--superficie-2); border-radius: var(--r-md);
  border: 1.5px solid var(--borde-2);
}

/* --------------------------------------------------------------- tablas --- */

.tabla-envoltura { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-md); }
table.tabla { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 480px; }
table.tabla th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--suave); font-weight: 800; padding: 10px 12px;
  border-bottom: 2px solid var(--borde-2); white-space: nowrap;
}
table.tabla td { padding: 11px 12px; border-bottom: 1px solid var(--borde-2); }
table.tabla tbody tr:last-child td { border-bottom: 0; }
table.tabla tbody tr:hover { background: var(--superficie-2); }
table.tabla .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ------------------------------------------------------------ estructura -- */

.app { min-height: 100dvh; display: flex; flex-direction: column; }

.barra-sup {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--borde-2);
  min-height: 60px;
}
.barra-sup .marca { display: flex; align-items: center; gap: var(--s-2); font-weight: 800; }
.barra-sup .marca img { width: 32px; height: 32px; border-radius: 9px; }
.barra-sup .crece { flex: 1; }

.contenido { flex: 1; padding: var(--s-4); padding-bottom: calc(var(--nav-h) + var(--safe-b) + var(--s-6)); }
.contenido > * + * { margin-top: var(--s-4); }

.nav-inf {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; align-items: stretch;
  background: color-mix(in srgb, var(--superficie) 94%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--borde-2);
  padding-bottom: var(--safe-b);
  box-shadow: 0 -4px 20px rgba(42,33,28,.06);
}
.nav-inf a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 9px 4px; height: var(--nav-h);
  color: var(--suave); font-size: .68rem; font-weight: 800; text-decoration: none;
  position: relative; transition: color var(--t);
}
.nav-inf a[aria-current="page"] { color: var(--rojo); }
.nav-inf a[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--rojo);
}
.nav-inf .globo {
  position: absolute; top: 6px; right: 50%; margin-right: -20px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--rojo); color: #fff; border-radius: var(--r-full);
  font-size: .62rem; display: grid; place-items: center; font-weight: 800;
}

.lateral { display: none; }

@media (min-width: 1000px) {
  .app { flex-direction: row; }
  .lateral {
    display: flex; flex-direction: column; gap: 2px;
    width: 240px; flex: 0 0 240px;
    padding: var(--s-4) var(--s-3);
    border-right: 1px solid var(--borde-2);
    background: var(--superficie);
    position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  }
  .lateral .marca { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3) var(--s-5); }
  .lateral .marca img { width: 38px; height: 38px; border-radius: 10px; }
  .lateral a {
    display: flex; align-items: center; gap: var(--s-3);
    padding: 11px var(--s-3); border-radius: var(--r-md);
    color: var(--suave); font-weight: 700; font-size: .93rem; text-decoration: none;
    transition: background var(--t), color var(--t);
  }
  .lateral a:hover { background: var(--superficie-2); color: var(--texto); }
  .lateral a[aria-current="page"] { background: color-mix(in srgb, var(--rojo) 10%, transparent); color: var(--rojo); }
  .lateral .globo {
    margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
    background: var(--rojo); color: #fff; border-radius: var(--r-full);
    font-size: .7rem; display: grid; place-items: center; font-weight: 800;
  }
  .lateral .separador { height: 1px; background: var(--borde-2); margin: var(--s-3) var(--s-3); }
  .nav-inf { display: none; }
  .columna-app { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  .contenido { padding: var(--s-6); padding-bottom: var(--s-8); max-width: 1280px; width: 100%; margin: 0 auto; }
}

/* ------------------------------------------------------------- mostrador -- */

.mostrador { display: grid; gap: var(--s-4); }
@media (min-width: 1000px) {
  .mostrador { grid-template-columns: minmax(0,1fr) 400px; align-items: start; }
  .mostrador .ticket-col { position: sticky; top: var(--s-6); }
}

.buscador { position: relative; }
.buscador .entrada { padding-left: 44px; padding-right: 52px; font-size: 1.05rem; min-height: 56px; }
.buscador .lupa { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--suave); }
.buscador .escanear {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  width: 42px; height: 42px; border-radius: var(--r-md); border: 0;
  background: var(--amarillo); color: var(--cacao);
  display: grid; place-items: center; cursor: pointer;
}

.resultados { display: flex; flex-direction: column; gap: var(--s-2); max-height: 46vh; overflow-y: auto; }

.prod-btn {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: var(--s-3) var(--s-4); text-align: left;
  border: 1.5px solid var(--borde-2); border-radius: var(--r-md);
  background: var(--superficie); cursor: pointer; font: inherit; color: inherit;
  transition: border-color var(--t), transform var(--t);
}
.prod-btn:hover { border-color: var(--rojo); }
.prod-btn:active { transform: scale(.985); }
.prod-btn.sin-stock { opacity: .6; }

/* --- el ticket vivo --- */

.ticket {
  background: var(--superficie);
  border: 2px solid var(--cacao);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--sombra-md);
}
.ticket-top {
  background: var(--cacao); color: var(--crema);
  padding: var(--s-3) var(--s-4);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
}
.ticket-top .cuenta { font-size: .8rem; opacity: .8; font-weight: 700; }
.ticket-lineas { max-height: 42vh; overflow-y: auto; padding: var(--s-2); display: flex; flex-direction: column; gap: 6px; }
.ticket-linea {
  display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s-3);
  align-items: center;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md);
  background: var(--superficie-2);
  animation: entra-linea 260ms cubic-bezier(.2,.9,.3,1.2);
}
@keyframes entra-linea {
  from { opacity: 0; transform: translateY(-6px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.ticket-linea .nombre { font-weight: 700; font-size: .92rem; }
.ticket-linea .detalle { font-size: .78rem; color: var(--suave); grid-column: 1; }
.ticket-linea .importe { font-weight: 800; font-variant-numeric: tabular-nums; grid-row: 1 / span 2; align-self: center; }
.ticket-linea .pasos { display: flex; align-items: center; gap: 6px; grid-column: 1; margin-top: 4px; }
.ticket-linea .pasos button {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  border: 1.5px solid var(--borde); background: var(--superficie);
  font-weight: 800; cursor: pointer; display: grid; place-items: center;
}
.ticket-linea .pasos .cant {
  min-width: 56px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums;
  background: transparent; border: 0; padding: 2px;
}
.ticket-linea .quitar { color: var(--error); border: 0; background: transparent; cursor: pointer; padding: 4px; }

.ticket-total {
  border-top: 2px dashed var(--borde);
  padding: var(--s-4);
  display: flex; flex-direction: column; gap: var(--s-3);
  background: var(--superficie-2);
}
.ticket-total .fila { display: flex; justify-content: space-between; align-items: baseline; }
.ticket-total .fila.grande { font-size: 1.05rem; }
.ticket-total .fila.grande .val { font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ticket-total .sugerencia { font-size: .85rem; color: var(--suave); text-align: center; }

.ticket-vacio { padding: var(--s-8) var(--s-4); text-align: center; color: var(--suave); }
.ticket-vacio img { width: 120px; margin: 0 auto var(--s-3); opacity: .9; }

/* dientes de ticket abajo */
.ticket::after {
  content: ""; display: block; height: 10px;
  background:
    radial-gradient(circle at 6px -2px, transparent 7px, var(--superficie-2) 7px) 0 0/14px 10px repeat-x;
  margin-top: -1px;
}

/* ------------------------------------------------------------- modales ---- */

.velo {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(42,33,28,.5);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: aparece 160ms ease;
}
@media (min-width: 700px) { .velo { align-items: center; padding: var(--s-4); } }
@keyframes aparece { from { opacity: 0; } to { opacity: 1; } }

.hoja {
  background: var(--superficie);
  width: 100%; max-width: 560px;
  max-height: 92dvh; overflow-y: auto;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--s-5);
  padding-bottom: calc(var(--s-5) + var(--safe-b));
  animation: sube 260ms cubic-bezier(.2,.9,.3,1);
  box-shadow: var(--sombra-lg);
}
@media (min-width: 700px) { .hoja { border-radius: var(--r-lg); animation: escala 200ms cubic-bezier(.2,.9,.3,1); } }
@keyframes sube   { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes escala { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

.hoja-ancha { max-width: 820px; }
.hoja-cabecera { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.hoja-acciones { display: flex; gap: var(--s-2); margin-top: var(--s-5); }
.hoja-acciones .btn { flex: 1; }
.tirador { width: 40px; height: 4px; border-radius: 4px; background: var(--borde); margin: 0 auto var(--s-4); }
@media (min-width: 700px) { .tirador { display: none; } }

/* ------------------------------------------------------------- avisos ----- */

.avisos { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: var(--s-2); width: min(94vw, 460px); pointer-events: none; }
@media (min-width: 1000px) { .avisos { bottom: 20px; } }
.aviso {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  background: var(--cacao); color: var(--crema);
  box-shadow: var(--sombra-md);
  font-weight: 700; font-size: .92rem;
  animation: aviso-entra 240ms cubic-bezier(.2,.9,.3,1.1);
  pointer-events: auto;
}
@keyframes aviso-entra { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.aviso.ok    { background: var(--ok); color: #fff; }
.aviso.error { background: var(--error); color: #fff; }
.aviso.warn  { background: var(--amarillo); color: var(--cacao); }
.aviso.saliendo { animation: aviso-sale 200ms ease forwards; }
@keyframes aviso-sale { to { transform: translateY(10px); opacity: 0; } }

/* -------------------------------------------------------------- estados --- */

.vacio { text-align: center; padding: var(--s-8) var(--s-4); color: var(--suave); }
.vacio img { width: 150px; margin: 0 auto var(--s-4); }
.vacio h3 { color: var(--texto); margin-bottom: var(--s-2); }

.cargando { display: grid; place-items: center; padding: var(--s-10); }
.giro {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--borde); border-top-color: var(--rojo);
  animation: gira .8s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }

.esqueleto {
  background: linear-gradient(90deg, var(--borde-2) 25%, var(--superficie-2) 50%, var(--borde-2) 75%);
  background-size: 200% 100%;
  animation: brillo 1.4s infinite;
  border-radius: var(--r-sm);
  height: 16px;
}
@keyframes brillo { to { background-position: -200% 0; } }

/* -------------------------------------------------------------- gráficos -- */

.gr { width: 100%; height: auto; overflow: visible; }
.gr .barra { fill: var(--rojo); transition: fill var(--t); }
.gr .barra:hover { fill: var(--rojo-osc); }
.gr .barra-2 { fill: var(--amarillo); }
.gr .eje { stroke: var(--borde); stroke-width: 1; }
.gr .rejilla-l { stroke: var(--borde-2); stroke-width: 1; stroke-dasharray: 3 4; }
.gr text { fill: var(--suave); font-size: 10px; font-family: var(--fuente); font-weight: 700; }
.gr .linea { fill: none; stroke: var(--rojo); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.gr .linea-2 { fill: none; stroke: var(--ok); stroke-width: 2; stroke-dasharray: 4 4; }
.gr .area { fill: url(#degradado-rojo); }
.gr .punto { fill: var(--rojo); }

.barra-mini { height: 8px; background: var(--borde-2); border-radius: var(--r-full); overflow: hidden; }
.barra-mini > i { display: block; height: 100%; background: var(--rojo); border-radius: var(--r-full); transition: width var(--t); }

/* ------------------------------------------------------------- señales ---- */

.senal {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-4);
  border-radius: var(--r-md);
  border: 1.5px solid var(--borde-2);
  background: var(--superficie);
}
.senal .punto-senal { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex: 0 0 auto; background: var(--suave); }
.senal.bien     .punto-senal { background: var(--ok); }
.senal.atencion .punto-senal { background: var(--amarillo); }
.senal.mal      .punto-senal { background: var(--error); }
.senal.info     .punto-senal { background: var(--info); }
.senal .titulo { font-weight: 800; }
.senal .detalle { font-size: .88rem; color: var(--suave); }

/* ------------------------------------------------------------ escáner ----- */

.escaner { position: fixed; inset: 0; z-index: 150; background: #000; display: flex; flex-direction: column; }
.escaner video { flex: 1; width: 100%; object-fit: cover; }
.escaner .mira {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(78vw, 320px); height: 190px;
  border: 3px solid var(--amarillo); border-radius: var(--r-lg);
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.5);
}
.escaner .mira::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 2px;
  background: var(--rojo); box-shadow: 0 0 12px var(--rojo);
  animation: barrido 1.8s ease-in-out infinite;
}
@keyframes barrido { 0%,100% { transform: translateY(-80px); } 50% { transform: translateY(80px); } }
.escaner .pie {
  padding: var(--s-4); padding-bottom: calc(var(--s-4) + var(--safe-b));
  background: #000; color: #fff; text-align: center;
  display: flex; flex-direction: column; gap: var(--s-3);
}

/* --------------------------------------------------------- carga rápida --- */

.carga-rapida { display: flex; flex-direction: column; gap: var(--s-4); }
.carga-progreso {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: linear-gradient(120deg, var(--amarillo), color-mix(in srgb, var(--amarillo) 65%, #fff));
  color: var(--cacao); border-radius: var(--r-lg); font-weight: 800;
}
.carga-progreso .num { font-size: 1.8rem; line-height: 1; font-variant-numeric: tabular-nums; }
.racha { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; }

.sugerencias { display: flex; flex-wrap: wrap; gap: 6px; }
.sugerencias button {
  padding: 7px 12px; border-radius: var(--r-full);
  border: 1.5px solid var(--borde); background: var(--superficie);
  font-size: .85rem; font-weight: 700; cursor: pointer;
  transition: background var(--t), border-color var(--t);
}
.sugerencias button:hover { border-color: var(--rojo); background: color-mix(in srgb, var(--rojo) 8%, transparent); }

.teclado-plata { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); }
.teclado-plata button {
  padding: var(--s-3); border-radius: var(--r-md); border: 1.5px solid var(--borde);
  background: var(--superficie); font-weight: 800; cursor: pointer; min-height: 52px; font-size: 1.05rem;
}
.teclado-plata button:active { transform: scale(.96); }

/* --------------------------------------------------------------- utils ---- */

.fila { display: flex; align-items: center; gap: var(--s-3); }
.fila-sep { justify-content: space-between; }
.fila-envuelve { flex-wrap: wrap; }
.crece { flex: 1; min-width: 0; }
.centro { text-align: center; }
.derecha { text-align: right; }
.suave { color: var(--suave); }
.chico { font-size: .85rem; }
.mini  { font-size: .76rem; }
.fuerte { font-weight: 800; }
.plata { font-variant-numeric: tabular-nums; font-weight: 800; }
.verde { color: var(--ok); }
.rojo  { color: var(--error); }
.nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; }
.mt-2 { margin-top: var(--s-2); }
.mt-4 { margin-top: var(--s-4); }
.mb-2 { margin-bottom: var(--s-2); }
.mb-4 { margin-bottom: var(--s-4); }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }

/* -------------------------------------------------------------- imprimir -- */

@media print {
  .barra-sup, .nav-inf, .lateral, .avisos, .btn { display: none !important; }
  body { background: #fff; }
  .contenido { padding: 0; }
  .tarjeta { box-shadow: none; border: 1px solid #ddd; }
}
