:root {
  color-scheme: light;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #d97706;
  --primary-dark: #b45309;
  --primary-light: #fef3c7;
  --danger: #dc2626;
  --warn: #7c3aed;
  --ok: #16a34a;
  --shadow: 0 4px 24px rgba(15, 23, 42, .07);
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: 'Inter', Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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: 60px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 18px;
  background: #0f172a;
  color: white;
  border-bottom: 3px solid var(--primary);
  box-shadow: 0 4px 24px rgba(0,0,0,.3);
  position: sticky;
  top: 0;
  z-index: 200;
}

.topbar-left  { display: flex; align-items: center; gap: 16px; }
.topbar-center { display: flex; align-items: center; justify-content: center; }
.topbar-right  { display: flex; align-items: center; justify-content: flex-end; }

.mobile-nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 0;
}
.mobile-nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: white;
  border-radius: 2px;
}

.brand {
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  background: var(--primary);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 900;
  color: white;
  flex-shrink: 0;
}

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

.brand-text span {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.2px;
}

.brand-text small {
  font-size: 10px;
  font-weight: 500;
  color: #fcd34d;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  color: #94a3b8;
  text-decoration: none;
  padding: 7px 13px;
  border-radius: 7px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 600;
  transition: background 140ms, color 140ms;
}

.nav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.nav-link.active {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.logout {
  color: #94a3b8;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid rgba(255,255,255,.1);
  transition: background 140ms, color 140ms, border-color 140ms;
}

.logout:hover {
  background: rgba(220,38,38,.25);
  border-color: rgba(220,38,38,.4);
  color: #fca5a5;
}

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

/* ── Login ─────────────────────────────────────────────────────────── */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  background: linear-gradient(140deg, #0f172a 55%, #78350f 55%);
}

.login-panel {
  width: min(380px, calc(100vw - 28px));
  background: white;
  padding: 28px;
  border-radius: 10px;
  box-shadow: 0 24px 64px rgba(0,0,0,.3);
  display: grid;
  gap: 14px;
}

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

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

.pin-pad button {
  min-height: 62px;
  background: #1e293b;
  color: white;
  font-size: 22px;
  border-radius: 8px;
}

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

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

.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: 14px;
  padding: 14px;
  overflow: hidden;
  background: linear-gradient(135deg, #f8fafc 0%, #eef3f8 100%);
}

.menu-side, .ticket-side, .page-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
  overflow: hidden;
}

.page-loading {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.page-loading span {
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: pageLoadingSpin .7s linear infinite;
}

@keyframes pageLoadingSpin { to { transform: rotate(360deg); } }

.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: 15px 16px;
  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;
}

.pos-head small, .ticket-head small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.pos-head select {
  min-width: 124px;
  border: 1px solid #f4cf9b;
  border-radius: 8px;
  background: #fffaf2;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  padding: 8px 28px 8px 10px;
}

.active-staff {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--primary-dark);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}

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

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

.sku-search-inner {
  display: flex;
  gap: 6px;
  align-items: center;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  transition: border-color 150ms, box-shadow 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: 11px 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); }

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

.tab {
  padding: 8px 13px;
  background: #f8fafc;
  border: 1px solid transparent;
  color: #475569;
  white-space: nowrap;
  font-size: 13px;
  border-radius: 999px;
  transition: background 140ms, color 140ms, border-color 140ms;
}

.tab:hover { background: #fff7ed; border-color: #fed7aa; color: var(--primary-dark); }

.tab.active {
  background: var(--primary);
  color: white;
}

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

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

.menu-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(15,23,42,.10);
  border-color: #f4c27b;
}

.menu-btn-img-wrapper {
  height: 140px;
  background: linear-gradient(145deg, #fffaf2, #f8fafc);
  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: 8px 12px;
}

.ticket-row {
  display: flex;
  align-items: center;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
  gap: 12px;
}
.ticket-img {
  width: 44px;
  height: 44px;
  background: #f8fafc;
  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: #f8fafc;
  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: white;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
}
.qty-controls button:hover { background: #f1f5f9; 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: 14px 16px 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  background: linear-gradient(180deg, #fff 0%, #fffaf2 100%);
}

.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 {
  margin-top: 3px;
  padding-top: 9px;
  border-top: 1px dashed #f4c27b;
  font-size: 23px;
  font-weight: 900;
  color: var(--primary-dark);
}

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

.actions button { border-radius: 9px; }
.actions .primary { box-shadow: 0 5px 12px rgba(180, 83, 9, .22); }

.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: white;
  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: #e2e8f0;
  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: white; }
.warn { width: auto; padding: 11px; background: var(--warn); color: white; }
.ghost { width: auto; padding: 11px; background: #f1f5f9; }

/* ── 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: #fff;
  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: #f8fafc; opacity: .7; }

.badge {
  display: inline-flex;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 700;
  background: #e2e8f0;
  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: #f8fafc;
  display: grid;
  justify-items: center;
  padding: 18px;
}

.receipt {
  width: min(320px, 100%);
  background: white;
  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: white;
}

/* ── 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: white;
  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: #f1f5f9;
  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: white; 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: #f8fafc; border: 1px solid var(--line); font-size: 15px; }
.search-field:focus { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15); }
.cat-filter { min-width: 200px; width: auto; background: #f8fafc; font-size: 14px; }
.filter-pills { display: flex; gap: 8px; }
.pill { padding: 8px 16px; background: white; 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: #f1f5f9; }
.pill.active { background: var(--ink); color: white; border-color: var(--ink); }
.pill.alert-pill.active { background: var(--danger); border-color: var(--danger); }
.pill-badge { background: var(--danger); color: white; 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: white; 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: #f1f5f9; 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: white; 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: #f1f5f9; color: var(--ink); }
.action-menu { position: absolute; right: 0; top: 100%; background: white; 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: #f1f5f9; border-radius: 4px; }
.archive-btn { color: var(--danger) !important; }

.sku-text { font-family: monospace; color: var(--muted); background: #f1f5f9; padding: 2px 6px; border-radius: 4px; display: inline-block; }
.price-tier { display: grid; gap: 8px; background: #f8fafc; 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: white; 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: #f8fafc; padding: 4px; border-radius: 8px; border: 1px solid var(--line); }
.adjust-btn { width: 32px; height: 32px; background: white; 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: #f1f5f9; }
.adjust-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.restock-btn { width: 100%; padding: 10px; background: var(--danger); color: white; border-radius: 8px; font-size: 14px; }
.restock-btn:hover { background: #b91c1c; }

/* ── Sales Table ──────────────────────────────────────────────────────── */
.sales-table-container { margin: 0 24px 24px; background: white; 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: #f8fafc; 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: #f1f5f9; }
.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: white; 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: white; 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: white; 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: #0f172a;
    border-right: 1px solid rgba(255,255,255,0.1);
    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.5);
  }
  .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; }
}
