/* Marbert — estilos de la app. Pensados para el dedo: 48 px mínimo, una acción principal por pantalla. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--fuente); font-size: var(--t-15); line-height: 1.4; color: var(--texto); background: var(--fondo); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: var(--t-28); font-weight: 700; } h2 { font-size: var(--t-22); font-weight: 700; } h3 { font-size: var(--t-17); font-weight: 700; }
p { margin: 0; }
a { color: var(--cielo); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.oculto { display: none !important; }
.num, .dinero, td.num, .kpi-valor, .total-grande { font-variant-numeric: tabular-nums; }
.mudo { color: var(--mudo); } .peq { font-size: var(--t-13); } .fuerte { font-weight: 700; }
.ojo { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--mudo); font-weight: 600; }
.verde { color: var(--verde); } .rojo { color: var(--rojo); } .ambar { color: var(--ambar); }
.fila { display: flex; align-items: center; gap: 12px; } .fila.entre { justify-content: space-between; } .fila.arriba { align-items: flex-start; } .fila.envolver { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.crece { flex: 1; min-width: 0; }
.truncar { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── acceso ── */
.acceso { min-height: 100dvh; display: grid; place-items: center; background: var(--carbon); color: var(--sal); padding: 24px; }
.acceso-caja { width: min(420px, 100%); display: flex; flex-direction: column; gap: 16px; }
.acceso-logo { width: 100%; max-width: 320px; margin: 0 auto 8px; }
.acceso-sub { text-align: center; color: #B9B7B0; font-size: var(--t-13); letter-spacing: .08em; text-transform: uppercase; }
.acceso .campo input { background: #1B1B1F; border-color: #33343A; color: var(--sal); }
.acceso .campo span { color: #B9B7B0; }
.acceso-error { color: #FF8A80; min-height: 1.4em; text-align: center; }

/* ── estructura ── */
.app { display: grid; grid-template-rows: var(--cabecera) 1fr var(--barra); grid-template-areas: "cab" "vista" "nav"; min-height: 100dvh; }
.cabecera { grid-area: cab; background: var(--carbon); color: var(--sal); display: flex; align-items: center; justify-content: space-between; padding: 0 16px; padding-top: env(safe-area-inset-top); position: sticky; top: 0; z-index: 20; }
.cab-marca img { display: block; height: 30px; }
.cab-derecha { display: flex; align-items: center; gap: 14px; font-size: var(--t-13); }
.cab-usuario { color: #B9B7B0; }
.cab-salir { background: none; border: 1px solid #3A3B40; color: var(--sal); border-radius: var(--r-pastilla); padding: 6px 12px; min-height: 36px; }
.cab-red { background: none; border: 0; color: var(--sal); display: flex; align-items: center; gap: 8px; padding: 6px 8px; min-height: 36px; border-radius: var(--r-pastilla); }
.cab-red .punto { width: 10px; height: 10px; border-radius: 50%; background: var(--verde); box-shadow: 0 0 0 3px rgba(30,142,78,.25); }
.cab-red.offline .punto { background: var(--rojo); box-shadow: 0 0 0 3px rgba(200,53,46,.25); }
.cab-red.pendiente .punto { background: var(--ambar); box-shadow: 0 0 0 3px rgba(199,119,0,.25); }
/* En un teléfono estrecho el punto de color ya dice el estado, y el nombre sobra. */
@media (max-width: 480px) {
  .cabecera { padding: 0 10px; gap: 8px; }
  .cab-marca img { height: 26px; }
  .cab-derecha { gap: 8px; }
  #estado-red-texto, .cab-usuario { display: none; }
}
.nav { grid-area: nav; display: flex; background: var(--superficie); border-top: 1px solid var(--borde); position: sticky; bottom: 0; z-index: 20; padding-bottom: env(safe-area-inset-bottom); }
.nav a { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: var(--barra); text-decoration: none; color: var(--mudo); font-size: 11px; font-weight: 600; }
.nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.activo { color: var(--texto); }
.nav a.activo svg { stroke-width: 2.2; }
/* min-width:0 — sin esto, una tabla ancha estira la columna de la rejilla y toda la app se desborda. */
.cabecera, .nav, .vista { min-width: 0; }
.vista { grid-area: vista; padding: 16px; padding-bottom: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }
@media (min-width: 900px) {
  .app { grid-template-columns: var(--rail) 1fr; grid-template-rows: var(--cabecera) 1fr; grid-template-areas: "cab cab" "nav vista"; }
  .nav { flex-direction: column; border-top: 0; border-right: 1px solid var(--borde); position: sticky; top: var(--cabecera); height: calc(100dvh - var(--cabecera)); justify-content: flex-start; padding-top: 8px; }
  .nav a { flex: 0 0 auto; min-height: 72px; font-size: 12px; }
  .vista { padding: 24px 28px; }
}

/* ── componentes ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--toque); padding: 0 18px; border-radius: var(--r-campo); border: 1px solid var(--carbon); background: var(--carbon); color: var(--sal); font-weight: 700; text-decoration: none; white-space: nowrap; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secundario { background: transparent; color: var(--texto); border-color: var(--borde); }
.btn.suave { background: var(--superficie); color: var(--texto); border-color: var(--borde); }
.btn.peligro { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn.btn-claro { background: var(--sal); color: var(--carbon); border-color: var(--sal); }
.btn.btn-grande { min-height: var(--toque-grande); font-size: var(--t-17); }
.btn.chico { min-height: 36px; padding: 0 12px; font-size: var(--t-13); }
.btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-color-scheme: dark) { .btn { background: var(--sal); color: var(--carbon); border-color: var(--sal); } .btn.secundario, .btn.suave { background: transparent; color: var(--texto); border-color: var(--borde); } }
.campo { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-13); color: var(--texto-2); font-weight: 600; }
.campo input, .campo select, .campo textarea { min-height: var(--toque); padding: 8px 12px; border: 1px solid var(--borde); border-radius: var(--r-campo); background: var(--superficie); color: var(--texto); font-size: var(--t-17); font-weight: 400; width: 100%; }
.campo textarea { min-height: 88px; resize: vertical; }
.campo input:focus, .campo select:focus, .campo textarea:focus, .buscador input:focus { outline: 2px solid var(--cielo); outline-offset: 0; border-color: var(--cielo); }
.campo.horizontal { flex-direction: row; align-items: center; justify-content: space-between; }
.campo.horizontal input[type=checkbox] { width: 24px; height: 24px; min-height: 0; }
.rejilla { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.rejilla-2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.tarjeta { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); padding: 16px; box-shadow: var(--sombra); }
.tarjeta.densa { padding: 12px; }
.seccion { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.cab-vista { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.kpi { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); padding: 14px 16px; }
.kpi-valor { font-size: var(--t-28); font-weight: 700; line-height: 1.1; margin-top: 4px; }
.kpi.acento { background: var(--carbon); color: var(--sal); border-color: var(--carbon); } .kpi.acento .ojo { color: #B9B7B0; }
.pastilla { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pastilla); font-size: 12px; font-weight: 700; background: var(--fondo); border: 1px solid var(--borde); color: var(--texto-2); white-space: nowrap; }
.pastilla.verde { background: var(--verde-suave); color: var(--verde); border-color: transparent; }
.pastilla.rojo { background: var(--rojo-suave); color: var(--rojo); border-color: transparent; }
.pastilla.ambar { background: var(--ambar-suave); color: var(--ambar); border-color: transparent; }
.pastilla.cielo { background: var(--cielo-suave); color: var(--cielo); border-color: transparent; }
.lista { display: flex; flex-direction: column; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); overflow: hidden; }
.lista-item { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 14px; border-bottom: 1px solid var(--borde); text-decoration: none; color: inherit; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; }
.lista-item:last-child { border-bottom: 0; }
.lista-item.tocable:hover, .lista-item.tocable:focus-visible { background: var(--fondo); }
.lista-item .principal { flex: 1; min-width: 0; } .lista-item .sub { color: var(--mudo); font-size: var(--t-13); }
.tabla { width: 100%; border-collapse: collapse; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); overflow: hidden; font-size: var(--t-15); }
.tabla th, .tabla td { padding: 10px 12px; border-bottom: 1px solid var(--borde); text-align: left; vertical-align: middle; }
.tabla th { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--mudo); font-weight: 600; background: var(--fondo); }
.tabla td.num, .tabla th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tr.tocable { cursor: pointer; } .tabla tr.tocable:hover { background: var(--fondo); }
.tabla input, .tabla select { min-height: 40px; padding: 4px 8px; border: 1px solid var(--borde); border-radius: var(--r-campo); background: var(--superficie); color: inherit; width: 100%; font-variant-numeric: tabular-nums; }
.tabla-envoltura { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-tarjeta); }
.vacio { padding: 32px 16px; text-align: center; color: var(--mudo); background: var(--superficie); border: 1px dashed var(--borde); border-radius: var(--r-tarjeta); }
.pestanas { display: flex; gap: 6px; flex-wrap: wrap; }
.pestanas button { min-height: 40px; padding: 0 14px; border-radius: var(--r-pastilla); border: 1px solid var(--borde); background: var(--superficie); color: var(--texto-2); font-weight: 600; }
.pestanas button.activo { background: var(--carbon); color: var(--sal); border-color: var(--carbon); }
.buscador { display: flex; align-items: center; gap: 8px; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-campo); padding: 0 12px; min-height: var(--toque-grande); }
.buscador svg { width: 22px; height: 22px; stroke: var(--mudo); fill: none; stroke-width: 2; stroke-linecap: round; flex: none; }
.buscador input { flex: 1; min-width: 0; border: 0; background: none; font-size: var(--t-17); min-height: 44px; outline: none; }
.barras { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.barras div { flex: 1; background: var(--carbon); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; position: relative; }
.barras div.hoy { background: var(--cielo); opacity: 1; }
.barras div span { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--mudo); }
.progreso { height: 6px; background: var(--borde); border-radius: 3px; overflow: hidden; } .progreso i { display: block; height: 100%; background: var(--verde); }

/* ── modal y avisos ── */
.capa-modal { position: fixed; inset: 0; background: rgba(14,14,16,.55); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 700px) { .capa-modal { align-items: center; padding: 24px; } }
.modal { background: var(--superficie); color: var(--texto); border-radius: 16px 16px 0 0; width: 100%; max-width: 640px; max-height: 92dvh; display: flex; flex-direction: column; overflow: hidden; }
@media (min-width: 700px) { .modal { border-radius: 14px; } .modal.ancho { max-width: 960px; } }
.modal-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--borde); }
.modal-cuerpo { padding: 16px 20px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-pie { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--borde); padding-bottom: calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
.modal-pie .btn { flex: 1; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--barra) + 12px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: min(92vw, 480px); }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { background: var(--carbon); color: var(--sal); padding: 12px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.25); animation: subir .18s ease-out; }
.toast.error { background: var(--rojo); color: #fff; } .toast.ok { background: var(--verde); color: #fff; }
@keyframes subir { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── vender ── */
.vender { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .vender { grid-template-columns: 1.1fr 1fr; align-items: start; } }
.resultados { display: flex; flex-direction: column; gap: 6px; max-height: 50dvh; overflow: auto; }
.resultado { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); text-align: left; width: 100%; min-height: 60px; }
.resultado:hover { border-color: var(--carbon); }
.resultado .precio { font-weight: 700; font-variant-numeric: tabular-nums; }
.carrito { background: var(--superficie); border: 1px solid var(--borde); border-radius: var(--r-tarjeta); display: flex; flex-direction: column; overflow: hidden; }
.carrito-lineas { display: flex; flex-direction: column; }
.linea { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 10px 14px; border-bottom: 1px solid var(--borde); }
.linea-controles { display: flex; align-items: center; gap: 6px; grid-column: 1 / -1; flex-wrap: wrap; }
.linea-controles .btn.chico { min-width: 52px; }
.linea-controles input { width: 76px; min-height: 40px; text-align: center; border: 1px solid var(--borde); border-radius: var(--r-campo); background: var(--superficie); color: inherit; font-variant-numeric: tabular-nums; }
.carrito-pie { padding: 14px; border-top: 2px solid var(--carbon); display: flex; flex-direction: column; gap: 12px; position: sticky; bottom: 0; background: var(--superficie); }
.total-grande { font-size: var(--t-40); font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.formas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.formas button { min-height: var(--toque); border: 1px solid var(--borde); border-radius: var(--r-campo); background: var(--superficie); color: var(--texto); font-weight: 600; }
.formas button.activo { background: var(--carbon); color: var(--sal); border-color: var(--carbon); }
.teclado-vuelto { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.teclado-vuelto button { min-height: 44px; border: 1px solid var(--borde); border-radius: var(--r-campo); background: var(--superficie); color: var(--texto); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── cuadrícula colores × tallas ── */
.cuadricula { overflow-x: auto; } .cuadricula table { border-collapse: collapse; } .cuadricula th, .cuadricula td { padding: 4px; text-align: center; }
.cuadricula th { font-size: var(--t-13); color: var(--texto-2); font-weight: 600; white-space: nowrap; }
.cuadricula input { width: 64px; min-height: 44px; text-align: center; border: 1px solid var(--borde); border-radius: var(--r-campo); background: var(--superficie); color: inherit; font-size: var(--t-17); font-variant-numeric: tabular-nums; }
.cuadricula input.lleno { background: var(--cielo-suave); border-color: var(--cielo); font-weight: 700; }
.cuadricula td.total, .cuadricula th.total { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── impresión ── */
@media print { .cabecera, .nav, .toasts { display: none !important; } .app { display: block; } .vista { padding: 0; } }
