:root {
  /* Brand ixubun */
  --bg: #141414;
  --surface: #1d1d1c;
  --surface-2: #262624;
  --line: #34332f;
  --cream: #f5f5f0;
  --cream-dim: #c9c7bd;
  --muted: #8a887f;
  /* Chức năng: phân biệt phương thức & trạng thái nhanh bằng mắt */
  --qr: #6ea8fe;      /* chuyển khoản / QR — lạnh */
  --cash: #e8b84b;    /* tiền mặt — ấm */
  --ok: #6fcf7f;
  --danger: #e8705f;
  --radius: 16px;
  --tap: 56px;
  font-family: 'Comfortaa', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--cream);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  overscroll-behavior-y: none;
}
/* Comfortaa chỉ dùng cho brand/nhãn; số liệu dùng system + tabular */
.brand, h1, h2, .tab-label, button.tile .t-name { font-family: 'Comfortaa', system-ui, sans-serif; }
.num { font-variant-numeric: tabular-nums; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* ---------- Header ---------- */
.hdr {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}
.hdr .brand { font-weight: 600; font-size: 20px; letter-spacing: .5px; }
.hdr .brand small { color: var(--cream-dim); font-weight: 400; font-size: 11px; display: block; letter-spacing: 2px; margin-top: -2px; }
.hdr .spacer { flex: 1; }
.net {
  font-size: 11px; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--cream-dim);
  display: inline-flex; align-items: center; gap: 6px;
}
.net .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.net.off .dot { background: var(--danger); }
.net.off { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.whoami { font-size: 12px; color: var(--cream-dim); }
.hdr-logout { width: 38px; height: 38px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--cream-dim); font-size: 18px; flex: none; display: flex; align-items: center; justify-content: center; }
.hdr-logout:active { transform: scale(.94); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.miniprice { width: 96px; flex: none; min-height: 40px; text-align: right; font-variant-numeric: tabular-nums; padding: 0 10px; font-size: 15px; }
.hint-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 13px; color: var(--cream-dim); }
.hint-box b { color: var(--cream); }
.recon-mini { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); font-size: 12.5px; }
.recon-mini .row { padding: 2px 0; }

/* ---------- Generic ---------- */
main { flex: 1; padding: 4px 16px 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
h2 { font-size: 15px; font-weight: 600; margin: 4px 2px 12px; color: var(--cream-dim); letter-spacing: .3px; }
.row { display: flex; gap: 10px; align-items: center; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.dim { color: var(--cream-dim); }

button { font-family: inherit; cursor: pointer; border: none; color: inherit; }
.btn {
  min-height: var(--tap); border-radius: 14px; padding: 0 20px;
  background: var(--cream); color: #141414; font-weight: 600; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
}
.btn:active { transform: scale(.985); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--cream); }
.btn:disabled { opacity: .4; }
.btn.ghost:disabled { opacity: .4; }
.btn.danger { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn.sm { min-height: 40px; font-size: 14px; padding: 0 14px; width: auto; }

input, select {
  width: 100%; min-height: var(--tap); background: var(--surface-2);
  border: 1px solid var(--line); color: var(--cream); border-radius: 12px;
  padding: 0 14px; font-size: 16px; font-family: system-ui, sans-serif;
}
label.fld { display: block; margin-bottom: 12px; }
label.fld span { display: block; font-size: 12px; color: var(--cream-dim); margin-bottom: 6px; letter-spacing: .3px; }

/* ---------- Login ---------- */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 24px; gap: 18px; max-width: 400px; margin: 0 auto; width: 100%; }
.login .logo { text-align: center; margin-bottom: 8px; }
.login .logo .mark { font-family: 'Comfortaa'; font-weight: 600; font-size: 40px; letter-spacing: 1px; }
.login .logo .tag { color: var(--cream-dim); letter-spacing: 4px; font-size: 12px; text-transform: uppercase; }
.userpick { display: grid; gap: 8px; }
.userpick button {
  min-height: 54px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
  color: var(--cream); text-align: left; padding: 0 18px; font-size: 16px; display: flex; align-items: center; gap: 10px;
}
.userpick button.sel { border-color: var(--cream); background: var(--surface-2); }
.userpick button .role { margin-left: auto; font-size: 11px; color: var(--muted); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pinpad button { min-height: 62px; font-size: 24px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--cream); }
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 68px; }
.pass-wrap .reveal { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); height: 40px; padding: 0 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); color: var(--cream-dim); font-size: 13px; }
.pindots { display: flex; justify-content: center; gap: 14px; margin: 6px 0 4px; }
.pindots i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--cream-dim); }
.pindots i.on { background: var(--cream); border-color: var(--cream); }

/* ---------- Order / product grid (signature) ---------- */
.sizebar { display: flex; gap: 8px; margin-bottom: 12px; }
.sizebar button { flex: 1; min-height: 44px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--cream-dim); font-weight: 600; font-family: 'Comfortaa'; }
.sizebar button.on { background: var(--cream); color: #141414; border-color: var(--cream); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
button.tile {
  position: relative; min-height: 88px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); color: var(--cream);
  padding: 14px 12px; text-align: left; display: flex; flex-direction: column; justify-content: space-between;
}
button.tile:active { transform: scale(.97); }
button.tile.tracer { border-color: color-mix(in srgb, var(--cash) 45%, var(--line)); }
button.tile .t-name { font-size: 16px; font-weight: 600; line-height: 1.2; }
button.tile .t-price { font-size: 13px; color: var(--cream-dim); }
button.tile .qbadge {
  position: absolute; top: 8px; right: 8px; min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 999px; background: var(--cream); color: #141414; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Cart bar ---------- */
.cartbar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(72px + env(safe-area-inset-bottom) + 10px);
  width: min(528px, calc(100% - 32px)); z-index: 25;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 10px 12px 10px 16px; display: flex; align-items: center; gap: 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.cartbar .sum { flex: 1; }
.cartbar .sum b { font-size: 18px; }
.cartbar .sum small { display: block; color: var(--cream-dim); font-size: 12px; }
.cartbar .btn { width: auto; padding: 0 22px; }

/* ---------- Payment sheet ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 40; display: flex; align-items: flex-end; }
.sheet { background: var(--surface); border-radius: 22px 22px 0 0; width: 100%; max-width: 560px; margin: 0 auto; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.sheet h2 { text-align: center; }
.paypick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.paypick button { min-height: 84px; border-radius: 16px; background: var(--surface-2); border: 2px solid var(--line); color: var(--cream); font-size: 16px; font-weight: 600; font-family: 'Comfortaa'; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.paypick button .ic { font-size: 26px; }
.paypick button.on.qr { border-color: var(--qr); color: var(--qr); }
.paypick button.on.cash { border-color: var(--cash); color: var(--cash); }
.photo-slot { border: 1px dashed var(--line); border-radius: 14px; padding: 14px; text-align: center; color: var(--cream-dim); margin-bottom: 14px; }
.photo-slot img { max-width: 100%; max-height: 180px; border-radius: 10px; display: block; margin: 0 auto 8px; }

/* ---------- Shift / list ---------- */
.stat { text-align: center; padding: 10px; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .k { font-size: 12px; color: var(--cream-dim); }
.olist { display: flex; flex-direction: column; gap: 8px; }
.oitem { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.oitem .pm { width: 8px; align-self: stretch; border-radius: 4px; }
.oitem .pm.qr { background: var(--qr); } .oitem .pm.cash { background: var(--cash); }
.oitem .body { flex: 1; min-width: 0; }
.oitem .body .l1 { font-size: 14px; }
.oitem .body .l2 { font-size: 12px; color: var(--muted); }
.oitem .amt { font-weight: 700; }
.oitem.pending { border-style: dashed; opacity: .8; }
.badge-pending { font-size: 10px; color: var(--cash); border: 1px solid var(--cash); border-radius: 6px; padding: 1px 5px; }
.badge-live { font-size: 10px; color: var(--ok); border: 1px solid var(--ok); border-radius: 6px; padding: 1px 5px; margin-left: 4px; }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 70%, transparent); animation: livepulse 1.8s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- Checklist ---------- */
.chk { display: flex; flex-direction: column; gap: 8px; }
.chk .it { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.chk .it.done { color: var(--muted); }
.chk .box { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); flex: none; display: flex; align-items: center; justify-content: center; }
.chk .it.done .box { background: var(--ok); border-color: var(--ok); color: #141414; }
.chk .it .lbl { flex: 1; font-size: 15px; }
.chk .it.done .lbl { text-decoration: line-through; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 560px; z-index: 30;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  display: flex; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
.tabbar button { flex: 1; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; }
.tabbar button .ic { font-size: 20px; line-height: 1; }
.tabbar button .tab-label { font-size: 11px; }
.tabbar button.on { color: var(--cream); }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(150px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--surface-2); border: 1px solid var(--line); color: var(--cream); padding: 12px 18px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.5); animation: pop .2s ease; }
.toast.ok { border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.toast.err { border-color: var(--danger); color: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* Máy tính tiền thừa (tiền mặt) */
.cashcalc { margin-bottom: 14px; }
.quickrow { display: flex; flex-wrap: wrap; gap: 8px; }
.quickrow .chip { flex: 1; min-width: 64px; min-height: 44px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); color: var(--cream); font-weight: 600; font-family: 'Comfortaa'; font-size: 14px; }
.quickrow .chip:active { transform: scale(.96); }
.changerow { min-height: 34px; display: flex; align-items: center; justify-content: space-between; padding: 6px 4px 0; }

/* Thumbnail ảnh bill trong lịch sử đơn */
.billthumb { width: 46px; height: 46px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; }

/* Lightbox xem ảnh bill */
.photo-viewer { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.9); display: flex; align-items: center; justify-content: center; padding: 20px; }
.photo-viewer img { max-width: 100%; max-height: 100%; border-radius: 10px; }
.hide { display: none !important; }
table.report { width: 100%; border-collapse: collapse; font-size: 14px; }
table.report td, table.report th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.report td.n, table.report th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.report .tracer td:first-child::after { content: ' ◆'; color: var(--cash); }
