/* ============================================================
   Tap POS — checkout screen (landscape, HP Engage 14")
   ============================================================ */

body.pos {
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 100% 0%, #EFEADB 0%, var(--paper) 46%, #EEE9DC 100%);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ---- Header ---------------------------------------------- */
.topbar {
  flex: none;
  height: 66px;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  padding: 0 1.1rem 0 1.25rem;
  color: var(--on-dark);
  background: linear-gradient(100deg, var(--amana-800), var(--amana-600) 60%, var(--amana));
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 22px rgba(6,40,33,.28);
  z-index: 5;
}
.topbar .girih {
  position: absolute; inset: 0;
  color: var(--gold);
  opacity: .10;
  pointer-events: none;
}
.topbar .wordmark { color: #fff; font-size: 1.28rem; position: relative; }
.topbar .wordmark .name span { color: var(--gold-200); }
.topbar .tag {
  font-family: var(--mono);
  font-size: .62rem; letter-spacing: .18em; text-transform: uppercase;
  padding: .26rem .5rem; border-radius: 6px;
  background: rgba(255,255,255,.12); color: var(--gold-100);
  position: relative;
}
.topbar .spacer { flex: 1; }
.topbar .meta {
  display: flex; align-items: center; gap: 1.3rem;
  position: relative;
}
.topbar .meta .cell { display: flex; flex-direction: column; line-height: 1.15; }
.topbar .meta .cell b { font-weight: 700; font-size: .92rem; }
.topbar .meta .cell small { color: #C2D8CF; font-size: .68rem; letter-spacing: .04em; }
.topbar .clock { font-variant-numeric: tabular-nums; text-align: right; }
.topbar .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(160deg, var(--gold-200), var(--gold-600));
  color: var(--ink); display: grid; place-items: center; font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
  position: relative;
}

/* ---- Main split ------------------------------------------ */
.pos-main {
  flex: 1; min-height: 0;
  display: grid;
  grid-template-columns: 1fr clamp(340px, 30vw, 420px);
}

/* ---- Left: catalogue ------------------------------------- */
.catalog { display: flex; flex-direction: column; min-height: 0; padding: 1rem 1.1rem 0; }
.toolbar {
  flex: none;
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: .85rem;
}
.search {
  flex: 1;
  display: flex; align-items: center; gap: .6rem;
  height: 50px; padding: 0 1rem;
  background: var(--card); border-radius: var(--r-pill);
  box-shadow: var(--sh-1); border: 1px solid var(--line-soft);
}
.search svg { width: 19px; height: 19px; color: var(--text-faint); flex: none; }
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 1rem; }
.search input::placeholder { color: var(--text-faint); }
.search kbd {
  font-family: var(--mono); font-size: .64rem; color: var(--text-faint);
  border: 1px solid var(--line); border-radius: 5px; padding: .12rem .38rem;
}

.chips { display: flex; gap: .5rem; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  height: 50px; padding: 0 1.05rem;
  border-radius: var(--r-pill);
  background: var(--card);
  border: 1px solid var(--line-soft);
  color: var(--text-dim);
  font-weight: 600; font-size: .92rem;
  display: inline-flex; align-items: center; gap: .45rem;
  transition: all .14s ease;
}
.chip[aria-pressed="true"] {
  background: var(--ink-2); color: #fff; border-color: var(--ink-2);
  box-shadow: var(--sh-2);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }

.grid-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: .55rem .55rem 1.1rem; margin: 0 -.55rem; }
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(146px, 1fr));
  gap: .8rem;
}
.tile {
  position: relative;
  display: flex; flex-direction: column; gap: .15rem;
  padding: .85rem .8rem .7rem;
  background: var(--card);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  text-align: left;
  box-shadow: var(--sh-1);
  transition: transform .1s ease, box-shadow .15s ease, border-color .15s ease;
  min-height: 138px;
}
.tile:hover { box-shadow: var(--sh-2); border-color: var(--amana-200); transform: translateY(-2px); }
.tile:active { transform: translateY(0) scale(.985); }
.tile .emoji {
  font-size: 2.5rem; line-height: 1; margin-bottom: .35rem;
  filter: drop-shadow(0 4px 6px rgba(14,26,23,.12));
}
.tile .nm { font-weight: 700; font-size: .96rem; letter-spacing: -.01em; }
.tile .un { font-size: .74rem; color: var(--text-faint); }
.tile .pr {
  margin-top: auto; padding-top: .35rem;
  font-family: var(--display); font-weight: 800; font-size: 1.02rem;
  color: var(--amana-700);
}
.tile .pr .cur { font-size: .68rem; color: var(--text-faint); font-weight: 600; margin-right: .15em; }
.tile .qbadge {
  position: absolute; top: -8px; right: -8px;
  min-width: 28px; height: 28px; padding: 0 .4rem;
  border-radius: var(--r-pill);
  background: var(--gold); color: var(--ink);
  font-weight: 800; font-size: .9rem;
  display: grid; place-items: center;
  box-shadow: var(--sh-2);
  transform: scale(0); transition: transform .18s cubic-bezier(.34,1.56,.64,1);
}
.tile[data-qty]:not([data-qty="0"]) { border-color: var(--gold); box-shadow: 0 0 0 1.5px var(--gold) inset, var(--sh-1); }
.tile[data-qty]:not([data-qty="0"]) .qbadge { transform: scale(1); }

/* ---- Right: order rail ----------------------------------- */
.rail {
  background: var(--card);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
  box-shadow: -10px 0 30px rgba(14,26,23,.05);
}
.rail-head {
  flex: none; padding: 1rem 1.15rem .75rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
}
.rail-head .o-no { display: flex; flex-direction: column; }
.rail-head .o-no .eyebrow { margin-bottom: .15rem; }
.rail-head .o-no b { font-family: var(--display); font-weight: 800; font-size: 1.2rem; letter-spacing: -.01em; }
.linkbtn {
  font-weight: 700; font-size: .85rem; color: var(--danger);
  padding: .5rem .6rem; border-radius: 9px;
}
.linkbtn:hover { background: var(--danger-bg); }
.linkbtn[disabled] { color: var(--text-faint); pointer-events: none; }

.lines { flex: 1; min-height: 0; overflow-y: auto; padding: .35rem .75rem; }
.line {
  display: grid; grid-template-columns: auto 1fr auto; gap: .7rem;
  align-items: center;
  padding: .6rem .5rem;
  border-radius: var(--r);
}
.line + .line { border-top: 1px solid var(--line-soft); }
.line .l-emoji { font-size: 1.5rem; width: 2rem; text-align: center; }
.line .l-mid .l-nm { font-weight: 700; font-size: .92rem; }
.line .l-mid .l-un { font-size: .74rem; color: var(--text-faint); }
.line .l-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: .35rem; }
.line .l-tot { font-weight: 800; font-family: var(--display); font-size: .98rem; }
.stepper {
  display: inline-flex; align-items: center; gap: .1rem;
  background: var(--mist); border-radius: var(--r-pill); padding: 2px;
}
.stepper button {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.15rem; font-weight: 800;
  color: var(--amana-700);
}
.stepper button:hover { background: #fff; }
.stepper .q { min-width: 26px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; font-size: .92rem; }

.empty {
  flex: 1; display: grid; place-items: center; text-align: center; padding: 2rem;
  color: var(--text-faint);
}
.empty .ill { font-size: 3rem; opacity: .5; margin-bottom: .6rem; }
.empty p { font-size: .92rem; max-width: 22ch; }

/* ---- Totals + charge ------------------------------------- */
.totals { flex: none; padding: .85rem 1.15rem; border-top: 1px solid var(--line); background: var(--paper-2); }
.trow { display: flex; justify-content: space-between; font-size: .9rem; color: var(--text-dim); padding: .18rem 0; }
.trow.grand {
  margin-top: .5rem; padding-top: .65rem; border-top: 1px dashed var(--line);
  align-items: baseline;
}
.trow.grand .lbl { font-weight: 700; color: var(--text); font-size: 1rem; }
.trow.grand .amt { font-family: var(--display); font-weight: 800; font-size: 1.9rem; letter-spacing: -.02em; color: var(--ink); }
.trow.grand .amt .cur { font-size: .9rem; color: var(--text-dim); font-weight: 700; margin-right: .2em; }
.charge {
  margin-top: .8rem; width: 100%;
  min-height: 70px;
  font-family: var(--display); font-size: 1.18rem; font-weight: 800;
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: space-between; padding: 0 1.4rem;
  background: linear-gradient(180deg, var(--gold-200), var(--gold));
  color: var(--ink);
  box-shadow: var(--sh-2), inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .08s ease, filter .15s ease;
}
.charge:hover { filter: brightness(1.04); }
.charge:active { transform: translateY(1px); }
.charge[disabled] { filter: grayscale(.6); opacity: .5; pointer-events: none; }
.charge .ct { font-variant-numeric: tabular-nums; }

/* ============================================================
   Payment modal
   ============================================================ */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(8,24,20,.55);
  backdrop-filter: blur(5px);
  display: grid; place-items: center;
  padding: 1.5rem;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.sheet {
  width: min(560px, 96vw);
  max-height: 92dvh;
  background: var(--paper-2);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-3);
  overflow: hidden;
  display: flex; flex-direction: column;
  transform: translateY(14px) scale(.985);
  transition: transform .24s cubic-bezier(.2,.9,.3,1);
}
.overlay.show .sheet { transform: none; }
.sheet-head {
  padding: 1.1rem 1.3rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
}
.sheet-head .h-amt { display: flex; flex-direction: column; }
.sheet-head .h-amt .eyebrow { margin-bottom: .2rem; }
.sheet-head .h-amt b { font-family: var(--display); font-weight: 800; font-size: 1.75rem; letter-spacing: -.02em; }
.sheet-head .h-amt b .cur { font-size: .8rem; color: var(--text-dim); font-weight: 700; margin-right: .2em; }
.x {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.3rem; color: var(--text-dim);
  background: var(--mist);
}
.x:hover { background: var(--line); color: var(--text); }
.sheet-body { padding: 1.3rem; overflow-y: auto; }

/* method picker */
.methods { display: grid; gap: .8rem; }
.method {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.05rem 1.2rem;
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-md);
  text-align: left;
  transition: all .14s ease;
}
.method:hover { border-color: var(--amana-300); box-shadow: var(--sh-2); transform: translateY(-1px); }
.method .m-ic {
  width: 52px; height: 52px; border-radius: 14px; flex: none;
  display: grid; place-items: center;
}
.method .m-ic svg { width: 26px; height: 26px; }
.method.cash .m-ic { background: var(--success-bg); color: var(--success); }
.method.card .m-ic { background: #E9EFFB; color: #2F5FB0; }
.method.amanapay .m-ic { background: linear-gradient(150deg, var(--amana-300), var(--amana-700)); color: var(--gold-100); }
.method .m-tx { flex: 1; }
.method .m-tx b { font-weight: 700; font-size: 1.05rem; display: block; }
.method .m-tx small { color: var(--text-dim); font-size: .82rem; }
.method .m-go { color: var(--text-faint); font-size: 1.4rem; }
.method.amanapay .m-tx b { display: inline-flex; align-items: center; gap: .4rem; }
.badge-amana {
  font-family: var(--mono); font-size: .56rem; letter-spacing: .12em; text-transform: uppercase;
  background: var(--amana); color: var(--gold-100); padding: .15rem .4rem; border-radius: 5px;
}

/* sub-flow shell */
.flow { display: none; }
.flow.active { display: block; animation: flow-in .26s ease both; }
@keyframes flow-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.flow-back {
  display: inline-flex; align-items: center; gap: .4rem;
  font-weight: 700; color: var(--amana-700); font-size: .9rem;
  margin-bottom: 1rem; padding: .4rem .2rem;
}
.flow-back:hover { color: var(--amana); }

/* cash flow */
.cash-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: .4rem 0 1rem; }
.cash-grid button {
  min-height: 58px; border-radius: var(--r); background: var(--card);
  border: 1.5px solid var(--line); font-weight: 800; font-size: 1rem;
  font-family: var(--display); color: var(--ink);
  transition: all .12s ease;
}
.cash-grid button:hover { border-color: var(--gold); background: #fff; }
.cash-grid button.exact { grid-column: span 3; background: var(--ink-2); color: #fff; border-color: var(--ink-2); }
.tender-line {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: .6rem 0; font-size: 1rem;
}
.tender-line.change {
  margin-top: .3rem; padding-top: .8rem; border-top: 1px dashed var(--line);
}
.tender-line.change .v { font-family: var(--display); font-weight: 800; font-size: 1.8rem; color: var(--success); }
.tender-line .v.neg { color: var(--danger); }

/* card flow */
.terminal {
  text-align: center; padding: 1.5rem 1rem;
}
.terminal .device {
  width: 130px; height: 130px; margin: 0 auto 1.2rem;
  border-radius: 28px;
  background: linear-gradient(160deg, var(--ink-2), #0b1714);
  display: grid; place-items: center; position: relative;
  box-shadow: var(--sh-3);
}
.terminal .device .wave {
  width: 64px; height: 64px; color: var(--gold-100);
}
.terminal .device::after {
  content: ""; position: absolute; inset: -6px; border-radius: 32px;
  border: 2px solid var(--amana-300); opacity: 0;
  animation: ping 1.6s ease-out infinite;
}
@keyframes ping { 0% { transform: scale(.9); opacity: .6; } 100% { transform: scale(1.18); opacity: 0; } }
.terminal h3 { font-family: var(--display); font-size: 1.2rem; margin-bottom: .3rem; }
.terminal p { color: var(--text-dim); font-size: .9rem; }

/* mobilepay / QR flow */
.qr-flow { text-align: center; }
.qr-stage { display: flex; flex-direction: column; align-items: center; }
.qr-frame {
  position: relative;
  width: 268px; height: 268px;
  margin: .3rem auto 1.1rem;
  display: grid; place-items: center;
  padding: 20px;
  background: #fff;
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.qr-frame .corner {
  position: absolute; width: 30px; height: 30px;
  border: 3px solid var(--gold); border-radius: 4px;
}
.qr-frame .corner.tl { top: 9px; left: 9px; border-right: 0; border-bottom: 0; }
.qr-frame .corner.tr { top: 9px; right: 9px; border-left: 0; border-bottom: 0; }
.qr-frame .corner.bl { bottom: 9px; left: 9px; border-right: 0; border-top: 0; }
.qr-frame .corner.br { bottom: 9px; right: 9px; border-left: 0; border-top: 0; }
.qr-frame canvas, .qr-frame img { width: 220px !important; height: 220px !important; border-radius: 6px; }
.qr-frame .scanline {
  position: absolute; left: 22px; right: 22px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--amana-300), transparent);
  box-shadow: 0 0 10px 2px rgba(62,158,137,.55);
  animation: scan 2.4s ease-in-out infinite;
}
@keyframes scan { 0%,100% { top: 26px; } 50% { top: calc(100% - 28px); } }

.qr-flow h3 { font-family: var(--display); font-size: 1.22rem; }
.qr-flow .sub { color: var(--text-dim); font-size: .9rem; margin-top: .15rem; }
.qr-ref {
  font-family: var(--mono); font-size: .76rem; letter-spacing: .04em;
  color: var(--text-dim); margin-top: .9rem;
  display: inline-flex; gap: .5rem; align-items: center;
}
.qr-ref b { color: var(--text); }
.waiting {
  display: inline-flex; align-items: center; gap: .55rem;
  margin-top: 1.1rem; padding: .5rem .95rem;
  background: var(--amana); color: #fff; border-radius: var(--r-pill);
  font-weight: 700; font-size: .9rem;
}
.waiting .pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--gold-200);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.25); } }
.qr-flow .manual {
  margin-top: 1rem; font-size: .82rem; color: var(--text-faint);
}
.qr-flow .manual button { color: var(--amana-700); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* success */
.done { text-align: center; padding: 1.4rem 1rem .6rem; }
.done .seal {
  width: 110px; height: 110px; margin: 0 auto 1.1rem; position: relative;
  display: grid; place-items: center;
}
.done .seal .ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, var(--success-bg), #fff);
  box-shadow: 0 0 0 2px var(--success) inset;
}
.done .seal .star { width: 108px; height: 108px; color: var(--success); opacity: .14; position: absolute; }
.done .seal .tick { position: relative; width: 56px; height: 56px; color: var(--success); }
.done .seal .tick path { stroke-dasharray: 48; stroke-dashoffset: 48; animation: draw .5s ease .15s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.done h3 { font-family: var(--display); font-size: 1.5rem; }
.done .paid { font-family: var(--display); font-weight: 800; font-size: 1.1rem; color: var(--amana-700); margin: .2rem 0 .1rem; }
.done .via { color: var(--text-dim); font-size: .88rem; }
.done .ref2 { font-family: var(--mono); font-size: .74rem; color: var(--text-faint); margin-top: .6rem; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--ink-2); color: #fff; padding: .8rem 1.2rem; border-radius: var(--r-pill);
  font-weight: 600; font-size: .92rem; box-shadow: var(--sh-3);
  display: flex; align-items: center; gap: .6rem;
  opacity: 0; pointer-events: none; transition: all .26s cubic-bezier(.2,.9,.3,1); z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast .k { color: var(--gold-200); }

/* ---- Responsive: stack rail for tablet / portrait --------- */
@media (max-width: 880px) {
  .pos-main { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: auto 0 0 0; max-height: 64dvh;
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    box-shadow: 0 -16px 40px rgba(14,26,23,.18);
    transform: translateY(calc(100% - 132px));
    transition: transform .3s cubic-bezier(.2,.9,.3,1);
    z-index: 20;
  }
  .rail.open { transform: none; }
  .rail-head { cursor: pointer; }
  .catalog { padding-bottom: 150px; }
}
@media (max-width: 520px) {
  .topbar .meta .cell.hide-sm { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: .6rem; }
  .tile .emoji { font-size: 2.1rem; }
}
