/* CuentaFácil · Pulpería San Antonio — consulta para el teléfono (solo lectura) */
: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; }
.marca-sistema { color: var(--verde); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; font-size: 12px; }
.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; }
.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: #d8f0e4; font-size: 10px; }
.marca-negocio { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.estado-lectura { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #eafaf1; white-space: nowrap; }
.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(70px + 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); }

.bloque { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 12px; margin-bottom: 10px; }
.bloque > h2, .bloque > h3 { margin: 0 0 8px; font-size: 13px; color: var(--tinta-suave); text-transform: uppercase; letter-spacing: .04em; }
.bloque.reportes h2 { color: var(--verde-oscuro); }

.cifras { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.cifra { background: var(--verde-suave); border-radius: 8px; padding: 9px 10px; }
.cifra b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.cifra span { font-size: 11px; color: var(--tinta-suave); }
.cifra.roja { background: var(--rojo-suave); }
.cifra.roja b { color: var(--rojo); }

/* 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 .dato { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fila .nota { font-size: 12px; color: var(--tinta-suave); white-space: nowrap; }
.fila .flecha { color: var(--tinta-suave); }
.etiqueta { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--verde-suave); color: var(--verde-oscuro); white-space: nowrap; }
.etiqueta.vencido { background: var(--rojo-suave); color: var(--rojo); }
.etiqueta.por-vencer { background: var(--ambar-suave); color: var(--ambar); }
.etiqueta.gris { background: #eef2ef; color: var(--tinta-suave); }
.vacio { padding: 14px 2px; color: var(--tinta-suave); font-size: 13px; }

.buscador { display: flex; gap: 8px; margin-bottom: 8px; }
.buscador input, .seleccion {
  flex: 1; border: 1px solid var(--borde); border-radius: 8px; background: var(--blanco);
  padding: 9px 10px; font-size: 15px; min-width: 0;
}
.seleccion { flex: 0 0 auto; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--borde); border-radius: 999px; background: var(--blanco); padding: 6px 11px; font-size: 13px; }
.chip.activa { background: var(--verde); border-color: var(--verde); color: #fff; }

.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th, .tabla td { text-align: left; padding: 5px 4px; border-bottom: 1px solid var(--borde); }
.tabla td.num, .tabla th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabla th { color: var(--tinta-suave); font-weight: 600; font-size: 11px; text-transform: uppercase; }

/* ---------- 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 .solo { color: var(--tinta-suave); }
.ticket .nota { font-size: 11px; }

/* ---------- pestañas ---------- */
.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--blanco); border-top: 1px solid var(--borde);
  padding-bottom: env(safe-area-inset-bottom);
}
.pestanas button { border: 0; background: transparent; padding: 9px 2px 7px; 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; }
.pestanas button[data-vista="hoy"]::before { clip-path: polygon(50% 0, 100% 38%, 100% 100%, 0 100%, 0 38%); }
.pestanas button[data-vista="ventas"]::before { clip-path: polygon(12% 0, 88% 0, 100% 22%, 100% 100%, 0 100%, 0 22%); }
.pestanas button[data-vista="fiado"]::before { clip-path: polygon(0 20%, 100% 20%, 100% 55%, 55% 55%, 55% 100%, 0 100%); }
.pestanas button[data-vista="inventario"]::before { clip-path: polygon(0 0, 100% 0, 100% 35%, 55% 35%, 55% 100%, 0 100%); }
.pestanas button[data-vista="reportes"]::before { clip-path: polygon(0 100%, 0 55%, 30% 55%, 30% 100%, 45% 100%, 45% 25%, 70% 25%, 70% 100%, 85% 100%, 85% 45%, 100% 45%, 100% 100%); }
.pestanas button.activa { color: var(--verde-oscuro); font-weight: 700; }
.pestanas button.activa::before { background: var(--verde); }

/* ---------- impresion / PDF ---------- */
.impresion { display: none; }
@media print {
  body > *:not(#impresion) { display: none !important; }
  #impresion { display: block; padding: 12px; background: #fff; }
  #impresion .ticket { border: 0; }
  @page { margin: 10mm; }
}

@media (min-width: 520px) {
  .cifras { grid-template-columns: repeat(4, 1fr); }
}
