/* JS POS: the till screen and its receipts. Uses the app's tokens (app.css).
   The till is for counter staff: touch first, few words, big targets (at least 48px), the total always in view. */
:root {
  --till-go: #13804b;          /* Pay, Exact money: the one thing to do next */
  --till-go-hover: #0f6b3e;
  --till-go-text: #ffffff;
  --till-tile: #ffffff;
  --till-tile-line: #d5dce8;
  --till-soft: #eef3fb;
}

/* the till takes the whole window: no menu, no page header */
body.pos-mode #nav, body.pos-mode #nav-scrim, body.pos-mode #topbar { display: none !important; }
body.pos-mode #app { display: block; }
body.pos-mode #main { margin: 0; width: 100%; height: 100vh; }
body.pos-mode #view { padding: 0; max-width: none; height: 100vh; overflow: hidden; }
body.pos-mode #toasts { top: 70px; bottom: auto; }

.till { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr); grid-template-rows: auto minmax(0, 1fr);
  height: 100vh; background: var(--bg); font-size: 15px; }

/* top bar */
.till-top { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--nav); color: var(--nav-text); }
.till-mark { font: 700 18px var(--font-display); color: #fff; letter-spacing: .02em; }
.till-mark b { color: var(--brand); }
.till-where { display: flex; flex-direction: column; line-height: 1.2; flex: 1 1 auto; min-width: 0; }
.till-where b { color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.till-where span { font-size: 12px; color: var(--nav-muted); }
.till-clock { font: 600 17px var(--font-display); color: #fff; padding: 0 4px; }
.till-btn { height: 44px; padding: 0 14px; background: var(--nav-2); border-color: var(--nav-3); color: #fff; font-size: 14px; }
.till-btn:hover { background: var(--nav-3); border-color: var(--nav-3); }
.till-who { font-weight: 700; }

/* left: find and tap items */
.till-pick { display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 12px; }
.till-scan { position: relative; display: flex; align-items: center; }
.till-scan > .i { position: absolute; left: 16px; width: 24px; height: 24px; color: var(--muted); pointer-events: none; }
.till-scan input { flex: 1 1 auto; height: 56px; font-size: 19px; padding: 0 16px 0 52px; border: 2px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
.till-scan input:focus { border-color: var(--primary); outline: 3px solid var(--primary-ring); outline-offset: 0; }
.till-mult:not(:empty) { position: absolute; right: 16px; font: 700 20px var(--font-display); color: var(--primary); }
.till-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; flex: 0 0 auto; }
.till-tabs button { flex: 0 0 auto; height: 44px; padding: 0 18px; border-radius: 22px; background: var(--surface); color: var(--text-2);
  border: 1px solid var(--till-tile-line); font-size: 15px; font-weight: 600; box-shadow: none; }
.till-tabs button.on { background: var(--text); color: #fff; border-color: var(--text); }
.till-tiles { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  grid-auto-rows: 104px; gap: 10px; align-content: start; padding: 2px; }
.tile { display: flex; flex-direction: column; justify-content: space-between; align-items: stretch; height: 100%; padding: 12px; text-align: left;
  background: var(--till-tile); color: var(--text); border: 1px solid var(--till-tile-line); border-radius: 12px; box-shadow: var(--shadow-1); white-space: normal; }
.tile:hover { background: var(--till-soft); border-color: var(--primary); }
.tile:active { transform: scale(.98); }
.tile-name { font: 600 15px/1.25 var(--font); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile-price { font: 700 18px var(--font-display); color: var(--text); }
.tile-price small { font: 500 12px var(--font); color: var(--muted); }
.tile.off { opacity: .55; }
.tile.off .tile-price { font-size: 13px; color: var(--muted); }
.till-none { grid-column: 1 / -1; padding: 40px; text-align: center; color: var(--muted); font-size: 16px; }

/* right: the basket, the total, Pay */
.till-cart { display: flex; flex-direction: column; min-height: 0; margin: 12px 12px 12px 0; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-2); overflow: hidden; }
.cart-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.cart-head b { font: 700 17px var(--font-display); }
.cart-head > span:not(.grow) { color: var(--muted); }
.cart-head .grow { flex: 1 1 auto; }
.cart-chip { height: 40px; max-width: 55%; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line-strong); box-shadow: none; }
.cart-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-chip.on { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.cart-lines { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.cline { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 8px 12px 8px 4px; border-bottom: 1px solid var(--line); }
.cline-main { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; height: auto; min-height: 52px; padding: 6px 12px; background: none;
  border: 0; box-shadow: none; color: var(--text); text-align: left; white-space: normal; }
.cline-main:hover { background: var(--till-soft); }
.cline-name { font-weight: 600; font-size: 15px; line-height: 1.25; }
.cline-sub { color: var(--muted); font-size: 13px; font-weight: 400; }
.cline-sub em { font-style: normal; color: var(--warn); background: var(--warn-soft); border-radius: 4px; padding: 0 5px; }
.cline-qty { display: flex; align-items: center; gap: 4px; }
.cline-qty button { width: 44px; height: 44px; padding: 0; border-radius: 50%; font: 600 22px/1 var(--font-display);
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line-strong); box-shadow: none; }
.cline-qty b { min-width: 30px; text-align: center; font-size: 17px; }
.cline-amt { min-width: 76px; text-align: right; font-size: 16px; }
.cart-empty, .cart-done { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 20px; text-align: center; color: var(--muted); }
.cart-empty .i { width: 56px; height: 56px; color: var(--faint); }
.cart-empty p { font: 600 17px var(--font-display); color: var(--text-2); max-width: 260px; }
.cart-done span { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--good); }
.cart-done b { font: 700 64px/1 var(--font-display); color: var(--good); }
.cart-done p { font-size: 14px; }
.cart-done button { height: 44px; margin-top: 6px; }
.cart-done small { margin-top: 10px; max-width: 280px; }
.cart-sum { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); }
.cart-sum div { display: flex; flex-direction: column; }
.cart-sum span { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.cart-sum small { color: var(--muted); }
.cart-sum > b { font: 700 40px/1 var(--font-display); }
.cart-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 12px 0; }
.cart-acts button { height: 52px; font-size: 15px; background: var(--surface); color: var(--text); border-color: var(--line-strong); box-shadow: none; position: relative; }
.cart-acts em { position: absolute; top: 6px; right: 8px; min-width: 22px; height: 22px; border-radius: 11px; background: var(--brand); color: #241703;
  font: 700 12px/22px var(--font); font-style: normal; }
.cart-acts em:empty { display: none; }
.cart-pay { display: flex; justify-content: space-between; align-items: center; margin: 10px 12px 12px; height: 76px; padding: 0 22px; border-radius: 12px;
  background: var(--till-go); border-color: var(--till-go); color: var(--till-go-text); font: 700 26px var(--font-display); }
.cart-pay:hover { background: var(--till-go-hover); border-color: var(--till-go-hover); }
.cart-pay b { font-size: 28px; }
.cart-pay:disabled { background: var(--line-strong); border-color: var(--line-strong); opacity: 1; }

/* dialogs on the till: bigger to tap */
.pos-modal .modal { width: min(560px, 100%); }
.pos-modal .modal.wide { width: min(860px, 100%); }
.pos-modal .modal-head h2 { font-size: 19px; }
.pos-modal input.big { height: 56px; font-size: 26px; text-align: right; }
.pos-modal input.big-text { height: 52px; font-size: 20px; }
.pos-modal button.wide { width: 100%; height: 54px; font-size: 17px; margin-top: 10px; }
.till-ask { display: flex; flex-direction: column; gap: 8px; }

.kp { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.kp-label { font-weight: 600; color: var(--text-2); }
.kp-show { font: 700 40px var(--font-display); text-align: right; padding: 8px 14px; border: 2px solid var(--line-strong); border-radius: 12px; background: var(--surface-2); }
.kp-hint { color: var(--muted); }
.kp-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.kp-keys button { height: 66px; font: 600 26px var(--font-display); background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.kp-keys button:disabled { visibility: hidden; }
.kp-ok { height: 60px; font: 700 20px var(--font-display); background: var(--till-go); border-color: var(--till-go); }
.kp-ok:hover { background: var(--till-go-hover); }

.pin-box { display: flex; flex-direction: column; align-items: center; gap: 12px; outline: none; }
.pin-people { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.pin-person { height: auto; min-width: 110px; padding: 12px; flex-direction: column; gap: 6px; background: var(--surface); color: var(--text); border-color: var(--line-strong); font-size: 15px; }
.pin-person b { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: 20px; }
.pin-person.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.pin-person.on b { background: var(--primary); color: #fff; }
.pin-who { font-weight: 700; color: var(--text-2); font-size: 16px; }
.pin-dots { display: flex; gap: 12px; height: 18px; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); }
.pin-dots i.on { background: var(--text); border-color: var(--text); }
.pin-keys { display: grid; grid-template-columns: repeat(3, 92px); gap: 8px; }
.pin-keys button { height: 66px; font: 600 26px var(--font-display); background: var(--surface); color: var(--text); border-color: var(--line-strong); }
.pin-keys button.ok { background: var(--till-go); color: #fff; border-color: var(--till-go); font-size: 20px; }
.pin-err { color: var(--bad); font-weight: 600; min-height: 1.4em; text-align: center; }

.paybox { display: flex; flex-direction: column; gap: 14px; }
.pay-due { display: flex; justify-content: space-between; align-items: baseline; }
.pay-due span { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.pay-due b { font: 700 44px var(--font-display); }
.pay-methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.pay-methods button { height: 58px; background: var(--surface); color: var(--text); border-color: var(--line-strong); font-size: 16px; }
.pay-methods button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); box-shadow: 0 0 0 2px var(--primary-ring); }
.pay-label { font-weight: 600; color: var(--text-2); }
.pay-notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 8px; }
.pay-notes button { height: 84px; flex-direction: column; gap: 2px; background: var(--surface); color: var(--text); border: 2px solid var(--line-strong); }
.pay-notes button b { font: 700 24px var(--font-display); }
.pay-notes button small { font-size: 12px; color: var(--muted); font-weight: 600; }
.pay-notes button.exact { background: var(--till-go); border-color: var(--till-go); color: #fff; }
.pay-notes button.exact small { color: rgba(255, 255, 255, .85); }
.pay-notes button:hover { border-color: var(--primary); }
.pay-ref { display: flex; flex-direction: column; gap: 10px; }
.pay-go { height: 64px; font: 700 20px var(--font-display); background: var(--till-go); border-color: var(--till-go); color: #fff; width: 100%; }
.pay-go:hover { background: var(--till-go-hover); }
.pay-list { display: flex; flex-direction: column; gap: 4px; }
.pay-list:empty { display: none; }
.pay-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 6px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.pay-row small { color: var(--muted); }
.pay-split { align-self: center; color: var(--muted); }

.lsheet { display: flex; flex-direction: column; gap: 14px; }
.lsheet-qty { display: flex; align-items: center; justify-content: center; gap: 18px; }
.lsheet-qty button { width: 66px; height: 66px; border-radius: 50%; font: 600 32px/1 var(--font-display); background: var(--surface-2); color: var(--text); border-color: var(--line-strong); }
.lsheet-qty b { min-width: 110px; text-align: center; font: 700 34px var(--font-display); cursor: pointer; border-bottom: 2px dashed var(--line-strong); }
.lsheet-amt { text-align: center; color: var(--muted); font-size: 15px; }
.lsheet-disc { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lsheet-disc span { font-weight: 600; color: var(--text-2); margin-right: 4px; }
.lsheet-disc button { height: 48px; min-width: 64px; background: var(--surface); color: var(--text); border-color: var(--line-strong); font-size: 16px; }
.lsheet-disc button.on { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.lsheet-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.lsheet-acts button { height: 52px; font-size: 15px; }

.till-list { display: flex; flex-direction: column; gap: 8px; }
.till-list button { height: 58px; justify-content: space-between; gap: 12px; background: var(--surface); color: var(--text); border-color: var(--line-strong); font-size: 16px; }
.till-list button.on { border-color: var(--primary); background: var(--primary-soft); }
.till-menu button { justify-content: flex-start; }
.till-menu button span { flex: 1 1 auto; text-align: left; }
.till-pickc { display: flex; flex-direction: column; gap: 10px; }
.till-pickc > input { height: 52px; font-size: 18px; }
.till-dev { display: flex; flex-direction: column; gap: 10px; }

.ret table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.ret td, .ret th { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }
.ret .r { text-align: right; }
.ret small { display: block; color: var(--muted); }
.ret input { width: 90px; height: 44px; text-align: right; font-size: 17px; }
form.ret { display: flex; flex-direction: column; gap: 8px; }
.count { display: flex; flex-direction: column; gap: 10px; }
.count-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.count-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); font-weight: 600; }
.count-grid input { text-align: right; height: 46px; font-size: 18px; }
.count-diff b.over, .count-diff b.ok { color: var(--good); }
.count-diff b.short { color: var(--bad); }

/* a small screen (a tablet held upright): the basket goes under the items */
@media screen and (max-width: 900px) {
  .till { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr); }
  .till-cart { margin: 0 12px 12px; }
  .till-where span, .till-clock { display: none; }
  .cart-sum > b { font-size: 32px; }
  .count-grid { grid-template-columns: repeat(3, 1fr); }
}

/* setup and shifts pages (inside the normal app frame) */
.pos-setup { display: flex; flex-direction: column; gap: 14px; max-width: 900px; }
.pos-setup h3 { margin: 16px 0 6px; }
.pos-setup .check { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.pos-methods { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 6px 14px; }
.pos-methods input:not([type=checkbox]) { flex: 1 1 auto; }
.pos-quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 2px 14px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row-form input { flex: 1 1 160px; }
table.plain { width: 100%; border-collapse: collapse; }
table.plain td, table.plain th { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
table.plain .r { text-align: right; }
.pos-shifts small { color: var(--muted); }
.pos-shifts .bad { color: var(--bad); }
.pos-shifts .good { color: var(--good); }

/* receipts: thermal paper, black on white */
#print-root .receipt { font: 12px/1.35 var(--mono); color: #000; margin: 0 auto; padding: 3mm 0; }
#print-root .rc-logo { display: block; max-width: 40mm; max-height: 18mm; margin: 0 auto 2mm; }
#print-root .rc-co { text-align: center; font-weight: 700; font-size: 14px; }
#print-root .rc-c { text-align: center; }
#print-root .rc-title { text-align: center; font-weight: 700; margin: 2mm 0 1mm; letter-spacing: .1em; }
#print-root .rc-row { display: flex; justify-content: space-between; gap: 3mm; }
#print-root .rc-row span:last-child { text-align: right; white-space: nowrap; }
#print-root .rc-item { margin: 1mm 0; }
#print-root .rc-name { font-weight: 700; }
#print-root .rc-total { font-weight: 700; font-size: 15px; margin: 1mm 0; }
#print-root .rc-rule { border-top: 1px dashed #000; margin: 2mm 0; }
#print-root .rc-jjs { font-weight: 700; margin-top: 1mm; }
#print-root .rc-faint { font-size: 10px; margin-top: 2mm; }

/* on the till, messages appear at the top, clear of the Pay button */
body.pos-mode #toasts { top: 64px; bottom: auto; }
.pay-notes [data-other] b { font-size: 17px; }
