:root {
  --header-h: 64px;
  --blue: #0a6cc4;
  --blue-dark: #08579e;
  --orange: #f7941d;
  --orange-light: #fde7c8;

  --bg: #f4f6fb;
  --surface: #fff;
  --text: #1f2937;
  --text-2: #374151;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --line: #f3f4f6;
  --hover: #f9fafb;
  --tint-blue: #e8f1fb;
  --tint-orange: #fff1e0;
  --tint-green: #dcfce7;
  --tint-red: #fee2e2;
  --shadow: rgba(0, 0, 0, 0.08);
  --stripe: #edf3fb;
  --stripe-head: #e3ebf6;
  color-scheme: light;
  --sold-out: "หมด";
}
:root[lang="en"] { --sold-out: "Sold out"; }
:root[data-theme="dark"] {
  --blue: #3b8fe0;
  --blue-dark: #2a7bcc;
  --bg: #0d1524;
  --surface: #172236;
  --text: #e6ebf2;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --border: #2b3a52;
  --border-strong: #3b4d68;
  --line: #22304a;
  --hover: #1f2d44;
  --tint-blue: rgba(59, 143, 224, 0.16);
  --tint-orange: rgba(247, 148, 29, 0.16);
  --tint-green: rgba(34, 197, 94, 0.16);
  --tint-red: rgba(239, 68, 68, 0.16);
  --shadow: rgba(0, 0, 0, 0.35);
  --stripe: rgba(255, 255, 255, 0.035);
  --stripe-head: rgba(255, 255, 255, 0.06);
  color-scheme: dark;
}
body, header, .card, .stat, .cart, .product-card, .pos-item, dialog { transition: background-color 0.2s, color 0.2s; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: "Sarabun", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 32px;
}
.login-card { width: 100%; max-width: 380px; border-top: 4px solid var(--orange); }
.login-logo { display: block; width: 220px; max-width: 100%; margin: 0 auto 8px; }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); text-align: center; }
label { display: block; font-size: 14px; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font-size: 15px;
  background-color: var(--surface);
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid #b9d8f5; border-color: var(--blue); }
button {
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
button:hover { background: var(--blue-dark); }
button:disabled { opacity: 0.7; cursor: wait; }
button.secondary { background: var(--border); color: var(--text); }
button.secondary:hover { background: var(--border-strong); }
button.small { padding: 4px 10px; font-size: 13px; }
.full { width: 100%; margin-top: 20px; }
.error { color: #dc2626; font-size: 14px; min-height: 20px; margin-top: 12px; }
.hint { font-size: 12px; color: var(--muted-2); margin-top: 16px; line-height: 1.6; }

header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 3px solid var(--orange);
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header .brand {
  font-weight: bold;
  color: var(--blue);
  display: flex;
  align-items: center;
  gap: 12px;
}
header .brand img { height: 40px; }
[data-theme="dark"] header .brand img,
[data-theme="dark"] .login-logo,
[data-theme="dark"] .receipt .r-head img { background: #fff; border-radius: 10px; padding: 3px 8px; }
.header-tools { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--line);
  color: var(--text-2);
}
.icon-btn:hover { background: var(--border); }
.install-btn { background: var(--tint-orange); color: var(--orange); }
.lang-switch { display: inline-flex; background: var(--line); border-radius: 10px; padding: 3px; }
.lang-switch button { background: transparent; color: var(--muted); padding: 5px 10px; font-size: 13px; font-weight: 600; border-radius: 8px; }
.lang-switch button:hover { background: transparent; color: var(--text); }
.lang-switch button.active { background: var(--surface); color: var(--blue); box-shadow: 0 1px 4px var(--shadow); }
.login-tools { position: fixed; top: 16px; right: 16px; display: flex; gap: 10px; }
header .who { font-size: 14px; color: var(--muted); display: flex; gap: 12px; align-items: center; }
.app-version { font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; cursor: default; }
.login-version { margin-top: 14px; text-align: center; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--orange-light);
  color: #b45309;
}
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.off { background: var(--line); color: var(--muted); }
main { max-width: 1100px; margin: 24px auto; padding: 0 16px; display: grid; gap: 24px; }

.layout { display: flex; min-height: calc(100vh - var(--header-h)); }
.sidebar {
  width: 252px;
  flex-shrink: 0;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 18px 14px 14px;
  color: #fff;
  background:
    radial-gradient(circle at 110% 8%, rgba(247, 148, 29, 0.35) 0, transparent 38%),
    radial-gradient(circle at -20% 60%, rgba(255, 255, 255, 0.10) 0, transparent 40%),
    linear-gradient(180deg, #0b2f5c 0%, #0a4f96 55%, #0a6cc4 100%);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.side-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(4px);
}
.avatar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--orange), #ffc069);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(247, 148, 29, 0.45);
}
.side-name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.side-role { font-size: 12px; opacity: 0.7; }
.sidebar .group {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  margin: 14px 10px 6px;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 10px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-size: 15px;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.nav-ic {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.10);
  transition: background 0.15s;
}
.sidebar a:hover { background: rgba(255, 255, 255, 0.08); color: #fff; transform: translateX(2px); }
.sidebar a:hover .nav-ic { background: rgba(255, 255, 255, 0.18); }
.sidebar a.active {
  background: #fff;
  color: var(--blue);
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(4, 30, 66, 0.35);
}
.sidebar a.active .nav-ic {
  background: linear-gradient(135deg, var(--orange), #ffb44d);
  color: #fff;
  box-shadow: 0 3px 10px rgba(247, 148, 29, 0.45);
}
.side-promo {
  margin-top: auto;
  padding: 12px;
  border-radius: 16px;
  background: #fffaf2;
  color: #1f2937;
  text-align: center;
  box-shadow: 0 8px 24px rgba(4, 30, 66, 0.3);
}
.side-promo img { width: 100%; height: 104px; object-fit: cover; border-radius: 12px; display: block; }
@media (max-height: 920px) {
  .sidebar a { padding: 5px 10px; }
  .nav-ic { width: 32px; height: 32px; }
  .sidebar .group { margin: 10px 10px 4px; }
  .side-profile { padding: 10px; margin-bottom: 4px; }
  .side-promo { padding: 10px; }
  .side-promo img { height: 84px; }
  .side-promo .promo-text { display: none; }
  .side-promo .promo-title { margin: 8px 0; }
  .side-logout { margin-top: 6px; padding: 8px 12px; }
}
@media (max-height: 680px) {
  .side-promo img { display: none; }
  .side-promo .promo-title { margin-top: 0; }
}
.promo-title { font-weight: bold; color: var(--blue); margin-top: 10px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.promo-title .ic { color: var(--orange); }
.promo-text { font-size: 12px; color: #6b7280; margin: 2px 0 10px; }
.side-promo .promo-title { color: #0a6cc4; }
.promo-btn { width: 100%; background: var(--orange); font-weight: 600; padding: 8px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.promo-btn:hover { background: #e07f0a; }
.side-logout {
  margin-top: 10px;
  background: transparent;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
}
.side-logout:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.layout main { flex: 1; margin: 24px; max-width: none; align-content: start; min-width: 0; }
.page { display: grid; gap: 24px; }
.page[hidden] { display: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.tile {
  display: block;
  padding: 20px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}
.tile:hover { border-color: var(--orange); box-shadow: 0 2px 12px rgba(247, 148, 29, 0.15); }
.tile .num { font-size: 28px; font-weight: bold; color: var(--blue); }
.tile .label { color: var(--muted); font-size: 14px; margin-top: 4px; }
.placeholder { text-align: center; color: var(--muted-2); padding: 48px 16px; }
.narrow { max-width: 420px; }

/* ---------- Products ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.toolbar .left, .toolbar .right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.search { width: 240px; padding-left: 36px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%239ca3af' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 14px;
}
.chip:hover { background: var(--hover); }
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip .count { opacity: 0.7; margin-left: 4px; }
.btn-orange { background: var(--orange); }
.btn-orange:hover { background: #e07f0a; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.product-card {
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition: transform 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
}
.product-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1); }
.product-img {
  position: relative;
  aspect-ratio: 4 / 3;
  background: linear-gradient(135deg, #fdf3e4, #e8f1fb);
  cursor: pointer;
}
.product-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.product-img .noimg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 48px; opacity: 0.5; }
.product-img .cat-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 12px;
  color: var(--blue);
  font-weight: 600;
}
.product-card.off .product-img img { filter: grayscale(1) opacity(0.6); }
.product-card.off .product-img::after {
  content: var(--sold-out);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(31, 41, 55, 0.85);
  color: #fff;
  padding: 6px 18px;
  border-radius: 999px;
  font-weight: bold;
}
.product-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.product-name { font-weight: 600; font-size: 16px; }
.product-desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 39px;
}
.product-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 6px; }
.product-price { font-size: 20px; font-weight: bold; color: var(--orange); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); cursor: pointer; margin: 0; }
.switch input { display: none; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.switch input:checked + .track { background: #22c55e; }
.switch input:checked + .track::after { left: 18px; }

.empty-state { text-align: center; padding: 64px 16px; color: var(--muted-2); }
.empty-state .icon { font-size: 48px; }

dialog {
  background: var(--surface);
  color: var(--text);
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(17, 24, 39, 0.45); }
.dlg-head { padding: 18px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.dlg-head h3 { margin: 0; color: var(--blue); }
.dlg-close { background: none; color: var(--muted-2); font-size: 22px; padding: 0 4px; }
.dlg-close:hover { background: none; color: var(--text-2); }
.dlg-body { padding: 8px 24px 16px; }
.dlg-foot { padding: 16px 24px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.dlg-foot .spacer { flex: 1; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }

.dropzone {
  margin-top: 12px;
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted-2);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  background: var(--hover);
}
.dropzone:hover, .dropzone.drag { border-color: var(--orange); background: #fffaf3; }
.dropzone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dropzone .remove-img { position: absolute; top: 8px; right: 8px; z-index: 1; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: 8px; font: inherit; font-size: 15px; resize: vertical; }
.cat-list { list-style: none; padding: 0; margin: 12px 0; }
.cat-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cat-list .cat-name { flex: 1; min-width: 0; padding: 8px 10px; }
.inline-form { display: flex; gap: 8px; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.pos-left { display: grid; gap: 16px; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.pos-item {
  background: var(--surface);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  border: 2px solid transparent;
  padding: 0;
  text-align: left;
  color: inherit;
  font: inherit;
  position: relative;
  transition: transform 0.1s, border-color 0.1s;
}
.pos-item:hover { background: var(--surface); border-color: var(--orange); }
.pos-item:active { transform: scale(0.97); }
.pos-item .thumb { aspect-ratio: 1; background: linear-gradient(135deg, #fdf3e4, #e8f1fb); display: flex; align-items: center; justify-content: center; font-size: 36px; }
.pos-item .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pos-item .info { padding: 8px 10px 10px; }
.pos-item .name { font-size: 14px; font-weight: 600; line-height: 1.3; min-height: 36px; }
.pos-item .price { color: var(--orange); font-weight: bold; margin-top: 2px; }
.pos-item .in-cart {
  position: absolute; top: 8px; right: 8px; min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 999px; background: var(--blue); color: #fff; font-size: 13px; font-weight: bold;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.pos-item:disabled { cursor: not-allowed; opacity: 0.55; border-color: transparent; }
.pos-item:disabled .thumb img { filter: grayscale(1); }
.pos-item:disabled::after {
  content: var(--sold-out); position: absolute; top: 35%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(31,41,55,.85); color: #fff; padding: 4px 14px; border-radius: 999px; font-weight: bold;
}

.cart {
  position: sticky;
  top: 16px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 110px);
}
.cart-head { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.cart-head h3 { margin: 0; color: var(--blue); font-size: 17px; }
.cart-items { flex: 1; overflow-y: auto; padding: 4px 18px; min-height: 120px; }
.cart-empty { text-align: center; color: var(--muted-2); padding: 40px 0; }
.cart-empty .icon { font-size: 40px; }
.cart-line { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.cart-line img, .cart-line .ph { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--line); display: flex; align-items: center; justify-content: center; }
.cart-line .ln-name { font-size: 14px; font-weight: 600; }
.cart-line .ln-price { font-size: 12px; color: var(--muted); }
.cart-line .ln-right { text-align: right; }
.cart-line .ln-total { font-weight: bold; font-size: 14px; }
.qty { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; }
.qty button { width: 26px; height: 26px; padding: 0; border-radius: 50%; background: var(--line); color: var(--text-2); font-size: 16px; line-height: 1; }
.qty button:hover { background: var(--border); }
.qty span { min-width: 20px; text-align: center; font-weight: 600; }
.cart-foot { padding: 14px 18px 18px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.sum-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--muted); }
.sum-row input { width: 110px; padding: 6px 10px; text-align: right; }
.sum-total { font-size: 22px; font-weight: bold; color: var(--text); }
.sum-total span:last-child { color: var(--orange); }
.delivery-box { display: grid; gap: 6px; }
.delivery-box select, .delivery-box input { width: 100%; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-methods button { background: var(--line); color: var(--text-2); padding: 10px 4px; font-size: 14px; border: 2px solid transparent; }
.pay-methods button:hover { background: var(--border); }
.pay-methods button.active { background: var(--tint-blue); color: var(--blue); border-color: var(--blue); font-weight: 600; }
.cash-quick { display: flex; gap: 6px; flex-wrap: wrap; }
.cash-quick button { flex: 1; background: #fff7ed; color: #b45309; padding: 6px 4px; font-size: 13px; }
.cash-quick button:hover { background: #ffedd5; }
.change-row { font-size: 16px; font-weight: 600; }
.change-row.ok span:last-child { color: #15803d; }
.change-row.short span:last-child { color: #dc2626; }
.btn-pay { background: var(--orange); font-size: 18px; font-weight: bold; padding: 14px; width: 100%; }
.btn-pay:hover { background: #e07f0a; }
.btn-pay:disabled { background: #fcd9a8; cursor: not-allowed; }

/* ---------- Receipt: thermal slip 80×100 mm ---------- */
#receipt-body { background: #eceff3; }
.receipt {
  font-family: "Sarabun", "Segoe UI", Tahoma, sans-serif;
  width: 80mm;
  min-height: 100mm;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 2mm 2.5mm;
  background: #fff;
  color: #111;
  font-size: 11px;
  line-height: 1.25;
  position: relative;
}
.receipt .r-head { text-align: center; margin-bottom: 4px; }
.receipt .r-head img { width: 22mm; }
.receipt .r-shop { font-weight: bold; font-size: 13px; color: #111; }
.receipt .r-meta { display: flex; justify-content: space-between; gap: 4px; font-size: 10px; color: #374151; }
.receipt hr { border: 0; border-top: 1px dashed #9ca3af; margin: 4px 0; }
.receipt table { width: 100%; }
.receipt table td { padding: 1px 0; border: 0; font-size: 11px; color: #111; }
.receipt .r-num { text-align: right; white-space: nowrap; }
.receipt .r-total td { font-size: 13px; font-weight: bold; }
.receipt .r-foot { text-align: center; margin-top: 6px; color: #374151; font-size: 10px; }
.receipt .r-void {
  position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg);
  font-size: 28px; font-weight: bold; color: rgba(220, 38, 38, 0.35); border: 3px solid rgba(220, 38, 38, 0.35);
  padding: 2px 10px; border-radius: 8px; pointer-events: none;
}
.receipt .r-opts { color: #4b5563; }
.receipt .r-info { font-size: 10px; color: #374151; line-height: 1.3; }
.receipt .r-doc { font-size: 11px; font-weight: 700; margin-top: 2px; color: #111; }
.receipt .r-small td { font-size: 10px; color: #4b5563; }
.vat-row { font-size: 13px; color: var(--muted); }

/* ---------- Shift / cash drawer ---------- */
.shift-open-card { text-align: center; padding: 36px 24px; }
.shift-closed-icon { width: 68px; height: 68px; border-radius: 20px; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; background: var(--tint-orange); color: var(--orange); }
.shift-open-form { max-width: 280px; margin: 16px auto 0; display: grid; gap: 8px; text-align: left; }
.shift-open-form input { font-size: 20px; text-align: center; }
.shift-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.shift-head .row-actions .ic { vertical-align: -3px; }
.drawer-calc { margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; padding: 6px 16px; max-width: 460px; }
.drawer-calc > div { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.drawer-calc > div:last-child { border-bottom: 0; }
.drawer-calc .dc-total { font-weight: 800; font-size: 17px; color: var(--blue); }
.diff { font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.diff.ok { background: var(--tint-green); color: #16a34a; }
.diff.over { background: var(--tint-blue); color: var(--blue); }
.diff.short { background: var(--tint-red); color: #dc2626; }
.sub-h { margin: 18px 0 8px; font-size: 15px; color: var(--text-2); }
td.pos { color: #16a34a; }
td.neg { color: #dc2626; }
.table-scroll { overflow-x: auto; max-width: 100%; }
.table-scroll table { white-space: nowrap; }
.page > * { min-width: 0; }
.shift-banner { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--tint-orange); color: var(--orange); border-radius: 10px; padding: 8px 12px; font-size: 13px; font-weight: 600; }

/* ---------- Stock ---------- */
.stock-tag {
  position: absolute;
  left: 8px;
  bottom: auto;
  top: 8px;
  z-index: 1;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #16a34a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.stock-tag.low { background: #fff7ed; color: #ea580c; }
.stock-tag.out { background: #dc2626; color: #fff; }
.product-img .stock-tag { left: auto; right: 8px; }
.pos-item { position: relative; }
.stock-qty { font-weight: 800; font-size: 16px; padding: 2px 10px; border-radius: 8px; background: var(--tint-green); color: #16a34a; }
.stock-qty.low { background: var(--tint-orange); color: #ea580c; }
.stock-qty.out { background: var(--tint-red); color: #dc2626; }
.stock-prod { display: flex; align-items: center; gap: 10px; }
.stock-prod img, .stock-prod .ph { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--line); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stock-preview { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--hover); font-size: 15px; }
.stock-preview .neg, td.neg { color: #dc2626; }
.stock-now { padding: 9px 0; font-weight: 700; font-size: 16px; }
.stock-now a { font-size: 13px; font-weight: 500; margin-left: 8px; }
.badge.mv-SALE { background: var(--tint-blue); color: var(--blue); }
.badge.mv-VOID { background: var(--hover); color: var(--muted); }
.badge.mv-RECEIVE { background: var(--tint-green); color: #16a34a; }
.badge.mv-WASTE { background: var(--tint-red); color: #dc2626; }
.badge.mv-COUNT { background: var(--tint-orange); color: #ea580c; }
#page-stock .stat-strip { margin-bottom: 16px; }
#page-stock .row-actions { justify-content: flex-end; flex-wrap: nowrap; }
@media (max-width: 900px) {
  #stock-rows { display: block; }
  #stock-rows tr { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 8px 0; }
  #stock-rows td { border: 0; padding: 4px 8px; background: transparent !important; }
  #stock-rows tr { border-radius: 10px; }
  #stock-rows tr:nth-child(even) { background: var(--stripe); }
  #stock-rows td:nth-child(3) { display: none; }
  #stock-rows td:nth-child(4) { grid-column: 1 / -1; }
  #stock-rows td.placeholder { grid-column: 1 / -1; }
  #page-stock .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  #stock-table thead { display: none; }
}

/* ---------- Members & points ---------- */
.member-add { width: 100%; background: var(--tint-blue); color: var(--blue); border: 1.5px dashed var(--blue); font-weight: 600; padding: 9px; }
.member-add:hover { background: var(--tint-blue); filter: brightness(0.97); }
.member-chip { display: flex; align-items: center; gap: 10px; background: var(--tint-orange); border-radius: 12px; padding: 8px 10px; }
.member-chip .mc-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.member-chip .mc-info { flex: 1; min-width: 0; font-size: 14px; }
.member-chip .mc-info small { color: var(--muted); }
.member-chip .mc-info div { color: var(--orange); font-weight: 700; font-size: 13px; }
.earn-hint { text-align: right; font-size: 13px; color: var(--orange); font-weight: 600; margin-top: -4px; }
.points-pill { display: inline-block; background: var(--tint-orange); color: var(--orange); font-weight: 700; border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.member-results { list-style: none; padding: 0; margin: 10px 0 0; max-height: 240px; overflow-y: auto; }
.member-results li { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.member-results li:hover { background: var(--hover); }
.member-results li.empty { cursor: default; }
.member-new { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.member-new h4 { margin: 0 0 4px; color: var(--blue); }
tr.voided td { text-decoration: line-through; color: var(--muted-2); }

/* ---------- Shop settings & PromptPay ---------- */
.settings-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.settings-grid .card { margin-bottom: 0; }
.ok-msg { color: #16a34a; font-weight: 600; margin-left: 12px; }
.qr-preview-card { text-align: center; }
.qr-card { text-align: center; color: #111; }
.qr-card .r-shop { font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.qr-box { width: 220px; max-width: 100%; margin: 8px auto; background: #fff; border-radius: 12px; padding: 8px; }
.qr-box:empty { display: none; }
.qr-box svg, .qr-box img { display: block; width: 100%; height: auto; }
.qr-dialog { width: min(460px, calc(100vw - 16px)); }
.qr-pay { text-align: center; padding-top: 8px; background: #fff; color: #111; }
.qr-pay .pp-logo { height: 36px; display: block; margin: 0 auto 6px; }
.qr-pay .qr-box { width: min(320px, 78vw); border: 1px solid #e5e7eb; }
.pos-qr-live { text-align: center; background: #fff; color: #111; border-radius: 12px; padding: 8px 8px 10px; }
.pos-qr-live .qr-box { width: min(260px, 100%); border: 1px solid #e5e7eb; }
.pos-qr-live .qr-amount { font-size: 22px; }
.qr-amount { font-size: 30px; font-weight: 800; color: var(--orange); margin-top: 6px; }
.qr-loading { width: 100%; aspect-ratio: 1; border-radius: 8px; background: linear-gradient(90deg, var(--line), var(--hover), var(--line)); background-size: 200% 100%; animation: qr-shimmer 1.2s infinite linear; }
@keyframes qr-shimmer { to { background-position: -200% 0; } }
@media (max-width: 900px) {
  .settings-grid { grid-template-columns: 1fr; }
}

/* ---------- Product options ---------- */
.pos-item .has-opt { margin-left: 4px; font-size: 12px; color: var(--muted-2); }
.cart-line .ln-opts { font-size: 12px; color: var(--blue); line-height: 1.3; }
.opt-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.opt-img { width: 48px; height: 48px; border-radius: 10px; overflow: hidden; flex-shrink: 0; background: var(--line); display: flex; align-items: center; justify-content: center; font-size: 24px; }
.opt-img img { width: 100%; height: 100%; object-fit: cover; }
.opt-body { max-height: 60vh; overflow-y: auto; display: grid; gap: 14px; padding-top: 14px; }
.opt-group { border: 0; padding: 0; margin: 0; display: grid; gap: 6px; }
.opt-group legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.opt-group legend small { font-weight: 400; color: var(--muted); margin-left: 6px; font-size: 12px; }
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  margin: 0;
  color: var(--text);
  font-size: 15px;
}
.opt input { width: 18px; height: 18px; margin: 0; accent-color: var(--orange); }
.opt:has(input:checked) { border-color: var(--orange); background: var(--tint-orange); }
.opt-name { flex: 1; }
.opt-price { color: var(--orange); font-weight: 600; font-size: 14px; }
.qty.big button { width: 36px; height: 36px; font-size: 20px; }
.qty.big span { min-width: 28px; font-size: 17px; }
.muted-note { color: var(--muted); font-size: 13px; }
.optgroup-editor { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.optgroup-editor h4 { margin: 0 0 4px; color: var(--blue); }
.opt-flags { display: flex; gap: 18px; margin: 8px 0; }
label.check { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; color: var(--text); cursor: pointer; }
label.check input { width: 16px; height: 16px; margin: 0; }
.opt-row { display: grid; grid-template-columns: 1fr 100px auto; gap: 8px; margin-bottom: 6px; }
.opt-row input { padding: 8px 10px; }
.opt-pick { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 4px 0; }

.r-void-note { background: #fef2f2; color: #b91c1c; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-top: 10px; }
#print-area { display: none; }
@page {
  size: 80mm 100mm;
  margin: 2mm;
}
@media print {
  :root, :root[data-theme="dark"] { --text: #111827; --muted: #4b5563; --muted-2: #9ca3af; --surface: #fff; }
  html, body { width: 80mm; margin: 0; padding: 0; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; width: 76mm; background: #fff; color: #111; }
  #print-area .receipt { width: 76mm; min-height: 0; padding: 0; box-shadow: none; }
  #print-area .qr-card { width: 100%; }
  #print-area .qr-box { width: 58mm; border-radius: 0; }
  body { background: #fff; }
}

/* ---------- Sales list & reports ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.filters > div { display: grid; gap: 4px; }
.filters label { margin: 0; font-size: 13px; color: var(--muted); }
.filters input, .filters select { width: auto; padding: 8px 10px; }
.stat-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.stat {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border-left: 4px solid var(--blue);
}
.stat.orange { border-left-color: var(--orange); }
.stat.green { border-left-color: #22c55e; }
.stat.red { border-left-color: #ef4444; }
.stat .s-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.s-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8f1fb;
  color: var(--blue);
}
.stat.orange .s-icon { background: var(--tint-orange); color: var(--orange); }
.stat.green .s-icon { background: var(--tint-green); color: #16a34a; }
.stat.red .s-icon { background: var(--tint-red); color: #dc2626; }
.stat .s-label { font-size: 13px; color: var(--muted); }
.stat .s-value { font-size: 24px; font-weight: bold; color: var(--text); margin-top: 4px; }
.stat .s-sub { font-size: 12px; color: var(--muted-2); margin-top: 2px; }
.striped thead th { background: var(--stripe-head); }
.striped thead th:first-child { border-radius: 8px 0 0 8px; }
.striped thead th:last-child { border-radius: 0 8px 8px 0; }
.striped tbody tr:nth-child(even) td { background: var(--stripe); }
.striped tbody td { border-bottom-color: transparent; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td,
.striped tbody tr.clickable:hover td { background: var(--tint-blue); }
tr.voided td { color: var(--muted-2); text-decoration: line-through; }
tr.voided td:last-child, tr.voided td .badge { text-decoration: none; }
.badge.void { background: #fee2e2; color: #b91c1c; }
.badge.pay-CASH { background: #dcfce7; color: #15803d; }
.badge.pay-TRANSFER { background: #e0f2fe; color: #0369a1; }
.badge.pay-CARD { background: #ede9fe; color: #6d28d9; }
.num { text-align: right; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.presets, .filters > .presets { display: flex; gap: 6px; flex-wrap: wrap; }

.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; }
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 220px; padding-top: 24px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-col .bar {
  width: 100%;
  max-width: 44px;
  background: linear-gradient(180deg, var(--orange), #fbbf6b);
  border-radius: 6px 6px 0 0;
  min-height: 2px;
  position: relative;
  transition: height 0.3s;
}
.bar-col .bar.blue { background: linear-gradient(180deg, var(--blue), #5aa6e6); }
.bar-col:hover .bar { filter: brightness(1.08); }
.bar-col .bar-val { font-size: 11px; color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.bar-col .bar-label { font-size: 11px; color: var(--muted); margin-top: 6px; white-space: nowrap; }
.hbar-list { display: grid; gap: 12px; }
.hbar .hb-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; gap: 8px; }
.hbar .hb-top small { color: var(--muted-2); }
.hbar .hb-track { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.hbar .hb-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), #5aa6e6); }
.hbar.orange .hb-fill { background: linear-gradient(90deg, var(--orange), #fbbf6b); }
.rank { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: var(--line); color: var(--muted); font-size: 12px; font-weight: bold; align-items: center; justify-content: center; margin-right: 6px; }
.rank.r1 { background: #fef3c7; color: #b45309; }
.rank.r2 { background: var(--border); color: var(--text-2); }
.rank.r3 { background: #fde7c8; color: #9a3412; }

.hero {
  background: linear-gradient(120deg, var(--blue), #2f8be0 60%, var(--orange));
  color: #fff;
  border-radius: 16px;
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.hero h2 { color: #fff; margin: 0 0 4px; font-size: 22px; }
.hero p { margin: 0; opacity: 0.9; }
.hero a.btn-hero {
  background: #fff; color: #0a6cc4; padding: 12px 22px; border-radius: 10px;
  font-weight: bold; text-decoration: none; box-shadow: 0 4px 14px rgba(0,0,0,.15);
}
.hero a.btn-hero:hover { background: #fff7ed; }

/* ---------- Dashboard charts ---------- */
.dash-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; }
.dash-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.card-sub { font-size: 13px; color: var(--muted); background: var(--line); padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-axis { fill: var(--muted-2); font-size: 12px; font-family: inherit; }
.ch-dot { fill: var(--surface); stroke-width: 3; transition: r 0.15s; }
.ch-point:hover .ch-dot { r: 7; }
.donut-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.donut { width: 180px; height: 180px; }
.ch-track { stroke: var(--line); }
.ch-arc { transition: stroke-width 0.15s; cursor: pointer; }
.ch-arc:hover { stroke-width: 32; }
.ch-center-label { fill: var(--muted); font-size: 13px; font-family: inherit; }
.ch-center-value { fill: var(--text); font-size: 24px; font-weight: bold; font-family: inherit; }
.legend { width: 100%; display: grid; gap: 8px; }
.lg-row { display: grid; grid-template-columns: 12px 1fr auto 44px; gap: 8px; align-items: center; font-size: 14px; }
.lg-dot { width: 12px; height: 12px; border-radius: 4px; }
.lg-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-val { font-weight: 600; }
.lg-pct { color: var(--muted); text-align: right; font-size: 13px; }
.trend { font-weight: 600; }
.trend.up { color: #16a34a; }
.trend.down { color: #dc2626; }

@media (max-width: 1280px) {
  .dash-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .dash-grid { grid-template-columns: 1fr; }
  .pos { grid-template-columns: minmax(0, 1fr) 320px; }
}

/* ---------- Mobile ---------- */
.nav-toggle, .nav-backdrop, .bottom-nav, .cart-close, .cart-backdrop, .cart-bar { display: none; }
.cart-actions { display: flex; gap: 8px; align-items: center; }

@media (max-width: 900px) {
  :root { --header-h: 56px; --bottom-h: 62px; }
  body { -webkit-tap-highlight-color: transparent; }
  input, select, textarea { font-size: 16px; }

  header { padding: 0 10px; gap: 8px; }
  header .brand { gap: 8px; min-width: 0; flex: 1; }
  header .brand img { height: 30px; }
  #tenant-name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  header .who { gap: 6px; }
  header .who > :not(.header-tools) { display: none; }
  .header-tools { gap: 6px; }
  .lang-switch button { padding: 4px 8px; }
  .icon-btn { width: 36px; height: 36px; }
  .nav-toggle { display: inline-flex; flex-shrink: 0; }

  .layout { display: block; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    width: min(84vw, 300px);
    height: 100%;
    padding-top: calc(18px + env(safe-area-inset-top));
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.3);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open, body.cart-open { overflow: hidden; }
  .nav-backdrop, .cart-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
  }
  .nav-backdrop { z-index: 45; }
  body.nav-open .nav-backdrop, body.cart-open .cart-backdrop { opacity: 1; pointer-events: auto; }

  .bottom-nav {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    height: calc(var(--bottom-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 18px var(--shadow);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0 2px;
    border-radius: 0;
    background: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    min-width: 0;
  }
  .bottom-nav span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav button:hover { background: none; }
  .bottom-nav a.active { color: var(--orange); font-weight: 700; }
  .bottom-nav a.active .ic { transform: translateY(-1px); }

  .layout main {
    margin: 0;
    padding: 14px 12px calc(var(--bottom-h) + 20px + env(safe-area-inset-bottom));
    gap: 16px;
  }
  .page { gap: 14px; }
  .card { padding: 16px; border-radius: 14px; }
  h2 { font-size: 16px; margin-bottom: 12px; }
  .card:has(> table) { overflow-x: auto; }
  #page-sales th:nth-child(3), #page-sales td:nth-child(3),
  #page-sales th:nth-child(4), #page-sales td:nth-child(4) { display: none; }
  table { font-size: 13px; }
  th, td { padding: 9px 6px; white-space: nowrap; }

  .hero { padding: 18px; border-radius: 14px; }
  .hero h2 { font-size: 18px; }
  .hero a.btn-hero { width: 100%; text-align: center; padding: 11px; }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; border-radius: 12px; }
  .stat .s-value { font-size: 19px; }
  .stat .s-label { font-size: 12px; }
  .s-icon { width: 34px; height: 34px; border-radius: 10px; }
  .s-icon .ic { width: 18px; height: 18px; }
  .dash-grid, .dash-grid-3, .report-grid { grid-template-columns: 1fr; gap: 14px; }
  .bar-chart { height: 180px; }
  .bar-col .bar-val { display: none; }

  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .filters input, .filters select { width: 100% !important; }
  .filters > .presets { grid-column: 1 / -1; }
  .filters > button, .filters > span { grid-column: 1 / -1; }
  .toolbar, .toolbar .left, .toolbar .right { width: 100%; }
  .search { width: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 0 12px 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex-shrink: 0; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .form-grid { grid-template-columns: 1fr; }

  dialog {
    width: 100% !important; /* beats per-dialog inline widths */
    max-width: 100%;
    max-height: 92vh;
    margin: auto 0 0;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .dlg-head { padding: 14px 18px; }
  .dlg-body { padding: 8px 18px 14px; }
  .dlg-foot { padding: 12px 18px; flex-wrap: wrap; }

  /* POS: product grid fills the screen, cart opens as a bottom sheet. */
  .pos { display: block; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .pos-item .name { font-size: 13px; min-height: 34px; }
  #page-pos { padding-bottom: 70px; }
  .cart {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    z-index: 60;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(105%);
    transition: transform 0.28s ease;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
  }
  .cart::before {
    content: "";
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: var(--border-strong);
    margin: 8px auto 0;
    flex-shrink: 0;
  }
  body.cart-open .cart { transform: none; }
  .cart-backdrop { z-index: 55; }
  .cart-close { display: inline-flex; font-size: 16px; }
  .cart-items { min-height: 60px; }
  .cart-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(var(--bottom-h) + 10px + env(safe-area-inset-bottom));
    z-index: 25;
    padding: 12px 16px;
    border-radius: 14px;
    background: linear-gradient(120deg, var(--orange), #ffad42);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(247, 148, 29, 0.45);
    animation: bar-in 0.25s ease;
  }
  .cart-bar:hover { background: linear-gradient(120deg, #e8860f, var(--orange)); }
  .cb-count { min-width: 28px; height: 28px; border-radius: 999px; background: #fff; color: var(--orange); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; padding: 0 8px; }
  .cb-label { flex: 1; text-align: left; }
  @keyframes bar-in { from { transform: translateY(20px); opacity: 0; } }
}
@media print {
  .bottom-nav, .cart-bar, .nav-backdrop, .cart-backdrop { display: none !important; }
}
h2 { margin: 0 0 16px; font-size: 18px; color: var(--blue); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }
