:root {
  --bg: #f4efe9; --card: #fffdfa; --ink: #2b1d14; --muted: #8a7768; --line: #eadfd4;
  --brand: #6f4e37; --brand-2: #a9744f; --brand-soft: #f3e6da;
  --g1: #2f7d6d; --g1s: #e2f2ee;   /* KH thường */
  --g2: #c2562f; --g2s: #fbe7de;   /* KH sự kiện */
  --g3: #6a4bb3; --g3s: #ece6f8;   /* KH truyền thống */
  --ok: #2f7d4f; --danger: #c0392b; --r: 18px; --gap: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 15px/1.35 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; overflow: hidden; user-select: none; }
input, select, textarea { user-select: text; font: inherit; color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; touch-action: manipulation; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }

/* layout: tối ưu 1397x768 */
.shell { display: grid; grid-template-columns: 88px 1fr; height: 100vh; }
.nav { background: var(--ink); display: flex; flex-direction: column; gap: 6px; padding: 10px 8px; }
.nav .logo { color: #f3d9b8; font-weight: 800; text-align: center; font-size: 13px; padding: 6px 0 10px; line-height: 1.15; }
.nav button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 2px; border-radius: 14px;
  color: #cdbbaa; font-size: 12px; }
.nav button .ic { font-size: 24px; line-height: 1; }
.nav button.on { background: var(--brand); color: #fff; }
.nav .spacer { flex: 1; }
.main { padding: var(--gap); overflow: hidden; display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: 0 1px 0 var(--line), 0 6px 18px -12px rgba(60,30,10,.25); min-height: 0; }
.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.scroll { overflow-y: auto; overscroll-behavior: contain; }
.scroll::-webkit-scrollbar { width: 8px; } .scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }

.btn { min-height: 48px; padding: 0 18px; border-radius: 14px; background: var(--brand-soft); color: var(--brand); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.danger { background: #fbe4e1; color: var(--danger); }
.btn.sm { min-height: 38px; padding: 0 12px; border-radius: 10px; font-size: 14px; }
.btn:disabled { opacity: .45; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea, input.in, select.in {
  height: 46px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px; background: #fff; font-size: 16px; color: var(--ink); }
.field textarea { height: 70px; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); border-color: transparent; }

/* ---------- POS ---------- */
.tabs { display: flex; gap: 8px; align-items: center; height: 54px; flex-shrink: 0; }
.tabs .list { display: flex; gap: 8px; overflow-x: auto; flex: 0 1 auto; scrollbar-width: none; }
.tabs .add { margin-right: auto; }
.tab { height: 50px; padding: 0 16px; border-radius: 14px; background: var(--card); font-weight: 700; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tab .badge { background: var(--brand-soft); color: var(--brand); border-radius: 99px; padding: 1px 8px; font-size: 13px; }
.tab.on { background: var(--brand); color: #fff; } .tab.on .badge { background: rgba(255,255,255,.2); color: #fff; }
.tab .x { margin-left: 2px; width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; opacity: .7; }
.tab .x:active { background: rgba(0,0,0,.15); }
.tab.add { background: var(--brand-soft); color: var(--brand); font-size: 22px; padding: 0 18px; }
.who { font-size: 13px; text-align: right; color: var(--muted); }
.who b { color: var(--ink); display: block; font-size: 15px; }

.pos { display: grid; grid-template-columns: 1fr 430px; gap: var(--gap); flex: 1; min-height: 0; }
.menu { display: flex; flex-direction: column; gap: 10px; }
.cats { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { height: 44px; padding: 0 16px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.chip.on { background: var(--brand); color: #fff; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(146px, 1fr)); gap: 10px; align-content: start; flex: 1; padding-right: 4px; }
.prod { background: #fff; border: 1.5px solid var(--line); border-radius: 16px; overflow: hidden; text-align: left; display: flex; flex-direction: column; position: relative; }
.prod:active { transform: scale(.96); border-color: var(--brand-2); }
.prod .img { height: 92px; background: var(--brand-soft) center/cover no-repeat; display: grid; place-items: center; font-size: 34px; color: var(--brand-2); font-weight: 800; }
.prod .t { padding: 8px 10px 0; font-weight: 700; font-size: 15px; line-height: 1.2; height: 44px; overflow: hidden; }
.prod .p { padding: 0 10px 8px; color: var(--brand); font-weight: 800; }
.prod .q { position: absolute; top: 6px; right: 6px; background: var(--brand); color: #fff; min-width: 30px; height: 30px; border-radius: 99px;
  display: grid; place-items: center; font-weight: 800; padding: 0 8px; box-shadow: 0 2px 6px rgba(0,0,0,.25); }

.side { display: flex; flex-direction: column; gap: var(--gap); min-height: 0; }
.groups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gbtn { height: 58px; border-radius: 14px; font-weight: 800; font-size: 15px; border: 2px solid transparent; line-height: 1.1; }
.gbtn small { display: block; font-weight: 600; font-size: 11px; opacity: .8; }
.gbtn.thuong { background: var(--g1s); color: var(--g1); } .gbtn.thuong.on { background: var(--g1); color: #fff; }
.gbtn.su_kien { background: var(--g2s); color: var(--g2); } .gbtn.su_kien.on { background: var(--g2); color: #fff; }
.gbtn.truyen_thong { background: var(--g3s); color: var(--g3); } .gbtn.truyen_thong.on { background: var(--g3); color: #fff; }
.cart { flex: 1; display: flex; flex-direction: column; padding: 10px 14px; }
.cart .items { flex: 1; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: center; }
.line .n { font-weight: 700; } .line .sub { font-size: 13px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 4px; grid-row: span 2; }
.stepper button { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-size: 22px; font-weight: 800; }
.stepper span { min-width: 32px; text-align: center; font-weight: 800; font-size: 18px; }
.empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; }
.pay { padding: 12px 14px; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 14px; margin-bottom: 10px; }
.totals .big { font-size: 30px; font-weight: 900; color: var(--brand); }
.paybtns { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; }
.paybtns .btn { height: 62px; font-size: 18px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(30,18,10,.45); display: grid; place-items: center; z-index: 50; }
.modal-box { background: var(--card); border-radius: 22px; padding: 22px; width: 520px; max-width: 94vw; max-height: 94vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.modal-box.wide { width: 860px; }
.modal-box h2 { margin: 0 0 14px; font-size: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.qrbox { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: center; }
.qrbox .qr { background: #fff; padding: 10px; border-radius: 16px; border: 1.5px solid var(--line); }
.qrbox .qr svg { display: block; width: 100%; height: auto; }
.amount-big { font-size: 38px; font-weight: 900; color: var(--brand); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.quick .btn { height: 56px; font-size: 17px; }
.change { font-size: 26px; font-weight: 900; color: var(--ok); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 14px; z-index: 60; font-weight: 600; }
.toast.err { background: var(--danger); }

/* ---------- admin pages ---------- */
.page-head { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.page-head h1 { margin: 0; font-size: 24px; flex: 1; }
.bento { display: grid; gap: var(--gap); flex: 1; min-height: 0; }
.kpi .v { font-size: 28px; font-weight: 900; } .kpi .s { color: var(--muted); font-size: 13px; }
.kpi.g-thuong { background: var(--g1s); } .kpi.g-thuong .v { color: var(--g1); }
.kpi.g-su_kien { background: var(--g2s); } .kpi.g-su_kien .v { color: var(--g2); }
.kpi.g-truyen_thong { background: var(--g3s); } .kpi.g-truyen_thong .v { color: var(--g3); }
.kpi.dark { background: var(--brand); color: #fff; } .kpi.dark .s { color: #f0dccb; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 1.5px solid var(--line); position: sticky; top: 0; background: var(--card); }
table.t td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t .r { text-align: right; }
.pill { display: inline-block; border-radius: 99px; padding: 2px 10px; font-size: 12px; font-weight: 700; }
.pill.thuong { background: var(--g1s); color: var(--g1); } .pill.su_kien { background: var(--g2s); color: var(--g2); } .pill.truyen_thong { background: var(--g3s); color: var(--g3); }
.pill.cancelled { background: #eee; color: #777; } .pill.staff { background: var(--brand-soft); color: var(--brand); } .pill.admin { background: var(--ink); color: #fff; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 100%; padding-top: 6px; }
.bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; min-width: 0; }
.bars .stack { display: flex; flex-direction: column-reverse; border-radius: 6px 6px 0 0; overflow: hidden; }
.bars .lbl { font-size: 11px; color: var(--muted); text-align: center; margin-top: 4px; white-space: nowrap; overflow: hidden; }
.seg-thuong { background: var(--g1); } .seg-su_kien { background: var(--g2); } .seg-truyen_thong { background: var(--g3); } .seg-all { background: var(--brand-2); }
.share { height: 14px; border-radius: 99px; overflow: hidden; display: flex; background: var(--line); margin: 6px 0 10px; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.presets { display: flex; gap: 6px; } .presets .chip { height: 40px; padding: 0 12px; font-size: 14px; }
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; align-content: start; }
.pcard { background: #fff; border: 1.5px solid var(--line); border-radius: 16px; overflow: hidden; text-align: left; }
.pcard .img { height: 110px; background: var(--brand-soft) center/cover; display: grid; place-items: center; font-size: 38px; color: var(--brand-2); font-weight: 800; }
.pcard .b { padding: 10px; } .pcard.off { opacity: .5; }
.imgpick { display: flex; gap: 12px; align-items: center; }
.imgpick .prev { width: 110px; height: 110px; border-radius: 14px; background: var(--brand-soft) center/cover; flex-shrink: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.lines-in { display: grid; grid-template-columns: 1fr 80px 90px 120px 110px 40px; gap: 6px; align-items: center; }
.lines-in input { height: 44px; border: 1.5px solid var(--line); border-radius: 10px; padding: 0 10px; width: 100%; min-width: 0; background: #fff; font-size: 15px; }
.lines-in .hd { font-size: 12px; color: var(--muted); }
.seg { display: inline-flex; background: var(--brand-soft); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { height: 42px; padding: 0 18px; border-radius: 10px; font-weight: 700; color: var(--brand); }
.seg button.on { background: var(--brand); color: #fff; }
.login { height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #3b2619, #6f4e37); }
.login .card { width: 400px; padding: 28px; }
.login h1 { margin: 0 0 4px; } .login form { display: grid; gap: 12px; margin-top: 18px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; color: var(--ink); height: 46px; }
.check input { width: 22px; height: 22px; }
.totals > :nth-child(even) { text-align: right; }
.gbtn { position: relative; transition: transform .1s; }
.groups:has(.on) .gbtn:not(.on) { opacity: .45; }
.gbtn.thuong.on { transform: scale(1.04); box-shadow: 0 0 0 3px var(--card), 0 0 0 6px var(--g1), 0 8px 18px -6px rgba(0,0,0,.35); }
.gbtn.su_kien.on { transform: scale(1.04); box-shadow: 0 0 0 3px var(--card), 0 0 0 6px var(--g2), 0 8px 18px -6px rgba(0,0,0,.35); }
.gbtn.truyen_thong.on { transform: scale(1.04); box-shadow: 0 0 0 3px var(--card), 0 0 0 6px var(--g3), 0 8px 18px -6px rgba(0,0,0,.35); }
.gbtn.on::after { content: '✓'; position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 99px; background: #fff; color: var(--ink); font-size: 14px; display: grid; place-items: center; box-shadow: 0 2px 6px rgba(0,0,0,.3); }
.groups { padding: 6px; }
.menu .cats { flex-wrap: nowrap; }
.menu .cats .chip { flex: 1; min-width: 0; padding: 0 8px; height: 52px; font-size: 16px; }
.qbtn { width: 64px; height: 52px; padding: 0; font-size: 22px; flex-shrink: 0; }
.menu #q { height: 52px; }
