:root {
  --bg: #F0FAFA;
  --surface: #FFFFFF;
  --surface-2: #E6F7F6;
  --border: #C9EEEB;
  --text: #1A3C3A;
  --muted: #6B9E9A;
  --accent: #81D8D0;
  --accent-2: #5BBFB5;
  --accent-3: #3A9E96;
  --danger: #D94F43;
  --warning: #E8A838;
  --shadow: 0 1px 3px rgba(129, 216, 208, 0.15);
  --radius: 8px;
  --radius-sm: 6px;
  --bg-grad-1: rgba(129, 216, 208, 0.20);
  --bg-grad-2: rgba(230, 247, 246, 0.92);
  --bg-grad-3: #F0FAFA;
}
body.dark {
  --bg: #163331;
  --surface: #1D403D;
  --surface-2: #27534F;
  --border: #3E7B76;
  --text: #F4FFFE;
  --muted: #A8D3CF;
  --accent: #81D8D0;
  --accent-2: #5BBFB5;
  --accent-3: #3A9E96;
  --danger: #D94F43;
  --warning: #E8A838;
  --shadow: 0 12px 34px rgba(7, 28, 27, 0.34);
  --bg-grad-1: rgba(129, 216, 208, 0.18);
  --bg-grad-2: rgba(91, 191, 181, 0.12);
  --bg-grad-3: #163331;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'IBM Plex Sans Thai', sans-serif;
  background:
    radial-gradient(circle at top right, var(--bg-grad-1), transparent 38%),
    radial-gradient(circle at left 20%, var(--bg-grad-2), transparent 28%),
    linear-gradient(180deg, var(--bg-grad-3) 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button { min-height: 44px; }
.login-screen, .app-shell { min-height: 100vh; }
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card, .shell-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}
.login-card {
  width: min(420px, 100%);
  padding: 30px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.brand-badge {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: var(--text);
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 22px rgba(129, 216, 208, 0.28);
  font-weight: 700;
}
.brand-title { font-size: 25px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.field { margin-bottom: 14px; }
.label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input, .select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}
.input:focus, .select:focus { outline: 2px solid rgba(129,216,208,0.30); border-color: var(--accent); box-shadow: 0 0 0 2px rgba(129,216,208,0.14); }
body.dark .input,
body.dark .select {
  background: var(--surface-2);
}
.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .2s ease, filter .2s ease, background .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--text);
  box-shadow: 0 10px 20px rgba(129, 216, 208, 0.24);
}
.btn-primary:hover { filter: brightness(1.04); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); box-shadow: 0 1px 2px rgba(129,216,208,0.10); }
.btn-danger { background: rgba(217,79,67,0.10); color: var(--danger); border: 1px solid rgba(217,79,67,0.20); }
.error {
  display: none;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(192,57,43,0.08);
  color: var(--danger);
  font-size: 13px;
}
.password-wrap {
  position: relative;
}
.password-wrap .input {
  padding-right: 42px;
}
.pw-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  padding: 4px;
  font-size: 16px;
  line-height: 1;
}
.pw-toggle:hover { color: var(--text); }
.app-shell { display: none; min-height: 100vh; padding: 16px; gap: 16px; }
.app-shell.is-ready {
  display: block;
}
.shell-card { width: 100%; max-width: 100%; padding: 18px; overflow-x: clip; }
.pos-sidebar {
  display: none;
}
.pos-sidebar-brand { display: flex; justify-content: center; width: 100%; }
.pos-sidebar-nav { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.sidebar-icon, .mini-icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all 150ms ease;
}
.sidebar-icon.active, .sidebar-icon:hover, .mini-icon-btn:hover {
  background: var(--surface-2);
  color: var(--accent-3);
  border-color: var(--accent);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.shopify-topbar {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.topbar-store { display: flex; align-items: center; gap: 14px; }
.topbar-store-label {
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--accent-3);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
}
.topbar h1 { font-size: clamp(26px, 3.1vw, 34px); letter-spacing: .2px; }
.topbar p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
/* Floating corner controls - for mobile/tablet */
.floating-controls {
  display: none;
  flex-wrap: wrap;
  max-width: 160px;
  justify-content: flex-end;
}
.floating-toggle-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.floating-controls-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.floating-controls.collapsed .floating-controls-menu {
  display: none;
}
@media (max-width: 980px) {
  .floating-controls {
    display: flex;
    position: fixed;
    top: 8px;
    right: 8px;
    z-index: 100;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  }
  .floating-controls .toolbar-group {
    padding: 0;
    border: none;
    background: transparent;
  }
  .floating-controls .mini-btn {
    padding: 6px 8px;
    font-size: 11px;
  }
  /* Hide desktop toolbar groups on mobile */
  .topbar-actions .toolbar-group {
    display: none;
  }
}
.mini-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 4px 6px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 10px;
}
.mini-btn:hover { color: var(--text); }
.mini-btn.active {
  background: var(--accent);
  color: #163332;
  box-shadow: 0 1px 3px rgba(129,216,208,0.24);
}
.cashier-pill {
  padding: 10px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}
.layout {
  display: grid;
  grid-template-columns: minmax(0, 60%) minmax(0, 40%);
  gap: 18px;
}
.view-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  margin-bottom: 16px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 1px rgba(129,216,208,0.08);
}
.view-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
}
.view-tab.active {
  background: #FFFFFF;
  color: var(--text);
  box-shadow: 0 2px 8px rgba(129,216,208,0.18);
  border: 1px solid var(--border);
}
.pos-view {
  display: none;
}
.pos-view.active {
  display: block;
}
.mobile-switcher {
  display: none;
  gap: 10px;
  margin-bottom: 14px;
}
.mobile-switcher .btn {
  flex: 1;
  padding: 14px 16px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
  overflow: hidden;
}
.panel-heading {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
}
.shopify-browser-panel, .shopify-order-panel {
  min-height: calc(100vh - 180px);
}
.shopify-order-panel {
  display: flex;
  flex-direction: column;
}
.shopify-order-meta {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}
.customer-row, .discount-row {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  color: var(--text);
  transition: all 150ms ease;
}
.customer-row:hover, .discount-row:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.shopify-summary-stack {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.charge-btn {
  width: 100%;
  min-height: 52px;
  position: sticky;
  bottom: 0;
}
body.dark .panel {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
}
.section-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
}
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px auto 120px;
  gap: 10px;
  margin-bottom: 14px;
  min-width: 0;
}
.product-tools {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px;
  margin-bottom: 12px;
  align-items: center;
}
.browse-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.category-strip {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 6px;
  margin-bottom: 12px;
}
.shopify-pill-strip {
  scrollbar-width: none;
}
.shopify-pill-strip::-webkit-scrollbar { display: none; }
.shopify-pill-strip > * {
  border-radius: 999px !important;
}
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.pagination-meta {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.parent-strip {
  display: flex;
  gap: 10px;
  overflow: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.parent-chip {
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.parent-chip.active {
  background: var(--surface-2);
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent-3);
}
.category-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.category-chip.active {
  background: var(--surface-2);
  color: var(--accent-3);
  border-color: var(--accent);
}
.category-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  background: linear-gradient(135deg, var(--surface-2), var(--surface));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.category-label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.jump-strip {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding-bottom: 4px;
}
.jump-chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
.jump-chip.active {
  background: var(--surface-2);
  color: var(--accent-3);
  border-color: var(--accent);
}
.group-label {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .6px;
  text-transform: uppercase;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.category-browser {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.category-card {
  border: 1px solid var(--border);
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.category-card:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(29,27,24,0.08); border-color: rgba(0,106,82,0.25); }
.category-card-media {
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(13,143,110,0.2), transparent 52%),
    linear-gradient(135deg, #efe6d5, #f8f2e8);
  border: 1px solid rgba(0,0,0,0.05);
}
.category-card-media img,
.favorite-thumb img,
.all-product-thumb img,
.product-thumb img,
img[data-image-candidates] {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.media-placeholder {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: grid;
  place-items: center;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--accent);
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.7), transparent 50%),
    linear-gradient(135deg, rgba(13,143,110,0.12), rgba(0,106,82,0.04));
}
.category-card-copy { min-width: 0; }
.category-card-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}
.category-card-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.favorite-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  padding-bottom: 6px;
  margin-bottom: 14px;
}
.favorite-btn {
  min-width: 0;
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #fff, var(--surface-2));
  cursor: pointer;
  text-align: left;
  max-width: 100%;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.favorite-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 18px rgba(29,27,24,0.07); border-color: rgba(0,106,82,0.2); }
.favorite-thumb {
  width: 60px;
  height: 60px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.05);
  background: linear-gradient(135deg, #efe6d5, #f8f2e8);
}
.favorite-copy { min-width: 0; }
.favorite-btn strong { display: block; font-size: 14px; }
.favorite-btn span { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.favorite-empty {
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  min-width: 0;
}
.stat {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #FFFFFF, #F7FCFC);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(129,216,208,0.10);
}
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.product-grid {
  display: flex;
  flex-direction: column;
  max-height: none;
  overflow-x: hidden;
  overflow-y: visible;
  padding-right: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  min-width: 0;
}
.product-grid.expanded {
  max-height: none;
  overflow: visible;
  padding-right: 0;
  border: none;
  background: transparent;
}
.all-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.all-product-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #FFFFFF, #F7FCFC);
  padding: 10px;
  display: grid;
  gap: 8px;
  min-width: 0;
  box-shadow: 0 1px 3px rgba(129,216,208,0.10);
}
.all-product-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.all-product-thumb {
  width: 100%;
  min-height: 120px;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
  background: linear-gradient(135deg, #efe6d5, #f8f2e8);
}
.all-product-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.all-product-sub {
  font-size: 11px;
  color: var(--muted);
}
.all-product-meta {
  font-size: 12px;
  color: var(--muted);
}
.all-product-meta strong {
  color: var(--text);
  font-size: 14px;
}
.all-product-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}
.all-product-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.product-head,
.product-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 2.2fr) minmax(0, .9fr) minmax(0, 1fr) minmax(0, .85fr) minmax(72px, .55fr) minmax(92px, .7fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
}
.product-head > div,
.product-row > div { min-width: 0; }
.product-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: .5px;
}
.product-row {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: background-color .18s ease;
}
.product-row:last-child { border-bottom: none; }
.product-row:hover { background: var(--surface-2); }
.product-main {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
}
.product-thumb {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
  background: linear-gradient(135deg, #efe6d5, #f8f2e8);
  flex-shrink: 0;
}
.product-copy { min-width: 0; }
.product-name { font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.product-meta, .product-stock { color: var(--muted); font-size: 12px; margin-top: 4px; overflow-wrap: anywhere; }
.product-stock strong,
.product-sku strong {
  display: block;
  font-size: 14px;
  color: var(--text);
}
.product-price { font-size: 15px; font-weight: 700; color: var(--accent); }
.stock-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}
.stock-badge.ok   { background: rgba(129,216,208,0.18); color: #2E9E8F; }
.stock-badge.low  { background: rgba(232,168,56,0.16); color: #9B6B00; }
.stock-badge.out  { background: rgba(217,79,67,0.12); color: var(--danger); }
body.dark .stock-badge.ok  { background: rgba(129,216,208,0.24); color: #9DE7E0; }
body.dark .stock-badge.low { background: rgba(232,168,56,0.22); color: #FFD17B; }
body.dark .stock-badge.out { background: rgba(217,79,67,0.22); color: #FFB2AA; }
.all-product-card.stock-out { opacity: 0.55; }
.all-product-card.stock-out .all-product-price { color: var(--muted); }
.product-sku {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.favorite-star {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  font-size: 16px;
}
.favorite-star.active {
  background: rgba(129,216,208,0.16);
  border-color: rgba(129,216,208,0.35);
  color: var(--accent-3);
}
.qty-mini {
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
}
/* Tap-to-add animation */
.product-card-addable {
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.2s;
}
.product-card-addable:active {
  transform: scale(0.97);
}
.product-card-addable.added {
  animation: addFlash 0.3s ease;
  background: rgba(129,216,208,0.16);
}
@keyframes addFlash {
  0%,100% { background: transparent; }
  50% { background: rgba(129,216,208,0.18); }
}
.row-add {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
}
.cart-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  max-height: 340px;
  overflow: auto;
}
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.cart-name { font-weight: 700; }
.cart-meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.qty-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.qty-input {
  width: 86px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
  background: #fff;
  -webkit-appearance: none;
  appearance: none;
}
.icon-btn {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
}
.cart-total {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.total-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
}
.total-row.grand {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.total-row.change-row {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.total-row.change-row strong {
  color: var(--accent);
}
.total-row.change-row.insufficient strong {
  color: var(--danger);
}
.cash-change-note {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.cash-denom-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.denom-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex: 1 1 auto;
  min-width: 48px;
  transition: background .15s, border-color .15s;
}
.denom-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.cash-change-note.insufficient {
  color: var(--danger);
}
.checkout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
.quick-qty-bar {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.quick-qty-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 10px;
  min-height: 38px;
  font-weight: 700;
  cursor: pointer;
}
.quick-qty-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.quick-qty-custom {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}
.mini-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
}
body.dark .mini-input {
  background: var(--surface-2);
}
.stock-movement {
  margin-top: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: rgba(255,255,255,0.45);
}
body.dark .stock-movement {
  background: rgba(255,255,255,0.03);
}
.stock-movement-grid {
  display: grid;
  grid-template-columns: 1.3fr .8fr .9fr auto;
  gap: 8px;
}
.line-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.line-actions .btn {
  padding: 8px 10px;
  font-size: 12px;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
}
.status-pill.offline {
  color: #9a5a00;
  border-color: rgba(198,137,26,0.35);
  background: rgba(198,137,26,0.12);
}
.status-pill.online {
  color: #0f7c58;
  border-color: rgba(15,124,88,0.32);
  background: rgba(15,124,88,0.10);
}
.history-item-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.history-item-actions .btn {
  padding: 7px 10px;
  font-size: 12px;
}
.order-note { margin-top: 10px; }
.recent-sales { margin-top: 18px; }
.sales-history { margin-top: 18px; }
.sales-history.standalone { margin-top: 0; }
.history-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.history-shell .section-title {
  margin-bottom: 14px;
}
.history-tools {
  display: grid;
  grid-template-columns: 1fr 170px 160px;
  gap: 10px;
  margin-bottom: 12px;
}
.history-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.daily-dashboard {
  margin-bottom: 16px;
}
.summary-card {
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: linear-gradient(140deg, var(--surface), var(--surface-2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.38);
}
body.dark .summary-card {
  box-shadow: none;
}
.summary-card .summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}
.summary-card .summary-value {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 700;
}
.summary-card .summary-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}
.recent-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.recent-item:last-child { border-bottom: none; }
.history-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-item button {
  padding: 8px 12px;
}
.empty {
  min-height: 140px;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: rgba(248,242,232,0.6);
}
.scan-btn {
  white-space: nowrap;
}
body:not(.app-ready) .mobile-cartbar,
body:not(.app-ready) .mobile-cart-toggle,
body:not(.app-ready) .mobile-quickbar {
  display: none !important;
}
.mobile-cartbar {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 70;
  padding: 12px;
  border-radius: 18px;
  background: rgba(25,29,34,0.96);
  color: #fff;
  box-shadow: 0 18px 40px rgba(0,0,0,0.26);
  backdrop-filter: blur(10px);
}
body:not(.dark) .mobile-cartbar {
  background: rgba(26,60,58,0.96);
}
.mobile-cart-toggle {
  display: none;
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 71;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 18px 40px rgba(0,0,0,0.28);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transform: translateY(0) scale(1);
  opacity: 1;
  transition: transform .24s ease, opacity .24s ease, box-shadow .24s ease, background .24s ease;
}
.mobile-cart-toggle-icon {
  font-size: 22px;
  line-height: 1;
}
.mobile-cart-toggle-count {
  position: absolute;
  top: -4px;
  right: -2px;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}
.mobile-cart-toggle.active {
  background: linear-gradient(135deg, #444, #222);
  transform: translateY(-110px) scale(0.96);
}
.mobile-cart-toggle.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px) scale(0.92);
}
.mobile-cartbar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.mobile-cartbar-meta {
  font-size: 12px;
  color: rgba(255,255,255,0.78);
}
.mobile-cartbar-total {
  font-size: 22px;
  font-weight: 700;
}
.mobile-cartbar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mobile-cash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.mobile-cash-field .label {
  color: rgba(255,255,255,0.76);
}
.mobile-cash-field .input {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
  color: #fff;
}
.mobile-cash-field .input[readonly] {
  opacity: 0.9;
}
.mobile-cash-note {
  margin-bottom: 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.76);
}
.mobile-cash-note.insufficient {
  color: #ff9b8f;
}
.mobile-cartbar .btn {
  padding: 13px 14px;
}
.mobile-cartbar.is-mobile {
  display: block;
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
  transition: opacity .28s ease, transform .28s ease;
}
.mobile-cartbar.is-mobile.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
#confirmModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,60,58,0.4);
  backdrop-filter: blur(4px);
  z-index: 88;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#confirmModal.open { display: flex; }
.confirm-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
}
.confirm-amount {
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  margin: 10px 0 4px;
}
.confirm-meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}
#scannerModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26,60,58,0.4);
  backdrop-filter: blur(4px);
  z-index: 80;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#scannerModal.open { display: flex; }
.scanner-card {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.history-modal-card {
  width: min(720px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  max-height: 88vh;
  overflow: auto;
}
.history-lines {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.history-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.history-line:last-child { border-bottom: none; }
#scanner-video-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
#scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#scanner-status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}
#toast {
  display: none;
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(29,27,24,0.94);
  color: #fff;
  z-index: 95;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  #toast { bottom: 88px; }
}
#toast.success { background: rgba(58,158,150,0.96); }
#toast.error { background: rgba(217,79,67,0.96); }
#toast.info { background: rgba(26,60,58,0.94); }
@media (max-width: 1023px) {
  .app-shell.is-ready { display: block; padding: 12px 12px 92px; }
  .pos-sidebar { display: none; }
  .layout { grid-template-columns: 1fr; }
  .shopify-browser-panel, .shopify-order-panel { min-height: auto; }
  .product-grid { max-height: none; overflow: visible; }
  .search-row { grid-template-columns: minmax(0, 1fr) minmax(160px, .8fr) auto 120px; }
  .category-browser { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
  .stock-movement-grid { grid-template-columns: 1fr 1fr; }
  .favorite-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .all-products-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .product-head,
  .product-row { grid-template-columns: 42px minmax(0, 2fr) minmax(0, .8fr) minmax(0, .9fr) minmax(0, .75fr) minmax(70px, .5fr) minmax(88px, .65fr); }
  .product-main { grid-template-columns: 64px minmax(0, 1fr); }
  .product-thumb { width: 64px; height: 64px; }
}
@media (max-width: 1180px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .topbar-actions > * { min-width: 0; }
  .cashier-pill { max-width: 100%; overflow-wrap: anywhere; }
  .toolbar-group { flex-wrap: wrap; }
}
@media (max-width: 980px) {
  .topbar { flex-wrap: wrap; align-items: flex-start; }
  .topbar-store { width: 100%; }
}
@media (max-width: 640px) {
  .layout { grid-template-columns: 1fr !important; }
  #products-panel { min-height: auto; }
}
@media (max-width: 640px) {
  .app-shell.is-ready { padding: 10px; }
  .shell-card { padding: 12px; }
  .mobile-switcher { display: block; }
  .view-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }
  .search-row, .checkout-grid, .pagination-bar { grid-template-columns: 1fr; }
  .quick-qty-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .quick-qty-custom { grid-template-columns: 1fr; }
  .stock-movement-grid { grid-template-columns: 1fr; }
  .product-tools { grid-template-columns: 1fr; }
  .history-tools { grid-template-columns: 1fr; }
  .history-summary { grid-template-columns: 1fr 1fr; }
  .parent-strip,
  .category-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: visible;
  }
  .parent-chip,
  .category-chip {
    width: 100%;
    min-width: 0;
    text-align: center;
  }
  .stats {
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    overflow: auto;
    padding-bottom: 2px;
  }
  .stat { min-width: 110px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar-actions { width: 100%; justify-content: stretch; flex-wrap: wrap; }
  .toolbar-group { width: 100%; justify-content: center; min-width: 0; }
  .cashier-pill { width: 100%; text-align: center; }
  .panel { padding: 12px; }
  .favorite-strip {
    display: grid;
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .favorite-btn { min-width: 0; width: 100%; grid-template-columns: 56px minmax(0, 1fr); }
  .favorite-thumb { width: 56px; height: 56px; }
  .all-products-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .all-product-card { padding: 9px; }
  .all-product-actions { grid-template-columns: 1fr; }
  .search-row .btn, .search-row .select, .search-row .input, .pagination-bar .btn { min-height: 48px; min-width: 0; width: 100%; }
  .product-head { display: none; }
  .product-row {
    grid-template-columns: 40px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
    align-items: start;
  }
  .product-row > div { min-width: 0; }
  .product-row > div:nth-child(2) { grid-column: 2; }
  .product-row > div:nth-child(3),
  .product-row > div:nth-child(4),
  .product-row > div:nth-child(5) { grid-column: 2; }
  .product-row > div:nth-child(6) { grid-column: 2; }
  .product-row > div:nth-child(7) { grid-column: 2; }
  .product-main {
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: start;
  }
  .product-thumb {
    width: 72px;
    height: 72px;
  }
  .product-stock strong,
  .product-sku strong,
  .product-price {
    font-size: 15px;
  }
  .qty-mini {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    text-align: center;
  }
  .row-add {
    min-width: 0;
    width: 100%;
    min-height: 44px;
  }
  .cart-list { max-height: none; }
  .cart-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .qty-controls { gap: 8px; }
  .icon-btn {
    width: 38px;
    height: 38px;
    font-weight: 700;
  }
  .qty-input {
    width: 96px;
    min-height: 38px;
  }
  .cart-total {
    position: static;
    bottom: auto;
    background: var(--surface);
    padding-bottom: 10px;
  }
  #cart-panel,
  #cart-panel.mobile-open {
    display: none !important;
    opacity: 0;
    transform: none;
  }
  .mobile-cash-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 420px) {
  .topbar h1 { font-size: 22px; }
  .history-item { flex-direction: column; align-items: flex-start; }
  .history-item > div:last-child { width: 100%; text-align: left !important; }
  .history-item-actions { justify-content: flex-start; width: 100%; }
  .history-item-actions .btn { flex: 1 1 calc(50% - 6px); min-width: 120px; }
  .quick-qty-btn { min-height: 42px; }
}

/* ============================================================
   RESPONSIVE IMPROVEMENTS: TABLET + MOBILE
   ============================================================ */

/* --- Phone (≤640px): hide cart panel, show quickbar instead --- */
@media (max-width: 640px) {
  .mobile-switcher { display: flex !important; }
  #cart-panel,
  #cart-panel.mobile-open {
    display: none !important;
    opacity: 0;
    transform: none;
  }
}

/* --- Tablet landscape (769-980px): restore 2-column layout --- */
@media (min-width: 769px) and (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 60%) minmax(0, 40%) !important; }
  #cart-panel {
    display: block !important;
    opacity: 1 !important;
    transform: none !important;
  }
  .mobile-cart-toggle { display: none !important; }
  .cart-list { max-height: 320px; overflow-y: auto; }
  .cart-total {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding-bottom: 10px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
  }
  .search-row { grid-template-columns: 1fr auto 120px !important; }
  #barcode-search { display: none; }
}

/* --- Mobile (≤640px): comprehensive improvements --- */
@media (max-width: 640px) {
  .topbar {
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 8px;
    margin-bottom: 10px;
  }
  .topbar > div:first-child { flex: 1; min-width: 0; overflow: hidden; }
  .topbar h1 {
    font-size: 15px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar p { display: none !important; }
  .topbar-actions {
    width: auto !important;
    flex-wrap: nowrap !important;
    justify-content: flex-end !important;
    gap: 4px;
    flex-shrink: 0;
  }
  .cashier-pill,
  #network-pill,
  .topbar-actions .toolbar-group,
  .topbar-actions .mini-icon-btn,
  .topbar-actions .btn-secondary {
    display: none !important;
  }
  .topbar-actions .btn-danger {
    padding: 8px 10px !important;
    font-size: 11px !important;
    min-height: 36px !important;
  }
  .parent-strip,
  .category-strip,
  .quick-qty-bar {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    grid-template-columns: unset !important;
  }
  .parent-strip::-webkit-scrollbar,
  .category-strip::-webkit-scrollbar,
  .quick-qty-bar::-webkit-scrollbar { display: none; }
  .parent-chip, .category-chip {
    flex-shrink: 0 !important;
    width: auto !important;
    min-width: unset !important;
    text-align: left !important;
    min-height: 42px;
  }
  .quick-qty-btn {
    flex-shrink: 0;
    min-width: 58px !important;
    min-height: 48px !important;
    font-size: 14px;
    border-radius: 12px;
  }
  .quick-qty-custom {
    flex-shrink: 0;
    width: 132px;
    min-width: 132px;
    display: grid !important;
    grid-template-columns: 1fr auto;
    gap: 6px;
  }
  .search-row {
    grid-template-columns: 1fr auto !important;
    grid-template-rows: auto auto auto;
    gap: 8px;
  }
  #product-search { grid-column: 1 / 3; grid-row: 1; min-height: 48px; font-size: 16px; }
  #barcode-search { grid-column: 1; grid-row: 2; }
  .scan-btn { grid-column: 2; grid-row: 2; padding: 0 12px !important; }
  #stock-filter { grid-column: 1 / 3; grid-row: 3; }
  .search-row .btn, .search-row .select, .search-row .input { min-height: 48px !important; width: 100%; }
  .btn { min-height: 44px; }
  .icon-btn { width: 44px !important; height: 44px !important; border-radius: 10px !important; font-size: 15px; }
  .denom-btn { min-height: 46px; font-size: 13px; }
  .mini-btn { padding: 8px 12px !important; font-size: 12px !important; min-height: 36px; }
  .jump-chip { min-height: 38px; padding: 8px 14px; }
  .favorite-star { width: 44px !important; height: 44px !important; }
  .row-add { min-height: 48px !important; font-size: 14px; }
  .qty-mini { min-height: 48px !important; font-size: 16px !important; text-align: center; }
  .all-products-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .all-product-card { padding: 10px; }
  .cart-name { font-size: 15px; }
  .qty-input { min-height: 44px; }
  .history-summary { grid-template-columns: 1fr 1fr !important; }
  .stock-movement { padding: 8px 10px; }
  .floating-controls {
    top: auto !important;
    right: 10px !important;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
    left: auto !important;
    z-index: 73 !important;
  }
  .mobile-cartbar.open ~ .floating-controls,
  .mobile-cartbar.open + .floating-controls {
    display: none !important;
  }
  .floating-controls-menu {
    margin-bottom: 6px;
  }
  .mobile-cartbar {
    left: 10px;
    right: 10px;
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
    top: auto;
    border-radius: 18px;
    padding: 12px;
    max-height: 56vh;
    min-height: 0;
    overflow-y: auto;
    z-index: 72;
  }
  .mobile-cartbar-top {
    position: sticky;
    top: 0;
    z-index: 2;
    margin-bottom: 8px;
    padding-bottom: 8px;
    background: inherit;
  }
  .mobile-cash-grid,
  .mobile-cartbar-actions {
    grid-template-columns: 1fr;
  }
  .mobile-cartbar-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    padding-top: 10px;
    background: inherit;
  }
}

/* --- Touch devices: tap feedback & remove broken hover effects --- */
@media (hover: none) and (pointer: coarse) {
  .btn:active            { transform: scale(0.97) !important; }
  .denom-btn:active      { background: var(--accent) !important; color: #fff !important; border-color: var(--accent) !important; }
  .category-chip:active,
  .parent-chip:active,
  .jump-chip:active      { opacity: 0.7; }
  .all-product-card:active { transform: scale(0.98); }
  .favorite-btn:active   { transform: scale(0.98); }

  /* Remove desktop-only hover effects */
  .btn:hover             { transform: none; }
  .btn-primary:hover     { filter: none; }
  .category-card:hover   { transform: none; box-shadow: none; }
  .favorite-btn:hover    { transform: none; box-shadow: none; }
  .btn-secondary:hover   { background: var(--surface-2); }
}

/* --- Floating controls: cleaner on all mobile --- */
@media (max-width: 980px) {
  .mini-btn { padding: 7px 10px; font-size: 11px; }
  .floating-controls {
    top: 10px;
    right: 10px;
    gap: 6px;
    padding: 7px;
  }
}

/* --- Report Toast --- */
#reportToast {
  position: fixed;
  top: 72px;
  right: 16px;
  width: 300px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px 12px;
  z-index: 350;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  animation: reportSlideIn 0.22s cubic-bezier(.22,.68,0,1.2);
}
@keyframes reportSlideIn {
  from { transform: translateX(330px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
.report-toast-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
}
.report-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 15px;
  color: var(--muted);
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
}
.report-close:hover { background: var(--surface-2); }
.report-highlight {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
  margin: 2px 0 10px;
  letter-spacing: -0.5px;
}
.report-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}
.report-row:last-child { border-bottom: none; }
.report-row strong { font-size: 14px; font-weight: 600; color: var(--text); }
.report-warn { color: var(--warning, #f59e0b) !important; }
.report-warn strong { color: var(--warning, #f59e0b) !important; }
.report-btn { font-size: 12px; padding: 5px 10px; }

/* --- Toast warning type --- */
#toast.warning {
  background: #f59e0b;
  color: #fff;
}

/* --- Daily Dashboard collapsible --- */
.daily-dashboard-details { margin-bottom: 8px; }
.daily-dashboard-details[open] .history-summary { margin-top: 8px; }
.daily-dashboard-summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.daily-dashboard-summary::-webkit-details-marker { display: none; }
.daily-dashboard-summary::before {
  content: '▶';
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.18s;
  display: inline-block;
}
.daily-dashboard-details[open] .daily-dashboard-summary::before {
  transform: rotate(90deg);
}

/* --- Stock Movement collapsible --- */
.stock-movement-details {
  margin-bottom: 10px;
}
.stock-movement-details[open] .stock-movement-grid {
  margin-top: 10px;
}
.stock-movement-summary {
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stock-movement-summary::-webkit-details-marker { display: none; }
.stock-movement-summary::before {
  content: '▶';
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.18s;
  display: inline-block;
}
.stock-movement-details[open] .stock-movement-summary::before {
  transform: rotate(90deg);
}

/* --- Payment method big buttons --- */
.payment-main-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 6px;
}
.payment-btn-main {
  min-height: 52px;
  font-size: 16px;
  font-weight: 700;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.payment-btn-main.active {
  background: var(--accent);
  border-color: var(--accent-2);
  color: #fff;
}
.payment-btn-main:not(.active):hover {
  border-color: var(--accent);
  background: rgba(129,216,208,0.15);
}
.payment-rare-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.payment-btn-rare {
  min-height: 34px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.payment-btn-rare.active {
  background: var(--surface-2);
  border-color: var(--accent);
  color: var(--text);
}
.payment-btn-rare:hover { color: var(--text); border-color: var(--accent); }

/* --- Exact change button (พอดี) --- */
.denom-exact {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent-2) !important;
  font-weight: 700;
  font-size: 15px;
  min-height: 52px;
  flex: 1.5;
}
.denom-exact:hover { background: var(--accent-2) !important; }

/* --- Bigger cart qty controls on desktop --- */
.icon-btn {
  width: 36px !important;
  height: 36px !important;
}

/* --- PromptPay QR --- */
#transfer-qr-section {
  text-align: center;
  padding: 14px 0 8px;
  border-top: 1px solid var(--border);
}
#promptpay-qr-canvas {
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.qr-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  letter-spacing: 0.04em;
}

/* ============================================================
   MOBILE QUICKBAR — persistent bottom action bar (phone ≤640px)
   ============================================================ */
.mobile-quickbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 80;
  background: var(--surface);
  border-top: 2px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.13);
  padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  gap: 8px;
  align-items: stretch;
  height: auto;
}

/* --- Left: tappable summary (count + total) --- */
.mqb-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  gap: 1px;
  text-align: left;
  min-width: 0;
  cursor: pointer;
}
.mqb-meta {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.2;
}
.mqb-amount {
  font-size: 19px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.3px;
}

/* --- Middle: เงินสด / โอน stacked buttons --- */
.mqb-payments {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
}
.mqb-pm {
  min-height: 0;
  flex: 1;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.mqb-pm.active {
  background: var(--accent);
  border-color: var(--accent-2);
  color: #fff;
}

/* --- Right: Charge button --- */
.mqb-charge {
  flex-shrink: 0;
  min-width: 70px;
  background: var(--accent-3);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 800;
  padding: 0 14px;
  cursor: pointer;
  transition: background .12s;
  letter-spacing: -0.2px;
}
.mqb-charge:active { background: #2d8079; }

body.dark .mobile-quickbar { background: var(--surface); border-top-color: var(--border); }
body.dark .mqb-info { background: var(--surface-2); }

/* mobile-quickbar active state: cart-open — slightly dim charge btn */
.mobile-quickbar.cart-open .mqb-charge { opacity: 0.6; }

/* Mobile denom bar inside cartbar */
.mobile-denom-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.mobile-denom-bar .denom-btn {
  flex: 1 1 calc(33% - 6px);
  min-height: 44px;
  font-size: 14px;
}
.mobile-denom-bar .denom-exact {
  flex: 2 1 calc(66% - 6px);
  font-size: 15px;
  min-height: 44px;
}

/* ============================================================
   PHONE ≤640px — quickbar visible, single column products
   ============================================================ */
@media (max-width: 640px) {
  .mobile-quickbar { display: flex; }
  body, body.app-ready { padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important; }
  .app-shell.is-ready { padding-bottom: 0 !important; }
}

/* ============================================================
   TABLET PORTRAIT 641px–768px — side-by-side, no quickbar
   ============================================================ */
@media (min-width: 641px) and (max-width: 768px) {
  /* Show both panels side by side */
  .layout {
    display: grid !important;
    grid-template-columns: 58% 42% !important;
    gap: 12px;
    align-items: start;
  }
  #cart-panel {
    display: flex !important;
    flex-direction: column;
    opacity: 1 !important;
    transform: none !important;
    position: sticky;
    top: 12px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
  }
  .mobile-quickbar { display: none !important; }
  .mobile-cart-toggle { display: none !important; }
  .mobile-switcher { display: none !important; }
  .cart-list { max-height: 260px; overflow-y: auto; }
  .cart-total { position: sticky; bottom: 0; background: var(--surface); padding-bottom: 8px; }
  /* Tighten up the search row */
  .search-row { grid-template-columns: 1fr auto 100px !important; }
  #barcode-search { display: none; }
  /* Bigger product cards in the all-products grid */
  .all-products-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  /* Payment buttons full width on tablet portrait cart */
  .payment-main-btns .payment-btn-main { min-height: 48px; font-size: 14px; }
  /* No body bottom padding needed */
  body { padding-bottom: 0 !important; }
}

/* ============================================================
   TOUCH DEVICE — quickbar tap feedback
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
  .mqb-info:active  { opacity: 0.8; }
  .mqb-pm:active    { opacity: 0.75; }
  .mqb-charge:active { background: #2d8079 !important; transform: scale(0.97); }
  .mobile-denom-bar .denom-btn:active { background: var(--accent) !important; color: #fff !important; }
}
