/* DERPE v3.4 p100 TPV de mini-crm: panel (tpv-panel), pantalla de venta táctil (tpv-venta) y ticket impreso de 80 o 58 mm (tpv-ticket, prefijo tk-).
   Colores de las formas de pago: paleta categórica de referencia en orden fijo (efectivo, tarjeta, Bizum, otro), validada para daltonismo. */

:root {
    --tpv-oscuro: #15171c;
    --tpv-oscuro-2: #23262e;
    --tpv-tenue: #9aa0ab;
    --tpv-cobrar: #16a34a;
    --tpv-cobrar-hover: #15803d;
    --tpv-borde: #e6e8ee;
    --tpv-fondo: #f3f4f7;
    --tpv-c1: #2a78d6;
    --tpv-c2: #eb6834;
    --tpv-c3: #1baf7a;
    --tpv-c4: #eda100;
}

/* ─── Panel ─── */
.tpv-kpi .fs-3 { letter-spacing: -.02em; }
.tpv-caja { border-top: 4px solid var(--tpv-borde); }
.tpv-caja-abierta { border-top-color: var(--tpv-cobrar); }
.tpv-grafica { min-height: 240px; }
.tpv-muestra { display: inline-block; width: .75rem; height: .75rem; border-radius: 3px; margin-right: .4rem; vertical-align: -1px; }
.tpv-c1 { background: var(--tpv-c1); } .tpv-c2 { background: var(--tpv-c2); } .tpv-c3 { background: var(--tpv-c3); } .tpv-c4 { background: var(--tpv-c4); }
.tpv-barra { height: .6rem; background: #eef0f3; border-radius: 4px; overflow: hidden; margin-top: .3rem; }
.tpv-barra-valor { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.tpv-puesto { display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--tpv-fondo); font-weight: 700; font-size: .8rem; }
.tpv-filtro { width: auto; }
.tpv-impresion { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }

/* ─── Mesas (panel y venta) ─── */
.tpv-plano { display: grid; gap: .5rem; background: var(--tpv-fondo); border-radius: 12px; padding: .75rem; overflow-x: auto; }
.tpv-mesa, .tpv-hueco { aspect-ratio: 1 / 1; min-height: 52px; border-radius: 12px; border: 2px solid transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .8rem; line-height: 1.1; transition: transform .1s; }
.tpv-mesa:active { transform: scale(.96); }
.tpv-hueco { background: transparent; border: 2px dashed #d4d7de; color: #b4b9c3; }
.tpv-hueco:hover { border-color: #9aa0ab; color: #52514e; }
.tpv-hueco-vacio { border: 0; }
.tpv-mesa-nombre { font-weight: 700; font-size: .95rem; }
.tpv-mesa-tipo-barra { border-radius: 50%; }
.tpv-mesa-libre { background: #ffffff; border-color: #cfe8d8; color: #14532d; }
.tpv-mesa-ocupado { background: var(--tpv-oscuro); color: #fff; border-color: var(--tpv-oscuro); }
.tpv-mesa-reservado { background: #fff4d6; border-color: #e8c66a; color: #6b4e00; }
.tpv-mesa-bloqueado { background: #e5e7eb; border-color: #cbd0d8; color: #6b7280; }
.tpv-mesa-actual { box-shadow: 0 0 0 3px var(--tpv-cobrar); }
.tpv-mesa-total { font-weight: 700; color: #86efac; }

/* DERPE v3.4 p101 Editor de salas: recolocar mesas arrastrando (sólo a huecos libres) y panel lateral de configuración */
#tpvSalas .tpv-mesa { cursor: grab; touch-action: none; }
.tpv-mesa.tpv-arrastrando { opacity: .35; }
.tpv-fantasma { position: fixed; z-index: 2000; pointer-events: none; margin: 0; cursor: grabbing; transform: scale(1.06); box-shadow: 0 10px 24px rgba(21, 23, 28, .25); }
.tpv-plano-arrastre .tpv-hueco { border-color: #b4b9c3; }
.tpv-hueco.tpv-destino { border: 2px solid var(--tpv-c1); background: #e8f1fb; color: var(--tpv-c1); }
.tpv-mesa.tpv-prohibido { box-shadow: 0 0 0 3px #d03b3b; }
.tpv-ajustes { width: 420px; max-width: 100%; }
.tpv-mesa-hora, .tpv-mesa-plazas { font-size: .72rem; opacity: .8; }
.tpv-muestra.tpv-mesa-libre, .tpv-muestra.tpv-mesa-ocupado, .tpv-muestra.tpv-mesa-reservado, .tpv-muestra.tpv-mesa-bloqueado { border: 1px solid #cbd0d8; }

/* ─── Pantalla de venta ─── */
body.tpv-cuerpo { background: var(--tpv-fondo); overflow: hidden; }
.tpv-venta { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.min-w-0 { min-width: 0; }
.tpv-barra-superior { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem; background: var(--tpv-oscuro); color: #fff; flex-wrap: wrap; }
.tpv-marca { width: 40px; height: 40px; border-radius: 10px; background: var(--crm-red, #ff6b8b); display: inline-flex; align-items: center; justify-content: center; font-size: 1.25rem; }
.tpv-tenue { color: var(--tpv-tenue); }
.tpv-reloj { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tpv-boton-barra { position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 64px; padding: .35rem .6rem; border-radius: 10px; background: var(--tpv-oscuro-2); color: #fff; border: 0; font-size: .72rem; text-decoration: none; }
.tpv-boton-barra i { font-size: 1.2rem; }
.tpv-boton-barra:hover { background: #31353f; color: #fff; }
.tpv-contador { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--tpv-c2); font-size: .7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 5px; }
.tpv-cuerpo-venta { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 400px; min-height: 0; }
.tpv-catalogo { display: flex; flex-direction: column; min-height: 0; padding: .75rem; gap: .6rem; }
.tpv-buscador { display: flex; align-items: center; gap: .6rem; background: #fff; border: 1px solid var(--tpv-borde); border-radius: 12px; padding: .4rem .5rem .4rem .9rem; }
.tpv-buscador i { font-size: 1.3rem; color: #6b7280; }
.tpv-buscador input { flex: 1; border: 0; outline: none; font-size: 1.05rem; padding: .35rem 0; background: transparent; min-width: 0; }
.tpv-categorias { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .2rem; flex-wrap: nowrap; scrollbar-width: thin; }
.tpv-categoria { flex: 0 0 auto; border: 1px solid var(--tpv-borde); background: var(--tpv-tinte, #fff); border-radius: 999px; padding: .55rem 1rem; font-weight: 600; font-size: .9rem; color: #1f2430; white-space: nowrap; }
.tpv-categoria.activa { background: var(--tpv-oscuro); color: #fff; border-color: var(--tpv-oscuro); }
.tpv-categoria-n { font-weight: 500; opacity: .6; font-size: .8rem; }
.tpv-productos { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; align-content: start; padding-bottom: 1rem; }
.tpv-producto { display: flex; flex-direction: column; text-align: left; background: #fff; border: 1px solid var(--tpv-borde); border-radius: 14px; overflow: hidden; padding: 0; transition: transform .08s, box-shadow .15s; min-height: 170px; }
.tpv-producto:hover { box-shadow: 0 .4rem 1rem rgba(0, 0, 0, .08); }
.tpv-producto:active { transform: scale(.97); }
.tpv-producto-imagen { position: relative; display: flex; align-items: center; justify-content: center; height: 92px; background: var(--tpv-tinte, #eef0f3); }
.tpv-producto-imagen img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tpv-iniciales { font-size: 1.6rem; font-weight: 700; color: rgba(31, 36, 48, .55); }
.tpv-producto-nombre { padding: .45rem .6rem 0; font-weight: 600; font-size: .9rem; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tpv-producto-pie { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: .3rem; padding: .3rem .6rem .5rem; }
.tpv-producto-precio { font-weight: 700; font-size: 1rem; }
.tpv-producto-stock { font-size: .7rem; color: #6b7280; }
.tpv-producto-stock.tpv-poco { color: #b45309; font-weight: 600; }
.tpv-producto-stock.tpv-sin { color: #dc2626; font-weight: 700; }
.tpv-agotado .tpv-producto-imagen { filter: grayscale(.8); opacity: .7; }
.tpv-vacio { grid-column: 1 / -1; text-align: center; color: #6b7280; padding: 3rem 1rem; }
.tpv-ticket { display: flex; flex-direction: column; min-height: 0; background: #fff; border-left: 1px solid var(--tpv-borde); }
.tpv-ticket-cabecera { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .8rem 1rem; border-bottom: 1px solid var(--tpv-borde); }
.tpv-lineas { flex: 1; overflow-y: auto; }
.tpv-ticket-vacio { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; height: 100%; color: #9aa0ab; padding: 2rem; text-align: center; }
.tpv-ticket-vacio i { font-size: 2.5rem; }
.tpv-linea { display: grid; grid-template-columns: minmax(0, 1fr) auto 76px; align-items: center; gap: .5rem; padding: .55rem .8rem; border-bottom: 1px solid #f1f2f5; }
.tpv-linea-texto { display: flex; flex-direction: column; text-align: left; background: none; border: 0; padding: 0; min-width: 0; }
.tpv-linea-texto span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpv-cantidad { display: flex; align-items: center; gap: .25rem; }
.tpv-cantidad button { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--tpv-borde); background: var(--tpv-fondo); display: inline-flex; align-items: center; justify-content: center; }
.tpv-cantidad span { min-width: 28px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.tpv-linea-total { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.tpv-totales { padding: .7rem 1rem; border-top: 1px solid var(--tpv-borde); background: #fafbfc; }
.tpv-total { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tpv-acciones { display: grid; grid-template-columns: 1fr 1.6fr; gap: .5rem; padding: .7rem 1rem 1rem; }
.tpv-boton-cobrar { background: var(--tpv-cobrar); color: #fff; font-weight: 700; font-size: 1.15rem; border: 0; }
.tpv-boton-cobrar:hover, .tpv-boton-cobrar:focus { background: var(--tpv-cobrar-hover); color: #fff; }
.tpv-boton-cobrar:disabled { background: #a7d7b8; color: #fff; }

/* Ventanas de la venta */
.tpv-modal { border-radius: 16px; }
.tpv-total-grande { font-size: 3rem; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tpv-formas { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.tpv-forma { display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .8rem .4rem; border-radius: 12px; border: 2px solid var(--tpv-borde); background: #fff; font-weight: 600; }
.tpv-forma i { font-size: 1.5rem; }
.tpv-forma.activa { border-color: var(--tpv-oscuro); background: var(--tpv-oscuro); color: #fff; }
.tpv-importe { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tpv-billetes { display: flex; flex-wrap: wrap; gap: .4rem; }
.tpv-billetes .btn { flex: 1 0 auto; font-weight: 600; }
.tpv-cambio { display: flex; justify-content: space-between; align-items: baseline; padding: .7rem .9rem; border-radius: 12px; background: var(--tpv-fondo); }
.tpv-cambio strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.tpv-teclado { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.tpv-teclado button { height: 58px; border-radius: 12px; border: 1px solid var(--tpv-borde); background: #fff; font-size: 1.4rem; font-weight: 600; }
.tpv-teclado button:active { background: var(--tpv-fondo); }
.tpv-teclado.tpv-inactivo { opacity: .35; pointer-events: none; }
.tpv-aviso-tarjeta { display: flex; align-items: center; gap: .8rem; padding: 1rem; border-radius: 12px; background: var(--tpv-fondo); }
.tpv-aviso-tarjeta i { font-size: 2rem; }
.tpv-mixto-forma { min-width: 90px; }
.tpv-hecho { width: 84px; height: 84px; margin: 0 auto; border-radius: 50%; background: var(--tpv-cobrar); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 3rem; }
.tpv-cambio-final { font-size: 1.4rem; }
.tpv-cambio-final strong { font-size: 2.4rem; display: block; }
.tpv-aparcado { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid #f1f2f5; }
.tpv-aparcado-abre { flex: 1; display: flex; flex-direction: column; text-align: left; background: none; border: 0; padding: 0; }
.tpv-dato { padding: .6rem .8rem; border-radius: 10px; background: var(--tpv-fondo); }
.tpv-dato-destacado { background: var(--tpv-oscuro); color: #fff; }
.tpv-dato-destacado .text-muted { color: var(--tpv-tenue) !important; }
.tpv-recuento { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .5rem; }
.tpv-denominacion { display: flex; align-items: center; gap: .4rem; background: var(--tpv-fondo); border-radius: 10px; padding: .35rem .5rem; font-weight: 600; font-size: .85rem; }
.tpv-denominacion span { min-width: 44px; }
.tpv-cuadre > div { min-width: 120px; }
.tpv-plano-venta .tpv-mesa { min-height: 72px; }

@media (max-width: 991.98px) {
    body.tpv-cuerpo { overflow: auto; }
    .tpv-venta { height: auto; min-height: 100vh; }
    .tpv-cuerpo-venta { grid-template-columns: 1fr; }
    .tpv-productos { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); max-height: 55vh; }
    .tpv-ticket { border-left: 0; border-top: 1px solid var(--tpv-borde); }
    .tpv-lineas { max-height: 40vh; }
    .tpv-boton-barra span:not(.tpv-contador) { display: none; }
    .tpv-boton-barra { min-width: 44px; }
    .tpv-formas { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Ticket impreso (tk-) ─── */
body.tk-pagina { background: #fff; margin: 0; color: #000; }
.tk-papel { font-family: "Courier New", ui-monospace, monospace; font-size: 12px; line-height: 1.35; padding: 4mm 3mm; margin: 0 auto; }
.tk-80 { width: 72mm; }
.tk-58 { width: 48mm; font-size: 10.5px; }
.tk-centro { text-align: center; }
.tk-negrita { font-weight: 700; }
.tk-grande { font-size: 1.25em; }
.tk-pequeno { font-size: .85em; }
.tk-fila { display: flex; justify-content: space-between; gap: 2mm; }
.tk-concepto { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tk-raya { border: 0; border-top: 1px dashed #000; margin: 2mm 0; }
.tk-iva { width: 100%; border-collapse: collapse; font-size: .9em; }
.tk-iva th, .tk-iva td { text-align: right; padding: 0; }
.tk-iva th:first-child, .tk-iva td:first-child { text-align: left; }
.tk-qr { width: 32mm; height: 32mm; margin: 3mm auto 1mm; }
.tk-qr svg { width: 100%; height: 100%; }
.tk-pie { margin-top: 3mm; }
@media print {
    @page { margin: 0; size: 80mm auto; }
    .tk-58 { width: 48mm; }
}
