/* =============================================
   نظام الكاشير برو - التصميم الاحترافي
   لوحة ألوان: رمادي داكن + أزرق هادئ
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-primary:    #0F1117;
  --bg-secondary:  #161B27;
  --bg-card:       #1C2333;
  --bg-hover:      #232B3E;
  --border:        #2A3349;
  --border-light:  #344060;

  --text-primary:  #E8EDF5;
  --text-secondary:#8A97B0;
  --text-muted:    #5A6785;

  --accent:        #3B82F6;
  --accent-hover:  #2563EB;
  --accent-light:  rgba(59,130,246,0.12);
  --accent-glow:   rgba(59,130,246,0.25);

  --success:       #10B981;
  --success-light: rgba(16,185,129,0.12);
  --warning:       #F59E0B;
  --warning-light: rgba(245,158,11,0.12);
  --danger:        #EF4444;
  --danger-light:  rgba(239,68,68,0.12);
  --purple:        #8B5CF6;
  --purple-light:  rgba(139,92,246,0.12);

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     16px;
  --radius-xl:     24px;

  --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);
  --shadow:        0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.5);
  --shadow-accent: 0 4px 20px rgba(59,130,246,0.3);

  --sidebar-w:     260px;
  --topbar-h:      64px;
  --transition:    all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin:0; padding:0; box-sizing:border-box; }

html { font-size: 16px; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Layout ─── */
.layout { 
  display: flex; 
  min-height: 100vh; 
  position: relative; 
  width: 100%; 
  overflow-x: hidden; 
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  z-index: 100;
  transition: right 0.3s ease-in-out;
  overflow-y: auto;
  transform: none !important; 
}

/* Overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-accent);
  flex-shrink: 0;
}

.sidebar-logo-text h2 {
  font-size: 15px; font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logo-text span {
  font-size: 11px; color: var(--text-muted);
  white-space: nowrap;
}

/* Close button for mobile */
.sidebar-close {
  display: none;
  margin-right: auto;
  width: 32px; height: 32px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  align-items: center; justify-content: center;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section-title {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  color: var(--text-muted); text-transform: uppercase;
  padding: 0 12px 8px;
  margin-top: 8px;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: var(--transition);
  margin-bottom: 2px;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid rgba(59,130,246,0.2);
}
.nav-item.active .nav-icon { color: var(--accent); }

.nav-icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.nav-badge {
  margin-right: auto;
  background: var(--accent);
  color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ─── Hamburger button (mobile only) ─── */
.sidebar-toggle {
  display: none;
  width: 38px; height: 38px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* ─── Main Content ─── */
.main-content {
  margin-right: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── Topbar ─── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
  gap: 16px;
}
.topbar-title { font-size: 18px; font-weight: 700; flex: 1; white-space: nowrap; }
.topbar-subtitle { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* ─── Page Content ─── */
.page-content { padding: 28px; flex: 1; }

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}
.card:hover { border-color: var(--border-light); }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.card-title { font-size: 16px; font-weight: 700; }

/* ─── Stats Cards ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  transition: var(--transition);
  cursor: default;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-light);
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: var(--accent-light); color: var(--accent); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.purple { background: var(--purple-light); color: var(--purple); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 24px; font-weight: 800; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  font-family: 'Cairo', sans-serif;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-accent); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; }

.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-warning:hover { background: #D97706; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }

.btn-outline-primary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-outline-primary:hover { background: var(--accent-light); }

/* ─── Forms ─── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 7px;
}
.form-label .required { color: var(--danger); margin-right: 3px; }

.form-control {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px; font-family: 'Cairo', sans-serif;
  color: var(--text-primary);
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--text-muted); }

select.form-control {
  cursor: pointer;
  -webkit-appearance: none;
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ─── Table ─── */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
}
thead th {
  background: var(--bg-primary);
  padding: 12px 16px;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

.td-name { font-weight: 600; }
.td-code { font-family: monospace; font-size: 12px; color: var(--text-muted); }

/* ─── Badges ─── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-blue    { background: var(--accent-light);  color: var(--accent); }

/* ─── Color Dot ─── */
.color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 6px;
}

/* ─── Modal ─── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  padding: 16px;
}
.modal-overlay.show { display: flex; animation: fadeIn 0.2s ease; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 90%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  background: var(--bg-hover);
  border: none; border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--danger-light); color: var(--danger); }

/* ─── Alert ─── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-light); color: var(--success); border-color: rgba(16,185,129,0.2); }
.alert-danger   { background: var(--danger-light);  color: var(--danger);  border-color: rgba(239,68,68,0.2); }
.alert-warning  { background: var(--warning-light); color: var(--warning); border-color: rgba(245,158,11,0.2); }

/* ─── Search Bar ─── */
.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 320px;
}
.search-icon {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px;
  pointer-events: none;
}
.search-input {
  width: 100%;
  padding: 9px 36px 9px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Cairo', sans-serif;
  font-size: 13px; color: var(--text-primary);
  outline: none; transition: var(--transition);
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-input::placeholder { color: var(--text-muted); }

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.empty-text { font-size: 13px; }

/* ─── Color Picker ─── */
.color-options {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.color-option {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
}
.color-option:hover, .color-option.selected {
  border-color: white;
  transform: scale(1.15);
}

/* ─── Tooltips / Actions ─── */
.action-btns { display: flex; gap: 6px; }

/* ─── Product Image Placeholder ─── */
.product-thumb {
  width: 40px; height: 40px;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 16px;
}

/* ─── POS Layout ─── */
.pos-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  height: calc(100vh - var(--topbar-h) - 44px);
}

.pos-products {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.pos-products-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 12px; align-items: center;
  flex-shrink: 0;
}

.pos-categories {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; gap: 8px; overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}
.pos-categories::-webkit-scrollbar { height: 3px; }

.cat-chip {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: var(--transition);
  background: transparent;
  font-family: 'Cairo', sans-serif;
}
.cat-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.cat-chip.active { background: var(--accent); color: white; border-color: var(--accent); }

.pos-products-grid {
  flex: 1; overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  padding: 16px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
}

.product-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}
.product-card:hover {
  border-color: var(--accent);
  background: var(--bg-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.product-card:active { transform: scale(0.97); }
.product-card-icon {
  font-size: 28px;
  margin-bottom: 8px;
}
.product-card-name {
  font-size: 12px; font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.product-card-price {
  font-size: 13px; font-weight: 700;
  color: var(--accent);
}

/* ─── Cart ─── */
.pos-cart {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
.cart-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 700;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.cart-items { flex: 1; overflow-y: auto; padding: 12px; -webkit-overflow-scrolling: touch; min-height: 150px; }
.cart-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { font-size: 12px; color: var(--text-muted); }
.cart-item-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.qty-btn {
  width: 26px; height: 26px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  font-family: 'Cairo', sans-serif;
}
.qty-btn:hover { background: var(--accent); border-color: var(--accent); }
.qty-num { font-size: 14px; font-weight: 700; min-width: 24px; text-align: center; }

.cart-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.cart-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  font-size: 13px; color: var(--text-secondary);
}
.cart-total-row.grand {
  font-size: 18px; font-weight: 800; color: var(--text-primary);
  padding-top: 12px;
  margin-top: 6px;
  border-top: 1px solid var(--border);
}
.cart-total-row.grand .val { color: var(--accent); }

/* ─── Animations ─── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ─── Divider ─── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ─── Checkbox Toggle ─── */
.toggle {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
}
.toggle input { display: none; }
.toggle-track {
  width: 42px; height: 24px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  position: relative;
  transition: var(--transition);
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  width: 16px; height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  position: absolute; right: 3px; top: 3px;
  transition: var(--transition);
}
.toggle input:checked ~ .toggle-track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked ~ .toggle-track::after { right: calc(100% - 19px); background: white; }
.toggle-label { font-size: 13px; font-weight: 500; }

/* ─── Pagination ─── */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.page-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer; font-size: 13px; font-weight: 600;
  transition: var(--transition);
  text-decoration: none;
}
.page-btn:hover, .page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* ─── Utility ─── */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); font-size: 12px; }
.fw-bold     { font-weight: 700; }
.mt-4        { margin-top: 16px; }
.gap-2       { gap: 8px; }
.d-flex      { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100       { width: 100%; }

/* Login page full height */
body.login-page { height: 100vh; overflow: hidden; }

/* ─── RTL Icon Fix — شامل ─── */
[dir="rtl"] [data-feather="arrow-left"],
[dir="rtl"] [data-feather="arrow-right"],
[dir="rtl"] [data-feather="log-in"],
[dir="rtl"] [data-feather="log-out"],
[dir="rtl"] [data-feather="chevron-left"],
[dir="rtl"] [data-feather="chevron-right"],
[dir="rtl"] [data-feather="corner-up-left"],
[dir="rtl"] [data-feather="corner-up-right"],
[dir="rtl"] [data-feather="rotate-ccw"],
[dir="rtl"] [data-feather="rotate-cw"] {
  transform: scaleX(-1);
}

/* ─── Touch improvements ─── */
@media (hover: none) {
  .stat-card:hover { transform: none; box-shadow: none; }
  .product-card:hover { transform: none; box-shadow: none; }
  .nav-item:hover { background: transparent; }
  .nav-item:active { background: var(--bg-hover); }
  .product-card:active { background: var(--bg-hover); border-color: var(--accent); }
}

/* ═══════════════════════════════════════════════
   RESPONSIVE — Tablet: 768px - 1024px
   ═══════════════════════════════════════════════ */
@media (max-width: 1024px) {

  :root {
    --sidebar-w: 230px;
  }

  .stats-grid[style*="repeat(4,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .stats-grid[style*="repeat(3,1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }

  /* Dashboard chart + top products: stack vertically */
  .page-content > div[style*="grid-template-columns:1fr 340px"] {
    grid-template-columns: 1fr !important;
  }

  .pos-layout {
    grid-template-columns: 1fr 320px;
  }

  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .sidebar {
    right: calc(-1 * var(--sidebar-w)) !important;
    transform: none !important;
    box-shadow: none;
  }
  .sidebar.open {
    right: 0 !important;
    box-shadow: var(--shadow-lg);
  }
  .sidebar-close { display: flex; }
  .sidebar-toggle { display: flex; }
  .main-content {
    margin-right: 0 !important;
    width: 100% !important;
  }
}


/* ═══════════════════════════════════════════════
   RESPONSIVE — Mobile: max 768px
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {

  :root {
    --topbar-h: 56px;
    --sidebar-w: 260px;
  }

 /* ── Sidebar: RTL Fix ── */
  .sidebar {
    right: -300px !important;
    box-shadow: none;
  }
  .sidebar.open {
    right: 0 !important;
    box-shadow: var(--shadow-lg);
  }

  .sidebar-close { display: flex; }

  /* ── Main: full width ── */
  .main-content {
    margin-right: 0 !important;
    width: 100% !important;
  }

  /* ── Topbar ── */
  .topbar {
    padding: 0 16px;
    gap: 10px;
  }
  .topbar-title { font-size: 15px; }
  .topbar-subtitle { display: none; }

  .sidebar-toggle { display: flex; }

/* ── Page content ── */
  .page-content { 
    padding: 16px; 
    max-width: 100%;
    overflow-x: hidden;
  }

  /* ── Stats grids: 2 col ── */
  .stats-grid,
  .stats-grid[style*="repeat(4,1fr)"],
  .stats-grid[style*="repeat(3,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card { padding: 14px 12px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 11px; }

  /* ── Dashboard chart + top products: full width ── */
  .page-content > div[style*="grid-template-columns"] {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 16px !important;
  }

  /* ── Cards ── */
  .card { 
    padding: 16px; 
    border-radius: var(--radius);
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
  }
  canvas { max-width: 100% !important; }
  .card-header { margin-bottom: 14px; padding-bottom: 12px; }
  .card-title { font-size: 14px; }

  /* ── Forms ── */
  .form-row,
  .form-row-3 { grid-template-columns: 1fr; }

  /* ── POS: stacked layout ── */
  .pos-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - var(--topbar-h));
  }

  .page-content[style*="height:calc"] {
    height: auto !important;
    overflow: visible !important;
    padding: 12px !important;
  }

  .pos-products {
    height: 70vh;
    min-height: 400px;
    border-radius: var(--radius);
  }

  .pos-products-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    padding: 10px;
  }

  .product-card { padding: 12px 8px; }
  .product-card-icon { font-size: 22px; margin-bottom: 6px; }
  .product-card-name { font-size: 11px; }
  .product-card-price { font-size: 12px; }

  .pos-cart {
    height: auto;
    border-radius: var(--radius);
  }

  .cart-items {
    max-height: 220px;
  }

  .cart-footer { padding: 12px; }
  .cart-total-row { font-size: 12px; }
  .cart-total-row.grand { font-size: 16px; }

  /* ── Topbar actions in POS ── */
  .topbar-actions select.form-control { width: 120px !important; }

  /* ── Modal: full-ish width ── */
  .modal {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    max-height: 85vh;
    padding: 20px;
  }
  .modal-overlay.show { align-items: flex-end; padding: 0; }

  /* ── Tables ── */
  .table-wrapper { 
    margin: 0 -16px; 
    padding: 0 16px; 
    width: calc(100% + 32px);
    border-radius: 0;
  }
  table { min-width: 640px; }
  thead th { padding: 10px 12px; font-size: 10px; }
  tbody td { padding: 10px 12px; font-size: 13px; white-space: nowrap; }

  /* ── POS categories scroll ── */
  .pos-categories { padding: 10px 12px; gap: 6px; }
  .cat-chip { padding: 5px 12px; font-size: 11px; }

  .pos-products-header { padding: 12px 14px; }
  .search-wrapper { max-width: 100% !important; }

  .cart-header { padding: 12px 16px; font-size: 14px; }

  /* ── Buttons: smaller on mobile ── */
  .btn-lg { padding: 10px 20px; font-size: 14px; }
}


/* ═══════════════════════════════════════════════
   RESPONSIVE — Small mobile: max 480px
   ═══════════════════════════════════════════════ */
@media (max-width: 480px) {

  .stats-grid,
  .stats-grid[style*="repeat(4,1fr)"],
  .stats-grid[style*="repeat(3,1fr)"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }

  .stat-value { font-size: 16px; }
  .stat-icon { width: 36px; height: 36px; font-size: 16px; }

  .pos-products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px;
    padding: 8px;
  }

  .product-card { padding: 10px 6px; }
  .product-card-icon { font-size: 20px; }

  .topbar-title { font-size: 14px; }

  .page-content { padding: 10px; }

  .pos-layout { gap: 12px; }

  .stat-card { gap: 8px; }

  .modal { padding: 16px; }
  .modal-title { font-size: 16px; }
}

@media (min-width: 1025px) {
  .sidebar-overlay { display: none !important; }
  .sidebar-overlay.show { display: none !important; }
  .sidebar { right: 0 !important; }
  .main-content { 
    margin-right: var(--sidebar-w) !important; 
    width: calc(100% - var(--sidebar-w)) !important; 
  }
}


.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-bottom: 20px;
}

.mobile-cards {
  display: none;
}

.mobile-card-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.mobile-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.mobile-card-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.mobile-card-footer {
  display: flex;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .desktop-table {
    display: none;
  }
  .mobile-cards {
    display: block;
  }
}


@media (min-width: 1025px) {
  .topbar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 250px !important;
    width: calc(100% - 250px) !important;
    height: 70px !important;
    box-sizing: border-box !important;
    z-index: 990 !important;
  }
}

@media (max-width: 1024px) {
  .topbar {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 70px !important;
    box-sizing: border-box !important;
    z-index: 990 !important;
  }
  
  .sidebar {
    z-index: 9999 !important;
  }
  
  .sidebar-overlay {
    z-index: 9998 !important;
  }
}

.sidebar-logo {
  height: 70px !important;
  box-sizing: border-box !important;
}

.page-content {
  margin-top: 70px !important;
}