:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f5;
  --panel: #ffffff;
  --ink: #09090b;
  --muted: #71717a;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --primary: #18181b;
  --primary-dark: #09090b;
  --primary-light: #f4f4f5;
  --primary-fg: #ffffff;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --info: #2563eb;
  --info-bg: #eff6ff;
  --shadow: 0 1px 3px rgba(0, 0, 0, .05), 0 4px 12px rgba(0, 0, 0, .03);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .07);
  --radius: 8px;
  --radius-sm: 6px;
  --login-bg: #f4f4f5;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --panel: #18181b;
  --ink: #fafafa;
  --muted: #a1a1aa;
  --line: #27272a;
  --line-strong: #3f3f46;
  --primary: #ffffff;
  --primary-dark: #f4f4f5;
  --primary-light: #27272a;
  --primary-fg: #09090b;
  --danger: #ef4444;
  --danger-bg: #450a0a;
  --warn: #f59e0b;
  --warn-bg: #451a03;
  --ok: #22c55e;
  --ok-bg: #052e16;
  --info: #3b82f6;
  --info-bg: #172554;
  --shadow: 0 4px 20px rgba(0, 0, 0, .5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .7);
  --radius: 8px;
  --radius-sm: 6px;
  --login-bg: #09090b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  transition: background-color 0.2s ease, color 0.2s ease;
}

button, input, select { font: inherit; }

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

button:active { transform: translateY(1px); }

/* ── Top Navigation Bar ─────────────────────────────────────────────── */
.topbar {
  height: 68px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 0 20px;
  background: var(--panel);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  position: sticky;
  top: 0;
  z-index: 200;
  gap: 24px;
}

[data-theme="dark"] .topbar {
  background: #18181b;
  color: #fafafa;
  border-bottom: 1px solid #27272a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.topbar-left  { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.topbar-center { display: flex; align-items: center; justify-content: center; }
.topbar-right  { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex-shrink: 0; }

/* Divider between brand and nav */
.topbar-divider {
  width: 1px;
  height: 28px;
  background: var(--line);
  flex-shrink: 0;
}

.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--line);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 0;
}
.mobile-nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
  border-radius: 2px;
}

/* ── Brand ── */
.brand {
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: #18181b;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 18px;
  font-weight: 900;
  color: #ffffff;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  letter-spacing: -1px;
}

[data-theme="dark"] .brand-logo {
  background: #27272a;
  border: 1px solid #3f3f46;
  color: #fafafa;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text span {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.3px;
}

.brand-text small {
  font-size: 9.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* ── Nav Pills ── */
nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  transition: background 120ms, color 120ms;
  display: flex;
  align-items: center;
  gap: 7px;
  letter-spacing: 0.1px;
}

.nav-link .nav-icon {
  font-size: 15px;
  line-height: 1;
  opacity: 0.85;
}

.nav-link:hover {
  background: var(--line);
  color: var(--ink);
}

.nav-link:hover .nav-icon { opacity: 1; }

.nav-link.active {
  background: #e4e4e7;
  color: #18181b !important;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px #d4d4d8;
}

[data-theme="dark"] .nav-link {
  color: var(--muted);
}
[data-theme="dark"] .nav-link:hover {
  background: var(--line);
  color: var(--ink);
}
[data-theme="dark"] .nav-link.active {
  background: #3f3f46;
  color: #fafafa !important;
  box-shadow: inset 0 0 0 1px #52525b;
}

.nav-link.active .nav-icon { opacity: 1; }

/* ── Right Side ── */
.topbar-clock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.topbar-clock #navTime {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: 0.5px;
  font-variant-numeric: tabular-nums;
}

.topbar-clock #navDate {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}

[data-theme="dark"] .topbar-clock #navTime { color: #fff; }
[data-theme="dark"] .topbar-clock #navDate { color: rgba(255,255,255,0.4); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #22c55e;
  flex-shrink: 0;
}

/* ── Theme Toggle Button ── */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  background: var(--line);
  transform: scale(1.05);
}

.logout {
  color: var(--muted);
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
  transition: background 140ms, color 140ms, border-color 140ms;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.logout:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #dc2626;
}

[data-theme="dark"] .logout {
  color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,.1);
}
[data-theme="dark"] .logout:hover {
  background: rgba(239,68,68,.2);
  border-color: rgba(239,68,68,.4);
  color: #fca5a5;
}

main { min-height: calc(100vh - 69px); }

/* ── Login ─────────────────────────────────────────────────────────── */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: var(--login-bg);
  padding: 20px 10px;
}

.login-panel {
  width: min(460px, calc(100vw - 24px));
  background: var(--panel);
  padding: 28px;
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 14px;
}

.login-panel h1 { margin: 0; font-size: 22px; letter-spacing: -0.5px; color: var(--ink); }
.login-panel p { margin: 0 0 4px; color: var(--muted); }
.login-panel label { display: grid; gap: 6px; font-weight: 700; color: var(--ink); }
.login-panel input, .field, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.pin-pad button {
  min-height: 62px;
  background: var(--bg);
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid var(--line);
  transition: all 0.15s ease;
}

.pin-pad button:hover {
  background: var(--line);
}

.pin-pad button:last-child {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
  font-size: 16px;
}

.login-panel button, .primary {
  padding: 12px 16px;
  background: var(--primary);
  color: var(--primary-fg);
}

.login-panel small { color: var(--muted); }
.error { color: var(--danger) !important; font-weight: 700; }

/* ── POS Shell ──────────────────────────────────────────────────────── */
.pos-shell {
  height: calc(100vh - 63px);
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 10px;
  padding: 10px;
  overflow: hidden;
}

.menu-side, .ticket-side, .page-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.menu-side {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  min-width: 0;
  min-height: 0;
}

.ticket-side {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
  min-height: 0;
}

.pos-head, .ticket-head, .panel-head {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pos-head h2, .ticket-head h2, .panel-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
}

.ticket-head small {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
}

/* ── SKU Search Bar ─────────────────────────────────────────────────── */
.sku-search-wrap {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.sku-search-inner {
  display: flex;
  gap: 6px;
  align-items: center;
  background: var(--panel);
  border: 1.5px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  transition: border-color 150ms;
}

.sku-search-inner:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217,119,6,.12);
}

.sku-search-icon { color: var(--muted); font-size: 14px; flex-shrink: 0; }

.sku-search-input {
  flex: 1;
  border: 0;
  outline: none;
  padding: 9px 0;
  font-size: 13.5px;
  background: transparent;
}

.sku-search-clear {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 4px;
}

.sku-search-clear:hover { color: var(--danger); }

/* ── Barcode Button & Scanner ── */
.barcode-scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1.5px solid var(--line);
  color: var(--ink);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.barcode-scan-btn:hover {
  background: var(--line);
  border-color: var(--line-strong);
}

[data-theme="dark"] .barcode-scan-btn {
  background: #18181b;
  border-color: #27272a;
  color: #fafafa;
}

[data-theme="dark"] .barcode-scan-btn:hover {
  background: #27272a;
  border-color: #3f3f46;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 5px;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  transition: all 0.15s ease;
}

.btn-xs:hover {
  background: var(--line);
  border-color: var(--line-strong);
}

.scanner-viewfinder {
  position: relative;
  width: 100%;
  height: 200px;
  background: #09090b;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.scanner-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scanner-reticle {
  position: absolute;
  inset: 16px;
  border: 2px dashed rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  pointer-events: none;
  z-index: 4;
}

.scanner-laser {
  position: absolute;
  left: 5%;
  right: 5%;
  height: 2px;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: scanLineAnim 2s infinite ease-in-out;
  z-index: 5;
}

@keyframes scanLineAnim {
  0% { top: 12%; opacity: 0.7; }
  50% { top: 88%; opacity: 1; }
  100% { top: 12%; opacity: 0.7; }
}

.quick-barcode-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.12s ease;
  font-family: monospace;
}

.quick-barcode-pill:hover {
  background: var(--line);
  border-color: var(--ink);
}

/* ── Category Tabs ──────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 8px 14px;
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--line);
  transition: background 140ms, color 140ms, border-color 140ms;
}

.tab:hover {
  background: var(--line);
  color: var(--ink);
}

.tab.active {
  background: var(--primary);
  color: var(--primary-fg);
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* ── Product Grid ───────────────────────────────────────────────────── */
.item-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
  overflow-y: auto;
  min-height: 0;
}

.menu-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: left;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
  padding: 0;
  min-height: 250px;
}

.menu-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
  border-color: #cbd5e1;
}

.menu-btn-img-wrapper {
  height: 140px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-bottom: 1px solid var(--line);
}

.menu-btn-img-wrapper svg {
  width: 48px !important;
  height: 48px !important;
  color: #94a3b8;
  opacity: 0.6;
}

.menu-btn-content {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.menu-btn strong {
  font-size: 14px;
  color: var(--ink);
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
  line-height: 1.3;
}

.menu-btn .item-sku {
  font-size: 11px;
  color: var(--muted);
  font-family: inherit;
  margin-bottom: 8px;
}

.menu-btn .item-price {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 12px;
}

.menu-btn-stock-status {
  margin-top: auto;
  font-size: 11px;
  font-weight: 600;
  color: #16a34a;
  display: flex;
  align-items: center;
  gap: 4px;
  background: #dcfce7;
  padding: 4px 8px;
  border-radius: 4px;
  align-self: flex-start;
}

.menu-btn-stock-status.low {
  color: #dc2626;
  background: #fee2e2;
}

/* Low stock badge top right */
.stock-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #dcfce7;
  color: #16a34a;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 12px;
  line-height: 1;
}

.stock-badge.low { background: #fee2e2; color: #dc2626; }

/* ── Ticket / Cart ──────────────────────────────────────────────────── */
.ticket-list {
  overflow: auto;
  padding: 6px;
}

.ticket-row {
  display: flex;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}
.ticket-img {
  width: 44px;
  height: 44px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ticket-img svg { width: 22px !important; height: 22px !important; color: #94a3b8; }
.ticket-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ticket-info strong { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.ticket-info small { font-size: 11px; color: var(--muted); font-family: inherit; }
.t-price { font-size: 12px; font-weight: 700; color: var(--ink); margin-top: 2px; }
.ticket-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.t-total { font-size: 13px; font-weight: 800; color: var(--ink); }

.qty-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px;
}
.qty-controls button {
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
}
.qty-controls button:hover { background: var(--bg); color: var(--ink); }
.qty-controls strong { font-size: 13px; min-width: 20px; text-align: center; }
.remove-btn { color: var(--danger) !important; border: 0 !important; background: transparent !important; margin-left: 4px;}


.ticket-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.customer-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.customer-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.totals {
  display: grid;
  gap: 5px;
  font-size: 14px;
}

.totals div {
  display: flex;
  justify-content: space-between;
}

.totals .grand {
  font-size: 22px;
  font-weight: 900;
  color: var(--primary-dark);
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.compact-field {
  min-width: 220px;
  padding: 9px;
}

/* Payment */
.pay-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.receipt-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ── Receipt Modal ──────────────────────────────────────────────────── */
.receipt-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 16px;
  transition: background 200ms ease;
}

.receipt-modal-overlay.receipt-modal-visible {
  display: flex;
  background: rgba(15, 23, 42, .6);
}

.receipt-modal {
  position: relative;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, .32);
  padding: 24px 24px 20px;
  width: min(360px, calc(100vw - 32px));
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 180ms ease forwards;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.receipt-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: var(--line);
  color: #172033;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.receipt-modal-close:hover { background: #cbd5e1; }

.receipt-modal .receipt {
  border: 0;
  box-shadow: none;
  padding: 0;
  width: 100%;
}

/* Buttons */
.secondary { width: auto; padding: 11px; }
.danger { width: auto; padding: 11px; background: var(--danger); color: #ffffff; }
.warn { width: auto; padding: 11px; background: var(--warn); color: #ffffff; }
.ghost { width: auto; padding: 11px; background: var(--bg); }

/* ── Page shell ─────────────────────────────────────────────────────── */
.page-shell {
  margin: 10px;
  min-height: calc(100vh - 83px);
}

.content-grid {
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.table-card, .order-card, .metric, .kitchen-card, .menu-card, .supplier-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: var(--panel);
  display: grid;
  gap: 7px;
}

.busy   { border-color: #f97316; background: #fff7ed; }
.paid   { border-color: #22c55e; background: #f0fdf4; }
.sent   { border-color: #0ea5e9; background: #f0f9ff; }
.cancelled { border-color: #94a3b8; background: var(--bg); opacity: .7; }

.badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--line);
  color: #1e293b;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.empty {
  padding: 40px;
  color: var(--muted);
  text-align: center;
}

/* ── Receipt page ───────────────────────────────────────────────────── */
.receipt-body {
  background: var(--bg);
  display: grid;
  justify-items: center;
  padding: 18px;
}

.receipt {
  width: min(320px, 100%);
  background: #ffffff;
  color: #000;
  padding: 18px;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.receipt * {
  font-weight: 900 !important;
  color: #000 !important;
  font-family: system-ui, -apple-system, sans-serif !important;
  -webkit-text-stroke: 0.6px black !important;
}

.receipt h1, .receipt p {
  margin: 0;
  text-align: center;
}

.receipt h1 { font-size: 22px; }

.receipt table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.receipt td {
  border-top: 1px dashed #bbb;
  padding: 7px 0;
  font-size: 13px;
}

.receipt td:last-child { text-align: right; }

.receipt-line, .receipt-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed #bbb;
  font-size: 13px;
}

.receipt-total {
  font-size: 18px;
  border-top: 2px solid #111;
  border-bottom: 0;
  margin-top: 4px;
}

.receipt-note {
  color: #000;
  font-weight: 700;
  font-size: 11px;
  padding: 8px 0;
  text-align: center;
}

.receipt button {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: #ffffff;
}

/* ── Qty popup modal ────────────────────────────────────────────────── */
.qty-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8000;
  padding: 20px;
  animation: modalIn 150ms ease;
}

.qty-popup {
  background: var(--panel);
  border-radius: 10px;
  padding: 22px;
  width: min(300px, 100%);
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  display: grid;
  gap: 14px;
  text-align: center;
}

.qty-popup h3 { margin: 0; font-size: 15px; font-weight: 800; }
.qty-popup p { margin: 0; color: var(--muted); font-size: 13px; }

.qty-popup-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.qty-popup-row input {
  width: 80px;
  text-align: center;
  padding: 10px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  font-size: 20px;
  font-weight: 800;
}

.qty-popup-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217,119,6,.15);
}

.qty-pop-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 20px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.qty-popup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Products & Stock New UI ────────────────────────────────────────── */
.panel-title-group { display: flex; align-items: center; gap: 12px; }
.panel-title-group h2 { margin: 0; }
.add-btn { background: var(--primary); color: #fff; padding: 10px 18px; font-size: 14px; }
.add-btn:hover { background: var(--primary-dark); }

.toolbar { display: flex; gap: 16px; margin: 0 24px 20px; align-items: center; background: var(--panel); padding: 14px 20px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.04); }
.search-bar { flex: 1; display: flex; align-items: center; position: relative; }
.search-bar .search-icon { position: absolute; left: 14px; color: var(--muted); }
.search-field { padding-left: 36px; width: 100%; background: var(--bg); border: 1px solid var(--line); font-size: 15px; }
.search-field:focus { background: var(--panel); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15); }
.cat-filter { min-width: 200px; width: auto; background: var(--bg); font-size: 14px; }
.filter-pills { display: flex; gap: 8px; }
.pill { padding: 8px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.15s; }
.pill:hover { background: var(--bg); }
.pill.active { background: var(--ink); color: #ffffff; border-color: var(--ink); }
.pill.alert-pill.active { background: var(--danger); border-color: var(--danger); }
.pill-badge { background: var(--danger); color: #ffffff; padding: 2px 6px; border-radius: 10px; font-size: 11px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 999; display: grid; place-items: center; padding: 20px; backdrop-filter: blur(2px); overflow-y: auto; }
.modal-box { background: var(--panel); width: 100%; max-width: 540px; max-height: 90vh; display: flex; flex-direction: column; border-radius: 12px; box-shadow: 0 20px 40px rgba(0,0,0,0.15); overflow: hidden; animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 18px; color: var(--ink); }
.modal-close { background: none; font-size: 24px; color: var(--muted); padding: 0; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--ink); }
.modal-form { padding: 24px; display: flex; flex-direction: column; gap: 24px; overflow-y: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; flex-shrink: 0; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--line); padding-top: 24px; }
.modal-actions button { padding: 10px 20px; }

/* Product Cards */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 0 24px 24px; }
.product-card { background: var(--panel); padding: 20px; border-radius: 12px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; transition: transform 0.2s, box-shadow 0.2s; position: relative; }
.product-card:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(0,0,0,0.06); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.card-actions { position: relative; }
.action-menu-btn { background: none; color: var(--muted); padding: 4px; font-size: 16px; opacity: 0; transition: opacity 0.2s; }
.product-card:hover .action-menu-btn { opacity: 1; }
.action-menu-btn:hover { background: var(--bg); color: var(--ink); }
.action-menu { position: absolute; right: 0; top: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); padding: 6px; display: flex; flex-direction: column; z-index: 10; }
.action-menu.hidden { display: none; }
.action-menu button { background: none; text-align: left; padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--ink); }
.action-menu button:hover { background: var(--bg); border-radius: 4px; }
.archive-btn { color: var(--danger) !important; }

.sku-text { font-family: monospace; color: var(--muted); background: var(--bg); padding: 2px 6px; border-radius: 4px; display: inline-block; }
.price-tier { display: grid; gap: 8px; background: var(--bg); padding: 12px; border-radius: 8px; margin-top: auto; }
.price-row { display: flex; justify-content: space-between; align-items: center; }
.price-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.price-value { font-weight: 700; font-size: 14px; }
.sell-price { color: var(--primary-dark); font-size: 16px; }
.cost-price { color: var(--ink); }

.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }

/* Stock Cards */
.stock-grid { padding: 0 24px 24px; gap: 20px; }
.stock-card { background: var(--panel); border-radius: 12px; border: 1px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.stock-card.low-stock { border-color: rgba(220, 38, 38, 0.4); background: #fef2f2; }
.stock-card.low-stock .status-badge { background: #fee2e2; color: #dc2626; }
.stock-card.in-stock .status-badge { background: #dcfce7; color: #16a34a; }
.status-badge { font-size: 10px; font-weight: 800; padding: 4px 8px; border-radius: 12px; text-transform: uppercase; }
.category-text { font-size: 12px; color: var(--muted); font-weight: 600; }
.stock-display { margin: 12px 0; display: flex; align-items: baseline; gap: 6px; }
.stock-value { font-size: 32px; font-weight: 900; color: var(--ink); }
.stock-card.low-stock .stock-value { color: var(--danger); }
.stock-unit { font-size: 14px; font-weight: 600; color: var(--muted); }
.inline-adjust { display: flex; align-items: center; justify-content: space-between; background: var(--bg); padding: 4px; border-radius: 8px; border: 1px solid var(--line); }
.adjust-btn { width: 32px; height: 32px; background: var(--panel); border-radius: 6px; font-size: 16px; color: var(--ink); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.adjust-btn:hover { background: var(--bg); }
.adjust-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.restock-btn { width: 100%; padding: 10px; background: var(--danger); color: #ffffff; border-radius: 8px; font-size: 14px; }
.restock-btn:hover { background: #b91c1c; }

/* ── Sales Table ──────────────────────────────────────────────────────── */
.sales-table-container { margin: 0 24px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.02); }
.sales-table { width: 100%; border-collapse: collapse; text-align: left; }
.sales-table th { padding: 16px 20px; background: var(--bg); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); }
.sales-row { transition: all 0.2s; cursor: pointer; }
.sales-row:hover { background: var(--bg); }
.sales-row td { padding: 16px 20px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink); vertical-align: middle; }
.sales-row:last-child td { border-bottom: none; }
.sales-total { font-weight: 800; color: var(--ink); font-size: 15px; }
.font-mono { font-family: monospace; font-size: 15px; color: var(--primary-dark); }
.text-muted { color: var(--muted); }
.pay-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
  border-top: 1px dashed #bbb;
  padding: 7px 0;
  font-size: 13px;
}

.receipt td:last-child { text-align: right; }

.receipt-line, .receipt-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed #bbb;
  font-size: 13px;
}

.receipt-total {
  font-size: 18px;
  border-top: 2px solid #111;
  border-bottom: 0;
  margin-top: 4px;
}

.receipt-note {
  color: #000;
  font-weight: 700;
  font-size: 11px;
  padding: 8px 0;
  text-align: center;
}

.receipt button {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: #ffffff;
}

/* ── Qty popup modal ────────────────────────────────────────────────── */
.qty-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8000;
  padding: 20px;
  animation: modalIn 150ms ease;
}

.qty-popup {
  background: var(--panel);
  border-radius: 10px;
  padding: 22px;
  width: min(300px, 100%);
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
  display: grid;
  gap: 14px;
  text-align: center;
}

.qty-popup h3 { margin: 0; font-size: 15px; font-weight: 800; }
.qty-popup p { margin: 0; color: var(--muted); font-size: 13px; }

.qty-popup-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

.qty-popup-row input {
  width: 80px;
  text-align: center;
  padding: 10px;
  border: 1.5px solid var(--line);
  border-radius: 7px;
  font-size: 20px;
  font-weight: 800;
}

.qty-popup-row input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217,119,6,.15);
}

.qty-pop-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg);
  font-size: 20px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.qty-popup-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ── Products & Stock New UI ────────────────────────────────────────── */
.panel-title-group { display: flex; align-items: center; gap: 12px; }
.panel-title-group h2 { margin: 0; }
.add-btn { background: var(--primary); color: #fff; padding: 10px 18px; font-size: 14px; }
.add-btn:hover { background: var(--primary-dark); }

.toolbar { display: flex; gap: 16px; margin: 0 24px 20px; align-items: center; background: var(--panel); padding: 14px 20px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.04); }
.search-bar { flex: 1; display: flex; align-items: center; position: relative; }
.search-bar .search-icon { position: absolute; left: 14px; color: var(--muted); }
.search-field { padding-left: 36px; width: 100%; background: var(--bg); border: 1px solid var(--line); font-size: 15px; }
.search-field:focus { background: var(--panel); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15); }
.cat-filter { min-width: 200px; width: auto; background: var(--bg); font-size: 14px; }
.filter-pills { display: flex; gap: 8px; }
.pill { padding: 8px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 8px; transition: all 0.15s; }
.pill:hover { background: var(--bg); }
.pill.active { background: var(--ink); color: #ffffff; border-color: var(--ink); }
.pill.alert-pill.active { background: var(--danger); border-color: var(--danger); }
.pill-badge { background: var(--danger); color: #ffffff; padding: 2px 6px; border-radius: 10px; font-size: 11px; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); z-index: 999; display: grid; place-items: center; padding: 20px; backdrop-filter: blur(2px); overflow-y: auto; }
.modal-box { background: var(--panel); width: 100%; max-width: 540px; max-height: 90vh; display: flex; flex-direction: column; border-radius: 12px; box-shadow: 0 20px 40px rgba(0,0,0,0.15); overflow: hidden; animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 18px; color: var(--ink); }
.modal-close { background: none; font-size: 24px; color: var(--muted); padding: 0; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--ink); }
.modal-form { padding: 24px; display: flex; flex-direction: column; gap: 24px; overflow-y: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; flex-shrink: 0; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--line); padding-top: 24px; }
.modal-actions button { padding: 10px 20px; }

/* Product Cards */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding: 0 24px 24px; }
.product-card { background: var(--panel); padding: 20px; border-radius: 12px; border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; transition: transform 0.2s, box-shadow 0.2s; position: relative; }
.product-card:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(0,0,0,0.06); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; }
.card-actions { position: relative; }
.action-menu-btn { background: none; color: var(--muted); padding: 4px; font-size: 16px; opacity: 0; transition: opacity 0.2s; }
.product-card:hover .action-menu-btn { opacity: 1; }
.action-menu-btn:hover { background: var(--bg); color: var(--ink); }
.action-menu { position: absolute; right: 0; top: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); padding: 6px; display: flex; flex-direction: column; z-index: 10; }
.action-menu.hidden { display: none; }
.action-menu button { background: none; text-align: left; padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--ink); }
.action-menu button:hover { background: var(--bg); border-radius: 4px; }
.archive-btn { color: var(--danger) !important; }

.sku-text { font-family: monospace; color: var(--muted); background: var(--bg); padding: 2px 6px; border-radius: 4px; display: inline-block; }
.price-tier { display: grid; gap: 8px; background: var(--bg); padding: 12px; border-radius: 8px; margin-top: auto; }
.price-row { display: flex; justify-content: space-between; align-items: center; }
.price-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.price-value { font-weight: 700; font-size: 14px; }
.sell-price { color: var(--primary-dark); font-size: 16px; }
.cost-price { color: var(--ink); }

.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }

/* Stock Cards */
.stock-grid { padding: 0 24px 24px; gap: 20px; }
.stock-card { background: var(--panel); border-radius: 12px; border: 1px solid var(--line); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.stock-card.low-stock { border-color: rgba(220, 38, 38, 0.4); background: #fef2f2; }
.stock-card.low-stock .status-badge { background: #fee2e2; color: #dc2626; }
.stock-card.in-stock .status-badge { background: #dcfce7; color: #16a34a; }
.status-badge { font-size: 10px; font-weight: 800; padding: 4px 8px; border-radius: 12px; text-transform: uppercase; }
.category-text { font-size: 12px; color: var(--muted); font-weight: 600; }
.stock-display { margin: 12px 0; display: flex; align-items: baseline; gap: 6px; }
.stock-value { font-size: 32px; font-weight: 900; color: var(--ink); }
.stock-card.low-stock .stock-value { color: var(--danger); }
.stock-unit { font-size: 14px; font-weight: 600; color: var(--muted); }
.inline-adjust { display: flex; align-items: center; justify-content: space-between; background: var(--bg); padding: 4px; border-radius: 8px; border: 1px solid var(--line); }
.adjust-btn { width: 32px; height: 32px; background: var(--panel); border-radius: 6px; font-size: 16px; color: var(--ink); border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.adjust-btn:hover { background: var(--bg); }
.adjust-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.restock-btn { width: 100%; padding: 10px; background: var(--danger); color: #ffffff; border-radius: 8px; font-size: 14px; }
.restock-btn:hover { background: #b91c1c; }

/* ── Sales Table ──────────────────────────────────────────────────────── */
.sales-table-container { margin: 0 24px 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.02); }
.sales-table { width: 100%; border-collapse: collapse; text-align: left; }
.sales-table th { padding: 16px 20px; background: var(--bg); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--line); }
.sales-row { transition: all 0.2s; cursor: pointer; }
.sales-row:hover { background: var(--bg); }
.sales-row td { padding: 16px 20px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink); vertical-align: middle; }
.sales-row:last-child td { border-bottom: none; }
.sales-total { font-weight: 800; color: var(--ink); font-size: 15px; }
.font-mono { font-family: monospace; font-size: 15px; color: var(--primary-dark); }
.text-muted { color: var(--muted); }
.pay-badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.pay-badge.cash { background: #dcfce7; color: #16a34a; }
.pay-badge.mpesa { background: #dcfce7; color: #16a34a; }
.pay-badge.mpesa { background: #fee2e2; color: #dc2626; } /* Wait, mpesa standard color is green. But maybe blue is better. */
.pay-badge.mpesa { background: #dbeafe; color: #1d4ed8; }
.pay-ref { font-size: 12px; color: var(--muted); margin-top: 4px; font-family: monospace; }
.view-receipt-btn { background: var(--panel); border: 1px solid var(--line); padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--muted); transition: all 0.2s; }
.sales-row:hover .view-receipt-btn { background: var(--primary); color: #ffffff; border-color: var(--primary); }

/* ── Toast Notifications ──────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 1000; }
.toast { background: var(--panel); border-left: 4px solid var(--ok); box-shadow: 0 4px 12px rgba(0,0,0,0.15); padding: 12px 16px; border-radius: 6px; display: flex; gap: 12px; align-items: center; font-weight: 600; font-size: 14px; animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.toast.error { border-left-color: var(--danger); }
.toast.error span:first-child { color: var(--danger); }
.toast.success span:first-child { color: var(--ok); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .topbar {
    height: 60px;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    padding: 0 14px;
    gap: 8px;
  }

  .topbar-left  { grid-column: 1; }
  .topbar-right { grid-column: 2; }
  
  .mobile-nav-toggle { display: flex; }

  .topbar-center {
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    width: 250px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 9999;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 20px;
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }
  .topbar-center.open {
    transform: translateX(0);
  }

  nav { 
    flex-direction: column; 
    gap: 8px; 
    width: 100%;
  }
  .nav-link {
    width: 100%;
    border-radius: 8px;
    padding: 12px 16px;
    text-align: left;
    justify-content: flex-start;
  }

  main { min-height: calc(100vh - 60px); }

  .pos-shell {
    height: auto;
    min-height: calc(100vh - 104px);
    grid-template-columns: 1fr;
  }

  .ticket-side { min-height: 440px; }

  .actions { grid-template-columns: 1fr 1fr 1fr; }

  .form-row, .pay-actions {
    grid-template-columns: 1fr;
  }

  .head-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .compact-field { min-width: 0; }
}

/* ── Print / Thermal receipt ────────────────────────────────────────── */
@media print {
  @page {
    size: 80mm auto;
    margin: 4mm 3mm;
  }

  body > *:not(#receiptModal) { display: none !important; }

  #receiptModal,
  #receiptModal .receipt-modal,
  #receiptModal .receipt-modal-print-area {
    display: block !important;
    position: static !important;
    background: none !important;
    box-shadow: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
    animation: none !important;
    inset: auto !important;
  }

  .receipt, .receipt * {
    font-family: system-ui, -apple-system, sans-serif !important;
    color: #000 !important;
    font-weight: 900 !important;
    -webkit-text-stroke: 0.6px black !important;
  }

  .receipt {
    width: 100% !important;
    border: 0 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    line-height: 1.4;
  }

  .receipt h1 { font-size: 18px !important; letter-spacing: 1px; margin-bottom: 4px; }
  .receipt p { font-size: 12px !important; margin: 0 0 5px; }
  .receipt .receipt-line { font-size: 12px !important; padding: 4px 0; border-bottom: 1px dashed #000 !important; }
  .receipt table { margin: 6px 0; width: 100%; }
  .receipt td { font-size: 12px !important; padding: 4px 0; border-top: 1px dashed #000 !important; }
  .receipt .receipt-total { font-size: 16px !important; border-top: 2px solid #000 !important; border-bottom: 0 !important; padding: 6px 0 !important; }
  .receipt .receipt-note { font-size: 11px !important; text-align: center; margin-top: 6px; }
  
  #receiptModal .receipt-modal-close,
  #receiptModal #receiptPrintBtn { display: none !important; }
}

/* ── Business Settings & Profiles UI ─────────────────────────────────────── */
.settings-container {
  max-width: 1080px;
  margin: 24px auto;
  padding: 0 20px 60px;
}

.settings-header {
  margin-bottom: 24px;
}

.settings-header h2 {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--ink);
}

.settings-header p {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

.settings-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--ink);
}

.section-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 16px;
}

.profile-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.profile-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.profile-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.profile-card.selected {
  border-color: var(--ink);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--ink);
}

.profile-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.profile-card-icon {
  font-size: 28px;
}

.profile-card-check {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--line);
  color: var(--muted);
}

.profile-card.selected .profile-card-check {
  background: var(--ink);
  color: var(--panel);
}

.profile-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.profile-card-tag {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
  line-height: 1.4;
}

.profile-caps-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.cap-pill {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
  text-transform: capitalize;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

/* ── Image Search Modal & Thumbnails ──────────────────────────────────────── */
.img-search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  max-height: 380px;
  overflow-y: auto;
  padding: 16px 20px 20px;
}

.img-search-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: all 0.2s;
  position: relative;
}

.img-search-card:hover {
  border-color: var(--primary);
  transform: scale(1.02);
}

.img-search-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  background: #0f172a;
}

.img-card-title {
  font-size: 11px;
  padding: 6px 8px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.img-card-select-btn {
  font-size: 11px;
  padding: 5px;
  background: var(--line);
  color: var(--ink);
  border-radius: 0;
  width: 100%;
}

.img-search-card:hover .img-card-select-btn {
  background: var(--primary);
  color: var(--primary-fg);
}

.img-search-card.loading {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
}

/* ── Variant Picker Modal ─────────────────────────────────────────────────── */
.variant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.variant-btn {
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.15s;
}

.variant-btn:hover {
  border-color: var(--ink);
  background: var(--line);
}

.variant-btn strong {
  font-size: 14px;
  color: var(--ink);
}

.variant-btn small {
  font-size: 12px;
  color: var(--muted);
}

.variant-pill {
  display: inline-block;
  font-size: 11px;
  background: var(--line);
  color: var(--ink);
  padding: 1px 6px;
  border-radius: 4px;
  margin-top: 2px;
}

.batch-pill {
  display: inline-block;
  font-size: 11px;
  color: #38bdf8;
  margin-top: 2px;
}

/* ── Expiry and Reorder Alerts ────────────────────────────────────────────── */
.expiry-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

.expiry-badge.danger {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid #ef4444;
}

.expiry-badge.warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fde68a;
  border: 1px solid #f59e0b;
}

.expiry-badge.ok {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

/* ── Wholesale Price & Decimal Switch ─────────────────────────────────────── */
.tier-toggle-btn {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
  background: var(--line);
  color: var(--ink);
}

.tier-toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

.quote-banner {
  background: rgba(234, 179, 8, 0.15);
  border: 1px solid #eab308;
  color: #fef08a;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Mobile / Capacitor phone layout (≤ 600 px) ────────────────────── */
@media (max-width: 600px) {
  /* Stack POS shell: menu above, ticket below */
  .pos-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  /* Let each panel scroll independently on phone */
  .menu-side,
  .ticket-side {
    min-height: 0;
    max-height: none;
  }

  /* 2-column product grid on phone (was 4) */
  .item-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
  }

  /* Smaller product cards on phone */
  .menu-btn {
    min-height: 160px;
  }

  .menu-btn-img-wrapper {
    height: 90px;
  }

  /* Ensure all interactive elements meet 44px touch target */
  .tab,
  .nav-link,
  .qty-controls button,
  .pin-pad button {
    min-height: 44px;
  }

  /* Full-width pay buttons */
  .pay-actions {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  /* Prevent horizontal overflow in ticket totals */
  .ticket-foot {
    padding: 8px;
  }

  .totals {
    font-size: 13px;
  }

  .totals .grand {
    font-size: 18px;
  }

  /* Topbar: hide clock text on tiny screens */
  #navDate {
    display: none;
  }
}


/* ── ORAFORGE MOBILE APK POS ── */
.mobile-cart-backdrop,.mobile-cart-bar,.mobile-cart-close{display:none}
.pos-title-block{display:flex;flex-direction:column;gap:1px}.pos-kicker{font-size:10px;font-weight:800;letter-spacing:.12em;text-transform:uppercase;color:var(--muted)}.pos-title-block small{font-size:12px;color:var(--muted)}
.pos-control-strip{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:wrap}.pos-control-strip .field{width:auto;min-width:110px;padding:7px 10px;font-size:13px}
.mobile-search-row{display:flex;gap:8px;align-items:center}.mobile-search-row .sku-search-inner{flex:1}
@media (max-width:700px){
  html,body{width:100%;max-width:100%;overflow-x:hidden} body{padding:0!important} main{width:100%;max-width:100vw;overflow-x:hidden}
  .topbar{height:58px!important;width:100%!important;padding:0 10px!important;grid-template-columns:minmax(0,1fr) auto!important;gap:6px!important;position:sticky;top:0;z-index:5000}
  .topbar-left{min-width:0;overflow:hidden}.brand{min-width:0;gap:7px}.brand-logo{width:34px;height:34px;flex:0 0 34px}.brand-text{min-width:0}.brand-text span{font-size:13px!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block}.brand-text small{display:none}.topbar-divider{display:none}
  .topbar-right{gap:5px}.topbar-clock #navDate{display:none}.topbar-clock #navTime{font-size:12px!important}.theme-toggle-btn{width:36px!important;height:36px!important}.logout{font-size:0!important;width:36px;height:36px;padding:0!important;display:grid;place-items:center}.logout::before{content:'↪';font-size:18px}
  .pos-shell{display:block!important;width:100%!important;max-width:100vw!important;height:auto!important;min-height:calc(100dvh - 58px)!important;margin:0!important;padding:0 0 78px!important;overflow:visible!important;background:var(--bg)!important}
  .menu-side{width:100%!important;max-width:100%!important;border:0!important;border-radius:0!important;box-shadow:none!important;display:block!important;overflow:visible!important}
  .mobile-pos-head{display:flex!important;align-items:center!important;padding:10px 12px 8px!important;border-bottom:1px solid var(--line)!important;gap:8px!important}.pos-title-block{min-width:0;flex:1}.pos-title-block h2{font-size:18px!important}.pos-title-block small{display:none}.pos-kicker{font-size:9px}
  .pos-control-strip{margin-left:0!important;flex:0 0 auto!important;max-width:44%!important}.pos-control-strip .field{min-width:0!important;width:auto!important;max-width:120px!important;height:38px!important;padding:7px 8px!important;font-size:12px!important}.pos-control-strip #tierToggleBtn{max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .sku-search-wrap.mobile-search-row{padding:8px 10px!important;gap:7px!important;background:var(--panel)!important}.sku-search-inner{min-width:0!important}.sku-search-input{font-size:13px!important;padding:10px 0!important}.barcode-scan-btn{height:42px!important;padding:0 12px!important;font-size:12px!important;border-radius:9px!important}.barcode-glyph{font-size:18px}
  .tabs{padding:7px 10px!important;gap:7px!important;overflow-x:auto!important;scrollbar-width:none}.tabs::-webkit-scrollbar{display:none}.tab{flex:0 0 auto!important;white-space:nowrap!important;min-height:38px!important;padding:8px 12px!important;font-size:11px!important}
  .item-grid{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important;padding:10px!important;overflow:visible!important;height:auto!important;max-height:none!important;background:var(--bg)!important}
  .menu-btn{min-width:0!important;min-height:212px!important;height:auto!important;border-radius:13px!important;overflow:hidden!important;text-align:left!important}.menu-btn-img-wrapper{height:116px!important;min-height:116px!important}.menu-btn-img-wrapper img{padding:8px!important}.menu-btn-content{padding:10px!important;gap:4px!important}.menu-btn-content strong{font-size:13px!important;line-height:1.25!important;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.item-sku{font-size:10px!important}.item-price{font-size:14px!important}.stock-badge{top:7px!important;right:7px!important;font-size:9px!important;padding:3px 6px!important}.menu-btn-stock-status{font-size:10px!important;width:max-content!important;padding:3px 7px!important;border-radius:999px!important}
  .mobile-cart-bar{display:block!important;position:fixed;left:0;right:0;bottom:0;padding:8px 10px calc(8px + env(safe-area-inset-bottom));z-index:6500;background:linear-gradient(to top,var(--bg) 68%,transparent)}
  .mobile-cart-summary{width:100%;min-height:56px;border:1px solid var(--line);border-radius:14px;background:var(--panel);color:var(--ink);box-shadow:0 8px 30px rgba(0,0,0,.18);display:grid;grid-template-columns:1fr auto 1fr;align-items:center;padding:0 14px;gap:8px}.mobile-cart-items{display:flex;align-items:center;gap:5px;font-size:12px}.mobile-cart-total{font-size:15px}.mobile-cart-action{text-align:right;font-size:10px;font-weight:800}.mobile-cart-summary.has-items{border-color:var(--ink)}
  .mobile-ticket-drawer{display:grid!important;position:fixed!important;left:0!important;right:0!important;bottom:0!important;top:auto!important;width:100%!important;max-width:none!important;height:min(86dvh,720px)!important;min-height:0!important;border-radius:20px 20px 0 0!important;z-index:8000!important;transform:translateY(105%)!important;transition:transform .22s ease!important;box-shadow:0 -18px 60px rgba(0,0,0,.32)!important;background:var(--panel)!important;padding-bottom:env(safe-area-inset-bottom)}
  body.mobile-cart-open .mobile-ticket-drawer{transform:translateY(0)!important} body.mobile-cart-open{overflow:hidden}.mobile-cart-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.52);z-index:7900}.mobile-cart-open .mobile-cart-backdrop{display:block}.mobile-cart-close{display:grid!important;place-items:center;width:36px;height:36px;border:0;border-radius:50%;background:var(--bg);color:var(--ink);font-size:24px}.ticket-head{grid-template-columns:1fr auto auto!important}.ticket-staff{font-size:12px!important}.ticket-list{overflow:auto!important}.ticket-foot{max-height:46dvh;overflow:auto}
  .qty-popup-overlay,.modal-overlay{padding:0!important;align-items:flex-end!important}.qty-popup,.modal-box{width:100%!important;max-width:none!important;border-radius:20px 20px 0 0!important;max-height:92dvh!important;padding-bottom:calc(20px + env(safe-area-inset-bottom))!important}
}
@media (max-width:390px){.item-grid{gap:8px!important;padding:8px!important}.menu-btn{min-height:196px!important}.menu-btn-img-wrapper{height:102px!important;min-height:102px!important}.mobile-cart-total{font-size:14px}.pos-control-strip{max-width:42%!important}}


/* ── APK login viewport hardening ───────────────────────────────────────── */
html, body { max-width: 100%; overflow-x: hidden; }
#posLoginScreen {
  box-sizing: border-box !important;
  width: 100vw !important;
  max-width: 100vw !important;
  overflow-x: hidden !important;
}
#posLoginScreen .login-panel {
  box-sizing: border-box !important;
  width: min(440px, 100%) !important;
  max-width: 100% !important;
  min-width: 0 !important;
}
#loginChipsContainer {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  min-width: 0 !important;
  width: 100% !important;
}
#loginChipsContainer .login-shop-chip {
  box-sizing: border-box !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
}
#loginChipsContainer .login-shop-chip > span:last-child {
  min-width: 0 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
}
@media (max-width: 380px) {
  #posLoginScreen { padding: 10px !important; }
  #posLoginScreen .login-panel { padding: 16px !important; }
  #loginChipsContainer { grid-template-columns: 1fr !important; }
}

/* ── Checkout Processing Animations ────────────────────────────────────────── */
@keyframes pos-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.08); opacity: 0.85; }
}
@keyframes pos-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.pos-pulse-icon {
  animation: pos-pulse 2s ease-in-out infinite;
}
.pos-spinner-ring {
  width: 15px;
  height: 15px;
  border: 2px solid #2563eb;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: pos-spin 0.8s linear infinite;
  vertical-align: middle;
}


/* Keep wide records reachable on touch screens. */
.sales-table-container { min-width: 0; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 700px) {
  [data-page], .panel, .content-grid, .form-grid { min-width: 0; }
  .sales-table-container { margin: 0 12px 16px; }
  .sales-table { min-width: 640px; }
  .sales-table th, .sales-row td { padding: 12px; }
  .panel-title-group { flex-wrap: wrap; gap: 12px; margin-left: 12px !important; margin-right: 12px !important; }
  .panel-title-group > div { flex-wrap: wrap; gap: 8px; margin-left: 0 !important; }
  .panel-title-group h2 { flex: 1 0 100%; }
  .toolbar, .stock-toolbar, .filter-pills { flex-wrap: wrap; min-width: 0; }
  .toolbar .field, .toolbar .search-box { min-width: 0; max-width: 100%; }
  .content-grid, .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
  [data-page="settings"] [style*="grid-template-columns"],
  [data-page="reports"] [style*="grid-template-columns"] { grid-template-columns: minmax(0, 1fr) !important; }
  .qty-popup, .modal-box { overflow-y: auto; overscroll-behavior-y: contain; }
  .qty-popup input, .qty-popup select, .modal-box input, .modal-box select { min-width: 0; max-width: 100%; box-sizing: border-box; }
}

/* Compact mobile catalog and readable receipt controls. */
.receipt #receiptPrintBtn, #receiptPrintBtn { color:#fff !important; background:#18181b !important; -webkit-text-stroke:0 !important; }
.product-actions { display:flex;gap:8px;flex-shrink:0; }
.product-actions button { min-height:40px;padding:8px 12px;border:1px solid var(--line);border-radius:8px;background:var(--bg);color:var(--ink);font-weight:600; }
.product-actions .delete-btn { color:#dc2626; }
.product-card .card-header { gap:8px;flex-wrap:wrap; }
.product-card > strong { color:var(--ink); }
@media(max-width:700px) {
  .item-grid { gap:8px !important;padding:8px !important; }
  .menu-btn { min-height:152px !important; }
  .menu-btn-img-wrapper { height:66px !important;min-height:66px !important; }
  .menu-btn-img-wrapper img { padding:4px !important; }
  .menu-btn-content { padding:8px !important;gap:3px !important; }
  .menu-btn-content strong { font-size:12px !important;line-height:1.25 !important; }
  .menu-btn .item-sku { display:none; }
  .menu-btn .item-price { font-size:14px !important; }
  .product-grid { gap:10px !important;padding:0 12px 16px !important; }
  .product-card { padding:12px !important;gap:5px !important;min-height:0 !important; }
  .product-card .card-header { margin-bottom:2px; }
  .product-card > strong { font-size:14px;line-height:1.3; }
  .product-card .sku-text { display:inline-block;font-size:11px;padding:2px 4px;margin:0;overflow-wrap:anywhere; }
  .product-card .price-tier { display:flex;flex-wrap:wrap;gap:4px 16px;padding:7px 8px;margin:3px 0; }
  .product-card .price-row { flex:1 1 115px;gap:8px; }
  .product-card .price-value { font-size:13px; }
  .settings-container { padding:12px !important; }
  .settings-section { padding:16px !important; }
  .settings-section .section-title { flex-wrap:wrap;gap:10px; }
}

/* Staff catalog shares the admin portal's compact table layout. */
.staff-products { min-width:760px; }
.staff-products th { padding:13px 16px;font-size:11px; }
.staff-products td { padding:13px 16px;font-size:13px; }
.staff-products td:first-child { min-width:215px; }
.staff-products td:first-child small { display:block;color:var(--muted); }
.staff-products td:nth-child(4) { white-space:nowrap; }
.staff-stock { display:inline-block;padding:4px 9px;border-radius:20px;background:#dcfce7;color:#15803d;white-space:nowrap;font-size:11px;font-weight:700; }
.staff-stock.low { background:#fef3c7;color:#92400e; }
.staff-products .product-actions button { min-height:36px;padding:6px 10px; }
@media(max-width:700px) { [data-page="products"] .panel-head { flex-wrap:wrap;gap:12px; } [data-page="products"] .panel-head > div { flex-wrap:wrap; } }
