:root {
  /* Sáng */
  --bg: #FFF8F0;
  --card: #FFFFFF;
  --surface-2: #FFFCF8;
  --ink: #2B1D14;
  --ink-inv: #FFFFFF;
  --muted: #8A7666;
  --line: #EEDFCF;
  --accent: #D9480F;
  --accent-ink: #FFFFFF;
  --accent-soft: #FFE8D9;
  --accent-strong: #A33A00;
  --ok: #2F9E44;
  --ok-soft: #E6F6EA;
  --warn: #E67700;
  --warn-soft: #FFF1D6;
  --late: #E03131;
  --late-soft: #FFE3E3;
  --danger: #E03131;
  --note: #FFF3BF;
  --pay: #1C7ED6;
  --scrim: rgba(43, 29, 20, .45);
  --floor: #FBF1E6;
  --floor-dot: transparent;
  --wall: #CBB8A4;
  --empty-bg: rgba(255, 255, 255, .55);
  --counter-a: #EADBCB;
  --counter-b: #E3D2BF;
  --counter-ink: #7A6552;
  --counter-line: #D8C3AD;
  --lvl-bg: #FFE8CC;
  --lvl-ink: #A33A00;
  --lvl0-bg: #EDF2F7;
  --lvl0-ink: #4A5568;
  --lvl3-bg: #FFD8A8;
  --sbar-track: rgba(43, 29, 20, .08);
  --sbar-thumb: rgba(43, 29, 20, .38);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 30, 10, .06), 0 4px 14px rgba(60, 30, 10, .06);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
/* Tối (mặc định): kiểu "tech", tương phản cao, dễ nhìn trong bếp */
:root[data-theme="dark"] {
  --bg: #0D1015;
  --card: #161A22;
  --surface-2: #12161D;
  --ink: #E8EBF2;
  --ink-inv: #0D1015;
  --muted: #8C95A8;
  --line: #2A303C;
  --accent: #FF6A3D;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(255, 106, 61, .16);
  --accent-strong: #FF9A76;
  --ok: #34D399;
  --ok-soft: rgba(52, 211, 153, .14);
  --warn: #FBBF24;
  --warn-soft: rgba(251, 191, 36, .14);
  --late: #F87171;
  --late-soft: rgba(248, 113, 113, .16);
  --danger: #DC2626;
  --note: rgba(251, 191, 36, .16);
  --pay: #2563EB;
  --scrim: rgba(0, 0, 0, .62);
  --floor: #11151C;
  --floor-dot: rgba(255, 255, 255, .06);
  --wall: #3A4252;
  --empty-bg: rgba(255, 255, 255, .02);
  --counter-a: #1C222D;
  --counter-b: #181D26;
  --counter-ink: #8C95A8;
  --counter-line: #2A303C;
  --lvl-bg: rgba(251, 146, 60, .18);
  --lvl-ink: #FDBA74;
  --lvl0-bg: rgba(148, 163, 184, .18);
  --lvl0-ink: #CBD5E1;
  --lvl3-bg: rgba(251, 146, 60, .34);
  --sbar-track: rgba(255, 255, 255, .06);
  --sbar-thumb: rgba(255, 255, 255, .35);
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 6px 20px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--late); min-height: 1.2em; margin: 6px 0 0; }
.warn { color: var(--warn); font-size: 15px; margin: 6px 0 0; }
.warn-text { color: var(--warn); }

/* ---------- Nút ---------- */
.btn {
  border: 1.5px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px 16px;
  min-height: 48px;
  font-weight: 600;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.pay { background: var(--pay); border-color: var(--pay); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.big { min-height: 56px; font-size: 18px; }
.btn.small { min-height: 40px; padding: 6px 12px; font-size: 15px; }
.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 15px; padding: 8px 6px; }
.link-btn.danger { color: var(--muted); }
.icon-btn { border: 1.5px solid var(--line); background: var(--card); font-size: 20px; font-weight: 700; color: var(--accent); min-width: 48px; height: 44px; border-radius: 10px; padding: 0 8px; white-space: nowrap; flex: none; }
.icon-btn.small { min-width: 40px; height: 40px; font-size: 17px; border-color: transparent; }

/* ---------- Đăng nhập ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-box {
  background: var(--card); border-radius: 24px; box-shadow: var(--shadow);
  padding: 32px; width: min(380px, 100%); text-align: center; display: grid; gap: 12px;
}
.login-logo { font-size: 56px; }
.login-box h1 { margin: 0; font-size: 26px; }
.login-box p { margin: 0; }
.login-box input {
  text-align: center; font-size: 28px; letter-spacing: .3em; padding: 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg);
}

/* ---------- Thanh trên ---------- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 20px; white-space: nowrap; }
.tabs { display: flex; gap: 6px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
.tab {
  border: 0; background: transparent; padding: 10px 16px; border-radius: 999px;
  font-weight: 600; color: var(--muted); white-space: nowrap; min-height: 44px;
}
.tab.active { background: var(--ink); color: var(--ink-inv); }
.count { background: var(--late); color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 14px; margin-left: 4px; }
.net { font-size: 13px; font-weight: 600; }
.reload-btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; min-width: 56px; height: 48px; padding: 2px 8px; flex: none;
}
.reload-icon { font-size: 22px; font-weight: 700; }
.ver { font-size: 9px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.net.ok::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.net.bad { color: #fff; background: var(--late); padding: 4px 10px; border-radius: 999px; }

main { padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.active { display: block; }

/* ---------- Sơ đồ bàn ---------- */
.tables-layout { display: grid; grid-template-columns: 1fr minmax(330px, 38%); gap: 16px; align-items: start; }
.table-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tcard {
  text-align: left; border: 2px solid var(--line); background: var(--card);
  border-radius: var(--radius); padding: 14px; min-height: 132px;
  display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow);
}
.tcard.empty { background: transparent; box-shadow: none; border-style: dashed; }
.tcard.empty .tstatus { color: var(--muted); }
.tcard.waiting { border-color: var(--accent); }
.tcard.served { border-color: var(--ok); background: var(--ok-soft); }
.tcard.sel { outline: 4px solid var(--ink); outline-offset: 2px; }
.tcard-top { display: flex; justify-content: space-between; align-items: center; }
.tname { font-size: 22px; font-weight: 800; }
.dot-note { background: var(--note); border-radius: 8px; padding: 0 6px; font-size: 15px; }
.tstatus { font-weight: 600; font-size: 15px; }
.tmoney { font-size: 18px; font-weight: 700; margin-top: auto; }
.tmoney small { color: var(--warn); }
.twait { font-weight: 700; font-size: 15px; border-radius: 8px; padding: 2px 8px; align-self: flex-start; white-space: nowrap; }
.twait.muted { padding-left: 0; font-weight: 600; }
.w-ok { background: var(--ok-soft); color: var(--ok); }
.w-warn { background: var(--warn-soft); color: var(--warn); }
.w-late { background: var(--late-soft); color: var(--late); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .w-late { animation: none; } }

/* ---------- Chi tiết bàn ---------- */
.table-detail {
  position: sticky; top: 76px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px);
  overflow: hidden;
}
.empty-detail { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty-detail.small { padding: 24px 0; }
.detail-head { display: flex; align-items: baseline; gap: 10px; padding: 16px 16px 8px; flex-wrap: wrap; }
.detail-head h2 { margin: 0; font-size: 24px; }
.back-btn { display: none; }
.detail-scroll { overflow-y: auto; padding: 0 16px; flex: 1; -webkit-overflow-scrolling: touch; }
.detail-foot { border-top: 1px solid var(--line); padding: 12px 16px 16px; }
.sum { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; }
.sum b { font-size: 26px; }
.foot-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.foot-btns { flex-wrap: nowrap; }
.foot-btns .btn { flex: 1; padding: 8px 10px; font-size: 17px; }
.foot-btns .btn.primary { flex: 1.6; }

.order { border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; margin-bottom: 10px; }
.order-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; font-weight: 600; color: var(--muted); }
.spacer { flex: 1; }
.ok-badge { color: var(--ok); font-weight: 700; }
.order-note { background: var(--note); border-radius: 10px; padding: 6px 10px; margin: 6px 0; font-weight: 600; }

.line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px dashed var(--line); }
.order-head + .line, .order-note + .line, .qhead + .line { border-top: 0; }
.line-main { flex: 1; min-width: 0; }
.line-name { font-size: 18px; font-weight: 600; }
.qty { color: var(--accent); }
.line-opts { color: var(--muted); font-size: 15px; }
.line-note { background: var(--note); display: inline-block; border-radius: 8px; padding: 1px 8px; font-size: 15px; margin-top: 2px; }
.line-price { font-weight: 600; white-space: nowrap; font-size: 15px; }
.line.done .line-name, .line.done .line-opts { color: var(--muted); }
.line.cancelled { opacity: .45; }
.line.cancelled .line-name { text-decoration: line-through; }
.tick {
  width: 44px; height: 44px; flex: none; border-radius: 12px;
  border: 2px solid var(--line); background: var(--card); font-size: 22px; font-weight: 800; color: #fff;
}
.tick.on { background: var(--ok); border-color: var(--ok); }
.tick.off { display: grid; place-items: center; color: var(--muted); border-style: dashed; }

.lvl { display: inline-block; font-size: 14px; font-weight: 800; padding: 1px 8px; border-radius: 6px; background: var(--lvl-bg); color: var(--lvl-ink); vertical-align: 2px; font-variant-numeric: tabular-nums; }
.lvl-0 { background: var(--lvl0-bg); color: var(--lvl0-ink); }
.lvl-3, .lvl-4 { background: var(--lvl3-bg); color: var(--lvl-ink); }
.lvl-5, .lvl-6, .lvl-7 { background: var(--danger); color: #fff; }

/* ---------- Hàng chờ ---------- */
.queue { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; align-items: start; }
.qcard { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; border-top: 6px solid var(--ok); }
.qcard.w-warn { border-top-color: var(--warn); background: var(--card); color: inherit; }
.qcard.w-late { border-top-color: var(--late); background: var(--card); color: inherit; animation: none; }
.qcard.w-ok { background: var(--card); color: inherit; }
.qhead { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.qtable { font-size: 24px; font-weight: 800; }
.qcard .btn { width: 100%; margin-top: 8px; }

/* ---------- Đã thu ---------- */
.today-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.today-sum { text-align: center; display: grid; }
.today-sum b { font-size: 32px; }
.today-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 16px; }
.today-row { display: grid; grid-template-columns: 56px 70px 1fr auto auto 44px; cursor: pointer; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line); align-items: center; }
.del-row { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: transparent; font-size: 18px; opacity: .7; }
.del-row:active { opacity: 1; background: var(--surface-2); }
.today-row:first-child { border-top: 0; }
.today-items { color: var(--muted); font-size: 15px; }

/* ---------- Sửa thực đơn ---------- */
.menu-admin-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.hint { color: var(--muted); margin: 0; }
.cat-title { margin: 20px 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.madmin-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.mrow {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-align: left;
  border: 0; border-top: 1px solid var(--line); background: none; padding: 12px 16px;
}
.mrow:first-child { border-top: 0; }
.mname { font-weight: 700; }
.mopts { grid-column: 1; color: var(--muted); font-size: 14px; }
.mprice { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-weight: 600; }
.hidden-item { opacity: .5; }

/* ---------- Khung phủ ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--scrim); }
.overlay.center { display: grid; place-items: center; padding: 16px; z-index: 30; }
#confirmBox { z-index: 40; }
.sheet {
  background: var(--card); border-radius: 20px; padding: 20px; width: min(560px, 100%);
  max-height: calc(100dvh - 32px); overflow-y: auto; box-shadow: 0 20px 50px rgba(0, 0, 0, .2);
}
.sheet.small { width: min(440px, 100%); }
.sheet h2 { margin: 0 0 12px; font-size: 22px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.sheet-actions .btn { min-width: 120px; }
.full { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; }

.field { display: grid; gap: 4px; margin: 10px 0; flex: 1; }
.field > span { font-size: 14px; font-weight: 600; color: var(--muted); }
.field input, .field textarea {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--bg); min-height: 48px; width: 100%;
}
.field-row { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.check { display: flex; gap: 8px; align-items: center; min-height: 48px; margin: 10px 0; }
.check input { width: 22px; height: 22px; }

.chips { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.chips legend { font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 6px; padding: 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; justify-content: center; min-width: 56px; min-height: 52px;
  padding: 8px 16px; border: 2px solid var(--line); border-radius: 12px; font-weight: 700; font-size: 18px; background: var(--card);
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.chips.levels .chip span { min-width: 60px; font-size: 22px; }

.qty-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-weight: 600; }
.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: 52px; height: 52px; border: 0; background: var(--bg); font-size: 26px; font-weight: 700; }
.stepper b { min-width: 44px; text-align: center; font-size: 20px; }
.stepper.small button { width: 44px; height: 44px; font-size: 22px; }
.stepper.small b { min-width: 32px; font-size: 18px; }

.choices { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.btn.choice { display: grid; min-height: 64px; font-size: 18px; }
.btn.choice small { font-weight: 500; font-size: 12px; color: var(--warn); }
.bill { border: 1px solid var(--line); border-radius: 12px; padding: 4px 12px; }
.bill-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 15px; }
.bill-row:first-child { border-top: 0; }
.bill-row.total { font-size: 20px; font-weight: 800; border-top: 1.5px solid var(--ink); }

/* ---------- Gọi món ---------- */
.composer { position: absolute; inset: 0; background: var(--bg); display: flex; flex-direction: column; }
.composer-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; border-bottom: 1px solid var(--line);
}
.composer-head .btn { justify-self: start; }
.composer-head h2 { margin: 0; font-size: 20px; }
.composer-body { flex: 1; display: grid; grid-template-columns: 1fr 360px; min-height: 0; }
.picker { overflow-y: auto; padding: 12px 16px; -webkit-overflow-scrolling: touch; }
.cat-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.cat { border: 2px solid var(--line); background: var(--card); border-radius: 999px; padding: 10px 18px; font-weight: 700; min-height: 48px; }
.cat.active { background: var(--ink); color: var(--ink-inv); border-color: var(--ink); }
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.item {
  position: relative; text-align: left; background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); padding: 14px; min-height: 110px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow);
}
.item:active { border-color: var(--accent); }
.item-name { font-weight: 800; font-size: 19px; }
.item-price { color: var(--accent); font-weight: 700; margin-top: auto; }
.item-hint { font-size: 13px; color: var(--muted); }
.badge { position: absolute; top: -8px; right: -8px; background: var(--accent); color: #fff; border-radius: 999px; min-width: 30px; height: 30px; display: grid; place-items: center; font-weight: 800; border: 3px solid var(--bg); }
.cart {
  border-left: 1px solid var(--line); background: var(--card); padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; min-height: 0;
}
.cart h3 { margin: 4px 0 8px; }
.cart .field { flex: none; }
.cart .field textarea { resize: none; }
.cart-lines { flex: 1; overflow-y: auto; min-height: 60px; }
.cline { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line); }
.cline:first-child { border-top: 0; }
.cline-main { flex: 1; min-width: 0; }
.cart-total { display: flex; justify-content: space-between; font-size: 18px; margin: 4px 0 10px; }
.cart-total b { font-size: 22px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--ink-inv); padding: 12px 20px; border-radius: 999px; z-index: 50; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: calc(100% - 32px); text-align: center;
}
.toast.error { background: var(--late); }


/* ---------- Thứ tự ưu tiên ---------- */
.rank { background: var(--ink); color: var(--ink-inv); font-weight: 800; border-radius: 6px; padding: 2px 8px; font-size: 17px; font-family: var(--mono); }
.rank.small { font-size: 14px; padding: 1px 7px; border-radius: 8px; }
.twait { font-variant-numeric: tabular-nums; }

/* ---------- Khách / nhóm trong bàn ---------- */
.guest { border: 2px solid var(--line); border-radius: 16px; padding: 10px; margin-bottom: 12px; background: var(--surface-2); }
.guest-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 18px; }
.guest-name { background: var(--accent-soft); color: var(--accent-strong); border-radius: 8px; padding: 2px 10px; }
.guest-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.guest-btns .btn { flex: 1; }
.guest-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.gchip { border: 2px solid var(--line); background: var(--card); border-radius: 12px; padding: 8px 14px; min-height: 48px; font-weight: 700; }
.gchip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.gchip.add { border-style: dashed; color: var(--accent); }
.bill-guest { font-weight: 800; margin-top: 8px; color: var(--accent-strong); }

/* ---------- Màu từng tốp ---------- */
.gc0 { --g: #D9480F; --gs: #FFE8D9; }
.gc1 { --g: #1C7ED6; --gs: #E0EFFF; }
.gc2 { --g: #2F9E44; --gs: #E3F6E7; }
.gc3 { --g: #9C36B5; --gs: #F6E6FA; }
.gc4 { --g: #E67700; --gs: #FFF1D6; }
.gc5 { --g: #0C8599; --gs: #DDF5F8; }
.guest[class*="gc"] { border-color: var(--g); border-left-width: 8px; }
.guest[class*="gc"] .guest-name { background: var(--g); color: #fff; }
.gtag { display: inline-block; background: var(--g, var(--accent)); color: #fff; border-radius: 8px; padding: 1px 8px; font-weight: 800; font-size: 14px; }
.gchip[class*="gc"] { border-color: var(--g); color: var(--g); }
.gchip[class*="gc"].active { background: var(--g); color: #fff; }
.gdots { display: flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; }
.gdots span { margin-left: 3px; }
.gdot { width: 11px; height: 11px; border-radius: 50%; background: var(--g); display: inline-block; }
.paypicks { display: grid; gap: 8px; }
.btn.paypick { display: grid; gap: 4px; text-align: left; padding: 12px 14px; min-height: 64px; border-width: 2px; }
.btn.paypick[class*="gc"] { border-color: var(--g); background: color-mix(in srgb, var(--g) 14%, var(--card)); }
.btn.paypick.all { border-style: dashed; }
.paypick-top { display: flex; justify-content: space-between; align-items: center; font-size: 18px; }
.paypick small { color: var(--muted); font-weight: 500; }

/* ---------- Sửa món ---------- */
.cline-main { border: 0; background: none; text-align: left; padding: 4px 0; flex: 1; min-width: 0; }
.edit-hint { font-size: 13px; color: var(--accent); font-weight: 600; }
.choices.wide { grid-template-columns: 1fr 1fr; }
.btn.danger-outline { color: var(--late); border-color: var(--late-soft); }

/* ---------- Hàng chờ: theo món ---------- */
.seg { display: inline-flex; background: var(--line); border-radius: 12px; padding: 4px; margin-bottom: 12px; gap: 4px; }
.seg-btn { border: 0; background: transparent; border-radius: 9px; padding: 8px 16px; min-height: 44px; font-weight: 700; color: var(--muted); }
.seg-btn.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.queue.dish { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.qcount { color: var(--accent); }
.mix { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.mix-chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 15px; }
.part { border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 6px; }
.part-who { font-size: 15px; }
.part .line { border-top: 0; padding: 4px 0; }
.part-onote { background: var(--note); border-radius: 8px; padding: 2px 8px; font-size: 14px; display: inline-block; }


/* ---------- Sơ đồ quán ---------- */
.tables-left { min-width: 0; }
.floor-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; min-height: 48px; }
.seg.small { margin-bottom: 0; }
.floor {
  position: relative; width: 100%; aspect-ratio: 4 / 3; max-height: calc(100dvh - 160px);
  background: var(--floor); background-image: radial-gradient(var(--floor-dot) 1px, transparent 1px); background-size: 18px 18px; border-radius: 16px; border: 1.5px solid var(--line); overflow: hidden;
  touch-action: manipulation;
}
.floor .wall { position: absolute; left: 0; right: 0; height: 6px; background: var(--wall); }
.floor .wall.top { top: 0; }
.floor .wall.bottom { bottom: 0; }
.floor .tcard, .floor .counter { position: absolute; transform: translate(-50%, -50%); }
.floor .tcard { width: 17.5%; min-height: 0; height: 30%; padding: 8px; gap: 4px; overflow: hidden; }
.floor .tcard.empty { background: var(--empty-bg); }
.floor .tcard .tname { font-size: 24px; }
.floor .tcard .tstatus { font-size: 13px; line-height: 1.25; }
.floor .tcard .tmoney { font-size: 14px; }
.floor .tcard .twait { font-size: 12px; padding: 1px 5px; letter-spacing: -.05em; max-width: 100%; overflow: hidden; white-space: nowrap; box-sizing: border-box; }
.floor .tcard .rank { font-size: 15px; padding: 1px 7px; }
.floor .tcard.round { width: auto; height: 25%; aspect-ratio: 1; border-radius: 50%; align-items: center; justify-content: center; text-align: center; padding: 4px; gap: 2px; }
.floor .tcard.round .tfoot { margin-top: 0; justify-content: center; }
.floor .tcard.round .tcard-top { flex-direction: row; gap: 4px; }
.floor .tcard.round .twait { align-self: center; }
.floor .tcard.round .tmoney { margin-top: 0; }
.floor .counter {
  width: 28%; height: 26%; display: grid; place-items: center; border-radius: 14px;
  background: repeating-linear-gradient(45deg, var(--counter-a), var(--counter-a) 10px, var(--counter-b) 10px, var(--counter-b) 20px);
  color: var(--counter-ink); font-weight: 800; font-size: 15px; letter-spacing: .08em; text-transform: uppercase; border: 1.5px solid var(--counter-line);
}
.floor.editing { outline: 3px dashed var(--accent); outline-offset: 4px; touch-action: none; }
.floor.editing .tcard, .floor.editing .counter { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; box-shadow: 0 6px 18px rgba(217, 72, 15, .25); }
.del-badge {
  position: absolute; top: 4px; right: 4px; z-index: 2; width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; background: var(--late); color: #fff; font-size: 18px; font-weight: 800;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25); cursor: pointer;
}
.floor .tcard.round .del-badge { top: 2px; right: 2px; }
.floor.editing .tcard .rank { visibility: hidden; }
.floor .dragging { z-index: 5; cursor: grabbing; opacity: .9; transform: translate(-50%, -50%) scale(1.06); }


/* ---------- Gọn hơn ---------- */
.brand span { display: none; }
.tfoot { display: flex; align-items: center; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.tfoot .tmoney { margin-top: 0; }
.gdots { display: inline-flex; gap: 3px; }
.sum small { font-size: 13px; font-weight: 600; }
.qvariant { margin: -2px 0 6px; font-weight: 600; }
.part { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 8px; align-items: center; }
.part-who { display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.part-lines { min-width: 0; }
.part-lines .line + .line { border-top: 1px dashed var(--line); }
.part-time { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.line-name .line-opts { font-size: 15px; font-weight: 500; }
.order-head { min-height: 44px; }

/* ---------- iPad dọc / màn nhỏ ---------- */
@media (max-width: 900px) {
  .tables-layout { grid-template-columns: 1fr; }
  .floor { max-height: none; }
  .table-detail { display: none; }
  body.detail-open .table-detail {
    display: flex; position: fixed; inset: 0; top: 0; z-index: 10; border-radius: 0; max-height: none;
    padding-top: env(safe-area-inset-top);
  }
  .back-btn { display: inline-flex; }
  .table-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .composer-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .cart { border-left: 0; border-top: 1px solid var(--line); max-height: 45vh; }
  /* Điện thoại / iPad dọc: cả khung đơn cuộn được, Tạm tính + Gửi đơn luôn dính đáy */
  .cart { max-height: 52vh; max-height: 52dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 0; }
  .cart .cart-lines { flex: none; overflow: visible; min-height: 0; }
  .cart-foot { position: sticky; bottom: 0; z-index: 2; background: var(--card); margin: 0 -16px; padding: 6px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
  .cart-foot .cart-total { margin: 0 0 6px; }
  .cart-foot #sendOrder { width: 100%; }
}
@media (max-width: 560px) {
  .queue.dish { grid-template-columns: 1fr; }
  .brand span { display: none; }
  .tab { padding: 8px 12px; }
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .topbar .tabs { order: 9; flex: 1 1 100%; }
  .today-row { grid-template-columns: 48px 56px 1fr 44px; }
  .today-row .pay-tag { grid-column: 2; grid-row: 2; justify-self: start; }
  .today-row .today-money { grid-column: 3; grid-row: 2; }
  .today-row .del-row { grid-column: 4; grid-row: 1 / span 2; }
}
.foot-btns .btn { white-space: nowrap; font-size: 16px; }
.order-head .twait, .qhead .twait { align-self: center; }
.dish-var { font-weight: 700; font-size: 17px; }

/* Thanh cuộn tự vẽ */
.table-detail, .cart, .composer-body { position: relative; }
.sbar { position: absolute; right: 2px; width: 6px; border-radius: 3px; background: var(--sbar-track); z-index: 3; pointer-events: none; }
.sbar.fixed { position: fixed; right: 3px; z-index: 4; }
.sbar i { display: block; width: 100%; border-radius: 3px; background: var(--sbar-thumb); }
.detail-scroll, #cartLines, .picker { scrollbar-width: none; }
.detail-scroll::-webkit-scrollbar, #cartLines::-webkit-scrollbar, .picker::-webkit-scrollbar { display: none; }

/* ---------- Chờ món theo món: gọn, nhiều đơn một màn ---------- */
/* Lưới 2 cột: khung cùng hàng thẳng đầu, bằng đáy (Max 30/11: bỏ kiểu so le). */
.queue.dish { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.queue.dish .qcard { padding: 10px 12px; display: block; width: 100%; min-width: 0; }
.qcol { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.qcol-empty { color: var(--muted); font-size: 14px; padding: 14px; border: 1.5px dashed var(--line); border-radius: var(--radius); text-align: center; }
.qcol-gap { height: 6px; }
.qcol-h { font-size: 15px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 4px; }
.queue.dish .qhead { gap: 8px; margin-bottom: 2px; }
.queue.dish .qtable { font-size: 21px; }
.queue.dish .qhead .btn { width: auto; margin: 0; min-height: 40px; }
.queue.dish .qtable, .queue.dish .qhead .btn { white-space: nowrap; }
@media (max-width: 900px) { .queue.dish { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .qvar .v-line .v-txt, .queue.dish .qtable { white-space: normal; } .v-line { flex-wrap: wrap; } }

/* ---------- Kiểu "tech": số đều, viền mảnh, góc vuông hơn ---------- */
.twait, .qtime, .tmoney, .sum b, .line-price, .cart-total b, .today-sum b, .ver, .part-time, .qcount, .qty, .count, .badge, #optQty, .stepper b, .mprice, .bill-row span:last-child {
  font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}
.btn { border-radius: 10px; }
.tcard, .item, .qcard, .order, .guest, .madmin-list, .today-list, .sheet, .table-detail { border-radius: var(--radius); }
.topbar { backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px); background: color-mix(in srgb, var(--bg) 88%, transparent); }
.cat-title, .chips legend, .field > span { text-transform: uppercase; letter-spacing: .06em; font-size: 12px; }
:root[data-theme="dark"] .tcard, :root[data-theme="dark"] .item, :root[data-theme="dark"] .qcard, :root[data-theme="dark"] .table-detail,
:root[data-theme="dark"] .madmin-list, :root[data-theme="dark"] .today-list { border: 1px solid var(--line); }
:root[data-theme="dark"] .tcard.waiting { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 18px rgba(255, 106, 61, .18); }
:root[data-theme="dark"] .tcard.served { border-color: var(--ok); }
:root[data-theme="dark"] .tcard.empty { border-style: dashed; }
:root[data-theme="dark"] .qcard { border-top-width: 3px; }
:root[data-theme="dark"] .w-late { box-shadow: 0 0 0 1px rgba(248, 113, 113, .35); }
:root[data-theme="dark"] .chip span, :root[data-theme="dark"] .gchip, :root[data-theme="dark"] .cat, :root[data-theme="dark"] .item { background: var(--card); }
:root[data-theme="dark"] .field input, :root[data-theme="dark"] .field textarea, :root[data-theme="dark"] .login-box input { background: var(--surface-2); }
:root[data-theme="dark"] .stepper button { background: var(--surface-2); }
:root[data-theme="dark"] .seg { background: var(--surface-2); border: 1px solid var(--line); }
:root[data-theme="dark"] .seg-btn.active { background: var(--card); }
.theme-btn { border: 1.5px solid var(--line); background: var(--card); border-radius: 10px; width: 48px; height: 48px; font-size: 20px; flex: none; }

/* ---------- Chờ món theo món: cột cố định, ô tích cuối dòng ---------- */
.qrow {
  display: grid; grid-template-columns: 96px minmax(0, 1fr) 44px; gap: 8px;
  align-items: center; min-height: 50px; padding: 4px 0; border-top: 1px solid var(--line);
}
.qrow.same { border-top: 1px dashed var(--line); }
.qrow .tick { width: 44px; height: 44px; justify-self: end; }
.qwho { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; font-size: 15px; line-height: 1.15; min-width: 0; }
.qwho .who-top { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.qwho .gtag { font-size: 11px; padding: 0 6px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qvar { font-size: 17px; font-weight: 700; min-width: 0; }
.qvar .line-opts { font-weight: 500; font-size: 14px; margin-left: 4px; }
.qvar .line-note { display: block; width: fit-content; font-size: 13px; margin-top: 2px; font-weight: 500; }
.qlvl { justify-self: start; }
.qlvl .lvl { font-size: 15px; padding: 3px 8px; vertical-align: 0; }
.qtime { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }

/* Ô tích cuối dòng: viền màu nhấn cho dễ thấy */
.qrow .tick { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
:root[data-theme="dark"] .cat.active { background: var(--ink); color: var(--ink-inv); border-color: var(--ink); }

/* ---------- Mang về ---------- */
:root { --ta: #6D4AFF; --ta-ink: #fff; }
:root[data-theme="dark"] { --ta: #8B6CFF; }
.ta-badge { display: inline-block; background: var(--ta); color: var(--ta-ink); font-weight: 800; font-size: 12px; line-height: 1.5; padding: 0 7px; border-radius: 6px; white-space: nowrap; }
.qwho .ta-badge { font-size: 11px; }
.qrow.ta { box-shadow: inset 3px 0 0 var(--ta); padding-left: 6px; }
.dot-ta { font-size: 15px; }
.takeaway-toggle { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; margin: 8px 0; padding: 0 14px; border: 2px dashed var(--line); border-radius: 12px; background: transparent; color: var(--ink); font-weight: 800; font-size: 16px; }
.takeaway-toggle .ta-box { width: 22px; height: 22px; border: 2px solid var(--muted); border-radius: 6px; flex: none; display: grid; place-items: center; font-size: 15px; }
.takeaway-toggle.on { border-style: solid; border-color: var(--ta); background: color-mix(in srgb, var(--ta) 16%, transparent); }
.takeaway-toggle.on .ta-box { background: var(--ta); border-color: var(--ta); color: #fff; }
.takeaway-toggle.on .ta-box::after { content: '✓'; }
.ta-strip { background: var(--ta); color: var(--ta-ink); font-weight: 800; font-size: 14px; border-radius: 8px; padding: 3px 10px; margin: 4px 0 6px; width: fit-content; }

/* ---------- Tiền mặt / chuyển khoản, chi tiết đơn đã thu ---------- */
:root { --cash: #15803D; --transfer: #1D4ED8; }
:root[data-theme="dark"] { --cash: #22C55E; --transfer: #60A5FA; }
.pay-tag { font-size: 12px; font-weight: 800; padding: 2px 7px; border-radius: 6px; border: 1.5px solid currentColor; white-space: nowrap; }
.pay-tag.pay-cash { color: var(--cash); }
.pay-tag.pay-transfer { color: var(--transfer); }
.pay-tag.pay-none { color: var(--muted); border-style: dashed; }
.today-row:active { background: var(--surface-2); }
.pay-split { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.pay-split > div { flex: 1 1 140px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.pay-split b { font-family: var(--mono); font-size: 18px; }
.paid-facts { display: grid; gap: 4px; margin-bottom: 10px; }
.paid-facts > div { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; }
.bill-row.cancelled > span:first-child { text-decoration: line-through; opacity: .6; }
.pay-ask { margin: 14px 0 6px; font-weight: 700; }
.pay-choose { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.pay-choose .btn.choice { flex: 1 1 140px; min-height: 52px; font-size: 16px; }
.pay-choose.big .btn.choice { min-height: 64px; font-size: 18px; }
.pay-choose .btn.choice.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pay-choose .btn.pay-cash { border: 2px solid var(--cash); }
.pay-choose .btn.pay-transfer { border: 2px solid var(--transfer); }
.pay-choose > span { flex-basis: 100%; }
/* Bàn Mang về */
.tcard.ta-table { border-color: var(--ta); }
.tcard.ta-table.empty { border-style: dashed; border-color: color-mix(in srgb, var(--ta) 60%, var(--line)); }
.tcard.ta-table .tname { font-size: 18px; white-space: nowrap; }
.floor .tcard.ta-table { height: 27%; width: 21%; }
.floor .tcard.ta-table .tname { font-size: 14px; min-width: 0; overflow: hidden; text-overflow: clip; }
:root[data-theme="dark"] .tcard.ta-table.waiting { border-color: var(--ta); box-shadow: 0 0 0 1px var(--ta), 0 0 18px color-mix(in srgb, var(--ta) 30%, transparent); }

/* ---------- iPad ngang / màn rộng: sơ đồ dùng hết chiều cao màn hình, ô bàn to theo sơ đồ ---------- */
@media (min-width: 901px) {
  .tables-layout { grid-template-columns: 1fr minmax(330px, 36%); }
  .floor { aspect-ratio: auto; height: calc(100dvh - 162px - env(safe-area-inset-bottom)); max-height: none; min-height: 380px; container-type: size; }
  .floor .tcard { padding: clamp(6px, 1.6cqh, 14px); width: 19%; }
  .floor .tcard.ta-table { width: 22%; }
  .floor .tcard .tname { font-size: clamp(20px, 6cqh, 38px); line-height: 1.05; }
  .floor .tcard .tstatus { font-size: clamp(13px, 2.6cqh, 18px); }
  .floor .tcard .tmoney { font-size: clamp(14px, 2.8cqh, 20px); }
  .floor .tcard .twait { font-size: clamp(11px, 2.1cqh, 15px); }
  .floor .tcard .rank { font-size: clamp(15px, 3cqh, 20px); }
  .floor .tcard.ta-table .tname { font-size: clamp(13px, 2.8cqh, 18px); }
  .floor .tcard.round { height: auto; width: min(17.5cqw, 25cqh); }
  .floor .counter { font-size: clamp(14px, 2.8cqh, 20px); }
}

/* ---------- Tổng quan (khung phải khi chưa chọn bàn) ---------- */
.ov-title { margin: 6px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ov-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; width: 100%; min-height: 54px; padding: 6px 4px; border: 0; border-top: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; font-size: 17px; }
.ov-row:first-of-type { border-top: 0; }
.ov-row:active { background: var(--surface-2); }
.ov-count { color: var(--muted); font-weight: 600; font-size: 15px; }
.ov-hint { margin: 16px 0; font-size: 14px; }

/* ---------- 3 kiểu bố cục tab Bàn cho iPad ngang ---------- */
@media (min-width: 901px) {
  .lay-a .table-detail, .lay-b .table-detail { height: calc(100dvh - 98px - env(safe-area-inset-bottom)); top: 0; max-height: none; }
  /* B: lưới ô to, không sơ đồ */
  .lay-b #floorBar { display: none; }
  .lay-b .tables-layout { grid-template-columns: minmax(0, 1fr) minmax(330px, 36%); }
  .lay-b .table-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: calc((100dvh - 104px - 24px - env(safe-area-inset-bottom)) / 3); gap: 12px; }
  .lay-b .table-grid .tcard { min-height: 0; }
  .lay-b .table-grid .tname { font-size: 26px; white-space: nowrap; }
  .lay-b .table-grid .ta-table .tname { font-size: 17px; }
  .lay-b .table-grid .tstatus, .lay-b .table-grid .twait { font-size: 16px; }
  /* C: sơ đồ toàn màn, chi tiết trượt ra bên phải */
  .lay-c .tables-layout { grid-template-columns: 1fr; }
  .lay-c .table-detail { display: none; }
  .lay-c.detail-open .table-detail {
    display: flex; position: fixed; top: 72px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: min(440px, 44vw);
    z-index: 10; max-height: none; box-shadow: 0 12px 40px rgba(0, 0, 0, .28); border: 1px solid var(--line);
  }
  .lay-c .back-btn { display: inline-flex; }
}

/* Món thêm có số lượng */
.xchip { display: inline-flex; align-items: stretch; border: 2px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; }
.xchip .xadd { min-height: 52px; padding: 8px 14px; border: 0; background: transparent; color: var(--ink); font-weight: 700; font-size: 17px; }
.xchip .xminus { min-width: 48px; border: 0; border-left: 2px solid rgba(255, 255, 255, .35); background: transparent; color: inherit; font-size: 24px; font-weight: 800; }
.xchip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.xchip.on .xadd { color: #fff; }
.xchip .xq { font-family: var(--mono); background: rgba(0, 0, 0, .22); border-radius: 6px; padding: 0 6px; margin-left: 4px; }

/* Nút Mang về trong menu ⋯ của khách */
.choices .span2 { grid-column: 1 / -1; }
.choices .ta-pick { border-color: var(--ta); color: var(--ta); }

/* Bảng chọn món: tiêu đề + ghi chú + số lượng + nút Huỷ/Thêm luôn hiện, phần Loại / Cấp / Món thêm cuộn riêng */
#optForm { display: flex; flex-direction: column; overflow: hidden; width: min(940px, 100%); }
#optBody { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; margin: 0 -8px; padding: 0 8px; }
#optBody:not(:has(> *)) { display: none; }
#optForm h2, #optForm .field, #optForm .qty-row, #optForm .sheet-actions { flex: 0 0 auto; }
#optForm .field { margin: 8px 0 4px; }
#optForm .sheet-actions { margin-top: 10px; }
.xchip .xadd { min-height: 48px; font-size: 16px; }
#optForm .chip span { min-height: 48px; font-size: 17px; padding: 6px 14px; }
#optForm .chips { margin-bottom: 8px; }
#optBody.more { box-shadow: inset 0 -16px 14px -12px rgba(0, 0, 0, .5); }
.opt-more { text-align: center; font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.opt-more[hidden] { display: none; }
#optError:empty { display: none; }

/* ================= Sổ sách ================= */
:root { --cost: #B08968; }
:root[data-theme="dark"] { --cost: #A8927C; }
#view-today { max-width: 1100px; margin: 0 auto; padding-bottom: 96px; }
.books-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.books-top .seg { margin: 0; }
.books-actions { display: flex; gap: 8px; margin-left: auto; }
.books-nav { display: grid; grid-template-columns: 52px 1fr 52px; gap: 8px; align-items: center; margin: 10px 0 12px; }
.books-nav .btn { min-height: 52px; font-size: 24px; padding: 0; }
.books-lbl { text-align: center; display: grid; }
.books-lbl small { color: var(--muted); font-size: 14px; }
.books-lbl b { font-family: var(--mono); font-size: 30px; letter-spacing: -.02em; }
.books-loading { opacity: .55; transition: opacity .15s; }
.pos { color: var(--ok); }
.neg { color: var(--late); }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0 10px; }
.trow-time { font-family: var(--mono); font-size: 14px; line-height: 1.25; white-space: nowrap; }
.trow-time small { display: block; color: var(--muted); font-size: 12px; }
#view-today .today-row { grid-template-columns: 92px 84px 1fr auto auto 44px; }
.sum-row { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; min-height: 48px; }
.sum-row:first-child { border-top: 0; }
.sum-row:active { background: var(--surface-2); }
.today-money { font-family: var(--mono); white-space: nowrap; }

/* Chi phí */
.egroups { padding: 0; overflow: hidden; }
.egrp + .egrp { border-top: 1px solid var(--line); }
.egh { display: grid; grid-template-columns: 1fr auto 22px; gap: 10px; align-items: center; width: 100%; border: 0; background: none; padding: 14px 16px; min-height: 56px; text-align: left; font-weight: 700; font-size: 17px; color: var(--ink); }
.egh .muted { font-weight: 500; font-size: 14px; }
.ear { color: var(--muted); transition: transform .15s; text-align: center; }
.egrp.open .ear { transform: rotate(90deg); }
.egsub { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; font-size: 13px; }
.egsub span { border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; color: var(--muted); background: var(--surface-2); }
.erow { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; border: 0; border-top: 1px solid var(--line); background: var(--surface-2); padding: 10px 16px; text-align: left; color: var(--ink); }
.erow .en { font-weight: 600; }
.erow small { color: var(--muted); font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.erow .pay-tag { justify-self: end; }
.emore { width: 100%; min-height: 44px; border: 0; border-top: 1px solid var(--line); background: var(--surface-2); color: var(--accent); font-weight: 700; }
.books-fab { display: none; }
@media (max-width: 700px) {
  .books-add-top { display: none; }
  .books-fab { display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 40%); }
  .books-fab .btn { width: 100%; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); }
  .books-top .seg { width: 100%; }
  .books-top .seg .seg-btn { flex: 1; padding: 8px 4px; }
  .books-actions { width: 100%; }
  .books-actions .btn { flex: 1; }
  #view-today .today-row { grid-template-columns: 70px 1fr auto 40px; }
  #view-today .today-row > b:not(.today-money) { grid-column: 2; grid-row: 1; }
  #view-today .today-row .today-items { grid-column: 2; grid-row: 2; }
  #view-today .today-row .pay-tag { grid-column: 3; grid-row: 2; justify-self: end; }
  #view-today .today-row .today-money { grid-column: 3; grid-row: 1; }
  #view-today .today-row .trow-time { grid-row: 1 / span 2; }
  #view-today .today-row .del-row { grid-column: 4; grid-row: 1 / span 2; }
}

/* Lãi lỗ */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 8px; }
@media (max-width: 700px) { .kpis { grid-template-columns: 1fr; } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.kpi > span { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.kpi b { display: block; font-family: var(--mono); font-size: 24px; letter-spacing: -.02em; margin: 2px 0; }
.kpi small { color: var(--muted); font-size: 13px; }
.pl-chart { padding: 10px 8px 8px; margin-bottom: 12px; }
.pl-svg { overflow-x: auto; }
.pl-svg svg { display: block; width: 100%; min-width: 320px; height: auto; }
.pl-legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); padding: 4px 8px 0; }
.pl-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.pl-table { width: 100%; border-collapse: collapse; }
.pl-table td { padding: 10px 0; border-top: 1px solid var(--line); }
.pl-table tr:first-child td { border-top: 0; }
.pl-table td:last-child { text-align: right; font-family: var(--mono); font-weight: 700; white-space: nowrap; padding-left: 12px; }
.pl-table tr.sum td { font-weight: 800; font-size: 18px; border-top: 1.5px solid var(--ink); }

/* Khoá bằng mã chủ quán */
.owner-lock { min-height: 60vh; display: grid; place-items: center; text-align: center; }
.owner-lock h2 { margin: 0 0 4px; }
.owner-lock .muted { max-width: 340px; margin: 0 auto; }
.owner-dots { display: flex; gap: 14px; justify-content: center; margin: 18px 0 6px; }
.owner-dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.owner-dots i.on { background: var(--accent); border-color: var(--accent); }
.owner-lock .error { min-height: 22px; }
.owner-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; justify-content: center; }
.owner-pad button { height: 64px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); font-size: 26px; font-family: var(--mono); }
.owner-pad button:active { background: var(--surface-2); }
.owner-pad button.g { border-color: transparent; background: transparent; font-size: 22px; }

/* Bảng thêm / sửa khoản chi */
#bookSheet { z-index: 35; }
.book-sheet { display: flex; flex-direction: column; padding: 0; overflow: hidden; width: min(560px, 100%); }
@media (max-width: 700px) {
  #bookSheet.overlay.center { place-items: end center; padding: 0; }
  .book-sheet { border-radius: 20px 20px 0 0; max-height: 94dvh; padding-bottom: env(safe-area-inset-bottom); }
}
.bs-head { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.bs-head h2 { margin: 0; font-size: 18px; text-align: center; }
.bs-head .btn { color: var(--accent); justify-self: end; }
.bs-body { padding: 10px 16px 6px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
.bs-foot { padding: 10px 16px 14px; border-top: 1px solid var(--line); display: grid; }
.bs-lab { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--muted); margin: 12px 0 6px; }
.bs-lab:first-child { margin-top: 4px; }
.bs-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.bs-chip { border: 2px solid var(--line); border-radius: 12px; min-height: 46px; padding: 0 14px; font-weight: 700; background: var(--card); color: var(--ink); }
.bs-chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.bs-amt { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center; border: 2px solid var(--accent); border-radius: 14px; padding: 4px 6px 4px 14px; background: var(--card); }
.bs-amt input { border: 0; background: transparent; color: var(--ink); font-family: var(--mono); font-size: 30px; font-weight: 800; width: 100%; min-width: 0; padding: 8px 0; outline: none; }
.bs-clr { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); color: var(--muted); font-size: 20px; font-weight: 800; }
.bs-clr[hidden] { display: none; }
.bs-pm { min-height: 44px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--ink); padding: 0 10px; font-weight: 700; font-size: 14px; white-space: nowrap; }
.bs-prev { min-height: 22px; margin: 6px 0 0; font-size: 15px; }
.bs-prev.ok b { color: var(--ok); font-family: var(--mono); }
.bs-date, .bs-inp { border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); min-height: 46px; padding: 0 12px; font-size: 16px; }
.bs-inp { width: 100%; }
.bs-big { font-family: var(--mono); font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 8px; }
.bs-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bs-row2 .btn { min-height: 50px; }

/* ---------- Cài đặt ---------- */
.settings { max-width: 760px; margin: 0 auto; display: grid; gap: 16px; }
.set-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.set-card h2 { margin: 0 0 2px; font-size: 20px; }
.set-card .muted { margin: 0 0 6px; }
.set-card .field-row .field { min-width: 200px; }
.set-card .field input { font-size: 20px; letter-spacing: 2px; }
.set-card .error { min-height: 20px; margin: 4px 0 8px; }
.set-card .btn.primary { min-height: 48px; }
.set-card .hint { margin: 12px 0 0; }
.set-lock { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.set-lock .btn { min-width: 96px; min-height: 48px; }
@media (max-width: 560px) {
  .tab-txt { display: none; }
  .tabs { gap: 0; }
  .topbar .tab { padding: 8px 11px; }
  .set-card { padding: 14px; }
  .set-card .field-row { flex-direction: column; align-items: stretch; gap: 0; }
}
.xr-quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }
.xr-quick .btn { min-height: 44px; }
#confirmText .field input[type=date] { min-height: 48px; font-size: 17px; }

/* ---------- Nhật ký thao tác ---------- */
.log-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.log-btns .btn { min-height: 48px; }
#logOut h3 { margin: 18px 0 6px; font-size: 16px; }
.log-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.log-kpis > div { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.log-kpis span { display: block; font-size: 13px; color: var(--muted); }
.log-kpis b { display: block; font-family: var(--mono); font-size: 20px; }
.log-kpis small { color: var(--muted); }
.log-hours > div { display: grid; grid-template-columns: 40px 1fr 48px; gap: 8px; align-items: center; font-size: 14px; padding: 2px 0; }
.log-hours i { display: block; height: 12px; border-radius: 6px; background: var(--accent); }
.log-hours b, .log-top b { text-align: right; font-family: var(--mono); }
.log-top > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 15px; }
.log-top > div:first-child { border-top: 0; }

/* ---------- Phiếu tạm tính (luôn nền trắng chữ đen để khách chụp rõ) ---------- */
#receipt { z-index: 40; }
.receipt-wrap { width: min(440px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; gap: 10px; }
.receipt-paper { background: #fff; color: #111; border-radius: 14px; padding: 20px 22px; overflow-y: auto; min-height: 0; font-size: 16px; }
.rc-title { text-align: center; font-weight: 800; font-size: 20px; letter-spacing: .08em; }
.rc-meta { text-align: center; margin: 6px 0 12px; padding-bottom: 12px; border-bottom: 1.5px dashed #bbb; }
.rc-meta b { display: block; font-size: 18px; }
.rc-meta span { color: #555; font-size: 14px; }
.rc-line { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px dashed #ddd; }
.rc-line:first-child { border-top: 0; }
.rc-line small { display: block; color: #555; font-size: 13px; }
.rc-line span { font-family: var(--mono); font-weight: 700; white-space: nowrap; }
.rc-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; padding-top: 10px; border-top: 2px solid #111; font-size: 18px; font-weight: 800; }
.rc-total b { font-family: var(--mono); font-size: 26px; }
.rc-split { display: flex; justify-content: space-between; margin-top: 6px; font-size: 16px; }
.rc-split b { font-family: var(--mono); }
.rc-note { text-align: center; color: #666; font-size: 13px; margin: 10px 0 0; }
.receipt-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex: none; }
.rc-stepper { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px; padding: 4px 10px; color: var(--ink); }
.rc-stepper .btn { min-width: 44px; min-height: 44px; font-size: 22px; padding: 0; }
.rc-stepper b { min-width: 24px; text-align: center; font-size: 18px; }
.receipt-bar .btn.primary { min-height: 48px; }
.rc-stepper span, .receipt-bar .btn { white-space: nowrap; }
@media (max-width: 420px) { .rc-stepper { gap: 4px; padding: 4px 6px; } .receipt-bar .btn.primary { padding: 0 14px; } }

/* Loại món 1 dòng; mỗi món gọi thêm 1 dòng riêng bên dưới (Max 30/11) */
.v-line { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Cấp/sốt đứng SAU tên loại (Max 30/11). Tên dài thì cắt tên, cấp luôn thấy. */
.v-line { display: flex !important; align-items: center; gap: 6px; min-width: 0; }
.v-line .v-txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v-line .lvl, .v-line .qty { flex: none; }
.v-sub { font-weight: 500; font-size: .82em; color: var(--muted); }
.x-line { display: block; }
.qvar .line-opts { display: block; margin-left: 0; }

/* Chờ món (Max 30/11): số thứ tự #1 #2 mờ đi. Món thêm giữ kiểu mờ như cũ. */
#queueList .rank { background: transparent; color: var(--muted); border: 1.5px solid var(--line); font-weight: 700; }

/* Chờ món (thử 30/11): ô tích bên trái · món · bàn/mang về/thời gian bên phải. */
.qrow { grid-template-columns: 44px minmax(0, 1fr) 100px; }
.qrow .tick { justify-self: start; }
.qrow .qwho { align-items: flex-end; text-align: right; }
.qrow.ta { box-shadow: inset -3px 0 0 var(--ta); padding-left: 0; padding-right: 6px; }

/* Chi tiết bàn / Theo bàn: cột hẹp nên tên loại được xuống dòng, không cắt chữ (chỉ Chờ món theo món giữ 1 dòng). */
.line .v-line { flex-wrap: wrap; row-gap: 2px; }
.line .v-line .v-txt { white-space: normal; overflow: visible; }

/* Bảng Lãi lỗ: dòng tổng là hàng bảng, không ăn kiểu .sum (flex) của thanh tổng tiền. */
.pl-table tr.sum { display: table-row; }
