/* ============================================================
   Components — Premium UI Kit
   Buttons, Cards, Modals, Tables, Forms, POS, and more
   Responsive: 320px → 2560px+
   ============================================================ */

/* ======================== BUTTONS ======================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(79,70,229,0.4); }

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
  box-shadow: var(--shadow-success);
}
.btn-success:hover { box-shadow: 0 6px 20px rgba(16,185,129,0.4); }

.btn-warning {
  background: linear-gradient(135deg, var(--warning), #d97706);
  color: #fff;
  box-shadow: 0 2px 8px rgba(245,158,11,0.3);
}
.btn-warning:hover { box-shadow: 0 6px 20px rgba(245,158,11,0.4); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: #fff;
  box-shadow: var(--shadow-danger);
}
.btn-danger:hover { box-shadow: 0 6px 20px rgba(239,68,68,0.4); }

.btn-info {
  background: linear-gradient(135deg, var(--info), #0284c7);
  color: #fff;
  box-shadow: 0 2px 8px rgba(6,182,212,0.3);
}
.btn-info:hover { box-shadow: 0 6px 20px rgba(6,182,212,0.4); }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border-dark);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-bg);
  box-shadow: var(--shadow-xs);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg); color: var(--primary); }

.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius);
}
.btn-icon.btn-sm { width: 30px; height: 30px; }

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ======================== CARDS ======================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-width: 0;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-body { }

.card-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* === STAT CARDS === */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--primary-light), transparent);
  opacity: 0;
  transition: opacity var(--transition);
}
.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.stat-card:hover::before { opacity: 1; }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-icon.primary { background: var(--primary-bg); color: var(--primary); }
.stat-icon.success { background: var(--success-bg); color: var(--success); }
.stat-icon.warning { background: var(--warning-bg); color: var(--warning); }
.stat-icon.danger  { background: var(--danger-bg);  color: var(--danger); }
.stat-icon.info    { background: var(--info-bg);    color: var(--info); }

.stat-info { flex: 1; min-width: 0; }
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.stat-change {
  font-size: 0.75rem;
  margin-top: 6px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}
.stat-change.up   { color: var(--success); background: var(--success-bg); }
.stat-change.down { color: var(--danger); background: var(--danger-bg); }

/* ======================== FORMS ======================== */
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:hover { border-color: var(--border-dark); }
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control.error { border-color: var(--danger); }
.form-control.error:focus { box-shadow: 0 0 0 3px var(--danger-bg); }

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .form-control {
  border-radius: var(--radius) 0 0 var(--radius);
}
.input-group .input-addon {
  padding: 10px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
}

/* ======================== TABLES ======================== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  max-width: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.data-table th,
.data-table td {
  padding: 13px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.data-table th {
  background: var(--bg);
  font-weight: 700;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table tbody tr {
  transition: background var(--transition);
}
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.table-actions {
  display: flex;
  gap: 4px;
}

/* ======================== MODALS ======================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}
.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(24px) scale(0.96);
  transition: transform var(--transition-bounce);
}
.modal-overlay.show .modal {
  transform: translateY(0) scale(1);
}

.modal-sm { max-width: 400px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  padding: 6px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.modal-close:hover { color: var(--danger); background: var(--danger-bg); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
}

/* ======================== BADGES ======================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-primary { background: var(--primary-bg); color: var(--primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-muted   { background: var(--bg);         color: var(--text-muted); }

/* ======================== SEARCH & FILTERS ======================== */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 400px;
}
.search-box .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}
.search-box .search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.88rem;
  color: var(--text);
  outline: none;
  transition: all var(--transition);
}
.search-box .search-input:hover { border-color: var(--border-dark); }
.search-box .search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Date preset quick-filter buttons */
.date-presets {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.filter-bar .form-control {
  width: auto;
  min-width: 140px;
}

/* ======================== INV TABS (Inventory sub-navigation) ======================== */
.inv-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.inv-tabs::-webkit-scrollbar { display: none; }
.inv-tab {
  padding: 10px 22px;
  border: none;
  background: none;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted);
  transition: all 0.2s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.inv-tab:hover { color: var(--text-secondary); }
.inv-tab.active {
  border-bottom-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* ======================== DETAIL GRIDS (modal info grids) ======================== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.detail-grid > div { min-width: 0; }
@media (max-width: 480px) {
  .detail-grid { grid-template-columns: 1fr; gap: 8px; }
}

/* ======================== PAGINATION ======================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  gap: 12px;
  flex-wrap: wrap;
}
.pagination-info {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination-btn {
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.pagination-btn:hover {
  background: var(--primary-bg);
  color: var(--primary);
  border-color: var(--primary);
}
.pagination-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: var(--shadow-primary);
}
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ======================== PAGE HEADER ======================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-left { flex: 1; min-width: 0; }
.page-header-right { display: flex; gap: 8px; flex-wrap: wrap; }
.page-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px;
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ======================== PRODUCT GRID ======================== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 16px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  position: relative;
}
.product-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.product-card:active { transform: translateY(0); }
.product-card.out-of-stock {
  opacity: 0.45;
  pointer-events: none;
}
.product-card.out-of-stock::after {
  content: 'Out of Stock';
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--danger-bg);
  color: var(--danger);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}
.product-card .product-img {
  width: 64px;
  height: 64px;
  border-radius: var(--radius);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  font-size: 1.5rem;
  color: var(--text-muted);
  overflow: hidden;
}
.product-card .product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-card .product-name {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.product-card .product-price {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}
.product-card .product-stock {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ======================== POS LAYOUT ======================== */

/* ── Root grid ─────────────────────────────────────── */
.pos-root {
  display: grid;
  grid-template-columns: 1fr 390px;
  grid-template-rows: 1fr;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

/* ── Left: Product Browser ─────────────────────────── */
.pos-left {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1.5px solid var(--border);
  background: var(--bg);
  min-width: 0;
}

/* Top search bar */
.pos-topbar {
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.pos-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.pos-barcode-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.pos-barcode-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  background: var(--surface);
}
.pos-search-icon {
  position: absolute;
  left: 10px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}
.pos-input {
  width: 100%;
  padding: 8px 8px 8px 32px;
  font-size: 0.85rem;
  border: none;
  background: transparent;
  outline: none;
  color: var(--text);
  font-family: inherit;
  flex: 1;
  min-width: 0;
}
.pos-input::placeholder { color: var(--text-muted); }
.pos-cam-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 5px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color var(--transition), background var(--transition);
}
.pos-cam-btn:hover { color: var(--primary); background: var(--primary-bg); }

/* Mobile cart toggle button */
.pos-cart-toggle {
  display: none;   /* hidden on desktop */
  position: relative;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.pos-cart-toggle:hover { background: var(--primary-dark); }
.pos-cart-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
  border: 2px solid var(--surface);
}

/* Category pills */
.pos-cats {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  scrollbar-width: none;
}
.pos-cats::-webkit-scrollbar { display: none; }
.pos-cat {
  white-space: nowrap;
  padding: 5px 14px;
  font-size: 0.77rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  -webkit-tap-highlight-color: transparent;
}
.pos-cat:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.pos-cat.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: var(--shadow-primary); }

/* Product grid */
.pos-grid {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  align-content: start;
}
.pos-grid::-webkit-scrollbar { width: 4px; }
.pos-grid::-webkit-scrollbar-track { background: transparent; }
.pos-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Product card */
.pos-product-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.18s ease;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.pos-product-card:not(.oos):hover {
  border-color: var(--primary);
  box-shadow: 0 4px 18px rgba(37, 99, 235, 0.13);
  transform: translateY(-2px);
}
.pos-product-card:not(.oos):active { transform: scale(0.97); }
.pos-product-card.oos {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.4);
}
.ppc-img {
  position: relative;
  height: 90px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}
.ppc-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ppc-ph { font-size: 2rem; opacity: 0.6; }
.ppc-oos, .ppc-low {
  position: absolute;
  top: 5px;
  right: 5px;
  font-size: 0.63rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
  line-height: 1.4;
}
.ppc-oos { background: var(--danger); color: #fff; }
.ppc-low { background: var(--warning); color: #fff; }
.ppc-info {
  padding: 8px 10px 10px;
  flex: 1;
}
.ppc-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}
.ppc-price {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--primary);
}
.ppc-stock {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Right: Cart Panel ─────────────────────────────── */
.pos-right {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}

/* Mobile backdrop */
.pos-backdrop {
  display: none;
}

.pos-cart-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  height: 100%;
  border-left: 1.5px solid var(--border);
}

/* Cart header */
.pcp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
}
.pcp-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
}
.pcp-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 5px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.pcp-icon-btn:hover { background: var(--bg); color: var(--text); }
.pcp-icon-btn:hover:first-child { color: var(--danger); }
.pcp-close-mobile { display: none; }  /* visible only on mobile */

/* Cart items list */
.pcp-items {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  border-top: 1px solid var(--border-light);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.pcp-items::-webkit-scrollbar { width: 3px; }
.pcp-items::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Empty state */
.pcp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  height: 100%;
  min-height: 100px;
}

/* Cart rows */
.pcp-cart-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.pcp-cart-row:hover { background: var(--bg); }
.pcr-info { flex: 1; min-width: 0; }
.pcr-name {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.pcr-unit { font-size: 0.68rem; color: var(--text-muted); margin-top: 1px; }
.pcr-controls {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.pcr-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: all var(--transition);
  flex-shrink: 0;
}
.pcr-btn:hover { background: var(--primary-bg); color: var(--primary); }
.pcr-qty {
  width: 24px;
  text-align: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text);
}
.pcr-qty-input {
  width: 46px;
  text-align: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  padding: 2px 3px;
  -moz-appearance: textfield;
}
.pcr-qty-input::-webkit-inner-spin-button,
.pcr-qty-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pcr-qty-input:focus { outline: none; border-color: var(--primary); }
.pcr-total {
  font-weight: 700;
  font-size: 0.78rem;
  min-width: 58px;
  text-align: right;
  color: var(--text);
}
.pcr-del {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 3px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.pcr-del:hover { color: var(--danger); background: var(--danger-bg); }

/* Block sections */
.pcp-block {
  padding: 6px 12px;
  border-top: 1px solid var(--border-light);
  flex-shrink: 0;
  position: relative;
}
.pcp-label {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.pcp-input {
  width: 100%;
  padding: 6px 10px;
  font-size: 0.82rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.pcp-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: var(--surface);
}
.pcp-ghost-btn {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  padding: 6px 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.pcp-ghost-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }

/* Customer dropdown */
.pcp-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 160px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.pcp-dd-item {
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
.pcp-dd-item:hover { background: var(--primary-bg); color: var(--primary); }
.pcp-dd-item:last-child { border-bottom: none; }

/* Selected customer tag */
.pcp-cust-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-bg);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: var(--radius);
  padding: 5px 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--primary);
}
.pcp-cust-tag span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Totals */
.pcp-totals {
  padding: 6px 12px;
  border-top: 2px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.pcp-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.pcp-grand {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary);
  border-top: 2px solid var(--border);
  padding-top: 5px;
  margin-top: 3px;
}

/* Payment methods */
.pcp-methods {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 2px;
}
.pcp-method {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 6px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text-secondary);
  -webkit-tap-highlight-color: transparent;
}
.pcp-method span { font-size: 0.9rem; }
.pcp-method:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.pcp-method.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Notices */
.pcp-notice {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius);
}
.pcp-notice.warning { background: #fef3c7; color: #92400e; border: 1px solid #f59e0b; }
.pcp-notice.success { background: #d1fae5; color: #065f46; border: 1px solid #10b981; }
.pcp-notice.danger { background: #fee2e2; color: #991b1b; border: 1px solid #ef4444; }

/* Checkout */
.pcp-checkout {
  padding: 8px 12px;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.pcp-btn-checkout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 20px;
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.pcp-btn-checkout:hover { background: #059669; box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4); transform: translateY(-1px); }
.pcp-btn-checkout:active { transform: none; }
.pcp-btn-checkout:disabled { opacity: 0.6; cursor: not-allowed; transform: none; box-shadow: none; }

/* ======================== DASHBOARD GRID ======================== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 24px;
}

/* ======================== CARD GRID ======================== */
.card-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ======================== TAB PANEL ======================== */
.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease;
}
.tab-panel.show {
  display: block;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ======================== EMPTY STATE ======================== */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  opacity: 0.35;
}
.empty-state .empty-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.empty-state .empty-text {
  font-size: 0.88rem;
  max-width: 380px;
  margin: 0 auto 24px;
  line-height: 1.6;
}

/* ======================== LOADING ======================== */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.spinner-sm { width: 20px; height: 20px; border-width: 2px; }
.spinner-lg { width: 48px; height: 48px; border-width: 4px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Full page loader */
.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 9999;
}
.page-loader .loader-text {
  font-size: 0.92rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ======================== TABS ======================== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 11px 22px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

/* ======================== ALERTS ======================== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger); }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info); }

/* ======================== TOAST ======================== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border-left: 4px solid;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  animation: toastIn 0.35s var(--transition-bounce);
  min-width: 300px;
}
.toast.removing { animation: toastOut 0.3s ease forwards; }

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info    { border-left-color: var(--info); }

.toast .toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-success .toast-icon { color: var(--success); }
.toast-error   .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info    .toast-icon { color: var(--info); }

.toast .toast-msg { flex: 1; }
.toast .toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  border-radius: var(--radius);
  transition: all var(--transition);
}
.toast .toast-close:hover { color: var(--text); background: var(--bg); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

/* ======================== CONFIRM DIALOG ======================== */
.confirm-body {
  text-align: center;
  padding: 28px 0;
}
.confirm-body .confirm-icon {
  font-size: 3.2rem;
  margin-bottom: 16px;
}
.confirm-body .confirm-icon.warning { color: var(--warning); }
.confirm-body .confirm-icon.danger  { color: var(--danger); }
.confirm-body .confirm-text {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ======================== AVATAR ======================== */
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.7rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }
.avatar-primary { background: var(--primary-bg); color: var(--primary); }
.avatar-success { background: var(--success-bg); color: var(--success); }

/* ======================== UTILITY ======================== */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8  { gap: 8px; }
.gap-16 { gap: 16px; }

.d-flex { display: flex; }
.d-grid { display: grid; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* ======================== RESPONSIVE VISIBILITY ======================== */
@media (max-width: 1024px) { .hide-tablet, .hide-tablet-down { display: none !important; } }
@media (max-width: 768px)  { .hide-mobile { display: none !important; } }
@media (min-width: 769px)  { .show-mobile-only { display: none !important; } }

/* ============================================================
   RESPONSIVE — Every device from 320px → 2560px+
   ============================================================ */

/* ---------- XL Desktop: ≥ 1536px ---------- */
@media (min-width: 1536px) {
  .stat-cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
  .stat-card { padding: 26px; }
  .stat-value { font-size: 1.8rem; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
  .dashboard-grid { gap: 28px; }
  .pos-root { grid-template-columns: 1fr 420px; }
}

/* ---------- TV / Ultra-wide: ≥ 1920px ---------- */
@media (min-width: 1920px) {
  .stat-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .stat-value { font-size: 2rem; }
  .stat-icon { width: 60px; height: 60px; font-size: 1.5rem; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
  .pos-root { grid-template-columns: 1fr 460px; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
  .dashboard-grid { gap: 32px; }
  .card { padding: 28px; }
  .page-title { font-size: 1.7rem; }
}

/* ---------- 4K: ≥ 2560px ---------- */
@media (min-width: 2560px) {
  .stat-cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 28px; }
  .stat-card { padding: 32px; gap: 20px; }
  .stat-icon { width: 68px; height: 68px; font-size: 1.7rem; }
  .stat-value { font-size: 2.2rem; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 24px; }
  .pos-root { grid-template-columns: 1fr 520px; }
  .card { padding: 36px; }
  .page-title { font-size: 1.9rem; }
  .data-table th, .data-table td { padding: 16px 22px; }
  .btn { padding: 14px 28px; }
  .modal { max-width: 640px; }
  .modal-lg { max-width: 900px; }
}

/* ---------- Medium desktop: ≤ 1280px ---------- */
@media (max-width: 1280px) {
  .pos-root { grid-template-columns: 1fr 350px; }
  .stat-cards { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* ---------- Tablet: ≤ 1024px ---------- */
@media (max-width: 1024px) {
  .stat-cards {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 14px;
  }
  .stat-card { padding: 18px; }
  .stat-value { font-size: 1.35rem; }
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
  }
  .pos-root { grid-template-columns: 1fr 320px; }
  .dashboard-grid { gap: 16px; }
  .card { padding: 18px; }
}

/* ---------- Narrow desktop / landscape tablet: ≤ 900px ---------- */
@media (max-width: 900px) {
  .page-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .search-box { max-width: 100%; }
  .filter-bar { flex-wrap: wrap; gap: 8px; }
  .filter-bar .form-control,
  .filter-bar input,
  .filter-bar select { min-width: 0 !important; }
  .dashboard-grid { grid-template-columns: 1fr; gap: 16px; }
}

/* ---------- Mobile: ≤ 768px ---------- */
@media (max-width: 768px) {
  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
  }
  .page-header-right { width: 100%; flex-wrap: wrap; }
  .page-header-right .btn { flex: 1; min-width: 100px; justify-content: center; }
  .page-title { font-size: 1.2rem; }

  /* Stat cards */
  .stat-cards {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
  }
  .stat-card { padding: 14px; gap: 10px; }
  .stat-icon { width: 42px; height: 42px; font-size: 1rem; }
  .stat-value { font-size: 1.15rem; }
  .stat-label { font-size: 0.7rem; }

  /* Toolbar / Filters */
  .page-toolbar {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  .search-box { max-width: 100%; }
  .filter-bar { width: 100%; gap: 6px; flex-wrap: wrap; }
  .filter-bar .form-control,
  .filter-bar input,
  .filter-bar select { min-width: 0 !important; flex: 1 !important; width: auto !important; }
  .date-presets { width: 100%; }

  /* Tables — allow wrapping on mobile */
  .data-table th,
  .data-table td { padding: 10px 12px; font-size: 0.82rem; white-space: normal; word-break: break-word; }
  .table-wrapper { border-radius: var(--radius); }
  .table-actions { gap: 2px; flex-wrap: nowrap; }
  .table-actions .btn-icon { width: 30px; height: 30px; flex-shrink: 0; }
  .table-actions .btn-icon.btn-sm { width: 26px; height: 26px; }

  /* Modals — full screen on mobile */
  .modal-overlay { padding: 0; }
  .modal {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    height: 100vh;
    height: 100dvh;
  }
  .modal-sm, .modal-md, .modal-lg, .modal-xl { max-width: 100%; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px; }

  /* Forms */
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .form-group { margin-bottom: 14px; }

  /* Detail grids & inline 2-col grids → single column on mobile */
  .detail-grid { grid-template-columns: 1fr; }
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Cards */
  .card { padding: 16px; }

  /* Tabs */
  .tab { padding: 9px 16px; font-size: 0.82rem; }

  /* Product grid */
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }
  .product-card { padding: 12px; }
  .product-card .product-img { width: 50px; height: 50px; }
  .product-card .product-name { font-size: 0.78rem; }
  .product-card .product-price { font-size: 0.88rem; }

  /* POS Layout — mobile overlay cart */
  .pos-root {
    display: block;
    height: 100%;
    overflow: hidden;
    position: relative;
  }
  .pos-left {
    height: 100%;
    border-right: none;
  }
  .pos-cart-toggle { display: flex; }  /* show toggle on mobile */
  .pos-right {
    position: fixed;
    inset: 0;
    z-index: 300;
    pointer-events: none;
  }
  .pos-right.active { pointer-events: auto; }
  .pos-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
  }
  .pos-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }
  .pos-cart-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    pointer-events: auto;
    border-left: none;
    border-top: 1.5px solid var(--border);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
  }
  .pos-cart-panel.open {
    transform: translateY(0);
  }
  .pcp-close-mobile { display: flex; }
  .pos-cats { padding: 8px 12px; gap: 4px; }
  .pos-cat { padding: 4px 12px; font-size: 0.72rem; }
  .pos-topbar { padding: 10px 12px; }

  /* Dashboard grid */
  .dashboard-grid { grid-template-columns: 1fr; gap: 14px; }

  /* Dashboard quick actions — fill-width grid on mobile */
  .dashboard-grid ~ .card .btn-group,
  .card .btn-group { display: grid; grid-template-columns: 1fr 1fr; }
  .card .btn-group .btn { justify-content: center; text-align: center; }

  /* Dashboard card tables — compact on mobile */
  .card .table-wrapper .data-table th,
  .card .table-wrapper .data-table td { padding: 8px 10px; font-size: 0.78rem; }

  /* Stat value overflow prevention */
  .stat-value { word-break: break-word; font-size: 1.1rem; }
  .stat-info { min-width: 0; overflow: hidden; }

  /* Inventory table — compact image on mobile */
  .data-table .inv-img-cell { width: 36px !important; }
  .data-table .inv-img-cell > div { width: 36px !important; height: 36px !important; }

  /* Pagination */
  .pagination { flex-direction: column; gap: 8px; text-align: center; }

  /* Alerts */
  .alert { font-size: 0.82rem; padding: 10px 12px; }

  /* Toast — show above bottom nav */
  #toast-container {
    top: auto;
    bottom: calc(var(--bottom-nav-height) + 12px);
    left: 12px;
    right: 12px;
    max-width: none;
  }
  .toast { min-width: 0; width: 100%; font-size: 0.82rem; }

  /* Empty state */
  .empty-state { padding: 36px 16px; }
  .empty-state .empty-icon { font-size: 2.5rem; }

  /* Badge */
  .badge { font-size: 0.68rem; padding: 2px 8px; }

  /* Buttons */
  .btn { padding: 9px 16px; font-size: 0.82rem; }
  .btn:hover { transform: none; }
  .btn-lg { padding: 11px 22px; font-size: 0.92rem; }

  /* Avatar */
  .avatar { width: 36px; height: 36px; font-size: 0.82rem; }
}

/* ---------- Small phone: ≤ 480px ---------- */
@media (max-width: 480px) {
  /* Stat cards single column */
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; gap: 8px; }
  .stat-icon { width: 38px; height: 38px; font-size: 0.9rem; }
  .stat-value { font-size: 1.05rem; }

  /* Tables tighter */
  .data-table th,
  .data-table td { padding: 8px 10px; font-size: 0.78rem; }

  /* Product grid */
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .product-card { padding: 10px; }
  .product-card .product-img { width: 44px; height: 44px; }
  .product-card .product-name { font-size: 0.72rem; }
  .product-card .product-price { font-size: 0.82rem; }
  .product-card .product-stock { font-size: 0.65rem; }

  /* POS tighter on small phones */
  .pos-topbar { padding: 8px 10px; }
  .pos-input { font-size: 0.8rem; }
  .pcp-totals { padding: 6px 10px; }
  .pcp-block { padding: 6px 10px; }
  .pcp-total-row { font-size: 0.75rem; }
  .pcp-grand { font-size: 0.95rem; }
  .pcp-btn-checkout { padding: 10px 16px; font-size: 0.85rem; }
  .pcr-btn { width: 22px; height: 22px; font-size: 0.85rem; }
  .pcr-qty { width: 22px; font-size: 0.72rem; }
  .pcr-qty-input { width: 40px; font-size: 0.72rem; }

  /* Modal mobile */
  .modal-header { padding: 12px 14px; }
  .modal-title { font-size: 0.95rem; }
  .modal-body { padding: 14px; }
  .modal-footer { padding: 10px 14px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 100px; }

  /* Forms */
  .form-control { padding: 8px 12px; font-size: 0.82rem; }
  .form-label { font-size: 0.78rem; margin-bottom: 4px; }
  .form-group { margin-bottom: 12px; }

  /* Detail grid in modals — single column on small phones */
  [style*="grid-template-columns:1fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Receipt */
  .receipt-preview { font-size: 10px; padding: 12px; max-width: 100%; }

  /* Buttons */
  .btn { padding: 8px 14px; font-size: 0.78rem; gap: 6px; }
  .btn-icon { width: 32px; height: 32px; }
  .btn-icon.btn-sm { width: 28px; height: 28px; }

  /* Page title */
  .page-title { font-size: 1.1rem; }
  .page-subtitle { font-size: 0.78rem; }

  /* Inventory tabs smaller on phones */
  .inv-tab { padding: 8px 14px; font-size: 0.82rem; }

  /* Stat cards — tighter values on small phones */
  .stat-value { font-size: 0.95rem; }
  .stat-label { font-size: 0.65rem; }

  /* Quick actions — single column on small phones */
  .card .btn-group { grid-template-columns: 1fr; }

  /* Inventory image cell even smaller */
  .data-table .inv-img-cell { width: 30px !important; }
  .data-table .inv-img-cell > div { width: 30px !important; height: 30px !important; border-radius: 6px !important; }

  /* Date presets wrap tightly */
  .date-presets .btn { padding: 5px 10px; font-size: 0.72rem; }
}

/* ---------- Extra small: ≤ 360px ---------- */
@media (max-width: 360px) {
  .stat-cards { grid-template-columns: 1fr; gap: 8px; }
  .stat-card { padding: 12px; gap: 8px; }
  .stat-value { font-size: 1rem; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  /* POS extra small */
  .pcp-methods { grid-template-columns: 1fr 1fr; }
  .modal-body { padding: 12px; }
  .modal-footer { flex-direction: column; }
  .modal-footer .btn { width: 100%; }
  .page-title { font-size: 1rem; }
}

/* ---------- Landscape phone ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .pos-root {
    display: grid;
    grid-template-columns: 1fr 280px;
    height: 100%;
  }
  .pos-left {
    height: 100%;
    border-right: 1.5px solid var(--border);
  }
  .pos-right { position: static; pointer-events: auto; }
  .pos-cart-panel {
    position: static;
    transform: none;
    border-radius: 0;
    max-height: 100%;
    border-left: 1.5px solid var(--border);
    border-top: none;
    box-shadow: none;
  }
  .pos-backdrop { display: none !important; }
  .pos-cart-toggle { display: none !important; }
  .pcp-close-mobile { display: none !important; }
  .modal { height: 100vh; height: 100dvh; }
}

/* ---------- Shop context badge (page subtitles) ---------- */
.shop-ctx-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 8px;
  padding: 2px 8px;
  background: var(--primary-bg);
  color: var(--primary);
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  vertical-align: middle;
  white-space: nowrap;
}

/* ---------- POS topbar shop row ---------- */
.pos-shop-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 0 5px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 600;
}

@media (max-width: 480px) {
  .shop-ctx-badge { font-size: 0.65rem; padding: 1px 6px; }
  .pos-shop-row { font-size: 0.72rem; }
}

/* ---------- Print styles ---------- */
@media print {
  #sidebar, #top-header, #bottom-nav, .sidebar-overlay,
  .page-toolbar, .page-header-right, .table-actions,
  .btn, .modal-overlay, #toast-container { display: none !important; }

  #app-wrapper {
    display: block !important;
    grid-template-columns: 1fr !important;
  }
  #page-view {
    padding: 0 !important;
    max-height: none !important;
    height: auto !important;
    margin: 0 !important;
  }
  .card { border: none; box-shadow: none; break-inside: avoid; }
  .data-table th, .data-table td { padding: 6px 8px; }
  .stat-cards { break-inside: avoid; }
  .stat-card { box-shadow: none; border: 1px solid #ddd; }
  .stat-card:hover { transform: none; }
}