/* ============================================
   Hospitality OS — Mobile & Tablet Responsive CSS
   Mobile-first: base = phone (≤768px)
   Tablet: 769px–1024px
   Desktop: ≥1025px (unchanged)
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --bottom-nav-height: 64px;
  --topbar-height-mobile: 56px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  --mobile-radius: 12px;
  --mobile-card-radius: 14px;
  --mobile-btn-radius: 10px;
  --mobile-font-sm: 0.75rem;
  --mobile-font-base: 0.875rem;
  --mobile-font-lg: 1rem;
  --mobile-font-xl: 1.125rem;
  --mobile-font-2xl: 1.375rem;
  --mobile-font-3xl: 1.625rem;
  --touch-target: 48px;
  --mobile-overlay: rgba(0, 0, 0, 0.5);
  --bottom-nav-bg: #ffffff;
  --bottom-nav-border: #e5e7eb;
  --drawer-bg: #111827;
}

/* ============================================
   BASE: Mobile first (≤768px)
   These styles activate on all screens ≤768px
   ============================================ */
@media (max-width: 768px) {
  html, body {
    overflow: hidden;
    height: 100%;
    -webkit-overflow-scrolling: touch;
  }

  /* --- Safe Areas --- */
  .app {
    padding-top: var(--safe-area-top);
  }

  /* --- Bottom Navigation Bar (Apple-style pill) --- */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: max(8px, var(--safe-area-bottom));
    left: 10px;
    right: 10px;
    height: var(--bottom-nav-height);
    background: var(--bottom-nav-bg);
    border-radius: 24px;
    z-index: 100002;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: none;
    padding-bottom: 0;
  }

  .mobile-bottom-nav-inner {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: stretch;
    border-radius: 24px;
    overflow: hidden;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.55rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    transition: color 0.2s;
    padding: 4px 2px;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    text-decoration: none;
  }

  .mobile-nav-item i {
    font-size: 1.2rem;
    transition: color 0.2s;
  }

  .mobile-nav-item span {
    font-size: 0.55rem;
    line-height: 1;
  }

  .mobile-nav-item:active {
    transform: scale(0.92);
  }

  .mobile-nav-item.active {
    color: var(--accent);
  }

  .mobile-nav-item.active i {
    color: var(--accent);
  }

  .mobile-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
  }

  /* --- FAB hidden on mobile (bottom nav POS button suffices) --- */
  .mobile-fab {
    display: none !important;
  }

  /* --- More Sheet Backdrop --- */
  .more-sheet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100000;
    -webkit-tap-highlight-color: transparent;
  }

  .more-sheet-backdrop.show {
    display: block;
  }

  /* --- More Bottom Sheet --- */
  .more-sheet {
    position: fixed;
    bottom: 0;
    left: 8px;
    right: 8px;
    background: var(--surface);
    border-radius: 16px;
    z-index: 100001;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    padding-bottom: var(--safe-area-bottom);
    display: none;
    animation: slideUp 0.3s ease;
  }

  .more-sheet::-webkit-scrollbar {
    display: none;
  }

  .more-sheet.open {
    display: block;
  }

  .more-sheet .bottom-sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong);
    margin: 8px auto;
  }

  .more-sheet .bottom-sheet-body {
    padding: 4px 8px calc(var(--bottom-nav-height) + 12px);
  }

  /* More Grid - auto-fit to screen */
  .more-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    gap: 6px 2px;
    padding: 0 2px;
  }

  .more-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 2px 6px;
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
    text-align: center;
    min-height: 60px;
  }

  .more-grid-item:active {
    background: var(--surface-2);
    transform: scale(0.95);
  }

  .more-grid-item i {
    font-size: 1rem;
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--surface-2);
  }

  .more-grid-item span {
    font-size: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.2;
    word-break: break-word;
    max-width: 100%;
  }

  /* --- Sidebar hidden on mobile (use More sheet instead) --- */
  .sidebar {
    display: none !important;
  }

  .sidebar-backdrop {
    display: none !important;
  }

  /* --- Topbar mobile --- */
  .topbar {
    padding: 0 8px !important;
    height: var(--topbar-height-mobile) !important;
    padding-top: var(--safe-area-top) !important;
    gap: 4px;
  }

  .topbar-left {
    gap: 8px !important;
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }

  .page-title {
    font-size: 0 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 1;
    min-width: 0;
  }

  .page-title::before {
    content: '\f2e7';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 1.1rem;
    color: #4b5563;
  }

  /* Hide hamburger on mobile (desktop sidebar toggle) */
  #desktopSidebarToggle {
    display: none !important;
  }

  /* Hide branch/restaurant selectors on mobile */
  .context-select {
    display: none !important;
  }

  /* Hide branch name badge on mobile */
  .topbar-left > span:last-child {
    display: none !important;
  }

  /* Hide online indicator on mobile */
  #onlineIndicator {
    display: none !important;
  }

  /* Hide subscription/premium status badges on mobile */
  .topbar-right a[href*="upgrade"],
  .topbar-right > span {
    display: none !important;
  }

  /* Hide language toggle on mobile */
  .topbar-right > div[id*="lang"],
  .topbar-right > div[class*="lang"] {
    display: none !important;
  }

  /* Hide POS quick button on mobile (already in bottom nav) */
  .topbar-right button[onclick*="openTab.*pos"] {
    display: none !important;
  }

  .topbar-right {
    gap: 6px !important;
    flex-shrink: 0;
  }

  .user-name-text {
    display: none !important;
  }

  .user-role-text {
    display: none !important;
  }

  .topbar-right .user-profile {
    gap: 4px !important;
    padding: 2px 6px !important;
  }

  .user-avatar {
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
  }

  .topbar-right a[title="Logout"] {
    padding: 4px !important;
    font-size: 14px !important;
  }

  /* Notification bell on mobile */
  .notif-wrap .topbar-icon {
    padding: 4px !important;
    font-size: 14px !important;
  }

  /* --- Main content --- */
  .main-content {
    padding-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom) + 24px) !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }

  /* Hide scrollbar on content area (keep scrolling) */
  .tabs-content {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 8px 8px 24px 8px !important;
  }

  .tabs-content::-webkit-scrollbar,
  .main-content::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  .tabs-container {
    height: 100%;
  }

  .tabs-header {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-right: 0 !important;
    border-bottom: none !important;
    background: var(--gray-100) !important;
  }

  .tabs-header::-webkit-scrollbar {
    display: none;
  }

  .tabs-list {
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    gap: 0 !important;
  }

  .tab {
    padding: 6px 4px !important;
    font-size: 0.65rem !important;
    width: 88px !important;
    gap: 2px !important;
  }

  .tab i:first-child {
    font-size: 8px !important;
  }

  .tab span {
    font-size: 0.6rem !important;
  }

  .tab-close {
    font-size: 8px !important;
    margin-left: 2px !important;
  }

  /* --- Page wraps --- */
  .page-wrap {
    padding: 0 !important;
  }

  /* --- Module Header --- */
  .module-header h4 {
    font-size: 1.1rem !important;
  }

  .module-header .header-actions {
    width: 100%;
    justify-content: flex-end;
  }

  /* --- Cards --- */
  .stat-card {
    padding: 14px !important;
  }

  .stat-card .stat-info .stat-value {
    font-size: 1.3rem !important;
  }

  .stat-card .stat-icon {
    width: 36px !important;
    height: 36px !important;
    font-size: 16px !important;
  }

  /* --- Dashboard Stats: horizontal scrolling carousel on mobile --- */
  .page-wrap.dash-wrap {
    padding: 6px 4px !important;
  }

  .dash-stats-carousel {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    margin-bottom: 4px !important;
    width: 100% !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  .dash-stats-carousel::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  .dash-stats-track {
    display: flex !important;
    gap: 6px !important;
    padding: 2px 0 !important;
    width: max-content !important;
  }

  .dash-stats-track > div {
    display: flex !important;
    flex-shrink: 0 !important;
    gap: 6px !important;
    margin-bottom: 0 !important;
    grid-template-columns: none !important;
  }

  .dash-stats-track > div > div {
    flex-shrink: 0 !important;
    width: 120px !important;
    padding: 5px 7px !important;
    border-radius: 8px !important;
  }

  .dash-stats-track > div > div [style*="font-size:0.8rem"] {
    font-size: 0.55rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .dash-stats-track > div > div [style*="font-size:1.5rem"] {
    font-size: 0.8rem !important;
    margin-top: 0 !important;
  }

  .dash-stats-track > div > div > div {
    align-items: center !important;
  }

  .dash-stats-track > div > div [style*="width:44px"] {
    width: 18px !important;
    height: 18px !important;
    font-size: 8px !important;
    border-radius: 5px !important;
    flex-shrink: 0 !important;
  }

  /* JS-based auto-scroll (no CSS animation to avoid conflict) */

  /* Dashboard main grid (Recent Orders / Tables etc.) → stack on mobile */
  .dash-main-grid {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }

  .dash-main-grid > div,
  .dash-main-grid [style*="background:white"] {
    padding: 10px 12px !important;
    border-radius: 8px !important;
  }

  .dash-main-grid > div[style*="flex-direction:column"] {
    gap: 6px !important;
  }

  .dash-main-grid h3 {
    font-size: 0.85rem !important;
    margin-bottom: 6px !important;
  }

  .dash-main-grid table {
    font-size: 0.72rem !important;
  }

  .dash-main-grid td,
  .dash-main-grid th {
    padding: 6px 4px !important;
  }

  /* --- Dashboard Header: compact row on mobile --- */
  .dash-header-mobile {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 6px !important;
    gap: 6px !important;
  }

  .dash-header-left {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .dash-header-left h1 {
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: #1F2937 !important;
    margin: 0 !important;
    white-space: nowrap !important;
  }

  .dash-header-left p {
    font-size: 0.55rem !important;
    color: #6B7280 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Hide New Order button on mobile (bottom nav has same action) */
  .dash-new-order-btn {
    display: none !important;
  }

  /* --- Tables → Card List on Mobile --- */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* --- Form Controls --- */
  .form-control, .form-select {
    font-size: 0.95rem !important;
    padding: 12px 14px !important;
    min-height: 48px;
  }

  .form-label {
    font-size: 0.85rem !important;
  }

  /* --- Buttons --- */
  .btn {
    padding: 10px 18px !important;
    font-size: 0.9rem !important;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }

  .btn-sm {
    padding: 8px 14px !important;
    font-size: 0.8rem !important;
    min-height: 38px;
  }

  /* --- POS Quick Access --- */
  .pos-quick-btn {
    width: 100%;
    justify-content: center;
    padding: 12px 20px !important;
    font-size: 1rem !important;
  }

  /* --- Empty State --- */
  .empty-state {
    padding: 40px 16px !important;
  }

  /* --- Modal → Bottom Sheet --- */
  .modal, [id$="Modal"] {
    align-items: flex-end !important;
  }

  .modal-dialog, [id$="Modal"] > div:not([class*="position"]) {
    margin: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 85vh !important;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    animation: slideUp 0.3s ease;
  }

  /* Keep center modals for small confirmations */
  .modal-sm, [id$="Modal"] .modal-sm {
    border-radius: 16px !important;
    margin: 0 16px !important;
    width: auto !important;
    max-width: 400px !important;
    position: relative;
  }

  /* --- Cards --- */
  .card {
    border-radius: var(--mobile-card-radius) !important;
  }

  .card-body {
    padding: 16px !important;
  }

  /* --- Badges --- */
  .badge {
    font-size: 0.7rem !important;
    padding: 4px 10px !important;
  }

  /* --- Hotel Dashboard: horizontal scrolling carousel on mobile --- */
  .page-wrap.hotel-wrap {
    padding: 6px 4px !important;
  }

  .hotel-stats-carousel {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    margin-bottom: 4px !important;
    width: 100% !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  .hotel-stats-carousel::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }

  .hotel-stats-track {
    display: flex !important;
    gap: 6px !important;
    padding: 2px 0 !important;
    width: max-content !important;
  }

  .hotel-stats-track > div {
    display: flex !important;
    flex-shrink: 0 !important;
    gap: 6px !important;
    margin-bottom: 0 !important;
    grid-template-columns: none !important;
  }

  .hotel-stats-track > div > div {
    flex-shrink: 0 !important;
    width: 120px !important;
    padding: 5px 7px !important;
    border-radius: 8px !important;
  }

  .hotel-stats-track > div > div [style*="font-size:0.8rem"] {
    font-size: 0.55rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  .hotel-stats-track > div > div [style*="font-size:1.5rem"] {
    font-size: 0.8rem !important;
    margin-top: 0 !important;
  }

  .hotel-stats-track > div > div > div {
    align-items: center !important;
  }

  .hotel-stats-track > div > div [style*="width:44px"] {
    width: 18px !important;
    height: 18px !important;
    font-size: 8px !important;
    border-radius: 5px !important;
    flex-shrink: 0 !important;
  }

  /* Hotel main grid → stack on mobile */
  .hotel-main-grid {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }

  .hotel-main-grid > div,
  .hotel-main-grid [style*="background:white"] {
    padding: 10px 12px !important;
    border-radius: 8px !important;
  }

  .hotel-main-grid > div[style*="flex-direction:column"] {
    gap: 6px !important;
  }

  .hotel-main-grid h3 {
    font-size: 0.85rem !important;
    margin-bottom: 6px !important;
  }

  .hotel-main-grid table {
    font-size: 0.72rem !important;
  }

  .hotel-main-grid td,
  .hotel-main-grid th {
    padding: 6px 4px !important;
  }

  /* Hotel Header: compact on mobile */
  .hotel-header-mobile {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 6px !important;
    gap: 6px !important;
  }

  .hotel-header-left {
    flex: 1 !important;
    min-width: 0 !important;
  }

  .hotel-header-left h1 {
    font-size: 1rem !important;
    font-weight: 700 !important;
    color: #1F2937 !important;
    margin: 0 !important;
    white-space: nowrap !important;
  }

  .hotel-header-left p {
    font-size: 0.55rem !important;
    color: #6B7280 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Hotel revenue row → 2-col on mobile */
  .hotel-stats-grid-2 {
    grid-template-columns: 1fr 1fr !important;
    gap: 6px !important;
  }

  .hotel-stats-grid-2 > div {
    padding: 10px !important;
    border-radius: 8px !important;
  }

  .hotel-stats-grid-2 > div > div:last-child {
    font-size: 0.9rem !important;
  }

  .hotel-stats-grid-2 > div > div:first-child {
    font-size: 0.55rem !important;
  }

  /* --- POS Specific Mobile Overrides --- */
  .pos-container {
    grid-template-columns: 1fr !important;
  }

  .cart-panel {
    position: fixed;
    bottom: var(--bottom-nav-height);
    left: 0;
    right: 0;
    z-index: 9999;
    max-height: 50vh;
    border-left: none !important;
    border-top: 2px solid #e5e7eb;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
  }

  .cart-panel.collapsed {
    transform: translateY(calc(100% - 52px));
  }

  .cart-panel .cart-header {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  /* Force show name & phone inputs on mobile */
  .cart-header #customerName,
  .cart-header #customerPhone {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    width: 48% !important;
    padding: 8px 10px !important;
    font-size: 0.85rem !important;
    background: #F3F4F6 !important;
    border: 1px solid #D1D5DB !important;
    border-radius: 6px !important;
    color: #1F2937 !important;
  }
}

/* ============================================
   TABLET: 769px – 1024px
   ============================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  /* --- Tablet Layout --- */
  .topbar {
    padding: 0 16px !important;
  }

  .page-title {
    font-size: 1.05rem !important;
  }

  /* Tablet: collapsed sidebar */
  .sidebar:not(.full) {
    width: 72px !important;
  }

  .sidebar:not(.full) .logo-text,
  .sidebar:not(.full) .nav-text,
  .sidebar:not(.full) .sidebar-search input,
  .sidebar:not(.full) .submenu-arrow,
  .sidebar:not(.full) .user-details-sidebar {
    display: none !important;
  }

  .sidebar:not(.full) .sidebar-search {
    padding: 8px 12px !important;
    display: block !important;
  }

  .sidebar:not(.full) .sidebar-search::after {
    content: '\f002';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    display: block;
    text-align: center;
    color: #6B7280;
    font-size: 14px;
  }

  .sidebar:not(.full) .nav-link {
    justify-content: center !important;
    padding: 10px !important;
  }

  .sidebar:not(.full) .nav-link i:first-child {
    margin: 0 !important;
  }

  .sidebar:not(.full) .submenu {
    display: block !important;
    padding-left: 0 !important;
  }

  .sidebar:not(.full) .submenu li a {
    justify-content: center !important;
    font-size: 0 !important;
    padding: 8px !important;
  }

  .sidebar:not(.full) .submenu li a i {
    font-size: 14px !important;
    margin: 0 !important;
  }

  /* --- Pagination / Stats --- */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* --- Module Header --- */
  .module-header h4 {
    font-size: 1.2rem !important;
  }

  /* --- Tablet specific card sizes --- */
  .stat-card .stat-info .stat-value {
    font-size: 1.4rem !important;
  }

  /* --- Form Controls --- */
  .form-control, .form-select {
    font-size: 0.9rem !important;
    padding: 10px 14px !important;
  }

  /* --- Button Sizes --- */
  .btn {
    padding: 8px 16px !important;
    font-size: 0.85rem !important;
    min-height: 42px;
  }

  /* --- POS Tablet --- */
  .pos-container {
    grid-template-columns: 1fr 320px !important;
  }

  .menu-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
  }

  .page-wrap {
    padding: 20px !important;
  }

  /* Hotel Dashboard tablet */
  .hotel-main-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .hotel-stats-grid-2 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ============================================
   SHARED: Utility classes for mobile/tablet
   ============================================ */
@media (max-width: 1024px) {
  /* Grid helpers */
  .mobile-stack {
    flex-direction: column !important;
  }

  .mobile-full {
    width: 100% !important;
  }

  .mobile-gap-2 {
    gap: 8px !important;
  }

  .mobile-gap-4 {
    gap: 16px !important;
  }

  .mobile-text-center {
    text-align: center !important;
  }

  .mobile-p-4 {
    padding: 16px !important;
  }

  .mobile-px-4 {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .mobile-py-2 {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
  }

  .mobile-mt-4 {
    margin-top: 16px !important;
  }

  .mobile-mb-4 {
    margin-bottom: 16px !important;
  }

  /* Hide on mobile */
  .mobile-hide {
    display: none !important;
  }

  /* Show only on mobile */
  .mobile-only {
    display: block !important;
  }

  /* Card list view (for replacing tables) */
  .card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .card-list-item {
    background: white;
    border-radius: var(--mobile-card-radius);
    padding: 14px 16px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s;
  }

  .card-list-item:active {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  /* Page header */
  .page-header-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 8px;
  }

  .page-header-compact h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1f2937;
  }

  /* Filter pills (horizontal scroll) */
  .filter-pills {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
    margin-bottom: 16px;
    scrollbar-width: none;
  }

  .filter-pills::-webkit-scrollbar {
    display: none;
  }

  .filter-pill {
    flex-shrink: 0;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: white;
    font-size: 0.8rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
  }

  .filter-pill:active {
    transform: scale(0.96);
  }

  .filter-pill.active {
    background: #d97706;
    color: white;
    border-color: #d97706;
  }

  /* Bottom sheet */
  .bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px 16px 0 0;
    z-index: 100001;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease;
    padding-bottom: var(--safe-area-bottom);
  }

  .bottom-sheet-handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #d1d5db;
    margin: 8px auto;
  }

  .bottom-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
  }

  .bottom-sheet-header h3 {
    font-size: 1rem;
    font-weight: 600;
  }

  .bottom-sheet-body {
    padding: 16px;
  }

  /* Swipe indicator for cart */
  .swipe-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: #d1d5db;
    margin: 8px auto;
    display: block;
  }

  /* Touch-safe spacing for content inside bottom-nav area */
  .has-bottom-nav {
    padding-bottom: calc(var(--bottom-nav-height) + 16px) !important;
  }

  /* Section title */
  .section-title-mobile {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .section-title-mobile i {
    color: #d97706;
    font-size: 1rem;
  }

  /* --- POS mobile: hide scrollbars, bigger touch targets --- */
  .pos-container .menu-panel {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  .pos-container .menu-panel::-webkit-scrollbar {
    display: none !important;
  }

  .pos-container .cart-items {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  .pos-container .cart-items::-webkit-scrollbar {
    display: none !important;
  }

  .pos-container .cat-tabs {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  .pos-container .cat-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .pos-container .table-select {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }
  .pos-container .table-select::-webkit-scrollbar {
    display: none !important;
  }

  /* Smaller menu item on mobile */
  .pos-container .menu-item {
    padding: 8px 6px !important;
    min-height: 72px !important;
    border-radius: 10px !important;
  }

  .pos-container .menu-item .emoji {
    font-size: 20px !important;
    margin-bottom: 2px !important;
  }

  .pos-container .menu-item .name {
    font-size: 0.65rem !important;
  }

  .pos-container .menu-item .price {
    font-size: 0.6rem !important;
  }

  /* Category tabs compact */
  .pos-container .cat-tab {
    padding: 8px 14px !important;
    font-size: 0.7rem !important;
    min-height: 36px !important;
  }

  /* Table buttons compact */
  .pos-container .table-btn {
    padding: 6px 12px !important;
    font-size: 0.65rem !important;
    min-height: 32px !important;
  }

  /* Cart bottom sheet adjustments */
  .pos-container .cart-header {
    padding: 10px 14px !important;
  }

  .pos-container .cart-header h3 {
    font-size: 0.85rem !important;
  }

  .pos-container .cart-item {
    padding: 8px 0 !important;
  }

  .pos-container .cart-item-name {
    font-size: 0.75rem !important;
  }

  .pos-container .qty-btn {
    width: 30px !important;
    height: 30px !important;
    font-size: 14px !important;
    border-radius: 8px !important;
  }

  .pos-container .cart-footer {
    padding: 8px 12px !important;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .pos-container .place-order-btn {
    padding: 16px !important;
    font-size: 1.05rem !important;
    min-height: 52px !important;
    border-radius: 12px !important;
  }

  /* Customer name & phone inputs mobile friendly - side by side */
  .pos-container #customerName,
  .pos-container #customerPhone {
    font-size: 0.75rem !important;
    padding: 1px 10px !important;
    min-height: 0px !important;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDownOut {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* --- More Sheet animation tweaks --- */
.more-sheet.closing {
  animation: slideDownOut 0.25s ease forwards;
  pointer-events: none;
}

/* Modal slide down close animation */
.modal-closing {
  animation: slideDownOut 0.25s ease forwards !important;
  pointer-events: none !important;
}
.modal-closing > div {
  animation: slideDownOut 0.25s ease forwards !important;
}

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

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Ripple effect for touch feedback */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: scale(0);
  opacity: 1;
  pointer-events: none;
}

.ripple:active::after {
  animation: ripple 0.4s ease-out;
}

/* ============================================
   CRM MODULE: Mobile & Tablet Responsive
   ============================================ */
@media (max-width: 768px) {
  /* CRM Stats: horizontal scroll, scrollbar hidden, auto-scroll */
  .crm-stats-carousel {
    overflow-x: auto !important;
    overflow-y: hidden !important;
    margin-bottom: 8px !important;
    width: 100% !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 0 !important;
  }
  .crm-stats-carousel::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }

  .crm-stats-track {
    display: flex !important;
    gap: 6px !important;
    padding: 2px 0 !important;
    width: max-content !important;
    animation: crmAutoScroll 8s ease-in-out infinite alternate;
  }

  @keyframes crmAutoScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(calc(-100% + 100vw - 20px)); }
  }

  .crm-stats-track > div {
    display: flex !important;
    flex-shrink: 0 !important;
    gap: 6px !important;
    margin: 0 auto !important;
    grid-template-columns: none !important;
    justify-content: center !important;
  }

  .crm-stats-track > div > div {
    flex-shrink: 0 !important;
    width: 105px !important;
    padding: 8px 8px !important;
    border-radius: 8px !important;
    text-align: center !important;
  }

  .crm-stats-track > div > div .crm-stat .icon {
    width: 22px !important;
    height: 22px !important;
    font-size: 0.55rem !important;
    border-radius: 6px !important;
    margin: 0 auto 4px !important;
  }

  .crm-stats-track > div > div .crm-stat .value {
    font-size: 0.8rem !important;
    white-space: nowrap !important;
    line-height: 1.1 !important;
  }

  .crm-stats-track > div > div .crm-stat .label {
    font-size: 0.48rem !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    margin-top: 2px !important;
  }

  /* CRM Grids → single column, centered */
  .crm-grid-4, .crm-grid-3, .crm-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    max-width: 100% !important;
  }

  /* CRM Cards compact, centered */
  .crm-card {
    padding: 12px !important;
    border-radius: 10px !important;
    width: 100% !important;
    margin: 0 auto !important;
  }

  .crm-card h5 {
    font-size: 0.82rem !important;
    margin-bottom: 8px !important;
  }

  /* CRM Tables → scrollable but hide scrollbar */
  .crm-table {
    font-size: 0.7rem !important;
  }

  .crm-table th, .crm-table td {
    padding: 5px 6px !important;
    white-space: nowrap !important;
  }

  .crm-card .table-responsive {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    -webkit-overflow-scrolling: touch !important;
    overflow-x: auto !important;
  }
  .crm-card .table-responsive::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }

  /* CRM Tabs → horizontal scroll, scrollbar hidden */
  .crm-tabs {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    flex-wrap: nowrap !important;
    gap: 0 !important;
    border-bottom: none !important;
    margin-bottom: 12px !important;
  }
  .crm-tabs::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }

  .crm-tab {
    padding: 8px 12px !important;
    font-size: 0.68rem !important;
    white-space: nowrap !important;
    flex-shrink: 0;
  }

  /* CRM Modal → bottom sheet on mobile */
  .crm-modal-overlay {
    align-items: flex-end !important;
    z-index: 100003 !important;
  }

  .crm-modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 85vh !important;
    padding: 16px !important;
    animation: slideUp 0.3s ease;
    z-index: 100003 !important;
  }

  .crm-form-row {
    grid-template-columns: 1fr !important;
  }

  .crm-input, .crm-select, .crm-textarea {
    font-size: 0.9rem !important;
    padding: 12px 14px !important;
    min-height: 44px;
  }

  .crm-btn {
    padding: 10px 18px !important;
    font-size: 0.85rem !important;
    min-height: 44px;
  }

  /* CRM Badge compact */
  .crm-badge {
    font-size: 0.58rem !important;
    padding: 2px 7px !important;
  }

  /* CRM Page Header */
  .crm-page-header {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-bottom: 12px !important;
    gap: 8px !important;
  }

  .crm-page-header h4 {
    font-size: 1rem !important;
    margin: 0 !important;
  }

  /* ========== Customer Detail Page Mobile ========== */
  .cd-grid-4, .cd-grid-3, .cd-grid-2, .cd-grid-1-2, .cd-grid-2-1 {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .cd-card {
    padding: 12px !important;
    border-radius: 10px !important;
  }

  /* Profile header: name left, info right */
  .cd-profile-header {
    flex-direction: row !important;
    align-items: center !important;
    text-align: left !important;
    gap: 12px !important;
  }

  .cd-avatar {
    width: 50px !important;
    height: 50px !important;
    font-size: 1.2rem !important;
    flex-shrink: 0 !important;
  }

  .cd-profile-info {
    text-align: left !important;
    flex: 1 !important;
    min-width: 0 !important;
  }

  .cd-profile-info h3 {
    font-size: 0.95rem !important;
    margin-bottom: 2px !important;
  }

  .cd-profile-info p {
    font-size: 0.7rem !important;
    line-height: 1.3 !important;
  }

  /* Profile right side (Customer since) */
  .cd-profile-header > div:last-child {
    text-align: right !important;
    flex-shrink: 0 !important;
    font-size: 0.65rem !important;
  }

  /* Stats row: horizontal scroll, scrollbar hidden */
  .cd-grid-4 {
    display: flex !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    gap: 6px !important;
    padding: 0 0 4px !important;
  }
  .cd-grid-4::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }

  .cd-grid-4 > div {
    flex-shrink: 0 !important;
    min-width: 80px !important;
    padding: 8px 6px !important;
    text-align: center !important;
  }

  .cd-stat .value {
    font-size: 0.85rem !important;
  }

  .cd-stat .label {
    font-size: 0.55rem !important;
  }

  /* CD Tabs → horizontal scroll, scrollbar hidden */
  .cd-tabs {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    flex-wrap: nowrap !important;
    gap: 0 !important;
    margin-bottom: 12px !important;
  }
  .cd-tabs::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }

  .cd-tab {
    padding: 8px 10px !important;
    font-size: 0.68rem !important;
    white-space: nowrap !important;
    flex-shrink: 0;
  }

  .cd-table {
    font-size: 0.7rem !important;
  }

  .cd-table th, .cd-table td {
    padding: 5px 6px !important;
    white-space: nowrap !important;
  }

  /* Hide all scrollbars inside cd-card */
  .cd-card {
    overflow: hidden !important;
  }

  .cd-card .table-responsive {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }
  .cd-card .table-responsive::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }

  /* Stats row scrollbar hidden */
  .cd-grid-4::-webkit-scrollbar { display: none !important; width: 0 !important; height: 0 !important; }

  /* Order Items Modal → bottom sheet */
  #orderItemsModal {
    align-items: flex-end !important;
    z-index: 100003 !important;
  }

  #orderItemsModal > div {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
    max-height: 85vh !important;
    animation: slideUp 0.3s ease;
    z-index: 100003 !important;
  }
}

/* CRM Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  .crm-grid-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .crm-grid-3 {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

/* ============================================
   PRINT: Hide mobile elements when printing
   ============================================ */
@media print {
  .mobile-bottom-nav,
  .mobile-fab,
  .sidebar-backdrop {
    display: none !important;
  }
}
