/* The register: catalog on the left, a paper receipt on the right. */
.main-pos { height: 100dvh; overflow: hidden; }
.pos { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(340px, 32vw, 430px); }

.catalog { display: flex; flex-direction: column; min-height: 0; padding: 1.1rem 1.2rem 0; gap: 0.8rem; }
.catalog-top { display: grid; gap: 0.7rem; }
.pos-search .input { min-height: 56px; font-size: 1.1rem; border-radius: 14px; padding-left: 3rem; }
.pos-search .icon { left: 1rem; width: 1.4em; height: 1.4em; }
.pos-search kbd { position: absolute; right: 0.9rem; top: 50%; transform: translateY(-50%); font: inherit; font-size: 0.8rem; color: var(--ink-3); border: 1px solid var(--line-strong); border-radius: 6px; padding: 0 0.4rem; background: var(--canvas); }
.pos-cats { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.2rem; scrollbar-width: thin; }
.pos-cats .chip { flex: none; }

.grid-scroll { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -1.2rem; padding: 0.2rem 1.2rem 6rem; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 0.8rem; }
.tile {
  position: relative; display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; transition: transform 0.08s, border-color 0.12s, box-shadow 0.12s;
}
.tile:hover { border-color: var(--ink-3); box-shadow: var(--shadow); }
.tile:active { transform: scale(0.97); }
.tile:disabled { opacity: 0.55; cursor: not-allowed; }
.tile-img { aspect-ratio: 1 / 0.66; width: 100%; object-fit: cover; display: grid; place-items: center; background: hsl(var(--hue, 210) 70% 91%); color: hsl(var(--hue, 210) 55% 28%); font-family: var(--font-display); font-weight: 700; font-size: 2rem; }
.tile-body { padding: 0.65rem 0.75rem 0.8rem; display: grid; gap: 0.3rem; flex: 1; align-content: space-between; }
.tile-name { font-weight: 650; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; }
.tile-stock { font-size: 0.8rem; font-weight: 600; color: var(--ink-3); }
.tile-stock.low { color: var(--amber); }
.tile-stock.out { color: var(--red); }
.tile-qty {
  position: absolute; top: 8px; right: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 99px;
  background: var(--green); color: #fff; font-weight: 700; display: grid; place-items: center; box-shadow: var(--shadow-sm);
}
.tile.flash { animation: tile-flash 0.35s ease-out; }
@keyframes tile-flash { 0% { box-shadow: 0 0 0 0 rgb(14 122 90 / 0.55); } 100% { box-shadow: 0 0 0 12px rgb(14 122 90 / 0); } }
.grid-empty { grid-column: 1 / -1; text-align: center; padding: 3rem 1rem; color: var(--ink-2); }
.grid-empty strong { display: block; font-size: 1.1rem; color: var(--ink); margin-bottom: 0.3rem; }

.quick-custom { margin-top: 0.8rem; }

/* The paper receipt */
.cart-wrap { display: flex; flex-direction: column; min-height: 0; background: var(--canvas); padding: 1rem 1rem 1rem 0; }
.cart {
  flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--paper); border-radius: 6px 6px 0 0;
  box-shadow: var(--shadow); position: relative;
  --tooth: 9px;
}
.cart::after { /* torn paper edge at the bottom */
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: var(--tooth);
  background: linear-gradient(-45deg, transparent calc(var(--tooth) * 0.7), var(--paper) 0) 0 0 / calc(var(--tooth) * 1.4) 100% repeat-x,
              linear-gradient(45deg, transparent calc(var(--tooth) * 0.7), var(--paper) 0) 0 0 / calc(var(--tooth) * 1.4) 100% repeat-x;
  filter: drop-shadow(0 2px 2px rgb(24 34 46 / 0.08));
}
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem 0.7rem; border-bottom: 2px dashed var(--line-strong); }
.cart-head h2 { font-size: 1.15rem; }
.cart-lines { flex: 1; min-height: 0; overflow-y: auto; padding: 0.4rem 0; }
.cart-empty { display: grid; place-items: center; text-align: center; height: 100%; padding: 1.5rem; color: var(--ink-3); gap: 0.4rem; align-content: center; }
.cart-empty .icon { width: 2.6rem; height: 2.6rem; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 0.8rem; padding: 0.7rem 1.2rem; border-bottom: 1px dotted var(--line-strong); }
.line-name { font-weight: 650; line-height: 1.25; overflow-wrap: anywhere; }
.line-total { font-family: var(--font-display); font-weight: 700; text-align: right; }
.line-unit { color: var(--ink-3); font-size: 0.88rem; }
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1.5px solid var(--line-strong); border-radius: 12px; overflow: hidden; background: #fff; }
.stepper button { width: 42px; height: 42px; border: 0; background: transparent; display: grid; place-items: center; }
.stepper button:hover { background: #f1f4f6; }
.stepper input { width: 52px; height: 42px; border: 0; text-align: center; font-weight: 700; font-size: 1.05rem; background: transparent; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.line-remove { background: none; border: 0; color: var(--ink-3); width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; }
.line-remove:hover { color: var(--red); background: var(--red-soft); }
.line-ctrl { display: flex; align-items: center; justify-content: space-between; grid-column: 1 / -1; }
.line-warn { grid-column: 1 / -1; font-size: 0.85rem; font-weight: 600; color: var(--amber); }

.cart-foot { padding: 0.9rem 1.2rem 1.4rem; border-top: 2px dashed var(--line-strong); display: grid; gap: 0.35rem; background: var(--paper); }
.sum { display: flex; justify-content: space-between; align-items: baseline; color: var(--ink-2); }
.sum-total { color: var(--ink); font-family: var(--font-display); font-size: 2.1rem; font-weight: 750; letter-spacing: -0.02em; line-height: 1.1; padding: 0.25rem 0; }
.sum-total span:first-child { font-size: 1.1rem; font-weight: 650; }
.discount-row { display: flex; gap: 0.5rem; align-items: center; }
.discount-row .input { min-height: 40px; max-width: 110px; padding: 0.3rem 0.6rem; }
.discount-row .select { min-height: 40px; width: auto; padding: 0.3rem 0.6rem; }
.charge-btn { margin-top: 0.4rem; }
.charge-btn .num { font-size: 1.25rem; }

/* Checkout dialog */
.pay-dialog { width: min(96vw, 520px); }
.pay-total { text-align: center; padding: 1.2rem 1rem 0.2rem; }
.pay-total .label { color: var(--ink-2); font-weight: 600; }
.pay-total .amount { font-family: var(--font-display); font-size: 3rem; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
.methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin: 1rem 0; }
.method {
  display: grid; justify-items: center; gap: 0.3rem; padding: 0.9rem 0.4rem; border: 2px solid var(--line-strong);
  border-radius: 14px; background: #fff; font-weight: 700; min-height: 84px;
}
.method .icon { width: 1.7em; height: 1.7em; }
.method[aria-checked="true"] { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }
.quick-cash { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.quick-cash .btn { flex: 1 1 80px; }
.change-box { display: flex; justify-content: space-between; align-items: baseline; padding: 0.9rem 1.1rem; border-radius: 14px; background: var(--tag-soft); margin-top: 1rem; }
.change-box .amount { font-family: var(--font-display); font-size: 1.9rem; font-weight: 750; }
.change-box.short { background: var(--red-soft); color: #7e1d17; }
.pay-error { margin: 0.8rem 0 0; }

/* Phones & small tablets: catalog first, receipt slides up from the bottom. */
.cart-bar { display: none; }
@media (max-width: 900px) {
  .main-pos { height: calc(100dvh - 56px); }
  .pos { grid-template-columns: 1fr; position: relative; }
  .catalog { padding: 0.8rem 0.8rem 0; }
  .grid-scroll { margin: 0 -0.8rem; padding: 0.2rem 0.8rem 6rem; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.6rem; }
  .cart-wrap {
    position: fixed; inset: 56px 0 0 0; z-index: 40; padding: 0; transform: translateY(105%); transition: transform 0.25s ease; background: var(--paper);
  }
  .cart { border-radius: 0; box-shadow: none; }
  .cart::after { display: none; }
  .pos[data-cart-open="true"] .cart-wrap { transform: none; }
  .cart-bar {
    display: flex; position: fixed; left: 0.8rem; right: 0.8rem; bottom: 0.8rem; z-index: 30; min-height: 62px; align-items: center; justify-content: space-between;
    background: var(--green); color: #fff; border: 0; border-radius: 16px; padding: 0.6rem 1.1rem; box-shadow: var(--shadow-lift); font-weight: 700; font-size: 1.05rem;
  }
  .cart-bar[hidden] { display: none; }
  .cart-bar .num { font-size: 1.3rem; }
  .cart-close { display: grid !important; }
}
.cart-close { display: none; }
.cart-close { white-space: nowrap; }

/* Venta lista */
.done-dialog { width: min(94vw, 440px); text-align: center; }
.done-body { display: grid; justify-items: center; gap: 0.3rem; padding-top: 1.8rem; }
.done-check { width: 56px; height: 56px; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); display: grid; place-items: center; margin-bottom: 0.4rem; }
.done-amount { font-size: 3rem; font-weight: 750; line-height: 1.1; letter-spacing: -0.03em; }
.done-note { color: var(--ink-2); font-weight: 600; }
.done-foot { flex-direction: column; align-items: stretch; }
.done-foot .btn { width: 100%; }
.autoprint { margin-top: 0.9rem; }
.ticket-frame { position: fixed; width: 0; height: 0; border: 0; left: -9999px; top: 0; }

/* Scanner feedback */
.catalog { position: relative; }
.scan-msg {
  position: absolute; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 5; max-width: 90%;
  background: var(--green); color: #fff; font-weight: 650; padding: 0.7rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow-lift);
  animation: toast-in 0.2s ease-out; text-align: center;
}
.scan-msg.bad { background: var(--red); }
@media (max-width: 900px) { .scan-msg { bottom: 5.6rem; } }
