:root {
  --bg: #f4efe6;
  --panel: #ffffff;
  --ink: #241a12;
  --muted: #8a7a68;
  --accent: #c65d2e;
  --accent-2: #2e6b5e;
  --border: #e2d6c4;
  --danger: #b8402f;
  --ok: #2e6b5e;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

input {
  font-family: inherit;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Login --- */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

.login-box h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.login-box p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field input, .field select {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 16px;
  background: var(--bg);
  color: var(--ink);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  background: var(--accent);
  color: white;
  font-size: 17px;
  font-weight: 700;
  margin-top: 8px;
}

.btn-primary:active { opacity: 0.85; }

.error-msg {
  color: var(--danger);
  font-size: 14px;
  margin-top: 10px;
}

/* --- POS header --- */
.pos-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.pos-header .titles h2 {
  margin: 0;
  font-size: 17px;
}

.pos-header .titles span {
  font-size: 12px;
  color: var(--muted);
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--ok);
}

.status-dot.off { background: var(--danger); }

.pos-header .right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.pill {
  background: var(--bg);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
}

.icon-btn {
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
}

/* --- Grid de productos --- */
.grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  align-content: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
}

.card:active { transform: scale(0.98); }

.card .thumb {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}

.card .info {
  padding: 10px 12px 14px;
}

.card .info .name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.card .info .price {
  color: var(--accent);
  font-weight: 700;
  font-size: 15px;
}

.card .info .ubicacion {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 4px;
}

.ubicacion-grande {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
}

.card .info .stock-low {
  color: var(--danger);
  font-size: 11px;
  margin-top: 2px;
}

.card { position: relative; }

.card.disabled .thumb,
.card.disabled .info {
  opacity: 0.4;
}

.card.disabled .thumb { filter: grayscale(1); }

/* Banda cruzada "SIN STOCK" sobre la foto */
.banda-sin-stock {
  position: absolute;
  top: 28%;
  left: -10%;
  width: 120%;
  transform: rotate(-12deg);
  background: var(--danger);
  color: white;
  text-align: center;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 2px;
  padding: 7px 0;
  z-index: 2;
}

/* Filtro por talle */
.filtros {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.filtro-btn {
  flex: none;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  padding: 10px 20px;
  border-radius: 999px;
}

.filtro-btn.activo {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.card .info .talle-detalle {
  color: var(--ok);
  font-weight: 700;
  font-size: 13px;
  margin-top: 4px;
}

.grid-vacia {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

/* --- Sheet modal --- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(36, 26, 18, 0.5);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}

.sheet {
  background: var(--panel);
  width: 100%;
  border-radius: 24px 24px 0 0;
  padding: 24px;
  max-height: 80vh;
  overflow-y: auto;
}

.sheet h3 {
  margin: 0 0 4px;
  font-size: 19px;
}

.sheet .sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 18px;
}

.option-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.option-btn {
  flex: 1;
  min-width: 90px;
  padding: 18px 10px;
  border-radius: 14px;
  border: 2px solid var(--border);
  background: var(--bg);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.option-btn .stock-tag {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 2px;
}

.option-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.option-btn.medio {
  padding: 26px 10px;
  font-size: 18px;
}

.option-btn.medio.efectivo { border-color: var(--ok); }
.option-btn.medio.posnet { border-color: var(--accent); }
.option-btn.medio.qr { border-color: #6b4fa0; }

.close-sheet {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
}

/* --- Confirmación / undo --- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 60;
}

.toast button {
  background: var(--accent);
  color: white;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
}

/* --- Admin --- */
.admin-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.tab-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}

.panel h3 {
  margin-top: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.summary-total {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
}

.product-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.product-block input {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin-bottom: 8px;
  width: 100%;
}

.variant-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}

.variant-row input { margin-bottom: 0; }

.btn-secondary {
  background: var(--bg);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
}

/* --- Carrito --- */
.cart-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  background: var(--ink);
  color: white;
}

.cart-resumen {
  display: flex;
  flex-direction: column;
  font-size: 14px;
}

.cart-resumen span {
  font-size: 22px;
  font-weight: 700;
}

.cart-cobrar {
  background: var(--accent);
  color: white;
  font-size: 18px;
  font-weight: 700;
  padding: 16px 34px;
  border-radius: 14px;
}

.cart-list {
  max-height: 34vh;
  overflow-y: auto;
  margin-bottom: 10px;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.cart-item-name { font-weight: 700; font-size: 15px; }
.cart-item-ubic { font-size: 12px; color: var(--muted); }

.cart-item-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.cart-quitar {
  background: var(--bg);
  color: var(--danger);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 16px;
}

.cart-total {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 14px;
}

/* --- Ventas de la caja (panel de venta) --- */
.btn-ventas {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 10px;
  margin-right: 8px;
}

.btn-anular {
  background: var(--bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  font-weight: 700;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 10px;
}

.venta-anulada .cart-item-name,
.venta-anulada .cart-item-right span {
  text-decoration: line-through;
  color: var(--muted);
}

.venta-anulada .cart-item-ubic { color: var(--danger); }

/* --- Cobro por QR de Mercado Pago --- */
.qr-monto {
  text-align: center;
  font-size: 40px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 4px;
}

.qr-img {
  width: min(300px, 42vh);
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: white;
}

.qr-alias {
  text-align: center;
  font-size: 15px;
  margin: 0 0 10px;
}

.qr-alias strong { font-size: 18px; }

/* --- Precio en efectivo --- */
.card .info .price-efectivo {
  color: var(--ok);
  font-weight: 700;
  font-size: 13px;
}

.cart-total-efectivo {
  color: var(--ok);
  font-size: 18px;
  margin-top: 2px;
}

/* --- Cambiar precio / regalo --- */
.cart-precio {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  padding: 6px 10px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.cart-precio small {
  font-size: 11px;
  font-weight: 600;
  color: var(--ok);
}

.cart-precio.manual {
  border-color: var(--accent);
  color: var(--accent);
}

.cart-precio.manual small { color: var(--accent); }

.btn-regalo {
  width: 100%;
  margin-top: 10px;
  background: #fbe9d0;
  border: 2px dashed var(--accent);
  color: var(--accent);
  font-weight: 800;
  font-size: 16px;
  padding: 14px;
  border-radius: 14px;
}

/* --- Billetes para pago en efectivo --- */
.billetes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.billete {
  background: #e7f0ea;
  border: 1px solid var(--ok);
  color: var(--ok);
  font-weight: 800;
  font-size: 15px;
  padding: 14px 4px;
  border-radius: 12px;
}

.billete.borrar {
  background: var(--bg);
  border-color: var(--danger);
  color: var(--danger);
}

/* --- Admin: corregir stock en vivo --- */
.btn-ajuste {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink);
  font-weight: 800;
  font-size: 18px;
  width: 38px;
  height: 34px;
  border-radius: 8px;
}

/* --- Resumen del show --- */
.rs-controles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.rs-controles select {
  flex: 1;
  min-width: 200px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 15px;
}

.rs-reporte h2 { margin: 2px 0; font-size: 22px; }
.rs-reporte h3 { font-size: 15px; margin: 0 0 10px; }
.rs-reporte p { margin: 4px 0; font-size: 14px; }

.rs-cabecera {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 3px solid var(--accent);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.rs-marca {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
}

.rs-sub { color: var(--muted); font-size: 13px; }
.rs-tabla td.rs-ancho { width: 100%; }
.rs-fecha { color: var(--muted); font-size: 12px; white-space: nowrap; }

.rs-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.rs-kpi {
  background: var(--bg);
  border-radius: 12px;
  padding: 12px 14px;
}

.rs-kpi span { display: block; font-size: 12px; color: var(--muted); }
.rs-kpi strong { font-size: 22px; }
.rs-kpi.principal { background: var(--accent); color: white; }
.rs-kpi.principal span { color: rgba(255, 255, 255, 0.85); }
.rs-kpi.principal strong { font-size: 26px; }

.rs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.rs-bloque { margin-bottom: 18px; }

.rs-tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.rs-tabla td, .rs-tabla th { padding: 6px 4px; border-bottom: 1px solid var(--border); vertical-align: middle; text-align: left; }
.rs-tabla th { font-size: 12px; color: var(--muted); font-weight: 600; }
.rs-tabla .rs-der { text-align: right; white-space: nowrap; }
.rs-tabla .rs-num { width: 34px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.rs-detalle tr.rs-apagado td { color: var(--muted); }
.rs-agotado { color: var(--danger) !important; font-weight: 800; }

/* Barras: una sola serie, un solo color, extremos redondeados */
.rs-barra {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  margin-top: 4px;
  overflow: hidden;
}

.rs-barra span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}

.rs-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.rs-chips span { background: var(--bg); padding: 6px 12px; border-radius: 999px; font-size: 13px; }

/* Al imprimir / guardar PDF: solo el informe */
@media print {
  body * { visibility: hidden; }
  #resumen-reporte, #resumen-reporte * { visibility: visible; }
  #resumen-reporte { position: absolute; left: 0; top: 0; width: 100%; border: none; box-shadow: none; }
  .rs-kpi, .rs-barra, .rs-barra span, .rs-chips span { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  section, .rs-kpis { break-inside: avoid; }
}

/* --- Barra del carrito fija abajo, siempre visible --- */
.cart-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  box-shadow: 0 -6px 20px rgba(36, 26, 18, 0.25);
  animation: subir 0.25s ease-out;
}

/* Que la grilla no quede tapada por la barra */
body.con-carrito .grid { padding-bottom: 110px; }

@keyframes subir {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Salto cada vez que se agrega algo */
.cart-bar.salto { animation: salto 0.45s ease-out; }

@keyframes salto {
  0% { transform: translateY(0); }
  30% { transform: translateY(-14px); }
  60% { transform: translateY(0); }
  80% { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}

/* Cartelito "✓ Agregado" arriba de la barra */
.cart-agregado {
  position: absolute;
  left: 16px;
  bottom: 100%;
  margin-bottom: 8px;
  background: var(--ok);
  color: white;
  font-weight: 700;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  max-width: calc(100% - 32px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-agregado.visible { animation: aviso 2.2s ease-out forwards; }

@keyframes aviso {
  0% { opacity: 0; transform: translateY(8px); }
  12% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* El toast de "cobrado / deshacer" va arriba de la barra */
body.con-carrito .toast { bottom: 110px; }

.v-encabezado {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  padding: 0 52px 4px 2px;
}

.p-oculto-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 10px;
}

.p-oculto-label input { width: auto; margin: 0; }

/* --- Admin: Cargar stock con fotos --- */
.admin-grid { padding: 0; overflow: visible; }
.card-nuevo .thumb { font-size: 48px; color: var(--accent); background: #fbe9d0; }
.card-nuevo { border: 2px dashed var(--accent); }
.card-oculta .thumb, .card-oculta .info { opacity: 0.45; }
.card-oculta .thumb { filter: grayscale(1); }

.banda-oculta {
  position: absolute;
  top: 28%;
  left: -10%;
  width: 120%;
  transform: rotate(-12deg);
  background: var(--muted);
  color: white;
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 2px;
  padding: 6px 0;
  z-index: 2;
}

.price-efvo-chico { display: block; color: var(--ok); font-size: 12px; }
.quedan-admin { font-size: 13px; margin-top: 4px; }
.talles-admin { font-size: 11px; color: var(--muted); margin-top: 2px; }

.editor-sheet { max-width: 620px; margin: 0 auto; max-height: 92vh; }
.editor-top { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }

.editor-foto {
  width: 84px;
  height: 84px;
  flex: none;
  border-radius: 14px;
  background: var(--bg) center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.ed-label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.editor-sheet input:not([type="checkbox"]) { width: 100%; }
.editor-sheet .p-oculto-label input { width: 18px; height: 18px; flex: none; }
.ed-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.ed-talle {
  display: grid;
  grid-template-columns: 1fr 44px 70px 44px 40px;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.ed-talle input { margin: 0; text-align: center; }
.ed-talle .v-talle { text-align: left; }
.ed-talle .btn-ajuste { width: 44px; height: 42px; }

.ed-quitar {
  background: var(--bg);
  color: var(--danger);
  height: 42px;
  border-radius: 10px;
}

.editor-sheet input:not([type="checkbox"]) {
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 16px;
  background: var(--bg);
  color: var(--ink);
}
