/* Counter till (PS1). Built for a counter tablet in landscape and a phone in the hand: 56 px touch targets, high
   contrast, totals readable at arm's length. Tablet and desktop: products left, sale right. Phone (< 760 px): one
   column with Products / Sale tabs and the Pay button always in reach. */
:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #5b6474;
  --line: #d8dee9;
  --bg: #f4f6fb;
  --card: #ffffff;
  --navy: #14213d;
  --amber: #fca311;
  --go: #15803d;
  --go-ink: #ffffff;
  --bad: #b91c1c;
  --bad-bg: #fee2e2;
  --ok-bg: #dcfce7;
  --info-bg: #e0e7ff;
  --teal: #0f766e;
  --rose: #be123c;
  --slate: #475569;
  --radius: 14px;
  --tap: 56px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); -webkit-tap-highlight-color: transparent; }
body { overflow-x: hidden; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
h1 { font-size: 1.5rem; margin: 0 0 .4rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code { font-size: .85em; background: rgba(15, 23, 42, .07); padding: .1em .35em; border-radius: 6px; }
.muted { color: var(--muted); }
.boot { padding: 2rem; text-align: center; color: var(--muted); }

.bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap;
  padding: .55rem max(1rem, env(safe-area-inset-right)) .55rem max(1rem, env(safe-area-inset-left)); background: var(--navy); color: #fff; }
.brand { font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.logo { color: var(--amber); }
.bar-right { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.chip { min-height: 44px; border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .08); color: #fff; border-radius: 999px; padding: .3rem .85rem; font-weight: 600; }
.chip-k { opacity: .7; font-weight: 400; }
.pill { display: inline-flex; align-items: center; min-height: 30px; border-radius: 999px; padding: .15rem .7rem; font-size: .85rem; font-weight: 700; }
.pill-ok { background: #166534; color: #dcfce7; }
.pill-off { background: var(--amber); color: #1f2937; }
.chip-bad { background: var(--bad); border-color: var(--bad); }
.tag-prov { display: inline-block; font-size: .75rem; letter-spacing: .06em; background: var(--amber); color: #1f2937; border-radius: 6px; padding: .1rem .4rem; vertical-align: middle; }
.wait { padding: .5rem 0; border-bottom: 1px solid var(--line); }
.wait-bad { color: var(--bad); }

.msg { margin: .6rem 1rem; padding: .7rem .9rem; border-radius: 10px; font-weight: 600; }
.msg-error { background: var(--bad-bg); color: var(--bad); }
.msg-ok { background: var(--ok-bg); color: #14532d; }
.msg-info { background: var(--info-bg); color: #1e3a8a; }

.centre { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.card { background: var(--card); border-radius: var(--radius); padding: 1.25rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06); }
.narrow { width: min(440px, 100%); }
.card .msg, .sheet-body .msg { margin: .6rem 0; }
label { display: grid; gap: .3rem; margin: .7rem 0; font-weight: 600; }
input { min-height: var(--tap); border: 1px solid var(--line); border-radius: 10px; padding: 0 .8rem; background: #fff; width: 100%; }
textarea { border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; background: #fff; width: 100%; font: inherit; font-size: max(16px, 1rem); resize: vertical; }
#switch-on { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .5rem; }
#switch-on h2 { font-size: 1.1rem; margin: .6rem 0 .2rem; }
#switch-on .small { margin: -.4rem 0 .4rem; font-weight: 400; }
.toggle { display: flex; align-items: center; gap: .6rem; }
.toggle input { width: 28px; min-height: 28px; }

.btn { min-height: var(--tap); border-radius: 12px; border: 1px solid var(--line); background: #fff; padding: 0 1rem; font-weight: 700; }
.btn-go { background: var(--go); border-color: var(--go); color: var(--go-ink); }
.btn-quiet { background: transparent; }
.wide { width: 100%; margin-top: .6rem; }
.link { background: none; border: 0; color: #1d4ed8; text-decoration: underline; min-height: 44px; padding: 0 .4rem; }
.row { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.row .btn { flex: 1 1 8rem; }

.display { display: block; font-size: 2.2rem; font-weight: 800; text-align: right; padding: .4rem .6rem; margin: .5rem 0; background: var(--bg); border-radius: 10px; font-variant-numeric: tabular-nums; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.key { min-height: 60px; font-size: 1.4rem; font-weight: 700; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.pin { display: flex; justify-content: center; gap: .7rem; margin: 1rem 0; }
.dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink-2); }
.dot-on { background: var(--ink); }
.operators, .reasons { display: flex; flex-wrap: wrap; gap: .5rem; }
.op { min-height: var(--tap); border-radius: 12px; border: 2px solid var(--line); background: #fff; padding: 0 1rem; font-weight: 700; }
.op-on { border-color: var(--navy); background: var(--navy); color: #fff; }

.phone-tabs { display: none; }
.till { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); gap: 1rem; padding: 1rem max(1rem, env(safe-area-inset-right)) 1rem max(1rem, env(safe-area-inset-left)); align-items: start; }
.items { min-width: 0; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; margin-bottom: .8rem; }
.qk { min-height: 72px; border: 0; border-radius: 12px; color: #fff; font-weight: 800; display: grid; align-content: center; gap: .15rem; padding: .4rem; }
.qk small { font-weight: 600; }
.qk-ink { background: var(--navy); }
.qk-amber { background: #b45309; }
.qk-teal { background: var(--teal); }
.qk-rose { background: var(--rose); }
.qk-slate { background: var(--slate); }
.filters { display: grid; gap: .5rem; margin-bottom: .7rem; }
.search { min-height: 48px; }
.tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; }
.tab { min-height: 44px; border-radius: 999px; border: 1px solid var(--line); background: #fff; padding: 0 .9rem; white-space: nowrap; font-weight: 600; }
.tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.tile { min-height: 96px; text-align: left; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: .7rem; display: grid; align-content: space-between; gap: .4rem; }
.tile-name { font-weight: 700; line-height: 1.25; }
.tile-price { font-weight: 800; font-variant-numeric: tabular-nums; }

.basket { background: var(--card); border-radius: var(--radius); padding: 1rem; position: sticky; top: 4.2rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }
.empty { color: var(--muted); padding: 1rem 0; }
.lines { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow: auto; }
.line { display: flex; gap: .5rem; align-items: center; border-bottom: 1px solid var(--line); padding: .35rem 0; }
.line-on .line-main { background: #eef2ff; }
.line-main { flex: 1; min-width: 0; text-align: left; border: 0; background: none; border-radius: 8px; padding: .4rem; display: grid; grid-template-columns: 1fr auto; gap: .2rem .5rem; }
.line-name { font-weight: 600; min-width: 0; overflow-wrap: break-word; }
.line-sum { font-weight: 700; font-variant-numeric: tabular-nums; }
.tag { grid-column: 1 / -1; font-size: .8rem; color: var(--teal); font-weight: 700; }
.stepper { display: flex; align-items: center; gap: .2rem; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 1.2rem; font-weight: 800; }
.stepper output { min-width: 2ch; text-align: center; font-weight: 700; }
.sums { margin: .7rem 0; }
.sums div { display: flex; justify-content: space-between; padding: .15rem 0; }
.sums dt, .sums dd { margin: 0; }
.sums .total { font-size: 1.4rem; font-weight: 800; border-top: 2px solid var(--ink); padding-top: .4rem; margin-top: .3rem; }
.sums.big { font-size: 1.15rem; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.actions .btn { padding: 0 .4rem; font-size: .9rem; }
.pay { width: 100%; margin-top: .7rem; font-size: 1.2rem; min-height: 64px; }

#sheet:empty { display: none; }
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(15, 23, 42, .45); display: grid; place-items: end center; }
.sheet-body { background: var(--card); width: min(560px, 100%); max-height: 100vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 1.1rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
.sheet-body.pay { width: min(620px, 100%); }
.seg { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.seg button { flex: 1 1 7rem; min-height: 48px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-weight: 700; }
.seg button[aria-checked="true"] { border-color: var(--navy); background: var(--navy); color: #fff; }
.quickcash { display: grid; grid-template-columns: repeat(4, 1fr); gap: .4rem; margin-bottom: .5rem; }
.tenders, .hits { list-style: none; padding: 0; margin: .4rem 0; }
.tenders li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.customer { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .4rem; }
.label { font-weight: 600; margin: .8rem 0 .3rem; }
.done { text-align: center; }
.receipt-no { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.change { font-size: 1.6rem; }

/* Cash management, X and Z (PS1 item 4) */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.small { font-size: .85rem; }
.menu { display: grid; gap: .2rem; }
.sheet-body.close { width: min(900px, 100%); }
/* Set-up: Set my PIN and the manager's quick keys (sprint step 4) */
.sheet-body.setup { width: min(720px, 100%); }
.sheet-body.zhist { width: min(900px, 100%); }
.zlist .nowrap { white-space: nowrap; }
.zlist td.bad { color: var(--bad); }
.sub { font-size: 1rem; margin: 1rem 0 .4rem; }
.keys { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.keyrow { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px 48px 48px; gap: .35rem; align-items: center; }
.swatch { min-height: 48px; border: 0; border-radius: 10px; color: #fff; font-weight: 800; }
.keylabel { display: grid; font-weight: 700; overflow-wrap: anywhere; }
.keylabel small { font-weight: 400; }
.btn-ico { min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 1.1rem; }
.btn-ico:disabled { opacity: .35; }
.offer { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .4rem; max-height: 40vh; overflow: auto; }
.offer-btn { width: 100%; min-height: var(--tap); text-align: left; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: .4rem .6rem; display: grid; }
.offer-btn small { color: var(--muted); }
.offer-on { border: 2px solid var(--go); background: var(--ok-bg); }
.close-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.denoms, .fig { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin: .4rem 0 .8rem; }
.denoms caption, .fig caption { text-align: left; font-weight: 700; padding-bottom: .3rem; }
.denoms th, .denoms td, .fig th, .fig td { padding: .2rem .3rem; border-bottom: 1px solid var(--line); text-align: right; }
.denoms th, .fig th[scope="row"] { text-align: left; font-weight: 600; }
.denoms .stepper { justify-content: center; }
.denoms .count { min-width: 3.2rem; width: auto; }
.denom-on th, .denom-on .count { background: #eef2ff; }
.denoms .total th, .denoms .total td, .fig .total th, .fig .total td { font-weight: 800; border-top: 2px solid var(--ink); }
.sums .bad dd { color: var(--bad); font-weight: 800; }
.report h3 { margin: .2rem 0 .3rem; font-size: 1.1rem; }

/* Receipts and the customer display (PS1 item 5) */
.ticket { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .82rem; background: #fff; border: 1px dashed var(--line); border-radius: 8px; padding: .8rem .6rem; margin: .4rem 0; overflow-x: auto; }
.tk { white-space: pre; line-height: 1.35; }
.tk-c { text-align: center; }
.tk-b { font-weight: 800; }
.tk-code { display: grid; justify-items: center; margin-top: .6rem; }
.tk-code .barcode { max-width: 100%; height: 48px; }
.cd-body { background: var(--navy); color: #fff; }
.cd { min-height: 100vh; display: grid; align-content: center; gap: 1rem; padding: 2rem clamp(1rem, 5vw, 4rem); font-size: clamp(1.1rem, 2.6vw, 2rem); }
.cd .muted { color: #cbd5e1; }
.cd-hello { font-size: clamp(2rem, 6vw, 4rem); font-weight: 800; margin: 0; }
.cd-lines { list-style: none; margin: 0; padding: 0; }
.cd-lines li, .cd-row { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px solid rgba(255, 255, 255, .15); margin: 0; font-variant-numeric: tabular-nums; }
.cd-total { font-size: clamp(2rem, 6vw, 4.5rem); font-weight: 800; color: var(--amber); margin: 0; }
.cd-change { font-size: clamp(1.4rem, 4vw, 3rem); margin: 0; }
.cd-idle, .cd-paid { text-align: center; }

@media print {
  body * { visibility: hidden; }
  .printable, .printable * { visibility: visible; }
  .printable { position: absolute; inset: 0 auto auto 0; width: 100%; padding: 0; color: #000; }
  .sheet { position: static; background: none; }
}

@media (min-width: 760px) {
  .sheet { place-items: center; }
  .sheet-body { border-radius: 18px; }
}
@media (max-width: 759px) {
  /* past Z reports: one card per Z, each figure labelled, so nothing runs off a phone */
  .zlist thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .zlist tr { display: grid; grid-template-columns: 1fr 1fr; gap: .1rem .8rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
  .zlist th, .zlist td { display: block; border: 0; text-align: left; padding: .1rem 0; }
  .zlist [data-label]::before { content: attr(data-label); display: block; font-size: .78rem; font-weight: 600; color: var(--muted); }
  .zlist th[scope="row"]::before { content: "Z report"; }
  .zlist td.zpdf { grid-column: 1 / -1; }
  .zlist td.zpdf .btn { width: 100%; }
  .phone-tabs { display: grid; grid-template-columns: 1fr 1fr; position: sticky; top: 3.4rem; z-index: 4; background: var(--bg); padding: .5rem 1rem 0; gap: .4rem; }
  .phone-tabs button { min-height: 48px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 700; }
  .phone-tabs button[aria-current="true"] { background: var(--ink); color: #fff; }
  .till { grid-template-columns: 1fr; padding-top: .6rem; }
  [data-phone-hidden] { display: none; }
  .basket { position: static; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lines { max-height: none; }
  .line-main { grid-template-columns: minmax(0, 1fr); }
  .line-sum { justify-self: start; }
  .bar { flex-wrap: nowrap; padding-left: .5rem; padding-right: .5rem; }
  .brand { display: none; }
  .bar-right { flex-wrap: nowrap; min-width: 0; width: 100%; justify-content: flex-end; gap: .3rem; }
  .chip { min-height: 44px; padding: .2rem .55rem; font-size: .85rem; white-space: nowrap; max-width: 7.5rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .pill { font-size: .8rem; padding: .15rem .55rem; }
  .chip-k { display: none; }
  .phone-tabs { top: 3.6rem; }
  .close-grid { grid-template-columns: minmax(0, 1fr); }
  .chip { max-width: 6.6rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
