/* ==========================================================================
   SELZA ERP — نظام التصميم (فاتح، مريح للعين، يشتغل على الموبايل والتابلت)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&display=swap');

:root {
  /* ألوان هادية ومريحة */
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #dbeafe;

  --green: #15803d;
  --green-soft: #dcfce7;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --red: #b91c1c;
  --red-soft: #fee2e2;
  --purple: #6d28d9;
  --purple-soft: #ede9fe;

  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #d8e0ea;
  --border-2: #e8eef5;

  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --sw: 268px;

  /* اتجاه إخفاء القايمة الجانبية.
     القايمة متثبّتة بـ inset-inline-end، يعني في RTL بتقع على الشمال —
     فالإخفاء لازم يكون ناحية الشمال (سالب). الزيادة 24px عشان الظل ما يبانش. */
  --side-hide: calc(-100% - 24px);

  /* خط كبير نسبياً للوضوح */
  --fs: 16px;
  --fs-sm: 14px;
  --fs-lg: 19px;
  --font: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--fs); }

/* في LTR القايمة بتقع على اليمين — نعكس اتجاه الإخفاء تلقائياً */
[dir="ltr"] { --side-hide: calc(100% + 24px); }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ============================ التخطيط ============================ */
.layout { display: flex; min-height: 100vh; }

.side {
  width: var(--sw);
  background: var(--surface);
  border-inline-start: 1px solid var(--border);
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  overflow-y: auto;
  z-index: 60;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}

.side-brand {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
}
.side-brand .logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: grid; place-items: center;
  color: #fff; font-weight: 900; font-size: 19px;
  flex-shrink: 0;
}
.side-brand .nm { font-weight: 900; font-size: 18px; line-height: 1.2; }
.side-brand .sb { font-size: 11px; color: var(--muted); }

.side-nav { padding: 10px 10px 90px; flex: 1; }

.nav-grp { margin-bottom: 4px; }
.nav-head {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 12px;
  font-weight: 700; font-size: 15px; color: var(--text-2);
  cursor: pointer; border-radius: var(--r-sm);
  user-select: none;
  transition: background .15s;
}
.nav-head:hover { background: var(--surface-3); }
.nav-head .ico { font-size: 17px; width: 22px; text-align: center; }
.nav-head .arw { margin-inline-start: auto; font-size: 11px; color: var(--muted); transition: transform .2s; }
.nav-grp.open .nav-head .arw { transform: rotate(-90deg); }
.nav-grp.open .nav-head { color: var(--primary); }

.nav-body { display: none; padding: 2px 0 6px; }
/* عنوان مجموعة فرعية جوه القايمة (تقسيم التقارير) */
.nav-sec {
  font-size: 11px; font-weight: 800; color: var(--muted);
  letter-spacing: .2px; padding: 9px 12px 3px;
  border-top: 1px solid var(--border-2); margin-top: 4px;
}
.nav-body > .nav-sec:first-child { border-top: none; margin-top: 0; padding-top: 4px; }
.nav-grp.open .nav-body { display: block; }

.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px 9px 12px;
  margin-inline-start: 20px;
  font-size: var(--fs-sm); color: var(--muted);
  cursor: pointer; border-radius: var(--r-sm);
  border-inline-start: 2px solid transparent;
  transition: all .15s;
}
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft); color: var(--primary-dark);
  font-weight: 700; border-inline-start-color: var(--primary);
}
.nav-item .badge {
  margin-inline-start: auto; background: var(--red); color: #fff;
  font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 20px;
}

/* ============================ المحتوى ============================ */
.main {
  flex: 1;
  margin-inline-end: var(--sw);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 50;
}
.burger {
  display: none; width: 40px; height: 40px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface);
  font-size: 19px; cursor: pointer; align-items: center; justify-content: center;
}

.search-wrap { position: relative; flex: 1; max-width: 520px; }
.search-wrap input {
  width: 100%; height: 42px; padding: 0 42px 0 14px;
  border: 1px solid var(--border); border-radius: 24px;
  background: var(--surface-2); font-family: var(--font); font-size: var(--fs-sm);
  color: var(--text); outline: none; transition: all .15s;
}
.search-wrap input:focus { border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-wrap .si { position: absolute; inset-inline-end: 15px; top: 11px; color: var(--muted); pointer-events: none; }

.search-pop {
  position: absolute; top: 50px; inset-inline: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); box-shadow: var(--shadow-lg);
  max-height: 440px; overflow-y: auto; z-index: 90; padding: 6px;
}
.search-pop .grp { font-size: 11px; font-weight: 700; color: var(--muted); padding: 8px 10px 4px; }
.search-pop .row {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: var(--r-sm); cursor: pointer; font-size: var(--fs-sm);
}
.search-pop .row:hover, .search-pop .row.sel { background: var(--primary-soft); }
.search-pop .row .r-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.search-pop .row .r-main { flex: 1; min-width: 0; }
.search-pop .row .r-t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-pop .row .r-s { font-size: 12px; color: var(--muted); }
.search-pop .empty { padding: 22px; text-align: center; color: var(--muted); font-size: var(--fs-sm); }

.tb-right { margin-inline-start: auto; display: flex; align-items: center; gap: 10px; }
.tb-btn {
  position: relative; width: 42px; height: 42px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-size: 17px; display: grid; place-items: center;
}
.tb-btn:hover { background: var(--surface-3); }
.tb-btn .dot {
  position: absolute; top: -5px; inset-inline-end: -5px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 20px; display: grid; place-items: center;
  padding: 0 4px;
}
.tb-user { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 5px 9px; border-radius: var(--r-sm); }
.tb-user:hover { background: var(--surface-3); }
.tb-user .av {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700;
  display: grid; place-items: center; font-size: var(--fs-sm); flex-shrink: 0;
}
.tb-user .un { font-size: 13px; font-weight: 700; line-height: 1.25; }
.tb-user .ur { font-size: 11px; color: var(--muted); }

.content { padding: 22px; flex: 1; }
.page { display: none; }
.page.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ============================ العناصر ============================ */
.ph { margin-bottom: 18px; }
.ph h1 { font-size: 25px; font-weight: 900; line-height: 1.3; }
.ph h1 span { color: var(--primary); }
.ph .sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
.ct {
  font-weight: 700; font-size: var(--fs-lg); margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.ct .hint { font-size: 12px; color: var(--muted); font-weight: 400; }

/* خطوات مرقمة */
.steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.step {
  flex: 1; min-width: 130px; display: flex; align-items: center; gap: 9px;
  padding: 11px 13px; border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid transparent;
  font-size: 13px; color: var(--muted); transition: all .2s;
}
.step .n {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: var(--border); color: var(--text-2);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
}
.step.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); font-weight: 700; }
.step.active .n { background: var(--primary); color: #fff; }
.step.done { background: var(--green-soft); color: var(--green); }
.step.done .n { background: var(--green); color: #fff; }
.step .lbl { line-height: 1.3; }

/* نماذج */
.fr { display: flex; gap: 13px; flex-wrap: wrap; margin-bottom: 13px; }
.fr:last-child { margin-bottom: 0; }
.fg { flex: 1; min-width: 165px; display: flex; flex-direction: column; }
.fg.wide { flex: 2.2; min-width: 240px; }
.fg label {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  margin-bottom: 6px; display: flex; align-items: center; gap: 5px;
}
.fg label .req { color: var(--red); }
.fg label .hint { font-size: 11px; color: var(--muted); font-weight: 400; }
.fg .help { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
/* سطر التأكيد تحت خانة الكود */
.fg .help.good { color: var(--green); font-weight: 600; }
.fg .help.bad {
  color: var(--red); font-weight: 700;
  background: var(--red-soft); border: 1px solid var(--red);
  border-radius: var(--r-sm); padding: 5px 8px;
}
input.bad { border-color: var(--red); background: var(--red-soft); }
input.bad:focus { box-shadow: 0 0 0 3px var(--red-soft); border-color: var(--red); }

/* خانتي الكود والاسم جنب بعض في شاشة الفاتورة */
.pick-row { align-items: flex-start; }
.pick-row .pick-code { flex: 0 0 180px; min-width: 150px; }

input, select, textarea, .sel {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: var(--fs-sm);
  outline: none; transition: all .15s;
}
input:focus, select:focus, textarea:focus, .sel:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
input:disabled, select:disabled, .sel:disabled, input[readonly] { background: var(--surface-3); color: var(--muted); }
.rep-bar input:disabled, .rep-bar select:disabled { opacity: .55; cursor: not-allowed; }
input[type="number"] { -moz-appearance: textfield; }
select { cursor: pointer; }
textarea { resize: vertical; min-height: 70px; }

.inline { display: flex; gap: 7px; align-items: stretch; }
.inline > input, .inline > select { flex: 1; }

/* أزرار */
.btn {
  padding: 11px 18px; border: 1px solid transparent; border-radius: var(--r-sm);
  font-family: var(--font); font-size: var(--fs-sm); font-weight: 700;
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; transition: all .15s; white-space: nowrap; line-height: 1.4;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.bp { background: var(--primary); color: #fff; }
.bp:hover:not(:disabled) { background: var(--primary-dark); }
.bg2 { background: var(--green); color: #fff; }
.bg2:hover:not(:disabled) { filter: brightness(.92); }
.bd { background: var(--red); color: #fff; }
.bd:hover:not(:disabled) { filter: brightness(.92); }
.bw { background: var(--amber); color: #fff; }
.bk { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.bk:hover:not(:disabled) { background: var(--surface-3); }
.bsm { padding: 6px 11px; font-size: 13px; }
.bxs { padding: 4px 9px; font-size: 12px; }
.bfull { width: 100%; }
.blg { padding: 14px 24px; font-size: var(--fs); }

.btn-row { display: flex; gap: 9px; flex-wrap: wrap; }

/* جداول */
.tw { overflow-x: auto; border-radius: var(--r-sm); border: 1px solid var(--border-2); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
thead th {
  background: var(--surface-3); padding: 11px 12px; text-align: right;
  font-weight: 700; font-size: 13px; color: var(--text-2);
  white-space: nowrap; border-bottom: 1px solid var(--border);
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.clickable { cursor: pointer; }
tfoot td { padding: 11px 12px; background: var(--surface-3); font-weight: 800; border-top: 2px solid var(--border); }
.num { font-variant-numeric: tabular-nums; }
.empty-row td { text-align: center; padding: 34px; color: var(--muted); }

/* بطاقات أرقام */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); gap: 13px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 16px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.kpi::before { content: ''; position: absolute; inset-block: 0; inset-inline-start: 0; width: 4px; background: var(--primary); }
.kpi.g::before { background: var(--green); } .kpi.r::before { background: var(--red); }
.kpi.a::before { background: var(--amber); } .kpi.p::before { background: var(--purple); }
.kpi .k-l { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.kpi .k-v { font-size: 24px; font-weight: 900; line-height: 1.35; letter-spacing: -.4px; }
.kpi .k-s { font-size: 11.5px; color: var(--muted); }
.kpi.g .k-v { color: var(--green); } .kpi.r .k-v { color: var(--red); }
.kpi.a .k-v { color: var(--amber); } .kpi.p .k-v { color: var(--purple); }

/* شارات */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.tag.g { background: var(--green-soft); color: var(--green); }
.tag.r { background: var(--red-soft); color: var(--red); }
.tag.a { background: var(--amber-soft); color: var(--amber); }
.tag.b { background: var(--primary-soft); color: var(--primary-dark); }
.tag.p { background: var(--purple-soft); color: var(--purple); }
.tag.n { background: var(--surface-3); color: var(--muted); }

/* تنبيهات */
.alert {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 15px; border-radius: var(--r-sm);
  border-inline-start: 4px solid; margin-bottom: 10px; font-size: var(--fs-sm);
}
.alert .a-i { font-size: 19px; line-height: 1; flex-shrink: 0; }
.alert .a-b { flex: 1; min-width: 0; }
.alert .a-t { font-weight: 700; }
.alert .a-d { color: var(--muted); font-size: 13px; }
.alert.danger { background: var(--red-soft); border-color: var(--red); }
.alert.danger .a-t { color: var(--red); }
.alert.warn { background: var(--amber-soft); border-color: var(--amber); }
.alert.warn .a-t { color: var(--amber); }
.alert.info { background: var(--primary-soft); border-color: var(--primary); }
.alert.info .a-t { color: var(--primary-dark); }
.alert.ok { background: var(--green-soft); border-color: var(--green); }
.alert.ok .a-t { color: var(--green); }

/* نتائج البحث في الشاشة */
.res {
  position: absolute; z-index: 40; inset-inline: 0; top: calc(100% + 4px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); box-shadow: var(--shadow-lg);
  max-height: 300px; overflow-y: auto;
}
.res .r {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 13px; cursor: pointer; font-size: var(--fs-sm);
  border-bottom: 1px solid var(--border-2);
}
.res .r:last-child { border-bottom: none; }
.res .r:hover, .res .r.sel { background: var(--primary-soft); }

/* مودال */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px; backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
.modal.lg { max-width: 860px; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.modal-h {
  padding: 17px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  position: sticky; top: 0; background: var(--surface); border-radius: 16px 16px 0 0; z-index: 2;
}
.modal-h h3 { font-size: var(--fs-lg); font-weight: 800; }
.modal-h .x { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; padding: 0 4px; }
.modal-b { padding: 20px; }
.modal-f { padding: 15px 20px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-start; }

/* توست */
#toast-box { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 300; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--primary);
  border-radius: var(--r-sm); padding: 13px 17px; box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm); font-weight: 600; max-width: 380px;
  animation: slide .22s ease; display: flex; gap: 9px; align-items: center;
}
@keyframes slide { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.toast.success { border-inline-start-color: var(--green); }
.toast.error { border-inline-start-color: var(--red); }
.toast.warn { border-inline-start-color: var(--amber); }

/* شرايح */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.chip {
  background: var(--primary-soft); color: var(--primary-dark);
  padding: 4px 11px; border-radius: 20px; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip .x { cursor: pointer; opacity: .6; font-weight: 900; }
.chip .x:hover { opacity: 1; }

/* تبويبات */
.tabs { display: flex; gap: 5px; margin-bottom: 16px; border-bottom: 2px solid var(--border-2); overflow-x: auto; }
.tab {
  padding: 10px 17px; cursor: pointer; font-size: var(--fs-sm); font-weight: 700;
  color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px;
  white-space: nowrap; background: none; border-top: none; border-inline: none;
  font-family: var(--font);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* شبكة */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; align-items: start; }

/* بار تقدم */
.bar { height: 7px; background: var(--surface-3); border-radius: 20px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: 20px; }

.muted { color: var(--muted); }
.hidden { display: none !important; }
.center { text-align: center; }
.tleft { text-align: left; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.pos { color: var(--green); font-weight: 700; }
.neg { color: var(--red); font-weight: 700; }
.big { font-size: 21px; font-weight: 900; }

.spinner {
  width: 34px; height: 34px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 34px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* شاشة الدخول */
.gate {
  position: fixed; inset: 0; z-index: 500;
  background: linear-gradient(135deg, #eef2ff, #f8fafc 55%, #ecfdf5);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.gate-box {
  background: var(--surface); border-radius: 18px; padding: 34px 30px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); text-align: center;
}
.gate-box .logo {
  width: 62px; height: 62px; border-radius: 17px; margin: 0 auto 15px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: grid; place-items: center; color: #fff; font-size: 27px; font-weight: 900;
}
.gate-box h2 { font-size: 22px; font-weight: 900; margin-bottom: 5px; }
.gate-box .s { color: var(--muted); font-size: var(--fs-sm); margin-bottom: 22px; }
.gate-box input { text-align: center; margin-bottom: 11px; padding: 13px; font-size: var(--fs); }
.gate-msg { color: var(--red); font-size: 13px; min-height: 19px; margin-top: 10px; font-weight: 600; }

/* ============================ الموبايل والتابلت ============================ */
.side-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  z-index: 55; display: none;
}
.side-overlay.show { display: block; }

@media (max-width: 1024px) {
  :root { --sw: 260px; }
  .side {
    /* مقفولة = بره الشاشة بالكامل (الاتجاه بيتحدد من --side-hide حسب dir) */
    transform: translateX(var(--side-hide));
    box-shadow: var(--shadow-lg);
    visibility: hidden;
    transition: transform .25s ease, visibility 0s linear .25s;
  }
  .side.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform .25s ease, visibility 0s;
  }
  .main { margin-inline-end: 0; }
  .burger { display: flex; }
  .content { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
}

/* على الشاشة الكبيرة القايمة ثابتة ظاهرة — يبقى الحجاب الأسود مالوش لازمة أبداً.
   ده بيمنع إن الحجاب يفضل مغطّي الشاشة لو حد فتح القايمة على الموبايل وكبّر الشاشة. */
@media (min-width: 1025px) {
  .side-overlay { display: none !important; }
  .side { transform: none !important; visibility: visible !important; }
}

@media (max-width: 640px) {
  :root { --fs: 15.5px; --fs-lg: 17px; --sw: min(84vw, 280px); }
  .content { padding: 13px; }
  .card { padding: 14px; border-radius: 10px; }
  .ph h1 { font-size: 21px; }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(144px, 1fr)); gap: 10px; }
  .kpi { padding: 13px; }
  .kpi .k-v { font-size: 20px; }
  .tb-user .un, .tb-user .ur { display: none; }
  .search-wrap { max-width: none; }
  .fg { min-width: 100%; }
  .fg.wide { min-width: 100%; }
  /* الكود والاسم يفضلوا جنب بعض حتى على الموبايل */
  .pick-row { gap: 9px; flex-wrap: nowrap; }
  .pick-row .pick-code { flex: 0 0 108px; min-width: 108px; }
  .pick-row .fg.wide { flex: 1; min-width: 0; }
  .step { min-width: calc(50% - 3px); font-size: 12px; }
  .btn { padding: 10px 15px; }
  thead th, tbody td { padding: 9px 8px; font-size: 13px; }
  .modal-f { flex-direction: column-reverse; }
  .modal-f .btn { width: 100%; }
}

/* ============================ الطباعة ============================ */
@media print {
  .side, .topbar, .no-print, .btn, .tabs, .side-overlay { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; }
  body { background: #fff; font-size: 12px; }
  .card { border: none; box-shadow: none; padding: 0; margin-bottom: 12px; page-break-inside: avoid; }
  table { font-size: 11px; }
  thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kpi { border: 1px solid #ccc; box-shadow: none; }
}
