:root {
  --accent: #34c759;
  --accent-dark: #248a3d;
  --accent-soft: rgba(52, 199, 89, 0.12);
  --accent-mid: rgba(52, 199, 89, 0.22);
  --bg: #f2f2f7;
  --bg-elevated: #ffffff;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #3a3a3c;
  --text-muted: #8e8e93;
  --border: rgba(60, 60, 67, 0.12);
  --border-strong: rgba(60, 60, 67, 0.18);
  --danger: #ff3b30;
  --warning: #ff9f0a;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --header-h: 56px;
  --nav-w: 168px;
  --cart-w: 360px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ——— Login ——— */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(52, 199, 89, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 90%, rgba(52, 199, 89, 0.1), transparent 50%),
    var(--bg);
}
.login-card {
  background: var(--surface-solid);
  border-radius: var(--radius-xl);
  padding: 44px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 1px solid var(--border);
}
.login-logo { width: 120px; margin-bottom: 20px; }
.login-card h1 {
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.login-card > p {
  color: var(--text-muted);
  margin-bottom: 28px;
  font-size: 0.95rem;
}

.form-group { margin-bottom: 14px; text-align: left; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.form-input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), background 0.2s;
  min-height: 48px;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-solid);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: 980px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.15s, opacity 0.15s, box-shadow 0.15s;
  min-height: 44px;
  touch-action: manipulation;
  letter-spacing: -0.01em;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(52, 199, 89, 0.35);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-secondary {
  background: var(--fill);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background: var(--fill-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border-radius: var(--radius-sm); }
.btn-ghost:hover { background: var(--fill); color: var(--text); }
.btn-sm { padding: 8px 14px; font-size: 0.85rem; min-height: 36px; }
.btn-block { width: 100%; }
.error-msg { color: var(--danger); font-size: 0.875rem; margin-top: 12px; }

/* ——— App shell ——— */
.app { display: none; height: 100dvh; flex-direction: column; overflow: hidden; }
.app.active { display: flex; }

.header {
  height: var(--header-h);
  min-height: var(--header-h);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}
.header-logo { height: 34px; width: auto; }
.header-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.header-spacer { flex: 1; }

.app-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.app-content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Left sidebar navigation */
.nav-tabs {
  width: var(--nav-w, 168px);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  min-height: 44px;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
  text-align: left;
  letter-spacing: -0.01em;
}
.nav-tab svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.75;
}
.nav-tab.active {
  background: var(--text);
  color: #fff;
}
.nav-tab.active svg { opacity: 1; }
.nav-tab:hover:not(.active) { background: var(--fill); color: var(--text); }

/* ——— POS layout ——— */
#pos-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#pos-view.hidden { display: none !important; }

/* Categories on top */
.categories {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 10px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.categories::-webkit-scrollbar { display: none; }
.cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  border-radius: 980px;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  min-height: 40px;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.cat-btn .cat-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--fill);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}
.cat-btn .cat-icon svg { width: 13px; height: 13px; }
.cat-btn.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
  box-shadow: var(--shadow);
}
.cat-btn.active .cat-icon {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}
.cat-btn:hover:not(.active) {
  background: var(--fill);
  border-color: transparent;
}

.main-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.products-area {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px 24px;
  -webkit-overflow-scrolling: touch;
}
.products-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  position: sticky;
  top: 0;
  z-index: 5;
  padding-bottom: 2px;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
}
.product-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.product-search-wrap > svg {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
}
.product-search {
  width: 100%;
  min-height: 44px;
  padding: 10px 42px 10px 42px;
  border: 1px solid var(--border-strong);
  border-radius: 980px;
  background: var(--surface-solid);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.product-search::placeholder { color: var(--text-muted); font-weight: 400; }
.product-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.product-search-clear {
  position: absolute;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--fill);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.product-search-clear:hover { background: var(--fill-strong); color: var(--text); }
.type-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.type-filters::-webkit-scrollbar { display: none; }
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 980px;
  background: var(--surface-solid);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  min-height: 34px;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.type-chip-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-dark);
}
.type-chip-icon svg { width: 14px; height: 14px; }
.type-chip-count {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.type-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
  color: var(--accent-dark);
}
.type-chip.active .type-chip-count { color: var(--accent-dark); }
.type-chip:hover:not(.active) { background: var(--fill); border-color: transparent; }

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}
.product-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px 12px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s, border-color 0.15s, background 0.15s;
  text-align: center;
  min-height: 118px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.product-card:hover {
  border-color: var(--accent-mid);
  box-shadow: var(--shadow);
}
.product-card:active {
  transform: scale(0.96);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.product-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--accent-soft), rgba(52, 199, 89, 0.04));
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.product-icon svg { width: 22px; height: 22px; }
.product-card .name {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card .price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-dark);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.product-card .price-from::before {
  content: 'ab ';
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ——— Cart ——— */
.cart-panel {
  width: var(--cart-w);
  background: var(--surface-solid);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  min-height: 0;
}
.cart-header {
  padding: 16px 18px 12px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.cart-items {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 12px 12px;
  -webkit-overflow-scrolling: touch;
}
.cart-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  background: var(--bg);
  transition: background 0.15s;
}
.cart-item-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cart-item-icon svg { width: 18px; height: 18px; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}
.cart-item-price {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.cart-item-price .price-was {
  text-decoration: line-through;
  opacity: 0.65;
  margin-right: 4px;
}
.cart-item-discount-tag {
  margin-top: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--danger);
}
.cart-item-discount {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--surface-solid);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.cart-item-discount:hover,
.cart-item-discount.active {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
}
.cart-item.has-discount {
  background: rgba(255, 59, 48, 0.04);
}
.discount-row {
  color: var(--danger);
  font-weight: 600;
}
.discount-code-section { margin-bottom: 4px; }
.discount-or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 12px;
  color: var(--text-muted);
  font-size: 12px;
}
.discount-or-divider::before,
.discount-or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border, rgba(0,0,0,.1));
}
.discount-modal-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.qty-control { display: flex; align-items: center; gap: 2px; }
.qty-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface-solid);
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: transform 0.1s;
}
.qty-btn:active { transform: scale(0.92); }
.qty-value {
  width: 26px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}
.cart-item-remove {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cart-item-remove:hover { background: rgba(255, 59, 48, 0.1); color: var(--danger); }
.cart-item-remove svg { width: 14px; height: 14px; }

.cart-footer {
  border-top: 1px solid var(--border);
  padding: 14px 16px calc(16px + var(--safe-bottom));
  flex-shrink: 0;
  background: var(--surface-solid);
}
.cart-totals { margin-bottom: 14px; }
.total-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.total-row.grand {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
  letter-spacing: -0.03em;
}
.total-row.grand span:last-child { color: var(--accent-dark); }
.cart-actions { display: flex; flex-direction: column; gap: 8px; }
.cart-actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.empty-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 12px;
  border-radius: 16px;
  background: var(--fill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.empty-state-icon svg { width: 28px; height: 28px; }

/* ——— Modals ——— */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface-solid);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: min(90dvh, 720px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.modal-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.modal-footer {
  padding: 14px 22px calc(16px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* Checkout */
.checkout-summary {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
}
.checkout-section-label {
  margin: 18px 0 10px;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.payment-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}
.payment-btn {
  padding: 18px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-solid);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.payment-btn svg { width: 28px; height: 28px; color: var(--text-muted); }
.payment-btn:active { transform: scale(0.97); }
.payment-btn.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.payment-btn.selected svg { color: var(--accent-dark); }

.admin-panel {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px;
  -webkit-overflow-scrolling: touch;
}
.admin-panel.hidden { display: none !important; }
.admin-panel h2 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}
.customer-detail-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.customer-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.customer-hero { display: grid; gap: 14px; margin-bottom: 22px; }
.customer-hero-title {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
}
.customer-hero-meta { color: var(--text-muted); font-size: 0.95rem; }
.customer-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.customer-stat {
  background: var(--surface-2, rgba(0,0,0,.04));
  border-radius: 14px;
  padding: 14px 16px;
}
.customer-stat .label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.customer-stat .value { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.customer-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 4px 18px;
  margin-bottom: 22px;
  font-size: 0.95rem;
}
.customer-info-grid dt { color: var(--text-muted); font-size: 12px; margin-bottom: 2px; }
.customer-info-grid dd { margin: 0 0 10px; font-weight: 500; }
.customer-section { margin-bottom: 28px; }
.customer-section h3 { font-size: 1.05rem; font-weight: 700; margin: 0 0 10px; }
.customer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border, rgba(0,0,0,.08));
  flex-wrap: wrap;
}
.customer-row-main { min-width: 0; flex: 1; }
.customer-row-title { font-weight: 600; }
.customer-row-sub { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }
.customer-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(52,199,89,.15);
  color: #1b7a36;
}
.badge.used { background: rgba(0,0,0,.08); color: var(--text-muted); }
.badge.rest { background: rgba(0,122,255,.12); color: #0051a8; }
.reports-header { margin-bottom: 16px; }
.reports-hint { color: var(--text-muted); font-size: 0.9rem; margin-top: 6px; max-width: 720px; }
.reports-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.reports-type-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.reports-type-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.reports-date-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.reports-date-row .form-input { width: auto; min-width: 160px; }
.report-preview {
  background: var(--surface-solid, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 24px;
}
.report-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.report-stat {
  background: var(--surface-2, rgba(0,0,0,.04));
  border-radius: 12px;
  padding: 12px 14px;
}
.report-stat .label { font-size: 11px; color: var(--text-muted); }
.report-stat .value { font-size: 1.15rem; font-weight: 700; margin-top: 2px; }
.report-section { margin-top: 18px; }
.report-section h4 { font-size: 0.95rem; margin-bottom: 8px; }
.reports-finalize, .reports-history { margin-top: 28px; }
.reports-finalize h3, .reports-history h3 { font-size: 1.05rem; margin-bottom: 8px; }
.table-wrap {
  overflow-x: auto;
  background: var(--surface-solid);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0, 0, 0, 0.015); }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 980px;
  font-size: 0.72rem;
  font-weight: 700;
}
.badge-success { background: var(--accent-soft); color: var(--accent-dark); }
.badge-danger { background: rgba(255, 59, 48, 0.12); color: var(--danger); }

.customer-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  padding: 8px 12px;
  border-radius: 980px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
}
.customer-chip svg { width: 16px; height: 16px; }

.cart-toggle {
  display: none;
  position: fixed;
  bottom: calc(20px + var(--safe-bottom));
  right: 20px;
  width: 60px;
  height: 60px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  box-shadow: 0 8px 28px rgba(52, 199, 89, 0.45);
  cursor: pointer;
  z-index: 200;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.cart-toggle:active { transform: scale(0.94); }
.cart-toggle svg { width: 24px; height: 24px; }
.cart-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: #fff;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 980px;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.profile-avatar-wrap { position: relative; }
.profile-avatar {
  width: 100px; height: 100px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--accent); background: var(--bg);
}
.profile-avatar-placeholder {
  width: 100px; height: 100px; border-radius: 50%;
  background: var(--accent-soft); border: 3px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.4rem; color: var(--accent-dark); font-weight: 600;
}
.profile-avatar-actions { display: flex; flex-direction: column; gap: 8px; }
.profile-section {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.profile-section h3 {
  margin-bottom: 14px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.profile-role-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 980px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 4px;
}
.header-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}
.header-profile:hover { background: var(--fill); transform: scale(1.04); }
.header-avatar {
  width: 36px; height: 36px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--accent);
}
.header-avatar-placeholder {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; border: 2px solid var(--accent); color: var(--accent-dark);
}

.profile-overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  z-index: 800; display: none; opacity: 0; transition: opacity 0.25s;
}
.profile-overlay.active { display: block; opacity: 1; }
.profile-panel {
  position: fixed; top: 0; right: -420px; width: min(400px, 94vw);
  height: 100dvh; background: var(--surface-solid); z-index: 900;
  box-shadow: var(--shadow-lg);
  transition: right 0.3s var(--ease); display: flex; flex-direction: column;
}
.profile-panel.open { right: 0; }
.profile-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.profile-panel-header h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }
.profile-panel-body { flex: 1; overflow-y: auto; padding: 20px; -webkit-overflow-scrolling: touch; }

.print-success { text-align: center; padding: 20px 8px; }
.print-success .icon {
  width: 64px; height: 64px; margin: 0 auto 16px;
  border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark);
  display: flex; align-items: center; justify-content: center;
}
.print-success .icon svg { width: 32px; height: 32px; }
.print-success h3 { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 8px; }
.print-success p { color: var(--text-secondary); margin: 4px 0; }
.print-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hidden { display: none !important; }

.cart-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  z-index: 250;
}
.cart-backdrop.open { display: block; }

/* ——— Responsive ——— */
@media (max-width: 1100px) {
  :root { --cart-w: 320px; --nav-w: 148px; }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
}

@media (max-width: 900px) {
  .cart-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: min(var(--cart-w), 100vw);
    z-index: 300;
    transform: translateX(105%);
    transition: transform 0.3s var(--ease);
    box-shadow: var(--shadow-lg);
    border-left: none;
  }
  .cart-panel.open { transform: translateX(0); }
  .cart-toggle { display: flex; }
  :root { --nav-w: 72px; }
  .nav-tab {
    flex-direction: column;
    gap: 4px;
    padding: 10px 6px;
    justify-content: center;
    text-align: center;
    font-size: 0.65rem;
    min-height: 56px;
    border-radius: 12px;
  }
  .nav-tab span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-tab svg { width: 20px; height: 20px; opacity: 1; }
}

@media (max-width: 720px) {
  :root {
    --header-h: 52px;
    --nav-w: 64px;
  }
  .header { padding: 0 12px; }
  .header-title { font-size: 0.95rem; }
  .nav-tabs { padding: 8px 6px; gap: 2px; }
  .nav-tab { padding: 8px 4px; font-size: 0.6rem; min-height: 52px; }
  .nav-tab span { display: none; }

  .categories { padding: 8px 10px; gap: 6px; }
  .cat-btn { padding: 7px 12px; font-size: 0.78rem; min-height: 36px; }

  .products-area { padding: 10px 10px 88px; }
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
  .product-card { min-height: 110px; padding: 12px 8px; border-radius: 14px; }
  .product-icon { width: 36px; height: 36px; border-radius: 10px; }
  .product-icon svg { width: 18px; height: 18px; }
  .product-card .name { font-size: 0.78rem; }
  .product-card .price { font-size: 0.92rem; }

  .login-card { padding: 32px 22px; border-radius: 24px; }
  .grid-2 { grid-template-columns: 1fr; }
  .modal { max-height: 92dvh; border-radius: 24px 24px 0 0; margin-top: auto; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .payment-btns { grid-template-columns: 1fr 1fr; }
  .admin-panel { padding: 16px; }
}

@media (max-width: 420px) {
  .products-grid { grid-template-columns: repeat(2, 1fr); }
  .cart-actions-row { grid-template-columns: 1fr; }
}

@media (min-width: 1400px) {
  .products-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }
  :root { --cart-w: 400px; --nav-w: 180px; }
}

/* ——— App Dialog (Alert / Confirm / Prompt) ——— */
.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s var(--ease), visibility 0.22s;
}
.dialog-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.dialog-card {
  width: 100%;
  max-width: 360px;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 22px;
  padding: 28px 24px 20px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  transform: scale(0.92) translateY(8px);
  transition: transform 0.22s var(--ease);
}
.dialog-overlay.active .dialog-card {
  transform: scale(1) translateY(0);
}
.dialog-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dialog-icon svg { width: 28px; height: 28px; }
.dialog-icon.info { background: var(--fill); color: var(--text-secondary); }
.dialog-icon.success { background: var(--accent-soft); color: var(--accent-dark); }
.dialog-icon.warning { background: rgba(255, 159, 10, 0.15); color: #c77700; }
.dialog-icon.danger { background: rgba(255, 59, 48, 0.12); color: var(--danger); }
.dialog-icon.error { background: rgba(255, 59, 48, 0.12); color: var(--danger); }
.dialog-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
  color: var(--text);
}
.dialog-message {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 18px;
  white-space: pre-wrap;
}
.dialog-message:empty { display: none; margin: 0; }
.dialog-input-wrap {
  display: none;
  margin: 0 0 18px;
  text-align: left;
}
.dialog-input-wrap.visible { display: block; }
.dialog-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dialog-actions.row {
  flex-direction: row-reverse;
}
.dialog-actions .btn { min-height: 46px; border-radius: 14px; }
.dialog-actions.row .btn { flex: 1; }
.dialog-actions .btn-danger-soft {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
}
.dialog-actions .btn-danger-soft:hover { background: rgba(255, 59, 48, 0.18); }

@media (max-width: 720px) {
  .dialog-overlay {
    align-items: center;
    padding: 16px;
  }
  .dialog-card {
    max-width: 100%;
    border-radius: 20px;
    margin: 0;
  }
}

/* Product create / preview */
.products-toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.products-toolbar-row .type-filters { flex: 1; min-width: 0; }
.products-toolbar-row .btn { flex-shrink: 0; border-radius: 980px; }
.product-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}
.product-preview .product-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
}
.product-preview-name {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 2px;
}
.product-preview-type {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.table-product-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}
.table-product-icon svg { width: 16px; height: 16px; }

.voucher-customer-results {
  margin-top: 6px;
  max-height: 180px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
}
.voucher-customer-result {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  text-align: left;
}
.voucher-customer-result:hover { background: var(--accent-soft); }
.voucher-customer-result span { font-size: 0.78rem; color: var(--text-muted); }
.voucher-apply-row { display: flex; gap: 8px; }
.voucher-apply-row .form-input { flex: 1; }
.voucher-applied-info {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.printers-settings { max-width: 960px; }
.printers-hint { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 16px; line-height: 1.45; }
.printer-scan-bar { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 14px; flex-wrap: wrap; }
.printer-scan-results {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
}
.printer-found {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.printer-found:last-child { border-bottom: none; }
.printer-found-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.printers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.printer-card {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.printer-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}
.printer-card-head h3 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
