/* =====================================================================
   Point of sale — the counter screen
   Two columns: a tappable product wall and the running order.
   ===================================================================== */
.pos-screen {
  display: grid;
  grid-template-columns: 1fr 372px;
  gap: 16px;
  /* Fill the viewport below the top bar so neither column scrolls the page. */
  height: calc(100vh - var(--topbar-h) - 44px);
}

.pos-catalogue {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pos-toolbar {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.pos-search { flex: 1; font-size: 15px; padding: 10px 13px; }
.pos-branch { width: 210px; }

.pos-cats {
  display: flex;
  gap: 7px;
  padding: 11px 14px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #fbfbf8;
}
.pos-cats::-webkit-scrollbar { height: 5px; }
.pos-cats::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }

.pos-cat {
  padding: 7px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.pos-cat:hover { border-color: var(--green-500); color: var(--green-700); }
.pos-cat.active { background: var(--green-700); border-color: var(--green-700); color: var(--cream); }

.pos-grid {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  /* Each row takes the height its tiles actually need. Left on `auto` the
     rows collapse to the photo and clip the name and price beneath it. */
  grid-auto-rows: max-content;
  gap: 11px;
  align-content: start;
}

.pos-tile {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 96px;
  padding: 13px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .08s, border-color .12s, box-shadow .12s;
}
.pos-tile:hover { border-color: var(--green-500); box-shadow: var(--shadow); }
.pos-tile:active { transform: scale(.97); }
.pos-tile.out { opacity: .45; cursor: not-allowed; background: #f7f7f4; }
.pos-tile.out:hover { border-color: var(--line-strong); box-shadow: none; }

.pos-tile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  flex: 1;
}
.pos-tile-price { font-size: 16px; font-weight: 700; color: var(--green-700); }
.pos-tile-stock { font-size: 11px; color: var(--ink-faint); }

/* ----------------------------- Order panel ---------------------------- */
.pos-order {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pos-order-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff, #fcfcfa);
}
.pos-order-head > div { flex: 1; }
.pos-order-head .muted { font-size: 11.5px; }

.pos-lines { flex: 1; overflow-y: auto; padding: 8px 0; min-height: 90px; }

.pos-empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--ink-faint);
  font-size: 13px;
}
.pos-empty .big { font-size: 34px; opacity: .3; margin-bottom: 10px; }

.pos-line { padding: 9px 15px; border-bottom: 1px solid #f4f3ee; }
.pos-line-main { display: flex; gap: 10px; align-items: baseline; }
.pos-line-name { flex: 1; font-size: 13px; font-weight: 600; line-height: 1.3; }
.pos-line-total { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos-line-sub { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 12px; }

.pos-qty {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pos-qty button {
  width: 27px; height: 27px;
  border: none;
  background: #f6f6f2;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  cursor: pointer;
}
.pos-qty button:hover { background: var(--green-050); color: var(--green-700); }
.pos-qty input {
  width: 44px; height: 27px;
  border: none;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-radius: 0;
  text-align: center;
  padding: 0;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.pos-qty input:focus { box-shadow: none; }

.pos-line-del {
  margin-left: auto;
  background: none; border: none;
  color: var(--ink-faint);
  font-size: 17px; line-height: 1;
  cursor: pointer; padding: 0 3px;
}
.pos-line-del:hover { color: var(--danger); }

.pos-totals { padding: 12px 15px; border-top: 1px solid var(--line); background: #fbfbf8; }
.pos-total-row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 3px 0;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.pos-total-row.grand {
  margin-top: 7px; padding-top: 9px;
  border-top: 1px solid var(--line-strong);
  font-size: 17px; font-weight: 700; color: var(--ink);
}

.pos-pay { padding: 13px 15px 15px; border-top: 1px solid var(--line); }
.pos-pay .field { margin-bottom: 11px; }
.pos-label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--ink-soft); margin-bottom: 6px;
}

.pos-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 12px; }
.pos-method {
  padding: 9px 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 12.5px; font-weight: 600; font-family: inherit;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.pos-method:hover { border-color: var(--green-500); }
.pos-method.active { background: var(--green-700); border-color: var(--green-700); color: var(--cream); }

.pos-quick { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.pos-quick-btn {
  flex: 1; min-width: 58px;
  padding: 7px 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 12px; font-weight: 600; font-family: inherit;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.pos-quick-btn:hover { background: var(--green-050); border-color: var(--green-500); color: var(--green-700); }

.pos-change-box {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--ok-bg);
  color: var(--ok);
  font-size: 13px;
  margin-bottom: 11px;
  display: flex; justify-content: space-between; align-items: center;
}
.pos-change-box b { font-size: 16px; }
.pos-change-box.short { background: var(--danger-bg); color: var(--danger); }

.pos-charge {
  width: 100%;
  padding: 14px;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: .01em;
}

@media (max-width: 1080px) {
  .pos-screen { grid-template-columns: 1fr; height: auto; }
  .pos-grid { max-height: 400px; }
}

/* ------------------------------- Receipt ------------------------------ */
.receipt {
  max-width: 320px;
  margin: 0 auto;
  padding: 18px;
  background: #fff;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink);
}
.receipt-head { text-align: center; padding-bottom: 12px; border-bottom: 1px dashed var(--line-strong); }
.receipt-logo {
  width: 96px;
  margin: 0 auto 8px;
  display: block;
  /* The mark is cream-on-transparent; darken it so it reads on white paper. */
  filter: brightness(.3) sepia(1) hue-rotate(85deg) saturate(3);
}
.receipt-co { font-size: 13.5px; font-weight: 700; letter-spacing: .04em; }
.receipt-meta { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }

.receipt-meta-row {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--ink-soft);
  padding: 3px 0;
}
.receipt-meta-row:first-of-type { padding-top: 10px; }

.receipt-items {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  border-top: 1px dashed var(--line-strong);
  border-bottom: 1px dashed var(--line-strong);
}
.receipt-items td { padding: 6px 0; vertical-align: top; font-size: 11.5px; }
.receipt-items td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.receipt-items .muted { font-size: 10.5px; }

.receipt-totals div {
  display: flex; justify-content: space-between;
  padding: 3px 0; font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.receipt-totals .grand {
  font-size: 14px; font-weight: 700;
  border-top: 1px dashed var(--line-strong);
  margin-top: 5px; padding-top: 7px;
}

.receipt-foot {
  text-align: center;
  font-size: 10.5px;
  color: var(--ink-faint);
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px dashed var(--line-strong);
  line-height: 1.6;
}

/* ------------------------- Till selection ----------------------------- */
/* Shown when a user could work at more than one branch. Selling against the
   wrong branch is silent and awkward to unwind, so the choice is explicit. */
.till-chooser { max-width: 860px; margin: 40px auto; }
.till-chooser-head { text-align: center; margin-bottom: 26px; }
.till-chooser-head h2 { font-size: 22px; color: var(--green-700); }
.till-chooser-head p { margin: 8px 0 0; color: var(--ink-faint); font-size: 13.5px; }

.till-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.till-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
  padding: 22px 20px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .1s, border-color .12s, box-shadow .12s;
}
.till-card:hover {
  border-color: var(--green-600);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.till-card:active { transform: translateY(0); }
.till-card-name { font-size: 16px; font-weight: 700; color: var(--green-800); line-height: 1.3; }
.till-card-meta { font-size: 12.5px; color: var(--ink-faint); }

/* Persistent reminder of which branch is being sold from. */
.till-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  background: var(--green-050);
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.till-banner b { color: var(--green-800); }
.till-banner-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 700;
  color: var(--ink-faint);
}
.till-banner .btn { margin-left: auto; }

/* ---------------------- Product photos on the till -------------------- */
.pos-tile { padding: 0; gap: 0; overflow: hidden; }
.pos-tile .product-img.tile {
  width: 100%;
  height: 92px;
  /* The tile is a flex column; without this the photo is squashed to a
     sliver to make room for the text below it. */
  flex: 0 0 92px;
  border-radius: 0;
  font-size: 26px;
}
.pos-tile-body .pos-tile-name {
  /* Reserve two lines so a one-line name and a two-line name produce tiles of
     the same height, keeping the grid even. */
  min-height: 2.6em;
}
.pos-tile-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 11px 12px;
  /* Sized by its own content. A flex-basis of 0 would contribute nothing to
     the tile's height, leaving the text clipped behind the photo. */
  flex: 0 0 auto;
}
.pos-tile.out .product-img { filter: grayscale(1); }

.pos-line-main { align-items: center; }

/* A duplicate must never pass for a second sale. */
.receipt-reprint {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--danger);
  border: 1px dashed var(--danger);
  border-radius: 3px;
  padding: 3px;
  margin-bottom: 10px;
}
