/* =========================================================
   نظام قافلة الجزيرة — نظام التصميم (النسخة الجديدة)
   مطابق للتصميم المرجعي: كريمي · IBM Plex Sans Arabic · أخضر عميق
   ========================================================= */

:root {
  /* الأسطح والخلفيات */
  --bg: #f4f3ee;
  --surface: #ffffff;
  --surface-2: #fafaf6;
  --surface-3: #f7f7f3;
  --field-bg: #faf9f5;
  /* الحدود */
  --border: #ececec;
  --border-2: #e2e1da;
  --border-3: #eae9e2;
  --hair: #f2f1ea;
  /* النصوص */
  --text: #141a18;
  --text-2: #2b332f;
  --text-3: #4a534e;
  --text-4: #6d766f;
  --muted: #8a938d;
  --faint: #a3aaa2;
  /* العلامة */
  --brand: #0f6d5b;
  --brand-hover: #0a5748;
  --brand-2: #0f7a66;
  --brand-deep: #0a4436;
  --brand-grad: linear-gradient(150deg, #12836d, #0a4436);
  /* سُلّم العلامة (توافقيّة مع مكوّنات JS) */
  --brand-50: #e8f4f0;
  --brand-100: #cbe6dd;
  --brand-300: #6fb8a6;
  --brand-400: #2f9a83;
  --brand-500: #12836d;
  --brand-600: #0f6d5b;
  --brand-700: #0c5748;
  --brand-800: #0a4436;
  --green: #0d7a4f;
  --gold: #e9b949;
  --gold-500: #e9b949;
  --gold-hover: #dcaa38;
  --gold-ink: #4a3a08;
  --border-strong: #d3d8d2;
  /* دلالات الحالة (خلفية + نص) */
  --success: #0d7a4f;   --success-bg: #e7f6ef;
  --info: #2f66b3;      --info-bg: #e6eefb;
  --warning: #b5771a;   --warning-bg: #fbeeda;
  --danger: #b23a2e;    --danger-bg: #fbe9e7;
  --purple: #6355c9;    --purple-bg: #ebe9fb;
  --teal: #0f7a66;      --teal-bg: #e4f2ee;
  --neutral-ink: #5a635d; --neutral-bg: #f2f1ea;
  --seg-track: #efeee8;
  --red-dot: #e0554a;
  /* الأنصاف */
  --r-sm: 10px; --r: 12px; --r-md: 14px; --r-lg: 16px; --r-xl: 18px; --r-2xl: 22px; --r-full: 999px;
  /* الظلال */
  --sh-sm: 0 1px 2px rgba(20,26,24,.04);
  --sh: 0 8px 24px rgba(20,40,34,.05);
  --sh-lg: 0 14px 32px rgba(20,40,34,.1);
  --sh-xl: 0 30px 70px rgba(6,42,34,.35);
  --sh-btn: 0 8px 20px rgba(15,109,91,.22);
  --font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --t-fast: .16s var(--ease);
  --t: .24s var(--ease);
}

:root[data-theme="dark"] {
  --bg: #0d1512; --surface: #141f19; --surface-2: #17231d; --surface-3: #17231d; --field-bg: #17231d;
  --border: rgba(255,255,255,.09); --border-2: rgba(255,255,255,.1); --border-3: rgba(255,255,255,.08); --hair: rgba(255,255,255,.06);
  --text: #eaf2ee; --text-2: #d4e0da; --text-3: #b3c4bc; --text-4: #9db8b1; --muted: #8fa39a; --faint: #6b857e;
  --success-bg: #102e20; --info-bg: #122740; --warning-bg: #33280f; --danger-bg: #3a1717; --purple-bg: #211a3d; --teal-bg: #103029; --neutral-bg: #1c2a24;
  --brand-50: #14261f; --brand-100: #17352b; --brand-300: #2f9a83; --border-strong: rgba(255,255,255,.18); --seg-track: #1c2a24;
  --sh-sm: 0 1px 2px rgba(0,0,0,.4); --sh: 0 8px 24px rgba(0,0,0,.4); --sh-lg: 0 14px 34px rgba(0,0,0,.5); --sh-xl: 0 30px 70px rgba(0,0,0,.6);
}

/* ---------- إعادة الضبط ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); background: var(--bg); color: var(--text);
  line-height: 1.55; font-size: 14px; letter-spacing: -.1px;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden; transition: background var(--t), color var(--t);
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-deep); }
::placeholder { color: #9aa39f; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d8d7cf; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); background-clip: padding-box; }

/* ---------- إمكانية الوصول ---------- */
:where(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- أدوات ---------- */
.hidden { display: none !important; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1{gap:4px}.gap-2{gap:8px}.gap-3{gap:12px}.gap-4{gap:16px}
.grid { display: grid; } .text-center { text-align: center; } .w-full { width: 100%; }
.mt-2{margin-top:8px}.mt-4{margin-top:16px}.mb-4{margin-bottom:16px}
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.ic { flex-shrink: 0; vertical-align: middle; }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: var(--r); font-weight: 600; font-size: 14px;
  transition: all var(--t-fast); white-space: nowrap; user-select: none; border: 1px solid transparent; line-height: 1;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .ic { margin-inline-end: -2px; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--sh-btn); }
.btn-primary:hover { background: var(--brand-hover); box-shadow: 0 12px 30px rgba(15,109,91,.3); }
.btn-gold { background: var(--gold); color: var(--gold-ink); font-weight: 700; box-shadow: 0 8px 20px rgba(233,185,73,.28); }
.btn-gold:hover { background: var(--gold-hover); }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: #c4cac4; }
.btn-outline { background: var(--surface); color: var(--text-2); border: 1px solid var(--border-2); font-weight: 600; }
.btn-outline:hover { background: var(--surface-2); }
.btn-success { background: linear-gradient(135deg, #12836d, #0d5f50); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-dark { background: var(--text); color: #fff; }
.btn-dark:hover { background: #000; }
.btn-sm { height: 36px; padding: 0 13px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-lg { height: 50px; padding: 0 24px; font-size: 15px; border-radius: 13px; }
.btn-block { width: 100%; }

/* ---------- البطاقات ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--sh-sm); transition: box-shadow var(--t), transform var(--t), border-color var(--t); }
.card-pad { padding: 20px; }
.card-hover { cursor: pointer; }
.card-hover:hover { box-shadow: var(--sh-lg); transform: translateY(-3px); border-color: #cfe6dc; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid #f0efe8; }
.card-head h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-head h3 .ic { width: 18px; height: 18px; color: var(--brand); }

/* ---------- بطاقات الإحصائيات (أفقية: نص + أيقونة) ---------- */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  box-shadow: var(--sh-sm); transition: transform var(--t), box-shadow var(--t); animation: floatUp .45s ease both;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); }
.stat-main { min-width: 0; }
.stat-label { font-size: 12.5px; color: var(--text-4); margin-bottom: 8px; font-weight: 500; }
.stat-value { font-size: 27px; font-weight: 700; line-height: 1; letter-spacing: -.5px; font-variant-numeric: tabular-nums; color: var(--text); }
.stat-sub { font-size: 11.5px; color: var(--faint); margin-top: 8px; display: flex; align-items: center; gap: 5px; }
.stat-ico { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; flex-shrink: 0; font-size: 21px; background: var(--teal-bg); color: var(--teal); border: 1px solid transparent; }
.stat-ico .ic { width: 22px; height: 22px; }
.stat.gold .stat-ico { background: var(--warning-bg); color: var(--warning); }
.stat.blue .stat-ico { background: var(--info-bg); color: var(--info); }
.stat.red .stat-ico { background: var(--danger-bg); color: var(--danger); }
.stat.green .stat-ico { background: var(--success-bg); color: var(--success); }
.stat.purple .stat-ico { background: var(--purple-bg); color: var(--purple); }

/* ---------- الشارات ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: var(--r-full); font-size: 11.5px; font-weight: 600; line-height: 1.4; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-teal { background: var(--teal-bg); color: var(--teal); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-ink); }
/* شارتا مصدر الطلب (فرع / نظام التوصيل) */
.badge-src-branch { background: #e6eefb; color: #2f66b3; }
.badge-src-system { background: #f0ece4; color: #8a6a12; }
html[data-theme="dark"] .badge-src-branch { background: #122740; color: #7fb0ff; }
html[data-theme="dark"] .badge-src-system { background: #2c2612; color: #d8b967; }
/* شرائح تصفية المصدر */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 15px; border-radius: var(--r-full); font-size: 12.5px; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--muted); border: 1px solid var(--hair); transition: all .18s var(--ease); user-select: none; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ---------- الجداول ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--border); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; background: var(--surface); }
.tbl thead th { background: var(--surface-2); text-align: right; padding: 14px 18px; font-weight: 600; color: var(--muted); font-size: 12px; white-space: nowrap; border-bottom: 1px solid var(--hair); }
.tbl tbody td { padding: 15px 18px; border-top: 1px solid var(--hair); }
.tbl tbody tr:first-child td { border-top: none; }
.tbl tbody tr { transition: background var(--t-fast); }
.tbl tbody tr:hover { background: var(--surface-2); }

/* ---------- الحقول ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-3); margin-bottom: 7px; }
.input, .select, .textarea {
  width: 100%; height: 48px; padding: 0 15px; border: 1px solid var(--border-2); border-radius: var(--r);
  background: var(--field-bg); transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast); outline: none; color: var(--text);
}
.textarea { height: auto; min-height: 96px; padding: 12px 15px; resize: vertical; line-height: 1.7; }
.select { background: var(--surface); cursor: pointer; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(15,109,91,.12); background: var(--surface); }
.input-group { position: relative; }
.input-group .ico { position: absolute; inset-inline-start: 16px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; display: flex; }
.input-group .ico .ic { width: 18px; height: 18px; }
.input-group .input { padding-inline-start: 44px; }

/* ---------- تخطيط اللوحة ---------- */
.app-shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-inline-start: 1px solid var(--border-3); display: flex; flex-direction: column; padding: 22px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40; transition: transform var(--t); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.sidebar-brand .logo { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-grad); display: grid; place-items: center; font-size: 22px; color: var(--gold); font-weight: 700; box-shadow: 0 6px 16px rgba(10,68,54,.28); }
.sidebar-brand .name { font-weight: 700; font-size: 15.5px; color: var(--text); }
.sidebar-brand .sub { font-size: 11px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-section { font-size: 11px; font-weight: 600; color: var(--faint); padding: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 11px; font-weight: 500; font-size: 14px; color: var(--text-3); transition: background var(--t-fast), color var(--t-fast); width: 100%; text-align: right; }
.nav-item .nav-dot { width: 9px; height: 9px; border-radius: 3px; background: #cdd3cc; flex-shrink: 0; transition: background var(--t-fast); }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-item.active .nav-dot { background: var(--gold); }
.nav-item .count { margin-inline-start: auto; background: var(--warning-bg); color: var(--warning); font-size: 11px; font-weight: 700; min-width: 20px; height: 20px; border-radius: 7px; display: grid; place-items: center; padding: 0 5px; }
.nav-item.active .count { background: rgba(255,255,255,.25); color: #fff; }
.sidebar-foot { margin-top: auto; padding-top: 12px; }
.help-box { background: var(--bg); border-radius: 14px; padding: 14px; margin-top: 14px; }
.help-box .t { font-size: 12.5px; font-weight: 600; margin-bottom: 8px; }
.help-box .btn-support { display: flex; align-items: center; justify-content: center; gap: 7px; height: 38px; border-radius: 10px; background: var(--brand-2); color: #fff; font-size: 12.5px; font-weight: 700; width: 100%; transition: background var(--t-fast); }
.help-box .btn-support:hover { background: var(--brand-hover); }
.logout-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 12px; margin-top: 8px; border-radius: 10px; color: var(--muted); font-size: 13px; font-weight: 500; transition: all var(--t-fast); }
.logout-row:hover { background: var(--danger-bg); color: var(--danger); }
.logout-row .ic { width: 17px; height: 17px; }

.main-area { display: flex; flex-direction: column; min-width: 0; }
.topbar { min-height: 76px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border-3); display: flex; align-items: center; gap: 16px; padding: 16px 28px; position: sticky; top: 0; z-index: 30; }
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar-search { position: relative; flex: 1; max-width: 420px; }
.topbar-search input { width: 100%; height: 44px; padding: 0 44px 0 16px; border-radius: 12px; border: 1px solid var(--border-2); background: var(--surface); font-family: inherit; font-size: 14px; outline: none; color: var(--text); transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.topbar-search input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(15,109,91,.1); }
.topbar-search .ico { position: absolute; inset-inline-start: 15px; top: 50%; transform: translateY(-50%); color: var(--faint); display: flex; pointer-events: none; }
.topbar-search .ico .ic { width: 17px; height: 17px; }
.topbar-right { margin-inline-start: auto; display: flex; align-items: center; gap: 14px; }
.topbar-divider { width: 1px; height: 28px; background: var(--border-2); }
.content { padding: 26px 28px 44px; flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; }
.top-btn { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border-2); color: var(--text-3); font-size: 17px; transition: all var(--t-fast); position: relative; }
.top-btn:hover { background: var(--surface-2); color: var(--brand); }
.top-btn .ic { width: 19px; height: 19px; }
.top-btn .dot { position: absolute; top: 9px; inset-inline-end: 11px; width: 9px; height: 9px; background: var(--red-dot); border-radius: 50%; border: 2px solid var(--surface); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .u-name { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.user-chip .u-role { font-size: 11.5px; color: var(--muted); line-height: 1.3; }
.avatar { width: 40px; height: 40px; border-radius: 11px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; flex-shrink: 0; }

/* ---------- ترويسة الترحيب (لوحة التحكم) ---------- */
.hero-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; animation: floatUp .5s ease both; }
.hero-head h1 { font-size: 25px; font-weight: 700; letter-spacing: -.3px; margin-bottom: 4px; }
.hero-head .sub { font-size: 14px; color: var(--text-4); }
.hero-head .acts { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- بطاقات KPI للوحة التحكم ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi-card { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 20px; transition: transform .2s var(--ease), box-shadow .2s var(--ease); animation: floatUp .5s ease both; }
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); }
.kpi-wm { position: absolute; bottom: -20px; inset-inline-start: 14px; font-size: 78px; font-weight: 800; color: var(--bg); line-height: 1; letter-spacing: -2px; pointer-events: none; user-select: none; }
.kpi-ico { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; font-size: 23px; position: relative; }
.kpi-body { position: relative; text-align: right; margin-top: 16px; }
.kpi-val { font-size: 33px; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; line-height: 1; }
.kpi-label { font-size: 13px; color: var(--text-3); margin-top: 8px; font-weight: 600; }
.kpi-sub { font-size: 11.5px; color: var(--faint); margin-top: 8px; }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes ringPulse { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(2.4); opacity: 0; } }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }

/* ---------- بوابات بترويسة علوية (بلا شريط جانبي) ---------- */
.portal-shell { min-height: 100vh; display: flex; flex-direction: column; }
.portal-top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(180%) blur(10px); -webkit-backdrop-filter: saturate(180%) blur(10px); border-bottom: 1px solid var(--border-3); display: flex; align-items: center; gap: 14px; padding: 12px 30px; }
.portal-top .logo-sm { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-grad); display: grid; place-items: center; color: var(--gold); font-weight: 700; font-size: 21px; flex-shrink: 0; }
.portal-nav { width: 100%; max-width: 1240px; margin: 0 auto; padding: 18px 30px 0; }
.portal-content { width: 100%; max-width: 1240px; margin: 0 auto; padding: 22px 30px 48px; }
@media (max-width: 640px) { .portal-top { padding: 12px 16px; } .portal-nav { padding: 14px 16px 0; } .portal-content { padding: 18px 16px 40px; } }

/* ---------- المستودع (Kanban) ---------- */
.wh-hero { position: relative; overflow: hidden; background: radial-gradient(120% 150% at 12% 0%, #12836d, #0a4436); border-radius: 22px; padding: 26px 30px; color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; animation: floatUp .5s ease both; }
.wh-hero::before { content: ""; position: absolute; top: -70px; left: -40px; width: 230px; height: 230px; border-radius: 50%; border: 1px solid rgba(255,255,255,.14); }
.wh-hero-ico { width: 56px; height: 56px; border-radius: 15px; background: rgba(255,255,255,.14); display: grid; place-items: center; font-size: 26px; flex-shrink: 0; }
.wh-hero-stat .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
.wh-hero-stat .l { font-size: 12px; color: rgba(255,255,255,.65); margin-top: 4px; }
.kanban-board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.kanban-col { border-radius: 18px; padding: 16px; border: 1px solid; }
.kanban-head { display: flex; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid; border-radius: 12px; padding: 9px 12px; }
.kanban-count { min-width: 24px; height: 24px; padding: 0 7px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.kanban-cards { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
@media (max-width: 900px) { .kanban-board { grid-template-columns: 1fr; } }

/* نموذج رفع طلب الفرع (منبثق أفقي) */
.branch-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
@media (max-width: 720px) { .branch-form { grid-template-columns: 1fr; } .branch-form > [style*="span 2"] { grid-column: auto !important; } }
.wh-card { background: var(--surface); border: 1px solid var(--border); border-radius: 13px; padding: 14px; display: flex; flex-direction: column; gap: 10px; animation: floatUp .4s ease both; transition: box-shadow .15s var(--ease); }
.wh-card:hover { box-shadow: 0 8px 22px rgba(20,26,24,.09); }

/* ---------- البوالص ---------- */
.ship-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.ship-stat { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 15px; display: flex; align-items: center; gap: 11px; min-width: 0; animation: floatUp .45s ease both; }
.ship-stat-ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; font-size: 19px; }
.ship-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 18px; }
.ship-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(20,26,24,.03); transition: box-shadow .18s var(--ease), border-color .18s var(--ease); animation: floatUp .45s ease both; }
.ship-card:hover { box-shadow: var(--sh-lg); border-color: var(--border-strong); }
@media (max-width: 1100px) { .ship-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .ship-stats { grid-template-columns: 1fr; } .ship-grid { grid-template-columns: 1fr; } }

/* شبكة لوحة التحكم: محتوى + عمود جانبي */
.dash-2 { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.dash-charts { display: grid; grid-template-columns: 1fr 320px; gap: 20px; margin-bottom: 20px; align-items: stretch; }
@media (max-width: 1000px) { .dash-2, .dash-charts { grid-template-columns: 1fr; } }

/* ---------- ترويسة القسم ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; animation: floatUp .5s ease both; }
.page-head-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.page-head-ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; background: var(--teal-bg); color: var(--teal); border: 1px solid #cfe6dc; }
.page-head-ico .ic { width: 25px; height: 25px; }
.page-head h1 { font-size: 24px; font-weight: 700; line-height: 1.2; letter-spacing: -.3px; }
.page-head .page-sub { font-size: 14px; color: var(--text-4); margin-top: 3px; }
.page-head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---------- الشبكات ---------- */
.grid-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(330px, 100%), 1fr)); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); gap: 20px; }

/* ---------- التبويبات ---------- */
.tabs { display: inline-flex; gap: 4px; background: var(--seg-track); padding: 5px; border-radius: 13px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tab { height: 38px; padding: 0 16px; border-radius: 9px; font-weight: 600; font-size: 13px; color: var(--text-4); white-space: nowrap; transition: all var(--t-fast); display: inline-flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text-2); }
.tab.active { background: var(--surface); color: var(--brand); box-shadow: 0 2px 6px rgba(20,26,24,.1); }

/* ---------- النوافذ ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,30,25,.5); backdrop-filter: blur(3px); z-index: 100; display: grid; place-items: center; padding: 22px; opacity: 0; pointer-events: none; transition: opacity var(--t); overflow: auto; }
.overlay.show { opacity: 1; pointer-events: auto; }
.modal { background: var(--surface); border-radius: var(--r-2xl); box-shadow: var(--sh-xl); width: 100%; max-width: 560px; max-height: 92vh; overflow: hidden; display: flex; flex-direction: column; transform: translateY(14px) scale(.98); transition: transform var(--t); }
.overlay.show .modal { transform: translateY(0) scale(1); }
.modal-lg { max-width: 720px; }
.modal-head { padding: 20px 24px; border-bottom: 1px solid var(--hair); display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 19px; font-weight: 700; }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--hair); display: flex; gap: 10px; justify-content: flex-start; }

/* ---------- إشعارات ---------- */
.toast-wrap { position: fixed; top: 18px; inset-inline-start: 50%; transform: translateX(50%); z-index: 200; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast { background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--brand); box-shadow: var(--sh-lg); border-radius: 12px; padding: 13px 18px; display: flex; align-items: center; gap: 12px; font-weight: 600; min-width: 280px; animation: toastIn .3s var(--ease); }
.toast.success { border-inline-start-color: var(--success); }
.toast.error { border-inline-start-color: var(--danger); }
.toast.warning { border-inline-start-color: var(--warning); }
.toast .ico { font-size: 18px; }

/* ---------- حالات فارغة وتحميل ---------- */
.empty { text-align: center; padding: 56px 24px; color: var(--muted); }
.empty .ico { width: 74px; height: 74px; margin: 0 auto 16px; border-radius: 20px; display: grid; place-items: center; background: var(--bg); border: 1px solid var(--border); font-size: 32px; }
.empty h3 { font-size: 16px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.empty p { font-size: 13px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }

/* ---------- تطبيق المندوب (عمود بعرض الجوال، متمركز على الشاشات الكبيرة) ---------- */
.emp-shell { max-width: 620px; margin-inline: auto; box-shadow: var(--sh-lg); background: var(--bg); }
.emp-shell .topbar { border-inline: 1px solid var(--border); }
.bottom-nav { position: fixed; bottom: 0; inset-inline: 0; margin-inline: auto; max-width: 620px; height: calc(68px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(180%) blur(12px); border-top: 1px solid var(--border); border-inline: 1px solid var(--border); display: flex; justify-content: space-around; z-index: 40; box-shadow: 0 -8px 24px rgba(20,26,24,.06); }
.bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; font-weight: 500; color: #9aa39f; transition: color var(--t-fast); position: relative; }
.bn-item .ico { width: 46px; height: 30px; border-radius: 11px; display: grid; place-items: center; transition: background var(--t-fast); }
.bn-item .ico .ic { width: 21px; height: 21px; }
.bn-item.active { color: var(--brand); font-weight: 700; }
.bn-item.active .ico { background: var(--teal-bg); }
.bn-item.center { flex: 0 0 auto; }
.bn-item.center .ico { width: 60px; height: 60px; margin-top: -30px; border-radius: 20px; border: 4px solid var(--surface); background: linear-gradient(135deg, #12836d, #0d5f50); color: #fff; box-shadow: 0 12px 26px rgba(15,109,91,.42); }
.bn-item.center .ico .ic { width: 26px; height: 26px; }
.bn-item .count { position: absolute; top: 4px; inset-inline-end: 26%; min-width: 17px; height: 17px; background: var(--red-dot); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 9px; display: grid; place-items: center; border: 2px solid var(--surface); padding: 0 4px; }

/* ---------- الحركات ---------- */
.fade-in, .view { animation: floatUp .35s var(--ease); }
@keyframes floatUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.18); opacity: 1; } }
@keyframes pulseDot { 0%,100% { transform: scale(1); opacity: .9; } 50% { transform: scale(1.18); opacity: 1; } }
@keyframes ring { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(2.4); opacity: 0; } }
.pulse-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--success); margin-inline-end: 5px; animation: pulseDot 1.6s ease-in-out infinite; }
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* ---------- التجاوب ---------- */
.menu-toggle, .sidebar-backdrop { display: none; }
.hide-sm { display: block; }
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-inline-start: 0; top: 0; width: 280px; transform: translateX(-105%); }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .sidebar.open { transform: translateX(0) !important; }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 39; }
  .menu-toggle { display: grid; }
  .grid-stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .content { padding: 16px; }
  .topbar { padding: 0 16px; height: 60px; }
  .page-head h1 { font-size: 20px; }
  .page-head-ico { width: 44px; height: 44px; }
  .grid-stats { grid-template-columns: 1fr; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .user-chip .uname { display: none; }
  .hide-sm { display: none; }
  .topbar-search { max-width: none; }
}

/* ---------- التقارير ---------- */
.rpt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.rpt-card { text-align: right; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 22px; cursor: pointer; font-family: inherit; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--sh); transition: transform .15s var(--ease), box-shadow .15s var(--ease), border-color .15s var(--ease); }
.rpt-card.live:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); border-color: #cfe6dc; }
.rpt-card.soon { cursor: not-allowed; opacity: .6; }
.rpt-card-ico { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; font-size: 25px; }
.rpt-kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px; }
.rpt-kpis.k4 { grid-template-columns: repeat(4, 1fr); }
.rpt-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 15px; padding: 15px; cursor: pointer; transition: box-shadow .15s var(--ease), border-color .15s var(--ease); }
.rpt-kpi:hover { border-color: #cfe6dc; }
.rpt-kpi.active { box-shadow: 0 0 0 2px var(--brand) inset; border-color: var(--brand); }
.rpt-kpi-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 15px; }
.rpt-kpi-val { font-size: 22px; font-weight: 700; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.rpt-kpi-unit { font-size: 11px; font-weight: 600; color: var(--muted); }
.rpt-kpi-label { font-size: 11.5px; color: var(--text-4); margin-top: 3px; }
@media (max-width: 1100px) { .rpt-kpis { grid-template-columns: repeat(3, 1fr); } .rpt-kpis.k4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .rpt-kpis, .rpt-kpis.k4 { grid-template-columns: 1fr 1fr; } }

/* المستند القابل للطباعة */
.doc-summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 22px; }
.doc-card { border-radius: 13px; padding: 16px; text-align: center; }
.doc-card-val { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.doc-card-label { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.doc-order { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; break-inside: avoid; page-break-inside: avoid; }
@media (max-width: 640px) { .doc-summary-grid { grid-template-columns: 1fr; } }

/* الطباعة: أظهر مستند التقرير فقط */
@media print {
  @page { margin: 14mm; }
  body { background: #fff !important; }
  body * { visibility: hidden !important; }
  .print-report, .print-report * { visibility: visible !important; }
  .print-report { position: absolute !important; inset: 0 !important; margin: 0 !important; padding: 0 !important; max-width: none !important; width: 100% !important; box-shadow: none !important; border: none !important; border-radius: 0 !important; max-height: none !important; overflow: visible !important; }
  .print-report .no-print { display: none !important; }
  .overlay { position: static !important; background: #fff !important; backdrop-filter: none !important; padding: 0 !important; display: block !important; }
  .doc-order { break-inside: avoid !important; page-break-inside: avoid !important; }
}

/* ---------- شاشة الدخول ---------- */
.login-screen { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 24px 18px; overflow: hidden;
  background: radial-gradient(130% 110% at 20% 0%, #12836d 0%, #0d5f50 44%, #0a4436 100%); }
.login-card { width: 100%; max-width: 900px; background: var(--surface); border-radius: 26px; overflow: hidden; display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); box-shadow: 0 30px 70px rgba(6,42,34,.4); animation: floatUp .7s ease both; position: relative; z-index: 2; }
.login-form-side { padding: 38px clamp(22px, 5vw, 40px) 34px; display: flex; flex-direction: column; justify-content: center; }
.login-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 24px; }
.login-brand .logo { width: 56px; height: 56px; border-radius: 16px; background: var(--brand-grad); color: var(--gold); display: grid; place-items: center; font-size: 27px; font-weight: 700; box-shadow: 0 12px 26px rgba(10,68,54,.35); }
.login-form-side h2 { font-size: 24px; font-weight: 700; letter-spacing: -.3px; text-align: center; margin-bottom: 6px; }
.login-form-side .sub { color: var(--text-4); text-align: center; margin-bottom: 28px; font-size: 14px; }
.login-err { background: var(--danger-bg); color: var(--danger); padding: 12px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; margin-bottom: 16px; display: none; }
.login-err.show { display: block; animation: floatUp .3s; }
.login-demo { margin-top: 24px; padding-top: 20px; border-top: 1px dashed var(--border-2); font-size: 13px; color: var(--muted); }
.login-demo b { color: var(--text-3); }
.login-demo .chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.login-demo .chip { background: var(--surface-2); border: 1px solid var(--border-2); padding: 5px 11px; border-radius: 9px; cursor: pointer; font-weight: 600; transition: all var(--t-fast); }
.login-demo .chip:hover { border-color: var(--brand); color: var(--brand); }
.login-hero { background: linear-gradient(160deg, #12836d, #0a4436); padding: 30px 26px; color: #fff; display: flex; flex-direction: column; gap: 16px; }
.login-hero .lh-head { display: flex; align-items: center; justify-content: space-between; }
.login-hero h3 { font-size: 16px; font-weight: 700; }
.login-hero .live { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: rgba(126,224,184,.14); border: 1px solid rgba(126,224,184,.3); font-size: 11.5px; font-weight: 600; color: #a9f0d0; }
.login-hero .live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #7ee0b8; animation: pulse 1.6s infinite; }
.login-hero .glass { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 16px; padding: 18px 16px; backdrop-filter: blur(4px); }
@media (max-width: 720px) { .login-hero { display: none; } }

/* احترام تفضيل تقليل الحركة (يزيل أي وميض/حركة مزعجة) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
