/* ============================================================
   POSly.pk - Main Stylesheet (v2: mobile responsive)
   ============================================================ */

:root {
  --primary: #0f1a3d;
  --primary-light: #1d2f6b;
  --accent: #3157f5;
  --accent-hover: #2544d6;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --info: #0284c7;
  --bg: #f0f2f8;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --sidebar-w: 240px;
  --sidebar-collapsed: 72px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- Sidebar ---- */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-collapsed);
  height: 100vh;
  height: 100dvh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  z-index: 600;
  overflow: hidden;
  transition: width .22s ease, transform .28s ease, box-shadow .22s ease;
}
#sidebar:hover,
#sidebar:focus-within {
  width: var(--sidebar-w);
  box-shadow: 12px 0 28px rgba(0,0,0,.22);
}

#sidebar .brand { padding: 20px 12px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
#sidebar .brand h1 { font-size: 1.1rem; font-weight: 700; color: #fff; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
#sidebar .brand-mark { flex-shrink: 0; display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; background: #fff; border-radius: 10px; }
#sidebar .brand-mark img { width: 34px; height: 34px; display: block; }
#sidebar .brand span { font-size: .72rem; color: rgba(255,255,255,.5); }
#sidebar .nav-label { white-space: nowrap; }
#sidebar .nav-badge { margin-left: 6px; background: #dc2626; color: #fff; border-radius: 10px; padding: 1px 8px; font-size: .68rem; font-weight: 700; }

#sidebar nav { flex: 1; padding: 12px 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }

#sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 18px;
  color: rgba(255,255,255,.72);
  text-decoration: none;
  font-size: .88rem; font-weight: 500;
  transition: background .18s, color .18s;
  border-left: 3px solid transparent;
  min-height: 44px; /* touch target */
}
#sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
#sidebar nav a.active { background: rgba(49,87,245,.25); color: #fff; border-left-color: var(--accent); }
#sidebar nav a svg { flex-shrink: 0; opacity: .8; }

#sidebar .sidebar-footer { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: .78rem; color: rgba(255,255,255,.45); }
#sidebar .posly-mark { font-size: .72rem; margin: 0 0 8px; opacity: .8; }
#sidebar .posly-mark a { color: inherit; text-decoration: none; font-weight: 600; }
#sidebar .posly-mark a:hover { text-decoration: underline; }
.addon-period { display: inline-flex; gap: 0; margin: .4rem 0; padding: 3px; background: #eef2ff; border-radius: 10px; }
.addon-period-btn { border: 0; background: transparent; color: #334155; font-weight: 700; font-size: .8rem; padding: .35rem .8rem; border-radius: 8px; cursor: pointer; }
.addon-period-btn.is-active { background: #3157f5; color: #fff; }
#sidebar .sidebar-footer strong { color: rgba(255,255,255,.8); display: block; margin-bottom: 2px; }

/* Sidebar overlay for mobile */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 550;
}

/* Hamburger button — hidden on desktop */
#menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-right: 6px;
  border-radius: 6px;
  color: var(--text);
}
#menu-toggle:hover { background: var(--bg); }

/* ---- Main ---- */
#main { margin-left: var(--sidebar-collapsed); min-height: 100vh; display: flex; flex-direction: column; }
@media (min-width: 821px) {
  #sidebar:not(:hover):not(:focus-within) .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
  }
  #sidebar:not(:hover):not(:focus-within) nav a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    gap: 0;
  }
  #sidebar:not(:hover):not(:focus-within) .brand { text-align: center; padding-left: 8px; padding-right: 8px; }
  #sidebar:hover .nav-label,
  #sidebar:focus-within .nav-label { opacity: 1; width: auto; }
}

#topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 500;
}
#topbar h2 { font-size: 1rem; font-weight: 600; }
#topbar .topbar-left { display: flex; align-items: center; }
#topbar .topbar-right { display: flex; align-items: center; gap: 14px; }

.content { padding: 24px; flex: 1; }

.addon-nav-wrap { padding: 16px 24px 0; }
.addon-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.addon-nav-link {
  padding: 8px 14px;
  border-radius: 8px;
  font-size: .86rem;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.addon-nav-link:hover { background: var(--bg); color: var(--text); }
.addon-nav-link.is-active {
  background: var(--accent);
  color: #fff;
}

/* ---- Cards ---- */
.card { background: var(--card); border-radius: 10px; border: 1px solid var(--border); padding: 20px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.card-header h3 { font-size: .95rem; font-weight: 600; }

/* ---- Stat Cards ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.blue   { background: #eff6ff; color: var(--info); }
.stat-icon.green  { background: #f0fdf4; color: var(--success); }
.stat-icon.orange { background: #fffbeb; color: var(--warning); }
.stat-icon.purple { background: #f5f3ff; color: var(--accent); }
.stat-icon.red    { background: #fef2f2; color: var(--danger); }
.stat-info .value { font-size: 1.4rem; font-weight: 700; }
.stat-info .label { font-size: .76rem; color: var(--muted); margin-top: 2px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; min-width: 480px; }
thead th { background: var(--bg); padding: 10px 12px; text-align: left; font-weight: 600; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8faff; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: .71rem; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #e0f2fe; color: #075985; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 7px; font-size: .85rem; font-weight: 600; cursor: pointer; border: none; transition: all .18s; text-decoration: none; min-height: 38px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 6px 11px; font-size: .78rem; min-height: 32px; }
.btn-lg { padding: 13px 24px; font-size: 1rem; }

/* ---- Forms ---- */
.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-size: .83rem; font-weight: 600; margin-bottom: 6px; }
.form-control { width: 100%; padding: 10px 13px; border: 1px solid var(--border); border-radius: 7px; font-size: .9rem; background: #fff; color: var(--text); transition: border .18s; outline: none; min-height: 42px; }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(49,87,245,.1); }
select.form-control { cursor: pointer; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: 8px; font-size: .88rem; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ---- Modals ---- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 900; align-items: center; justify-content: center; padding: 14px; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 100%; max-width: 540px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 1.4rem; color: var(--muted); padding: 4px 8px; }

/* ---- POS Layout (pharmacy till) ---- */
#pos-layout {
  --pos-teal: #0f6b5c;
  --pos-teal-soft: #e7f4f1;
  --pos-teal-line: #c5d4cf;
  --pos-ink: #16332e;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 36%);
  gap: 12px;
  height: calc(100vh - 58px);
  height: calc(100dvh - 58px);
  padding: 10px;
  box-sizing: border-box;
  background: #e6ece9;
}
#pos-left, #pos-right {
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--pos-teal-line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  min-width: 0;
}
#pos-right {
  overflow: hidden;
  box-shadow: inset 4px 0 0 var(--pos-teal);
}

@media (min-width: 821px) {
  html:has(#pos-layout),
  body:has(#pos-layout) { height: 100%; overflow: hidden; }
  #main:has(#pos-layout) {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }
  #main:has(#pos-layout) #pos-layout {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }
}

#pos-search-bar { padding: 10px 12px; border-bottom: 1px solid var(--pos-teal-line); display: flex; gap: 8px; flex-wrap: wrap; background: #f7faf8; flex-shrink: 0; }
#pos-cat-bar { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--pos-teal-line); background: #f7faf8; flex-shrink: 0; }
.pos-cat-chip { border: 1px solid var(--pos-teal-line); background: #fff; border-radius: 6px; padding: 5px 11px; font-size: .78rem; font-weight: 600; cursor: pointer; color: var(--text); }
.pos-cat-chip.active { background: var(--pos-teal); color: #fff; border-color: var(--pos-teal); }
#product-search { width: 100%; min-width: 160px; padding: 11px 12px; font-size: 1rem; border: 2px solid var(--pos-teal); border-radius: 6px; outline: none; background: #fff; }
#product-search:focus { box-shadow: 0 0 0 3px rgba(15,107,92,.16); border-color: var(--pos-teal); }

#product-grid {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
  align-content: start;
  background: #fbfcfb;
}
.product-card {
  border: 1px solid #d7e0dc;
  border-radius: 6px;
  padding: 14px 14px 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color .12s, background .12s;
  background: #fff;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 124px;
  /* Skip layout/paint for off-screen cards (large catalogs) */
  content-visibility: auto;
  contain-intrinsic-size: auto 124px;
}
.product-card:hover { border-color: var(--pos-teal); background: #f3faf8; }
.product-card:focus-visible { outline: 2px solid var(--pos-teal); outline-offset: 2px; }
.product-card .pname {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
  padding-right: 40px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  min-height: 2.6em;
  color: var(--pos-ink);
}
.product-card .psalt {
  font-size: .78rem;
  color: var(--pos-teal);
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.cart-item .item-salt { font-size: .72rem; color: var(--pos-teal); font-weight: 600; }
.search-result-item .ssalt { display:block; color: var(--pos-teal); font-size: .72rem; font-weight: 600; }
.product-card .pmeta {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #e4ece8;
}
.product-card .pprice { font-size: 1.12rem; font-weight: 800; color: var(--pos-teal); line-height: 1.1; white-space: nowrap; }
.product-card .pstock {
  font-size: .7rem;
  font-weight: 700;
  color: #334155;
  background: #eef2f0;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  margin: 0;
}
.product-card .pstock.is-out { background: #fee2e2; color: #991b1b; }
.product-card .pstock.is-low { background: #fef3c7; color: #92400e; }
.product-card .pstock.is-ok { background: #dcfce7; color: #166534; }
.product-card .pstock.is-svc { background: #e0f2fe; color: #075985; }
.product-card.is-blocked {
  background: #f8fafc;
  border-style: dashed;
  opacity: .85;
  pointer-events: none;
  cursor: not-allowed;
}
.product-card.is-blocked:hover { box-shadow: none; background: #f8fafc; }
.product-card .pexpiry { position: absolute; top: 8px; right: 8px; font-size: .62rem; padding: 2px 6px; border-radius: 4px; font-weight: 700; z-index: 1; }
.pexpiry.expired  { background: #fee2e2; color: #991b1b; }
.pexpiry.expiring { background: #fef3c7; color: #92400e; }

/* Cart — header + customer + scrolling lines + pinned ticket footer */
#cart-header {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--pos-teal);
  color: #fff;
  flex-shrink: 0;
}
#cart-header h3 { font-size: .95rem; font-weight: 700; letter-spacing: .02em; }
#cart-count { font-size: .78rem; color: rgba(255,255,255,.8); }
.cart-customer {
  padding: 8px 12px;
  border-bottom: 1px solid var(--pos-teal-line);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
  background: #fff;
}
.cart-customer .form-control { flex: 1; min-height: 36px; padding: 6px 10px; }
.cart-add-customer { min-height: 36px; }
#cart-items { flex: 1 1 0; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; min-height: 0; background: #fff; }
#cart-items .empty-state {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.cart-item { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 10px 14px; border-bottom: 1px solid #eef2f0; align-items: center; }
.cart-item:last-child { border-bottom: none; }
.cart-item .item-name { font-size: .88rem; font-weight: 600; color: var(--pos-ink); }
.cart-item .item-price { font-size: .77rem; color: var(--muted); }
.cart-item .item-total { font-weight: 700; font-size: .92rem; text-align: right; }
.qty-controls { display: flex; align-items: center; gap: 6px; }
.qty-btn { width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--pos-teal-line); background: #f3f6f4; cursor: pointer; font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.qty-btn:hover { background: var(--pos-teal); color: #fff; border-color: var(--pos-teal); }
.qty-display { font-weight: 700; min-width: 26px; text-align: center; font-size: .92rem; }
.remove-item { background: none; border: none; color: var(--danger); cursor: pointer; font-size: .85rem; padding: 6px 7px; border-radius: 5px; }
.remove-item:hover { background: #fee2e2; }

#cart-footer {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--pos-teal-line);
  background: #f4f8f6;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.foot-totals,
.foot-pay { width: 100%; min-width: 0; }

.tender-block { margin: 0; }
.tender-aside {
  flex-shrink: 0;
  font-size: .78rem;
  font-weight: 700;
  color: var(--success);
  white-space: nowrap;
}
.tender-aside.tender-due { color: var(--danger); }

/* Action buttons stay inside the sale ticket — never a viewport-fixed bar */
.foot-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.7fr);
  gap: 8px;
  position: static;
}
.foot-actions #btn-checkout,
.foot-actions #btn-save-draft,
.foot-actions #btn-clear-cart {
  width: auto;
  margin-top: 0;
  min-width: 0;
}

@media (min-width: 821px) and (max-height: 760px) {
  #cart-header { padding: 8px 12px; }
  .cart-customer { padding: 6px 10px; }
  #cart-footer { padding: 8px 10px 10px; gap: 6px; }
  #cart-footer .discount-row { margin: 4px 0; }
  #cart-footer .payment-method { margin: 0; }
  #cart-footer .totals-row { margin-bottom: 2px; }
  #cart-footer .totals-row.grand { padding-top: 5px; margin-top: 2px; }
  .pay-btn { min-height: 38px; padding: 7px 4px; }
  .foot-actions #btn-checkout { padding: 9px 8px; min-height: 40px; font-size: .92rem; }
  .foot-actions #btn-save-draft,
  .foot-actions #btn-clear-cart { padding: 8px; min-height: 40px; }
}

@media (min-width: 1400px) {
  #pos-layout { grid-template-columns: minmax(0, 1fr) minmax(440px, 34%); }
  #product-grid { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
}

@media print {
  .foot-actions { display: none !important; }
}



.totals-row { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: 4px; }
.totals-row.grand { font-weight: 800; font-size: 1.15rem; border-top: 1px solid var(--pos-teal-line, var(--border)); padding-top: 7px; margin-top: 4px; color: var(--pos-ink, var(--text)); }
.discount-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.discount-row label { font-size: .8rem; font-weight: 700; white-space: nowrap; }
.discount-row input { flex: 1; min-width: 0; padding: 7px 10px; border: 1px solid var(--pos-teal-line, var(--border)); border-radius: 6px; font-size: .9rem; min-height: 36px; }
#disc-type-toggle { display: inline-flex; flex-shrink: 0; border: 1px solid var(--pos-teal-line, var(--border)); border-radius: 6px; overflow: hidden; }
.disc-type { border: none; padding: 7px 11px; font-size: .82rem; font-weight: 700; cursor: pointer; background: #fff; color: var(--text); }
.disc-type.active { background: var(--pos-teal, #0f6b5c); color: #fff; }

.payment-method {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
  width: 100%;
}
.pay-btn {
  width: 100%;
  min-width: 0;
  padding: 8px 4px;
  border: 1px solid var(--pos-teal-line, var(--border));
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 700;
  min-height: 40px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pay-btn.active { border-color: var(--pos-teal, #0f6b5c); background: var(--pos-teal-soft, #e7f4f1); color: var(--pos-teal, #0f6b5c); }

#btn-checkout { width: 100%; padding: 11px 10px; font-size: .95rem; font-weight: 800; background: var(--success); color: #fff; border: none; border-radius: 6px; cursor: pointer; margin-top: 0; min-height: 44px; }
#btn-checkout:hover { background: #047857; }
#btn-checkout:disabled { background: #94a3b8; cursor: not-allowed; }
#btn-save-draft { width: 100%; padding: 10px; font-size: .82rem; font-weight: 700; background: #fff; color: #92400e; border: 1px solid #e8d48b; border-radius: 6px; cursor: pointer; margin-top: 0; min-height: 44px; }
#btn-save-draft:hover { background: #fffbeb; }
#btn-clear-cart { width: 100%; padding: 10px; font-size: .82rem; font-weight: 700; background: #fff; color: var(--danger); border: 1px solid #f0b4b4; border-radius: 6px; cursor: pointer; margin-top: 0; min-height: 44px; }
#btn-clear-cart:hover { background: #fee2e2; }

.drafts-bar { padding: 8px 12px; background: #fffbeb; border-bottom: 1px solid #fde68a; font-size: .8rem; flex-shrink: 0; }
.draft-chip { display: inline-block; background: #fef3c7; border: 1px solid #fde68a; border-radius: 5px; padding: 6px 10px; margin: 2px; cursor: pointer; font-size: .78rem; transition: background .15s; }
.draft-chip:hover { background: #fde68a; }
.draft-chip .del-draft { color: var(--danger); margin-left: 4px; font-weight: 700; }

/* Receipt modal (screen preview only — print CSS lives in pos.php) */
#receipt-modal .modal { max-width: 380px; }

/* ---- Misc ---- */
.empty-state { text-align: center; padding: 36px 18px; color: var(--muted); }
.empty-state svg { opacity: .3; margin-bottom: 10px; }
.empty-state p { font-size: .9rem; }

.search-results-dropdown { position: absolute; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); z-index: 400; max-height: 260px; overflow-y: auto; min-width: 240px; }
.search-result-item { padding: 12px 14px; cursor: pointer; font-size: .88rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.search-result-item:hover { background: var(--bg); }
.search-result-item .sname { font-weight: 600; }
.search-result-item .sprice { color: var(--pos-teal, var(--accent)); font-weight: 700; white-space: nowrap; }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .6s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.low-stock-badge { color: var(--danger); font-weight: 700; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-form-list { display: grid; grid-template-columns: 340px 1fr; gap: 18px; }

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */

/* Tablets and below */
@media (max-width: 1024px) {
  #pos-layout { grid-template-columns: minmax(0, 1fr) minmax(380px, 40%); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-form-list { grid-template-columns: 1fr; }
  #product-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
}

/* Mobile */
@media (max-width: 820px) {
  /* Sidebar becomes off-canvas drawer */
  #sidebar { width: var(--sidebar-w); transform: translateX(-100%); box-shadow: 4px 0 24px rgba(0,0,0,.25); }
  #sidebar .nav-label { opacity: 1 !important; width: auto !important; pointer-events: auto !important; }
  #sidebar nav a { justify-content: flex-start !important; padding-left: 18px !important; gap: 11px !important; }
  #sidebar.open { transform: translateX(0); }
  #sidebar-overlay.show { display: block; }

  #menu-toggle { display: inline-flex; align-items: center; }

  #main { margin-left: 0; }
  #topbar { padding: 0 12px; }
  #topbar h2 { font-size: .92rem; }
  .topbar-right span { display: none; } /* hide date on small screens */

  .content { padding: 14px; }
  .card { padding: 15px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 13px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-info .value { font-size: 1.1rem; }

  /* POS: stack — products on top, full sale ticket below. Page scrolls so
     Draft / Empty / Complete are always reachable on a phone. */
  #pos-layout {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: calc(100dvh - 58px);
    padding: 8px;
    gap: 8px;
    overflow: visible;
  }
  #pos-left {
    flex: none;
    height: 46vh;
    min-height: 240px;
  }
  #pos-right {
    flex: none;
    height: auto;
    overflow: visible;
    width: 100%;
    max-width: none;
    box-shadow: inset 0 4px 0 var(--pos-teal);
  }
  #cart-items { flex: 0 0 auto; max-height: none; overflow: visible; }
  #product-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 10px; padding: 10px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .product-card { padding: 12px; min-height: 112px; }
  .product-card .pname { font-size: .92rem; min-height: 2.4em; }
  .product-card .pprice { font-size: 1rem; }
  .payment-method { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .foot-actions { grid-template-columns: 1fr 1fr; }
  .foot-actions #btn-checkout { grid-column: 1 / -1; }

  #pos-search-bar { padding: 8px; gap: 6px; }
  #product-search { min-width: 0; font-size: 16px; } /* 16px stops iOS zoom */

  .modal { padding: 18px; border-radius: 12px 12px 0 0; max-width: none; align-self: flex-end; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  #receipt-modal .modal { max-width: none; }

  table { font-size: .8rem; }
  thead th, tbody td { padding: 8px 9px; }
}

/* Small phones — 2 wider columns so names stay readable */
@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr; }
  #product-grid { grid-template-columns: repeat(2, 1fr); }
  .payment-method { flex-direction: row; }
}

/* Inline UI icons (includes/icons.php) */
.btn .ui-ic { flex-shrink: 0; }
.alert .ui-ic { margin-right: 4px; }

/* POS: search-driven results */
.pos-search-hint { grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; color: var(--muted); padding: 60px 16px; font-size: .95rem; line-height: 1.5; }
.pos-search-hint .ui-ic { opacity: .5; }
.pos-search-more { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: .8rem; padding: 6px; }
.product-card .pinfo { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .76rem; color: #475569; }
.product-card .pinfo b { font-weight: 600; color: #64748b; }
.product-card .pinfo .pinfo-warn { color: #92400e; font-weight: 600; }
.product-card .pinfo .pinfo-bad { color: #991b1b; font-weight: 700; }
.product-card .pprice small { font-size: .7rem; font-weight: 600; color: var(--muted); }
.cart-item .qty-controls { flex-wrap: wrap; }
.cart-item .unit-select { min-height: 32px; padding: 4px 6px; border: 1px solid var(--pos-teal-line); border-radius: 6px; font-size: .8rem; font-weight: 600; background: #fff; max-width: 120px; }
.cart-item .item-units { color: var(--pos-teal); font-weight: 600; }
