@font-face{font-family:'Tajawal';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/tajawal-arabic-400-normal.woff2') format('woff2');unicode-range:U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F}
@font-face{font-family:'Tajawal';font-style:normal;font-weight:400;font-display:swap;src:url('/fonts/tajawal-latin-400-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215}
@font-face{font-family:'Tajawal';font-style:normal;font-weight:500;font-display:swap;src:url('/fonts/tajawal-arabic-500-normal.woff2') format('woff2');unicode-range:U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F}
@font-face{font-family:'Tajawal';font-style:normal;font-weight:500;font-display:swap;src:url('/fonts/tajawal-latin-500-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215}
@font-face{font-family:'Tajawal';font-style:normal;font-weight:700;font-display:swap;src:url('/fonts/tajawal-arabic-700-normal.woff2') format('woff2');unicode-range:U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F}
@font-face{font-family:'Tajawal';font-style:normal;font-weight:700;font-display:swap;src:url('/fonts/tajawal-latin-700-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215}
@font-face{font-family:'Tajawal';font-style:normal;font-weight:900;font-display:swap;src:url('/fonts/tajawal-arabic-900-normal.woff2') format('woff2');unicode-range:U+0600-06FF,U+0750-077F,U+08A0-08FF,U+FB50-FDFF,U+FE70-FEFF,U+200C-200F}
@font-face{font-family:'Tajawal';font-style:normal;font-weight:900;font-display:swap;src:url('/fonts/tajawal-latin-900-normal.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215}

:root {
  --primary:   #1e40af;
  --primary-l: #3b82f6;
  --primary-d: #1d3a9e;
  --tint:      #eff6ff;
  --tint2:     #dbeafe;
  --tint-bd:   #bfdbfe;
  --success:   #059669;
  --danger:    #dc2626;
  --warning:   #d97706;
  --info:      #0891b2;
  --bg:        #f1f5f9;
  --white:     #ffffff;
  --border:    #e2e8f0;
  --text:      #1e293b;
  --text-sub:  #64748b;
  --nav-bg:    #1e293b;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1);
}

* { box-sizing:border-box; margin:0; padding:0; }
body { font-family:'Tajawal',sans-serif; background:var(--bg); color:var(--text); direction:rtl; font-size:14px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width:5px; height:5px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:#cbd5e1; border-radius:99px; }

/* ── Navbar ── */
.navbar {
  background: var(--nav-bg);
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  gap: 4px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  margin-left: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.navbar-brand .logo {
  width: 34px; height: 34px;
  background: var(--primary-l);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 900; color: #fff;
}
.nav-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  min-width: 0;
}
.nav-tabs::-webkit-scrollbar { display:none; }
.nav-tab {
  padding: 6px 10px;
  border-radius: 7px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,.65);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-tab:hover  { background: rgba(255,255,255,.1); color: #fff; }
.nav-tab.active { background: var(--primary-l); color: #fff; }
.nav-right {
  display: flex; align-items: center; gap: 8px; margin-right: auto; flex-shrink: 0;
}
.nav-user {
  color: rgba(255,255,255,.8);
  font-size: 13px;
  font-weight: 700;
}
.btn-nav {
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,.2);
  background: transparent;
  color: rgba(255,255,255,.8);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.btn-nav:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Page ── */
.page { display: none; padding: 20px; max-width: 1400px; margin: 0 auto; }
.page.active { display: block; }

/* ── Card ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.card-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  text-align: center;
}
.kpi.blue   { background: var(--primary); color: #fff; border-color: var(--primary); }
.kpi.green  { background: #059669; color: #fff; border-color: #059669; }
.kpi.red    { background: #dc2626; color: #fff; border-color: #dc2626; }
.kpi.amber  { background: #d97706; color: #fff; border-color: #d97706; }
.kpi-label  { font-size: 11px; opacity: .8; margin-bottom: 6px; font-weight: 600; }
.kpi-value  { font-size: 24px; font-weight: 900; }
.kpi-sub    { font-size: 11px; opacity: .7; margin-top: 2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #047857; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; border: 1.5px solid var(--border); background: var(--white); font-family: inherit; font-weight: 700; cursor: pointer; transition: all .15s; color: var(--text); }
.btn-sm:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm.danger { border-color: var(--danger); color: var(--danger); }
.btn-sm.success { border-color: var(--success); color: var(--success); background: #f0fdf4; }
.btn-sm.primary { border-color: var(--primary); color: var(--primary); }

/* ── Form ── */
.form-grid { display: grid; gap: 14px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group label { display: block; font-size: 12px; font-weight: 700; color: var(--text-sub); margin-bottom: 5px; }
.inp {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color .15s;
}
.inp:focus { border-color: var(--primary); }
.inp::placeholder { color: #94a3b8; }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: #f8fafc; }
th { padding: 11px 14px; text-align: right; font-weight: 800; color: var(--text-sub); font-size: 11px; border-bottom: 1.5px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid #f8fafc; vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
.empty-td { text-align: center; padding: 40px; color: #94a3b8; }

/* ── Badge ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.badge-blue   { background: var(--tint2); color: var(--primary); }
.badge-green  { background: #d1fae5; color: #059669; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-amber  { background: #fef3c7; color: #d97706; }
.badge-gray   { background: #f1f5f9; color: #64748b; }

/* ── Search bar ── */
.search-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.search-wrap { position: relative; }
.search-wrap .inp { padding-right: 36px; }
.search-wrap .search-icon { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 14px; pointer-events: none; }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal.modal-wide { max-width: 980px; }
.modal.modal-wide .modal-footer { flex-wrap: wrap; align-items: center; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 800; }
.modal-close { width: 30px; height: 30px; border: none; background: #f1f5f9; border-radius: 7px; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Toast ── */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  box-shadow: var(--shadow-lg);
  animation: toastIn .25s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.info    { background: var(--info); }
@keyframes toastIn { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* ── POS Layout ── */
.pos-layout { display: grid; grid-template-columns: 1fr 320px; height: calc(100vh - 48px); gap: 0; }
.pos-products { background: #f8fafc; display: flex; flex-direction: column; overflow: hidden; border-left: 1px solid var(--border); }
.pos-invoice  { background: var(--white); display: flex; flex-direction: column; overflow: hidden; }
.pos-products-header { padding: 12px; background: var(--white); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.pos-grid { flex: 1; overflow-y: auto; padding: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; align-content: start; }
.pos-card {
  background: var(--white);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  position: relative;
}
.pos-card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow); }
.pos-card.in-cart { border-color: var(--primary); background: var(--tint); }
.pos-card.out-stock { opacity: .5; cursor: not-allowed; }
.pos-card-name { font-size: 12px; font-weight: 700; color: var(--text); margin-bottom: 4px; line-height: 1.3; }
.pos-card-price { font-size: 15px; font-weight: 900; color: var(--success); }
.pos-card-stock { font-size: 10px; padding: 2px 6px; border-radius: 99px; display: inline-block; margin-top: 4px; }
.pos-cart-badge { position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; background: var(--primary); color: #fff; border-radius: 50%; font-size: 11px; font-weight: 900; display: flex; align-items: center; justify-content: center; }

/* ── POS Invoice ── */
.pos-inv-header { background: linear-gradient(135deg,var(--nav-bg),var(--primary)); padding: 8px 12px; flex-shrink: 0; }
.pos-inv-items { flex: 1; overflow-y: auto; padding: 6px 10px; background: #f8fafc; }
.pos-item-row { display: flex; align-items: center; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.pos-item-info { flex: 1; }
.pos-item-name  { font-size: 12px; font-weight: 700; }
.pos-item-price { font-size: 11px; color: var(--text-sub); }
.pos-qty-ctrl { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.pos-qty-btn { width: 26px; height: 26px; border: 1.5px solid var(--border); background: var(--white); border-radius: 7px; font-size: 14px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.pos-qty { font-size: 14px; font-weight: 800; min-width: 24px; text-align: center; }
.pos-remove { width: 26px; height: 26px; border: none; background: #fef2f2; color: var(--danger); border-radius: 7px; cursor: pointer; font-size: 12px; }
.pos-inv-footer { flex-shrink: 0; background: var(--white); padding: 6px 10px; border-top: 1px solid var(--border); }
.pos-footer-totals { display: flex; gap: 16px; align-items: center; flex: 1; }
.pos-footer-actions { display: flex; gap: 6px; flex-shrink: 0; }
.pos-total-row { display: flex; justify-content: space-between; font-size: 12px; padding: 2px 0; }
.pos-grand { font-size: 18px; font-weight: 900; color: var(--success); }

/* ── Login ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,var(--nav-bg) 0%,var(--primary) 100%); }
.login-card { background: var(--white); border-radius: 16px; padding: 36px; width: 100%; max-width: 380px; box-shadow: 0 20px 40px rgba(0,0,0,.3); }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .ico { width: 60px; height: 60px; background: var(--primary); border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 900; color: #fff; }
.login-title { text-align: center; font-size: 20px; font-weight: 900; margin: 8px 0 2px; }
.login-sub { text-align: center; font-size: 12px; color: var(--text-sub); margin-bottom: 24px; }

/* ── Confirm Dialog ── */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9998; display: flex; align-items: center; justify-content: center; }
.confirm-box { background: var(--white); border-radius: 14px; padding: 24px; max-width: 380px; width: 90%; box-shadow: var(--shadow-lg); text-align: center; }
.confirm-msg { font-size: 15px; font-weight: 700; margin-bottom: 20px; line-height: 1.5; }
.confirm-btns { display: flex; gap: 10px; justify-content: center; }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--border); padding-bottom: 0; }
.tab-btn { padding: 8px 16px; border: none; background: none; font-family: inherit; font-size: 13px; font-weight: 700; color: var(--text-sub); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Dropdown search ── */
.dd-wrap { position: relative; }
.dd-list { position: absolute; top: calc(100% + 2px); right: 0; left: 0; background: var(--white); border: 1.5px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 500; max-height: 200px; overflow-y: auto; display: none; }
.dd-list.open { display: block; }
.dd-item { padding: 9px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid #f8fafc; }
.dd-item:hover { background: #f8fafc; }
.dd-item:last-child { border-bottom: none; }
.dd-selected { padding: 8px 12px; background: var(--tint); border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--primary); margin-top: 6px; display: none; }

/* ── Print ── */
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: fixed; top: 0; left: 0; width: 100%; }
}

/* ── Responsive ── */
@media (max-width: 1400px) {
  .pos-layout { grid-template-columns: 1fr 300px; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 5px; }
  .pos-card { padding: 8px; }
  .pos-card-name { font-size: 11px; }
  .pos-card-price { font-size: 13px; }
  .pos-inv-footer { padding: 8px 10px; }
  .pos-grand { font-size: 18px; }
}

@media (max-width: 1200px) {
  .pos-layout { grid-template-columns: 1fr 270px; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 4px; padding: 6px; }
  .pos-card { padding: 7px; }
  .pos-card-name { font-size: 10px; }
  .pos-card-price { font-size: 12px; }
  .pos-inv-header { padding: 10px 12px; }
  .pos-inv-footer { padding: 7px 10px; }
  .pos-grand { font-size: 17px; }
  .pos-total-row { font-size: 12px; }
}

@media (max-width: 1100px) {
  .pos-layout { grid-template-columns: 1fr 260px; }
  .pos-grid { grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 4px; padding: 5px; }
  .pos-card { padding: 6px; }
  .pos-card-name { font-size: 10px; }
  .pos-card-price { font-size: 12px; }
}

@media (max-width: 768px) {
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .pos-layout { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .pos-invoice { max-height: 45vh; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
}

/* عداد نواقص المخزون على تبويب المنتجات */
.nav-badge{display:inline-block;min-width:17px;height:17px;line-height:17px;padding:0 5px;margin-right:5px;border-radius:9px;background:#ef4444;color:#fff;font-size:10px;font-weight:800;text-align:center;vertical-align:middle}
.stk-chip{padding:5px 14px;border-radius:20px;border:1.5px solid var(--border,#e2e8f0);background:#fff;font-family:inherit;font-size:12px;font-weight:700;cursor:pointer;color:#475569;transition:all .15s}
.stk-chip:hover{border-color:var(--primary);color:var(--primary)}
.stk-chip.on{background:var(--primary);border-color:var(--primary);color:#fff}
.stk-chip.warn.on{background:#d97706;border-color:#d97706}
.stk-chip.danger.on{background:#dc2626;border-color:#dc2626}
.stk-bar{height:6px;border-radius:3px;background:#e2e8f0;overflow:hidden;min-width:60px}
.stk-bar>i{display:block;height:100%;border-radius:3px}
