:root {
  --bg: #f8fafc;
  --bg-2: #ffffff;
  --bg-3: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-dim: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --accent: #0891b2;
}

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

html, body {
  height: 100%;
  overflow-x: hidden;
  font-family: 'Cairo', 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  user-select: none;
  -webkit-user-select: none;
}

input, textarea { 
  user-select: text; 
  -webkit-user-select: text;
  touch-action: manipulation;
}

body {
  max-width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  padding-bottom: 90px;
}

/* Desktop responsive container */
@media (min-width: 768px) {
  body {
    max-width: 900px;
    padding: 0 24px;
  }
  .app-header {
    padding: 16px 24px;
  }
  .screen {
    padding: 10px 20px;
  }
  .stats-grid.three {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1200px) {
  body {
    max-width: 1100px;
  }
}

/* ===== HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-currency-select {
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  min-width: 60px;
  text-align: center;
}

/* Profile Modal */
.profile-user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-3);
  border-radius: 14px;
  margin-bottom: 16px;
}
.profile-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  overflow: hidden;
  flex-shrink: 0;
}
.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-info { flex: 1; }
.profile-name { font-weight: 800; font-size: 16px; }
.profile-email { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.profile-section { margin-bottom: 16px; }
.profile-section-title { font-weight: 800; font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.profile-setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.profile-setting-row:last-child { border-bottom: none; }
.profile-setting-label { font-weight: 700; font-size: 14px; }
.profile-setting-desc { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--border);
  border-radius: 26px;
  transition: 0.3s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* Dark Mode */
body.dark-mode {
  --bg: #0a0f1e;
  --bg-2: #111827;
  --bg-3: #1e293b;
  --border: #1e293b;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  background: linear-gradient(180deg, #0a0f1e 0%, #0f172a 100%) !important;
}
body.dark-mode .app-header { background: rgba(10, 15, 30, 0.95) !important; }

/* Center logo in header on all sizes */
.app-header {
  display: grid !important;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.app-header .app-logo { justify-self: center; text-align: center; }
#headerMobileRight { justify-self: end; }
.header-desktop-left { justify-self: start; }

/* Desktop header extras (avatar + theme toggle) — hidden on mobile */
.header-desktop-left { display: flex; align-items: center; gap: 8px; }
/* On mobile, hide the theme toggle (available in profile); keep avatar for profile access */
.header-theme-toggle { display: none; }
.header-avatar-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--primary); background: var(--bg-3);
  cursor: pointer; overflow: hidden; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.header-avatar-btn img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.header-theme-toggle {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-3);
  cursor: pointer; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.header-theme-toggle:hover, .header-avatar-btn:hover { border-color: var(--primary); }
body.dark-mode .bottom-nav { background: rgba(10, 15, 30, 0.97) !important; }
body.dark-mode .welcome-overlay,
body.dark-mode .license-overlay { background: linear-gradient(180deg, #0a0f1e 0%, #0f172a 100%) !important; }
body.dark-mode .more-menu { background: #111827 !important; }
body.dark-mode .toast { background: #1e293b !important; }
body.dark-mode .modal { background: #111827 !important; }
body.dark-mode .modal-overlay { background: rgba(0,0,0,0.6) !important; }
body.dark-mode .card { background: #1e293b !important; }
body.dark-mode .input, body.dark-mode select, body.dark-mode textarea { background: #0f172a !important; color: #f1f5f9 !important; border-color: #334155 !important; }
body.dark-mode .btn-outline { color: #f1f5f9 !important; border-color: #334155 !important; }
body.dark-mode .chip { background: #1e293b !important; color: #94a3b8 !important; }
body.dark-mode .chip.active { background: var(--primary) !important; color: white !important; }
body.dark-mode .list-item { border-color: #1e293b !important; }
body.dark-mode .pos-product-card { background: #1e293b !important; border-color: #334155 !important; }
body.dark-mode .stat-card { background: #1e293b !important; }
body.dark-mode .search-bar .input { background: #0f172a !important; }
body.dark-mode .welcome-currency-box, body.dark-mode .welcome-feature, body.dark-mode .welcome-usp, body.dark-mode .welcome-why { background: #1e293b !important; border-color: #334155 !important; }
body.dark-mode .welcome-pricing { background: rgba(37,99,235,0.1) !important; }
body.dark-mode .profile-user-card { background: #1e293b !important; }
body.dark-mode .profile-setting-row { border-color: #1e293b !important; }
body.dark-mode .more-menu-item:hover, body.dark-mode .more-menu-item:active { background: #1e293b !important; }
body.dark-mode .welcome-btn-google { background: #1e293b !important; border-color: #334155 !important; }

/* Invoice stays white with dark text even in dark mode (it's a printable receipt) */
#projectInvoiceArea {
  background: #fff !important;
  color: #1f2937 !important;
}
/* Purchase preview invoice: keep white in dark mode */
body.dark-mode #achatPreviewSheet { background: #f3f4f6 !important; }
body.dark-mode #achatPreviewContent { background: #f3f4f6 !important; }
body.dark-mode #achatPreviewContent .card { background: #ffffff !important; color: #000 !important; }

/* Sale invoice preview: keep white like a printed receipt, even in dark mode */
body.dark-mode #screen-invoice-preview .card {
  background: #ffffff !important;
  color: #000 !important;
}
/* The whole invoice view stays light (it's a printable receipt) — even in dark mode */
body.dark-mode #projectExpensesViewSheet { background: #f3f4f6 !important; }
body.dark-mode #projectExpensesViewContent { background: #f3f4f6 !important; }
body.dark-mode #projectInvoiceArea { background: #fff !important; color: #1f2937 !important; }
body.dark-mode #projectViewHeader { background: #fff !important; border-bottom-color: #e5e7eb !important; }
body.dark-mode #projectViewHeader #projectExpensesViewTitle { color: #1f2937 !important; }

.app-logo {
  font-weight: 900;
  font-size: 22px;
  background: linear-gradient(135deg, #3b82f6, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  padding: 20px;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== CARDS & ITEMS ===== */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  transition: all 0.2s;
}

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

.stat-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(6, 182, 212, 0.05));
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.stat-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 900;
  color: var(--text);
}

.stat-value.danger { color: var(--danger); }
.stat-value.success { color: var(--success); }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.stats-grid.three {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: white;
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  width: auto;
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
}

.action-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

/* ===== INPUTS ===== */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.input, .select, .textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  direction: rtl;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.input[type="number"] { direction: ltr; text-align: right; }
.input[type="date"] { direction: ltr; }

.search-bar {
  position: relative;
  margin-bottom: 16px;
}

.search-bar .input {
  padding-right: 42px;
}

.search-bar::before {
  content: "🔍";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.5;
  pointer-events: none;
}

/* Sticky search at bottom of stock screen — appears above bottom nav */
.stock-search-sticky {
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 900px;
  padding: 10px 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
  z-index: 90;
}
body.dark-mode .stock-search-sticky {
  background: #0a0f1e !important;
  border-color: #1e293b !important;
}

/* ===== LIST ITEMS ===== */
.list-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.list-item:active { transform: scale(0.98); background: var(--bg-3); }

.list-item.danger {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.05);
}

.list-item-info { flex: 1; min-width: 0; }

.list-item-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.list-item-value {
  font-weight: 900;
  font-size: 16px;
  color: var(--primary);
  margin-inline-start: 10px;
  white-space: nowrap;
}

.list-item-value.danger { color: var(--danger); }
.list-item-value.success { color: var(--success); }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge-success { background: rgba(16, 185, 129, 0.2); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.badge-primary { background: rgba(59, 130, 246, 0.2); color: var(--primary); }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state .icon {
  font-size: 64px;
  margin-bottom: 14px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 15px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

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

@keyframes posBlinkRed {
  0%, 100% { border-color: #dc2626; box-shadow: 0 0 0 0 rgba(220,38,38,0.5); }
  50% { border-color: #ff5252; box-shadow: 0 0 12px 2px rgba(220,38,38,0.6); }
}
.pos-card-error {
  border: 3px solid #dc2626 !important;
  animation: posBlinkRed 1.1s ease-in-out infinite;
}

/* These modals must appear above full-screen views (z-index:2500) */
#modalProjectExpense.active,
#modalDebtPayment.active,
#modalProjectExpense[style*="flex"],
#modalDebtPayment[style*="flex"] { z-index: 3200 !important; }

/* Confirm dialog must appear ABOVE everything (it's always the topmost action) */
#modalConfirm.active,
#modalConfirm[style*="flex"] { z-index: 4000 !important; }

/* Product picker must appear above card-edit + review sheets */
#posPickProductModal.active,
#posPickProductModal[style*="flex"] { z-index: 3300 !important; }

.modal {
  background: var(--bg-2);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 700px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px 20px;
  border-top: 1px solid var(--border);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

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

.modal-title {
  font-size: 20px;
  font-weight: 900;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-3);
  border: none;
  color: var(--text);
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 900px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  z-index: 99;
}

/* ===== DESKTOP SIDEBAR (hidden on mobile, shown >= 1024px) ===== */
.desktop-sidebar {
  display: none; /* hidden by default — mobile unaffected */
}

@media (min-width: 1024px) {
  /* Show sidebar */
  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    width: 260px;
    height: 100vh;
    background: var(--bg-2);
    border-left: 1px solid var(--border);
    padding: 20px 12px;
    z-index: 200;
    overflow-y: auto;
  }
  .desktop-sidebar .ds-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 18px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
  }
  .ds-logo-icon { font-size: 28px; }
  .ds-logo-text { font-size: 22px; font-weight: 900; color: var(--primary); }
  .ds-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
  .ds-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: none;
    background: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    text-align: right;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
    width: 100%;
  }
  .ds-nav-item:hover { background: var(--bg-3); }
  .ds-nav-item.active {
    background: var(--primary);
    color: #fff;
  }
  .ds-nav-item .ds-icon { font-size: 20px; width: 24px; text-align: center; flex-shrink: 0; }
  .ds-profile-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    background: var(--bg-3);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    margin-top: 12px;
  }
  .ds-profile-btn:hover { background: var(--primary); color: #fff; }
  .ds-profile-btn .ds-icon { font-size: 20px; width: 24px; text-align: center; }

  /* Hide mobile bottom nav on desktop */
  .bottom-nav { display: none !important; }

  /* Scale content UI up on desktop (app uses px units, so zoom gives
     a true desktop feel — enlarges fonts + elements together).
     Applied to content + header only; sidebar keeps its own sizing. */
  .app-header {
    zoom: 1.2;
    display: grid !important;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
  }
  /* Show desktop avatar + theme toggle */
  .header-desktop-left {
    display: flex !important;
    align-items: center;
    gap: 10px;
    justify-self: start;
  }
  .header-theme-toggle { display: flex !important; }
  /* Center the logo */
  .app-header .app-logo {
    justify-self: center;
    text-align: center;
  }
  /* Currency + backup on the right */
  #headerMobileRight { justify-self: end; }
  .screen { zoom: 1.2; }
  .modal { zoom: 1.15; }

  /* Shift main content to make room for sidebar (RTL: sidebar on right) */
  body {
    max-width: none !important;
    margin-right: 280px;
    margin-left: 0;
    padding: 0 !important;
    font-size: 16px;
  }
  .app-header {
    padding: 20px 48px;
    margin-right: 0;
  }
  .app-logo { font-size: 26px !important; }
  .header-currency-select { font-size: 15px !important; padding: 9px 14px !important; }

  /* Content uses full width minus comfortable side padding */
  .screen {
    max-width: 1500px;
    margin: 0 auto;
    padding: 28px 48px 60px;
  }

  /* Larger buttons and inputs */
  .btn { font-size: 15px; padding: 13px 22px; }
  .input, .form-input, select.input { font-size: 15px; padding: 13px 16px; }
  .form-label { font-size: 14px; }
  .search-bar .input { font-size: 16px; }

  /* Cards larger and roomier */
  .card { padding: 20px; }
  .stat-value { font-size: 26px; }
  .stat-label { font-size: 14px; }

  /* Stats grids show more columns on wide screens */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .stats-grid.three { grid-template-columns: repeat(4, 1fr); gap: 16px; }

  /* POS product grid: more columns on desktop */
  .pos-product-grid { grid-template-columns: repeat(5, 1fr); gap: 16px; }

  /* Section titles bigger */
  .section-title, .profile-section-title { font-size: 18px; }

  /* No bottom padding needed since no bottom nav */
  .screen { padding-bottom: 60px; }

  /* Hide the "More" button and its menu on desktop (sidebar replaces it) */
  .more-menu-overlay { display: none !important; }

  /* Center modals on desktop instead of bottom sheet */
  .modal-overlay { align-items: center !important; }
  .modal {
    border-radius: 20px !important;
    max-width: 640px !important;
    max-height: 88vh !important;
    padding: 30px 28px !important;
  }
  .modal-handle { display: none !important; }
  .modal-title { font-size: 22px !important; }
  .modal-close { font-size: 24px !important; }

  /* Enlarge text inside modals on desktop */
  .modal .form-label { font-size: 15px !important; }
  .modal .input,
  .modal select.input,
  .modal textarea.input { font-size: 16px !important; padding: 14px 16px !important; }
  .modal .btn { font-size: 16px !important; padding: 14px 22px !important; }
  .modal label { font-size: 15px !important; }
  .modal p, .modal span:not(.ds-icon), .modal div { font-size: inherit; }
  .modal .form-group { margin-bottom: 18px; }
  /* Bump up small helper texts that use inline 11-13px */
  .modal [style*="font-size:11px"],
  .modal [style*="font-size: 11px"] { font-size: 13px !important; }
  .modal [style*="font-size:12px"],
  .modal [style*="font-size: 12px"] { font-size: 14px !important; }
  .modal [style*="font-size:13px"],
  .modal [style*="font-size: 13px"] { font-size: 15px !important; }
  .modal [style*="font-size:14px"],
  .modal [style*="font-size: 14px"] { font-size: 15px !important; }

  /* Wider sidebar with bigger text */
  .desktop-sidebar { width: 280px; padding: 24px 14px; }
  .ds-logo-text { font-size: 24px; }
  .ds-nav-item { font-size: 15px; padding: 13px 16px; }
  .ds-nav-item .ds-icon { font-size: 22px; }

  /* Hide sidebar when welcome or license screen is showing (full-screen takeover) */
  body.welcome-active .desktop-sidebar,
  body.license-active .desktop-sidebar { display: none !important; }
  body.welcome-active, body.license-active { margin-right: 0 !important; }
}

/* Extra-wide screens (Full HD 1920px and above) */
@media (min-width: 1600px) {
  .screen { max-width: 1600px; padding: 32px 64px 60px; }
  html { font-size: 18px; }
  .pos-product-grid { grid-template-columns: repeat(6, 1fr); }
}



.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  padding: 5px 2px;
  border-radius: 10px;
  transition: all 0.2s;
  flex: 1;
  min-width: 0;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn .nav-icon { font-size: 22px; }

/* Cart alert badge */
.cart-alert-badge {
  position: absolute;
  top: 2px;
  right: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: pulse-badge 1.5s infinite;
}
@keyframes pulse-badge {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* Fixed expenses click hint */
.fixed-hint {
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
  animation: hint-slide 1.6s ease-in-out infinite;
  display: inline-block;
}
@keyframes hint-slide {
  0%, 100% { transform: translateX(0); opacity: 0.6; }
  50% { transform: translateX(-6px); opacity: 1; }
}

/* Center bubble — applies to active screen */
.nav-btn.center {
  position: relative;
}

.nav-btn.center .nav-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -22px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.4);
  font-size: 22px;
}

.nav-btn.center .nav-icon-wrap .nav-icon {
  font-size: 24px;
}

/* More Menu */
.more-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.2);
  z-index: 98;
  display: none;
}
.more-menu {
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom));
  left: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
  z-index: 98;
  animation: slideUp 0.2s ease;
}
.more-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: none;
  background: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}
.more-menu-item:hover, .more-menu-item:active {
  background: var(--bg-3);
}
.more-menu-item.active {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
}

.nav-btn.center .nav-icon { font-size: 26px; }
.nav-btn.center.active .nav-icon-wrap { transform: scale(1.05); }

/* ===== POS / CART ===== */
.pos-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pos-search-results {
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: -8px;
}

.pos-search-result {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pos-search-result:last-child { border-bottom: none; }
.pos-search-result:active { background: var(--bg-3); }

/* POS Product Grid */
.pos-product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}
@media (min-width: 768px) {
  .pos-product-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }
}
.pos-product-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.pos-product-card:active {
  transform: scale(0.95);
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}
.pos-product-card-name {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pos-product-card-price {
  font-size: 15px;
  font-weight: 900;
  color: var(--primary);
}
.pos-product-card-stock {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
}
.pos-product-card-stock.low {
  color: var(--danger);
}
.pos-product-card-cat {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 9px;
  background: var(--bg-3);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--text-dim);
}

.cart-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
}

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

.cart-item-name {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
}

.cart-item-remove {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.qty-input {
  width: 60px;
  text-align: center;
  padding: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-weight: 700;
}

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

.cart-item-price {
  font-size: 12px;
  color: var(--text-dim);
}

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

.cart-summary {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}

.summary-row.total {
  border-top: 1px dashed var(--border);
  margin-top: 8px;
  padding-top: 12px;
  font-size: 18px;
  font-weight: 900;
}

.summary-row.total .val { color: var(--success); font-size: 22px; }

.discount-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}

.discount-input-row .input { flex: 1; }

.discount-type {
  display: flex;
  background: var(--bg-3);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.discount-type button {
  padding: 10px 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.discount-type button.active {
  background: var(--primary);
  color: white;
}

/* ===== TABS ===== */
.tabs {
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== FILTER CHIPS ===== */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 10px;
  -webkit-overflow-scrolling: touch;
}

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

.chip {
  padding: 7px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Sadaqa chip — keep colored text always visible */
.chip.chip-sadaqa {
  background: rgba(5,150,105,0.08);
  border: 1.5px solid rgba(5,150,105,0.4);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  white-space: normal;
  height: auto;
  min-height: 48px;
}
.chip.chip-sadaqa.active {
  background: rgba(5,150,105,0.18) !important;
  border-color: var(--success) !important;
  color: inherit !important;
}
.chip.chip-sadaqa.active > div:first-child { color: #2563eb !important; }
.chip.chip-sadaqa.active > div:nth-child(2) { color: var(--success) !important; }
body.dark-mode .chip.chip-sadaqa { background: rgba(5,150,105,0.15) !important; }
body.dark-mode .chip.chip-sadaqa > div:first-child { color: #60a5fa !important; }
body.dark-mode .chip.chip-sadaqa > div:nth-child(2) { color: #34d399 !important; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-150px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 700;
  z-index: 9999;
  transition: transform 0.3s ease, opacity 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  max-width: 90%;
  text-align: center;
  opacity: 0;
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; pointer-events: auto; }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.danger { border-color: var(--danger); color: var(--danger); }
.toast.warning { border-color: var(--warning); color: var(--warning); }

/* ===== DETAILS VIEW ===== */
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}

.detail-row:last-child { border-bottom: none; }

.detail-label { color: var(--text-dim); }
.detail-value { font-weight: 700; }

/* ===== BAR CHART ===== */
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.bar-label {
  width: 30%;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  flex: 1;
  height: 10px;
  background: var(--bg-3);
  border-radius: 5px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 5px;
  transition: width 0.5s ease;
}

.bar-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  min-width: 40px;
  text-align: left;
}

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 12px;
}

.section-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.section-count {
  font-size: 12px;
  color: var(--text-dim);
}

/* Utility */
.mb-0 { margin-bottom: 0 !important; }
.mt-16 { margin-top: 16px; }
.text-dim { color: var(--text-dim); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }

/* ========== WELCOME SCREEN ========== */
.welcome-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  z-index: 10001;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.welcome-scroll {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 0 40px;
}

.welcome-hero {
  padding: 60px 24px 30px;
  text-align: center;
}
.welcome-logo {
  font-size: 72px;
  margin-bottom: 16px;
  display: inline-block;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(5, 150, 105, 0.1));
  width: 120px;
  height: 120px;
  border-radius: 30px;
  line-height: 120px;
  border: 1px solid var(--border);
}
.welcome-title {
  font-size: 36px;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}
.welcome-tagline {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 12px;
}
.welcome-sub {
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.6;
  max-width: 360px;
  margin: 0 auto;
}

.welcome-cta {
  padding: 0 20px;
  margin-bottom: 40px;
}
.welcome-btn {
  width: 100%;
  padding: 16px 20px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  border: none;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 12px;
  transition: all 0.2s;
}
.welcome-btn-primary {
  background: var(--primary);
  color: white;
}
.welcome-btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}
.welcome-btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.welcome-btn-outline:hover {
  background: rgba(255, 255, 255, 0.9);
}
.welcome-btn-buy {
  background: var(--success);
  color: white;
}
.welcome-btn-buy:hover {
  background: #059669;
}
.welcome-btn-big {
  padding: 18px;
  font-size: 17px;
}

.welcome-section {
  padding: 30px 20px;
}
.welcome-h2 {
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  margin-bottom: 24px;
  color: var(--text);
}

.welcome-features {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (min-width: 768px) {
  .welcome-features {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
  }
}

.welcome-usps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.welcome-currency-box {
  text-align: center;
  padding: 20px;
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: 16px;
}
.welcome-currency-label {
  display: block;
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text);
}
.welcome-currency-select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  appearance: auto;
  cursor: pointer;
}
.welcome-currency-select:focus {
  outline: none;
  border-color: var(--primary);
}
.welcome-currency-error {
  margin-top: 8px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.welcome-btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.welcome-btn-google:hover {
  background: var(--bg-3);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.welcome-btn-google:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.welcome-usp {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  background: var(--bg-2);
  border: 2px solid var(--primary);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(37, 99, 235, 0.08);
}
.welcome-usp-icon {
  font-size: 36px;
  flex-shrink: 0;
}
.welcome-usp-text { flex: 1; }
.welcome-usp-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 6px;
}
.welcome-usp-desc {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
}
.welcome-feature {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 14px;
  text-align: center;
}
.welcome-feature-icon {
  font-size: 32px;
  margin-bottom: 8px;
}
.welcome-feature-title {
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--text);
}
.welcome-feature-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.5;
}

.welcome-whys {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.welcome-why {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.welcome-why-icon {
  font-size: 28px;
  flex-shrink: 0;
}
.welcome-why-text {
  flex: 1;
}
.welcome-why-title {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 2px;
}
.welcome-why-desc {
  font-size: 12px;
  color: var(--text-dim);
}

.welcome-pricing {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.05), rgba(5, 150, 105, 0.05));
  border: 2px solid var(--primary);
  border-radius: 20px;
  padding: 28px 20px;
  text-align: center;
  position: relative;
}
.welcome-price-badge {
  display: inline-block;
  background: var(--success);
  color: white;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  margin-bottom: 12px;
}
.welcome-price-amount {
  font-size: 56px;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}
.welcome-price-amount span {
  font-size: 16px;
  color: var(--text-dim);
  font-weight: 600;
}
.welcome-price-mad {
  color: var(--text-dim);
  margin-bottom: 20px;
  font-size: 13px;
}
.welcome-price-list {
  list-style: none;
  text-align: right;
  margin-bottom: 20px;
  padding: 0;
}
.welcome-price-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.welcome-price-list li::before {
  content: '✓';
  color: var(--success);
  font-weight: 900;
  font-size: 16px;
  flex-shrink: 0;
}
.welcome-price-list li:last-child { border-bottom: none; }
.welcome-payment-info {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.6;
}

.welcome-final {
  text-align: center;
}
.welcome-final-text {
  color: var(--text-dim);
  margin-bottom: 20px;
  font-size: 14px;
}

.welcome-footer {
  text-align: center;
  padding: 30px 20px 0;
  border-top: 1px solid var(--border);
  margin: 30px 20px 0;
  color: var(--text-dim);
  font-size: 12px;
}
.welcome-footer a {
  color: var(--primary);
  text-decoration: none;
}

@media (max-width: 360px) {
  .welcome-features {
    grid-template-columns: 1fr;
  }
  .welcome-title { font-size: 30px; }
  .welcome-tagline { font-size: 18px; }
  .welcome-price-amount { font-size: 48px; }
}

/* ===== Welcome: dynamic + responsive (tablet / desktop) ===== */
/* Animated ambient background */
.welcome-overlay::before,
.welcome-overlay::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
}
.welcome-overlay::before {
  width: 380px; height: 380px;
  background: radial-gradient(circle, rgba(37,99,235,0.28), transparent 70%);
  top: -90px; inset-inline-start: -110px;
  animation: wm-float1 16s ease-in-out infinite;
}
.welcome-overlay::after {
  width: 340px; height: 340px;
  background: radial-gradient(circle, rgba(5,150,105,0.24), transparent 70%);
  bottom: 60px; inset-inline-end: -90px;
  animation: wm-float2 20s ease-in-out infinite;
}
body.dark-mode .welcome-overlay::before { background: radial-gradient(circle, rgba(59,130,246,0.30), transparent 70%); }
body.dark-mode .welcome-overlay::after { background: radial-gradient(circle, rgba(16,185,129,0.26), transparent 70%); }
.welcome-scroll { position: relative; z-index: 1; }
@keyframes wm-float1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(46px,34px); } }
@keyframes wm-float2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-34px,-44px); } }

/* Hero entrance */
.welcome-hero-text > * { animation: wm-rise 0.7s ease both; }
.welcome-hero-text .welcome-logo { animation-delay: 0.05s; }
.welcome-hero-text .welcome-title { animation-delay: 0.12s; }
.welcome-hero-text .welcome-tagline { animation-delay: 0.20s; }
.welcome-hero-text .welcome-sub { animation-delay: 0.28s; }
.welcome-hero .wm-showcase { animation: wm-rise 0.8s 0.22s ease both; }
@keyframes wm-rise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }

/* Scroll reveal (class added by JS, so no-JS still shows everything) */
.wm-reveal { opacity: 0; transform: translateY(28px); transition: opacity 0.6s ease, transform 0.6s ease; }
.wm-reveal.in-view { opacity: 1; transform: none; }
.welcome-features .welcome-feature:nth-child(2) { transition-delay: 0.05s; }
.welcome-features .welcome-feature:nth-child(3) { transition-delay: 0.10s; }
.welcome-features .welcome-feature:nth-child(4) { transition-delay: 0.15s; }
.welcome-usps .welcome-usp:nth-child(2) { transition-delay: 0.08s; }
.welcome-usps .welcome-usp:nth-child(3) { transition-delay: 0.16s; }

/* Interactive hover lift */
.welcome-feature, .welcome-usp, .welcome-why, .welcome-btn-google { transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease; }
@media (hover: hover) {
  .welcome-feature:hover { transform: translateY(-5px); box-shadow: 0 12px 26px rgba(0,0,0,0.12); border-color: var(--primary); }
  .welcome-usp:hover { transform: translateY(-5px); box-shadow: 0 14px 30px rgba(37,99,235,0.20); }
  .welcome-why:hover { transform: translateY(-4px); box-shadow: 0 10px 22px rgba(0,0,0,0.10); border-color: var(--primary); }
}

/* Tablet+ : larger type, wider container, multi-column USPs */
@media (min-width: 768px) {
  .welcome-scroll { max-width: 980px; }
  .welcome-hero { padding: 70px 32px 36px; }
  .welcome-logo { width: 140px; height: 140px; line-height: 140px; font-size: 84px; }
  .welcome-title { font-size: 50px; }
  .welcome-tagline { font-size: 30px; }
  .welcome-sub { font-size: 18px; max-width: 520px; }
  .welcome-h2 { font-size: 30px; margin-bottom: 30px; }
  .welcome-section { padding: 44px 24px; }
  .welcome-usps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; align-items: stretch; }
  .welcome-usp { flex-direction: column; text-align: center; }
  .welcome-usp-icon { font-size: 44px; }
  .welcome-usp-title { font-size: 19px; }
  .welcome-usp-desc { font-size: 15px; }
  .welcome-feature { padding: 24px 18px; }
  .welcome-feature-icon { font-size: 40px; margin-bottom: 12px; }
  .welcome-feature-title { font-size: 16px; }
  .welcome-feature-desc { font-size: 13px; }
  .welcome-why-title { font-size: 17px; }
  .welcome-why-desc { font-size: 14px; }
  .welcome-why-icon { font-size: 34px; }
  .wm-phone { width: 230px; height: 364px; }
  .welcome-currency-box, .welcome-cta { max-width: 520px; margin-inline: auto; }
}

/* Desktop : two-column hero, even larger type, 4-col features */
@media (min-width: 1024px) {
  .welcome-scroll { max-width: 1160px; }
  .welcome-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 56px;
    text-align: start;
    padding: 84px 40px 48px;
  }
  .welcome-hero-text { flex: 1; max-width: 520px; }
  .welcome-hero .wm-showcase { margin-top: 0; flex-shrink: 0; }
  .welcome-logo { margin-bottom: 20px; }
  .welcome-title { font-size: 60px; }
  .welcome-tagline { font-size: 36px; }
  .welcome-sub { font-size: 20px; max-width: none; margin-inline: 0; }
  .welcome-h2 { font-size: 34px; }
  .welcome-features { grid-template-columns: repeat(4, 1fr); }
  .wm-phone { width: 250px; height: 400px; }
  .welcome-pricing { max-width: 600px; margin-inline: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .welcome-overlay::before, .welcome-overlay::after,
  .welcome-hero-text > *, .welcome-hero .wm-showcase { animation: none !important; }
  .wm-reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* ========== LICENSE SCREEN ========== */
.license-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}
.license-container {
  max-width: 520px;
  width: 100%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px 24px;
  text-align: center;
  backdrop-filter: blur(10px);
}
.license-logo {
  font-size: 56px;
  margin-bottom: 12px;
}
.license-title {
  font-size: 24px;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 4px;
}
.license-subtitle {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 24px;
}
.license-trial-badge {
  display: inline-block;
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}
.license-trial-days {
  font-size: 28px;
  font-weight: 900;
  color: var(--success);
}
.license-expired-icon {
  font-size: 48px;
  margin-bottom: 8px;
}
.license-expired-text {
  font-size: 18px;
  font-weight: 800;
  color: var(--danger);
  margin-bottom: 4px;
}
.license-expired-sub {
  font-size: 13px;
  color: var(--text-dim);
}
.license-form {
  margin-bottom: 20px;
}
.license-label {
  display: block;
  text-align: right;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-weight: 600;
}
.license-input {
  width: 100%;
  padding: 14px 16px;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  color: #000000;
  font-size: 15px;
  font-family: 'Courier New', monospace;
  text-align: center;
  letter-spacing: 1px;
  margin-bottom: 12px;
  direction: ltr;
}
.license-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #ffffff;
}
body.dark-mode .license-input {
  background: #0f172a;
  color: #f1f5f9;
  border-color: #334155;
}
.license-btn {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: inherit;
  margin-bottom: 8px;
}
.license-btn-primary {
  background: var(--primary);
  color: white;
}
.license-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.license-btn-secondary {
  background: var(--success);
  color: white;
}
.license-btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.license-divider {
  color: var(--text-dim);
  font-size: 12px;
  margin: 16px 0;
  position: relative;
}
.license-divider::before,
.license-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}
.license-divider::before { right: 0; }
.license-divider::after { left: 0; }
.license-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.license-support {
  font-size: 12px;
  color: var(--text-dim);
}
.license-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  color: var(--danger);
  font-size: 13px;
}
.lang-pill.active { background: var(--primary) !important; color: #fff !important; border-color: var(--primary) !important; }

/* ===== LTR overrides for non-Arabic languages ===== */
html[dir="ltr"] input,
html[dir="ltr"] textarea,
html[dir="ltr"] select,
html[dir="ltr"] .input {
  direction: ltr !important;
  text-align: left !important;
}
html[dir="ltr"] table,
html[dir="ltr"] th,
html[dir="ltr"] td {
  direction: ltr !important;
  text-align: left !important;
}
html[dir="ltr"] .stk-table th,
html[dir="ltr"] .stk-table td {
  text-align: left !important;
}

/* ===== Welcome: language selector (top) ===== */
.welcome-lang-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 14px 16px 4px;
  position: sticky;
  top: 0;
  z-index: 5;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.welcome-lang-pill {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.15s ease;
}
.welcome-lang-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ===== Welcome: animated app showcase ===== */
.wm-showcase {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 18px;
}
.wm-phone {
  position: relative;
  width: 200px;
  height: 320px;
  border-radius: 28px;
  background: #0f172a;
  border: 6px solid #1e293b;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
  overflow: hidden;
}
.wm-notch {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 78px; height: 16px;
  background: #1e293b;
  border-radius: 0 0 12px 12px;
  z-index: 3;
}
.wm-screen {
  position: absolute;
  inset: 0;
  padding: 26px 12px 12px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  animation: wm-cycle 16s infinite;
}
.wm-screen-1 { animation-delay: 0s; }
.wm-screen-2 { animation-delay: 4s; }
.wm-screen-3 { animation-delay: 8s; }
.wm-screen-4 { animation-delay: 12s; }
@keyframes wm-cycle {
  0%   { opacity: 0; transform: scale(0.97); }
  3%   { opacity: 1; transform: scale(1); }
  22%  { opacity: 1; transform: scale(1); }
  25%  { opacity: 0; transform: scale(0.97); }
  100% { opacity: 0; }
}
.wm-topbar {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 800; color: #0f172a;
  padding-bottom: 4px; border-bottom: 2px solid #e2e8f0;
}
.wm-caption { font-size: 12px; }
/* POS grid */
.wm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.wm-tile { height: 34px; border-radius: 8px; background: #e2e8f0; }
.wm-tile-on { background: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.3); }
.wm-cartbar {
  margin-top: auto; display: flex; justify-content: space-between; align-items: center;
  background: #0f172a; border-radius: 10px; padding: 8px 10px;
}
.wm-money { color: #fff; font-weight: 800; font-size: 13px; }
.wm-pay { color: #fff; background: #10b981; border-radius: 6px; padding: 4px 8px; font-size: 11px; font-weight: 800; }
/* Stock / debts rows */
.wm-row { display: flex; align-items: center; gap: 8px; }
.wm-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.wm-ok { background: #10b981; }
.wm-low { background: #ef4444; }
.wm-bar { height: 10px; border-radius: 5px; background: #cbd5e1; }
.wm-bar.w35 { width: 35%; } .wm-bar.w50 { width: 50%; } .wm-bar.w60 { width: 60%; }
.wm-bar.w70 { width: 70%; } .wm-bar.w80 { width: 80%; } .wm-bar.w85 { width: 85%; } .wm-bar.w90 { width: 90%; }
.wm-qty { margin-inline-start: auto; font-size: 12px; font-weight: 800; color: #0f172a; }
.wm-due { margin-inline-start: auto; font-size: 11px; font-weight: 700; color: #64748b; }
.wm-soon { color: #ef4444; }
.wm-avatar {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: #2563eb; color: #fff; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
/* Reports */
.wm-kpi {
  display: flex; flex-direction: column; gap: 2px;
  background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 10px; padding: 8px 10px;
}
.wm-kpi-lbl { font-size: 11px; color: #047857; font-weight: 700; }
.wm-kpi-val { font-size: 20px; font-weight: 900; color: #059669; }
.wm-chart { display: flex; align-items: flex-end; gap: 6px; height: 90px; margin-top: 4px; }
.wm-chart i { flex: 1; background: linear-gradient(#60a5fa, #2563eb); border-radius: 4px 4px 0 0; }
/* Progress dots */
.wm-dots { display: flex; gap: 6px; margin-top: 12px; }
.wm-dot-i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border);
  animation: wm-dotcycle 16s infinite;
}
.wm-dot-2 { animation-delay: 4s; }
.wm-dot-3 { animation-delay: 8s; }
.wm-dot-4 { animation-delay: 12s; }
@keyframes wm-dotcycle {
  0%, 25%, 100% { background: var(--border); transform: scale(1); }
  3%, 22% { background: var(--primary); transform: scale(1.3); }
}
@media (prefers-reduced-motion: reduce) {
  .wm-screen, .wm-dot-i { animation: none; }
  .wm-screen-1 { opacity: 1; }
}
