/* ==========================================================================
   نظام إدارة الشبكة — نظام التصميم
   RTL · وضع فاتح وداكن · متجاوب
   ========================================================================== */

@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap;
  src: url("../fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap;
  src: url("../fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap;
  src: url("../fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap;
  src: url("../fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Plex Arabic"; font-weight: 400; font-display: swap;
  src: url("../fonts/ibm-plex-sans-arabic-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20AA, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 500; font-display: swap;
  src: url("../fonts/ibm-plex-sans-arabic-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20AA, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 600; font-display: swap;
  src: url("../fonts/ibm-plex-sans-arabic-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20AA, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-weight: 700; font-display: swap;
  src: url("../fonts/ibm-plex-sans-arabic-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+20AA, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* --------------------------------------------------------------------------
   الرموز اللونية
   -------------------------------------------------------------------------- */
:root {
  --font: "Plex Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --radius-xs: 5px;
  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 14px;

  --sidebar-w: 268px;
  --topbar-h: 60px;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --hover: #f1f5fb;
  --border: #e3e8ef;
  --border-strong: #cdd5e0;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  --primary: #2453d6;
  --primary-hover: #1c45b8;
  --primary-soft: #e9effd;
  --primary-ring: rgba(36, 83, 214, .22);
  --on-primary: #ffffff;

  --success: #15803d;  --success-soft: #e6f5ec;
  --warning: #b45309;  --warning-soft: #fdf2e1;
  --danger: #c62828;   --danger-soft: #fdeaea;
  --info: #0e7490;     --info-soft: #e2f3f7;
  --violet: #6d28d9;   --violet-soft: #f1eafd;
  --neutral: #475569;  --neutral-soft: #eef1f5;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow: 0 4px 14px rgba(15, 23, 42, .07);
  --shadow-lg: 0 18px 48px rgba(15, 23, 42, .16);

  --sidebar-bg: var(--surface);
  --sidebar-border: var(--border);
  --sidebar-text: var(--text-2);
  --sidebar-muted: var(--muted);
  --sidebar-hover: var(--hover);
  --sidebar-active-bg: var(--primary-soft);
  --sidebar-active: var(--primary);
  --sidebar-accent: var(--primary);

  --chart-1: #2453d6;
  --chart-2: #0f9d8a;
  --chart-3: #d97706;
  --chart-4: #9333ea;
  --chart-5: #dc2626;
  --chart-grid: #e8edf3;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1020;
  --surface: #121a2b;
  --surface-2: #161f33;
  --surface-3: #1c2740;
  --hover: #1a2439;
  --border: #233049;
  --border-strong: #31405f;
  --text: #e8edf6;
  --text-2: #c4cee0;
  --muted: #8b98b2;
  --faint: #66738f;

  --primary: #5383ff;
  --primary-hover: #6d96ff;
  --primary-soft: rgba(83, 131, 255, .15);
  --primary-ring: rgba(83, 131, 255, .32);
  --on-primary: #ffffff;

  --success: #3cc37d;  --success-soft: rgba(60, 195, 125, .14);
  --warning: #f1aa45;  --warning-soft: rgba(241, 170, 69, .14);
  --danger: #f26b6b;   --danger-soft: rgba(242, 107, 107, .14);
  --info: #3fc4dd;     --info-soft: rgba(63, 196, 221, .14);
  --violet: #ae91fb;   --violet-soft: rgba(174, 145, 251, .14);
  --neutral: #a3b0c7;  --neutral-soft: rgba(163, 176, 199, .12);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
  --shadow: 0 6px 18px rgba(0, 0, 0, .35);
  --shadow-lg: 0 20px 56px rgba(0, 0, 0, .55);


  --chart-1: #5d8bff;
  --chart-2: #2ec4a9;
  --chart-3: #f2a73f;
  --chart-4: #b48cff;
  --chart-5: #f26b6b;
  --chart-grid: #1f2a40;

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   الأساس
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 600; color: var(--text); }
h1 { font-size: 21px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 .75em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
img { max-width: 100%; }
code, .mono, kbd {
  font-family: var(--mono);
  font-size: .92em;
  direction: ltr;
  unicode-bidi: isolate;
}
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
[dir="rtl"] div.mono, [dir="rtl"] dd.mono, [dir="rtl"] td.mono, [dir="rtl"] th.mono { text-align: right; }
.icon {
  width: 18px; height: 18px;
  flex: none;
  vertical-align: middle;
  stroke: currentColor;
}
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 30px; height: 30px; }
::selection { background: var(--primary-ring); }
/* بدون مربع أزرق عند الضغط أو اللمس على أي عنصر */
html { -webkit-tap-highlight-color: transparent; }
:focus, :focus-visible { outline: none; }

/* شريط التمرير */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* --------------------------------------------------------------------------
   الهيكل العام
   -------------------------------------------------------------------------- */
.shell { min-height: 100vh; display: flex; }

.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .22s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--sidebar-border);
  color: var(--text);
}
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #3a6cf0, #2a48c0);
  color: #fff; flex: none;
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { min-width: 0; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 11.5px; color: var(--sidebar-muted); }

.sidebar-nav { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 10px 10px 18px; }
.nav-group { margin-top: 10px; }
.nav-group-title {
  font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: var(--sidebar-muted);
  padding: 8px 12px 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  margin: 1px 0;
  position: relative;
}
.nav-link .icon { width: 18px; height: 18px; opacity: .85; }
.nav-link:hover { background: var(--sidebar-hover); color: var(--text); }
.nav-link.is-active { background: var(--sidebar-active-bg); color: var(--sidebar-active); font-weight: 600; }
.nav-link.is-active .icon { color: var(--sidebar-accent); opacity: 1; }
.nav-link.is-active::before {
  content: ""; position: absolute; inset-inline-start: -10px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px; background: var(--sidebar-accent);
}
.nav-badge {
  margin-inline-start: auto;
  font-size: 11px; font-weight: 600;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; display: inline-grid; place-items: center;
  background: var(--surface-3); color: var(--text-2);
}
.nav-badge.is-danger { background: var(--danger); color: #fff; }
.sidebar-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 11.5px; color: var(--sidebar-muted);
  display: flex; justify-content: space-between; gap: 8px;
}

.main { flex: 1; min-width: 0; margin-inline-start: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
@supports not (background: color-mix(in srgb, red 50%, blue)) {
  .topbar { background: var(--surface); }
}
.topbar-search { flex: 1; max-width: 460px; position: relative; }
.topbar-search .icon { position: absolute; inset-inline-start: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.topbar-search input {
  width: 100%; height: 38px;
  padding-inline-start: 38px; padding-inline-end: 12px;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font: inherit;
}
.topbar-search input:focus { outline: none; border-color: var(--primary); background: var(--surface); }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 9px;
  display: inline-grid; place-items: center;
  border: 1px solid transparent; background: transparent; color: var(--text-2);
  cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 7px; inset-inline-end: 7px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}
.menu-toggle { display: none; }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 6px 4px 10px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text);
  cursor: pointer; font: inherit;
}
.user-chip:hover { background: var(--hover); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
  font-weight: 700; font-size: 13px; flex: none;
}
.user-chip-name { font-size: 13px; font-weight: 500; line-height: 1.2; text-align: start; }
.user-chip-role { font-size: 11.5px; color: var(--muted); line-height: 1.2; }

.content { padding: 24px; flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; }
.content.is-wide { max-width: none; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.page-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.page-title h1 { display: flex; align-items: center; gap: 10px; }
.page-sub { color: var(--muted); font-size: 13px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--primary); }
.crumbs .icon { width: 13px; height: 13px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.backdrop { display: none; }

/* القائمة الجانبية المخفية على كل المقاسات: تُفتح بزر القائمة (قابل للإيقاف من الإعدادات) */
/* المخفية لا تُرسم وهي خارج الشاشة، فتُرسم كاملة من جديد عند كل فتح */
.sidebar-hidden .sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); visibility: hidden; will-change: transform; transition: transform .22s ease, visibility 0s linear .22s; }
[dir="ltr"] .sidebar-hidden .sidebar { transform: translateX(-100%); }
.sidebar-hidden.sidebar-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease, visibility 0s; }
body.sidebar-open { overflow: hidden; }
.sidebar-hidden .main { margin-inline-start: 0; }
.sidebar-hidden .menu-toggle { display: inline-grid; }
.sidebar-hidden.sidebar-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(8, 13, 28, .5); z-index: 35; }

/* --------------------------------------------------------------------------
   الأزرار
   -------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px;
  border-radius: 9px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-weight: 500; font-size: 13.5px;
  cursor: pointer; white-space: nowrap;
  transition: background-color .15s, border-color .15s, box-shadow .15s, color .15s;
  text-decoration: none;
  user-select: none;
}
.btn:hover { background: var(--hover); color: var(--btn-fg); }
.btn:focus-visible { outline: none; }
.btn:disabled, .btn.is-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn .icon { width: 17px; height: 17px; }
.btn-primary { --btn-bg: var(--primary); --btn-fg: var(--on-primary); --btn-border: var(--primary); box-shadow: var(--shadow-xs); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); color: #fff; }
.btn-success { --btn-bg: var(--success); --btn-fg: #fff; --btn-border: var(--success); }
.btn-success:hover { background: color-mix(in srgb, var(--success) 88%, #000); color: #fff; }
.btn-soft { --btn-bg: var(--primary-soft); --btn-fg: var(--primary); --btn-border: transparent; }
.btn-soft:hover { background: var(--primary-soft); filter: brightness(.97); }
.btn-soft-danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-border: transparent; }
.btn-soft-danger:hover { background: var(--danger-soft); filter: brightness(.96); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover { background: var(--hover); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; gap: 5px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-xs { height: 27px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 4px; }
.btn-xs .icon { width: 14px; height: 14px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 32px; }
.btn-icon.btn-xs { width: 27px; }
.btn-block { width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 16px; height: 16px;
  border: 2px solid currentColor; border-color: var(--btn-fg); border-inline-end-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-start-start-radius: 9px; border-end-start-radius: 9px; }
.btn-group .btn:last-child { border-start-end-radius: 9px; border-end-end-radius: 9px; }
.btn-group .btn + .btn { margin-inline-start: -1px; }

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   النماذج
   -------------------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 18px; }
.col-12 { grid-column: span 12; } .col-9 { grid-column: span 9; } .col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; }
.col-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label {
  font-size: 13px; font-weight: 500; color: var(--text-2);
  display: flex; align-items: center; gap: 6px;
}
.req { color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--danger); }
.input, select.input, textarea.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 92px; padding: 10px 12px; line-height: 1.6; resize: vertical; }
select.input {
  appearance: none; -webkit-appearance: none;
  padding-inline-end: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 11px center;
}
[dir="ltr"] select.input { background-position: right 11px center; }
select.input[multiple] { height: auto; min-height: 120px; padding: 6px; background-image: none; }
.input:focus { outline: none; border-color: var(--primary); }
.input::placeholder { color: var(--faint); }
.input:disabled, .input[readonly] { background: var(--surface-2); color: var(--muted); }
.input.is-invalid { border-color: var(--danger); }
.input-sm { height: 32px; font-size: 13px; padding: 0 10px; border-radius: 8px; }
select.input-sm { padding-inline-end: 30px; background-position: left 8px center; }
.input-ltr { direction: ltr; text-align: left; }
.input-ltr::placeholder { text-align: left; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 0; flex: 1; min-width: 0; }
.input-group > :first-child { border-start-start-radius: 9px; border-end-start-radius: 9px; }
.input-group > :last-child { border-start-end-radius: 9px; border-end-end-radius: 9px; }
.input-group > * + * { margin-inline-start: -1px; }
.input-addon {
  display: grid; place-items: center; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  color: var(--muted); font-size: 13px; white-space: nowrap;
}
.input-group .btn { border-radius: 0; height: auto; }
.input-group > .btn:last-child { border-start-end-radius: 9px; border-end-end-radius: 9px; }
.input-group > select.input { flex: 0 0 auto; width: auto; }

.check {
  display: inline-flex; align-items: center; gap: 9px;
  cursor: pointer; font-size: 13.5px; color: var(--text); user-select: none;
}
.check input[type="checkbox"], .check input[type="radio"], .table input[type="checkbox"] {
  width: 17px; height: 17px; margin: 0; accent-color: var(--primary); cursor: pointer; flex: none;
}
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 38px; height: 22px; border-radius: 11px; flex: none;
  background: var(--border-strong); position: relative; transition: background .18s;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(-16px); }
[dir="ltr"] .switch input:checked + .track::after { transform: translateX(16px); }

.form-actions {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding-top: 18px; margin-top: 6px; border-top: 1px solid var(--border);
}
.form-section-title { font-size: 14px; font-weight: 600; color: var(--text); margin: 4px 0 -4px; grid-column: span 12; display: flex; align-items: center; gap: 8px; }
.form-section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 16px; }
.color-input { width: 46px; height: 40px; padding: 4px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; }

/* --------------------------------------------------------------------------
   اللوحات (البطاقات)
   -------------------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.panel + .panel { margin-top: 18px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.panel-head h2, .panel-head h3 { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.panel-head h2 .icon, .panel-head h3 .icon { color: var(--muted); }
.panel-head .sub { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-body { padding: 18px; }
.panel-body.tight { padding: 0; }
.panel-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 360px; }
.grid-side-main { grid-template-columns: 340px minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 18px; }

/* بطاقات المؤشرات */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 15px 16px; display: flex; gap: 13px; align-items: flex-start;
  box-shadow: var(--shadow-xs); min-width: 0; position: relative;
}
a.stat { color: inherit; }
a.stat:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.stat-icon {
  width: 42px; height: 42px; border-radius: 11px; flex: none;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.stat-icon .icon { width: 21px; height: 21px; }
.stat-icon.is-success { background: var(--success-soft); color: var(--success); }
.stat-icon.is-warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.is-danger { background: var(--danger-soft); color: var(--danger); }
.stat-icon.is-info { background: var(--info-soft); color: var(--info); }
.stat-icon.is-violet { background: var(--violet-soft); color: var(--violet); }
.stat-body { min-width: 0; flex: 1; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 23px; font-weight: 700; line-height: 1.25; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-meta .up { color: var(--success); }
.stat-meta .down { color: var(--danger); }

/* --------------------------------------------------------------------------
   الجداول
   -------------------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th, .table td { padding: 10px 14px; text-align: start; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table th {
  font-size: 12px; font-weight: 600; color: var(--muted);
  background: var(--surface-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table thead th:first-child { border-start-start-radius: 0; }
.table tbody tr:hover td { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.is-selected td { background: var(--primary-soft); }
.table td.num, .table th.num { text-align: end; }
.table .nowrap, .nowrap { white-space: nowrap; }
.table .w-check { width: 42px; }
.table .w-actions { width: 1%; white-space: nowrap; }
.table-compact th, .table-compact td { padding: 7px 12px; }
.table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.table .cell-title { font-weight: 500; color: var(--text); }
.table .cell-sub { font-size: 12px; color: var(--muted); }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }

.empty {
  text-align: center; padding: 48px 20px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty > .icon { width: 40px; height: 40px; color: var(--faint); stroke-width: 1.5; }
.empty-title { font-weight: 600; color: var(--text-2); font-size: 14.5px; }

/* شريط الفلاتر */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface); border-start-start-radius: var(--radius-lg); border-start-end-radius: var(--radius-lg); }
.filters .field { min-width: 150px; flex: 0 1 190px; }
.filters .field.grow { flex: 1 1 240px; }
.filters .field > label { font-size: 12px; color: var(--muted); }
.filters .input { height: 36px; font-size: 13px; }

/* شريط الإجراءات الجماعية */
.bulkbar {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 18px; background: var(--primary-soft); border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.bulkbar.is-visible { display: flex; }
.bulkbar strong { color: var(--primary); }

/* الترقيم */
.pager { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-info { font-size: 12.5px; color: var(--muted); }
.pager-links { display: flex; gap: 4px; margin-inline-start: auto; flex-wrap: wrap; }
.pager-link {
  min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border); color: var(--text-2); font-size: 13px; background: var(--surface);
}
.pager-link:hover { background: var(--hover); color: var(--text); }
.pager-link.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; }
.pager-link.is-disabled { opacity: .45; }
.pager-link .icon { width: 15px; height: 15px; }
.pager-gap { color: var(--muted); padding: 0 4px; align-self: center; }
.pager-per select { width: 78px; }

/* --------------------------------------------------------------------------
   الشارات
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 23px; padding: 0 9px; border-radius: 12px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral);
}
.badge .icon { width: 13px; height: 13px; }
.badge-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-violet  { background: var(--violet-soft);  color: var(--violet); }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }

.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--faint); }
.status-dot.is-online { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.status-dot.is-offline { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.status-dot.is-unknown { background: var(--faint); box-shadow: 0 0 0 3px var(--neutral-soft); }

/* --------------------------------------------------------------------------
   رسائل التنبيه داخل الصفحة
   -------------------------------------------------------------------------- */
.notice {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid transparent; font-size: 13.5px;
  background: var(--info-soft); color: var(--text); border-color: color-mix(in srgb, var(--info) 22%, transparent);
}
.notice > .icon { color: var(--info); margin-top: 2px; }
.notice-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.notice-success > .icon { color: var(--success); }
.notice-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.notice-warning > .icon { color: var(--warning); }
.notice-danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.notice-danger > .icon { color: var(--danger); }
.notice + .notice, .notice + .panel, .panel + .notice { margin-top: 14px; }
.notice-title { font-weight: 600; }

/* --------------------------------------------------------------------------
   قوائم القيم (مفتاح/قيمة)
   -------------------------------------------------------------------------- */
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 0; font-size: 13.5px; }
.kv > dt, .kv > dd { padding: 9px 0; border-bottom: 1px dashed var(--border); margin: 0; }
.kv > dt { color: var(--muted); padding-inline-end: 18px; }
.kv > dd { color: var(--text); font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.kv > dt:nth-last-child(2), .kv > dd:last-child { border-bottom: 0; }
.kv-2 { grid-template-columns: repeat(2, minmax(110px, max-content) 1fr); column-gap: 18px; }

/* --------------------------------------------------------------------------
   التبويبات
   -------------------------------------------------------------------------- */
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none; padding: 0 12px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 12px 12px; color: var(--muted); font-size: 13.5px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  background: none; border-top: 0; border-inline: 0; cursor: pointer; font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .icon { width: 16px; height: 16px; }
.tab .count { font-size: 11px; background: var(--surface-3); color: var(--text-2); padding: 0 7px; border-radius: 9px; }
.tab-count { display: inline-block; min-width: 20px; padding: 0 6px; margin-inline-start: 4px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font-size: 11.5px; line-height: 18px; text-align: center; font-weight: 500; }
.tab.is-active .tab-count { background: var(--primary-soft); color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

.segmented { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.segmented a, .segmented button, .segmented label {
  padding: 5px 12px; border-radius: 7px; font-size: 13px; color: var(--text-2);
  border: 0; background: none; cursor: pointer; font-family: inherit; display: inline-flex; align-items: center; gap: 6px;
}
.segmented .is-active, .segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); font-weight: 500; }
.segmented input { display: none; }
.segmented label span { padding: 5px 12px; border-radius: 7px; display: block; }
.segmented label { padding: 0; }

/* --------------------------------------------------------------------------
   القوائم المنسدلة
   -------------------------------------------------------------------------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0;
  min-width: 210px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  box-shadow: var(--shadow-lg); z-index: 60; display: none;
}
.dropdown-menu.align-start { inset-inline-end: auto; inset-inline-start: 0; }
.dropdown.is-open > .dropdown-menu { display: block; animation: pop .12s ease-out; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: 7px; border: 0; background: none;
  color: var(--text); font: inherit; font-size: 13.5px; text-align: start; cursor: pointer;
}
.dropdown-item:hover { background: var(--hover); color: var(--text); }
.dropdown-item .icon { color: var(--muted); width: 17px; height: 17px; }
.dropdown-item.is-danger { color: var(--danger); }
.dropdown-item.is-danger .icon { color: var(--danger); }
.dropdown-sep { height: 1px; background: var(--border); margin: 5px 2px; }
.dropdown-head { padding: 8px 10px 6px; font-size: 12px; color: var(--muted); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   النوافذ المنبثقة
   -------------------------------------------------------------------------- */
dialog.modal {
  border: 0; padding: 0; border-radius: 16px; width: min(560px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 40px);
}
dialog.modal.modal-lg { width: min(820px, calc(100vw - 32px)); }
dialog.modal.modal-sm { width: min(420px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(8, 13, 28, .55); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: pop .15s ease-out; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; display: flex; align-items: center; gap: 9px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 9px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-end-start-radius: 16px; border-end-end-radius: 16px; }
.modal-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--danger-soft); color: var(--danger); flex: none; }
.modal-icon.is-primary { background: var(--primary-soft); color: var(--primary); }
.confirm-body { display: flex; gap: 14px; align-items: flex-start; }
.confirm-text { font-size: 14px; color: var(--text-2); padding-top: 3px; }

/* --------------------------------------------------------------------------
   الإشعارات العائمة
   -------------------------------------------------------------------------- */
.toasts {
  position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px; max-width: min(400px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 13.5px;
  animation: toastIn .2s ease-out;
}
.toast .icon { margin-top: 2px; }
.toast-success .icon { color: var(--success); }
.toast-error .icon, .toast-danger .icon { color: var(--danger); }
.toast-warning .icon { color: var(--warning); }
.toast-info .icon { color: var(--info); }
.toast-close { margin-inline-start: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; display: grid; }
.toast.is-leaving { animation: toastOut .18s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* --------------------------------------------------------------------------
   مؤشرات التقدم والقياس
   -------------------------------------------------------------------------- */
.meter { height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--primary); transition: width .4s; }
.meter.is-success > span { background: var(--success); }
.meter.is-warning > span { background: var(--warning); }
.meter.is-danger > span { background: var(--danger); }
.meter-lg { height: 10px; border-radius: 6px; }
.meter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.meter-row strong { color: var(--text); font-weight: 600; }

.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--primary); animation: spin .7s linear infinite; display: inline-block; }
.loading-block { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px; color: var(--muted); }

.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* --------------------------------------------------------------------------
   عناصر متنوعة
   -------------------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); min-width: 0; }
.list-item:last-child { border-bottom: 0; }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 12px; color: var(--muted); }
.list-item-end { text-align: end; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.list-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); flex: none; }
.list-icon.is-success { background: var(--success-soft); color: var(--success); }
.list-icon.is-danger { background: var(--danger-soft); color: var(--danger); }
.list-icon.is-warning { background: var(--warning-soft); color: var(--warning); }
.list-icon.is-info { background: var(--info-soft); color: var(--info); }
.list-icon.is-primary { background: var(--primary-soft); color: var(--primary); }

.code-block {
  font-family: var(--mono); font-size: 12.5px; direction: ltr; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; overflow: auto; white-space: pre; line-height: 1.55; color: var(--text);
  max-height: 520px;
}
.copyable { position: relative; }
.copyable .copy-btn { position: absolute; top: 8px; right: 8px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 14px; background: var(--surface-3); font-size: 12.5px; color: var(--text-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.divider-text { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.chart-box { position: relative; height: 260px; }
.chart-box.is-sm { height: 190px; }
.chart-box.is-lg { height: 320px; }

.text-muted { color: var(--muted) !important; }
.table tr.is-muted > td { opacity: .55; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary) !important; }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.fw-600 { font-weight: 600; }
.text-end { text-align: end; }
.text-center { text-align: center; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.wrap { flex-wrap: wrap; } .gap-1 { gap: 6px; } .gap-2 { gap: 10px; } .gap-3 { gap: 16px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.ms-auto { margin-inline-start: auto; }
.w-100 { width: 100%; }
.hidden, [hidden] { display: none !important; }
.d-block { display: block; }
.d-inline-flex { display: inline-flex; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* --------------------------------------------------------------------------
   صفحات الدخول والتثبيت
   -------------------------------------------------------------------------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(1200px 600px at 100% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 60%),
  radial-gradient(900px 500px at -10% 110%, color-mix(in srgb, var(--chart-2) 12%, transparent), transparent 60%),
  var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 30px; }
.auth-card.is-wide { max-width: 720px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
.auth-brand .brand-name { color: var(--text); font-size: 17px; }
.auth-brand .brand-sub { color: var(--muted); font-size: 12.5px; }
.auth-title { font-size: 19px; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.auth-foot { margin-top: 18px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.auth-form { display: flex; flex-direction: column; gap: 15px; }
.password-field { position: relative; }
/* المسافة تُحجز بجهة الزر الفعلية حتى لو كان الحقل نفسه باتجاه LTR */
.password-field .input { padding-left: 44px; padding-right: 12px; }
.password-field .toggle-pass { position: absolute; left: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; }
[dir="ltr"] .password-field .input { padding-left: 12px; padding-right: 44px; }
[dir="ltr"] .password-field .toggle-pass { left: auto; right: 4px; }
.password-field .input-ltr::placeholder { direction: rtl; text-align: right; }

.steps { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.step-num { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-weight: 600; font-size: 12px; }
.step.is-active { color: var(--text); font-weight: 500; }
.step.is-active .step-num { background: var(--primary); color: #fff; }
.step.is-done .step-num { background: var(--success); color: #fff; }

.req-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.req-list li { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.req-list li:last-child { border-bottom: 0; }
.req-list .icon { width: 17px; height: 17px; }
.req-list .ok { color: var(--success); }
.req-list .bad { color: var(--danger); }
.req-list .warn { color: var(--warning); }

/* --------------------------------------------------------------------------
   الاستجابة للشاشات
   -------------------------------------------------------------------------- */
@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main-side { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 1100px) {
  .grid-main-side, .grid-side-main { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(100%); box-shadow: var(--shadow-lg); visibility: hidden; will-change: transform; transition: transform .22s ease, visibility 0s linear .22s; }
  [dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar-open .sidebar { transform: none; visibility: visible; transition: transform .22s ease, visibility 0s; }
  .main { margin-inline-start: 0; }
  .menu-toggle { display: inline-grid; }
  .sidebar-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(8, 13, 28, .5); z-index: 35; }
  .user-chip-text { display: none; }
}
@media (max-width: 760px) {
  .content { padding: 16px; }
  .topbar { padding: 0 12px; gap: 6px; }
  .topbar-search { max-width: none; }
  .topbar-spacer { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .col-9, .col-8, .col-6, .col-4, .col-3, .col-2 { grid-column: span 12; }
  .form-grid { gap: 14px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px; gap: 10px; }
  .stat-icon { width: 36px; height: 36px; border-radius: 9px; }
  .stat-value { font-size: 19px; }
  .page-head { margin-bottom: 14px; }
  h1 { font-size: 18px; }
  .panel-head, .panel-body { padding-inline: 14px; }
  .filters { padding: 12px 14px; }
  .filters .field { flex: 1 1 140px; min-width: 0; }
  .kv-2 { grid-template-columns: minmax(110px, max-content) 1fr; }
  .hide-sm { display: none !important; }
  .toasts { inset-inline: 12px; bottom: 12px; max-width: none; }
  .auth-card { padding: 22px; }
}
@media (max-width: 420px) {
  /* بطاقتان في الصف مع الأيقونة فوق النص لتقليل التمرير */
  .stat { flex-direction: column; align-items: flex-start; gap: 8px; }
  .stat-icon { width: 32px; height: 32px; }
  .stat-icon .icon { width: 18px; height: 18px; }
  .stat-value { font-size: 17px; }
  .stat-label, .stat-meta { font-size: 11.5px; }
}
@media (max-width: 330px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
}

/* --------------------------------------------------------------------------
   الطباعة
   -------------------------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .page-actions, .filters, .bulkbar, .pager, .no-print, .toasts { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; max-width: none; }
  body { background: #fff; color: #000; }
  .panel { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .table th { position: static; }
}
