/* ==========================================================================
   Guiro · PWA · Home "Vender" y componentes compartidos
   Layout: pulgar primero. Arriba se lee (resumen, alertas); abajo se actúa
   (dock con búsqueda + escaneo y "Nueva venta", luego la barra de navegación).
   En ventanas anchas (Windows/escritorio) la barra pasa a riel lateral y la
   Home a dos columnas. Los breakpoints son container queries sobre .app-host,
   así el mismo CSS sirve dentro de la PWA y del marco de teléfono del prototipo.
   ========================================================================== */

/* Tokens (color por tema, acento de la plataforma o de la empresa, tipografía, medidas): css/tokens.css */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--fs-md);
  line-height: 1.45;
  /* una palabra que no cabe (con el texto al 200 %, un correo, un código) pasa a la línea siguiente en vez de salirse */
  overflow-wrap: break-word;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
svg.ic { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* Filas a todo el ancho dentro de tarjetas o listas: contorno hacia adentro para que no se recorte */
.alert-row:focus-visible, .urgent-toggle:focus-visible, .urgent-item:focus-visible,
.result:focus-visible, .menu-item:focus-visible, .scan-result:focus-visible { outline-offset: -3px; border-radius: var(--r-md); }
.num { font-variant-numeric: tabular-nums; }
.code { font-family: var(--font-code); font-weight: 500; letter-spacing: 0; }
/* Atajos de teclado: solo con mouse y en ventana ancha (Windows / escritorio) */
kbd.kbd {
  font-family: var(--font-code); font-size: var(--fs-xs); font-weight: 500;
  padding: 2px 6px; border-radius: 6px; border: 1px solid currentColor; opacity: .85;
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  @container app (min-width: 840px) { kbd.kbd { display: inline-block; } }
}

/* ---------- Contenedor y layout ---------- */
.app-host {
  container: app / size;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: var(--ground);
}
.app {
  height: 100%;
  /* En la app nativa (pantalla completa) y en el iPhone instalado: nada queda bajo la barra de estado ni la muesca */
  padding: var(--safe-top) var(--safe-right) 0 var(--safe-left);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top" "main" "nav";
}
.app[inert] { user-select: none; }

/* ---------- Barra superior ---------- */
.topbar {
  grid-area: top;
  /* con el texto grande (o un teléfono angosto) el estado de los datos baja a su propia fila: el nombre no se aplasta */
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3);
  min-height: var(--top-h);
  padding: var(--s2) var(--s4);
  background: var(--ground);
}
.brand { display: flex; align-items: center; gap: var(--s3); min-width: 0; flex: 1 1 8em; }
/* Marca de la empresa (js/marca.js): el logo sobre una placa clara (también en oscuro: muchos logos tienen negro) o
   sus iniciales; un logo ancho (más de 1.6 a 1) usa una placa más larga. Vacía mientras carga. */
.brand-mark {
  width: 40px; height: 40px; flex: none; border-radius: 10px; overflow: hidden;
  background: var(--logo-placa); display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px var(--logo-borde);
}
.brand-mark:empty { background: var(--surface-2); box-shadow: none; }
.brand-mark img { display: block; width: 34px; height: 34px; object-fit: contain; }
.brand-mark.is-ancho { width: auto; min-width: 40px; max-width: 112px; padding: 0 6px; }
.brand-mark.is-ancho img { width: auto; max-width: 100px; height: 28px; }
.brand-text { min-width: 0; }
/* El nombre de la empresa: hasta dos líneas (los nombres largos no se cortan en la primera palabra) */
.brand-name { margin: 0; font-weight: 700; font-size: var(--fs-lg); line-height: 1.2; letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.brand-date { margin: 0; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.3; }
.brand-date::first-letter { text-transform: uppercase; }

.sync-chip {
  /* con el texto grande se angosta y su rótulo pasa a otra línea: la marca de la empresa conserva su lugar */
  flex: 0 1 auto; min-width: var(--tap); max-width: 100%; margin-left: auto;
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s4) 0 var(--s3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.15;
  text-align: left;
}
.sync-chip svg.ic { width: 20px; height: 20px; flex: none; }
.sync-chip > span { min-width: 0; overflow-wrap: anywhere; }
.sync-chip[data-sync="ok"] svg { color: var(--ok); }
.sync-chip[data-sync="pending"] { background: var(--warn-soft); border-color: transparent; }
.sync-chip[data-sync="pending"] svg { color: var(--warn); }
.sync-chip[data-sync="offline"], .sync-chip[data-sync="stale"] { background: var(--off-soft); border-color: transparent; }
.sync-chip[data-sync="error"] { background: var(--crit-soft); border-color: transparent; }
.sync-chip[data-sync="error"] svg { color: var(--crit); }
.sync-chip[data-sync="syncing"] svg { animation: spin 1.1s linear infinite; }
.sync-chip[data-sync="init"] { visibility: hidden; }   /* evita parpadeo en cargas rápidas */
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Área principal con scroll ---------- */
.scroller {
  grid-area: main;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-top: var(--s4);
  scroll-padding-bottom: calc(var(--dock-h, 168px) + var(--s4));
  -webkit-overflow-scrolling: touch;
}
/* Compacto: una sola columna. El DOM va "acciones primero" (dock, accesos, resumen,
   alertas); visualmente el orden se invierte para que lo que se toca quede abajo. */
.home {
  min-height: 100%;
  display: flex; flex-direction: column; gap: var(--s5);
  max-width: 640px; margin-inline: auto;
  padding: var(--s2) var(--s4) 0;
}
.col { display: contents; }
.banner { order: 0; }
.summary { order: 1; }
.alerts { order: 2; }
.shortcuts-wrap { order: 3; }

/* ---------- Dock (acción principal) ---------- */
.dock {
  order: 4;
  position: sticky; bottom: 0; z-index: 3;
  margin-top: auto;
  margin-inline: calc(var(--s4) * -1);
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--tap-lg);
  grid-template-areas: "search scan" "cta cta";
  gap: var(--s3);
  padding: var(--s3) var(--s4) var(--s4);
  background: var(--surface);
  box-shadow: var(--dock-shadow);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.search-trigger {
  grid-area: search;
  display: flex; align-items: center; gap: var(--s3);
  min-height: var(--tap-lg); padding: 0 var(--s4);
  border-radius: var(--r-pill);
  border: 1px solid var(--line-strong);
  background: var(--ground);
  color: var(--ink-2);
  font-size: var(--fs-md); text-align: left;
  min-width: 0;
}
.search-trigger span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-trigger svg { color: var(--ink); }
.scan-btn {
  grid-area: scan;
  width: var(--tap-lg); height: var(--tap-lg);
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  border: 0; background: var(--surface-2); color: var(--ink);
}
.scan-btn:active, .search-trigger:active { background: var(--surface-3); }
.cta {
  grid-area: cta;
  display: flex; align-items: center; justify-content: center; gap: var(--s3);
  min-height: var(--cta-h); padding: 0 var(--s5);
  border-radius: var(--r-lg);
  background: var(--accent); color: var(--on-accent);
  font-size: var(--fs-xl); font-weight: 700; letter-spacing: 0.005em;
  text-decoration: none;
  transition: transform .12s var(--ease), background-color .12s;
}
.cta svg.ic { width: 28px; height: 28px; stroke-width: 2.5; }
/* Solo con puntero real: en pantallas táctiles el :hover queda pegado después de tocar */
@media (hover: hover) { .cta:hover { background: var(--accent-press); } }
.cta:active { background: var(--accent-press); transform: scale(.985); }
.cta kbd.kbd { margin-left: var(--s2); }

/* ---------- Encabezados de sección ---------- */
.eyebrow {
  margin: 0;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-2);
}
.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); min-height: var(--tap); }

/* ---------- Banner de conexión / sincronización ---------- */
.banner {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s1) var(--s3);
  align-items: start;
  padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--off-soft);
}
.banner[data-kind="pending"] { background: var(--warn-soft); }
.banner[data-kind="error"] { background: var(--crit-soft); }
.banner > svg { margin-top: 1px; }
.banner[data-kind="pending"] > svg { color: var(--warn); }
.banner[data-kind="error"] > svg { color: var(--crit); }
.banner-title { margin: 0; font-weight: 700; }
.banner-text { margin: 0; font-size: var(--fs-sm); color: var(--ink-2); }
.banner-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s1); }
.banner[data-kind="syncing"] > svg { animation: spin 1.1s linear infinite; }

/* ---------- Botones genéricos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s5);
  border-radius: var(--r-pill); border: 1px solid transparent;
  font-weight: 700; font-size: var(--fs-md); text-decoration: none;
  /* con el texto grande (hasta 200 %) el rótulo pasa a otra línea en vez de salirse de la pantalla */
  max-width: 100%; padding-block: var(--s1); text-align: center; overflow-wrap: anywhere;
}
.btn svg.ic { width: 20px; height: 20px; flex: none; }
.btn-tonal { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-tonal:active { background: var(--surface-3); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active { background: var(--accent-press); }
.btn-ghost { background: transparent; color: var(--ink); padding-inline: var(--s3); }
.btn-ghost:active { background: var(--surface-3); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.icon-btn {
  width: var(--tap); height: var(--tap); flex: none;
  display: inline-grid; place-items: center;
  border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink);
}
.icon-btn:active { background: var(--surface-3); }

/* ---------- Resumen del día ---------- */
.summary { display: flex; flex-direction: column; gap: var(--s1); }
.summary .section-head { margin-bottom: calc(var(--s1) * -1); }
.amount {
  margin: 0;
  display: flex; align-items: baseline; gap: 2px; flex-wrap: wrap;
  font-weight: 800; letter-spacing: -0.02em; line-height: 1.05;
  font-size: clamp(2.25rem, 1.6rem + 3.2cqi, 3rem);
  font-variant-numeric: tabular-nums;
}
.amount .cur { font-size: .58em; font-weight: 700; letter-spacing: 0; color: var(--ink-2); }
.amount.is-zero { color: var(--ink-2); }
.amount.is-hidden .digits { letter-spacing: 0.08em; }
.stats { margin: 0; display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); color: var(--ink-2); font-size: var(--fs-md); }
.stats strong { color: var(--ink); font-weight: 700; }
.note {
  margin: var(--s1) 0 0; display: flex; align-items: center; gap: var(--s2);
  font-size: var(--fs-sm); color: var(--ink-2);
}
.note svg.ic { width: 18px; height: 18px; }
.note.warn svg { color: var(--warn); }
.empty-text { margin: var(--s1) 0 0; color: var(--ink-2); max-width: 40ch; }

/* ---------- Tarjeta genérica (solo donde agrupa filas accionables) ---------- */
.card { background: var(--surface); border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }

/* ---------- Alertas de inventario ---------- */
.alert-list { list-style: none; margin: 0; padding: 0; }
.alert-list > li + li { border-top: 1px solid var(--line); }
.alert-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: var(--s3);
  min-height: 72px; padding: var(--s3) var(--s2) var(--s3) var(--s4);
  text-decoration: none; color: inherit;
}
.alert-row:active { background: var(--surface-2); }
.alert-icon { width: 40px; height: 40px; border-radius: var(--r-pill); display: grid; place-items: center; }
.alert-row[data-sev="crit"] .alert-icon { background: var(--crit-soft); color: var(--crit); }
.alert-row[data-sev="warn"] .alert-icon { background: var(--warn-soft); color: var(--warn-icon); }
.alert-row[data-sev="none"] .alert-icon { background: var(--surface-2); color: var(--ink-2); }
.alert-title { margin: 0; font-weight: 700; font-size: var(--fs-lg); line-height: 1.25; }
.alert-sub { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--ink-2); line-height: 1.35; }
.count {
  min-width: 48px; padding: 4px 10px; border-radius: var(--r-pill);
  font-weight: 800; font-size: var(--fs-lg); text-align: center; font-variant-numeric: tabular-nums;
}
.count.crit { background: var(--crit-soft); color: var(--crit); }
.count.warn { background: var(--warn-soft); color: var(--warn); }
.count.muted { background: transparent; color: var(--ink-2); font-size: var(--fs-sm); font-weight: 700; min-width: 0; padding-inline: 0; }
.chev { color: var(--ink-2); }

.urgent-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s3) 0 var(--s4);
  border: 0; border-top: 1px solid var(--line); background: transparent;
  font-weight: 700; font-size: var(--fs-sm); text-align: left; color: var(--ink);
}
.urgent-toggle svg { transition: transform .2s var(--ease); color: var(--ink-2); }
.urgent-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.urgent-list { list-style: none; margin: 0; padding: 0 0 var(--s2); }
.urgent-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s1) var(--s3);
  min-height: 64px; padding: var(--s2) var(--s4);
  text-decoration: none; color: inherit;
}
.urgent-item:active { background: var(--surface-2); }
.p-name {
  margin: 0; font-weight: 700; font-size: var(--fs-md); line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere;
}
.p-meta { margin: 2px 0 0; font-size: var(--fs-sm); color: var(--ink-2); }
.dup { color: var(--warn); font-weight: 700; }
.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.pill.crit { background: var(--crit-soft); color: var(--crit); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: var(--surface-2); color: var(--ink); }

.state-box {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s1) var(--s3); align-items: start;
  padding: var(--s4);
}
.state-box > svg { margin-top: 1px; }
.state-box.ok > svg { color: var(--ok); }
.state-box.err > svg { color: var(--crit); }
.state-title { margin: 0; font-weight: 700; }
.state-text { margin: 0; color: var(--ink-2); font-size: var(--fs-sm); }
.state-box .btn { grid-column: 2; justify-self: start; margin-top: var(--s2); }

/* ---------- Estados reutilizables (CRH.ui.estado): ícono + qué pasa + qué hacer ---------- */
.estado {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s1) var(--s3); align-items: start;
  padding: var(--s4); border-radius: var(--r-md); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
}
.estado > svg.ic { margin-top: 1px; color: var(--ink-2); }
.estado-cuerpo { min-width: 0; }
.estado-titulo { margin: 0; font-weight: 700; overflow-wrap: break-word; }
.estado-texto { margin: 2px 0 0; color: var(--ink-2); font-size: var(--fs-sm); overflow-wrap: break-word; }
.estado-acciones { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.estado[data-estado="error"] { background: var(--crit-soft); box-shadow: none; }
.estado[data-estado="error"] > svg.ic { color: var(--crit); }
.estado[data-estado="pendiente"] { background: var(--warn-soft); box-shadow: none; }
.estado[data-estado="pendiente"] > svg.ic { color: var(--warn); }
.estado[data-estado="sin-conexion"], .estado[data-estado="sin-permiso"] { background: var(--off-soft); box-shadow: none; }
.estado[data-estado="listo"] { background: var(--ok-soft); box-shadow: none; }
.estado[data-estado="listo"] > svg.ic { color: var(--ok); }
.estado[data-estado="vacio"] { text-align: left; }
.estado[data-estado="cargando"] { align-items: center; }
.estado-compacto { padding: var(--s3); }
@media (forced-colors: active) { .estado { border: 1px solid CanvasText; } }

/* ---------- Accesos secundarios ---------- */
.shortcuts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.tile {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--s1) var(--s3);
  min-height: 72px; padding: var(--s3) var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface-2); color: var(--ink); text-decoration: none;
}
.tile:active { background: var(--surface-3); }
.tile-label { font-weight: 700; font-size: var(--fs-md); line-height: 1.25; overflow-wrap: break-word; min-width: 0; }
.tile-sub { display: block; font-weight: 400; font-size: var(--fs-sm); color: var(--ink-2); }

/* ---------- Esqueletos (loading) ---------- */
.skel {
  display: block; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--skel) 0%, var(--skel-hi) 50%, var(--skel) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.skel-amount { width: 62%; max-width: 240px; height: 44px; margin-block: 2px; }
.skel-line { height: 16px; width: 70%; }
.skel-line.short { width: 40%; }
.skel-row { display: grid; grid-template-columns: 40px minmax(0, 1fr) 48px; gap: var(--s3); align-items: center; min-height: 72px; padding: var(--s3) var(--s4); }
.skel-dot { width: 40px; height: 40px; border-radius: var(--r-pill); }
.skel-pill { width: 48px; height: 28px; border-radius: var(--r-pill); }
.skel-stack { display: grid; gap: var(--s2); }

/* ---------- Navegación principal: barra inferior / riel ---------- */
.navbar {
  grid-area: nav;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  min-height: var(--nav-h);
  padding: 0 var(--s2) var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: var(--nav-h); padding: var(--s2) var(--s1);
  border: 0; background: transparent; color: var(--ink-2);
  font-size: var(--fs-xs); font-weight: 700; text-decoration: none;
  min-width: 0; text-align: center; overflow-wrap: anywhere; hyphens: auto;
}
.nav-pill { width: 64px; height: 32px; border-radius: var(--r-pill); display: grid; place-items: center; transition: background-color .15s; }
.nav-item[aria-current] { color: var(--ink); }
.nav-item[aria-current] .nav-pill { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item:active .nav-pill { background: var(--surface-3); }

/* ---------- Hojas modales (Más, sync, búsqueda, escaneo) ---------- */
.scrim {
  position: absolute; inset: 0; z-index: 20;
  background: var(--scrim);
  opacity: 0; transition: opacity .2s var(--ease);
}
.scrim.is-open { opacity: 1; }
.sheet {
  position: absolute; z-index: 21; left: 0; right: 0; bottom: 0;
  max-height: calc(100% - 48px - var(--safe-top));
  display: flex; flex-direction: column;
  background: var(--surface); color: var(--ink);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--sheet-shadow);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  transform: translateY(100%); transition: transform .24s var(--ease);
  outline: none;
}
.sheet.is-open { transform: none; }
.sheet-head {
  display: flex; align-items: center; gap: var(--s2);
  min-height: var(--tap-lg); padding: var(--s2) var(--s2) 0 var(--s5);
}
.sheet-head h2 { margin: 0; flex: 1; font-size: var(--fs-xl); font-weight: 700; line-height: 1.25; }
.sheet-body { overflow-y: auto; padding: var(--s2) var(--s5) var(--s5); overscroll-behavior: contain; }
.sheet-grab { width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 10px auto 0; opacity: .6; }

.menu-list { list-style: none; margin: 0 calc(var(--s5) * -1); padding: 0; }
.menu-item {
  display: flex; align-items: center; gap: var(--s4);
  min-height: var(--tap-lg); padding: var(--s2) var(--s5);
  width: 100%; border: 0; background: transparent; text-align: left;
  font-size: var(--fs-md); font-weight: 600; text-decoration: none; color: var(--ink);
}
.menu-item:active { background: var(--surface-2); }
.menu-item .grow { flex: 1; min-width: 0; }
.menu-item .sub { display: block; font-weight: 400; font-size: var(--fs-sm); color: var(--ink-2); }
.menu-item > svg:first-child { color: var(--ink-2); }
.menu-sep { height: 1px; background: var(--line); margin: var(--s2) 0; }

.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s2) var(--s4); margin: 0 0 var(--s4); font-size: var(--fs-sm); }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.queue { list-style: none; margin: 0 0 var(--s4); padding: 0; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); }
.queue li { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4); font-size: var(--fs-sm); }
.queue li + li { border-top: 1px solid var(--line); }
.sheet-actions { display: flex; flex-wrap: wrap; gap: var(--s3); }
.sheet-actions .btn { flex: 1 1 auto; }
.help { margin: var(--s2) 0 0; font-size: var(--fs-sm); color: var(--ink-2); }

/* Búsqueda: pantalla completa en compacto */
.sheet.search { top: 0; max-height: none; border-radius: 0; padding-top: var(--safe-top); }
.search-bar {
  display: flex; align-items: center; gap: var(--s1);
  padding: var(--s2) var(--s2);
  border-bottom: 1px solid var(--line);
}
.search-field {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s1) 0 var(--s3);
  /* el borde va por dentro (sombra): el campo que se toca mide todo el alto, 48 px o más */
  border-radius: var(--r-pill); box-shadow: inset 0 0 0 1px var(--line-strong); background: var(--ground);
}
.search-field:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.search-field input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  min-height: var(--tap); font-size: var(--fs-lg);
}
.search-field input::placeholder { color: var(--ink-2); opacity: 1; }
.search-field input::-webkit-search-cancel-button { display: none; }
.results { overflow-y: auto; flex: 1; overscroll-behavior: contain; padding-bottom: var(--s4); }
.results-meta { margin: 0; padding: var(--s3) var(--s4) var(--s1); font-size: var(--fs-sm); color: var(--ink-2); }
.result-list { list-style: none; margin: 0; padding: 0; }
.result {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s1) var(--s3); align-items: center;
  min-height: 72px; padding: var(--s3) var(--s4);
  text-decoration: none; color: inherit;
}
.result:active, .result.is-active { background: var(--surface-2); }
.result + .result, .result-list li + li .result { border-top: 1px solid var(--line); }
.result-side { display: grid; justify-items: end; gap: 4px; }
.price { font-weight: 800; font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.hint { padding: var(--s5) var(--s4); color: var(--ink-2); }
.hint p { margin: 0 0 var(--s2); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.chip {
  display: inline-flex; align-items: center; gap: var(--s2);
  min-height: var(--tap); max-width: 100%; padding: 0 var(--s4);
  border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface);
  font-weight: 600; font-size: var(--fs-sm); color: var(--ink);
}
.chip:active { background: var(--surface-3); }

/* Escaneo */
.viewfinder {
  position: relative; aspect-ratio: 4 / 3; max-width: 100%;
  border-radius: var(--r-md); overflow: hidden; background: var(--visor);
  margin-bottom: var(--s4);
}
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder .reticle {
  position: absolute; inset: 22% 10%; border: 3px solid var(--visor-marco); border-radius: var(--r-md);
  box-shadow: 0 0 0 9999px var(--visor-velo);
}
.field { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s2); margin-bottom: var(--s3); }
.field label { font-weight: 700; font-size: var(--fs-sm); }
.field-row { display: flex; gap: var(--s2); }
.input {
  flex: 1; min-width: 0; min-height: var(--tap-lg); padding: 0 var(--s4);
  border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--ground);
  font-size: var(--fs-lg);
}
.input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.scan-result {
  border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line);
  padding: var(--s4); margin-bottom: var(--s4);
}
.scan-result .price { font-size: var(--fs-2xl); }
.scan-result .row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-top: var(--s3); flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Pantallas de módulos existentes (stubs de navegación) ---------- */
.route { display: flex; flex-direction: column; gap: var(--s4); padding: var(--s2) var(--s4) var(--s8); max-width: 640px; margin-inline: auto; }
.route-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); min-height: var(--tap-lg); margin-left: calc(var(--s2) * -1); }
.route-head h1 { margin: 0; font-size: var(--fs-2xl); line-height: 1.2; }
.route-card { background: var(--surface); border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); padding: var(--s4); }
.route-card p { margin: 0 0 var(--s2); }
.route-card p:last-child { margin-bottom: 0; }
.route .muted { color: var(--ink-2); font-size: var(--fs-sm); }

/* ---------- Toasts ---------- */
.toasts {
  position: absolute; z-index: 30; left: var(--s4); right: var(--s4);
  bottom: calc(var(--dock-h, 168px) + var(--nav-h) + var(--s3));
  display: grid; gap: var(--s2); justify-items: center; pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s3);
  max-width: min(480px, 100%); min-height: var(--tap); padding: var(--s3) var(--s4);
  border-radius: var(--r-md);
  background: var(--ink); color: var(--surface);
  font-weight: 600; font-size: var(--fs-sm);
  box-shadow: var(--toast-shadow);
  animation: toast-in .2s var(--ease);
}
.toast svg.ic { width: 20px; height: 20px; flex: none; }
/* El texto ocupa lo que quede; con el texto grande la acción baja a su propia línea (a la derecha) */
.toast-text { flex: 1 1 6em; min-width: 0; overflow-wrap: anywhere; }
.toast-btn {
  min-height: var(--tap); padding: 0 var(--s3); margin: calc(var(--s2) * -1) calc(var(--s2) * -1) calc(var(--s2) * -1) auto;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--surface);
  font-weight: 800; text-decoration: underline; text-underline-offset: 3px;
}
.toast-btn:focus-visible { outline: 3px solid var(--surface); outline-offset: -3px; }
.toast-warn { background: var(--warn-soft); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line), var(--toast-shadow); }
.toast-warn svg.ic { color: var(--warn); }
.toast-warn .toast-btn { color: var(--ink); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Tableta vertical: el dock se alinea con la columna de contenido ---------- */
@container app (min-width: 600px) and (max-width: 839px) {
  .dock { margin-inline: 0; border-radius: var(--r-lg) var(--r-lg) 0 0; }
}
/* Teléfono horizontal angosto (<600 px de ancho y poco alto): el dock sigue fijo, en una sola fila */
@container app (max-height: 560px) and (max-width: 599px) {
  .dock {
    grid-template-columns: minmax(0, 1fr) var(--tap) auto;
    grid-template-areas: "search scan cta";
    gap: var(--s2); padding: var(--s2) var(--s4);
  }
  .search-trigger, .scan-btn { min-height: var(--tap); height: var(--tap); }
  .scan-btn { width: var(--tap); }
  .cta { min-height: var(--tap-lg); font-size: var(--fs-lg); padding: 0 var(--s4); }
  .cta svg.ic { width: 24px; height: 24px; }
  .navbar, .nav-item { min-height: 60px; }
  .nav-item { gap: 2px; }
  .toasts { bottom: calc(var(--dock-h, 72px) + 60px + var(--s3)); }
}

/* ---------- Expandido: Windows / escritorio / tableta y teléfono en horizontal ---------- */
@container app (min-width: 840px) or ((min-width: 600px) and (max-height: 560px)) {
  .app {
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "nav top" "nav main";
  }
  .navbar {
    grid-template-columns: minmax(0, 1fr); grid-auto-rows: min-content; align-content: start; gap: var(--s2);
    padding: var(--s4) var(--s2);
    border-top: 0; border-right: 1px solid var(--line);
  }
  .nav-item { min-height: 72px; }
  .topbar { padding: var(--s3) var(--s6); min-height: 72px; }
  .home {
    max-width: 1180px; width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    grid-template-areas: "actions info";
    align-items: start; align-content: start;
    gap: var(--s6) var(--s8);
    padding: var(--s4) var(--s6) var(--s8);
  }
  .home.has-banner { grid-template-areas: "banner banner" "actions info"; }
  .banner { grid-area: banner; }
  .col { display: flex; flex-direction: column; gap: var(--s6); min-width: 0; }
  .col-actions { grid-area: actions; }
  .col-info { grid-area: info; }
  .banner, .summary, .alerts, .shortcuts-wrap, .dock { order: 0; }
  .dock {
    position: static; margin: 0;
    padding: 0; background: transparent; box-shadow: none; border-radius: 0;
  }
  .cta { min-height: 88px; font-size: var(--fs-2xl); border-radius: var(--r-lg); }
  .cta svg.ic { width: 32px; height: 32px; }
  .summary { padding: var(--s5) var(--s6); background: var(--surface); border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); }
  .shortcuts { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .scroller { scroll-padding-bottom: var(--s4); }
  .toasts { bottom: var(--s6); left: auto; right: var(--s6); width: 420px; justify-items: end; }
  .sheet:not(.search) {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: min(560px, calc(100% - 64px)); max-height: min(720px, calc(100% - 64px));
    transform: translate(-50%, -46%); opacity: 0;
    border-radius: 20px;
    transition: transform .2s var(--ease), opacity .2s var(--ease);
  }
  .sheet:not(.search).is-open { transform: translate(-50%, -50%); opacity: 1; }
  .sheet.search {
    left: 50%; right: auto; top: 72px; bottom: auto;
    width: min(760px, calc(100% - 64px)); height: min(680px, calc(100% - 112px));
    border-radius: 20px; padding-top: 0;
    transform: translate(-50%, -8px); opacity: 0;
    transition: transform .2s var(--ease), opacity .2s var(--ease);
  }
  .sheet.search.is-open { transform: translate(-50%, 0); opacity: 1; }
  .sheet-grab { display: none; }
  .route { max-width: 760px; padding-inline: var(--s6); }
}

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .skel { animation: none; background: var(--skel); }
}

/* ---------- Alto contraste de Windows ---------- */
@media (forced-colors: active) {
  .cta, .btn-primary { border: 2px solid ButtonText; }
  .count, .pill, .sync-chip, .tile, .search-trigger, .scan-btn, .search-field { border: 1px solid CanvasText; }
  .nav-item[aria-current] .nav-pill { outline: 2px solid Highlight; }
}
