/* =====================================================================
   منصة دار الذكر التعليمية — الهوية البصرية الموحّدة
   (دليل هوية مدارس دار الذكر: الأخضر والأصفر والبرتقالي والأزرق، خط GE Dinar One وPoppins — المتغيرات في brand.css)
   ===================================================================== */
:root {
  --bg: #f5f7f8; --card: #fff; --ink: #2f3133; --muted: #6b7470; --line: #e1e6e9;
  --brand: var(--dt-green); --brand-dark: var(--dt-green-dark); --brand2: var(--dt-mint); --brand-line: var(--dt-green-40);
  --primary: var(--brand); --accent: var(--dt-leaf); --gold: var(--dt-yellow); --orange: var(--dt-orange); --sky: var(--dt-blue); --pink: var(--dt-orange-dark);
  --ok: var(--dt-leaf-dark); --warn: var(--dt-orange-dark); --err: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,36,60,.04), 0 2px 8px rgba(0,36,60,.05);
  --font: var(--dt-font);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); color: var(--ink); direction: rtl; font-size: 15px; line-height: 1.55; background: var(--bg); }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
button, input, select, textarea { font: inherit; }

/* بطاقة (الاسم القديم .glass باقٍ لتوافق الصفحات) */
.glass, .card-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* الشريط العلوي الموحّد في assets/css/topbar.css */

/* ---------- عام ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 20px 18px 60px; }
.hero { padding: 20px 22px; margin-bottom: 18px; position: relative; overflow: hidden; border-inline-start: 5px solid var(--brand); }
.hero h1 { font-size: 1.45rem; color: var(--ink); }
.hero p { color: var(--muted); margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { padding: 3px 11px; border-radius: 999px; background: var(--brand2); color: var(--brand); font-weight: 600; font-size: .84rem; border: 1px solid var(--brand-line); }
.chip.teal { background: #e5eff6; color: var(--accent); border-color: #97c0db; }
.chip.pink { background: #FEF1E1; color: var(--warn); border-color: #FCD4A5; }
.chip.gray { background: #f1f3f5; color: var(--muted); border-color: var(--line); }
.chip.view-sw { cursor: pointer; font-family: inherit; opacity: .55; transition: .15s; }
.chip.view-sw:hover { opacity: .85; }
.chip.view-sw.on { opacity: 1; box-shadow: 0 0 0 2px currentColor inset; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 24px 0 12px; }
.section-title h2 { font-size: 1.15rem; margin: 0; }

.grid { display: grid; gap: 12px; }
.grid.modules { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.module {
  padding: 16px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 6px;
  transition: border-color .15s, box-shadow .15s; position: relative; min-height: 124px;
}
a.module:hover { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand2); }
.module .ic { font-size: 1.7rem; }
.module b { font-size: 1rem; }
.module small { color: var(--muted); }
.module.soon { opacity: .7; }
.module .badge { position: absolute; top: 12px; inset-inline-start: 12px; font-size: .72rem; padding: 2px 9px; border-radius: 999px;
  background: #FEF1E1; color: var(--warn); border: 1px solid #FCD4A5; font-weight: 700; }

.stat { padding: 12px 14px; }
.stat .n { font-size: 1.7rem; font-weight: 700; color: var(--brand); }
.stat .l { color: var(--muted); font-weight: 600; font-size: .88rem; }

.card { padding: 16px; }

/* ---------- أزرار وحقول ---------- */
.btn { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  font-family: inherit; font-weight: 600; font-size: .93rem; cursor: pointer; border-radius: 10px; padding: 8px 14px;
  background: #fff; color: var(--ink); border: 1px solid var(--line); transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--brand); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: #fff; color: var(--err); border-color: #f0c4be; }
.btn.danger:hover { border-color: var(--err); background: #fdf0ee; }
.btn.ok { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: .84rem; }
.icon-btn { border: 0; background: transparent; font-size: 1.1rem; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: rgba(0, 0, 0, .05); }

label.f { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .88rem; color: var(--ink); }
input, select, textarea {
  font-family: inherit; font-size: .94rem; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand2); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .grow { flex: 1; min-width: 180px; }
.hint { color: var(--muted); font-size: .86rem; }

/* ---------- جداول ---------- */
.table-wrap { overflow: auto; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; max-height: 64vh; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 8px 12px; text-align: right; unicode-bidi: plaintext; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: #fafbfc; font-weight: 700; color: var(--ink); z-index: 1; }
tr:hover td { background: #f6f8fa; }
td.actions { display: flex; gap: 4px; }
.empty { text-align: center; color: var(--muted); padding: 26px; }
.pill { padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.pill.on { background: #e5eff6; color: var(--accent); } .pill.off { background: #fdecea; color: var(--err); }

/* ---------- تبويبات ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; margin-bottom: 16px; }
.tabs button { font-family: inherit; border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer; font-size: .92rem; }
.tabs button:hover { color: var(--brand); background: var(--brand2); }
.tabs button.on { background: var(--brand); color: #fff; }
.tab-pane { display: none; } .tab-pane.on { display: block; }

/* ---------- نافذة منبثقة ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(47,49,51, .4); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: min(560px, 100%); max-height: 90vh; display: flex; flex-direction: column; background: #fff; }
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafbfc; border-radius: var(--radius) var(--radius) 0 0; }
.modal-head h3 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-start; padding: 12px 16px; border-top: 1px solid var(--line); }
.confirm-msg { margin: 0; font-size: 1rem; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- رسائل ---------- */
#toasts { position: fixed; bottom: 20px; left: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 16px; border-radius: 12px; color: #fff; font-weight: 600; box-shadow: 0 8px 24px -8px rgba(0,0,0,.35); max-width: 420px; background: var(--brand); transition: .35s; }
.toast.err { background: var(--err); }
.toast.warn { background: var(--warn); }
.toast.out { opacity: 0; transform: translateY(10px); }

/* ---------- صفحة الدخول ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(180deg, var(--brand) 0 210px, var(--bg) 210px); }
.login { width: min(440px, 100%); padding: 30px 28px; text-align: center; }
.login .logo-full { width: 180px; max-width: 70%; margin: 0 auto 10px; display: block; }
.login h1 { font-size: 1.4rem; }
.login p { color: var(--muted); }
.gbtn { display: inline-flex; align-items: center; gap: 10px; justify-content: center; width: 100%; padding: 12px; font-size: 1rem; margin-top: 10px; }
.gbtn svg { width: 22px; height: 22px; background: #fff; border-radius: 50%; padding: 2px; }
.notice { margin-top: 14px; padding: 10px 12px; border-radius: 12px; font-weight: 600; text-align: right; background: #fff8e6; border: 1px solid #f1d58a; color: #6b4e00; }
.notice.err { background: #fdecea; border-color: #f0c4be; color: #8f2a1f; } .notice.warn { background: #fff8e6; border-color: #f1d58a; color: #6b4e00; }
.notice.info { background: var(--brand2); border-color: var(--brand-line); color: var(--dt-green-dark, #003355); }

.loader { display: grid; place-items: center; padding: 60px; color: var(--muted); font-weight: 600; }
.spin { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--brand2); border-top-color: var(--brand); animation: sp 1s linear infinite; margin-bottom: 10px; }
@keyframes sp { to { transform: rotate(360deg); } }

.report { padding: 12px; border-radius: 12px; background: #fafbfc; border: 1px solid var(--line); margin-top: 12px; }
.report .row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.errors-list { max-height: 260px; overflow: auto; font-size: .9rem; }
.errors-list div { padding: 4px 0; border-bottom: 1px dashed #f0c4be; color: #8f2a1f; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.star { color: var(--err); }
.drop { display: block; border: 2px dashed var(--brand-line); border-radius: 14px; padding: 22px; text-align: center; cursor: pointer; background: #fff; }
.drop:hover { background: var(--brand2); }

footer.credit { text-align: center; color: var(--muted); font-size: .82rem; padding: 20px; }

@media (max-width: 720px) {
  html, body { overflow-x: hidden; }
  .hero h1 { font-size: 1.25rem; }
  .page { padding: 14px 10px 50px; }
}

/* ---------- الهجري بجانب حقول التاريخ + أدوات الجداول ---------- */
.hijri-hint { display: inline-block; margin-inline-start: 6px; color: var(--accent); font-size: .78rem; font-weight: 600; white-space: nowrap; }
.tbl-tools { display: flex; gap: 6px; justify-content: flex-end; margin: 4px 0 6px; }
.tbl-tools .btn { padding: 3px 10px; font-size: .8rem; }
@media print { #topbar, .tbl-tools, .no-print, .credit { display: none !important; } }

/* ---------- الرئيسية: وحدات خارجية + قسم «قيد الإنشاء» ---------- */
.module .ext { position: absolute; top: 10px; inset-inline-end: 12px; font-size: .9rem; color: var(--muted); font-weight: 700; }
.soon-box { margin-top: 22px; }
.soon-box > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.soon-box > summary::-webkit-details-marker { display: none; }
.soon-box > summary::before { content: '◂'; color: var(--muted); transition: transform .2s; }
.soon-box[open] > summary::before { transform: rotate(-90deg); }
.soon-box > summary h2 { margin: 0; font-size: 1.05rem; color: var(--muted); }

/* ---------- الرئيسية: لوحة «يومي» ---------- */
.today { padding: 16px 18px; margin-bottom: 16px; border-inline-start: 5px solid var(--gold); }
.today h3 { font-size: .95rem; margin: 0 0 8px; }
.today-grid { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.today-periods { display: flex; flex-wrap: wrap; gap: 8px; }
.today-periods .tp { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; background: var(--brand2); border: 1px solid var(--brand-line); border-radius: 10px; padding: 6px 10px; min-width: 130px; }
.today-periods .tp i { grid-row: span 2; font-style: normal; font-weight: 700; color: #fff; background: var(--brand); border-radius: 8px; width: 28px; height: 28px; display: grid; place-items: center; }
.today-periods .tp b { font-size: .9rem; }
.today-periods .tp small { color: var(--muted); font-size: .78rem; }
.today-tiles { display: flex; gap: 8px; }
.today-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 104px; padding: 10px 8px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: var(--ink); background: #fff; text-align: center; }
.today-tile:hover { border-color: var(--brand); }
.today-tile span { font-size: 1.3rem; }
.today-tile b { font-size: 1.2rem; color: var(--muted); min-height: 1em; }
.today-tile.hot b { color: var(--pink); }
.today-tile small { font-size: .78rem; color: var(--muted); }
@media (max-width: 720px) {
  .today-grid { grid-template-columns: 1fr; }
  .today-tiles { justify-content: stretch; } .today-tile { flex: 1; min-width: 0; }
}
.today-periods .tp .att-ok { color: var(--ok); font-weight: 600; }
.today-periods .tp .att-no { color: var(--muted); }
.today-periods .tp.ok { background: #e5eff6; border-color: #97c0db; }
.today-periods .tp.ok i { background: var(--ok); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- الوضع التجريبي (ديمو) ---------- */
.demo-band{position:sticky;top:0;z-index:60;display:flex;flex-wrap:wrap;gap:6px 16px;align-items:center;justify-content:center;
  background:#003a60;color:#fff;font-size:13px;padding:6px 12px;line-height:1.5;text-align:center}
.demo-band a{color:#ffe08a;font-weight:600;text-decoration:none}
.demo-band a:hover{text-decoration:underline}
.demo-band .db-r{opacity:.95}
.demo-roles{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px;margin:12px 0 6px}
.demo-roles button{display:flex;flex-direction:column;align-items:center;gap:4px;padding:14px 10px;border:1px solid var(--line,#dfe5ec);border-radius:14px;
  background:#fff;cursor:pointer;font:inherit;transition:transform .15s,box-shadow .15s,border-color .15s}
.demo-roles button:hover,.demo-roles button:focus-visible{transform:translateY(-2px);border-color:#003a60;box-shadow:0 6px 18px rgba(0,58,96,.15)}
.demo-roles button span{font-size:1.6rem}
.demo-roles button small{color:var(--muted,#667);font-size:12px}
.demo-link{display:inline-block;margin-top:16px;color:#003a60;font-weight:600;cursor:pointer;background:none;border:0;font:inherit;text-decoration:underline}

.today-periods .tp.clk { cursor: pointer; transition: box-shadow .15s, border-color .15s; } .today-periods .tp.clk:hover, .today-periods .tp.clk:focus-visible { border-color: var(--brand); box-shadow: 0 3px 10px rgba(0,74,123,.15); }
button.att-box { font: inherit; text-align: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; } button.att-box:hover { border-color: var(--brand); }

/* ---------- لمسات الهوية (عناصر دوائر دار الذكر) ---------- */
.hero { border-inline-start-color: var(--dt-green); }
.hero::after { content: ''; position: absolute; inset-inline-end: -14px; top: -14px; width: 92px; height: 92px; pointer-events: none;
  background: url('../img/brand/deco-top.svg') no-repeat center / contain; opacity: .9; }
[dir="rtl"] .hero::after { transform: scaleX(-1); }
.hero h1, .hero p { position: relative; z-index: 1; }
.hero h1 { color: var(--dt-green); }
::selection { background: var(--dt-yellow-40); }

/* شارة «تجريبي» على بطاقات الوحدات التجريبية */
.module { position: relative; }
.module .beta-badge { position: absolute; top: 10px; inset-inline-end: 12px; font-size: .72rem; font-weight: 700; color: #8a5a00; background: #fff4d6; border: 1px solid #f0d58a; padding: 1px 8px; border-radius: 999px; }

/* بطاقة وحدة بلا صلاحية: تظهر للتعريف بإمكانات المنصة وتعرض رسالة عند الضغط */
.module.locked { opacity: .62; filter: grayscale(.55); cursor: not-allowed; }
.module.locked:hover { opacity: .8; transform: none; }
.module.locked .lock { position: absolute; top: 10px; inset-inline-start: 12px; font-size: .95rem; }

/* «مهامي» في الرئيسية */
.my-tasks { padding: 12px 14px; } .my-tasks .mt-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.my-tasks .mt-list a { background: #f5f7f8; border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; text-decoration: none; color: inherit; font-size: .9rem; }
.my-tasks .mt-list a:hover { border-color: var(--brand); }

/* تنبيهات الجوال */
.push-card { padding: 12px 14px; margin-bottom: 14px; border: 1px solid #cedfea; background: #f3f8fb; }
.push-help { margin-top: 8px; font-size: .88rem; line-height: 1.9; background: #fff; border-radius: 10px; padding: 8px 10px; border: 1px solid var(--line); }
.push-mini { font-size: .85rem; color: var(--muted); margin: -4px 0 12px; } .push-mini a { color: var(--brand); }

/* بيانات منصة الموهبة في ملف الطالب ودليل الموظفين */
.tl-h { margin: 14px 0 6px; font-size: .95rem; }
.tag.win { background: #fff6d8; color: #8a6400; } .tag.fin { background: #e8f1fb; color: #2b5f8f; } .tag.q { background: #e6f0f6; color: #004a7b; }
.tl-chip { display: block; width: 100%; text-align: start; margin-top: 6px; border: 1px dashed #e0c36a; background: #fffbea; color: #7a5a00; border-radius: 10px; padding: 4px 8px; font: inherit; font-size: .8rem; cursor: pointer; }
.tl-chip:hover { background: #fff3c4; }
.tl-chip.inline { display: inline-block; width: auto; margin: 0 4px; padding: 0 6px; }

/* ترحيل الطلاب */
.promo-card { border: 1px solid #cedfea; background: #f3f8fb; padding: 14px; }
.promo-res { max-height: 200px; overflow: auto; } .promo-res a { display: block; padding: 6px; border-bottom: 1px solid #f1f3f2; text-decoration: none; color: inherit; } .promo-res a:hover { background: #f5f7f8; }
.promo-kpi { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0; } .promo-kpi div { background: #f5f7f8; border-radius: 10px; padding: 8px; text-align: center; }
.promo-kpi b { display: block; font-size: 1.4rem; color: var(--brand); } .promo-kpi span { font-size: .8rem; color: var(--muted); }
.chk { display: flex; gap: 8px; align-items: center; margin: 6px 0; cursor: pointer; }
footer.credit .prod { opacity: .75; white-space: nowrap; }

/* ---------- صفحة التفاصيل الكاملة (بدل النافذة المنبثقة الكبيرة) ---------- */
html.pg-open, html.pg-open body { overflow: hidden; }
.modal-wrap.pgfull, body.lms-solo .modal-wrap.pgfull { display: block; padding: 0; background: var(--bg, #f5f7f8); overflow: auto; animation: pgin .18s ease-out; }
.modal-wrap.pgfull .modal, body.lms-solo .modal-wrap.pgfull .modal { width: 100%; max-width: none; max-height: none; min-height: 100%; border-radius: 0; border: 0; box-shadow: none; background: transparent; display: flex; flex-direction: column; }
.modal-wrap.pgfull .modal-head, body.lms-solo .modal-wrap.pgfull .modal-head { position: sticky; top: 0; z-index: 5; border-radius: 0; background: var(--brand, #004a7b); color: #fff; padding: 10px max(16px, calc((100% - 1100px) / 2)); gap: 12px; justify-content: flex-start; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.modal-wrap.pgfull .modal-head h3 { color: #fff; font-size: 1.15rem; flex: 1; }
.modal-wrap.pgfull .pg-back, body.lms-solo .modal-wrap.pgfull .pg-back { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.35); white-space: nowrap; }
.modal-wrap.pgfull .pg-back:hover { background: rgba(255,255,255,.28); }
.modal-wrap.pgfull .modal-body, body.lms-solo .modal-wrap.pgfull .modal-body { width: 100%; max-width: 1100px; margin: 0 auto; padding: 18px 16px 28px; overflow: visible; flex: 1; }
.modal-wrap.pgfull .modal-foot, body.lms-solo .modal-wrap.pgfull .modal-foot { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line, #e1e6e9); padding: 10px max(16px, calc((100% - 1100px) / 2)); }
@keyframes pgin { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* أقسام صفحة التفاصيل */
.pg-hero { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; padding: 16px 18px; background: #fff; border: 1px solid var(--line, #e1e6e9); border-inline-start: 5px solid var(--brand, #004a7b); border-radius: 14px; margin-bottom: 14px; }
.pg-hero .ic { font-size: 2.4rem; line-height: 1; }
.pg-hero h2 { margin: 0; font-size: 1.35rem; }
.pg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pg-grid .kv { background: #fff; border: 1px solid var(--line, #e1e6e9); border-radius: 12px; padding: 10px 12px; }
.pg-grid .kv .k { color: var(--muted, #6b7470); font-size: .82rem; }
.pg-grid .kv .v { font-weight: 700; margin-top: 2px; }
.pg-sec { background: #fff; border: 1px solid var(--line, #e1e6e9); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.pg-sec > h3 { margin: 0 0 10px; font-size: 1.05rem; }
/* اسم قابل للضغط يفتح صفحة التفاصيل */
.nm-link { background: none; border: 0; padding: 0; margin: 0; font: inherit; font-weight: 700; color: inherit; cursor: pointer; text-align: inherit; text-decoration: underline dotted rgba(0,74,123,.45); text-underline-offset: 5px; }
.nm-link:hover, .nm-link:focus-visible { color: var(--brand, #004a7b); text-decoration-style: solid; }
/* الواجهة الإنجليزية: كل الصفحة من اليسار إلى اليمين */
html[dir="ltr"] body { direction: ltr; }

/* =====================================================================
   الوضع الليلي (زر 🌙 في الشريط العلوي — يُحفظ في lms_theme ويُطبَّق قبل الرسم في brand-early.js)
   خلفية كحلية بدل الأسود الصريح لراحة العين
   ===================================================================== */
html.dark { color-scheme: dark; --bg: #0F172A; --card: #1E293B; --ink: #F1F5F9; --muted: #94A3B8; --line: #334155;
  --dt-mint: color-mix(in srgb, var(--dt-green) 22%, #1E293B); --brand2: var(--dt-mint); --brand-line: color-mix(in srgb, var(--dt-green) 45%, #1E293B);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 2px 10px rgba(0,0,0,.25); --dt-ink: #F1F5F9; }
html.dark body { background: var(--bg); color: var(--ink); }
html.dark h1, html.dark h2, html.dark h3, html.dark h4, html.dark .hero h1 { color: var(--ink); }
html.dark .btn, html.dark .btn.danger, html.dark .table-wrap, html.dark .modal, html.dark button.att-box, html.dark .push-help,
html.dark .modal-wrap.pgfull .modal-foot, html.dark .pg-hero, html.dark .pg-grid .kv, html.dark .pg-sec, html.dark .gbtn svg { background: var(--card); color: var(--ink); }
html.dark input, html.dark select, html.dark textarea { background: #0F172A; color: var(--ink); border-color: var(--line); }
html.dark input::placeholder, html.dark textarea::placeholder { color: #64748B; }
html.dark th, html.dark .report, html.dark .my-tasks .mt-list a, html.dark .chip.gray { background: #172033; color: var(--ink); }
html.dark tr:hover td { background: #233149; }
html.dark td, html.dark th { border-color: var(--line); }
html.dark .chip.teal, html.dark .pill.on, html.dark .today-periods .tp.ok { background: var(--brand2); }
html.dark .chip.pink { background: #3b2a1c; }
html.dark .notice { background: #33290f; color: #FDE68A; }
html.dark .notice.err { background: #3b1d1d; color: #fecaca; }
html.dark .notice.info, html.dark .notice.ok { background: #13283a; color: #cfe8ff; }
html.dark .push-card, html.dark .promo-card { background: #172033; border-color: var(--line); }
html.dark .tag.win, html.dark .tl-chip { background: #33290f; color: #FDE68A; }
html.dark .tl-chip:hover { background: #45370f; }
html.dark .module .beta-badge { background: #45370f; color: #FDE68A; }
html.dark .hint, html.dark small { color: var(--muted); }
html.dark a:not(.btn):not([class*="tb-"]) { color: color-mix(in srgb, var(--dt-green) 55%, #ffffff); }
html.dark .modal-wrap { background: rgba(2,6,23,.65); }
html.dark ::-webkit-scrollbar { background: #0F172A; } html.dark ::-webkit-scrollbar-thumb { background: #334155; border-radius: 8px; }
/* العناصر ذات الخلفية البيضاء المكتوبة داخل الصفحات */
html.dark [style*="background:#fff"], html.dark [style*="background: #fff"], html.dark [style*="background:white"], html.dark [style*="background: white"],
html.dark [style*="background:#fafbfc"], html.dark [style*="background: #fafbfc"], html.dark [style*="background:#f8fafc"] { background: var(--card) !important; color: var(--ink); }
@media print { html.dark { color-scheme: light; } }

/* =====================================================================
   لوحة ألوان MechaSTEM (النسخة التجارية فقط — يُلحقها build.sh بآخر app.css)
   أزرق محيطي للشريط العلوي، سيرولين للأزرار، كهرماني للتحفيز بنسبة قليلة — مع وضع ليلي كحلي
   ===================================================================== */
:root {
  --bg-main: #F4F7FA; --bg-sidebar: #EDF2F7; --bg-card: #FFFFFF; --bg-card-tinted: #EBF3FA; --bg-header: #16425B;
  --banner-gradient: linear-gradient(135deg, #2B7A9E 0%, #16425B 100%);
  --color-primary: #21618C; --color-primary-hover: #1A4D6E; --color-accent: #F59E0B;
  --text-primary: #1E293B; --text-secondary: #5A6B7C; --text-on-dark: #FFFFFF; --border-subtle: #D6E4F0;
  /* ربطها بمتغيرات المنصة */
  --bg: var(--bg-main); --card: var(--bg-card); --ink: var(--text-primary); --muted: var(--text-secondary); --line: var(--border-subtle);
  --gold: var(--color-accent); --err: #E11D48;
  --shadow: 0 1px 2px rgba(22,66,91,.04), 0 2px 8px rgba(22,66,91,.05);
}
html.dark {
  --bg-main: #0F172A; --bg-sidebar: #162235; --bg-card: #1E293B; --bg-card-tinted: #1A2E44; --bg-header: #0B2536;
  --banner-gradient: linear-gradient(135deg, #1E5673 0%, #0D2B3E 100%);
  --color-primary: #38BDF8; --color-primary-hover: #0284C7; --color-accent: #FBBF24;
  --text-primary: #F1F5F9; --text-secondary: #94A3B8; --text-on-dark: #F8FAFC; --border-subtle: #2D3F59;
  --bg: var(--bg-main); --card: var(--bg-card); --ink: var(--text-primary); --muted: var(--text-secondary); --line: var(--border-subtle);
  --dt-green: #38BDF8; --dt-green-dark: #0284C7; --dt-green-80: #7DD3FC; --dt-green-60: #BAE6FD; --dt-green-40: #1E5673;
  --dt-leaf: #FBBF24; --gold: #FBBF24; --brand-line: #1E5673; --dt-mint: #1A2E44; --brand2: #1A2E44;
}
/* الشريط العلوي */
#topbar, html.dark #topbar { background: var(--bg-header); box-shadow: 0 2px 10px rgba(11,37,54,.18); border-bottom: 0; }
#topbar .tb-user .av { color: #16425B; }
html.dark #topbar .menu-btn, html.dark #topbar .tb-ic, html.dark #topbar .tb-lang, html.dark #topbar .tb-theme, html.dark #topbar .tb-pill, html.dark #topbar .calbar { background: #ffffff12; }
html.dark #topbar .tb-user .av { background: #38BDF8; color: #0B2536; }
/* القائمة الجانبية */
.lms-side, html.dark .lms-side { background: var(--bg-sidebar); border-color: var(--border-subtle); --line: var(--border-subtle); --ink: var(--text-primary); }
.lms-side .sb-head { border-color: var(--border-subtle); }
.lms-side .sb-q { background: var(--bg-card); border-color: var(--border-subtle); }
.lms-side .sb-it:hover, .lms-side .sb-it:focus-visible { background: #E2EAF3; }
.lms-side .sb-it.on { background: var(--bg-card); box-shadow: 0 1px 3px rgba(22,66,91,.08); }
html.dark .lms-side .sb-it:hover { background: #1E2D45; }
html.dark .lms-side .sb-it.on { background: var(--bg-card); color: #7DD3FC; }
html.dark .lms-side .sb-q, html.dark .lms-side .sb-pin, html.dark .lms-side .sb-x { background: var(--bg-main); border-color: var(--border-subtle); }
/* الأزرار */
.btn.primary { background: var(--color-primary); border-color: var(--color-primary); }
.btn.primary:hover { background: var(--color-primary-hover); border-color: var(--color-primary-hover); }
html.dark .btn.primary, html.dark .module .btn.primary { color: #0B2536; }
/* لافتة الترحيب وبطاقات التنبيهات */
.home-hero, html.dark .home-hero { background: radial-gradient(circle at 10% 120%, #ffffff1f 0 90px, transparent 91px), var(--banner-gradient); box-shadow: 0 10px 28px rgba(22,66,91,.18); }
html.dark .home-hero { box-shadow: none; }
.nf-t, .push-card, .promo-card { background: var(--bg-card-tinted); border-color: var(--border-subtle); }
html.dark .nf-t, html.dark .push-card, html.dark .promo-card { background: var(--bg-card-tinted) !important; border-color: var(--border-subtle) !important; }
.nf-t .ni { background: var(--bg-card); }
html.dark .nf-t .ni { background: var(--bg-main) !important; }
.nf-t.hot { background: #FEF6E4; border-color: #F8D58A; }
html.dark .nf-t.hot { background: #3A2E12 !important; border-color: #8A6A1C !important; }
/* حالات النظام: النجاح أخضر زمردي ناعم، والتعليق كهرماني، والخطأ أحمر وردي */
:root { --ok: #10B981; --warn: #F59E0B; --err: #E11D48; }
html.dark { --ok: #34D399; --warn: #FBBF24; --err: #FB7185; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.chip.teal { background: #ECFDF5; color: #047857; border-color: #A7F3D0; }
.notice.ok { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.today-periods .tp.ok { background: #ECFDF5; border-color: #A7F3D0; }
.today-periods .tp.ok i { background: var(--ok); }
html.dark .chip.teal, html.dark .today-periods .tp.ok { background: #0B3B2E !important; color: #6EE7B7; border-color: #065F46 !important; }
html.dark .notice.ok { background: #0B3B2E; color: #A7F3D0; }
html.dark .btn.ok { color: #0F172A; }
