/* Nopakgh POS */
:root { --navy: #0C1E36; --steel: #1E3A5F; --blue: #1D4ED8; --gold: #C5A028; --ink: #0C1E36; --muted: #4A5568; --border: #D5DCE6; --surface: #F4F6FA; --ok: #067647; --bad: #B42318; --warn: #93370D; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--surface); }
[hidden] { display: none !important; }
a { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
p { margin: 0 0 .75rem; }
small { color: var(--muted); }
code { font-size: .88em; background: #EEF1F6; padding: .1rem .35rem; border-radius: 4px; }
.hint { color: var(--muted); font-size: .92rem; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--blue); margin: 0 0 .25rem; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.demo-banner { background: #FFF4C2; color: #5C4600; font-size: .85rem; font-weight: 600; text-align: center; padding: .35rem 1rem; }
.demo-banner .link-btn { color: #5C4600; font-weight: 700; }
.logo { display: flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.15rem; }
.logo b { color: var(--blue); }
.warn { color: var(--warn); font-weight: 600; }

/* sign-in screens */
.center { min-height: calc(100vh - 32px); display: flex; align-items: center; justify-content: center; padding: 1.25rem 1rem; }
.auth { width: min(30rem, 100%); }
.auth .logo { margin-bottom: 1rem; }
.tabs { display: flex; gap: .25rem; background: var(--surface); padding: .25rem; border-radius: 10px; margin-bottom: 1rem; }
.tabs button { flex: 1; font: inherit; font-weight: 700; border: 0; background: none; padding: .6rem .5rem; border-radius: 8px; cursor: pointer; color: var(--muted); min-height: 44px; }
.tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(12, 30, 54, .15); }
.plans { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); }
.plan { position: relative; border: 2px solid var(--border); border-radius: 10px; padding: .7rem .8rem; cursor: pointer; display: grid; gap: .1rem; font-weight: 400; }
.plan input { position: absolute; opacity: 0; }
.plan:has(input:checked) { border-color: var(--blue); background: #EFF4FF; }
.plan:has(input:focus-visible) { outline: 3px solid var(--blue); outline-offset: 2px; }
.plan span { font-weight: 700; }
.staff-pick { display: grid; gap: .5rem; margin-bottom: 1rem; }
.staff-btn { display: flex; align-items: center; gap: .8rem; text-align: left; font: inherit; font-weight: 700; border: 1.5px solid var(--border); background: #fff; border-radius: 12px; padding: .7rem .9rem; cursor: pointer; min-height: 56px; }
.staff-btn:hover { border-color: var(--blue); }
.staff-btn small { display: block; font-weight: 400; }
.avatar { width: 2.4rem; height: 2.4rem; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }
.pin { text-align: center; margin-bottom: 1rem; }
.pin-dots { display: flex; justify-content: center; gap: .8rem; margin: .5rem 0 1rem; }
.pin-dots span { width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid var(--navy); }
.pin-dots span.on { background: var(--navy); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; max-width: 18rem; margin: 0 auto 1rem; }
.keypad button { font: inherit; font-size: 1.4rem; font-weight: 700; min-height: 60px; border-radius: 12px; border: 1.5px solid var(--border); background: #fff; cursor: pointer; }
.keypad button:active { background: var(--surface); }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) { .shake, .pulse { animation: none !important; } }

/* app shell */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--navy); color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .5rem 1rem; }
.topbar .logo { font-size: 1rem; }
.nav { display: flex; gap: .2rem; overflow-x: auto; order: 3; width: 100%; scrollbar-width: none; }
.nav a { color: #D8E0EC; text-decoration: none; font-weight: 600; padding: .45rem .7rem; border-radius: 8px; white-space: nowrap; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav a[aria-current="page"] { background: #fff; color: var(--navy); }
.who { margin-left: auto; display: flex; align-items: center; gap: .6rem; font-size: .88rem; color: #D8E0EC; }
@media (min-width: 1100px) { .nav { order: 0; width: auto; flex: 1; } .who { margin-left: 0; } }
.content { padding: 1.25rem 1rem 3rem; outline: none; }
@media (min-width: 900px) { .content { padding: 1.5rem 2rem 3rem; } }
body[data-page="till"] .content { padding: 0; }

/* blocks */
.panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.panel.narrow { max-width: 44rem; }
.auth.panel { padding: 1.5rem; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; display: grid; gap: .2rem; }
.kpi span { color: var(--muted); font-size: .88rem; font-weight: 600; }
.kpi strong { font-size: 1.4rem; }
.grid-2 { display: grid; gap: 0 1rem; }
@media (min-width: 1000px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.rows { list-style: none; margin: 0 0 .75rem; padding: 0; }
.rows li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.rows li:last-child { border-bottom: 0; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: .5rem; align-items: end; height: 170px; margin-bottom: .5rem; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .25rem; }
.bar-fill { width: 100%; max-width: 38px; background: var(--blue); border-radius: 6px 6px 0 0; min-height: 2px; }
.bar-val { font-size: .78rem; color: var(--muted); }
.bar-label { font-size: .8rem; font-weight: 600; }
.empty { background: #fff; border: 1px dashed var(--border); border-radius: 12px; padding: 2rem; text-align: center; color: var(--muted); }

/* tables */
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; margin-bottom: 1rem; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table-wrap table { min-width: 720px; }
th, td { text-align: left; padding: .6rem .8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.actions-cell { display: flex; gap: .4rem; justify-content: flex-end; }
.badge { display: inline-block; font-size: .78rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; white-space: nowrap; }
.badge-ok { background: #ECFDF3; color: var(--ok); }
.badge-bad { background: #FEF3F2; color: var(--bad); }
.badge-warn { background: #FFFAEB; color: var(--warn); }
.badge-muted { background: var(--surface); color: var(--muted); }

/* forms */
.form { display: grid; gap: .85rem; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .93rem; }
input, select { font: inherit; padding: .55rem .7rem; min-height: 44px; border: 1.5px solid #8A94A6; border-radius: 8px; background: #fff; color: var(--ink); width: 100%; }
input[type="checkbox"], input[type="radio"] { min-height: 0; width: 1.15rem; height: 1.15rem; accent-color: var(--blue); }
.toolbar input, .toolbar select { width: auto; }
.toolbar input[type="search"] { min-width: 14rem; }
.check { display: flex; align-items: center; gap: .5rem; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 600; font-size: .93rem; margin-bottom: .4rem; }
.row { display: grid; gap: .85rem; }
@media (min-width: 560px) { .row { grid-template-columns: 1fr 1fr; } .row .check { align-self: end; padding-bottom: .6rem; } }
.inline { display: flex; gap: .5rem; }
.error { color: var(--bad); font-weight: 600; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .5rem 1rem; border-radius: 8px; border: 2px solid transparent; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-light { background: rgba(255, 255, 255, .12); color: #fff; }
.btn-danger { background: #fff; color: var(--bad); border-color: var(--bad); }
.btn-small { min-height: 36px; padding: .3rem .7rem; font-size: .88rem; }
.btn-block { width: 100%; }
.btn-big { min-height: 56px; font-size: 1.1rem; }
.link-btn { font: inherit; background: none; border: 0; color: var(--blue); text-decoration: underline; cursor: pointer; padding: .25rem 0; }
dialog { border: 0; border-radius: 14px; padding: 0; width: min(34rem, calc(100vw - 1.5rem)); max-height: calc(100vh - 2rem); box-shadow: 0 20px 60px rgba(12, 30, 54, .3); }
dialog::backdrop { background: rgba(12, 30, 54, .45); }
.dialog-body { padding: 1.3rem; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--navy); color: #fff; padding: .7rem 1.1rem; border-radius: 10px; font-weight: 600; z-index: 50; max-width: calc(100vw - 2rem); box-shadow: 0 8px 24px rgba(12, 30, 54, .3); }

/* till */
.till { display: grid; grid-template-columns: 1fr; min-height: calc(100vh - 140px); }
.till-products { padding: 1rem; min-width: 0; }
.till-search { display: flex; gap: .5rem; margin-bottom: .75rem; }
.till-search input { font-size: 1.05rem; min-height: 50px; }
.till-search .btn { white-space: nowrap; }
@media (max-width: 599px) { .wide-only { display: none; } }
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .5rem; scrollbar-width: thin; }
.chip { font: inherit; font-size: .9rem; font-weight: 600; white-space: nowrap; border: 1.5px solid var(--border); background: #fff; border-radius: 999px; padding: .4rem .9rem; cursor: pointer; min-height: 40px; }
.chip[aria-pressed="true"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.product-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr)); padding-bottom: 5rem; }
.product { position: relative; font: inherit; text-align: left; display: flex; flex-direction: column; gap: .3rem; justify-content: space-between; min-height: 96px; padding: .75rem; border: 1.5px solid var(--border); border-radius: 12px; background: #fff; cursor: pointer; }
.product:hover { border-color: var(--blue); }
.product:active { transform: scale(.98); }
.p-name { font-weight: 600; line-height: 1.25; }
.product.has-img { padding-top: .5rem; }
.p-img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; background: var(--surface); margin-bottom: .15rem; }
.p-ph { display: grid; place-items: center; font-size: 2rem; font-weight: 800; color: #9AA6B8; background: linear-gradient(135deg, #EEF1F6, #E2E7EF); }
.p-cell { display: flex; align-items: center; gap: .6rem; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; background: var(--surface); }
.thumb-empty { border: 1px dashed var(--border); }
.photo-field { display: flex; gap: 1rem; align-items: center; }
.photo-preview { width: 96px; height: 96px; border-radius: 12px; border: 1.5px dashed var(--border); background: var(--surface); display: grid; place-items: center; overflow: hidden; flex: none; color: var(--muted); font-size: .85rem; }
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: grid; gap: .35rem; justify-items: start; }
.photo-actions .label { font-weight: 600; font-size: .93rem; }
.file-btn { display: inline-flex; cursor: pointer; }
.file-btn:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }
.p-price { font-weight: 800; }
.stock { font-size: .78rem; font-weight: 700; }
.stock.low { color: var(--warn); }
.stock.out { color: var(--bad); }
.p-qty { position: absolute; top: -.45rem; right: -.45rem; min-width: 1.6rem; height: 1.6rem; border-radius: 999px; background: var(--blue); color: #fff; font-weight: 800; font-size: .85rem; display: grid; place-items: center; padding: 0 .35rem; }
.cart { background: #fff; display: flex; flex-direction: column; }
.cart-head { display: flex; align-items: center; gap: 1rem; padding: 1rem 1rem .5rem; border-bottom: 1px solid var(--border); }
.cart-head h2 { margin: 0; flex: 1; }
.lines { list-style: none; margin: 0; padding: 0 1rem; overflow-y: auto; flex: 1; }
.lines li { display: grid; grid-template-columns: 1fr auto; gap: .2rem .75rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--border); }
.l-name { font-weight: 600; display: grid; }
.l-total { text-align: right; grid-column: 2; grid-row: 1; }
.qty { display: flex; align-items: center; gap: .35rem; grid-column: 1 / -1; }
.qty button { font: inherit; font-size: 1.2rem; font-weight: 700; width: 40px; height: 40px; border-radius: 8px; border: 1.5px solid var(--border); background: #fff; cursor: pointer; }
.qty span { min-width: 2rem; text-align: center; font-weight: 700; }
.empty-cart { color: var(--muted); padding: 1.5rem 1rem; flex: 1; }
.cart-foot { padding: .75rem 1rem 1rem; border-top: 1px solid var(--border); display: grid; gap: .35rem; }
.cart-extra { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; margin-bottom: .25rem; }
.sum { display: flex; justify-content: space-between; }
.sum.total { font-size: 1.25rem; font-weight: 800; margin-bottom: .5rem; }
.cart-bar { position: fixed; left: .75rem; right: .75rem; bottom: .75rem; z-index: 6; display: flex; justify-content: space-between; align-items: center; gap: .5rem; font: inherit; font-weight: 700; color: #fff; background: var(--blue); border: 0; border-radius: 12px; padding: .9rem 1.1rem; min-height: 56px; box-shadow: 0 8px 24px rgba(29, 78, 216, .35); cursor: pointer; }
.pulse { animation: pulse .35s; }
@keyframes pulse { 50% { transform: scale(1.03); } }
/* phone / small tablet: the sale opens as a sheet */
@media (max-width: 899px) {
  .cart { position: fixed; inset: auto 0 0 0; z-index: 8; max-height: 88vh; border-radius: 16px 16px 0 0; box-shadow: 0 -12px 40px rgba(12, 30, 54, .3); transform: translateY(105%); transition: transform .2s; }
  body.cart-open .cart { transform: none; }
  body.cart-open .cart-bar { display: none; }
}
@media (min-width: 900px) {
  .till { grid-template-columns: 1fr 24rem; height: calc(100vh - 92px); min-height: 0; }
  .till-products { overflow-y: auto; }
  .product-grid { padding-bottom: 1rem; }
  .cart { border-left: 1px solid var(--border); min-height: 0; }
  .cart-bar, .cart-close { display: none !important; }
}
@media (min-width: 900px) and (max-width: 1099px) { .till { height: calc(100vh - 132px); } }

/* payment + receipt dialogs */
.quick { display: flex; flex-wrap: wrap; gap: .4rem; }
.change { font-size: 1.15rem; margin: 0; min-height: 1.7rem; }
.momo-status { display: flex; align-items: center; gap: .6rem; background: #EFF4FF; border-radius: 10px; padding: .8rem 1rem; font-weight: 600; }
.spinner { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 3px solid #BFD0F5; border-top-color: var(--blue); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.done { background: #ECFDF3; color: var(--ok); font-weight: 700; border-radius: 10px; padding: .7rem 1rem; }
.receipt { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85rem; background: #FAFAF7; border: 1px dashed #C8CDD6; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.receipt h3 { text-align: center; margin: 0 0 .25rem; font-size: 1rem; }
.receipt > p { text-align: center; margin: 0 0 .5rem; }
.receipt table { margin: .5rem 0; border-top: 1px dashed #C8CDD6; border-bottom: 1px dashed #C8CDD6; }
.receipt td { padding: .2rem 0; border: 0; }
.r-row { display: flex; justify-content: space-between; }
.r-total { font-weight: 800; font-size: 1rem; margin: .25rem 0; }
.r-refund { color: var(--bad); font-weight: 700; }
.r-foot { margin-top: .75rem !important; }
.sms { margin-bottom: .25rem; }
.pick-list { list-style: none; padding: 0; margin: .75rem 0; max-height: 18rem; overflow-y: auto; }
.pick-list button { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: .5rem; text-align: left; font: inherit; border: 0; border-bottom: 1px solid var(--border); background: none; padding: .7rem .25rem; cursor: pointer; }
.pick-list button:hover { background: var(--surface); }
.pick-list small { display: block; }
details summary { cursor: pointer; font-weight: 600; color: var(--blue); margin: .5rem 0; }
.scan-video { width: 100%; border-radius: 10px; background: #000; aspect-ratio: 4 / 3; object-fit: cover; }

#print-area { display: none; }
@media print {
  @page { size: 80mm auto; margin: 4mm; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  #print-area .receipt { border: 0; background: none; padding: 0; font-size: 11px; }
}

/* offline / waiting sales */
.net { font: inherit; font-size: .8rem; font-weight: 700; border: 0; border-radius: 999px; padding: .2rem .65rem; cursor: pointer; }
.net-off { background: #FFE2B8; color: #6B3A00; }
.net-wait { background: #DCE8FF; color: #12307A; }
.net-bad { background: #FDE1DE; color: #8A1C12; }
.notice { background: #FFF8E1; border: 1px solid #E8C766; border-radius: 10px; padding: .65rem .9rem; }

/* branches */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin-bottom: .75rem; }
.page-head h1 { margin: 0; }
.branch-pick { display: flex; align-items: center; gap: .5rem; font-weight: 600; margin: 0; }
.branch-pick select { width: auto; margin: 0; }
.panel h3 { font-size: 1rem; margin: 1.1rem 0 .4rem; }
