/* =========================================================
   منصة أثر — نظام التصميم
   ========================================================= */
:root {
  color-scheme: light;
  --bg: #f5f6f5; --surface: #ffffff; --surface-2: #f8f9f8; --surface-3: #f0f2f1;
  --border: rgba(15, 26, 23, .09); --border-strong: rgba(15, 26, 23, .16);
  --ink: #0f1a17; --ink-2: #4a5753; --muted: #818c88;
  --brand: #0f766e; --brand-hover: #0b5f58; --brand-soft: #e7f4f1; --brand-ink: #0b5a53;
  --accent: #c8963e;
  --grid: #e7eae8; --axis: #c9cfcc;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a;
  --good: #0ca30c; --warn: #fab219; --crit: #d03b3b; --none: #c7cdca;
  --good-ink: #0a6b2a; --warn-ink: #8a5a00; --crit-ink: #b42318; --info-ink: #1d5fae; --purple-ink: #5b3fb0;
  --good-bg: rgba(12, 163, 12, .10); --warn-bg: rgba(250, 178, 25, .18); --crit-bg: rgba(208, 59, 59, .10);
  --info-bg: rgba(42, 120, 214, .10); --purple-bg: rgba(98, 80, 214, .10); --none-bg: rgba(15, 26, 23, .06);
  --shadow: 0 1px 2px rgba(15, 26, 23, .04), 0 1px 1px rgba(15, 26, 23, .02);
  --shadow-lg: 0 12px 32px rgba(15, 26, 23, .10), 0 2px 6px rgba(15, 26, 23, .05);
  --radius: 14px; --radius-sm: 10px; --side: 256px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c0e0d; --surface: #151817; --surface-2: #1a1e1c; --surface-3: #212624;
    --border: rgba(255, 255, 255, .08); --border-strong: rgba(255, 255, 255, .16);
    --ink: #eef2f0; --ink-2: #b6c0bc; --muted: #7d8884;
    --brand: #2bb3a1; --brand-hover: #3cc6b3; --brand-soft: rgba(43, 179, 161, .14); --brand-ink: #5fd3c2;
    --grid: #252a28; --axis: #3a403d;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70;
    --none: #3e4542;
    --good-ink: #4ade80; --warn-ink: #fbbf24; --crit-ink: #f87171; --info-ink: #7cb4f5; --purple-ink: #a99cf0;
    --good-bg: rgba(12, 163, 12, .16); --warn-bg: rgba(250, 178, 25, .14); --crit-bg: rgba(208, 59, 59, .18);
    --info-bg: rgba(57, 135, 229, .16); --purple-bg: rgba(144, 133, 233, .16); --none-bg: rgba(255, 255, 255, .06);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0e0d; --surface: #151817; --surface-2: #1a1e1c; --surface-3: #212624;
  --border: rgba(255, 255, 255, .08); --border-strong: rgba(255, 255, 255, .16);
  --ink: #eef2f0; --ink-2: #b6c0bc; --muted: #7d8884;
  --brand: #2bb3a1; --brand-hover: #3cc6b3; --brand-soft: rgba(43, 179, 161, .14); --brand-ink: #5fd3c2;
  --grid: #252a28; --axis: #3a403d;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70;
  --none: #3e4542;
  --good-ink: #4ade80; --warn-ink: #fbbf24; --crit-ink: #f87171; --info-ink: #7cb4f5; --purple-ink: #a99cf0;
  --good-bg: rgba(12, 163, 12, .16); --warn-bg: rgba(250, 178, 25, .14); --crit-bg: rgba(208, 59, 59, .18);
  --info-bg: rgba(57, 135, 229, .16); --purple-bg: rgba(144, 133, 233, .16); --none-bg: rgba(255, 255, 255, .06);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'IBM Plex Sans Arabic', system-ui, 'Segoe UI', Tahoma, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.65; font-size: 14.5px; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5em; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; } h2 { font-size: 1.02rem; } h3 { font-size: .95rem; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.num, .tnum { font-variant-numeric: tabular-nums; }

/* =========================================================
   الهيكل: قائمة جانبية + شريط علوي
   ========================================================= */
.app { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: var(--surface); border-inline-end: 1px solid var(--border); display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto; }
.side .brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; color: var(--ink); }
.logo { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 13px; white-space: nowrap; color: #fff;
  background: linear-gradient(140deg, #0f766e 0%, #14958a 55%, #c8963e 140%); box-shadow: 0 4px 12px rgba(15, 118, 110, .3), inset 0 1px 0 rgba(255,255,255,.2); }
.side .brand b { display: block; font-size: 15px; } .side .brand small { display: block; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.nav-label { font-size: 11px; font-weight: 600; color: var(--muted); padding: 14px 10px 6px; letter-spacing: .02em; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--ink-2); font-weight: 500; font-size: 14px; margin-bottom: 2px; position: relative; }
.nav a:hover { background: var(--surface-3); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.nav a.on::before { content: ''; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--brand); }
.nav a .badge { margin-inline-start: auto; background: var(--crit); color: #fff; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; font-size: 13px; flex: none; }
.me b { display: block; font-size: 13.5px; } .me small { color: var(--muted); font-size: 12px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-width: 0; }
.crumbs b { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 20px; background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { color: var(--ink); border-color: var(--border-strong); }
.menu-btn { display: none; }
.wrap { width: 100%; max-width: 1320px; margin: 0 auto; padding: 26px 28px 48px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 18px; }
.scrim { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset-block: 0; inset-inline-start: 0; width: 280px; z-index: 50; transform: translateX(100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 40; }
  .menu-btn { display: grid; }
  .topbar { padding: 10px 16px; }
  .wrap { padding: 18px 16px 40px; }
  .hide-sm { display: none !important; }
}

/* =========================================================
   رأس الصفحة والبطاقات
   ========================================================= */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { margin: 0 0 4px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; }
.page-head .sub span { display: inline-flex; align-items: center; gap: 5px; }
.page-head .sub svg.i { width: 15px; height: 15px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head-row h1 { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.card > h2:first-child { display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.card.flush { padding: 0; overflow: hidden; } .card.flush .card-head { padding: 18px 22px 0; }

.muted { color: var(--muted); } .small { font-size: 12.5px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid-2 { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; gap: 18px; grid-template-columns: 2fr 1fr; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.stack { display: grid; gap: 18px; margin-bottom: 18px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- بطاقات المؤشرات KPI ---------- */
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
.kpi-top { display: flex; align-items: center; gap: 9px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.kpi-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); }
.kpi-ico svg.i { width: 16px; height: 16px; }
.kpi-ico.t-warn { background: var(--warn-bg); color: var(--warn-ink); } .kpi-ico.t-crit { background: var(--crit-bg); color: var(--crit-ink); }
.kpi-ico.t-info { background: var(--info-bg); color: var(--info-ink); } .kpi-ico.t-purple { background: var(--purple-bg); color: var(--purple-ink); }
.kpi-val { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi-val b { font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.kpi-val small { color: var(--muted); font-size: 13px; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; min-height: 28px; }
.kpi .spark { width: 96px; height: 28px; flex: none; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 6px; direction: ltr; }
.delta.up { color: var(--good-ink); background: var(--good-bg); } .delta.down { color: var(--crit-ink); background: var(--crit-bg); } .delta.flat { color: var(--muted); background: var(--none-bg); }
.meter { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 6px; background: var(--brand); }
/* توافق مع البطاقة القديمة */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 1.5rem; font-weight: 700; }
.stat span { color: var(--muted); font-size: 12.5px; }

/* =========================================================
   أزرار ونماذج
   ========================================================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; background: var(--brand); color: #fff; border: 1px solid transparent; padding: 8px 16px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; font-size: 13.5px; line-height: 1.5; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--brand-hover); color: #fff; }
.btn svg.i { width: 16px; height: 16px; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.light { background: var(--brand-soft); color: var(--brand-ink); }
.btn.light:hover { background: var(--brand-soft); color: var(--brand-hover); border-color: var(--brand); }
.btn.danger { background: var(--crit); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 8px; }
.btn.wa { background: #1f9e55; } .btn.wa:hover { background: #188546; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a { padding: 5px 12px; border-radius: 8px; color: var(--ink-2); font-size: 13px; font-weight: 500; white-space: nowrap; }
.seg a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.seg a .n { color: var(--muted); font-weight: 500; margin-inline-start: 3px; }

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 14px; padding: 8px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[type=file] { font: inherit; font-size: 12.5px; color: var(--ink-2); max-width: 100%; }
input[type=file]::file-selector-button { font: inherit; font-size: 12.5px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink); border-radius: 8px; padding: 5px 10px; margin-inline-end: 8px; cursor: pointer; }
.field { margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.hdate-in { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.hdate-in select { width: auto; min-width: 82px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* =========================================================
   جداول
   ========================================================= */
.table-wrap { overflow-x: auto; margin: 0 -2px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: right; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; }
.card.flush table th:first-child, .card.flush table td:first-child { padding-inline-start: 22px; }
.card.flush table th:last-child, .card.flush table td:last-child { padding-inline-end: 22px; }

/* =========================================================
   الحالات والوسوم
   ========================================================= */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.st-green, .c-green { background: var(--good-bg); color: var(--good-ink); }
.st-yellow, .c-yellow { background: var(--warn-bg); color: var(--warn-ink); }
.st-red, .c-red { background: var(--crit-bg); color: var(--crit-ink); }
.st-none, .st-missing, .c-grey { background: var(--none-bg); color: var(--muted); }
.c-blue { background: var(--info-bg); color: var(--info-ink); }
.c-purple { background: var(--purple-bg); color: var(--purple-ink); }
.cell { display: inline-block; min-width: 36px; text-align: center; padding: 3px 7px; border-radius: 7px; font-weight: 600; font-variant-numeric: tabular-nums; }
.cell::before { display: none; }

.flash { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: 11px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; }
.flash.ok { background: var(--good-bg); color: var(--good-ink); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.flash.err { background: var(--crit-bg); color: var(--crit-ink); border-color: color-mix(in srgb, var(--crit) 25%, transparent); }
.flash.info { background: var(--info-bg); color: var(--info-ink); }
.empty { text-align: center; color: var(--muted); padding: 30px 16px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 12px; font-size: 13.5px; }
.note { display: flex; gap: 10px; background: var(--warn-bg); color: var(--warn-ink); padding: 11px 14px; border-radius: 11px; font-size: 13px; margin-bottom: 16px; }
.note.privacy { background: var(--info-bg); color: var(--info-ink); }
.note svg.i { margin-top: 2px; }

/* =========================================================
   الرسوم البيانية
   ========================================================= */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-family: inherit; fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { opacity: .1; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .hov rect { fill: transparent; }
.chart .hov .guide { stroke: var(--axis); stroke-width: 1; opacity: 0; }
.chart .hov:hover .guide { opacity: 1; }
.chart .hov:hover ~ * .dot, .chart .end-label { font-weight: 600; }
.chart .end-label { fill: var(--ink); font-size: 12px; }
.legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend i.ln { height: 3px; width: 14px; border-radius: 2px; }

/* أعمدة أفقية */
.hbars { display: grid; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 160px) 1fr 52px; align-items: center; gap: 12px; font-size: 13px; }
.hbar .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.hbar .track { display: block; height: 10px; background: var(--surface-3); border-radius: 0 5px 5px 0; position: relative; }
.hbar .fill { display: block; height: 100%; border-radius: 5px 0 0 5px; background: var(--s1); min-width: 2px; }
.hbar .val { font-weight: 600; font-variant-numeric: tabular-nums; text-align: left; direction: ltr; }
/* مكدس 100٪ */
.stack100 { display: flex; height: 10px; gap: 2px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.stack100 i { display: block; height: 100%; min-width: 3px; }
.stack100 i.g { background: var(--good); } .stack100 i.y { background: var(--warn); } .stack100 i.r { background: var(--crit); } .stack100 i.n { background: var(--none); }
.dist-row { display: grid; grid-template-columns: minmax(110px, 170px) 1fr 118px; gap: 12px; align-items: center; padding: 7px 0; font-size: 13px; }
.dist-row .lbl { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dist-row .tot { display: flex; gap: 6px; justify-content: flex-end; align-items: center; white-space: nowrap; text-align: left; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.sym { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font-size: 10px; font-weight: 700; color: #fff; flex: none; }
.sym.g { background: var(--good); } .sym.y { background: var(--warn); color: #0b0b0b; } .sym.r { background: var(--crit); } .sym.n { background: var(--none); color: var(--ink); }

/* دونات */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex: none; }
.donut .ring-bg { stroke: var(--surface-3); }
.donut .center-v { font-size: 26px; font-weight: 700; fill: var(--ink); }
.donut .center-l { font-size: 11px; fill: var(--muted); }
.donut-legend { display: grid; gap: 9px; font-size: 13px; flex: 1; min-width: 160px; }
.donut-legend div { display: flex; align-items: center; gap: 8px; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-legend b { margin-inline-start: auto; font-variant-numeric: tabular-nums; }

/* خريطة حرارية */
.heat { border-collapse: separate; border-spacing: 3px; font-size: 12px; }
.heat th { background: none; font-size: 11px; padding: 4px 2px; text-align: center; vertical-align: bottom; white-space: normal; line-height: 1.3; min-width: 44px; }
.heat th.sc { text-align: right; min-width: 170px; }
.heat td { padding: 0; border: 0; text-align: center; }
.heat td.sc { text-align: right; padding: 0 6px; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.heat tr:hover td { background: none; }
.heat .hc { display: block; height: 30px; line-height: 30px; border-radius: 6px; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12px; cursor: default; }
.heat .hc.g { background: var(--good-bg); color: var(--good-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--good) 30%, transparent); }
.heat .hc.y { background: var(--warn-bg); color: var(--warn-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--warn) 40%, transparent); }
.heat .hc.r { background: var(--crit-bg); color: var(--crit-ink); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--crit) 35%, transparent); }
.heat .hc.n { background: var(--surface-3); color: var(--ink-2); }
.heat .hc.m { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }

/* حلقة تقدم */
.ring { width: 64px; height: 64px; flex: none; }
.ring .bg { stroke: var(--surface-3); } .ring .fg { stroke: var(--brand); stroke-linecap: round; transition: stroke-dashoffset .6s; }
.ring text { font-size: 15px; font-weight: 700; fill: var(--ink); }

/* تلميح */
#tip { position: fixed; z-index: 100; pointer-events: none; background: var(--ink); color: var(--surface); padding: 7px 11px; border-radius: 9px; font-size: 12.5px; line-height: 1.6; white-space: pre-line; box-shadow: var(--shadow-lg); opacity: 0; transition: opacity .1s; max-width: 280px; }
#tip.on { opacity: 1; }

/* =========================================================
   قائمة المدارس حسب الحاجة
   ========================================================= */
.need-list { display: grid; gap: 10px; }
.need { display: grid; grid-template-columns: 4px 1fr auto; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px 14px 14px; box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.need:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.need .bar { align-self: stretch; border-radius: 4px; }
.need.lv-red .bar { background: var(--crit); } .need.lv-yellow .bar { background: var(--warn); } .need.lv-green .bar { background: var(--good); }
.need h3 { margin: 0 0 2px; font-size: 14.5px; } .need h3 a { color: var(--ink); } .need h3 a:hover { color: var(--brand); }
.why { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.why span { font-size: 12px; background: var(--surface-3); padding: 1px 9px; border-radius: 12px; color: var(--ink-2); }
.score { text-align: center; min-width: 54px; } .score b { font-size: 1.35rem; display: block; line-height: 1.2; } .score small { color: var(--muted); font-size: 11px; }
.mini-stack { width: 120px; }
@media (max-width: 640px) { .need { grid-template-columns: 4px 1fr; } .need .need-side { grid-column: 2; } }

/* =========================================================
   نموذج الرصد والتوصيات
   ========================================================= */
.ind-row { display: grid; grid-template-columns: 36px 1.3fr 120px 1.4fr; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.ind-row:last-of-type { border-bottom: 0; }
.ind-row .no { width: 32px; height: 32px; border-radius: 9px; background: var(--brand-soft); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.ind-row input[type=number] { text-align: center; font-size: 1.05rem; font-weight: 600; }
.ind-row .file a { font-size: 12.5px; }
@media (max-width: 720px) { .ind-row { grid-template-columns: 32px 1fr 96px; } .ind-row .file { grid-column: 2 / -1; } }
.progress-bar { position: sticky; top: 62px; z-index: 5; display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.progress-bar .meter { flex: 1; }

.rec { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; background: var(--surface); }
.rec .meta { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: center; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; }
.rec .body { white-space: pre-line; font-weight: 500; }
.rec .reply { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 13px; margin-top: 9px; font-size: 13.5px; white-space: pre-line; }
.rec details summary { cursor: pointer; color: var(--brand); font-size: 13px; margin-top: 9px; font-weight: 500; }
.pre { white-space: pre-line; }
.timeline { position: relative; padding-inline-start: 22px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; margin-bottom: 14px; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: -21px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); }

/* =========================================================
   الدخول
   ========================================================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--bg); }
.auth-brand { position: relative; overflow: hidden; color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(800px 500px at 90% 0%, rgba(200,150,62,.35), transparent 60%), radial-gradient(700px 600px at 0% 100%, rgba(20,149,138,.6), transparent 60%), linear-gradient(155deg, #062925 0%, #0b4a43 55%, #0f766e 100%); }
.auth-brand::after { content: ''; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 70%); pointer-events: none; }
.auth-brand > * { position: relative; z-index: 1; }
.auth-brand .top { display: flex; align-items: center; gap: 12px; } .auth-brand .top small { display: block; opacity: .7; font-size: 12.5px; }
.auth-brand h1 { font-size: clamp(2.2rem, 4vw, 3.4rem); line-height: 1.15; margin: 0 0 14px; font-weight: 700; letter-spacing: -.02em; }
.auth-brand h1 em { font-style: normal; background: linear-gradient(90deg, #f3d38f, #c8963e); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-brand p.lead { opacity: .82; max-width: 460px; font-size: 15.5px; line-height: 1.9; margin: 0; }
.feat { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; max-width: 520px; }
.feat div { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 12px; padding: 12px 14px; font-size: 13px; backdrop-filter: blur(6px); }
.feat b { display: block; font-size: 14px; margin-bottom: 2px; }
.auth-form { display: grid; place-items: center; padding: 32px 24px; }
.auth-form .box { width: 100%; max-width: 380px; }
.auth-form h2 { font-size: 1.5rem; margin-bottom: 4px; }
.auth-form p.sub { color: var(--muted); margin: 0 0 24px; font-size: 13.5px; }
.auth-form .btn { width: 100%; padding: 10px; font-size: 14.5px; }
.auth-single { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.auth-single .box { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.auth-single .logo { margin: 0 auto 12px; width: 52px; height: 52px; font-size: 18px; }
.auth-single h1 { text-align: center; font-size: 1.3rem; } .auth-single p.sub { text-align: center; color: var(--muted); font-size: 13px; }
.auth-single .btn { width: 100%; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-brand { padding: 28px 24px; gap: 22px; } .feat { display: none; } .auth-brand h1 { font-size: 2rem; } }

@media print {
  .side, .topbar, .foot, .btn, .no-print, .seg { display: none !important; }
  .app { display: block; } body { background: #fff; } .card, .kpi { break-inside: avoid; box-shadow: none; }
}

/* أيقونة الوضع */
#theme-btn .th-sun { display: none; }
:root[data-theme="dark"] #theme-btn .th-sun { display: block; } :root[data-theme="dark"] #theme-btn .th-moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) #theme-btn .th-sun { display: block; } :root:not([data-theme="light"]) #theme-btn .th-moon { display: none; } }
