* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   TOP NAVBAR
   ========================================================================== */
.navbar {
  height: 60px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 50;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.nav-brand .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-primary);
  color: white;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  position: relative;
}

.nav-btn:active {
  transform: scale(0.96);
}

.nav-btn .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

/* Live Printer Status Indicator */
.printer-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
}

.printer-status.online {
  background-color: var(--success-bg);
  color: var(--success);
}

.printer-status.offline {
  background-color: var(--danger-bg);
  color: var(--danger);
}

.printer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: currentColor;
}

.printer-status.online .printer-dot {
  box-shadow: 0 0 8px var(--success);
}

/* ==========================================================================
   MAIN POS LAYOUT (DEFAULT / TABLET)
   ========================================================================== */
.pos-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  height: calc(100vh - 60px);
}

/* Left Panel: Clean Natural Scroll Catalog Selection */
.catalog-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-primary);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  height: 100%;
}

.section-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* TOP: Categories Grid */
.category-section {
  flex: none;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.category-card {
  height: 60px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  box-shadow: var(--card-shadow);
  transition: all 0.15s ease;
}

.category-card.active {
  background: var(--accent-primary);
  color: var(--accent-text);
  border-color: var(--accent-primary);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.category-card:active {
  transform: scale(0.96);
}

/* BOTTOM: Price Grid */
.price-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  background-color: var(--bg-primary);
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.price-btn {
  height: 64px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1.4rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--card-shadow);
  transition: all 0.15s ease;
}

.price-btn:active {
  transform: scale(0.95);
  border-color: var(--accent-primary);
  background: var(--bg-surface-subtle);
}

.price-btn.custom-btn {
  border-style: dashed;
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.05);
  font-size: 1.05rem;
  font-weight: 700;
  gap: 6px;
}

/* Right Panel: Cart & Payment (Tablet Mode) */
.cart-panel {
  width: 380px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.cart-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.clear-cart-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

/* Cart Items Scroll List */
.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-cart {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 8px;
  font-size: 0.95rem;
}

.cart-item {
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cart-item-row1 {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.cart-item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.cart-item-staff {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 2px;
}

.cart-item-row2 {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.qty-btn:active {
  background: var(--bg-surface-subtle);
}

.qty-val {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 20px;
  text-align: center;
}

.cart-item-price {
  font-weight: 700;
  font-size: 1rem;
}

/* Cart Footer & Checkout Action */
.cart-footer {
  border-top: 1px solid var(--border-color);
  padding: 16px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cart-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.cart-summary-row.total-row {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 4px;
}

.cart-action-group {
  display: flex;
  gap: 10px;
}

.hold-btn {
  flex: 1;
  padding: 14px;
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.checkout-btn {
  flex: 2;
  padding: 14px;
  background: var(--accent-primary);
  border: none;
  color: white;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.checkout-btn:active, .hold-btn:active {
  transform: scale(0.97);
}

/* ==========================================================================
   MOBILE DEVICE MODE OVERRIDES (.device-mobile)
   ========================================================================== */
body.device-mobile .pos-container {
  flex-direction: column;
}

body.device-mobile .cart-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-height: 85vh;
  border-top: 2px solid var(--border-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
  transform: translateY(calc(100% - 70px)); /* Shows floating bottom summary bar */
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
  background: var(--bg-surface);
}

body.device-mobile .cart-panel.expanded {
  transform: translateY(0) !important;
}

body.device-mobile .mobile-cart-handle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  height: 70px;
  background: var(--bg-surface);
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

body.device-tablet .mobile-cart-handle {
  display: none;
}

body.device-mobile .catalog-panel {
  border-right: none;
  padding-bottom: 120px; /* plenty of room to scroll past the bottom bar to see all prices */
  height: calc(100vh - 60px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.device-mobile .category-section {
  flex: none;
  padding: 12px;
  background: var(--bg-surface);
}

body.device-mobile .category-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

body.device-mobile .category-card {
  height: 48px;
  font-size: 0.95rem;
  padding: 4px;
}

body.device-mobile .price-section {
  flex: none;
  padding: 12px;
  background: transparent;
}

body.device-mobile .price-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

body.device-mobile .price-btn {
  height: 52px;
  font-size: 1.3rem;
}

/* ==========================================================================
   MODALS & DIALOGS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--modal-shadow);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Staff Selection Modal */
.staff-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.staff-card {
  padding: 16px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}

.staff-card:active {
  border-color: var(--accent-primary);
  background: rgba(37, 99, 235, 0.1);
}

.skip-staff-btn {
  padding: 14px;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  background: none;
  color: var(--text-secondary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

/* Payment Modal Options */
.payment-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-surface-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
}

.pay-tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.pay-tab-btn.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--card-shadow);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input {
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1.1rem;
  font-weight: 600;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent-primary);
}

.quick-cash-row {
  display: flex;
  gap: 8px;
}

.quick-cash-chip {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

/* Toast Notifications - Top Center */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
  max-width: 90vw;
}

.toast {
  pointer-events: auto;
  background: #0f172a;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideToastTop 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideToastTop {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
