/* =========================================================================
   Grocery Manager Lite — Design System
   MD3-inspired tokens + components. Signature motif: receipt-perforation
   dividers and a torn-edge sheet grabber, tying the UI back to a physical
   till receipt — the one object every grocery sale produces.
   ========================================================================= */

@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Inter:wght@400;500;600;700&display=swap");

:root {
  /* ---- Color: surfaces & text ---- */
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-alt: #f8faf9;
  --text: #161a18;
  --text-muted: #667169;
  --border: #e3e8e4;

  /* ---- Color: brand (kept green — grocery/fresh produce/money) ---- */
  --primary: #16a34a;
  --primary-dark: #116534;
  --primary-light: #22c55e;
  --on-primary: #ffffff;
  --primary-container: #dcfce7;
  --on-primary-container: #0c4a24;

  /* ---- Color: semantic ---- */
  --danger: #dc2626;
  --danger-container: #fee2e2;
  --warning: #d97706;
  --warning-container: #fef3c7;
  --info: #2563eb;
  --info-container: #dbeafe;

  /* ---- Elevation (MD3-style layered shadows) ---- */
  --elevation-1: 0 1px 2px rgba(20, 30, 22, 0.06), 0 1px 3px rgba(20, 30, 22, 0.08);
  --elevation-2: 0 2px 6px rgba(20, 30, 22, 0.07), 0 4px 12px rgba(20, 30, 22, 0.07);
  --elevation-3: 0 8px 24px rgba(20, 30, 22, 0.14);
  --shadow: var(--elevation-1);

  /* ---- Shape ---- */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --radius-full: 999px;
  --nav-height: 66px;

  /* ---- Motion ---- */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 120ms;
  --dur-medium: 220ms;

  /* ---- Type ---- */
  --font-display: "Plus Jakarta Sans", "Segoe UI", Roboto, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", Roboto, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #10130f;
  --surface: #1a1f1a;
  --surface-alt: #20261f;
  --text: #eef2ee;
  --text-muted: #93a196;
  --border: #2b332b;

  --primary: #34d174;
  --primary-dark: #16a34a;
  --primary-light: #4ade80;
  --on-primary: #06210f;
  --primary-container: #123821;
  --on-primary-container: #86efac;

  --danger: #f87171;
  --danger-container: #3d1414;
  --warning: #fbbf24;
  --warning-container: #3a2a08;
  --info: #60a5fa;
  --info-container: #10233d;

  --elevation-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.3);
  --elevation-2: 0 2px 8px rgba(0, 0, 0, 0.4), 0 6px 16px rgba(0, 0, 0, 0.35);
  --elevation-3: 0 10px 28px rgba(0, 0, 0, 0.55);
  --shadow: var(--elevation-1);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }

html.theme-transition,
html.theme-transition * {
  transition: background-color var(--dur-medium) var(--ease-standard),
              color var(--dur-medium) var(--ease-standard),
              border-color var(--dur-medium) var(--ease-standard);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.45;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 6px;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); }

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--elevation-1);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16.5px;
  letter-spacing: -0.01em;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 21px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}
.icon-btn:active {
  background: var(--border);
  transform: scale(0.94);
}

.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
  margin-right: 4px;
  box-shadow: 0 0 0 3px var(--primary-container);
}
.online-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-container);
}

main.app-content {
  padding: 16px 16px 28px;
  max-width: 480px;
  margin: 0 auto;
  animation: viewFadeIn var(--dur-medium) var(--ease-standard);
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--elevation-1);
  padding: 16px;
  border: 1px solid var(--border);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.stat-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 14px 15px;
  box-shadow: var(--elevation-1);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow var(--dur-fast) var(--ease-standard);
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--text-muted);
  opacity: 0.25;
}
.stat-card.accent-green::before { background: var(--primary); opacity: 1; }
.stat-card.accent-red::before { background: var(--danger); opacity: 1; }
.stat-card.accent-amber::before { background: var(--warning); opacity: 1; }

.stat-card .label {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-card .value {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.stat-card.accent-green .value { color: var(--primary); }
.stat-card.accent-red .value { color: var(--danger); }
.stat-card.accent-amber .value { color: var(--warning); }

.section-title {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 22px 0 10px;
}

/* Receipt-perforation divider — the signature motif */
.section-divider {
  height: 8px;
  margin: 18px 0;
  background-image: radial-gradient(circle, var(--border) 1.6px, transparent 1.6px);
  background-size: 10px 8px;
  background-position: center;
  background-repeat: repeat-x;
  opacity: 0.9;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.quick-actions button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 4px 10px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
}
.quick-actions button i {
  font-size: 19px;
  color: var(--primary);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-container);
  border-radius: var(--radius-full);
}
.quick-actions button:active {
  transform: scale(0.95);
}

.chart-card { margin-bottom: 16px; }
.chart-card canvas { max-height: 200px; }

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.05);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 600;
  position: relative;
}

.bottom-nav a i {
  font-size: 19px;
  padding: 3px 16px;
  border-radius: var(--radius-full);
  transition: background-color var(--dur-medium) var(--ease-standard), color var(--dur-medium) var(--ease-standard);
}

.bottom-nav a.active {
  color: var(--primary);
}
.bottom-nav a.active i {
  background: var(--primary-container);
  color: var(--primary);
}

/* ---------- FAB ---------- */
.fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 16px);
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: var(--elevation-3);
  cursor: pointer;
  z-index: 90;
  transition: transform var(--dur-fast) var(--ease-standard), opacity var(--dur-medium) var(--ease-standard);
}
.fab:active { transform: scale(0.92); }
.fab.hidden { display: none !important; }

/* ---------- Sidebar Drawer ---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 11, 0.45);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-medium) var(--ease-standard);
}
.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  left: -85%;
  width: 80%;
  max-width: 320px;
  height: 100%;
  background: var(--surface);
  z-index: 200;
  transition: left 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  overflow-y: auto;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
}
.drawer.open { left: 0; }

.drawer-header {
  padding: 26px 18px 18px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--on-primary);
}
.drawer-header .drawer-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 10px;
}
.drawer-header .shop-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
}
.drawer-header .owner-name {
  font-size: 12px;
  opacity: 0.85;
}

.drawer-menu { padding: 6px 0; flex: 1; }
.drawer-menu a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background-color var(--dur-fast) var(--ease-standard);
}
.drawer-menu a:active { background: var(--surface-alt); }
.drawer-menu a i {
  width: 22px;
  text-align: center;
  color: var(--primary);
  font-size: 17px;
}

.drawer-footer {
  padding: 14px 18px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid var(--border);
}

/* ---------- Login screen ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: var(--bg);
}
.login-screen .app-title {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 800;
  margin-top: 14px;
  letter-spacing: -0.01em;
}
.login-screen .tagline {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 30px;
}
.pin-input {
  width: 100%;
  max-width: 260px;
  font-size: 24px;
  letter-spacing: 10px;
  text-align: center;
  padding: 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  margin-bottom: 12px;
  transition: border-color var(--dur-fast) var(--ease-standard);
}
.pin-input:focus { border-color: var(--primary); outline: none; }

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 20px;
  font-weight: 700;
  font-size: 14px;
  width: 100%;
  max-width: 260px;
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-standard), background-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
  box-shadow: var(--elevation-1);
}
.btn-primary:active {
  background: var(--primary-dark);
  transform: scale(0.98);
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 20px;
  font-weight: 700;
  font-size: 14px;
  width: 100%;
  cursor: pointer;
}
.btn-outline:active { background: var(--surface-alt); }

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  min-height: 18px;
}

.hidden { display: none !important; }

.storage-meter-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
  margin-top: 6px;
}
.storage-meter-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}
.storage-meter-fill.warning { background: var(--warning); }
.storage-meter-fill.danger { background: var(--danger); }

/* ---------- Modal bottom sheet ---------- */
.modal-sheet {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 11, 0.5);
  z-index: 300;
  display: flex;
  align-items: flex-end;
}
.modal-sheet-inner {
  background: var(--surface);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 10px 18px calc(24px + env(safe-area-inset-bottom));
  animation: slideUp var(--dur-medium) var(--ease-standard);
}
.modal-sheet-inner::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--border);
  margin: 4px auto 14px;
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16.5px;
  margin-bottom: 14px;
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 12px 0 5px;
}
.form-field {
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--dur-fast) var(--ease-standard);
}
.form-field:focus { border-color: var(--primary); outline: none; }

#barcode-scanner-region video {
  width: 100% !important;
  border-radius: var(--radius);
}

/* ---------- POS product grid ---------- */
.pos-product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
@media (min-width: 480px) {
  .pos-product-grid { grid-template-columns: repeat(4, 1fr); }
}
.pos-product-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  text-align: center;
  transition: border-color var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}
.pos-product-card:active { transform: scale(0.96); }
.pos-product-card:hover { border-color: var(--primary); }
.pos-product-card.out-of-stock {
  opacity: 0.5;
  cursor: not-allowed;
}
.pos-product-card-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-alt);
  margin-bottom: 6px;
}
.pos-product-card-img img { width: 100%; height: 100%; object-fit: cover; }
.pos-product-card-name {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 30px;
}
.pos-product-card-price {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary);
  margin-top: 2px;
}
.pos-product-card-stock {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.report-period-btn {
  flex-shrink: 0;
  padding: 9px 18px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}
.report-period-btn.active-period {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

/* ---------- Search / filter bar ---------- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.search-bar .form-field { flex: 1; }
.toolbar-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.toolbar-row .icon-btn {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}

/* ---------- Category chips ---------- */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  padding: 7px 15px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}
.chip-active {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}

/* ---------- List rows ---------- */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  box-shadow: var(--elevation-1);
}
.list-row-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: var(--radius-sm);
  background: var(--primary-container);
  color: var(--on-primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  overflow: hidden;
}
.list-row-icon img { width: 100%; height: 100%; object-fit: cover; }
.list-row-body { flex: 1; min-width: 0; }
.list-row-title { font-weight: 700; font-size: 14px; }
.list-row-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.list-row-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-success { background: var(--primary-container); color: var(--on-primary-container); }
.badge-danger { background: var(--danger-container); color: var(--danger); }
.badge-warning { background: var(--warning-container); color: var(--warning); }
.badge-info { background: var(--info-container); color: var(--info); }
.badge-neutral { background: var(--surface-alt); color: var(--text-muted); border: 1px solid var(--border); }

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 40px;
  color: var(--border);
  display: block;
  margin-bottom: 12px;
}
.empty-state .empty-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  margin-bottom: 4px;
}
.empty-state .empty-sub {
  font-size: 12.5px;
  max-width: 260px;
  margin: 0 auto;
}

/* ---------- Skeleton loaders ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-alt) 37%, var(--border) 63%);
  background-size: 400% 100%;
  animation: skeletonShimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeletonShimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-line { height: 12px; margin-bottom: 8px; width: 100%; }
.skeleton-line.short { width: 40%; }
.skeleton-card { height: 64px; border-radius: var(--radius); margin-bottom: 8px; }

/* ---------- Toast / snackbar ---------- */
#toast-container {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 500;
  pointer-events: none;
  padding: 0 16px;
}
.toast {
  pointer-events: auto;
  max-width: 420px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--text);
  color: var(--bg);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--elevation-3);
  animation: toastIn var(--dur-medium) var(--ease-standard);
}
.toast.toast-leaving { animation: toastOut var(--dur-medium) var(--ease-standard) forwards; }
.toast i { font-size: 17px; flex-shrink: 0; }
.toast.toast-success i { color: var(--primary-light); }
.toast.toast-error i { color: #f87171; }
.toast.toast-warning i { color: #fbbf24; }
.toast.toast-info i { color: #60a5fa; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(10px) scale(0.96); }
}

/* ---------- Scrollbar (desktop testing) ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ---------- POS Quantity Input ---------- */
.pos-qty-input {
  width: 60px;
  height: 32px;
  padding: 4px 6px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
  -moz-appearance: textfield;
}

.pos-qty-input::-webkit-outer-spin-button,
.pos-qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pos-qty-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.pos-qty-input:invalid {
  border-color: var(--danger);
}

/* Mobile responsive adjustments */
@media (max-width: 480px) {
  .pos-qty-input {
    width: 52px;
    height: 30px;
    font-size: 15px;
    padding: 2px 4px;
  }
}

/* Quantity display in cart */
.qty-display {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------
 * Sales History / Units / Returns / Day End additions
 * ------------------------------------------------------------- */

/* Quick-quantity chip row (kg/g/L/ml presets + Custom) — compact,
   horizontal, wraps naturally instead of a tall fixed grid (Phase 7/8). */
.quick-qty-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.quick-qty-row .qty-chip {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 5px 4px;
  font-size: 11px;
  white-space: nowrap;
  text-align: center;
}

/* Product form unit picker (Phase 6): grouped chips instead of a tall select */
.unit-group { margin-bottom: 10px; }
.unit-group-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.unit-group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.unit-chip {
  min-width: 52px;
  text-align: center;
}

/* Sales History summary grid — 2-up on phones, denser than default stat-grid */
.sh-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Day End line items */
.day-end-line {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 4px 0;
}
.day-end-line span:first-child { color: var(--text-muted); }
.day-end-line span:last-child { font-weight: 600; }

/* Custom quantity modal */
.custom-qty-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.custom-qty-input-row input {
  flex: 1;
  font-size: 20px;
  text-align: center;
  font-weight: 700;
}
.custom-qty-input-row .unit-suffix {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 40px;
}

@media (max-width: 380px) {
  .sh-summary-grid { grid-template-columns: 1fr 1fr; }
}