:root {
  --fondo: #f6f6f4; --tarjeta: #fff; --texto: #1b1b1b; --suave: #6b6b6b; --borde: #e2e2de;
  --acento: #f5b800; --acento-texto: #111; --rojo: #c62828; --verde: #2e7d32; --azul: #1565c0;
  --radio: 12px;
  --serie: #1565c0; --rejilla: #ecece8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--fondo); color: var(--texto); font-size: 16px; }
button, input, select, textarea { font: inherit; }
.barra { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: #111; color: #fff; flex-wrap: wrap; }
.barra a { color: #fff; text-decoration: none; }
.marca { font-weight: 800; color: var(--acento) !important; margin-right: 8px; }
.barra nav { display: flex; gap: 14px; flex: 1; flex-wrap: wrap; }
.barra nav a { opacity: .8; } .barra nav a.activo { opacity: 1; border-bottom: 2px solid var(--acento); }
.enlace { background: none; border: 0; color: inherit; cursor: pointer; text-decoration: underline; padding: 0; }
main { max-width: 980px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.4rem; margin: 4px 0 14px; } h2 { font-size: 1.1rem; margin: 18px 0 8px; }
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; margin-bottom: 12px; overflow-x: auto; }
#btnSalir { margin-left: auto; order: 2; }
.fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.fila > .crece { flex: 1; min-width: 180px; }
label { display: block; font-size: .85rem; color: var(--suave); margin-bottom: 4px; }
label.fila { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; font-size: .95rem; }
label.fila input[type=checkbox] { flex: none; width: 20px !important; height: 20px; margin: 0; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--borde); border-radius: 10px; background: #fff; color: var(--texto); }
input:focus, select:focus { outline: 2px solid var(--acento); border-color: transparent; }
.btn { display: inline-block; text-decoration: none; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; background: #e9e9e5; color: var(--texto); font-weight: 600; }
.btn.principal { background: var(--acento); color: var(--acento-texto); }
.btn.peligro { background: #fbe9e9; color: var(--rojo); }
.btn.chico { padding: 6px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }
.segmento { display: inline-flex; border: 1px solid var(--borde); border-radius: 10px; overflow: hidden; }
.segmento button { border: 0; background: #fff; padding: 9px 14px; cursor: pointer; font-weight: 600; }
.segmento button.activo { background: #111; color: #fff; }
.lista-busqueda { border: 1px solid var(--borde); border-radius: 10px; margin-top: 6px; max-height: 280px; overflow: auto; background: #fff; }
.lista-busqueda button { display: flex; justify-content: space-between; gap: 8px; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--borde); background: #fff; cursor: pointer; }
.lista-busqueda button:hover { background: #fafaf5; }
.suave { color: var(--suave); font-size: .85rem; }
.linea { border-top: 1px solid var(--borde); padding: 12px 0; }
.linea:first-child { border-top: 0; }
.linea-cab { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.linea-campos { display: grid; grid-template-columns: auto 90px 120px auto; gap: 8px; align-items: end; margin-top: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { border: 1px solid var(--borde); background: #fff; border-radius: 999px; padding: 4px 10px; font-size: .85rem; cursor: pointer; }
.alerta { color: var(--rojo); font-size: .85rem; font-weight: 600; }
.total { display: flex; justify-content: space-between; font-size: 1.4rem; font-weight: 800; margin: 8px 0 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--borde); vertical-align: top; }
th { font-size: .8rem; color: var(--suave); font-weight: 600; }
td.num, th.num { text-align: right; white-space: nowrap; }
.etiqueta { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.e-cotizacion { background: #fff4d6; color: #8a6300; } .e-pagada { background: #e3f3e4; color: var(--verde); } .e-anulada { background: #eee; color: #777; }
.recibo { background: #fff; max-width: 640px; margin: 0 auto; padding: 24px; border: 1px solid var(--borde); border-radius: var(--radio); }
.recibo-cab { display: flex; gap: 14px; align-items: center; border-bottom: 1px solid var(--borde); padding-bottom: 14px; margin-bottom: 10px; }
.recibo-logo { width: 80px; height: 80px; border-radius: 12px; background: #111; object-fit: cover; flex: none; }
.recibo-datos div { display: flex; justify-content: space-between; padding: 5px 0; font-size: .92rem; }
.recibo-datos b { text-align: right; }
.recibo-total { display: flex; justify-content: space-between; font-size: 1.5rem; font-weight: 800; margin-top: 16px; }
.solo-dueno { background: #f2f7ff; border: 1px dashed var(--azul); border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-size: .9rem; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 14px 0; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-caja { background: #fff; border-radius: var(--radio); padding: 18px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; }
.modal-caja table td, .modal-caja table th { font-size: .85rem; padding: 6px 4px; }
.modal-caja .fila { margin-top: 12px; justify-content: flex-end; }
.aviso { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100% - 32px); }
.aviso.error { background: var(--rojo); }
.cargando { color: var(--suave); }
.entrar { max-width: 360px; margin: 40px auto; }
.entrar .tarjeta > * + * { margin-top: 10px; }
@media (max-width: 600px) {
  .linea-campos { grid-template-columns: 1fr 1fr; }
  .barra nav { order: 3; width: 100%; flex: none; }
  th, td { padding: 8px 4px; font-size: .9rem; }
  .recibo { padding: 16px; border: 0; }
}
@media print {
  body { background: #fff; }
  .barra, .acciones, .solo-dueno, .no-imprimir { display: none !important; }
  main { padding: 0; } .recibo { border: 0; }
}

/* Estadísticas */
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.filtros .segmento { flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 8px; }
.tile { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; }
.tile-t { font-size: .85rem; color: var(--suave); }
.tile-v { font-size: 1.5rem; font-weight: 800; margin: 4px 0; }
.barra-meta { height: 8px; background: var(--rejilla); border-radius: 999px; overflow: hidden; margin: 6px 0; }
.barra-meta span { display: block; height: 100%; background: var(--serie); border-radius: 999px; }
.graf-env { position: relative; margin-top: 8px; }
.graf-env svg { display: block; max-width: 100%; }
.eje { font-size: 11px; fill: var(--suave); }
.tip { position: absolute; background: #111; color: #fff; padding: 8px 10px; border-radius: 8px; font-size: .8rem; pointer-events: none; width: 140px; }
.e-urgente { background: #fde7e7; color: var(--rojo); }
.filtros .fila { flex-wrap: wrap; }
.filtros label.fila { flex-wrap: nowrap; }
.filtros input[type=date] { width: auto; min-width: 0; max-width: 160px; padding: 8px; }

/* Vender estilo punto de venta: catálogo con fotos + carrito */
main:has(.pos) { max-width: 1400px; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.pos-cab { margin-bottom: 10px; }
.catalogo { min-width: 0; }
.chips-cat { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0; scrollbar-width: thin; }
.chip-cat { flex: none; border: 1px solid var(--borde); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: .8rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.chip-cat.activo { background: var(--acento); border-color: var(--acento); color: var(--acento-texto); }
.rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.prod { display: flex; flex-direction: column; align-items: center; gap: 4px; background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 10px 8px; cursor: pointer; text-align: center; font: inherit; color: inherit; position: relative; }
.prod:hover { border-color: var(--acento); }
.prod.en-carrito { border: 2px solid var(--acento); }
.prod img, .prod .sin-foto { width: 88px; height: 88px; object-fit: contain; border-radius: 8px; }
.prod .sin-foto { display: grid; place-items: center; background: #f0efe9; color: var(--suave); font-weight: 800; font-size: 1.3rem; }
.prod-precio { font-weight: 800; }
.prod-precio small { font-weight: 600; color: var(--suave); }
.prod-nombre { font-size: .8rem; line-height: 1.2; min-height: 2.4em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.prod-stock { font-size: .72rem; color: var(--verde); background: #e9f5ea; border-radius: 999px; padding: 2px 8px; }
.prod.agotado .prod-stock { color: var(--rojo); background: #fdeaea; }
.prod.agotado img { opacity: .5; }
.carrito { position: sticky; top: 64px; background: #fff; border: 1px solid var(--borde); border-radius: var(--radio); padding: 14px; max-height: calc(100vh - 80px); overflow: auto; }
.carrito-cab { margin-bottom: 8px; }
.carrito .linea-campos { grid-template-columns: 1fr 1fr; }
.linea-cab img.mini { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; flex: none; }
.linea-cab { align-items: center; }
.cantidad { display: flex; align-items: stretch; }
.cantidad input { text-align: center; border-radius: 0; min-width: 0; padding: 8px 4px; }
.cantidad button { border: 1px solid var(--borde); background: #f4f4f1; width: 38px; font-size: 1.1rem; cursor: pointer; }
.cantidad button:first-child { border-radius: 10px 0 0 10px; border-right: 0; }
.cantidad button:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.botones-venta { display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px; margin-top: 10px; }
.solo-movil { display: none; }
.barra-carrito { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 8; justify-content: space-between; align-items: center; gap: 8px; background: #111; color: #fff; border: 0; border-radius: 12px; padding: 14px 16px; font: inherit; cursor: pointer; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
@media (max-width: 900px) {
  .pos { grid-template-columns: 1fr; }
  .carrito { display: none; position: static; max-height: none; }
  .pos.ver-carrito .catalogo { display: none; }
  .pos.ver-carrito .carrito { display: block; }
  .pos.ver-carrito .barra-carrito { display: none !important; }
  .solo-movil { display: inline-block; }
  .barra-carrito.solo-movil { display: flex; }
  .rejilla { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 8px; }
  .prod img, .prod .sin-foto { width: 72px; height: 72px; }
  .catalogo { padding-bottom: 80px; }
}
.mini-tabla { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; flex: none; }
@media (max-width: 900px) { .aviso { bottom: 84px; } }
.sin-foto-mini { display: inline-grid; place-items: center; background: #f0efe9; color: var(--suave); font-size: .7rem; font-weight: 800; }
.modal-caja label.fila { justify-content: flex-start; }
.cambios { margin-top: 12px; padding: 10px 12px; background: #fff8e6; border-radius: 10px; }
.caja-abierta { background: #e3f3e4; color: var(--verde); }
.prod-cliente { font-size: .72rem; font-weight: 700; color: var(--azul); background: #e8f0fb; border-radius: 999px; padding: 2px 8px; }

/* Mi capital */
.avisos-cap { background: #fff8e6; border-color: #f3d27a; }
.avisos-cap div { padding: 2px 0; }
.dos-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 700px) { .dos-col { grid-template-columns: 1fr; } }
details summary { cursor: pointer; margin-top: 8px; }

/* Gasto: 4 formas de pago, que bajen de línea en pantallas chicas */
#gmet { display: flex; flex-wrap: wrap; }
#gmet button { flex: 1 1 auto; }

/* Recibo en ticket de impresora térmica (80 o 58 mm). Se activa con el botón "Ticket". */
@media print {
  body.ticket { font-family: Arial, Helvetica, sans-serif; color: #000; }
  body.ticket .recibo { max-width: none; width: var(--ancho-ticket, 72mm); margin: 0; padding: 0 1mm; border: 0; border-radius: 0; font-size: 11px; line-height: 1.25; }
  body.ticket .recibo-cab { display: block; text-align: center; padding-bottom: 4px; margin-bottom: 4px; border-bottom: 1px dashed #000; }
  body.ticket .recibo-cab > div:last-child > div:first-child { font-size: 14px !important; }
  body.ticket .recibo-logo { display: none; }
  body.ticket .recibo-datos div { padding: 1px 0; font-size: 11px; }
  body.ticket table { font-size: 10.5px; }
  body.ticket th, body.ticket td { padding: 2px 1px; border-color: #000; }
  body.ticket .recibo-total { font-size: 15px; margin-top: 6px; border-top: 1px dashed #000; padding-top: 4px; }
  body.ticket .cambios { display: none !important; }
}

/* Deudas (como Treinta) */
.deuda-total { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.deuda-cli { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 8px; }
.deuda-cli:hover { border-color: #bbb; }
.globo { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 999px; background: #e5f5ec; color: var(--verde); font-weight: 800; font-size: .85rem; }
.flecha { font-size: 1.6rem; color: var(--suave); line-height: 1; }
.deuda-linea { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.deuda-linea .resumen { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; }
.icono-deuda { width: 30px; height: 30px; flex: none; border-radius: 8px; background: #e5f5ec; color: var(--verde); display: grid; place-items: center; font-weight: 800; }
.tachado { text-decoration: line-through; color: var(--rojo); font-size: .8rem; }
.mini-acciones { font-size: .8rem; margin-top: 4px; white-space: nowrap; }

/* Inicio y días rápidos */
.hoy-card { max-width: 640px; }
.atajos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; max-width: 640px; }
.atajo { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; margin: 0; }
.atajo:hover { border-color: #bbb; }
.dias-rapidos { gap: 6px; }
.dias-rapidos .chip.activo { background: #111; color: #fff; }

.barra-tipos { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--rejilla, #eee); }
.barra-tipos span { display: block; height: 100%; }

/* Egresos agrupados */
.egr-grupo { border: 1px solid var(--borde); border-radius: 12px; margin-bottom: 8px; background: var(--tarjeta, #fff); overflow: hidden; }
.egr-grupo.abierto { border-color: #bbb; }
.egr-cab { display: flex; align-items: center; gap: 10px; padding: 12px; cursor: pointer; }
.egr-icono { width: 40px; height: 40px; flex: none; border-radius: 10px; background: #fdeaea; display: grid; place-items: center; font-size: 1.3rem; }
.egr-barra { height: 6px; background: #f0f0ee; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.egr-barra span { display: block; height: 100%; background: var(--rojo); border-radius: 999px; }
.egr-lista { border-top: 1px solid var(--borde); background: #fafaf8; padding: 0 12px; }
.egr-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--borde); }
.egr-item:last-child { border-bottom: 0; }
#egAgr { flex-wrap: wrap; }

/* Cobrar: cambio a devolver */
.cambio-caja { background: #f6f6f3; border: 1px solid var(--borde); border-radius: 10px; padding: 10px; margin-top: 8px; }
.cambio-resultado { font-size: 1.35rem; margin-top: 8px; min-height: 1.6rem; }
.cambio-resultado b { color: var(--verde); font-size: 1.6rem; }
