/* CuentaFácil · SuperTienda China — facturación de pasillo para el teléfono del vendedor */
:root {
  --verde: #0f7b4f;
  --verde-oscuro: #0a5637;
  --verde-suave: #e6f3ec;
  --tinta: #16211c;
  --tinta-suave: #5b6b63;
  --borde: #d8e1db;
  --fondo: #f2f5f3;
  --blanco: #ffffff;
  --rojo: #b3261e;
  --rojo-suave: #fbe9e7;
  --ambar: #9a6700;
  --ambar-suave: #fdf3d7;
  --sombra: 0 1px 2px rgba(16, 32, 24, .06), 0 8px 24px rgba(16, 32, 24, .06);
  --radio: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
/* Las clases de abajo definen display; sin esta regla el atributo hidden no ocultaria nada. */
[hidden] { display: none !important; }
body {
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--tinta);
  background: var(--fondo);
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; }
p { margin: 0; }
a { color: var(--verde-oscuro); }

/* ---------- acceso ---------- */
.pantalla {
  min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--verde-suave), var(--fondo));
}
.tarjeta {
  width: min(430px, 100%);
  background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio);
  box-shadow: var(--sombra); padding: 18px;
}
.acceso-tarjeta { display: flex; flex-direction: column; gap: 10px; text-align: center; }
.acceso-escudo { width: 72px; height: 72px; border-radius: 16px; align-self: center; }
/* Bloque de marca de la familia: CuentaFácil manda, su eslogan va pegado debajo y el nombre del negocio es
   la aplicación dependiente. */
.acceso-marca { display: grid; gap: 2px; }
.marca-sistema { color: var(--verde); font-weight: 800; letter-spacing: .2px; font-size: 13px; margin: 0; }
.acceso-marca .marca-sistema { font-size: 22px; line-height: 1.1; color: var(--verde-oscuro); }
.acceso-eslogan { margin: 0; font-size: 12px; font-style: italic; color: var(--verde-oscuro); }
.acceso-tarjeta h1 { margin: 0; font-size: 21px; }
.subtitulo { color: var(--tinta-suave); font-size: 13px; }
.campo { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.campo span { font-size: 12px; color: var(--tinta-suave); }
.campo input {
  border: 1px solid var(--borde); border-radius: 8px; background: var(--blanco);
  padding: 12px; font-size: 16px; /* 16px evita que iOS haga zoom al escribir */
}
.campo input:focus { outline: 2px solid var(--verde); outline-offset: 1px; }
.boton {
  border: 1px solid var(--borde); border-radius: 8px; background: var(--blanco);
  padding: 11px 14px; cursor: pointer;
}
.boton.principal { background: var(--verde); border-color: var(--verde); color: #fff; font-weight: 600; }
.boton.principal:disabled { opacity: .55; }
.boton.minimo { border: 0; background: transparent; padding: 6px 8px; }
.boton.peligro { background: var(--rojo); border-color: var(--rojo); color: #fff; font-weight: 600; }
.aviso { font-size: 13px; color: var(--rojo); min-height: 18px; }
.aviso.info { color: var(--tinta-suave); }
.pie { font-size: 11px; color: var(--tinta-suave); text-align: center; }

/* ---------- encabezado ---------- */
.encabezado {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--verde); color: #fff;
}
.encabezado .marca { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.encabezado .marca img { width: 30px; height: 30px; border-radius: 8px; }
.encabezado .marca-sistema { color: #eafaf1; font-size: 12.5px; font-weight: 800; }
.encabezado .marca-negocio { font-size: 11.5px; font-weight: 600; color: #bfe4cf; }
.marca-negocio { margin: 0; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acceso-marca .marca-negocio { font-weight: 600; color: var(--tinta-suave); }
.estado-lectura { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; font-size: 11px; color: #eafaf1; white-space: nowrap; }
#estadoTexto { display: flex; align-items: center; gap: 5px; max-width: 46vw; overflow: hidden; }
#estadoTexto > span { overflow: hidden; text-overflow: ellipsis; }
#vendedor { font-weight: 600; }
.punto { width: 8px; height: 8px; border-radius: 50%; background: #ffd166; display: inline-block; }
.punto.ok { background: #7ee2a8; }
.punto.mal { background: #ff8a80; }
#menu { color: #fff; font-size: 20px; line-height: 1; }
.menu-lista {
  position: absolute; right: 10px; top: calc(100% - 4px);
  background: var(--blanco); color: var(--tinta);
  border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra);
  overflow: hidden; min-width: 210px;
}
.menu-lista button { display: block; width: 100%; text-align: left; border: 0; background: var(--blanco); padding: 12px 14px; }
.menu-lista button + button { border-top: 1px solid var(--borde); }

/* ---------- cuerpo ---------- */
#contenido { padding: 12px 12px calc(140px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.cinta {
  margin: 0 0 10px; padding: 9px 12px; border-radius: 8px;
  background: var(--ambar-suave); color: var(--ambar); font-size: 13px;
}
.cinta.error { background: var(--rojo-suave); color: var(--rojo); }
.ayuda { margin: 0 0 8px; font-size: 12px; color: var(--tinta-suave); }

/* ---------- buscador y sugerencias ---------- */
.buscador { display: flex; gap: 6px; }
.buscador input {
  flex: 1; border: 1px solid var(--borde); border-radius: 8px; background: var(--blanco);
  padding: 11px 12px; font-size: 16px; min-width: 0;
}
.buscador .boton { background: var(--verde); border-color: var(--verde); color: #fff; font-size: 20px; line-height: 1; padding: 0 16px; }
.lista { list-style: none; margin: 0; padding: 0; }
.sugerencias {
  margin-top: 6px; background: var(--blanco); border: 1px solid var(--borde);
  border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden;
  max-height: 45vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sugerencias .fila { border-bottom: 1px solid var(--borde); }
.sugerencias .fila:last-child { border-bottom: 0; }

/* una sola linea por registro, sin espaciado vertical de sobra */
.fila {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; border-bottom: 1px solid var(--borde); background: transparent;
  padding: 8px 2px; text-align: left; cursor: pointer;
}
.fila:last-child { border-bottom: 0; }
.fila .nombre { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .sub { display: block; font-size: 11px; color: var(--tinta-suave); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila .dato { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fila .flecha { color: var(--tinta-suave); }
.fila .sin-existencia { color: var(--rojo); }
.etiqueta { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--verde-suave); color: var(--verde-oscuro); white-space: nowrap; }
.etiqueta.gris { background: #eef2ef; color: var(--tinta-suave); }
.etiqueta.roja { background: var(--rojo-suave); color: var(--rojo); }
.etiqueta.ambar { background: var(--ambar-suave); color: var(--ambar); }
.vacio { padding: 14px 2px; color: var(--tinta-suave); font-size: 13px; }

/* ---------- carrito ---------- */
.carrito { margin: 10px 0 0; background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 0 10px; }
.carrito .fila { padding: 7px 0; }
.paso { display: flex; align-items: center; gap: 2px; }
.paso .boton { font-size: 17px; line-height: 1; padding: 5px 10px; border: 1px solid var(--borde); border-radius: 8px; background: var(--verde-suave); color: var(--verde-oscuro); font-weight: 700; }
.cantidad {
  width: 62px; border: 1px solid var(--borde); border-radius: 8px; padding: 6px 4px;
  font-size: 15px; text-align: right; font-variant-numeric: tabular-nums; background: var(--blanco);
  -moz-appearance: textfield; appearance: textfield;
}
.cantidad::-webkit-outer-spin-button, .cantidad::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cantidad:focus { outline: 2px solid var(--verde); outline-offset: 1px; }
.quitar { color: var(--rojo); font-size: 15px; padding: 5px 8px; }
.aviso-mayoreo {
  margin: 8px 0 0; padding: 8px 10px; border-radius: 8px;
  background: var(--verde-suave); color: var(--verde-oscuro); font-size: 12.5px;
}
#datosCliente { margin-top: 10px; background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 8px 10px; }
#datosCliente summary { font-size: 13px; color: var(--verde-oscuro); font-weight: 600; cursor: pointer; }
#datosCliente .campo { margin-top: 8px; }

.pie-fijo {
  position: fixed; left: 0; right: 0; bottom: calc(52px + env(safe-area-inset-bottom)); z-index: 9;
  display: flex; align-items: center; gap: 10px;
  max-width: 720px; margin: 0 auto; padding: 8px 12px;
  background: var(--blanco); border-top: 1px solid var(--borde); box-shadow: var(--sombra);
}
.pie-fijo > div { flex: 1; min-width: 0; }
.etiqueta-total { font-size: 11px; color: var(--tinta-suave); text-transform: uppercase; letter-spacing: .04em; }
.total { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pie-fijo .boton { flex: 0 0 auto; }

/* ---------- hoja de detalle ---------- */
.hoja { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; background: rgba(16, 32, 24, .42); }
.hoja-cabecera {
  display: flex; align-items: center; gap: 8px;
  background: var(--verde); color: #fff; padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
}
.hoja-cabecera #cerrarHoja { color: #fff; font-size: 17px; }
.hoja-cabecera p { font-weight: 600; }
.hoja-cuerpo { flex: 1; overflow: auto; background: var(--fondo); padding: 12px; -webkit-overflow-scrolling: touch; }
.hoja-pie { display: flex; gap: 8px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: var(--blanco); border-top: 1px solid var(--borde); }
.hoja-pie .boton { flex: 1; }
.hoja-pie .boton:disabled { opacity: .5; }

.ticket { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; font-size: 13px; }
.ticket h4 { margin: 0 0 2px; font-size: 15px; text-align: center; }
.ticket .centro { text-align: center; color: var(--tinta-suave); font-size: 12px; margin-top: 2px; }
.ticket hr { border: 0; border-top: 1px dashed var(--borde); margin: 8px 0; }
.linea-iso { display: flex; justify-content: space-between; gap: 8px; padding: 1px 0; }
.linea-iso span:first-child { color: var(--tinta-suave); }
.linea-iso span:last-child { font-variant-numeric: tabular-nums; text-align: right; }
.linea-iso.total { font-size: 16px; font-weight: 700; }
.linea-iso.total span:first-child { color: var(--tinta); }
.ticket .nota { font-size: 11px; color: var(--tinta-suave); }

/* ---------- aviso flotante ---------- */
.mensaje {
  position: fixed; left: 12px; right: 12px; bottom: calc(120px + env(safe-area-inset-bottom)); z-index: 30;
  margin: 0 auto; max-width: 460px; padding: 11px 13px; border-radius: var(--radio);
  background: var(--tinta); color: #fff; font-size: 13.5px; box-shadow: var(--sombra);
}
.mensaje.ok { background: var(--verde-oscuro); }
.mensaje.mal { background: var(--rojo); }

/* ---------- pestañas ---------- */
.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--blanco); border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
}
.pestanas button { position: relative; border: 0; background: transparent; padding: 8px 1px 6px; color: var(--tinta-suave); font-size: 11px; }
.pestanas button span { display: block; }
.pestanas button::before { content: ""; display: block; width: 22px; height: 22px; margin: 0 auto 3px; border-radius: 6px; background: #e8eee9; }
/* Carretilla, factura apartada y reloj de historial. */
.pestanas button[data-vista="vender"]::before { clip-path: polygon(0 8%, 16% 8%, 26% 34%, 92% 34%, 80% 70%, 36% 70%, 32% 58%, 22% 58%, 28% 78%, 88% 78%, 100% 34%, 24% 34%, 16% 0, 0 0); }
.pestanas button[data-vista="apartadas"]::before { clip-path: polygon(12% 0, 70% 0, 100% 30%, 100% 100%, 12% 100%); }
.pestanas button[data-vista="historial"]::before { clip-path: polygon(50% 0, 82% 14%, 100% 50%, 82% 86%, 50% 100%, 18% 86%, 0 50%, 18% 14%); }
.pestanas button.activa { color: var(--verde-oscuro); font-weight: 700; }
.pestanas button.activa::before { background: var(--verde); }
.pestanas b {
  position: absolute; top: 4px; right: calc(50% - 20px);
  min-width: 17px; height: 17px; border-radius: 999px; background: var(--rojo); color: #fff;
  font-size: 10.5px; line-height: 17px; text-align: center; padding: 0 4px;
}

@media (min-width: 520px) {
  .cantidad { width: 72px; }
}
