/* ============ Dr.Anmytas – Bán hàng ============ */
:root {
  --g9: #0c3a2c; --g8: #114a38; --g7: #176047; --g6: #1f7a5a; --g1: #e4f0ea; --g0: #f1f7f3;
  --gold: #c9a24c; --gold2: #e6cd8f; --gold0: #fbf4e2;
  --bg: #f4f6f4; --card: #fff; --text: #1b2621; --muted: #67756d; --line: #e1e7e3; --line2: #eef2ef;
  --red: #c0392b; --red0: #fdecea; --orange: #d9661f; --orange0: #fdf0e6; --blue: #2563a8; --blue0: #e8f0fa;
  --r: 12px; --r-sm: 8px;
  --sh: 0 1px 2px rgba(12, 40, 30, .06), 0 6px 18px rgba(12, 40, 30, .06);
  --sh-lg: 0 10px 40px rgba(12, 40, 30, .22);
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--g7); text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.strike { text-decoration: line-through; color: var(--muted); }
.red { color: var(--red); }
.green { color: var(--g7); }
.bold { font-weight: 600; }
.hide { display: none !important; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn svg.i { width: 18px; height: 18px; }

/* ---------- Buttons & form ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 500; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--g0); border-color: #cfdcd4; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--g8); border-color: var(--g8); color: #fff; }
.btn.primary:hover { background: var(--g7); }
.btn.gold { background: linear-gradient(180deg, #e2c27a, #c9a24c); border-color: #bf9840; color: #2b2210; }
.btn.danger { color: var(--red); border-color: #efc8c3; }
.btn.danger:hover { background: var(--red0); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--g0); }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 40px; }
.btn.icon.sm { width: 32px; }
.btn.lg { min-height: 48px; font-size: 16px; font-weight: 600; }

.field { display: block; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { border-color: var(--g6); box-shadow: 0 0 0 3px rgba(31, 122, 90, .14); }
.input.num { text-align: right; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--g7); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.search { position: relative; flex: 1; min-width: 160px; }
.search svg.i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search .input { padding-left: 36px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff;
  font-size: 13px; cursor: pointer; white-space: nowrap; font-weight: 500;
}
.chip.on { background: var(--g8); border-color: var(--g8); color: #fff; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-size: 13px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--g1); color: var(--g8); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--g1); color: var(--g8); white-space: nowrap;
}
.badge.gold { background: var(--gold0); color: #8a6a1f; }
.badge.red { background: var(--red0); color: var(--red); }
.badge.orange { background: var(--orange0); color: var(--orange); }
.badge.gray { background: #eef0ef; color: var(--muted); }
.badge.blue { background: var(--blue0); color: var(--blue); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.card-pad { padding: 16px; }
.card h3 { font-size: 16px; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 20% -10%, #1d6b51 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 110%, #0f4a37 0%, transparent 60%), var(--g9);
}
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 18px; padding: 28px 24px; box-shadow: var(--sh-lg); }
.brand-mark { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 22px; text-align: center; }
.brand-mark img { width: 56px; height: 56px; }
.brand-name { font-size: 22px; font-weight: 700; color: var(--g9); letter-spacing: .3px; }
.brand-name b { color: var(--gold); }
.brand-sub { font-size: 12px; letter-spacing: 3px; color: var(--muted); text-transform: uppercase; }
.login-err { background: var(--red0); color: var(--red); padding: 9px 12px; border-radius: var(--r-sm); font-size: 14px; }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 12px 0 16px; background: var(--g9); color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .12);
}
.topbar .title { font-size: 17px; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .btn.ghost { color: #fff; }
.topbar .btn.ghost:hover { background: rgba(255, 255, 255, .1); }
.topbar .logo { width: 30px; height: 30px; border-radius: 8px; }
.main { padding: 14px 12px calc(var(--nav-h) + var(--safe-b) + 18px); max-width: 1400px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { font-size: 20px; flex: 1; min-width: 140px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(12, 40, 30, .06);
}
.bottomnav a, .bottomnav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 500; border: 0; background: none; cursor: pointer; padding: 0;
}
.bottomnav .on { color: var(--g8); }
.bottomnav .on svg.i { stroke-width: 2.4; }
.bottomnav svg.i { width: 22px; height: 22px; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 236px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
    background: linear-gradient(180deg, var(--g9), #0a3226); color: #d7e5dd; padding: 18px 12px;
  }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; border-bottom: 1px solid rgba(255, 255, 255, .08); margin-bottom: 12px; }
  .sidebar .brand img { width: 38px; height: 38px; border-radius: 10px; }
  .sidebar .brand b { display: block; color: #fff; font-size: 16px; }
  .sidebar .brand span { font-size: 11px; color: var(--gold2); letter-spacing: 2px; text-transform: uppercase; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .sidebar nav a, .sidebar .foot button {
    display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: #cfe0d6;
    font-weight: 500; border: 0; background: none; cursor: pointer; width: 100%; text-align: left;
  }
  .sidebar nav a:hover, .sidebar .foot button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
  .sidebar nav a.on { background: rgba(201, 162, 76, .16); color: #f3dfa9; }
  .sidebar nav .sep { height: 1px; background: rgba(255, 255, 255, .08); margin: 10px 4px; }
  .sidebar .foot { border-top: 1px solid rgba(255, 255, 255, .08); padding-top: 10px; }
  .sidebar .me { padding: 6px 12px 10px; font-size: 13px; }
  .sidebar .me b { color: #fff; display: block; }
  .topbar, .bottomnav { display: none; }
  .main { padding: 22px 26px 40px; width: 100%; }
  .page-head h1 { font-size: 24px; }
}

/* ---------- Product grid ---------- */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
@media (max-width: 420px) { .pgrid { grid-template-columns: 1fr 1fr; gap: 8px; } }
.pcard {
  position: relative; display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line);
  border-radius: var(--r); overflow: hidden; cursor: pointer; transition: box-shadow .15s, transform .1s, border-color .15s;
  text-align: left; padding: 0;
}
.pcard:hover { box-shadow: var(--sh); border-color: #cfdcd4; }
.pcard:active { transform: scale(.985); }
.pcard .pimg { aspect-ratio: 1; background: var(--g9); overflow: hidden; }
.pcard .pimg img { width: 100%; height: 100%; object-fit: cover; }
.pcard .pbody { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.pcard .pname { font-size: 13px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 34px; }
.pcard .punit { font-size: 12px; color: var(--muted); }
.pcard .pprice { margin-top: auto; padding-top: 4px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; }
.pcard .pprice b { color: var(--g8); font-size: 15px; }
.pcard .pprice s { color: var(--muted); font-size: 12px; }
.pcard .tag { position: absolute; top: 8px; left: 8px; }
.pcard .incart {
  position: absolute; top: 8px; right: 8px; min-width: 26px; height: 26px; padding: 0 7px; border-radius: 13px;
  background: var(--gold); color: #2b2210; font-weight: 700; font-size: 13px; display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}
.pcard .info {
  position: absolute; right: 6px; bottom: 6px; width: 30px; height: 30px; border-radius: 15px; border: 0;
  background: var(--g0); color: var(--g7); display: grid; place-items: center; cursor: pointer;
}
.pcard .info svg.i { width: 16px; height: 16px; }
.pcard.off { opacity: .55; }
.pcard.bump { animation: bump .25s ease; }
@keyframes bump { 50% { transform: scale(.96); } }

/* ---------- POS ---------- */
.pos { display: grid; gap: 14px; }
.pos-cust {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #fff; border: 1px solid var(--line);
  border-radius: var(--r); cursor: pointer; box-shadow: var(--sh); margin-bottom: 12px;
}
.pos-cust .av {
  width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; flex: none;
  background: var(--gold0); color: #8a6a1f; font-weight: 700;
}
.pos-cust b { display: block; }
.cart { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.cart-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cart-head h3 { flex: 1; font-size: 16px; }
.cart-lines { flex: 1; overflow: auto; }
.cline { padding: 10px 14px; border-bottom: 1px solid var(--line2); }
.cline .top { display: flex; gap: 8px; align-items: flex-start; }
.cline .nm { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; line-height: 1.3; }
.cline .nm small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.cline .grid { display: grid; grid-template-columns: 112px 1fr 1.35fr; gap: 6px; margin-top: 8px; align-items: end; }
.cline .grid label span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.cline .grid .input { min-height: 36px; padding: 6px 8px; }
.cline .foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 13px; }
.cline .foot b { font-size: 15px; }
.cline.manual .price-in { border-color: var(--gold); background: var(--gold0); }
.qty { display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; height: 36px; }
.qty button { width: 32px; height: 100%; border: 0; background: var(--g0); cursor: pointer; display: grid; place-items: center; color: var(--g8); }
.qty button svg.i { width: 16px; height: 16px; }
.qty input { width: 100%; min-width: 0; border: 0; text-align: center; height: 100%; outline: none; font-weight: 600; }
.cart-sum { padding: 12px 14px; border-top: 1px solid var(--line); background: #fbfcfb; border-radius: 0 0 var(--r) var(--r); }
.sum-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 3px 0; font-size: 14px; }
.sum-row .input { max-width: 150px; min-height: 34px; padding: 5px 8px; }
.sum-row.total { font-size: 18px; font-weight: 700; color: var(--g9); border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; }
.cart-empty { padding: 30px 16px; text-align: center; color: var(--muted); }
.cart-empty svg.i { width: 40px; height: 40px; color: #c5d3cb; margin: 0 auto 8px; }
.checkout-bar {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--nav-h) + var(--safe-b) + 10px); z-index: 35;
  display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 16px; border-radius: 14px;
  background: var(--g9); color: #fff; box-shadow: var(--sh-lg); cursor: pointer;
}
.checkout-bar .cnt { background: var(--gold); color: #2b2210; border-radius: 12px; padding: 1px 9px; font-weight: 700; font-size: 13px; }
.checkout-bar b { font-size: 17px; }
.cart-close { display: inline-flex; }

@media (max-width: 959px) {
  .pos { padding-bottom: 76px; }
  .pos-cart {
    position: fixed; inset: 0; z-index: 60; background: rgba(10, 30, 22, .45); display: none;
    align-items: flex-end;
  }
  .pos-cart.open { display: flex; }
  .pos-cart .cart { width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; animation: up .22s ease; padding-bottom: var(--safe-b); }
  .pos-cart .cart-sum { border-radius: 0; }
}
@media (min-width: 960px) {
  .pos { grid-template-columns: minmax(0, 1fr) clamp(330px, 34vw, 430px); align-items: start; }
  .pos-cart .cart { position: sticky; top: 16px; max-height: calc(100vh - 32px); }
  .checkout-bar, .cart-close { display: none; }
}
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- Lists ---------- */
.list { background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); overflow: hidden; }
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line2); cursor: pointer; color: inherit; }
.li:last-child { border-bottom: 0; }
.li:hover { background: var(--g0); }
.li .main-col { flex: 1; min-width: 0; }
.li .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .s { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .end { text-align: right; flex: none; }
.li .end b { display: block; }
.li .av { width: 40px; height: 40px; border-radius: 20px; display: grid; place-items: center; flex: none; background: var(--g1); color: var(--g8); font-weight: 700; }
.li.cancel .t, .li.cancel .end b { text-decoration: line-through; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--sh); }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .3px; }
.stat .v { font-size: 20px; font-weight: 700; margin-top: 2px; color: var(--g9); }
.stat .v.red { color: var(--red); }
.stat .d { font-size: 12px; color: var(--muted); }
.stat.hero { background: linear-gradient(135deg, var(--g8), var(--g9)); color: #fff; border: 0; }
.stat.hero .k { color: var(--gold2); }
.stat.hero .v { color: #fff; }
.stat.hero .d { color: #b9d1c4; }

.two-col { display: grid; gap: 14px; }
@media (min-width: 900px) { .two-col { grid-template-columns: 1fr 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line2); text-align: left; vertical-align: top; }
.tbl th { background: #f7f9f8; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap; position: sticky; top: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fafcfb; }
.tbl .pthumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }

/* ---------- Detail / invoice ---------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
.invoice { padding: 18px; }
.inv-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; border-bottom: 2px solid var(--g9); padding-bottom: 12px; margin-bottom: 14px; }
.inv-brand { display: flex; align-items: center; gap: 10px; }
.inv-brand img { width: 44px; height: 44px; border-radius: 10px; }
.inv-brand b { font-size: 18px; color: var(--g9); display: block; }
.inv-title { text-align: right; }
.inv-title h2 { font-size: 18px; letter-spacing: .5px; color: var(--g9); }
.inv-parties { display: grid; gap: 12px; margin-bottom: 14px; }
@media (min-width: 640px) { .inv-parties { grid-template-columns: 1fr 1fr; } }
.inv-sum { margin-left: auto; max-width: 360px; margin-top: 12px; }
.inv-sign { display: none; }
.cancel-stamp { display: inline-block; border: 2px solid var(--red); color: var(--red); padding: 2px 10px; border-radius: 6px; font-weight: 700; transform: rotate(-4deg); }

/* product detail */
.pd { display: grid; gap: 16px; }
@media (min-width: 720px) { .pd { grid-template-columns: 260px 1fr; } }
.pd .pimg { border-radius: var(--r); overflow: hidden; background: var(--g9); aspect-ratio: 1; }
.pd .pimg img { width: 100%; height: 100%; object-fit: cover; }
.pd h2 { font-size: 20px; color: var(--g9); }
.pd .price { font-size: 22px; font-weight: 700; color: var(--g8); }
.benefits { margin: 0; padding: 0; list-style: none; counter-reset: b; }
.benefits li { counter-increment: b; display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.benefits li::before {
  content: counter(b, decimal-leading-zero); flex: none; width: 26px; height: 26px; border-radius: 13px;
  background: var(--gold0); color: #8a6a1f; font-weight: 700; font-size: 12px; display: grid; place-items: center;
}
.catalog-pages { display: grid; gap: 10px; }
.catalog-pages img { width: 100%; border-radius: var(--r-sm); border: 1px solid var(--line); background: #eee; }
.section-t { font-size: 13px; font-weight: 700; color: var(--g8); text-transform: uppercase; letter-spacing: .5px; margin: 16px 0 6px; }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; z-index: 100; background: rgba(10, 30, 22, .5); display: flex;
  align-items: flex-end; justify-content: center; animation: fade .15s ease;
}
.modal {
  background: #fff; width: 100%; max-height: 94vh; display: flex; flex-direction: column;
  border-radius: 18px 18px 0 0; box-shadow: var(--sh-lg); animation: up .2s ease; padding-bottom: var(--safe-b);
}
.modal-h { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--line); }
.modal-h h3 { flex: 1; font-size: 17px; }
.modal-b { padding: 16px 18px; overflow: auto; flex: 1; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.modal-f .spacer { flex: 1; }
@media (min-width: 720px) {
  .modal-bg { align-items: center; padding: 20px; }
  .modal { max-width: 560px; border-radius: 16px; max-height: 90vh; }
  .modal.lg { max-width: 860px; }
  .modal.sm { max-width: 420px; }
}
@media (max-width: 520px) { .form-grid { grid-template-columns: 1fr; } }
@keyframes fade { from { opacity: 0; } }

.pick-list .li { padding: 10px 6px; }

/* ---------- Toast ---------- */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--safe-b) + 76px); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
@media (min-width: 960px) { #toasts { bottom: 24px; } }
.toast { background: #17241e; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--sh-lg); font-size: 14px; animation: up .2s ease; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--g7); }

.print-only { display: none; }
@media screen and (max-width: 640px) { .hide-sm { display: none; } }
@media print, (min-width: 641px) { .show-sm { display: none; } }

/* ---------- Print ---------- */
@media print {
  @page { margin: 10mm; }
  .print-only { display: block; }
  body { background: #fff; font-size: 12px; }
  .sidebar, .topbar, .bottomnav, .no-print, #toasts, .checkout-bar { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  .invoice { padding: 0; }
  .table-wrap { border: 0; box-shadow: none; overflow: visible; }
  .tbl th, .tbl td { padding: 5px 6px; }
  .tbl th { position: static; }
  .inv-sign { display: grid; grid-template-columns: 1fr 1fr; text-align: center; margin-top: 24px; font-weight: 600; }
  .inv-sign span { display: block; font-weight: 400; font-style: italic; font-size: 11px; margin-bottom: 50px; }
}
@media (max-width: 959px) { .page-head h1.t-dup { display: none; } .page-head { justify-content: flex-end; } }
.tbl td.r, .tbl th.r { white-space: nowrap; }
@media (max-width: 719px) { .pd .pimg { max-width: 240px; margin: 0 auto; } }
.sum-row .input.total-in { max-width: 190px; font-size: 18px; font-weight: 700; color: var(--g9); border-color: #cfdcd4; }
.sum-row .seg button { padding: 6px 10px; }
.pay-total { text-align: center; padding: 12px; border-radius: var(--r); background: var(--g0); border: 1px solid var(--g1); }
.pay-total span { display: block; font-size: 13px; color: var(--muted); }
.pay-total b { display: block; font-size: 26px; color: var(--g9); }

/* ---------- Giỏ hàng & thanh toán trên điện thoại ---------- */
.cart-pay { padding: 10px 14px 12px; background: #fbfcfb; border-radius: 0 0 var(--r) var(--r); }
.cart-pay .btn { gap: 8px; }
.cart-pay .pay-amt { font-weight: 700; }
.cart-sum { border-radius: 0; padding-bottom: 4px; }
.pay-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal { max-height: calc(100dvh - 12px); }
@media (max-width: 959px) {
  /* cả giỏ cuộn một khối, đầu giỏ và nút Thanh toán luôn hiện */
  .pos-cart .cart { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
  .pos-cart .cart-lines { flex: none; overflow: visible; }
  .pos-cart .cart-head { position: sticky; top: 0; z-index: 3; background: #fff; border-radius: 18px 18px 0 0; }
  .pos-cart .cart-pay { position: sticky; bottom: 0; z-index: 3; border-top: 1px solid var(--line); box-shadow: 0 -6px 16px rgba(12, 40, 30, .08); border-radius: 0; padding-bottom: calc(12px + var(--safe-b)); }
  .cline { padding: 8px 12px; }
  .cline .grid { grid-template-columns: 104px 1fr 1.3fr; gap: 5px; margin-top: 6px; }
  .cart-sum { padding: 8px 12px; }
  .sum-row { font-size: 13.5px; padding: 2px 0; }
  .sum-row.total { font-size: 16px; }
  .sum-row .input.total-in { font-size: 16px; max-width: 160px; }
  /* hộp thoại thanh toán gọn hơn */
  .modal-b { padding: 12px 14px; }
  .modal-f { padding: 10px 14px calc(10px + var(--safe-b)); }
  .modal-b .stack > * + * { margin-top: 9px; }
  .pay-total { padding: 8px; }
  .pay-total b { font-size: 22px; }
}
/* chữ ký */
.sig-pad-wrap { position: relative; border: 1.5px dashed #b8c9bf; border-radius: var(--r); background: #fff; }
.sig-pad { display: block; width: 100%; aspect-ratio: 5 / 2; touch-action: none; cursor: crosshair; }
.sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #b3c2ba; font-size: 18px; pointer-events: none; }
.sig-current { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); }
.sig-current img { max-height: 54px; max-width: 70%; }
.inv-sign .sig-box { height: 58px; display: grid; place-items: center; }
.inv-sign .sig-box img { max-height: 56px; max-width: 80%; }
.inv-sign b { display: block; }
@media print { .inv-sign span { margin-bottom: 0; } }
