/**
 * TechLine POS - Modern Design System & UI Stylesheet
 * Optimized for Restaurant & Café Touch POS and Admin Panels
 */

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* Primary & Brand Accents */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-rgb: 79, 70, 229;

  --accent-emerald: #10b981;
  --accent-emerald-light: #ecfdf5;
  --accent-amber: #f59e0b;
  --accent-amber-light: #fffbeb;
  --accent-rose: #f43f5e;
  --accent-rose-light: #fff1f2;
  --accent-cyan: #06b6d4;
  --accent-cyan-light: #ecfeff;

  /* Neutrals & Dark Slate */
  --bg-body: #f8fafc;
  --bg-surface: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #312e81;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 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.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 70px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
}

/* ============================================================
   LAYOUT WRAPPER
   ============================================================ */
.pos-app {
  display: flex;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  position: relative;
}

/* Sidebar Backdrop for Mobile/Tablet Drawer */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(2px);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.sidebar-backdrop.active {
  opacity: 1;
  visibility: visible;
}

/* Sidebar */
.pos-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 45;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.pos-sidebar::-webkit-scrollbar {
  width: 4px;
}
.pos-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.pos-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.sidebar-mobile-close {
  display: none;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
}

/* Collapsed Sidebar Mode (can be toggled by user or automatic) */
body.sidebar-collapsed .pos-sidebar {
  width: 70px;
}
body.sidebar-collapsed .brand-details,
body.sidebar-collapsed .nav-item span,
body.sidebar-collapsed .nav-badge,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .user-meta {
  display: none !important;
}
body.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding: 0;
}
body.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 0.85rem;
}
body.sidebar-collapsed .sidebar-footer {
  padding: 0.75rem 0.5rem;
}
body.sidebar-collapsed .sidebar-footer .user-profile-card {
  justify-content: center;
  padding: 0;
  border: none;
  background: transparent;
}
body.sidebar-collapsed .sidebar-footer .user-profile-card a[href="logout.php"] {
  display: none;
}
body.sidebar-collapsed .pos-main {
  margin-left: 70px;
  width: calc(100% - 70px);
  max-width: calc(100% - 70px);
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 0.75rem;
}

.brand-icon-box {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5, #ec4899);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.brand-details h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.2;
}

.brand-details span {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 700;
  padding: 0.75rem 0.875rem 0.375rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: #94a3b8;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.925rem;
  transition: var(--transition);
  position: relative;
}

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

.nav-item.active {
  background: linear-gradient(90deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke-width: 2.2;
}

.nav-badge {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: #334155;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid #6366f1;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-meta .name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-meta .role {
  font-size: 0.725rem;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 4px;
}

.user-meta .role::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
}

/* Main Content Area */
.pos-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  max-width: calc(100% - var(--sidebar-width));
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   CLASSIC & MODERN APPLICATION HEADER
   ============================================================ */
.pos-header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-xs);
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  min-width: 0;
}

.sidebar-toggle-btn {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  padding: 0;
}
.sidebar-toggle-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.page-title-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.page-title-box h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
}

.page-breadcrumb {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 1;
  min-width: 0;
  justify-content: flex-end;
}

/* Unified Live Online & Sync Status Badge */
.live-badge,
.header-pill.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  background: var(--accent-emerald-light);
  color: #065f46;
  font-size: 0.775rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  border: 1px solid rgba(16, 185, 129, 0.25);
  user-select: none;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.live-badge:hover,
.header-pill.sync-pill:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.live-dot,
.sync-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.2); }
}

/* Sync Engine Dynamic States */
.live-badge.status-synced,
.header-pill.sync-pill.status-synced {
  background: var(--accent-emerald-light);
  color: #065f46;
  border-color: rgba(16, 185, 129, 0.25);
}
.live-badge.status-synced .live-dot,
.live-badge.status-synced .sync-status-dot,
.header-pill.sync-pill.status-synced .live-dot,
.header-pill.sync-pill.status-synced .sync-status-dot {
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
  animation: pulse-dot 2s infinite;
}

.live-badge.status-syncing,
.header-pill.sync-pill.status-syncing {
  background: rgba(79, 70, 229, 0.08);
  color: #4f46e5;
  border-color: rgba(79, 70, 229, 0.25);
}
.live-badge.status-syncing .live-dot,
.live-badge.status-syncing .sync-status-dot,
.header-pill.sync-pill.status-syncing .live-dot,
.header-pill.sync-pill.status-syncing .sync-status-dot {
  background: #4f46e5;
  box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.3);
  animation: pulse-dot 1s infinite;
}

.live-badge.status-pending,
.header-pill.sync-pill.status-pending {
  background: rgba(245, 158, 11, 0.08);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.25);
}
.live-badge.status-pending .live-dot,
.live-badge.status-pending .sync-status-dot,
.header-pill.sync-pill.status-pending .live-dot,
.header-pill.sync-pill.status-pending .sync-status-dot {
  background: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
  animation: none;
}

.live-badge.status-offline,
.header-pill.sync-pill.status-offline {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.25);
}
.live-badge.status-offline .live-dot,
.live-badge.status-offline .sync-status-dot,
.header-pill.sync-pill.status-offline .live-dot,
.header-pill.sync-pill.status-offline .sync-status-dot {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
  animation: none;
}

/* Real-Time Date & Time Clock Pill */
.datetime-pill {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-body);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}

/* Header Action Buttons & Badges */
.header-currency-badge {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-full);
  font-size: 0.775rem;
  font-weight: 700;
  color: var(--primary);
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.header-currency-badge .currency-text-compact {
  display: none;
}

.btn-header-action {
  height: 32px;
  padding: 0 0.75rem;
  font-size: 0.75rem;
  border-radius: var(--radius-full);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
#btn-sales-history {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid var(--primary);
  color: var(--primary);
}

/* Logged-In User Profile Pill */
.user-header-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.25rem 0.5rem 0.25rem 0.35rem;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  white-space: nowrap;
}

.user-header-pill .user-avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  font-weight: 800;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-meta-header {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.user-header-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-main);
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-header-role {
  font-size: 0.675rem;
  color: var(--text-muted);
  font-weight: 600;
}

.btn-user-action {
  height: 26px;
  padding: 0 0.5rem;
  font-size: 0.72rem;
  border-radius: var(--radius-full);
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.btn-user-logout {
  height: 26px;
  padding: 0 0.55rem;
  font-size: 0.72rem;
  border-radius: var(--radius-full);
  text-decoration: none;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-user-logout:hover {
  background: #dc2626;
  color: #ffffff;
}

/* Compact Responsive Rules */
@media (max-width: 1440px) {
  .header-right .hide-compact {
    display: none !important;
  }
  .header-currency-badge .currency-text-full {
    display: none !important;
  }
  .header-currency-badge .currency-text-compact {
    display: inline !important;
  }
  .clock-date {
    display: none !important;
  }
  .user-header-name {
    max-width: 85px;
  }
}

@media (max-width: 1200px) {
  .datetime-pill,
  #pos-clock {
    display: none !important;
  }
  .user-meta-header {
    display: none !important;
  }
}

@media (max-width: 850px) {
  .pos-header {
    padding: 0 0.85rem;
  }
  .page-breadcrumb {
    display: none;
  }
}

/* Page Container */
.pos-content {
  padding: 1.5rem;
  flex: 1;
}

/* ============================================================
   STATS METRIC CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

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

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 4px;
}

.stat-card.blue::after { background: var(--primary); }
.stat-card.green::after { background: var(--accent-emerald); }
.stat-card.amber::after { background: var(--accent-amber); }
.stat-card.cyan::after { background: var(--accent-cyan); }

.stat-info p {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.stat-info h3 {
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card.blue .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.green .stat-icon { background: var(--accent-emerald-light); color: var(--accent-emerald); }
.stat-card.amber .stat-icon { background: var(--accent-amber-light); color: var(--accent-amber); }
.stat-card.cyan .stat-icon { background: var(--accent-cyan-light); color: var(--accent-cyan); }

.stat-icon svg {
  width: 24px;
  height: 24px;
}

/* ============================================================
   ACTION & FILTER TOOLBAR
   ============================================================ */
.action-toolbar {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: var(--shadow-xs);
}

.toolbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  flex: 1;
  min-width: 280px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 380px;
}

.search-box svg {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 42px;
  padding: 0 1rem 0 2.5rem;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-main);
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.filter-select {
  height: 42px;
  padding: 0 2rem 0 0.85rem;
  background: var(--bg-body) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 0.75rem center;
  background-size: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-main);
  cursor: pointer;
  appearance: none;
  transition: var(--transition);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.toolbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  flex-shrink: 0;
}

.view-switcher {
  display: flex;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
}

.view-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.view-btn:hover {
  color: var(--text-main);
}

.view-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.view-btn svg {
  width: 18px;
  height: 18px;
}

/* Primary Button */
.btn-primary {
  height: 42px;
  padding: 0 1.25rem;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  height: 42px;
  padding: 0 1.25rem;
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  background: var(--bg-body);
  border-color: #cbd5e1;
}

/* ============================================================
   CATEGORY CARD GRID (TOUCH-OPTIMIZED)
   ============================================================ */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.cat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.cat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: #cbd5e1;
}

.cat-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.cat-icon-wrapper {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.5rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  transition: var(--transition);
}

.cat-card:hover .cat-icon-wrapper {
  transform: scale(1.05);
}

.cat-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  font-size: 0.725rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.status-badge.active {
  background: var(--accent-emerald-light);
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.inactive {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.order-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-body);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.cat-body {
  flex: 1;
  margin-bottom: 1.25rem;
}

.cat-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

.cat-slug {
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--bg-body);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 0.5rem;
}

.cat-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.cat-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-light);
}

.cat-items-count {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.cat-items-count svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.cat-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.icon-action-btn:hover {
  background: var(--bg-body);
  color: var(--text-main);
  border-color: #cbd5e1;
}

.icon-action-btn.edit:hover {
  color: var(--primary);
  background: var(--primary-light);
  border-color: #c7d2fe;
}

.icon-action-btn.toggle:hover {
  color: var(--accent-amber);
  background: var(--accent-amber-light);
  border-color: #fde68a;
}

.icon-action-btn.delete:hover {
  color: var(--accent-rose);
  background: var(--accent-rose-light);
  border-color: #fecdd3;
}

.icon-action-btn svg {
  width: 15px;
  height: 15px;
}

/* ============================================================
   TABLE VIEW
   ============================================================ */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.pos-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.pos-table th {
  background: #f8fafc;
  padding: 0.85rem 1.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.pos-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.875rem;
  vertical-align: middle;
}

.pos-table tr:last-child td {
  border-bottom: none;
}

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

.table-cat-cell {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.table-cat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.15rem;
  flex-shrink: 0;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: var(--transition);
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: var(--transition);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .slider {
  background-color: var(--accent-emerald);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* ============================================================
   MODAL & SLIDE-OVER DRAWER
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

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

.modal-container {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  transform: scale(0.95) translateY(10px);
  transition: var(--transition);
  overflow: hidden;
}

.modal-container form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin: 0;
}

.modal-overlay.active .modal-container {
  transform: scale(1) translateY(0);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-body);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.modal-close-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.form-label span.req {
  color: var(--accent-rose);
}

.form-input, .form-textarea {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text-main);
  background: #ffffff;
  transition: var(--transition);
}

.form-input:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

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

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Live Preview Box */
.live-preview-box {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.preview-badge-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.live-pos-btn {
  width: 140px;
  height: 100px;
  border-radius: var(--radius-lg);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  text-align: center;
  box-shadow: 0 6px 14px rgba(0,0,0,0.15);
  transition: var(--transition);
  flex-shrink: 0;
}

.live-pos-btn .preview-icon {
  font-size: 2rem;
  line-height: 1;
}

.live-pos-btn .preview-name {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.preview-desc-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Icon Picker Grid */
.icon-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 0.5rem;
  max-height: 150px;
  overflow-y: auto;
  padding: 0.5rem;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.icon-chip {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--border-color);
  font-size: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
}

.icon-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: scale(1.05);
}

.icon-chip.selected {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
}

/* Color Swatches */
.color-swatches {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.color-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid #ffffff;
  box-shadow: 0 0 0 1px #cbd5e1;
  transition: var(--transition);
}

.color-dot:hover {
  transform: scale(1.15);
}

.color-dot.selected {
  box-shadow: 0 0 0 2.5px var(--primary);
  transform: scale(1.15);
}

.custom-color-input {
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: none;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background: var(--bg-surface);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-xl);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--text-muted);
  max-width: 360px;
  margin: 0 auto 1.5rem;
}

/* ============================================================
   TOAST NOTIFICATION ENGINE
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
}

.toast {
  min-width: 320px;
  max-width: 420px;
  background: #0f172a;
  color: #ffffff;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  pointer-events: auto;
  animation: toast-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--accent-emerald); }
.toast.error { border-left-color: var(--accent-rose); }
.toast.warning { border-left-color: var(--accent-amber); }

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.toast-msg {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px;
}

.toast-close:hover {
  color: #ffffff;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .pos-sidebar {
    width: 70px;
  }
  .brand-details, .nav-item span, .nav-badge, .nav-section-title, .user-meta {
    display: none !important;
  }
  .sidebar-header {
    justify-content: center;
    padding: 0;
  }
  .nav-item {
    justify-content: center;
    padding: 0.85rem;
  }
  .sidebar-footer {
    padding: 0.75rem 0.5rem;
  }
  .sidebar-footer .user-profile-card {
    justify-content: center;
    padding: 0;
    border: none;
    background: transparent;
  }
  .sidebar-footer .user-profile-card a[href="logout.php"] {
    display: none;
  }
  .pos-main {
    margin-left: 70px;
    width: calc(100% - 70px);
    max-width: calc(100% - 70px);
  }
}

@media (max-width: 768px) {
  .pos-sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 100;
    width: 260px;
  }
  .pos-sidebar.mobile-open {
    transform: translateX(0);
  }
  .pos-sidebar.mobile-open .sidebar-mobile-close {
    display: block;
    margin-left: auto;
  }
  .brand-details, .nav-item span, .nav-badge, .nav-section-title, .user-meta {
    display: flex !important;
  }
  .sidebar-header {
    justify-content: flex-start;
    padding: 0 1.5rem;
  }
  .nav-item {
    justify-content: flex-start;
    padding: 0.85rem 1.25rem;
  }
  .sidebar-footer {
    padding: 1rem 1.25rem;
  }
  .sidebar-footer .user-profile-card {
    justify-content: space-between;
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
  }
  .sidebar-footer .user-profile-card a[href="logout.php"] {
    display: flex;
  }
  .pos-main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .pos-header {
    height: auto;
    min-height: 52px;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }
  .header-left {
    min-width: 0;
    flex-shrink: 0;
  }
  .page-title-box h1 {
    font-size: 1.05rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
  }
  .page-breadcrumb {
    display: none;
  }
  .header-right {
    gap: 0.35rem;
    flex-shrink: 1;
    flex-wrap: nowrap;
  }
  .datetime-pill,
  #pos-clock {
    display: none !important;
  }
  .header-right a[href="settings.php"] span:last-child,
  .header-right div[title="Active Billing Currency"] span:last-child {
    display: none;
  }
  #btn-sales-history span:last-child {
    display: none;
  }
  #btn-fullscreen span {
    font-size: 0.72rem;
  }
  .user-header-pill {
    padding: 2px 4px !important;
    gap: 0.25rem !important;
  }
  .user-meta-header,
  .user-header-pill > div:nth-child(2) {
    display: none !important;
  }
  .user-header-pill a span:last-child {
    display: none !important;
  }
  .pos-content {
    padding: 1rem;
  }
  .action-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar-left, .toolbar-right {
    width: 100%;
  }
  .search-box {
    max-width: none;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .cart-actions-box {
    padding-bottom: max(env(safe-area-inset-bottom, 0px), 12px) !important;
  }
}

/* Phone Portrait Viewport (< 600px): Vertical Stacking with horizontal category scroll */
@media (max-width: 600px) {
  .pos-terminal-layout,
  .pos-main.is-cashier-view .pos-terminal-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 54px);
    height: calc(100dvh - 54px);
    min-height: 0;
    gap: 0.5rem;
    overflow-y: auto;
  }
  .pos-pane-categories {
    height: auto !important;
    min-height: auto !important;
    max-height: 48px !important;
    flex-shrink: 0;
    border-radius: var(--radius-md) !important;
  }
  .category-strip-header {
    display: none !important;
  }
  .category-nav-list {
    flex-direction: row !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 0.35rem !important;
    gap: 0.35rem !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch;
  }
  .pos-cat-pill {
    padding: 0.35rem 0.65rem !important;
    font-size: 0.75rem !important;
    flex-shrink: 0 !important;
  }
  .pos-pane-catalog {
    flex: 1;
    min-height: 280px;
    overflow: hidden;
  }
  .pos-item-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)) !important;
    gap: 0.5rem !important;
  }
  .touch-item-card {
    padding: 0.65rem !important;
    min-height: 110px !important;
  }
  .pos-pane-cart {
    height: auto !important;
    max-height: 48vh !important;
    border-radius: var(--radius-md) !important;
    flex-shrink: 0;
  }
}

/* Tablet Viewport (601px - 1024px): Optimized 3-pane touchscreen layout */
@media (min-width: 601px) and (max-width: 1024px) {
  .pos-terminal-layout,
  .pos-main.is-cashier-view .pos-terminal-layout {
    display: grid !important;
    grid-template-columns: 180px 1fr 340px !important;
    gap: 0.75rem !important;
    height: calc(100vh - 64px) !important;
    height: calc(100dvh - 64px) !important;
  }
  .pos-pane-categories {
    height: 100% !important;
    max-height: none !important;
  }
  .category-strip-header {
    display: flex !important;
    padding: 0.65rem 0.75rem !important;
  }
  .category-nav-list {
    flex-direction: column !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  .pos-item-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
  }
  .pos-pane-cart {
    height: 100% !important;
    max-height: none !important;
  }
}

/* ============================================================
   EMBEDDED MOBILE APP MODE (iframe in-app manager)
   ============================================================ */
html.is-embedded-app,
body.is-embedded-app {
  overflow-x: hidden !important;
  width: 100% !important;
  max-width: 100vw !important;
  background: var(--bg-body, #f8fafc) !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.is-embedded-app .pos-header,
body.is-embedded-app .pos-sidebar {
  display: none !important;
}

body.is-embedded-app .pos-app {
  width: 100% !important;
  max-width: 100% !important;
  min-height: auto !important;
  overflow-x: hidden !important;
  display: block !important;
}

body.is-embedded-app .pos-main,
.pos-main.is-embedded-view {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: auto !important;
  padding: 0 !important;
}

body.is-embedded-app .pos-content {
  padding: 0.75rem 1rem !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

body.is-embedded-app .page-container {
  width: 100% !important;
  max-width: 100% !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

body.is-embedded-app .action-toolbar {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0.5rem !important;
}

body.is-embedded-app .toolbar-left,
body.is-embedded-app .toolbar-right {
  width: 100% !important;
  flex-wrap: wrap !important;
}

body.is-embedded-app .search-box {
  max-width: none !important;
  width: 100% !important;
}

body.is-embedded-app .stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
  gap: 0.65rem !important;
  margin-bottom: 1rem !important;
}

body.is-embedded-app .stat-card {
  padding: 0.75rem 1rem !important;
}

body.is-embedded-app .table-responsive,
body.is-embedded-app div:has(> table),
body.is-embedded-app div[style*="overflow: hidden"]:has(table) {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  max-width: 100% !important;
}

body.is-embedded-app .modal-container {
  max-width: 95vw !important;
  max-height: 88vh !important;
  margin: 1rem auto !important;
}

/* ============================================================
   3-PANE TOUCHSCREEN POS TERMINAL STYLES
   ============================================================ */
body.page-pos .pos-content,
.pos-content:has(.pos-terminal-layout) {
  padding: 0.75rem 1rem !important;
}

.pos-terminal-layout {
  display: grid;
  grid-template-columns: 220px 1fr 380px;
  gap: 1rem;
  height: calc(100vh - var(--header-height) - 1.5rem);
  height: calc(100dvh - var(--header-height) - 1.5rem);
  min-height: 520px;
  width: 100%;
  max-width: 100%;
}

/* Collapsed Sidebar or Cashier full screen gets optimal terminal width */
body.sidebar-collapsed .pos-terminal-layout,
.pos-main.is-cashier-view .pos-terminal-layout {
  grid-template-columns: 240px 1fr 420px;
  gap: 1rem;
  height: calc(100vh - var(--header-height) - 1.5rem);
  height: calc(100dvh - var(--header-height) - 1.5rem);
}

/* Cashier Dedicated Full-Screen Touch Terminal Mode (No Sidebar) */
.pos-main.is-cashier-view {
  margin-left: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

.pos-main.is-cashier-view .pos-content {
  padding: 0.75rem 1rem !important;
}

/* 1. Left Categories Pane */
.pos-pane-categories {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.category-strip-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
  background: #f8fafc;
}

.category-nav-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pos-cat-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.pos-cat-pill:hover {
  background: var(--bg-body);
  border-color: var(--border-color);
}

.pos-cat-pill.active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.cat-pill-icon {
  font-size: 1.25rem;
  line-height: 1;
}

.cat-pill-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-pill-count {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.08);
}

.pos-cat-pill.active .cat-pill-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* 2. Center Catalog Grid */
.pos-pane-catalog {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.catalog-filter-bar {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  box-shadow: var(--shadow-xs);
}

.btn-dietary {
  height: 38px;
  padding: 0 0.85rem;
  border: 1px solid var(--border-color);
  background: var(--bg-body);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-dietary.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.pos-item-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  align-content: start;
  padding-right: 4px;
}

.touch-item-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-xs);
  user-select: none;
  position: relative;
  min-height: 140px;
}

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

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

.item-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.item-card-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.item-card-name {
  font-size: 0.925rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-card-price {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
}

/* 3. Right Cart / Billing Pane */
.pos-pane-cart {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.order-type-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: #f8fafc;
}

.order-type-tab {
  flex: 1;
  height: 44px;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 2px solid transparent;
}

.order-type-tab.active {
  color: var(--primary);
  background: #ffffff;
  border-bottom-color: var(--primary);
}

.cart-meta-box {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: #ffffff;
  display: flex;
  gap: 0.75rem;
}

.cart-items-container {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cart-empty-state {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
}

.cart-item-row {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

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

.cart-item-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 0.5rem;
}

.cart-item-price {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
}

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

.qty-stepper {
  display: inline-flex;
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.btn-qty {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

.qty-val {
  width: 28px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.cart-item-note-pill {
  font-size: 0.725rem;
  color: var(--primary);
  background: var(--primary-light);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-remove {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}

.cart-item-remove:hover {
  color: var(--accent-rose);
}

/* Cart Summary & Calculations */
.cart-summary-box {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border-color);
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.summary-total-line {
  display: flex;
  justify-content: space-between;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  border-top: 1px dashed var(--border-color);
  padding-top: 0.5rem;
  margin-top: 0.25rem;
}

.summary-total-line span:last-child {
  color: var(--primary);
}

/* Cart Actions */
.cart-actions-box {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  gap: 0.5rem;
}

.btn-clear-cart {
  width: 52px;
  height: 46px;
  border: 1px solid var(--border-color);
  background: #ffffff;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-clear-cart:hover {
  background: #fff1f2;
  color: var(--accent-rose);
  border-color: #fecdd3;
}

.btn-kot {
  flex: 1;
  height: 46px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(245, 158, 11, 0.25);
  transition: var(--transition);
}

.btn-kot:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(245, 158, 11, 0.35);
}

.btn-pay {
  flex: 1.5;
  height: 46px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
  transition: var(--transition);
}

.btn-pay:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

/* Payment Method Grid */
.pay-method-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.pay-method-btn {
  padding: 0.85rem 0.5rem;
  border: 2px solid var(--border-color);
  background: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  font-family: inherit;
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

.pay-method-btn:hover {
  border-color: #cbd5e1;
}

.pay-method-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.quick-cash-btn {
  height: 38px;
  padding: 0 1rem;
  border: 1px solid var(--border-color);
  background: var(--bg-body);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

.quick-cash-btn:hover {
  background: #ffffff;
  border-color: var(--primary);
  color: var(--primary);
}

/* ============================================================
   THERMAL RECEIPT & KOT STYLES (80MM / 58MM STANDARD)
   ============================================================ */
.thermal-receipt {
  width: 100%;
  max-width: 320px;
  background: #ffffff;
  color: #000000;
  padding: 1.25rem 1rem;
  font-family: 'Courier New', Courier, Consolas, monospace;
  font-size: 0.8rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
  box-sizing: border-box;
}

.receipt-header {
  text-align: center;
}

.receipt-header h2 {
  font-size: 1.15rem;
  font-weight: 900;
  margin-bottom: 2px;
  color: #000000;
  text-transform: uppercase;
}

.receipt-header p {
  font-size: 0.725rem;
  margin: 1px 0;
  color: #111111;
}

.receipt-divider {
  border-top: 1px dashed #000000;
  margin: 0.55rem 0;
}

.receipt-meta {
  font-size: 0.75rem;
  line-height: 1.4;
}

.receipt-meta div {
  display: flex;
  justify-content: space-between;
  margin: 2px 0;
}

.receipt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  table-layout: fixed;
  margin: 4px 0;
}

.receipt-table th {
  border-bottom: 1px dashed #000000;
  padding: 4px 0;
  font-weight: 700;
  text-transform: uppercase;
}

.receipt-table td {
  padding: 4px 0;
  vertical-align: top;
}

.receipt-table th:nth-child(1), .receipt-table td:nth-child(1) {
  width: 44%;
  text-align: left;
  word-break: break-word;
}

.receipt-table th:nth-child(2), .receipt-table td:nth-child(2) {
  width: 14%;
  text-align: center;
}

.receipt-table th:nth-child(3), .receipt-table td:nth-child(3) {
  width: 21%;
  text-align: right;
  white-space: nowrap;
}

.receipt-table th:nth-child(4), .receipt-table td:nth-child(4) {
  width: 21%;
  text-align: right;
  white-space: nowrap;
}

.receipt-totals {
  font-size: 0.75rem;
  line-height: 1.4;
}

.rcpt-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.rcpt-row.grand-total {
  font-size: 1rem;
  font-weight: 900;
  padding: 5px 0;
  border-top: 1px dashed #000000;
  border-bottom: 1px dashed #000000;
  margin: 4px 0;
}

.receipt-footer {
  text-align: center;
  font-size: 0.725rem;
  margin-top: 0.5rem;
  color: #000000;
}

.receipt-barcode {
  font-size: 1.25rem;
  letter-spacing: 2px;
  margin: 6px 0;
  font-weight: 900;
  font-family: monospace;
}

@page {
  size: 80mm auto;
  margin: 0;
}

@media print {
  /* Prevent browser header/footer and full-page layout disruption */
  html, body {
    width: 80mm !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  body * {
    visibility: hidden;
  }

  /* Isolate only the active receipt or KOT ticket, NEVER both */
  body.printing-kot #printable-kot,
  body.printing-kot #printable-kot * {
    visibility: visible;
  }
  body.printing-kot #printable-receipt {
    display: none !important;
  }

  body:not(.printing-kot) #printable-receipt,
  body:not(.printing-kot) #printable-receipt * {
    visibility: visible;
  }
  body:not(.printing-kot) #printable-kot {
    display: none !important;
  }

  #printable-receipt, #printable-kot {
    position: absolute;
    left: 0;
    top: 0;
    width: 76mm !important;
    margin: 0 auto !important;
    padding: 2mm 1mm !important;
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
  }
}

/* ============================================================
   SALES ANALYTICS & AUDIT STYLES
   ============================================================ */
.btn-period-pill {
  padding: 0.4rem 0.95rem;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  font-size: 0.825rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.btn-period-pill:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.04);
}
.btn-period-pill.active {
  background: var(--primary) !important;
  color: #ffffff !important;
  box-shadow: var(--shadow-sm);
}

.audit-comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-top: 1rem;
}
@media (max-width: 768px) {
  .audit-comparison-grid {
    grid-template-columns: 1fr;
  }
}
.audit-card {
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}
.audit-card.original {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.audit-card.revised {
  border-color: #6ee7b7;
  background: #f0fdf4;
}
.audit-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px dashed var(--border-color);
  font-size: 0.85rem;
}

/* Visual Timeline Bar Chart */
.timeline-chart-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 220px;
  padding: 1.5rem 0.5rem 0.5rem 0.5rem;
  border-bottom: 2px solid var(--border-color);
  overflow-x: auto;
}
.timeline-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 36px;
  height: 100%;
  justify-content: flex-end;
}
.timeline-bar {
  width: 100%;
  max-width: 42px;
  background: linear-gradient(180deg, var(--primary) 0%, #3730a3 100%);
  border-radius: 6px 6px 0 0;
  transition: height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
}
.timeline-bar:hover {
  background: linear-gradient(180deg, #6366f1 0%, var(--primary) 100%);
  filter: brightness(1.1);
}
.timeline-bar-label {
  font-size: 0.725rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
  white-space: nowrap;
}
.timeline-bar-val {
  font-size: 0.675rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
}

/* ============================================================
   ADMIN NAVIGATION DRAWER & IN-APP PORTAL (MOBILE APP)
   ============================================================ */
.admin-drawer-panel {
  box-shadow: 10px 0 35px rgba(0, 0, 0, 0.45);
}
.drawer-nav-item {
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}
.drawer-nav-item:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
  transform: translateX(3px);
}
.drawer-nav-item:active {
  transform: scale(0.98);
}



