/* ==========================================================================
   Art Jub POS - Restaurant Operating System
   Design System: Deep Crimson, Warm Amber, Dark Slate, Clean Modern Glassmorphism
   ========================================================================== */

:root {
  --primary: #c21820;
  --primary-hover: #a11219;
  --primary-light: #fef2f2;
  --primary-glow: rgba(194, 24, 32, 0.25);
  
  --secondary: #d97706;
  --secondary-light: #fffbeb;
  
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #0284c7;
  --info-bg: #f0f9ff;

  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;

  --border: #e2e8f0;
  --border-focus: #c21820;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  --font-thai: 'Prompt', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Kanit', var(--font-thai);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-thai);
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* App Shell Layout */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  width: 100dvw;
  overflow: hidden;
}

/* Left Sidebar Navigation */
.sidebar {
  width: 90px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 8px;
  flex-shrink: 0;
  z-index: 50;
  box-shadow: 4px 0 15px rgba(0,0,0,0.1);
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 24px;
  cursor: pointer;
}

.sidebar-logo {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  flex: 1;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  color: #94a3b8;
  cursor: pointer;
  background: transparent;
  border: none;
  width: 100%;
  transition: all 0.2s ease;
  position: relative;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #ffffff;
  transform: translateY(-2px);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--primary) 0%, #991b1b 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.nav-icon {
  font-size: 24px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
  text-align: center;
  letter-spacing: 0.2px;
}

.nav-badge {
  position: absolute;
  top: 6px;
  right: 14px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.6);
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.btn-icon-round {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-icon-round:hover {
  background: rgba(255,255,255,0.2);
  color: #ffffff;
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.view-section {
  display: none;
  flex: 1;
  height: 100%;
  overflow: hidden;
}

.view-section.active {
  display: flex;
}

/* ==========================================================================
   VIEW 1: POS Screen
   ========================================================================== */
.pos-container {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* POS Left: Menu Catalog */
.pos-catalog {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  overflow: hidden;
  background: #f8fafc;
}

.pos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 16px;
}

.pos-title-block h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.25rem, 1rem + 1.2vw, 1.625rem);
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.pos-title-block p {
  font-size: 13px;
  color: var(--text-muted);
}

.pos-search-box {
  position: relative;
  width: 280px;
}

.pos-search-input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  border-radius: var(--radius-xl);
  border: 1.5px solid var(--border);
  background: white;
  font-family: var(--font-thai);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.pos-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.pos-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 16px;
  pointer-events: none;
}

/* Table Bar at top of POS */
.pos-table-selector-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.pos-table-tag {
  background: linear-gradient(135deg, #b91c1c, #991b1b);
  color: white;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(185, 28, 28, 0.3);
}

.pos-table-quick-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
  padding-bottom: 2px;
}

.pos-table-pill {
  padding: 6px 14px;
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pos-table-pill:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.pos-table-pill.active {
  background: #0f172a;
  color: white;
  border-color: #0f172a;
}

.pos-table-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot.free { background: var(--success); }
.dot.busy { background: var(--danger); }
.dot.cook { background: var(--warning); }

/* Category Scroll */
.pos-categories {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 12px;
  margin-bottom: 12px;
  scrollbar-width: thin;
}

.pos-categories::-webkit-scrollbar {
  height: 4px;
}

.pos-categories::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.cat-btn {
  padding: 10px 18px;
  border-radius: var(--radius-xl);
  background: white;
  border: 1.5px solid var(--border);
  color: var(--text-main);
  font-family: var(--font-thai);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

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

.cat-btn.active {
  background: linear-gradient(135deg, var(--primary) 0%, #a11219 100%);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Menu Grid */
.pos-menu-grid {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  grid-auto-rows: auto;
  align-content: start;
  gap: 14px;
  padding-right: 6px;
  padding-bottom: 20px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.menu-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
  height: 255px;
  min-height: 255px;
}

.menu-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: #fca5a5;
}

.menu-card:active {
  transform: scale(0.98);
}

.menu-card-img-wrap {
  width: 100%;
  height: 135px;
  min-height: 135px;
  flex-shrink: 0;
  background: #f1f5f9;
  position: relative;
  overflow: hidden;
}

.menu-card-img {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.menu-card:hover .menu-card-img {
  transform: scale(1.06);
}

.badge-rec {
  position: absolute;
  top: 8px;
  left: 8px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 4px;
}

.menu-card-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  justify-content: space-between;
}

.menu-card-name {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
  margin-bottom: 2px;
}

.menu-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.25;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.menu-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.menu-card-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-heading);
}

.menu-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-edit-menu-mini {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-edit-menu-mini:hover {
  background: #eff6ff;
  color: #2563eb;
  border-color: #93c5fd;
  transform: scale(1.08);
}

.btn-add-mini {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid #fecaca;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.15s;
}

.menu-card:hover .btn-add-mini {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: rotate(90deg);
}

.menu-card.menu-card-add-new {
  border: 2px dashed #cbd5e1;
  background: #f8fafc;
  align-items: center;
  justify-content: center;
  color: #64748b;
  gap: 8px;
}

.menu-card.menu-card-add-new:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #fff5f5;
}

/* Compact Fast-Ordering List Mode */
.pos-menu-grid.compact-view {
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  grid-auto-rows: 64px;
  gap: 10px;
}

.pos-menu-grid.compact-view .menu-card {
  height: 64px;
  min-height: 64px;
  flex-direction: row;
  align-items: center;
  padding: 6px 10px;
  gap: 10px;
}

.pos-menu-grid.compact-view .menu-card-img-wrap {
  width: 48px;
  height: 48px;
  min-height: 48px;
  border-radius: 8px;
}

.pos-menu-grid.compact-view .badge-rec {
  display: none;
}

.pos-menu-grid.compact-view .menu-card-body {
  padding: 0;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.pos-menu-grid.compact-view .menu-card-desc {
  display: none;
}

.pos-menu-grid.compact-view .menu-card-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.pos-menu-grid.compact-view .menu-card-footer {
  margin: 0;
  gap: 6px;
}

.pos-menu-grid.compact-view .menu-card-price {
  font-size: 15px;
}

.pos-menu-grid.compact-view .btn-edit-menu-mini {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

.pos-menu-grid.compact-view .btn-add-mini {
  width: 26px;
  height: 26px;
  font-size: 14px;
}

/* POS Right: Cart Drawer / Billing */
.pos-cart-panel {
  width: 390px;
  background: white;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: -4px 0 20px rgba(0,0,0,0.04);
  z-index: 20;
}

.cart-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  flex-shrink: 0; /* Prevent header from being compressed */
}

.cart-header-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cart-header-title h2 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}

.cart-table-badge {
  background: #fee2e2;
  color: #991b1b;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-clear-cart {
  color: var(--text-muted);
  background: transparent;
  border: none;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-clear-cart:hover {
  background: #fee2e2;
  color: var(--danger);
}

/* Cart Items List */
.cart-items-list {
  flex: 1 1 0;
  min-height: 0; /* Critical for flex overflow to work correctly */
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafafa;
  scrollbar-width: thin;
  scrollbar-color: #e2e8f0 transparent;
}

.cart-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  gap: 12px;
}

.cart-empty-icon {
  font-size: 48px;
  opacity: 0.6;
}

.cart-item-row {
  background: white;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.15s;
}

.cart-item-row:hover {
  border-color: #cbd5e1;
}

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

.cart-item-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
  line-height: 1.3;
}

.cart-item-addons {
  font-size: 12px;
  color: #0369a1;
  background: #f0f9ff;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  display: inline-block;
}

.cart-item-note {
  font-size: 12px;
  color: #b45309;
  background: #fffbeb;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 3px;
  display: inline-block;
}

.cart-item-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2px;
}

.qty-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f1f5f9;
  padding: 3px 6px;
  border-radius: var(--radius-xl);
}

.btn-qty {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: none;
  background: white;
  color: var(--text-main);
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: all 0.15s;
}

.btn-qty:hover {
  background: var(--primary);
  color: white;
}

.qty-number {
  font-weight: 700;
  font-size: 14px;
  min-width: 20px;
  text-align: center;
}

.cart-item-total {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

/* Cart Summary & Actions */
.cart-summary {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: white;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0; /* CRITICAL: prevents cart summary from being pushed off-screen */
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text-muted);
}

.summary-row.total-row {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 4px;
}

.summary-row.total-row .total-amount {
  color: var(--primary);
  font-size: 24px;
  font-family: var(--font-heading);
}

.cart-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.btn-kds-send {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  color: #334155;
  font-family: var(--font-thai);
  font-size: 14px;
  font-weight: 600;
  padding: 12px 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-kds-send:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

.btn-checkout {
  grid-column: span 2;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  font-family: var(--font-thai);
  font-size: 17px;
  font-weight: 700;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
  transition: all 0.2s;
}

.btn-checkout:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.5);
}

.btn-checkout:active {
  transform: scale(0.98);
}

/* ==========================================================================
   VIEW 2: Kitchen Display System (KDS)
   ========================================================================== */
.kds-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #090d16;
  color: #e2e8f0;
  padding: 20px 24px;
  overflow: hidden;
}

.kds-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #1e293b;
}

.kds-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kds-title h1 {
  font-family: var(--font-heading);
  font-size: 24px;
  color: #f8fafc;
}

.kds-stats-pills {
  display: flex;
  gap: 10px;
}

.kds-stat-pill {
  background: #1e293b;
  padding: 6px 14px;
  border-radius: var(--radius-xl);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kds-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
  align-content: start;
}

.kds-ticket {
  background: #151d2f;
  border: 1.5px solid #293548;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  transition: all 0.2s;
}

.kds-ticket.pending { border-top: 5px solid var(--danger); }
.kds-ticket.cooking { border-top: 5px solid var(--warning); }
.kds-ticket.ready   { border-top: 5px solid var(--success); }

.kds-ticket-header {
  padding: 12px 16px;
  background: #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #293548;
}

.kds-ticket-table {
  font-weight: 700;
  font-size: 16px;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kds-ticket-timer {
  font-family: monospace;
  font-size: 14px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
}

.kds-ticket-timer.urgent {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  animation: blink-timer 1.5s infinite;
}

@keyframes blink-timer {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.kds-ticket-items {
  padding: 14px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 280px;
}

.kds-item-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s;
}

.kds-item-row:hover {
  background: rgba(255,255,255,0.05);
}

.kds-item-row.done .kds-item-name {
  text-decoration: line-through;
  opacity: 0.45;
}

.kds-item-qty {
  background: #0284c7;
  color: white;
  font-weight: 700;
  font-size: 13px;
  min-width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kds-item-content {
  flex: 1;
}

.kds-item-name {
  font-size: 15px;
  font-weight: 600;
  color: #f1f5f9;
}

.kds-item-sub {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.kds-ticket-footer {
  padding: 12px 16px;
  background: #111827;
  border-top: 1px solid #1f2937;
  display: flex;
  gap: 8px;
}

.btn-kds-status {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-thai);
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-kds-cook { background: #d97706; color: white; }
.btn-kds-cook:hover { background: #b45309; }

.btn-kds-ready { background: #059669; color: white; }
.btn-kds-ready:hover { background: #047857; }

.btn-kds-serve { background: #2563eb; color: white; }
.btn-kds-serve:hover { background: #1d4ed8; }

/* ==========================================================================
   VIEW 3: Tables Floor Plan
   ========================================================================== */
.tables-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 24px;
  background: var(--bg-main);
  overflow-y: auto;
}

.tables-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.tables-legend {
  display: flex;
  gap: 16px;
  background: white;
  padding: 10px 18px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.table-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 20px;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.table-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.table-card.available {
  border-color: #a7f3d0;
  background: #f0fdf4;
}

.table-card.occupied {
  border-color: #fca5a5;
  background: #fff5f5;
}

.table-card.kitchen_waiting {
  border-color: #fde68a;
  background: #fffdf2;
}

.table-card.ready {
  border-color: #93c5fd;
  background: #eff6ff;
}

.table-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-name {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.table-zone-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: rgba(0,0,0,0.06);
  color: var(--text-muted);
}

.table-status-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-xl);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.table-card.available .table-status-pill {
  background: #dcfce7;
  color: #15803d;
}

.table-card.occupied .table-status-pill {
  background: #fee2e2;
  color: #b91c1c;
}

.table-card.kitchen_waiting .table-status-pill {
  background: #fef3c7;
  color: #b45309;
}

.table-card.ready .table-status-pill {
  background: #dbeafe;
  color: #1d4ed8;
}

.table-card-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  border-top: 1px dashed rgba(0,0,0,0.1);
  padding-top: 10px;
}

.table-bill-total {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

/* ==========================================================================
   VIEW 4: Inventory & Stock Management
   ========================================================================== */
.inventory-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 24px;
  background: var(--bg-main);
  overflow-y: auto;
}

.inventory-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.inventory-table-wrap {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: auto;
  max-inline-size: 100%;
  container-type: inline-size;
  -webkit-overflow-scrolling: touch;
  flex-shrink: 0;
}

.custom-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 14px;
}

.custom-table thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
}

.custom-table th {
  background: #f8fafc;
  padding: 14px 18px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1.5px solid var(--border);
}

.custom-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
}

.custom-table tr:hover td {
  background: #f8fafc;
}

.stock-meter-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stock-progress-bar {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  max-width: 140px;
}

.stock-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.stock-progress-fill.normal { background: var(--success); }
.stock-progress-fill.warning { background: var(--warning); }
.stock-progress-fill.danger { background: var(--danger); }

/* ==========================================================================
   VIEW 5: Sales Reports & Analytics
   ========================================================================== */
.reports-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 24px;
  background: var(--bg-main);
  overflow-y: auto;
  gap: 20px;
}

.reports-container > * {
  flex-shrink: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.metric-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
}

.metric-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.metric-card.sales .metric-icon-box { background: #fee2e2; color: #b91c1c; }
.metric-card.orders .metric-icon-box { background: #fef3c7; color: #d97706; }
.metric-card.avg .metric-icon-box { background: #e0f2fe; color: #0284c7; }
.metric-card.cash .metric-icon-box { background: #dcfce7; color: #15803d; }

.metric-val {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-main);
}

.metric-label {
  font-size: 13px;
  color: var(--text-muted);
}

.chart-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   VIEW 6: Settings
   ========================================================================== */
.settings-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 24px;
  background: var(--bg-main);
  overflow-y: auto;
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
}

.settings-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-card h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}

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

.form-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.form-control {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-family: var(--font-thai);
  font-size: 14px;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ==========================================================================
   MODALS & DIALOGS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

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

.modal-dialog {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.modal-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-light);
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
}

/* Modifiers Addon Selector in Modal */
.addons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.addon-chip {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.15s;
}

.addon-chip:hover {
  border-color: var(--primary);
  background: #fff5f5;
}

.addon-chip.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.addon-chip-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.addon-chip-price {
  font-size: 12px;
  color: var(--primary);
  font-weight: 700;
}

/* Quick Notes Chips */
.quick-notes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.quick-note-chip {
  font-size: 12px;
  padding: 6px 12px;
  background: #f1f5f9;
  border-radius: var(--radius-xl);
  border: 1px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-note-chip:hover {
  background: #e2e8f0;
}

.quick-note-chip.active {
  background: #0f172a;
  color: white;
  border-color: #0f172a;
}

/* Payment Modal Custom Styles */
.pay-methods-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.pay-tab {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: white;
  font-family: var(--font-thai);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.pay-tab.active {
  border-color: var(--primary);
  background: #fff5f5;
  color: var(--primary);
}

.quick-cash-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.btn-cash-preset {
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #f8fafc;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}

.btn-cash-preset:hover {
  background: #e2e8f0;
}

.qr-box-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: #f8fafc;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  gap: 12px;
}

.qr-canvas-holder {
  background: white;
  padding: 12px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}

/* ==========================================================================
   THERMAL RECEIPT PREVIEW & PRINT STYLES
   ========================================================================== */
.receipt-paper {
  width: 320px;
  background: white;
  padding: 20px 16px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  color: #000;
  border: 1px solid #ccc;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
  line-height: 1.4;
}

.receipt-header {
  text-align: center;
  margin-bottom: 12px;
}

.receipt-title {
  font-size: 16px;
  font-weight: bold;
}

.receipt-divider {
  border-bottom: 1px dashed #000;
  margin: 8px 0;
}

.receipt-line {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.receipt-total {
  font-size: 14px;
  font-weight: bold;
  border-top: 1px dashed #000;
  border-bottom: 1px dashed #000;
  padding: 6px 0;
  margin: 6px 0;
}

.receipt-footer {
  text-align: center;
  font-size: 11px;
  margin-top: 12px;
}

/* Print Specific Rules */
@media print {
  body * {
    visibility: hidden;
  }
  #print-area, #print-area * {
    visibility: visible;
  }
  #print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm;
    margin: 0;
    padding: 0;
  }
  .receipt-paper {
    width: 100% !important;
    border: none !important;
    box-shadow: none !important;
    padding: 4mm !important;
  }
}

/* ==========================================================================
   VIEW 7: FOOD COST & RECIPE ENGINEERING STYLES
   ========================================================================== */
.foodcost-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 24px;
  background: var(--bg-main);
  overflow-y: auto;
  gap: 20px;
}

.foodcost-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
}

.fc-badge-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #4f46e5;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 6px;
}

.fc-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 4px 0;
}

.fc-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

.fc-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* KPI Summary Cards */
.fc-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.fc-kpi-card {
  background: white;
  border-radius: var(--radius-md);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fc-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.fc-kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.fc-kpi-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-grow: 1;
}

.fc-kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.fc-kpi-val {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
}

.fc-kpi-hint {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Sub-Navigation Tabs */
.fc-tabs-bar {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 2px;
  overflow-x: auto;
}

.fc-tab-btn {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.fc-tab-btn:hover {
  color: var(--primary);
}

.fc-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}

/* Sections & Cards */
.fc-section-card {
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.fc-table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.fc-table-title-group h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 2px 0;
}

.fc-table-title-group p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

/* Table Design */
.fc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.fc-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  padding: 10px 12px;
  border-bottom: 1.5px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.fc-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.fc-table tbody tr:hover {
  background: #f8fafc;
}

.fc-table.small th, .fc-table.small td {
  padding: 8px 10px;
  font-size: 12px;
}

.fc-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.fc-badge.good { background: #dcfce7; color: #15803d; }
.fc-badge.fair { background: #fef3c7; color: #b45309; }
.fc-badge.danger { background: #fee2e2; color: #b91c1c; }

.yield-tag {
  display: inline-block;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.soup-batch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.soup-batch-summary-box {
  display: flex;
  gap: 12px;
}

.soup-stat {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  text-align: right;
}

.soup-stat.highlight {
  background: #fff7ed;
  border-color: #ffedd5;
}

.soup-stat .lbl {
  font-size: 11px;
  color: var(--text-muted);
}

.soup-stat .val {
  font-size: 18px;
  font-weight: 800;
  color: #ea580c;
  font-family: var(--font-heading);
}

.pkg-total-badge {
  background: #fdf2f8;
  color: #db2777;
  border: 1px solid #fbcfe8;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
}

.fc-callout-info {
  background: #f0fdf4;
  border-left: 4px solid #22c55e;
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: #166534;
  line-height: 1.5;
}

/* Simulator Grid */
.fc-simulator-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  .fc-simulator-grid {
    grid-template-columns: 1fr;
  }
}

.fc-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: #e2e8f0;
  outline: none;
  margin: 8px 0;
  cursor: pointer;
}

.sim-results-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sim-result-box {
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1.5px solid;
  transition: all 0.2s ease;
}

.sim-result-box.primary {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.sim-result-box.warning {
  background: #fffbeb;
  border-color: #fde68a;
}

.sim-result-box.delivery {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.sim-box-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.sim-result-box.primary .sim-box-title { color: #1e293b; }
.sim-result-box.warning .sim-box-title { color: #92400e; }
.sim-result-box.delivery .sim-box-title { color: #166534; }

.sim-box-price {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 8px;
}

.sim-result-box.primary .sim-box-price { color: #2563eb; }
.sim-result-box.warning .sim-box-price { color: #d97706; }
.sim-result-box.delivery .sim-box-price { color: #15803d; }

.sim-box-detail {
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-main);
}

/* Recipe Inspector Modal */
.recipe-modal-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.stat-pill {
  background: white;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-pill .label {
  color: var(--text-muted);
}

.stat-pill .val {
  font-weight: 700;
}

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE DESIGN (Easy One-Handed Mobile POS)
   ========================================================================== */

/* Desktop defaults for mobile-only elements */
.mobile-cart-bar,
.mobile-cart-backdrop,
.btn-close-mobile-cart {
  display: none;
}

@media (max-width: 900px) {
  /* 1. App Shell: Stack main content above fixed Bottom Navigation Bar */
  #app {
    flex-direction: column;
    height: 100dvh;
    width: 100dvw;
  }

  .main-wrapper {
    flex: 1 1 0%;
    min-height: 0;
    width: 100%;
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
  }

  /* 2. Transform Sidebar into Fixed Bottom Navigation Bar */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.2);
    z-index: 90;
  }

  .sidebar-brand {
    display: none;
  }

  .sidebar-nav {
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    gap: 2px;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    padding: 6px 4px;
    min-width: 48px;
    flex: 1;
    border-radius: 10px;
  }

  .nav-item:hover {
    transform: none;
  }

  .nav-icon {
    font-size: 20px;
    margin-bottom: 2px;
  }

  .nav-label {
    font-size: 10px;
    white-space: nowrap;
  }

  .nav-badge {
    top: 2px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    font-size: 9px;
  }

  .sidebar-footer {
    margin-top: 0;
    margin-left: 4px;
    flex-shrink: 0;
  }

  .btn-icon-round {
    width: 34px;
    height: 34px;
    font-size: 15px;
  }

  /* 3. POS View on Mobile */
  .pos-container {
    flex-direction: column;
    position: relative;
  }

  .pos-catalog {
    padding: 12px 12px 84px 12px;
    width: 100%;
    height: 100%;
  }

  .pos-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 10px;
  }

  .pos-title-block p {
    font-size: 11px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .pos-header > div:last-child {
    width: 100%;
    display: flex;
    gap: 6px !important;
  }

  .pos-search-box {
    flex: 1 1 100%;
    width: 100%;
    order: -1;
  }

  .pos-search-input {
    padding: 8px 14px 8px 36px;
    font-size: 14px;
  }

  #btn-pos-add-menu,
  #btn-toggle-view-mode {
    flex: 1;
    justify-content: center;
    padding: 8px 10px !important;
    font-size: 12px !important;
  }

  /* Table selector bar compact on mobile */
  .pos-table-selector-bar {
    padding: 8px 10px;
    margin-bottom: 10px;
    gap: 8px;
  }

  .pos-table-tag {
    padding: 5px 10px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .pos-table-tag span:first-child {
    display: none;
  }

  .pos-table-pill {
    padding: 5px 12px;
    font-size: 12px;
  }

  /* Category bar compact on mobile */
  .pos-categories {
    gap: 6px;
    padding-bottom: 8px;
    margin-bottom: 8px;
  }

  .cat-btn {
    padding: 7px 13px;
    font-size: 13px;
  }

  /* 2-Column Menu Grid on Mobile */
  .pos-menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-right: 2px;
    padding-bottom: 24px;
  }

  .menu-card {
    height: 220px;
    min-height: 220px;
  }

  .menu-card-img-wrap {
    height: 110px;
    min-height: 110px;
  }

  .menu-card-body {
    padding: 8px 10px;
  }

  .menu-card-name {
    font-size: 13.5px;
    line-height: 1.25;
  }

  .menu-card-desc {
    font-size: 10.5px;
    -webkit-line-clamp: 1;
    margin-bottom: 4px;
  }

  .menu-card-price {
    font-size: 16px;
  }

  .btn-edit-menu-mini {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  .btn-add-mini {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .pos-menu-grid.compact-view {
    grid-template-columns: 1fr;
  }

  /* 4. Mobile Floating Cart Bar (Pinned above Bottom Nav) */
  .mobile-cart-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    background: #1e293b;
    color: white;
    padding: 10px 14px;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.35);
    z-index: 65;
    cursor: pointer;
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    transition: all 0.2s ease;
  }

  .mobile-cart-bar.has-items {
    background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%);
    border-color: #fca5a5;
    box-shadow: 0 8px 24px rgba(185, 28, 28, 0.45);
  }

  .mobile-cart-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
  }

  .mobile-cart-badge-wrap {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
  }

  .mobile-cart-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #f59e0b;
    color: #0f172a;
    font-size: 11px;
    font-weight: 800;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid #0f172a;
  }

  .mobile-cart-info {
    min-width: 0;
    flex: 1;
  }

  .mobile-cart-table {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-cart-sub {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-cart-bar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
  }

  .mobile-cart-total {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 800;
    color: #fde68a;
  }

  .mobile-cart-btn {
    background: #10b981;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 8px 12px;
    font-family: var(--font-thai);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  }

  /* 5. Slide-Up Cart Drawer on Mobile */
  .mobile-cart-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(3px);
    z-index: 80;
  }

  .mobile-cart-backdrop.active {
    display: block;
  }

  .pos-cart-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    width: 100%;
    height: 82dvh;
    max-height: 82dvh;
    border-left: none;
    border-radius: 22px 22px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.25);
    z-index: 85;
    transform: translateY(110%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .pos-cart-panel.mobile-open {
    transform: translateY(0);
  }

  .btn-close-mobile-cart {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px 12px;
    font-family: var(--font-thai);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
  }

  /* 6. Other Views on Mobile (Tables, KDS, Inventory, Food Cost, Reports, Settings) */
  .tables-container,
  .inventory-container,
  .foodcost-container,
  .reports-container,
  .settings-container,
  .kds-container {
    padding: 14px 12px 28px 12px;
  }

  .tables-header,
  .kds-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }

  .kds-stats-pills {
    width: 100%;
    overflow-x: auto;
  }

  .kds-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .tables-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .table-card {
    padding: 12px;
    gap: 10px;
  }

  .table-name {
    font-size: 16px;
  }

  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .metric-card {
    padding: 12px;
    gap: 10px;
  }

  .metric-icon-box {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }

  .metric-val {
    font-size: 18px;
  }

  .reports-bottom-grid,
  .settings-grid-row {
    grid-template-columns: 1fr !important;
  }

  .inventory-header input.form-control,
  .inventory-header select.form-control {
    flex: 1 1 140px;
    width: auto !important;
  }

  /* 7. Modals on Mobile */
  .modal-overlay {
    padding: 8px;
    align-items: flex-end;
  }

  .modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90dvh !important;
    border-radius: 20px 20px 12px 12px;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-body {
    padding: 14px 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
}

@media (max-width: 420px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .mobile-cart-btn {
    padding: 7px 10px;
    font-size: 11px;
  }
}


