/* ═══════════════════════════════════════════════════════════════════════
   مسار (Masar) — نظام التصميم الموحّد
   هوية جامعة تُنسّق بين «سند» (زمرّدي) و«إنجاز» (نحاسي) تحت مظلّة واحدة.
   RTL أولاً · خط Readex Pro · ثنائي اللغة.
   ═══════════════════════════════════════════════════════════════════════ */
:root {
  /* محايدات */
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #f9fafd;
  --border: #e7e9f2; --border-strong: #d6d9e6;
  --text: #14162b; --text-soft: #3c4162; --muted: #7a809b;
  /* هوية مسار الجامعة (نيلي هادئ) + لكنة معدنية */
  --brand: #4f46e5; --brand-600: #4338ca; --brand-700: #3730a3; --brand-050: #eef0fe;
  --brand-2: #0ea5b8;
  /* لكنات الأنظمة */
  --sanad: #059669; --sanad-050: #e6f6ef;
  --enjaz: #b45309; --enjaz-050: #fbf1e5;
  /* دلالات */
  --green: #16a34a; --green-050: #e9f8ef;
  --red: #e11d48; --red-050: #fdecef;
  --amber: #d97706; --amber-050: #fdf2e3;
  --sky: #0284c7; --sky-050: #e6f3fb;
  /* أبعاد وتأثيرات */
  --radius: 18px; --radius-sm: 12px; --radius-xs: 9px;
  --shadow-xs: 0 1px 2px rgba(20,22,43,.05);
  --shadow: 0 2px 6px rgba(20,22,43,.05), 0 12px 28px rgba(20,22,43,.06);
  --shadow-lg: 0 18px 48px rgba(20,22,43,.16);
  --ring: 0 0 0 4px var(--brand-050);
  --hero-1: #1e1b4b; --hero-2: #4f46e5; --hero-3: #0ea5b8;
}
:root[data-theme="dark"] {
  --bg: #0d0f1c; --surface: #14172a; --surface-2: #191d33;
  --border: #262b45; --border-strong: #333a5c;
  --text: #eef0fa; --text-soft: #c2c7de; --muted: #8b91b0;
  --brand: #7c78f0; --brand-600: #918dff; --brand-700: #a6a2ff; --brand-050: #20223f;
  --sanad-050: #10261d; --enjaz-050: #2a1c0d;
  --green-050: #10261a; --red-050: #2b1119; --amber-050: #2a1d0b; --sky-050: #0c2231;
  --shadow: 0 2px 6px rgba(0,0,0,.3), 0 12px 30px rgba(0,0,0,.4);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.55);
  --ring: 0 0 0 4px rgba(124,120,240,.18);
}

* { box-sizing: border-box; }
html { font-size: clamp(14px, 1.5vw, 15.5px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); min-height: 100vh;
  font-family: "Readex Pro", "Inter", "Segoe UI", Tahoma, system-ui, sans-serif;
  line-height: 1.7; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
html[dir="ltr"] body { font-family: "Inter", "Readex Pro", system-ui, sans-serif; line-height: 1.6; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; font-weight: 700; }
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
small.muted { font-size: .82rem; }

/* شعار مسار — رمز «مسار/طريق» بسيط */
.logo { width: 40px; height: 40px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--hero-2), var(--hero-3));
  position: relative; box-shadow: var(--shadow-xs); }
.logo::after { content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 30% 32%, #fff 3px, transparent 3.5px),
    radial-gradient(circle at 70% 68%, #fff 3px, transparent 3.5px);
}
.logo::before { content: ""; position: absolute; inset: 0;
  background: linear-gradient(45deg, transparent 44%, rgba(255,255,255,.85) 44%, rgba(255,255,255,.85) 50%, transparent 50%); }
.logo--lg { width: 60px; height: 60px; border-radius: 18px; }

/* ═══════════ تسجيل الدخول ═══════════ */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.auth__hero {
  background: linear-gradient(155deg, var(--hero-1), var(--hero-2) 62%, var(--hero-3));
  color: #fff; padding: clamp(28px, 5vw, 64px); display: flex; flex-direction: column; gap: 28px;
  position: relative; overflow: hidden;
}
.auth__hero::after { content: ""; position: absolute; inset: 0; opacity: .5;
  background: radial-gradient(60% 50% at 85% 15%, rgba(255,255,255,.16), transparent),
              radial-gradient(50% 40% at 10% 90%, rgba(14,165,184,.35), transparent); }
.auth__brand { display: flex; align-items: center; gap: 16px; position: relative; z-index: 1; }
.auth__title { font-size: 2.4rem; line-height: 1; }
.auth__subtitle { margin: 6px 0 0; color: rgba(255,255,255,.82); font-size: 1rem; }
.auth__points { list-style: none; margin: auto 0; padding: 0; display: grid; gap: 16px; position: relative; z-index: 1; font-size: 1.05rem; }
.auth__points li { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.94); }
.auth__points b { font-weight: 700; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--c, #fff); box-shadow: 0 0 0 4px rgba(255,255,255,.14); flex: none; }
.auth__foot { position: relative; z-index: 1; color: rgba(255,255,255,.6); font-size: .82rem; letter-spacing: .04em; }
.auth__panel { display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth__card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: clamp(24px, 4vw, 38px); }
.auth__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.auth__head h2 { font-size: 1.5rem; }
.auth__demos { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ═══════════ عناصر عامة ═══════════ */
.form { display: grid; gap: 16px; margin-top: 20px; }
.field { display: grid; gap: 7px; font-size: .9rem; font-weight: 500; color: var(--text-soft); }
.field input {
  padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: .98rem; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: .95rem; font-weight: 600; transition: transform .08s, background .15s, box-shadow .15s, border-color .15s; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.28); }
.btn--primary:hover { background: var(--brand-600); }
.btn--ghost { background: transparent; border-color: var(--border-strong); color: var(--text-soft); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--block { width: 100%; padding: 13px; }
.btn--sm { padding: 7px 12px; font-size: .85rem; }
.btn[disabled] { opacity: .6; pointer-events: none; }

.langbtn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft);
  border-radius: 999px; padding: 5px 13px; font-size: .8rem; font-weight: 600; }
.langbtn:hover { border-color: var(--brand); color: var(--brand); }
.auth__hero .langbtn { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.25); color: #fff; }

.chip { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft);
  border-radius: 999px; padding: 6px 12px; font-size: .82rem; font-weight: 500; }
.chip:hover { border-color: var(--brand); color: var(--brand); }

.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: .9rem; }
.alert--err { background: var(--red-050); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 25%, transparent); }

/* ═══════════ البوابة ═══════════ */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 12px clamp(16px, 4vw, 40px); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar__brand { display: flex; align-items: center; gap: 10px; }
.topbar__brand .logo { width: 30px; height: 30px; border-radius: 9px; }
.topbar__name { font-weight: 700; font-size: 1.15rem; }
.user { display: flex; align-items: center; gap: 10px; }
.user__meta { display: flex; flex-direction: column; line-height: 1.25; text-align: start; }
.user__meta b { font-size: .9rem; }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700; font-size: .95rem; }

.page { flex: 1; width: min(1120px, 100%); margin: 0 auto; padding: clamp(20px, 4vw, 38px); }
.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.page__head h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
.page__head p { margin: 6px 0 0; max-width: 60ch; }
.section-title { font-size: 1.15rem; margin: 34px 0 16px; }

/* مشغّل الأنظمة */
.apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.appcard { position: relative; display: flex; flex-direction: column; gap: 14px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-xs); transition: transform .12s, box-shadow .18s, border-color .18s; }
.appcard::before { content: ""; position: absolute; inset-inline-start: 0; inset-block: 0; width: 5px; background: var(--accent, var(--brand)); }
.appcard:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.appcard__top { display: flex; align-items: center; gap: 13px; }
.appicon { width: 46px; height: 46px; border-radius: 13px; flex: none; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.appicon svg { width: 24px; height: 24px; }
.appcard__title { font-size: 1.2rem; }
.appcard__title small { display: block; font-weight: 500; font-size: .82rem; color: var(--muted); letter-spacing: .02em; }
.appcard__desc { color: var(--text-soft); font-size: .92rem; margin: 0; }
.appcard__foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 600; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--gray, #9aa2bd); }
.status--up { color: var(--green); } .status--up::before { background: var(--green); box-shadow: 0 0 0 3px var(--green-050); }
.status--down { color: var(--red); } .status--down::before { background: var(--red); }
.open-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--accent); }
.open-link:hover { gap: 9px; }

/* اللوحة الموحّدة */
.overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.ocard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); overflow: hidden; }
.ocard__head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.ocard__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: none; }
.ocard__head b { font-size: 1.02rem; }
.ocard__head .muted { margin-inline-start: auto; font-size: .82rem; }
.ocard__body { padding: 20px; }
.hero-stat { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.hero-stat b { font-size: 2.4rem; font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.hero-stat span { color: var(--muted); font-size: .9rem; }
.mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.mini { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 11px 12px; text-align: center; }
.mini b { display: block; font-size: 1.3rem; font-weight: 700; }
.mini span { font-size: .76rem; color: var(--muted); }
.mini--green b { color: var(--green); } .mini--red b { color: var(--red); }
.mini--amber b { color: var(--amber); } .mini--sky b { color: var(--sky); }
.recent { margin-top: 18px; display: grid; gap: 2px; }
.recent__item { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-top: 1px dashed var(--border); font-size: .88rem; }
.recent__item:first-child { border-top: none; }
.recent__item .t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent__item .m { color: var(--muted); font-size: .8rem; flex: none; }
.badge { font-size: .72rem; padding: 2px 9px; border-radius: 999px; font-weight: 600; background: var(--brand-050); color: var(--brand-700); flex: none; }
.ocard--down .ocard__body { color: var(--muted); text-align: center; padding: 34px 20px; }

.foot { border-top: 1px solid var(--border); padding: 16px clamp(16px, 4vw, 40px); display: flex; justify-content: space-between; gap: 12px; font-size: .82rem; color: var(--muted); }

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius); min-height: 150px; border: 1px solid var(--border); }
.skeleton::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--border) 60%, transparent), transparent); animation: sweep 1.3s infinite; }
@keyframes sweep { 100% { transform: translateX(-100%); } }
html[dir="ltr"] @keyframes sweep { 100% { transform: translateX(100%); } }

/* ═══════════ التنقّل ═══════════ */
.nav { display: flex; align-items: center; gap: 4px; margin-inline-start: 10px; }
.nav__btn { background: transparent; border: 1px solid transparent; color: var(--text-soft); border-radius: 999px; padding: 8px 16px; font-size: .92rem; font-weight: 600; }
.nav__btn:hover { background: var(--surface-2); color: var(--text); }
.nav__btn--on { background: var(--brand-050); color: var(--brand-700); }
.nav__btn--cta { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.25); }
.nav__btn--cta:hover { background: var(--brand-600); color: #fff; }
.nav__btn--cta.nav__btn--on { background: var(--brand-600); color: #fff; }

/* ═══════════ عملي ═══════════ */
.wgroup { margin-bottom: 26px; }
.wgroup__title { font-size: 1.05rem; display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding-inline-start: 12px; border-inline-start: 4px solid var(--accent, var(--brand)); }
.wgroup__title .count { font-size: .78rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); border-radius: 999px; padding: 1px 10px; }
.wlist { display: grid; gap: 8px; }
.wrow { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow-xs); }
.wrow__body { flex: 1; min-width: 0; }
.wrow__main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wrow__code { font-size: .78rem; color: var(--muted); font-weight: 600; font-family: "Inter", monospace; }
.wrow__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46ch; }
.wrow__meta { font-size: .8rem; color: var(--muted); margin-top: 3px; display: flex; align-items: center; gap: 6px; }
.wrow__act { display: flex; align-items: center; gap: 6px; flex: none; }
.systag { font-size: .72rem; font-weight: 700; padding: 2px 9px; border-radius: 6px; }
.systag--sanad { background: var(--sanad-050); color: var(--sanad); }
.systag--enjaz { background: var(--enjaz-050); color: var(--enjaz); }
.chip--link { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand-700); border-color: transparent; font-size: .74rem; padding: 2px 9px; }
.empty { text-align: center; color: var(--muted); padding: 22px; background: var(--surface-2); border: 1px dashed var(--border); border-radius: var(--radius-sm); font-size: .9rem; }
.btn--ok { background: var(--green); color: #fff; } .btn--ok:hover { filter: brightness(.94); }
.btn--danger { background: var(--red); color: #fff; } .btn--danger:hover { filter: brightness(.94); }

/* ═══════════ جديد (النماذج) ═══════════ */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 4px; gap: 4px; margin-bottom: 20px; }
.seg { display: inline-flex; align-items: center; gap: 8px; border: none; background: transparent; color: var(--text-soft); border-radius: 999px; padding: 9px 20px; font-weight: 600; font-size: .95rem; }
.seg__ic { display: inline-flex; } .seg__ic svg { width: 18px; height: 18px; }
.seg--on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.formcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); padding: clamp(18px, 3vw, 28px); max-width: 720px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 .span2 { grid-column: 1 / -1; }
.field textarea, .field select { padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; font-size: .96rem; }
.field textarea:focus, .field select:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.field select { cursor: pointer; }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .92rem; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.check input { margin-top: 4px; width: 17px; height: 17px; accent-color: var(--brand); flex: none; }
.approvalBox { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 16px; border: 1px dashed var(--sanad); border-radius: var(--radius-sm); background: var(--sanad-050); }
.formfoot { display: flex; justify-content: flex-end; }

/* ═══════════ إشعارات + حوار ═══════════ */
.toasts { position: fixed; inset-block-end: 20px; inset-inline-start: 20px; z-index: 90; display: grid; gap: 10px; }
.toast { background: var(--text); color: var(--surface); padding: 12px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .9rem; font-weight: 500; max-width: 460px; animation: toastIn .3s ease; }
.toast--err { background: var(--red); color: #fff; }
.toast--ok { background: #0f2f24; color: #fff; }
:root[data-theme="dark"] .toast--ok { background: #16a34a; }
.toast--out { opacity: 0; transform: translateY(8px); transition: .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }
.modal-root { position: fixed; inset: 0; z-index: 100; background: rgba(10,12,24,.5); display: grid; place-items: center; padding: 20px; backdrop-filter: blur(3px); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 22px; width: min(440px, 100%); }
.modal h3 { margin-bottom: 12px; }
.modal textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); padding: 11px; font: inherit; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ═══════════════════════════════════════════════════════════════════════
   مساحة العمل المدمجة (Workspace)
   ═══════════════════════════════════════════════════════════════════════ */
.ws { display: flex; min-height: 100vh; }

/* الشريط الجانبي (يمين في RTL) */
.ws__side { width: 264px; flex: none; display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--hero-1), #171a35 60%, #12142a); color: #eef0fa;
  border-inline-start: 1px solid rgba(255,255,255,.06); position: sticky; top: 0; height: 100vh; z-index: 40; }
.ws__brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,.08); }
.ws__brand .topbar__name { color: #fff; font-size: 1.2rem; font-weight: 700; }
.icon-x { margin-inline-start: auto; background: transparent; border: 0; color: rgba(255,255,255,.6); font-size: 1rem; display: none; }
.ws__nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 4px; }
.ws__nav::-webkit-scrollbar { width: 7px; } .ws__nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

.nv { display: flex; align-items: center; gap: 10px; width: 100%; text-align: start; border: 0; background: transparent;
  color: rgba(255,255,255,.82); border-radius: 10px; padding: 9px 12px; font: inherit; font-size: .9rem; font-weight: 500; transition: background .12s, color .12s; }
.nv:hover { background: rgba(255,255,255,.07); color: #fff; }
.nv--on { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent, var(--brand-400)); }
.nv--top { font-weight: 600; }
.nv__ic { display: inline-flex; } .nv__ic svg { width: 18px; height: 18px; }

.nvgroup { margin: 6px 0 2px; }
/* رأس المجموعة زرّ قابل للنقر يطوي/يفتح تبويبات النظام */
.nvgroup__head { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; border: 0; background: transparent;
  font: inherit; font-size: .78rem; font-weight: 700; letter-spacing: .02em; color: rgba(255,255,255,.6); text-transform: uppercase;
  border-radius: 10px; cursor: pointer; transition: background .12s, color .12s; }
.nvgroup__head:hover { background: rgba(255,255,255,.06); color: #fff; }
.nvgroup__head.has-active { color: #fff; }
.nvgroup__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.nvgroup__ttl { flex: 1; text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nvgroup__st { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.nvgroup__st.up { background: #34d399; } .nvgroup__st.down { background: #f87171; }
.nvgroup__chev { flex: none; font-size: .7rem; color: rgba(255,255,255,.5); transition: transform .2s ease; }
.nvgroup.collapsed .nvgroup__chev { transform: rotate(-90deg); }
html[dir="ltr"] .nvgroup.collapsed .nvgroup__chev { transform: rotate(90deg); }
/* حاوية الطيّ — حركة ارتفاع سلسة عبر grid-template-rows */
.nvgroup__wrap { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .22s ease; }
.nvgroup.collapsed .nvgroup__wrap { grid-template-rows: 0fr; }
.nvgroup__items { overflow: hidden; display: flex; flex-direction: column; gap: 2px; padding-inline-start: 6px; min-height: 0; }
.nvgroup:not(.collapsed) .nvgroup__items { padding-top: 2px; padding-bottom: 4px; }
.nvgroup .nv { font-size: .88rem; padding: 8px 12px; }

.ws__foot { border-top: 1px solid rgba(255,255,255,.08); padding: 12px; display: grid; gap: 10px; }
.ws__foot .langbtn { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.16); color: #fff; justify-self: start; }
.ws__user { display: flex; align-items: center; gap: 10px; }
.ws__user .user__meta b { color: #fff; font-size: .88rem; } .ws__user .user__meta small { color: rgba(255,255,255,.55); }
.ws__foot .btn--ghost { border-color: rgba(255,255,255,.18); color: rgba(255,255,255,.85); }
.ws__foot .btn--ghost:hover { background: rgba(255,255,255,.08); color: #fff; }

/* المنطقة الرئيسية */
.ws__main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }
.ws__bar { display: flex; align-items: center; gap: 12px; padding: 0 clamp(12px, 3vw, 20px); height: 56px; flex: none;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.ws__crumb { font-size: 1.02rem; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws__health { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.burger { display: none; background: transparent; border: 1px solid var(--border); color: var(--text-soft); border-radius: 9px; width: 36px; height: 36px; font-size: 1.1rem; }
.ws__sub { flex: none; display: flex; align-items: center; gap: 14px; padding: 10px 20px; background: var(--surface-2); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ws__stage { flex: 1; position: relative; min-height: 0; background: var(--bg); }
.ws__frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: var(--surface); display: block; }
/* اللوح لا ينزلق أفقياً أبداً — الجداول العريضة تنزلق داخل حاوياتها فقط. */
.ws__panel { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: clamp(16px, 3vw, 32px); }
.ws__panel > * { max-width: 100%; }
/* حاويات الجداول: انزلاق أفقي للجدول فقط مع بقاء العناوين والأزرار ثابتة. */
#usersList, #rolesList, #auditList { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.utable { min-width: 560px; }

.ws__scrim { display: none; position: fixed; inset: 0; background: rgba(10,12,24,.5); z-index: 39; }
.ws__scrim.show { display: block; }

/* الإدارة الموحّدة: التبويبات الفرعية */
.segmented.sm { padding: 3px; }
.segmented.sm .seg { padding: 6px 16px; font-size: .88rem; }
.segmented.sm .seg--on { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--sc) 55%, transparent); color: var(--sc); }
.subtabs { display: flex; gap: 4px; flex-wrap: wrap; }
.subtab { border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: .84rem; font-weight: 600; }
.subtab:hover { border-color: var(--brand); color: var(--brand); }
.subtab--on { background: var(--brand); color: #fff; border-color: transparent; }

/* اللوحة الموحّدة (داخل اللوح) */
.dash__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.dash__head h1 { font-size: clamp(1.3rem, 3vw, 1.7rem); } .dash__head p { margin: 5px 0 0; max-width: 60ch; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 22px; }
.qcard { background: var(--surface); border: 1px solid var(--border); border-inline-start: 4px solid var(--accent); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-xs); }
.qcard > b { font-size: 1.05rem; }
.qcard__links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.qbtn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: .85rem; font-weight: 600; }
.qbtn:hover { border-color: var(--accent); color: var(--accent); }

/* إدارة المستخدمين الموحّدة */
.utable { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-xs); }
.utable th, .utable td { text-align: start; padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: .9rem; }
.utable th { background: var(--surface-2); font-size: .78rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.utable tbody tr:last-child td, .utable tbody tr:last-child td { border-bottom: 0; }
.utable .mono { font-family: "Inter", monospace; font-size: .84rem; color: var(--text-soft); }
.dash-line { color: var(--faint, var(--muted)); }
.rolebadge { display: inline-block; font-size: .78rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.rolebadge--employee { background: var(--sky-050); color: var(--sky); }
.rolebadge--manager { background: var(--amber-050); color: var(--amber); }
.rolebadge--admin { background: var(--brand-050); color: var(--brand-700); }
.rolebadge.off { opacity: .5; text-decoration: line-through; }
.rolechip { font-size: .8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-soft); }
.permchip { display: inline-block; font-size: .72rem; font-family: "Inter", monospace; padding: 1px 7px; border-radius: 6px; background: var(--brand-050); color: var(--brand-700); margin: 1px 0; }
.permgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; margin-top: 8px; }
.permopt { display: flex; align-items: flex-start; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: .88rem; cursor: pointer; }
.permopt input { margin-top: 3px; accent-color: var(--brand); }
.auditbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.auditbar input, .auditbar select { padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; font-size: .88rem; }
.actionchip { font-family: "Inter", monospace; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--brand-050); color: var(--brand-700); }
.actionchip.bad { background: var(--red-050); color: var(--red); }
.stcode { font-family: "Inter", monospace; font-size: .78rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; }
.stcode.st2 { background: var(--green-050); color: var(--green); }
.stcode.st4, .stcode.st5 { background: var(--red-050); color: var(--red); }
.stcode.st3 { background: var(--amber-050); color: var(--amber); }

.ucard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); padding: 20px; margin-bottom: 18px; }
.ugrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.usys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.usys { border: 1px solid var(--border); border-inline-start: 4px solid var(--sc); border-radius: var(--radius-sm); padding: 14px; background: var(--surface-2); }
.usys > b { display: block; margin-bottom: 8px; }
.usys select[data-lvl] { width: 100%; }
.about-card { max-width: 620px; }
.about-brand { display: flex; align-items: center; gap: 16px; }
.about-logo { width: 64px; height: 64px; border-radius: 16px; display: grid; place-items: center; font-weight: 800; font-size: 1.4rem; color: #fff; background: linear-gradient(135deg, #4f46e5, #0d9488); flex: none; }
.about-sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.about-by { font-size: 1rem; line-height: 1.9; }
.about-contact { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.about-contact a { display: inline-flex; align-items: center; gap: 10px; color: var(--primary); text-decoration: none; font-size: .95rem; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); width: fit-content; }
.about-contact a:hover { border-color: var(--primary); }
.uadmin { display: flex; align-items: center; gap: 12px; margin: 16px 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; }
.uadmin input { width: 18px; height: 18px; flex: none; }
.uadmin span { display: flex; flex-direction: column; }
.uadmin small { margin-top: 2px; }
.usys .check { background: transparent; border: 0; padding: 0 0 12px; }
.usys__body { display: grid; gap: 12px; transition: opacity .15s; }
.ucard__title { font-weight: 700; font-size: 1.05rem; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.utable--click tbody tr { cursor: pointer; transition: background .12s; }
.utable--click tbody tr:hover { background: var(--brand-050); }
.edit-cell { color: var(--brand); font-size: .82rem; font-weight: 600; white-space: nowrap; text-align: end; }

/* الملف الشخصي */
.prof-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.prof-av h3, .prof-grid h3 { font-size: 1rem; margin-bottom: 14px; }
.prof-av__row { display: flex; align-items: center; gap: 16px; }
.prof-avatar { width: 84px; height: 84px; border-radius: 50%; flex: none; display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 700; font-size: 1.8rem; }
.prof-avatar img { width: 100%; height: 100%; object-fit: cover; }
.prof-pw { display: grid; gap: 12px; }
@media (max-width: 760px) { .prof-grid { grid-template-columns: 1fr; } }

@media (max-width: 760px) { .ugrid, .usys-grid { grid-template-columns: 1fr; } }

@media (max-width: 900px) {
  .ws__side { position: fixed; inset-inline-end: 0; top: 0; height: 100vh; width: min(300px, 84vw); transform: translateX(100%); transition: transform .22s; box-shadow: var(--shadow-lg); }
  html[dir="ltr"] .ws__side { inset-inline-start: 0; inset-inline-end: auto; transform: translateX(-100%); }
  .ws__side.open { transform: translateX(0); }
  .icon-x { display: block; }
  .burger { display: inline-flex; align-items: center; justify-content: center; }
}
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth__hero { min-height: 180px; padding: 22px; }
  .auth__points { display: none; }
  .grid2, .approvalBox, .ugrid, .usys-grid, .prof-grid, .permgrid { grid-template-columns: 1fr; }
  .quick, .overview, .apps { grid-template-columns: 1fr; }
  .ws__sub { padding: 8px 14px; gap: 8px; }
  .mini-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .ws__health { display: none; }
  .dash__head h1 { font-size: 1.25rem; }
  .utable th, .utable td { padding: 10px 12px; font-size: .85rem; }
  .subtab { padding: 5px 11px; font-size: .8rem; }
}
