/* =============================================================================
   توجيه — واجهة لوحة التحكم («نهار تركوازي»)
   CSS مخصص بلا Bootstrap. كل القيم مجمّعة في متغيرات :root لتسهيل التعديل.
   ============================================================================= */

:root {
  --bg: #F2F5F4;
  --surface: #FFFFFF;
  --surface-2: #F7F9F8;
  --line: rgba(20, 32, 29, 0.09);
  --line-strong: rgba(20, 32, 29, 0.14);
  --ink: #14201D;
  --ink-2: #3D4A46;
  --muted: #5E6B67;
  --faint: #66736F;

  --accent: #0B7A68;
  --accent-dark: #086457;
  --accent-soft: rgba(11, 122, 104, 0.10);
  --accent-line: rgba(11, 122, 104, 0.30);
  --accent-dash: rgba(11, 122, 104, 0.50);
  --accent-glow: rgba(11, 122, 104, 0.25);

  --success: #1F7A46;
  --success-soft: rgba(31, 122, 70, 0.12);
  --warn: #8F5B0E;
  --warn-soft: rgba(217, 154, 43, 0.16);
  --danger: #B42318;
  --danger-soft: rgba(180, 35, 24, 0.10);
  --danger-line: rgba(180, 35, 24, 0.30);
  --info: #1D5FA8;
  --info-soft: rgba(29, 95, 168, 0.12);
  --star: #D99A2B;

  --font: "Readex Pro", "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --r-lg: 18px;
  --r-md: 14px;
  --r-sm: 10px;
  --r-xs: 6px;

  --shadow-card: 0 8px 30px rgba(20, 32, 29, 0.05);
  --shadow-pop: 0 12px 40px rgba(20, 32, 29, 0.06);

  --rail-w: 84px;
  --topbar-h: 76px;
}

/* ----------------------------------------------------------------------------
   الأساس
   ---------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
p { margin: 0; }

input, select, textarea, button { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ----------------------------------------------------------------------------
   أدوات صغيرة
   ---------------------------------------------------------------------------- */

.mono { font-family: var(--mono); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.light { font-weight: 300; }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.num { font-variant-numeric: tabular-nums; }
.text-center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.ms-auto { margin-inline-start: auto; }
.inline-form { display: inline-flex; margin: 0; }
.hide-mobile { }
.only-mobile { display: none !important; }

/* ----------------------------------------------------------------------------
   الهيكل العام: شريط جانبي نحيف + المحتوى
   ---------------------------------------------------------------------------- */

.app { min-height: 100vh; display: flex; align-items: stretch; }

.rail {
  flex: 0 0 var(--rail-w);
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail-brand {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 5px rgba(11, 122, 104, 0.12);
  flex-shrink: 0;
  text-decoration: none;
}

.rail-nav { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }

.rail-link {
  width: 64px; padding: 10px 0; border-radius: 12px;
  color: var(--muted); text-decoration: none;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 400;
}
.rail-link:hover { background: var(--surface-2); color: var(--ink); }
.rail-link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }

.rail-end { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #EEF3F1; border: 1px solid var(--line-strong);
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}

.rail-icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 0;
  background: transparent; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.rail-icon-btn:hover { background: var(--surface-2); color: var(--ink); }

.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

/* ترويسة الجوال (تظهر فقط على الشاشات الصغيرة) */
.mobile-header {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 10px 16px;
  align-items: center; gap: 10px;
}
.mobile-header .brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mobile-header .brand-name { font-size: 18px; font-weight: 700; }

/* شريط العنوان أعلى كل صفحة */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 18px 32px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  min-height: var(--topbar-h);
}
.topbar-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.topbar-title h1 { font-size: 24px; }
.topbar-title p { font-size: 13.5px; color: var(--muted); font-weight: 300; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); flex-wrap: wrap; min-width: 0; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs .current { color: var(--ink); font-weight: 500; }

.page { padding: 28px 32px 12px; display: flex; flex-direction: column; gap: 24px; }
.page-narrow { max-width: 760px; width: 100%; margin: 0 auto; }
.page-narrow-sm { max-width: 640px; width: 100%; margin: 0 auto; }

.app-footer {
  margin-top: auto; padding: 20px 32px;
  font-size: 12.5px; color: var(--faint); font-weight: 300;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

/* عمودان: رئيسي + جانبي */
.cols { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.col-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.col-side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }

/* ----------------------------------------------------------------------------
   الرسائل
   ---------------------------------------------------------------------------- */

.alerts { display: flex; flex-direction: column; gap: 10px; }
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: 12px; font-size: 13.5px; line-height: 1.7;
  border: 1px solid var(--line); background: var(--surface);
}
.alert .alert-text { flex: 1 1 auto; min-width: 0; }
.alert-close {
  width: 28px; height: 28px; border-radius: 8px; border: 0; background: transparent;
  color: inherit; opacity: .7; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.alert-close:hover { opacity: 1; background: rgba(0,0,0,.05); }
.alert-success { background: var(--success-soft); border-color: rgba(31,122,70,.25); color: var(--success); }
.alert-info { background: var(--info-soft); border-color: rgba(29,95,168,.25); color: var(--info); }
.alert-warning { background: var(--warn-soft); border-color: rgba(217,154,43,.35); color: var(--warn); }
.alert-error, .alert-danger { background: var(--danger-soft); border-color: var(--danger-line); color: var(--danger); }

/* ----------------------------------------------------------------------------
   الأزرار
   ---------------------------------------------------------------------------- */

.btn {
  height: 42px; padding: 0 16px; border-radius: 12px;
  border: 1px solid transparent; background: transparent;
  font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--ink);
}
.btn-primary { background: var(--accent); color: #fff; font-weight: 600; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-glow { box-shadow: 0 8px 24px var(--accent-glow); }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); color: var(--ink); }
.btn-outline-accent { background: var(--surface); border-color: rgba(11,122,104,.4); color: var(--accent); }
.btn-outline-accent:hover { background: var(--accent-soft); color: var(--accent-dark); }
.btn-outline-danger { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-soft { background: var(--accent-soft); color: var(--accent); border: 0; }
.btn-sm { height: 38px; padding: 0 14px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }

.btn-icon {
  width: 36px; height: 36px; padding: 0; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  text-decoration: none;
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }
.btn-icon.is-danger { border-color: var(--danger-line); color: var(--danger); }
.btn-icon.is-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-icon.is-plain { border-color: transparent; }
.btn-icon.is-lg { width: 44px; height: 44px; border-radius: 12px; }
.btn-icon.is-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 6px 18px var(--accent-glow); }
.btn-icon.is-primary:hover { background: var(--accent-dark); color: #fff; }

/* ----------------------------------------------------------------------------
   البطاقات
   ---------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}
.card-raised { border-radius: 20px; box-shadow: var(--shadow-card); }
.card-head {
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-head-title { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; }
.card-head-title svg { color: var(--accent); }
.card-meta { font-size: 12.5px; color: var(--muted); font-weight: 300; }
.card-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card-body-lg { padding: 28px; gap: 24px; }
.card-note { font-size: 13px; color: var(--muted); font-weight: 300; line-height: 1.8; }

.empty {
  padding: 36px 20px; text-align: center; color: var(--muted); font-size: 13.5px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty > svg { color: var(--faint); }

/* أيقونات الأزرار تأخذ لون الزر دائمًا مهما كان الحاوي */
.btn svg, .btn-icon svg, .rail-link svg, .lang-tag svg { color: inherit; }

/* بطاقات الإحصاءات */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px; display: flex; flex-direction: column; gap: 8px;
}
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-value { font-size: 32px; font-weight: 600; line-height: 1.1; color: var(--accent); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------------------
   الرقائق والوسوم والحالات
   ---------------------------------------------------------------------------- */

.chip {
  display: inline-block; font-family: var(--mono); direction: ltr; unicode-bidi: isolate;
  font-size: 11px; background: rgba(20,32,29,.06); border-radius: 5px; padding: 2px 7px; color: var(--ink-2);
  line-height: 1.6;
}
.chip-accent { font-family: var(--font); font-weight: 500; color: var(--accent); background: var(--accent-soft); }
.chip-outline { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.chip-lg { font-size: 12.5px; padding: 3px 8px; }

.pill-link {
  display: inline-block; font-family: var(--mono); direction: ltr; unicode-bidi: isolate;
  font-size: 13px; font-weight: 500; color: var(--accent);
  background: rgba(11,122,104,.08); border: 1px solid var(--accent-line);
  border-radius: 999px; padding: 6px 12px; white-space: nowrap; text-decoration: none;
}
.pill-link.is-off { color: var(--muted); background: rgba(20,32,29,.05); border-color: var(--line-strong); }

.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.tag-accent { background: var(--accent-soft); color: var(--accent); }
.tag-info { background: var(--info-soft); color: var(--info); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-muted { background: rgba(20,32,29,.06); color: var(--muted); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-rtl { font-family: var(--mono); font-size: 10.5px; background: var(--surface); border: 1px solid var(--line-strong); color: var(--muted); padding: 1px 6px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--success); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px rgba(31,122,70,.5); }
.status.is-off { color: var(--muted); }
.status.is-off::before { box-shadow: none; }

.dash { width: 22px; height: 1px; border-top: 1px dashed var(--accent-dash); flex-shrink: 0; }
.dash-v { width: 1px; height: 18px; border-inline-start: 1px dashed var(--accent-dash); margin: 0 auto; }

.ico-star { color: var(--star); }

/* ----------------------------------------------------------------------------
   قائمة المواد (بطاقة لكل مادة)
   ---------------------------------------------------------------------------- */

.list { display: flex; flex-direction: column; gap: 12px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 4px; }
.list-head-title { font-size: 15px; font-weight: 500; }

.mat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 16px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.mat.is-off { opacity: .6; }
.mat-body { flex: 1 1 240px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.mat-title { font-size: 16px; font-weight: 500; color: var(--ink); text-decoration: none; line-height: 1.4; }
.mat-title:hover { color: var(--accent); }
.mat-langs { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.mat-default { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; margin-inline-start: 6px; }
.mat-count { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; min-width: 72px; }
.mat-count strong { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.mat-count span { font-size: 11.5px; color: var(--muted); }

/* ----------------------------------------------------------------------------
   «بطاقة المسار» في صفحة المادة
   ---------------------------------------------------------------------------- */

.hero-stats { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.hero-stat { display: flex; flex-direction: column; gap: 2px; }
.hero-stat .label { font-size: 11.5px; }
.hero-stat .value { font-size: 18px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.hero-stat .value-sm { font-size: 14px; font-weight: 500; }

.route { display: flex; align-items: center; gap: 0; flex-wrap: wrap; row-gap: 16px; }
.route-pill {
  font-family: var(--mono); direction: ltr; unicode-bidi: isolate;
  font-size: 20px; font-weight: 500; color: #fff; background: var(--accent);
  border-radius: 999px; padding: 12px 20px; text-decoration: none; white-space: nowrap;
  box-shadow: 0 10px 28px rgba(11,122,104,.28);
}
.route-pill:hover { color: #fff; background: var(--accent-dark); }
.route-dash { width: 40px; height: 1px; border-top: 1px dashed rgba(11,122,104,.6); flex-shrink: 0; }
.route-langs {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  flex: 1 1 320px; min-width: 0; padding: 10px 14px;
  border: 1px dashed rgba(11,122,104,.4); border-radius: 16px;
}
.lang-tag {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px;
  background: var(--bg); border: 1px solid rgba(20,32,29,.1); color: var(--ink); font-size: 13.5px;
}
.lang-tag .chip { background: transparent; padding: 0; color: var(--muted); }
.lang-tag.is-default { background: var(--accent-soft); border-color: rgba(11,122,104,.5); font-weight: 500; }
.lang-tag.is-default .chip { color: var(--accent); }
.lang-tag.is-off { background: transparent; color: var(--faint); text-decoration: line-through; }
.lang-tag.is-add {
  border: 1px dashed var(--accent-dash); background: transparent; color: var(--accent);
  font-size: 13px; font-weight: 500; text-decoration: none; gap: 6px;
}
.lang-tag.is-add:hover { background: var(--accent-soft); }

/* ----------------------------------------------------------------------------
   رمز QR: مصغّر بجانب الرابط + نافذة مكبّرة
   ---------------------------------------------------------------------------- */

.qr-thumb {
  width: 44px; height: 44px; padding: 3px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: border-color .15s, box-shadow .15s;
}
.qr-thumb img { width: 100%; height: 100%; display: block; }
.qr-thumb:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.qr-thumb.is-lg { width: 96px; height: 96px; padding: 6px; border-radius: 14px; }
.qr-thumb.is-sm { width: 36px; height: 36px; padding: 2px; border-radius: 9px; }

.qr-dialog {
  border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px);
  color: var(--ink); font-family: var(--font);
}
.qr-dialog::backdrop { background: rgba(20, 32, 29, 0.45); }
.qr-dialog-body {
  width: 360px; max-width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 20px 22px 22px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-pop); direction: rtl; text-align: right;
}
.qr-dialog-title { font-size: 16px; font-weight: 600; line-height: 1.5; min-width: 0; }
.qr-dialog-img {
  align-self: center; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 16px;
}
.qr-dialog-img img { display: block; width: 280px; height: 280px; max-width: 100%; }
.qr-dialog-url { text-align: center; font-size: 14px; text-decoration: none; }
.qr-dialog .form-actions .btn { flex: 1 1 auto; }

/* ----------------------------------------------------------------------------
   الجداول
   ---------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
table.table { border-collapse: collapse; width: 100%; }
.table th {
  text-align: right; padding: 10px 16px; font-size: 12px; font-weight: 500;
  color: var(--muted); background: #F3F6F5; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table td { padding: 10px 16px; border-bottom: 1px solid rgba(20,32,29,.07); font-size: 14px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: rgba(20,32,29,.025); }
.table tr.is-off { opacity: .55; }
.table .td-center { text-align: center; }
.table .td-actions { white-space: nowrap; }
.table .td-actions .row { justify-content: flex-end; flex-wrap: nowrap; gap: 4px; }
.table .td-url { max-width: 320px; }
.table .td-url a { display: block; font-family: var(--mono); direction: ltr; unicode-bidi: isolate; font-size: 12.5px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table .cell-lang { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.table .cell-lang strong { font-weight: 500; }

/* ----------------------------------------------------------------------------
   النماذج
   ---------------------------------------------------------------------------- */

.form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 16px; align-items: start; }
.form-grid-wide { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 20px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.label .req { color: var(--danger); }
.help { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.error { font-size: 12.5px; color: var(--danger); }

.input, .select, .textarea,
input[type="text"].input, input[type="url"].input, input[type="number"].input, input[type="search"].input, input[type="password"].input {
  height: 42px; padding: 0 12px; width: 100%;
  border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface-2);
  font-size: 14px; color: var(--ink);
}
.textarea { height: auto; padding: 12px 14px; line-height: 1.7; resize: vertical; }
.input[dir="ltr"], .textarea[dir="ltr"] { font-family: var(--mono); font-size: 13.5px; }
.select {
  appearance: none; padding-inline-end: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235E6B67' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: left 12px center;
}
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }

.input-group { display: flex; align-items: stretch; direction: ltr; }
.input-group .prefix {
  display: flex; align-items: center; padding: 0 12px; white-space: nowrap;
  background: rgba(20,32,29,.06); border: 1px solid var(--line-strong); border-right: 0;
  border-radius: 12px 0 0 12px; font-family: var(--mono); font-size: 13px; color: var(--muted);
}
.input-group .input { border-radius: 0 12px 12px 0; flex: 1 1 auto; min-width: 0; }

.row > .input, .row > .select { flex: 1 1 auto; width: auto; min-width: 0; }

.search { position: relative; display: flex; align-items: center; }
.search input.input { padding-inline-start: 38px; background: var(--surface); }
.search svg { position: absolute; inset-inline-start: 12px; color: var(--faint); pointer-events: none; }
.search-w { width: 260px; max-width: 100%; }

/* مفتاح تبديل (checkbox مُنسَّق) داخل النماذج */
.switch-field {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px;
  cursor: pointer;
}
.switch-field .switch-text { display: flex; flex-direction: column; gap: 2px; }
.switch-field .switch-text strong { font-size: 14px; font-weight: 600; }
.switch-field .switch-text span { font-size: 12.5px; color: var(--muted); }

.switch-input {
  appearance: none; -webkit-appearance: none; margin: 0; flex-shrink: 0;
  width: 44px; height: 24px; border-radius: 999px; background: #C9D1CE; position: relative;
  cursor: pointer; transition: background .2s;
}
.switch-input::before {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s;
}
.switch-input:checked { background: var(--accent); }
.switch-input:checked::before { transform: translateX(-20px); }
[dir="ltr"] .switch-input:checked::before { transform: translateX(20px); }

/* مفتاح تبديل كزر إرسال (تفعيل/تعطيل رابط) */
.switch {
  width: 40px; height: 22px; border-radius: 999px; border: 0; padding: 0; position: relative;
  background: #C9D1CE; flex-shrink: 0; transition: background .2s;
}
.switch::before {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::before { transform: translateX(-18px); }

.check {
  display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); cursor: pointer; min-height: 32px;
}
.check-input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.notice {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border-radius: 12px; font-size: 13px; line-height: 1.7;
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--ink-2);
}
.notice svg { color: var(--accent); flex-shrink: 0; margin-top: 3px; }
.notice-plain { background: var(--surface-2); border-color: var(--line); }
.notice-plain svg { color: var(--muted); }

/* رابط قصير بارز داخل النماذج */
.link-box {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: 12px;
}
.link-box .link-box-label { font-size: 12.5px; font-weight: 500; color: var(--accent); }
.link-box .link-box-url { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; font-size: 15px; font-weight: 500; color: var(--accent-dark); overflow-wrap: anywhere; }

.danger-zone {
  background: var(--surface); border: 1px solid var(--danger-line); border-radius: 16px;
  padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.danger-zone .dz-icon {
  width: 36px; height: 36px; border-radius: 10px; background: var(--danger-soft); color: var(--danger);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.danger-zone .dz-title { font-size: 15px; font-weight: 700; color: var(--danger); }

/* ----------------------------------------------------------------------------
   عناصر جانبية: أشرطة اللغات، الخطوات، المحاكاة، الزيارات
   ---------------------------------------------------------------------------- */

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.bar-row .name { display: flex; align-items: center; gap: 8px; }
.bar-track { height: 8px; border-radius: 999px; background: rgba(20,32,29,.07); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--accent); }

.steps { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 10px; font-size: 13px; color: var(--ink-2); font-weight: 300; line-height: 1.7; }
.steps li { display: flex; gap: 10px; }
.steps .n {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0;
}

.quick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.quick a { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; font-size: 12px; color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 10px; text-decoration: none; }
.quick a.is-text { font-family: var(--font); }
.quick a:hover, .quick a.is-active { color: var(--accent); background: var(--accent-soft); border-color: rgba(11,122,104,.4); }

.sim { display: flex; flex-direction: column; align-items: stretch; gap: 0; margin-top: 4px; }
.sim-in { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 10px; align-self: flex-start; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.sim-dash { height: 16px; display: flex; flex-shrink: 0; margin-inline-start: 22px; }
.sim-dash div { width: 1px; height: 100%; border-inline-start: 1px dashed rgba(11,122,104,.6); }
.sim-out { flex: 1 1 auto; min-width: 0; background: rgba(11,122,104,.07); border: 1px solid rgba(11,122,104,.35); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.sim-out.is-warn { background: var(--warn-soft); border-color: rgba(217,154,43,.4); }
.sim-out a { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; font-size: 12px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }

.visits { list-style: none; margin: 0; padding: 6px 0; display: flex; flex-direction: column; }
.visits li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 20px; font-size: 13px; }
.visits li + li { border-top: 1px solid rgba(20,32,29,.06); }
.visits .al { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.visits .meta { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.visits .time { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------------------
   صفحة تسجيل الدخول (تخطيط مستقل عن الشريط الجانبي)
   ---------------------------------------------------------------------------- */

.login { min-height: 100vh; display: flex; flex-wrap: wrap; align-items: stretch; }
.login-brand {
  flex: 1 1 460px; padding: 56px 64px; min-height: 420px;
  background: var(--surface); border-inline-end: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: space-between; gap: 48px;
}
.login-logo { display: flex; align-items: center; gap: 12px; }
.login-logo .brand-mark {
  width: 44px; height: 44px; border-radius: 12px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 6px rgba(11,122,104,.12);
}
.login-logo .brand-name { font-size: 24px; font-weight: 700; }
.login-copy { display: flex; flex-direction: column; gap: 32px; max-width: 520px; }
.login-copy h2 { font-size: 40px; font-weight: 600; line-height: 1.3; text-wrap: pretty; }
.login-copy p { font-size: 15px; line-height: 1.9; color: var(--muted); font-weight: 300; }
.login-foot { font-size: 13px; color: var(--faint); font-weight: 300; }

.demo { display: flex; align-items: stretch; }
.demo-pill { display: flex; align-items: center; }
.demo-pill span {
  font-family: var(--mono); direction: ltr; unicode-bidi: isolate; font-size: 15px; font-weight: 500;
  color: #fff; background: var(--accent); border-radius: 999px; padding: 10px 16px; white-space: nowrap;
  box-shadow: 0 8px 24px var(--accent-glow);
}
.demo-gap { width: 36px; display: flex; flex-direction: column; justify-content: center; flex-shrink: 0; }
.demo-gap div { height: 1px; border-top: 1px dashed rgba(11,122,104,.55); }
.demo-rows { display: flex; flex-direction: column; gap: 10px; flex: 1 1 auto; min-width: 0; border-inline-start: 1px dashed rgba(11,122,104,.55); }
.demo-row { display: flex; align-items: center; }
.demo-row .tick { width: 24px; height: 1px; border-top: 1px dashed rgba(11,122,104,.55); flex-shrink: 0; }
.demo-row .box {
  display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: 14px;
}
.demo-row .code { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; font-size: 12px; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 2px 8px; min-width: 52px; text-align: center; }
.demo-row .code.is-warn { font-family: var(--font); color: var(--warn); background: var(--warn-soft); }
.demo-row .url { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; font-size: 12px; color: var(--faint); margin-inline-start: auto; }
.demo-row .url.is-text { font-family: var(--font); }

.login-form-wrap { flex: 1 1 440px; display: flex; align-items: center; justify-content: center; padding: 56px 32px; }
.login-form {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px; display: flex; flex-direction: column; gap: 22px; margin: 0;
  box-shadow: var(--shadow-pop);
}
.login-form h1 { font-size: 24px; }
.login-form .input { height: 46px; font-size: 15px; }
.login-form .btn { height: 48px; font-size: 15px; }
.login-hint { font-size: 12.5px; color: var(--faint); display: flex; align-items: center; gap: 6px; font-weight: 300; }

/* ----------------------------------------------------------------------------
   الجوال (≤ 720px): شريط تبويبات سفلي + ترويسة مضغوطة + بطاقات بدل الجداول
   ---------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .hide-mobile { display: none !important; }
  .only-mobile { display: flex !important; }

  .app { flex-direction: column; }
  .mobile-header { display: flex; }

  .rail {
    position: fixed; bottom: 0; inset-inline: 0; top: auto; height: auto; z-index: 20;
    flex-direction: row; justify-content: stretch; gap: 6px;
    padding: 8px 12px calc(14px + env(safe-area-inset-bottom));
    border-inline-end: 0; border-top: 1px solid var(--line);
  }
  .rail-brand, .rail-end { display: none; }
  .rail-nav { flex-direction: row; margin-top: 0; width: 100%; gap: 6px; }
  .rail-link { flex: 1 1 0; width: auto; min-height: 50px; justify-content: center; font-size: 11.5px; }

  .app-main { padding-bottom: 88px; }
  .topbar { padding: 14px 16px; min-height: 0; }
  .topbar-title h1 { font-size: 22px; }
  .page { padding: 20px 16px 24px; gap: 16px; }
  .app-footer { padding: 16px; justify-content: center; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px 16px; gap: 4px; }
  .stat-value { font-size: 26px; }

  .search-w { width: auto; flex: 1 1 0; min-width: 0; }
  .topbar-actions { width: 100%; flex-wrap: nowrap; }

  .card-body-lg { padding: 18px 16px; gap: 16px; }
  .route { flex-direction: column; align-items: stretch; row-gap: 0; }
  .route-pill { font-size: 16px; padding: 11px 18px; align-self: center; }
  .route .qr-thumb { align-self: center; }
  .route-dash { width: 1px; height: 18px; border-top: 0; border-inline-start: 1px dashed rgba(11,122,104,.6); margin: 0 auto; }
  .route-langs { padding: 10px; gap: 6px; }
  .lang-tag { padding: 7px 10px; font-size: 13px; }
  .form-actions .btn { width: 100%; }

  .input, .select, .textarea, .login-form .input { font-size: 16px; height: 46px; }
  .textarea { height: auto; }

  .cols { gap: 16px; }
  .col-main, .col-side { gap: 16px; }

  .login-brand { padding: 24px 20px; min-height: 0; gap: 24px; }
  .login-copy h2 { font-size: 26px; }
  .login-form-wrap { padding: 8px 20px 32px; }
  .login-form { padding: 22px 20px; }
  .demo { flex-direction: column; }
  .demo-pill { justify-content: center; }
  .demo-gap { width: auto; height: 18px; align-items: center; }
  .demo-gap div { width: 1px; height: 100%; border-top: 0; border-inline-start: 1px dashed rgba(11,122,104,.55); margin: 0 auto; }
  .demo-rows { border: 1px dashed rgba(11,122,104,.4); border-radius: 14px; padding: 10px; gap: 8px; }
  .demo-row .tick { display: none; }

  /* الجداول الموسومة بـ table-cards تتحوّل إلى بطاقات */
  .table-cards table.table, .table-cards tbody, .table-cards tr, .table-cards td { display: block; }
  .table-cards thead { display: none; }
  .table-cards tr {
    background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
    padding: 6px 14px; margin: 0 0 10px;
  }
  .table-cards tbody tr:hover td { background: transparent; }
  .table-cards td { padding: 6px 0; border: 0 !important; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .table-cards td[data-label]::before { content: attr(data-label); font-size: 12px; color: var(--muted); flex-shrink: 0; }
  .table-cards .td-url { max-width: none; }
  .table-cards .td-url a { flex: 1 1 auto; min-width: 0; text-align: left; }
  .table-cards .td-actions .row { justify-content: flex-end; flex-wrap: wrap; width: 100%; }
  .table-cards .td-center { text-align: start; }
}
