/* ==================================================================
   المجلس العربي للاختصاصات الصحية — لوحة القرار الإداري
   الهوية: #156b68 (الأخضر الرسمي) · #caa453 (الذهبي الرسمي)
   ألوان المخططات درجات مُتحقَّق منها من الهويّتين نفسهما:
     نهاراً  #00918a / #ab8532   ليلاً  #0d9a90 / #b28d3a
   (اجتازت: نطاق الإضاءة، حد التشبّع، فصل عمى الألوان، التباين)
   ================================================================== */

/* ==================================================================
   خط المراعي (Almarai) — مدمج في النظام، لا يعتمد على خطوط الجهاز.
   الملفات في fonts/ وتُخدَم من الحاوية نفسها؛ لا اتصال بأي مصدر خارجي،
   فيعمل الخط داخل الشبكة المغلقة وفي الطباعة كما هو.
   الأوزان: 300 خفيف · 400 عادي · 700 عريض · 800 أعرض.
   الرخصة: SIL Open Font License 1.1 — نصّها في fonts/OFL.txt
   ================================================================== */
@font-face {
  font-family: "Almarai"; font-style: normal; font-weight: 300; font-display: swap;
  src: url("fonts/almarai-300-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1,
    U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74,
    U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF;
}
@font-face {
  font-family: "Almarai"; font-style: normal; font-weight: 300; font-display: swap;
  src: url("fonts/almarai-300-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Almarai"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/almarai-400-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1,
    U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74,
    U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF;
}
@font-face {
  font-family: "Almarai"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("fonts/almarai-400-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Almarai"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/almarai-700-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1,
    U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74,
    U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF;
}
@font-face {
  font-family: "Almarai"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("fonts/almarai-700-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Almarai"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("fonts/almarai-800-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1,
    U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74,
    U+FE76-FEFC, U+102E0-102FB, U+10E60-10E7E, U+10EC2-10EC4, U+10EFC-10EFF;
}
@font-face {
  font-family: "Almarai"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("fonts/almarai-800-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --brand: #156b68;          /* الأخضر الرسمي */
  --brand-deep: #0e4a48;
  --brand-soft: #e3edec;
  --brand-softer: #f1f7f6;
  --gold: #caa453;           /* الذهبي الرسمي */
  --gold-deep: #a8842f;
  --gold-soft: #f7f0e0;

  --series-1: #00918a;       /* أخضر الهوية — درجة مخططات */
  --series-2: #ab8532;       /* ذهبي الهوية — درجة مخططات */
  --seq-1: #e3f2f0;
  --seq-2: #bfe2df;
  --seq-3: #8ecdc7;
  --seq-4: #4fb0a8;
  --seq-5: #00918a;
  --seq-6: #14726d;
  --seq-7: #0d514e;

  --surface-1: #ffffff;
  --surface-2: #f4f6f5;
  --page: #f7f9f8;
  --text-1: #0b0f0f;
  --text-2: #4f5654;
  --muted: #838a88;
  --grid: #e2e7e6;
  --border: rgba(11, 15, 15, .10);
  --border-strong: rgba(11, 15, 15, .18);

  --critical: #d03b3b;
  --serious: #ec835a;
  --warning: #fab219;
  --good: #0ca30c;

  --topbar-h: 130px;         /* يُحدَّث من app.js بقياس الترويسة الفعلي */
  --r-sm: 4px; --r-md: 8px; --r-lg: 12px;
  --shadow: 0 1px 2px rgba(11,15,15,.05), 0 10px 28px rgba(11,15,15,.07);
  /* المراعي أولاً — مدمج في الحاوية؛ وما بعده احتياط إن تعذّر تحميل الملف */
  --font: "Almarai", system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Naskh Arabic", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --brand: #2f9d98;
  --brand-deep: #86c9c5;
  --brand-soft: #162928;
  --brand-softer: #101c1c;
  --gold: #caa453;
  --gold-deep: #d8b76f;
  --gold-soft: #241f14;

  --series-1: #0d9a90;
  --series-2: #b28d3a;
  --seq-1: #0d2b29;
  --seq-2: #10403d;
  --seq-3: #145550;
  --seq-4: #0d7b74;
  --seq-5: #0d9a90;
  --seq-6: #4fb8b0;
  --seq-7: #8ed3cd;

  --surface-1: #14201f;
  --surface-2: #1b2827;
  --page: #0c1413;
  --text-1: #f2f6f5;
  --text-2: #b9c2c0;
  --muted: #7f8a88;
  --grid: #24312f;
  --border: rgba(255, 255, 255, .10);
  --border-strong: rgba(255, 255, 255, .20);
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 28px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0; background: var(--page); color: var(--text-1);
  font-family: var(--font); font-size: 15px; line-height: 1.55;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.3; }
code { font-family: ui-monospace, Consolas, monospace; font-size: .88em; }
.muted { color: var(--text-2); }
.tiny { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ ترويسة */
.topbar {
  position: sticky; top: 0; z-index: 40; background: var(--surface-1);
  border-bottom: 3px solid var(--brand);
}
.topbar-main {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px; flex-wrap: wrap;
  background: linear-gradient(90deg, var(--brand-softer), var(--surface-1) 55%);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo { height: 62px; width: auto; flex: none; }
.brand-text h1 { font-size: 18px; color: var(--brand); }
.brand-title { margin: 1px 0 0; font-size: 13.5px; font-weight: 600; color: var(--gold-deep); }
.brand-sub { margin: 2px 0 0; font-size: 12px; color: var(--text-2); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

#globalSearch {
  width: 280px; max-width: 58vw; padding: 8px 12px; border-radius: var(--r-md);
  border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text-1); font-family: inherit; font-size: 14px;
}
#globalSearch:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px;
  border-radius: var(--r-md); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-1);
  font-family: inherit; font-size: 14px; cursor: pointer;
}
.btn:hover { background: var(--grid); }
.btn-primary { background: var(--brand); color: #fff; border-color: transparent; font-weight: 600; }
.btn-primary:hover { background: var(--brand-deep); }
.btn-gold { background: var(--gold); color: #2b2205; border-color: transparent; font-weight: 600; }
.btn-gold:hover { background: var(--gold-deep); color: #fff; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: progress; }

.tabs { display: flex; gap: 2px; padding: 0 14px; overflow-x: auto; background: var(--surface-1); }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 9px 13px; font-family: inherit; font-size: 14px; color: var(--text-2);
  cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text-1); }
.tab[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--gold); font-weight: 600; }
.tab .tab-count {
  display: inline-block; margin-inline-start: 5px; padding: 0 5px; border-radius: 20px;
  background: var(--brand-soft); color: var(--brand); font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------ هيكل */
.view { padding: 18px; max-width: 1720px; margin: 0 auto; }
.loading, .empty { padding: 48px; text-align: center; color: var(--text-2); }
.section { margin-bottom: 24px; }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin-bottom: 10px; flex-wrap: wrap; border-inline-start: 4px solid var(--gold);
  padding-inline-start: 10px;
}
.section-head h2 { font-size: 16.5px; color: var(--brand); }
.section-head p { margin: 0; font-size: 12.5px; color: var(--text-2); }
.panel { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); }

/* ------------------------------------------------------------ مؤشرات */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 14px; }
.kpi-label { font-size: 12.5px; color: var(--text-2); }
.kpi-value { font-size: 27px; font-weight: 700; line-height: 1.12; }
.kpi-note { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.kpi-brand { border-inline-start: 3px solid var(--brand); }
.kpi-gold { border-inline-start: 3px solid var(--gold); }
.kpi-critical { border-inline-start: 3px solid var(--critical); }
.kpi-critical .kpi-value { color: var(--critical); }
.kpi-serious { border-inline-start: 3px solid var(--serious); }
.kpi-good { border-inline-start: 3px solid var(--good); }

.hero {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff; border-radius: var(--r-lg); padding: 18px 20px; margin-bottom: 14px;
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.hero .h-item { border-inline-start: 3px solid var(--gold); padding-inline-start: 11px; }
.hero .h-label { font-size: 12.5px; opacity: .88; }
.hero .h-value { font-size: 30px; font-weight: 700; line-height: 1.1; }
.hero .h-note { font-size: 11.5px; opacity: .82; }

/* شريط مكدّس أفقي (كان مفقوداً في هذه اللوحة فظهرت القطاعات فوق بعضها) */
.stack {
  display: flex; height: 22px; border-radius: var(--r-sm); overflow: hidden;
  gap: 2px; background: transparent;
}
.stack > div {
  display: grid; place-items: center; font-size: 11.5px; color: #fff;
  font-variant-numeric: tabular-nums; min-width: 2px;
}

/* المعين الملوّن: لون المجلس العلمي + الرمز الرقمي للاختصاص */
.dia {
  position: relative; width: 34px; height: 34px; flex: none;
  display: inline-grid; place-items: center; vertical-align: middle;
}
.dia i {
  position: absolute; inset: 3px; transform: rotate(45deg); border-radius: 4px;
  border: 1px solid rgba(11, 15, 15, .28); box-shadow: 0 1px 2px rgba(11,15,15,.12);
}
.dia b { position: relative; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.dia-lg { width: 52px; height: 52px; }
.dia-lg i { inset: 2px; border-radius: 6px; }
.dia-lg b { font-size: 17px; }
.dia-sm { width: 26px; height: 26px; }
.dia-sm b { font-size: 10px; }
.dia-xs { width: 21px; height: 21px; }
.dia-xs i { inset: 2px; border-radius: 3px; }
.dia-xs b { font-size: 8.5px; }
.council-dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 3px;
  transform: rotate(45deg); margin-inline-end: 7px;
  border: 1px solid rgba(11, 15, 15, .28); vertical-align: middle;
}

/* ------------------------------------------------------------ شارات */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px;
  border-radius: 20px; font-size: 12px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-1); white-space: nowrap;
}
.chip .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-critical { background: var(--critical); }
.dot-serious { background: var(--serious); }
.dot-warning { background: var(--warning); }
.dot-info { background: var(--muted); }
.dot-good { background: var(--good); }
.dot-active { background: var(--good); }
.dot-expired { background: var(--critical); }
.dot-not_accredited, .dot-unknown { background: var(--serious); }

.tier-critical { border-inline-start: 4px solid var(--critical); }
.tier-serious { border-inline-start: 4px solid var(--serious); }
.tier-warning { border-inline-start: 4px solid var(--warning); }
.tier-info { border-inline-start: 4px solid var(--muted); }
.tier-good { border-inline-start: 4px solid var(--good); }

/* ------------------------------------------------------------ فلاتر */
.filters {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px;
  padding: 10px 12px; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.filters label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 5px; }
.filters select {
  padding: 5px 9px; border-radius: var(--r-sm); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-1); font-family: inherit; font-size: 13px;
}
.filters .spacer { flex: 1; }
.filter-count { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ بنود القرار */
.dec {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 11px 14px; margin-bottom: 9px;
}
.dec-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.dec-rank {
  min-width: 30px; height: 24px; padding: 0 6px; border-radius: 6px; background: var(--brand-soft);
  color: var(--brand); display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dec-title { font-weight: 700; font-size: 14.5px; }
.dec-where { font-size: 13px; color: var(--text-1); margin-top: 5px; }
.dec-where b { color: var(--brand); }
.dec-why { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.dec-suggest {
  margin-top: 7px; padding: 6px 10px; border-radius: var(--r-sm);
  background: var(--gold-soft); border: 1px dashed var(--gold); font-size: 12.5px;
}
.dec-suggest b { color: var(--gold-deep); }
.dec-action {
  margin-top: 6px; padding: 6px 10px; border-radius: var(--r-sm);
  background: var(--brand-soft); border-inline-start: 3px solid var(--brand); font-size: 12.5px;
}
.dec-action b { color: var(--brand); }
.evidence { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.evidence .ev {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 1px 7px; font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.evidence .ev b { color: var(--text-1); }

/* ------------------------------------------------------------ جداول */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-1); }
/* ملاحظة: .table-wrap فيه overflow-x:auto فيصبح وعاء تمرير بارتفاع محتواه،
   فلا يعمل التصاق رأس الجدول داخله. يلزم لذلك تحديد max-height (تغيير سلوك
   متروك للاختيار)، ولذلك لا نضبط له top هنا. */
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
thead th {
  position: sticky; top: 0; z-index: 2; background: var(--brand); color: #fff;
  /* داخل .table-wrap لا يوجد وعاء تمرير رأسي، فالالتصاق يقاس من الصفحة */
  font-size: 12px; font-weight: 600; text-align: right; padding: 8px 10px;
  white-space: nowrap; cursor: pointer; user-select: none;
}
thead th.no-sort { cursor: default; }
thead th .arrow { color: var(--gold); font-size: 10px; margin-inline-start: 3px; }
tbody td { padding: 7px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--brand-softer); }
tbody tr.clickable { cursor: pointer; }
td.n, th.n { text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.zero { color: var(--muted); }
tfoot td {
  padding: 8px 10px; font-weight: 700; background: var(--brand-soft);
  border-top: 2px solid var(--brand); font-variant-numeric: tabular-nums;
}
.cell-main { font-weight: 600; }
.cell-sub { font-size: 11.5px; color: var(--text-2); }
.wrap-cell { max-width: 330px; white-space: normal; }

/* ------------------------------------------------------------ مخططات */
.chart-title { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; }
.chart-sub { font-size: 11.5px; color: var(--text-2); margin-bottom: 9px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 7px; }
.legend .key { display: inline-flex; align-items: center; gap: 5px; }
.legend .swatch { width: 11px; height: 11px; border-radius: 3px; }
.bar-row { display: grid; grid-template-columns: minmax(130px, 200px) 1fr auto; gap: 9px; align-items: center; margin-bottom: 5px; }
.bar-label { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: var(--grid); border-radius: var(--r-sm); height: 12px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--r-sm); background: var(--series-1); }
.bar-row.grouped .bar-track { height: 8px; margin-bottom: 2px; }
.bar-value { font-size: 12.5px; font-variant-numeric: tabular-nums; min-width: 36px; }

/* قمع مسار التشغيل + شريط مصغّر داخل الجداول */
.fn-row {
  display: grid; grid-template-columns: minmax(140px, 210px) 1fr auto;
  gap: 9px; align-items: center; margin-bottom: 6px;
}
.fn-drop { color: var(--critical); font-size: 11px; font-weight: 700; }
.minibar {
  display: block; height: 4px; border-radius: 2px; background: var(--seq-4);
  margin-top: 3px; min-width: 2px;
}

/* ------------------------------------------------------------ مصفوفة */
.matrix-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-1); max-height: 78vh; }
table.matrix { font-size: 12.5px; }
table.matrix th.corner, table.matrix th.rowhead {
  position: sticky; inset-inline-start: 0; z-index: 3; background: var(--surface-1);
  color: var(--text-1); text-align: right; font-weight: 600; min-width: 210px;
  border-inline-end: 1px solid var(--border-strong); cursor: pointer;
}
table.matrix th.corner { z-index: 5; background: var(--brand); color: #fff; }
table.matrix thead th { z-index: 4; }
table.matrix td {
  text-align: center; padding: 4px 3px; min-width: 62px; border: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
}
.cell-v { font-weight: 700; font-size: 12.5px; }
.cell-s { font-size: 10.5px; opacity: .82; }
.cell-empty { color: var(--muted); background: repeating-linear-gradient(135deg, transparent, transparent 5px, var(--grid) 5px, var(--grid) 6px); }
.cell-idle { outline: 2px solid var(--gold); outline-offset: -2px; }

/* ------------------------------------------------------------ دورة الحياة */
.life-row {
  display: grid; grid-template-columns: minmax(190px, 260px) 1fr; gap: 12px;
  align-items: center; padding: 7px 0; border-bottom: 1px solid var(--grid);
}
.life-name { font-size: 13px; }
.life-name .cell-sub { display: block; }
.life-track { position: relative; height: 26px; background: var(--surface-2); border-radius: var(--r-sm); }
.life-bar { position: absolute; top: 9px; height: 8px; border-radius: 4px; background: var(--series-1); opacity: .35; }
.life-dot {
  position: absolute; top: 4px; width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; font-size: 9.5px; font-weight: 700; color: #fff;
  transform: translateX(50%); border: 2px solid var(--surface-1);
}
.life-axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* محور السنوات أعلى دورة الحياة */
.year-axis { border-bottom: 1px solid var(--border-strong); padding: 4px 0 2px; }
.year-axis.is-sticky {
  position: sticky; top: calc(var(--topbar-h) + 2px); z-index: 6; background: var(--surface-1);
  box-shadow: 0 2px 0 var(--gold);
}
.year-axis-label { font-size: 11.5px; font-weight: 700; color: var(--brand); }
.year-axis-track { position: relative; height: 18px; }
.ytick {
  position: absolute; top: 0; font-size: 10.5px; color: var(--text-2);
  font-variant-numeric: tabular-nums; white-space: nowrap; line-height: 18px;
}
.ytick::after {
  content: ''; position: absolute; inset-inline-start: 50%; bottom: -4px;
  width: 1px; height: 4px; background: var(--axis);
}
.ytick-ref { color: var(--gold-deep); font-weight: 700; }
.ytick-ref::after { background: var(--gold); width: 2px; height: 6px; bottom: -6px; }

/* ------------------------------------------------------------ بطاقات البرامج */
.prog-wrap { display: grid; grid-template-columns: 288px minmax(0, 1fr); gap: 14px; align-items: start; }
/* min-width:0 ضروري: بدونه يتمدّد العمود بعرض أوسع جدول داخله فيفيض عن الصفحة */
.prog-wrap > * { min-width: 0; }
.prog-main, .pcard, .pcard-body, .pcard-sec { min-width: 0; }
.prog-rail {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 8px; overflow-y: auto; position: sticky;
  top: calc(var(--topbar-h) + 12px); max-height: calc(100vh - var(--topbar-h) - 42px);
}
.rail-group { margin-bottom: 10px; }
.rail-council {
  font-size: 11.5px; font-weight: 700; color: var(--brand); background: var(--brand-soft);
  padding: 4px 8px; border-radius: var(--r-sm); margin-bottom: 4px;
  display: flex; justify-content: space-between;
}
.rail-item {
  display: block; width: 100%; text-align: right; appearance: none; cursor: pointer;
  background: transparent; border: 0; border-inline-start: 3px solid transparent;
  padding: 6px 9px; border-radius: var(--r-sm); font-family: inherit; color: var(--text-1);
  position: relative;
}
.rail-item:hover { background: var(--surface-2); }
.rail-item.is-active {
  background: var(--brand-soft); border-inline-start-color: var(--gold); font-weight: 600;
}
.rail-name { display: block; font-size: 13px; line-height: 1.35; }
.rail-meta { display: block; font-size: 11px; color: var(--text-2); }
.rail-flag {
  position: absolute; inset-inline-end: 6px; top: 7px; min-width: 17px; height: 17px;
  border-radius: 9px; background: var(--critical); color: #fff; font-size: 10.5px;
  display: grid; place-items: center; font-variant-numeric: tabular-nums;
}

.pcard {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden;
}
.pcard-head {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff; padding: 16px 18px;
}
.pcard-title h2 { font-size: 21px; }
.pcard-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.pcard-meta .chip {
  background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.35); color: #fff;
}
.pcard-nums {
  display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  margin-top: 14px; padding-top: 13px; border-top: 1px solid rgba(255,255,255,.22);
}
.pnum { border-inline-start: 3px solid var(--gold); padding-inline-start: 9px; }
.pnum-l { font-size: 11.5px; opacity: .9; }
.pnum-v { font-size: 22px; font-weight: 700; line-height: 1.15; }
.pnum-n { font-size: 10.5px; opacity: .8; }

.pcard-body { padding: 4px 18px 18px; }
.pcard-sec { padding: 14px 0; border-bottom: 1px solid var(--grid); }
.pcard-sec:last-child { border-bottom: 0; }
.pcard-sec > h3 {
  font-size: 15px; color: var(--brand); margin-bottom: 9px;
  border-inline-start: 4px solid var(--gold); padding-inline-start: 9px;
}
.sec-note { font-size: 11.5px; font-weight: 400; color: var(--text-2); margin-inline-start: 6px; }
.pcard-foot { padding: 10px 18px 14px; border-top: 1px solid var(--grid); background: var(--surface-2); }

table.kvtable { width: 100%; font-size: 13.5px; }
table.kvtable th {
  width: 300px; text-align: right; font-weight: 600; color: var(--text-2);
  background: var(--surface-2); padding: 6px 10px; border: 1px solid var(--grid);
  font-size: 12.5px; position: static;
}
table.kvtable td { padding: 6px 10px; border: 1px solid var(--grid); }
.as-written { display: block; font-size: 11px; color: var(--muted); }

table.numtable { width: 100%; font-size: 13.5px; }
table.numtable thead th {
  background: var(--brand); color: #fff; padding: 7px 9px; font-size: 12px; text-align: center;
  position: static;
}
table.numtable thead th:first-child { text-align: right; }
table.numtable tbody th {
  text-align: right; font-weight: 600; padding: 7px 10px; border: 1px solid var(--grid);
  background: var(--surface-2); font-size: 12.5px; position: static;
}
table.numtable td { border: 1px solid var(--grid); }
table.numtable tr.is-total th, table.numtable tr.is-total td {
  background: var(--brand-soft); font-weight: 700;
}
.ok-note { margin-top: 8px; font-size: 12.5px; color: var(--good); }
.lag-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
table.ptable { font-size: 12.5px; }
table.ptable thead th { font-size: 11px; }

@media (max-width: 1080px) {
  .prog-wrap { grid-template-columns: 1fr; }
  .prog-rail { position: static; max-height: 260px; }
}
.d-request { background: var(--muted); }
.d-approved { background: var(--brand); }
.d-center { background: var(--series-2); }
.d-intake { background: var(--good); }
.d-grad { background: var(--gold-deep); }

/* ------------------------------------------------------------ بطاقات أداء */
.score-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; }
.score-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.score-head h3 { font-size: 15.5px; color: var(--brand); }
.ind { margin-bottom: 9px; }
.ind-top { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.ind-bar { height: 9px; border-radius: 5px; background: var(--grid); margin-top: 4px; overflow: hidden; }
.ind-fill { height: 100%; border-radius: 5px; }
.ind-desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.metric-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 8px; margin: 8px 0; }
.metric { background: var(--surface-2); border-radius: var(--r-md); padding: 6px 9px; }
.metric .m-label { font-size: 11px; color: var(--text-2); }
.metric .m-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sp-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 8px; border-radius: var(--r-sm); background: var(--surface-2);
  cursor: pointer; font-size: 13px; margin-bottom: 4px;
}
.sp-item:hover { background: var(--brand-soft); }

/* ------------------------------------------------------------ درج */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(11,15,15,.5); z-index: 50; }
.drawer {
  position: fixed; inset-block: 0; inset-inline-start: 0; width: min(1000px, 96vw);
  background: var(--page); z-index: 51; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 13px 18px; border-bottom: 3px solid var(--brand); background: var(--surface-1);
}
.drawer-head h2 { font-size: 17px; color: var(--brand); }
.drawer-head p { margin: 2px 0 0; font-size: 12.5px; }
.drawer-body { padding: 16px 18px 40px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 8px; }
.kv-item { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 10px; }
.kv-item .k { font-size: 11.5px; color: var(--text-2); }
.kv-item .v { font-size: 14.5px; font-weight: 600; }

/* ------------------------------------------------------------ تلميح */
.tooltip {
  position: fixed; z-index: 90; pointer-events: none; background: var(--surface-1);
  color: var(--text-1); border: 1px solid var(--brand); border-radius: var(--r-md);
  padding: 7px 10px; font-size: 12.5px; box-shadow: var(--shadow); max-width: 340px;
}

.footer {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px 26px; font-size: 12px; color: var(--muted);
  border-top: 1px solid var(--border); margin-top: 10px;
}
.notice {
  background: var(--gold-soft); border: 1px solid var(--gold); border-radius: var(--r-md);
  padding: 10px 13px; font-size: 13px; margin-bottom: 13px;
}
.notice b { color: var(--gold-deep); }
.prose { font-size: 14px; max-width: 96ch; }
.prose h3 { margin: 18px 0 6px; font-size: 15px; color: var(--brand); }
.prose p, .prose li { color: var(--text-2); }
.prose ul { margin: 6px 0; padding-inline-start: 20px; }
.prose li { margin-bottom: 4px; }
.prose strong { color: var(--text-1); }

@media (max-width: 760px) {
  .brand-logo { height: 46px; }
  #globalSearch { width: 170px; }
  .view { padding: 12px; }
}

/* ------------------------------------------------------------ طباعة
   الهوامش: @page يضبط هامش الورقة نفسها، ويُضاف هامش داخلي احتياطي على
   الحاوية حتى لا يلتصق المحتوى بالحافة إذا اختار المستخدم «بلا هوامش»
   في نافذة الطباعة (اختيار المتصفح يتغلّب على @page). */
@page { size: A4 portrait; margin: 12mm 10mm 14mm; }
@page wide { size: A4 landscape; margin: 10mm; }
/* طباعة بطاقة واحدة (برنامج أو مركز) على ورقة أفقية — يُعلَن خارج @media print
   لأن خاصية page لا تؤثر إلا في الوسائط المطبوعة أصلاً */
body.printing-card { page: wide; }

@media print {
  .topbar-actions, .tabs, .filters, .footer, .drawer, .drawer-backdrop,
  .prog-rail, .tooltip { display: none !important; }
  .topbar { position: static; border-bottom: 2px solid #156b68; }
  .topbar-main { background: none; }
  html, body { background: #fff; font-size: 11pt; }
  .view { padding: 4mm 2mm 0; max-width: none; }
  .hero, .pcard-head, .ind-fill, .bar-fill, .life-bar, .life-dot, .chip, .spark-bar {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .hero { background: #156b68 !important; }
  .prog-wrap { grid-template-columns: 1fr !important; }
  .pcard { border: 1px solid #156b68; box-shadow: none; }
  .year-axis.is-sticky { position: static; box-shadow: none; }
  .panel, .table-wrap, .kpi, .dec, .score-card, .pcard-sec, .life-row { break-inside: avoid; }
  .section { break-inside: auto; }
  body.printing-card .prog-wrap { display: block !important; }
}
