/* TimPOS Components */

/* Defense against the "must-click-twice" bug: the lucide library replaces
   <i data-lucide="…"> with an inline <svg> after page render. If a user
   clicks the <i> at the exact moment of replacement, the original target
   node is removed mid-event and the click never reaches the parent button.
   Forcing pointer-events:none on the icon means clicks pass straight
   through to the wrapping <button>/<a>, which is stable across the
   lucide swap. The post-swap <svg> still gets the click via bubbling
   (pointer-events default = auto on svg), and we explicitly preserve
   that so future styles don't accidentally disable it. */
i[data-lucide],
[data-lucide]:not(svg) {
  pointer-events: none;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch);
  padding: 0 var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--font-button);
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: var(--primary);
  border: 2px solid transparent;
  transition:
    transform var(--transition),
    background var(--transition),
    box-shadow var(--transition);
  text-align: center;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
  /* Skip iOS Safari's 300ms tap-then-zoom heuristic — every TimPOS button
     fits the "intentional tap" semantics (no pinch-to-zoom on buttons). */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn--secondary {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn--secondary:hover:not(:disabled) {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.btn--danger {
  background: var(--danger);
}
.btn--danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn--success {
  background: var(--success);
}
.btn--success:hover:not(:disabled) {
  background: #15803d;
}

.btn--warning {
  background: var(--warning);
  color: #0f172a;
}

.btn--ghost {
  background: transparent;
  color: var(--neutral-700);
  border-color: transparent;
}
.btn--ghost:hover:not(:disabled) {
  background: var(--neutral-100);
}

.btn--sm {
  min-height: var(--touch-sm);
  padding: 0 var(--space-4);
  font-size: var(--font-small);
  border-radius: var(--radius-sm);
}

.btn--lg {
  min-height: var(--touch-lg);
  padding: 0 var(--space-8);
  font-size: 22px;
}

.btn--block {
  width: 100%;
}

.btn--icon {
  min-width: var(--touch);
  padding: 0;
}
.btn--icon.btn--sm {
  min-width: var(--touch-sm);
}

/* ========== Inputs ========== */
.input,
.select,
.textarea {
  display: block;
  width: 100%;
  min-height: var(--touch);
  padding: var(--space-3) var(--space-4);
  font-size: var(--font-body);
  font-weight: 500;
  line-height: 1.4;
  color: var(--neutral-900);
  background: var(--bg-card);
  border: 2px solid var(--neutral-300);
  border-radius: var(--radius-md);
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input::placeholder {
  color: var(--neutral-400);
}

.input-lg {
  min-height: 58px;
  font-size: 20px;
  padding: 0 var(--space-4);
}

.input--error {
  border-color: var(--danger);
}

.textarea {
  min-height: 100px;
  resize: vertical;
}

.label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--font-label);
  font-weight: 600;
  color: var(--neutral-700);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field {
  margin-bottom: var(--space-4);
}

.field-error {
  margin-top: var(--space-2);
  color: var(--danger);
  font-size: var(--font-small);
}

.field-hint {
  margin-top: var(--space-2);
  color: var(--neutral-500);
  font-size: var(--font-small);
}

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--neutral-200);
  overflow: hidden;
}

.card--hoverable {
  cursor: pointer;
  transition:
    transform var(--transition),
    box-shadow var(--transition);
}
.card--hoverable:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--neutral-200);
  font-weight: 700;
  font-size: var(--font-subtitle);
}

.card-body {
  padding: var(--space-6);
}

.card-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--neutral-200);
  background: var(--bg-surface);
}

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-tiny);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--neutral-100);
  color: var(--neutral-700);
  line-height: 1.4;
}

.badge--success {
  background: var(--success-soft);
  color: var(--success);
}
.badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge--warning {
  background: var(--warning-soft);
  color: #b45309;
}
.badge--info {
  background: var(--info-soft);
  color: var(--info);
}
.badge--primary {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge--lg {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-small);
}

/* ========== Toast ========== */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 360px;
  pointer-events: none;
}

@media (max-width: 640px) {
  .toast-container {
    top: auto;
    bottom: 80px;
    left: var(--space-3);
    right: var(--space-3);
    max-width: none;
  }
  .toast-container--pos {
    display: none;
  }
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--neutral-900);
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-weight: 500;
  font-size: var(--font-body);
  pointer-events: auto;
  animation: toastSlideIn 200ms ease-out;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(20px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast--success {
  background: var(--success);
}
.toast--error {
  background: var(--danger);
}
.toast--warning {
  background: var(--warning);
  color: #0f172a;
}
.toast--info {
  background: var(--info);
}

.pos-toast-stack {
  display: none;
}

@media (max-width: 640px) {
  .pos-toast-stack {
    display: grid;
    flex-shrink: 0;
    gap: 6px;
    padding: 6px var(--space-3);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--neutral-200);
  }
  .pos-toast-stack .toast {
    min-height: 38px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    font-size: 14px;
  }
  .pos-toast-stack .toast span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 100ms ease-out;
  /* Hint the compositor so iOS Safari promotes the overlay to its own layer
     and the open animation doesn't repaint the entire page underneath. */
  will-change: opacity;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 560px;
  width: 100%;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  animation: modalPop 120ms ease-out;
  will-change: transform, opacity;
}

.modal--lg {
  max-width: 800px;
}
.modal--full {
  max-width: 100%;
}

@keyframes modalPop {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--neutral-200);
  font-size: var(--font-subtitle);
  font-weight: 700;
}

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--neutral-200);
  background: var(--bg-surface);
}

/* 2-column form grid that collapses to 1 column on phones.
   Used by the product create/edit modal (and any other form with
   multiple short fields). Hard-coded "1fr 1fr" inline styles squeeze
   labels into ~137px columns on a 375px phone — cramped + labels
   wrap awkwardly. Below 480px we drop to 1 column so each field is
   full-width and easy to tap/type on. */
.form-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
@media (max-width: 480px) {
  .form-grid-2col {
    grid-template-columns: 1fr;
  }
  .form-grid-2col > .field[style*="grid-column"] {
    grid-column: auto !important;
  }
}

.modal-close {
  background: transparent;
  color: var(--neutral-500);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  transition: background var(--transition);
  /* manipulation = remove iOS 300ms double-tap-zoom delay on this button */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.modal-close:hover {
  background: var(--neutral-100);
}
.modal-close:active {
  /* Immediate visual feedback on touch — without this iOS can feel laggy
     because the only state change is the modal disappearing 100ms later. */
  background: var(--neutral-200);
}

/* ========== POS specific: Product Card ========== */
.product-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 2px solid var(--neutral-200);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 140px;
  position: relative;
  overflow: hidden;
  /* Skip layout/paint for offscreen cards. Browser still keeps them in DOM
     for Alpine x-for keyed reconciliation, but ~90% of cards in a long grid
     are offscreen and now cost ~0 to render until scrolled into view. */
  content-visibility: auto;
  contain-intrinsic-size: 0 140px;
}

.product-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.product-card:active {
  transform: scale(0.97);
}

.product-card--out-of-stock {
  opacity: 0.6;
  cursor: not-allowed;
}

.product-card__img {
  width: 100%;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  background: var(--neutral-100);
}

.product-card__img--placeholder {
  display: grid;
  place-items: center;
  color: var(--neutral-400);
  font-size: 28px;
  background: var(--neutral-100);
}

.product-card__name {
  font-weight: 600;
  font-size: 15px;
  color: var(--neutral-900);
  line-height: 1.3;
  margin-bottom: var(--space-1);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card__price {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
  margin-top: auto;
}

.product-card__stock {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
  color: var(--neutral-700);
  font-weight: 600;
}
.product-card__stock--low {
  background: var(--warning-soft);
  color: #b45309;
}
.product-card__stock--out {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ========== POS: Cart Item ========== */
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--neutral-200);
  align-items: center;
}

.cart-item__name {
  font-weight: 600;
  font-size: 16px;
  color: var(--neutral-900);
}

.cart-item__price {
  color: var(--neutral-500);
  font-size: 14px;
}

.cart-item__total {
  font-weight: 700;
  font-size: 18px;
  color: var(--primary);
  text-align: right;
}

.cart-item__controls {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-top: var(--space-2);
}

.qty-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: grid;
  place-items: center;
  background: var(--neutral-100);
  color: var(--neutral-900);
  font-size: 20px;
  font-weight: 700;
  transition: all var(--transition);
  border: 1px solid var(--neutral-200);
}

.qty-btn:hover:not(:disabled) {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.qty-btn:active {
  transform: scale(0.9);
}

.qty-value {
  min-width: 32px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.qty-input {
  width: 56px;
  height: 40px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: var(--neutral-50);
  color: var(--neutral-900);
  padding: 0 4px;
  -moz-appearance: textfield;
  appearance: textfield;
}

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

.qty-input:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  background: #fff;
}

/* ========== Admin: Pagination ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-6);
  padding: var(--space-4) 0;
}

.pagination__btn {
  min-width: 40px;
  height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--neutral-900);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}

.pagination__btn:hover:not(:disabled):not(.pagination__btn--ellipsis) {
  background: var(--neutral-100);
  border-color: var(--primary);
  color: var(--primary);
}

.pagination__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination__btn--active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination__btn--active:hover {
  background: var(--primary);
  color: #fff;
}

.pagination__btn--ellipsis {
  border: none;
  background: transparent;
  cursor: default;
  opacity: 1 !important;
}

.pagination__info {
  margin-left: var(--space-4);
  color: var(--neutral-600);
  font-size: 13px;
}

/* ========== POS: Category pill ========== */
.category-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  color: var(--neutral-700);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  text-align: left;
  border: 2px solid transparent;
  min-height: 52px;
}

.category-pill:hover {
  background: var(--neutral-100);
}

.category-pill--active {
  background: var(--primary);
  color: #fff;
}

.category-pill--active:hover {
  background: var(--primary-dark);
}

/* ========== Numeric Keypad ========== */
.numeric-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.numeric-keypad button {
  min-height: 64px;
  font-size: 24px;
  font-weight: 700;
  background: var(--neutral-100);
  color: var(--neutral-900);
  border-radius: var(--radius-md);
  transition: all var(--transition);
  border: 2px solid transparent;
}

.numeric-keypad button:hover {
  background: var(--neutral-200);
}

.numeric-keypad button:active {
  transform: scale(0.95);
  background: var(--primary-soft);
  border-color: var(--primary);
}

/* ========== Bill quick buttons ========== */
.quick-bills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

@media (min-width: 640px) {
  .quick-bills {
    grid-template-columns: repeat(6, 1fr);
  }
}

.quick-bill {
  min-height: 56px;
  background: var(--neutral-100);
  color: var(--neutral-900);
  font-weight: 700;
  border-radius: var(--radius-md);
  font-size: 17px;
  transition: all var(--transition);
  border: 2px solid transparent;
}

.quick-bill:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.quick-bill:active {
  transform: scale(0.97);
}

/* ========== Tabs ========== */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 2px solid var(--neutral-200);
  margin-bottom: var(--space-4);
  overflow-x: auto;
}

.tab {
  padding: var(--space-3) var(--space-5);
  border-bottom: 3px solid transparent;
  font-weight: 600;
  font-size: 16px;
  color: var(--neutral-500);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  margin-bottom: -2px;
}

.tab:hover {
  color: var(--neutral-900);
}

.tab--active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ========== Spinner ========== */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--neutral-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner--lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

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

.loading-container {
  display: grid;
  place-items: center;
  min-height: 200px;
  color: var(--neutral-500);
}

/* ========== Empty state ========== */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--neutral-500);
}

.empty__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
  display: grid;
  place-items: center;
  color: var(--neutral-400);
}
.empty__icon [data-lucide] {
  width: 32px;
  height: 32px;
}

.empty__title {
  font-size: var(--font-subtitle);
  font-weight: 700;
  color: var(--neutral-700);
}

.empty__desc {
  font-size: 15px;
  max-width: 300px;
}

/* ========== Grids ========== */
.grid-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3);
}

.grid-cap-hint {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--neutral-50, #f5f5f5);
  border: 1px dashed var(--neutral-300, #d4d4d4);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-3);
  font-size: 0.875rem;
  color: var(--neutral-700, #404040);
}
.grid-cap-hint [data-lucide] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--primary, #2563eb);
}
.grid-cap-hint b {
  color: var(--primary, #2563eb);
}

@media (min-width: 768px) {
  .grid-products {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--space-4);
  }
}

/* ========== Stats cards ========== */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.stat-card__label {
  font-size: var(--font-label);
  font-weight: 600;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}

.stat-card__value {
  font-size: 32px;
  font-weight: 800;
  color: var(--neutral-900);
  line-height: 1.1;
}

.stat-card__sub {
  margin-top: var(--space-2);
  font-size: 13px;
  color: var(--neutral-500);
}

/* ========== Tables ========== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table th,
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--neutral-200);
  text-align: left;
}

.table th {
  font-size: var(--font-label);
  font-weight: 600;
  color: var(--neutral-500);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-surface);
}

.table tbody tr:hover {
  background: var(--bg-surface);
}

/* ========== Offline banner ========== */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--warning);
  color: #0f172a;
  padding: var(--space-2) var(--space-4);
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}
/* Online + queue draining: switch amber → info blue */
.offline-banner--online {
  background: var(--info, #2563eb);
  color: #fff;
}
.offline-banner i[data-lucide] {
  width: 18px;
  height: 18px;
}

/* ========== Status dot ========== */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: var(--neutral-400);
  flex-shrink: 0;
}

.status-dot--online {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}
.status-dot--offline {
  background: var(--danger);
}
.status-dot--idle {
  background: var(--warning);
}

/* Divider */
.divider {
  height: 1px;
  background: var(--neutral-200);
  margin: var(--space-4) 0;
}

/* Utilities for stat grids */
.stats-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 640px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .stats-row {
    grid-template-columns: repeat(3, 1fr);
  }
  .stats-row--4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ========== POS: Pack/Piece chooser modal ========== */
.pack-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
}
.pack-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.pack-modal__panel {
  position: relative;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  min-width: 320px;
  width: min(92vw, 640px);
  max-width: 640px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}
.pack-modal__title {
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 700;
}
.pack-modal__stock {
  color: var(--neutral-600);
  font-size: 14px;
  margin-bottom: 16px;
}
.pack-modal__buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.pack-btn {
  flex: 1;
  min-height: 120px;
  min-width: 140px;
  border-radius: 12px;
  border: 2px solid var(--neutral-200);
  background: var(--neutral-50);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 16px;
  transition: all var(--transition);
}
.pack-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #fff;
}
.pack-btn--focused {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.pack-btn--disabled,
.pack-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pack-btn__num {
  font-size: 12px;
  color: var(--neutral-500);
  font-weight: 600;
}
.pack-btn__label {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}
.pack-btn__price {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
}
.pack-btn__warning {
  font-size: 12px;
  color: var(--danger, #c0392b);
  margin-top: 4px;
}
.pack-modal__cancel {
  display: block;
  margin: 0 auto;
  background: transparent;
  border: none;
  color: var(--neutral-600);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 16px;
}
.pack-modal__cancel:hover {
  color: var(--neutral-900);
}
@media (max-width: 480px) {
  .pack-modal__buttons {
    grid-template-columns: 1fr;
  }
  .pack-btn {
    min-height: 80px;
    min-width: auto;
  }
}

/* ========== POS: Cart item pack hint ========== */
.cart-item__pack-hint {
  font-size: var(--font-tiny, 11px);
  color: var(--neutral-500);
  margin-top: 2px;
}

/* ========== POS: Phone topbar fit ========== */
@media (max-width: 1023px) {
  .topbar {
    gap: var(--space-2);
    padding: 0 var(--space-2);
    min-width: 0;
    overflow: hidden;
  }
  .topbar .brand {
    flex: 0 0 auto;
    gap: 6px;
    font-size: 14px;
    min-width: 0;
  }
  .topbar .brand__logo {
    width: 26px;
    height: 26px;
  }
  .topbar-user {
    flex: 1;
    min-width: 0;
    justify-content: flex-end;
    gap: 4px;
  }
  .topbar-user .btn {
    flex: 0 0 auto;
    padding: 0 8px;
  }
  .topbar-user .btn span {
    display: none;
  }
  .topbar-user .pos-language-switcher {
    flex: 0 1 auto;
    max-width: 136px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .topbar-user .pos-language-switcher::-webkit-scrollbar {
    display: none;
  }
  .topbar-user .pos-language-switcher__btn {
    flex: 0 0 auto;
    padding: 5px 6px;
    font-size: 11px;
  }
  .topbar-user .user-chip {
    min-width: 0;
    max-width: 92px;
    padding: 5px 8px;
    font-size: 12px;
  }
  .topbar-user .user-chip span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ========== Admin products: cashier-style card/list view ========== */
.admin-product-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-full);
  background: var(--bg-card);
}
.admin-product-view-toggle .btn {
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-full);
}
.admin-product-view-toggle .admin-product-view-toggle__btn--active,
.admin-product-view-toggle .admin-product-view-toggle__btn--active:hover:not(:disabled) {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}
.admin-products.admin-products--list {
  grid-template-columns: 1fr;
}
.admin-products.admin-products--list .admin-product-card {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 210px;
  min-height: 126px;
}
.admin-products.admin-products--list .admin-product-card__image {
  width: 112px;
  height: 100%;
  min-height: 126px;
}
.admin-products.admin-products--list .admin-product-card__body {
  min-width: 0;
  justify-content: center;
  padding: var(--space-3);
}
.admin-products.admin-products--list .admin-product-card__body h4 {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.admin-products.admin-products--list .admin-product-card__actions {
  align-content: center;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 0;
  border-left: 1px solid var(--neutral-200);
}
@media (max-width: 840px) {
  .admin-product-view-toggle {
    width: 100%;
  }
  .admin-product-view-toggle .btn {
    flex: 1;
  }
  .admin-products.admin-products--list .admin-product-card {
    grid-template-columns: 96px minmax(0, 1fr);
  }
  .admin-products.admin-products--list .admin-product-card__image {
    width: 96px;
    min-height: 112px;
  }
  .admin-products.admin-products--list .admin-product-card__actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border-top: 1px solid var(--neutral-200);
    border-left: 0;
  }
}
@media (max-width: 420px) {
  .admin-products.admin-products--list .admin-product-card {
    grid-template-columns: 84px minmax(0, 1fr);
  }
  .admin-products.admin-products--list .admin-product-card__image {
    width: 84px;
  }
  .admin-products.admin-products--list .admin-product-card__actions .btn {
    padding-inline: 0;
  }
}

/* ========== Admin action analytics ========== */
.analytics-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.analytics-head h2 {
  margin: 2px 0 0;
  font-size: 26px;
  line-height: 1.25;
}
.action-list {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-4);
}
.action-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-4);
  border: 1px solid var(--neutral-200);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
}
.action-card--high {
  border-left-color: var(--danger);
}
.action-card--medium {
  border-left-color: var(--warning);
}
.action-card__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  color: var(--primary);
  background: var(--primary-soft);
}
.action-card__body {
  min-width: 0;
}
.action-card__meta,
.action-card__metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--neutral-600);
  font-size: var(--font-small);
}
.action-card__meta span,
.action-card__metrics span {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--neutral-100);
}
.action-card h3 {
  margin: 6px 0;
  font-size: 18px;
  line-height: 1.35;
}
.action-card p {
  margin: 0;
  color: var(--neutral-700);
  line-height: 1.55;
}
.action-card__recommend {
  margin-top: 8px;
  color: var(--primary-dark);
  font-weight: 700;
}
.action-card__evidence {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--neutral-600);
  font-size: var(--font-small);
}
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}
.analytics-list {
  display: grid;
  gap: 10px;
}
.analytics-list__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px 0;
  border-bottom: 1px solid var(--neutral-100);
}
.analytics-list__row:last-child {
  border-bottom: 0;
}
.analytics-list__row div {
  min-width: 0;
}
.analytics-list__row strong {
  line-height: 1.35;
}
.analytics-list__row span {
  display: block;
  margin-top: 3px;
  color: var(--neutral-600);
  font-size: var(--font-small);
  line-height: 1.45;
}
@media (max-width: 760px) {
  .analytics-head {
    display: grid;
  }
  .analytics-head .chip-row {
    width: 100%;
  }
  .action-card {
    grid-template-columns: 44px minmax(0, 1fr);
  }
  .action-card > .btn {
    grid-column: 1 / -1;
    width: 100%;
  }
  .analytics-grid {
    grid-template-columns: 1fr;
  }
  .analytics-list__row {
    display: grid;
  }
}
