/* ─────────────────────────────────────────────────────────────────────────
   Portal identity colour. Each portal re-points the dk accent tokens, so
   everything already built on them (active nav item, primary buttons,
   links, focus rings, tab/segment highlights) takes the portal's hue with
   no per-page rules. Status colours (ok/warn/danger/info) never change.
   Fills are chosen so white text stays ≥ 4.5:1 in both themes.
   Loaded last.
   ───────────────────────────────────────────────────────────────────── */

/* فروش — سبزآبی */
body.sales-portal-active{
  --dk-accent:#0d6660;
  --dk-accent-fill:#0f766e;
  --dk-accent-soft:rgba(13,148,136,.12);
  --dk-focus:0 0 0 3px rgba(13,148,136,.25);
}
html[data-theme="dark"] body.sales-portal-active{
  --dk-accent:#5eead4;
  --dk-accent-fill:#0f766e;
  --dk-accent-soft:rgba(45,212,191,.14);
  --dk-focus:0 0 0 3px rgba(45,212,191,.28);
}

/* تولید محتوا — نارنجی سوخته */
body.content-portal-active{
  --dk-accent:#a8380b;
  --dk-accent-fill:#c2410c;
  --dk-accent-soft:rgba(234,88,12,.10);
  --dk-focus:0 0 0 3px rgba(234,88,12,.24);
}
html[data-theme="dark"] body.content-portal-active{
  --dk-accent:#fdba74;
  --dk-accent-fill:#c2410c;
  --dk-accent-soft:rgba(251,146,60,.14);
  --dk-focus:0 0 0 3px rgba(251,146,60,.28);
}

/* پشتیبانی — آبی */
body.support-portal-active{
  --dk-accent:#1d4ed8;
  --dk-accent-fill:#1d4ed8;
  --dk-accent-soft:rgba(37,99,235,.10);
  --dk-focus:0 0 0 3px rgba(37,99,235,.24);
}
html[data-theme="dark"] body.support-portal-active{
  --dk-accent:#93c5fd;
  --dk-accent-fill:#1d4ed8;
  --dk-accent-soft:rgba(96,165,250,.15);
  --dk-focus:0 0 0 3px rgba(96,165,250,.28);
}

/* مدیریت — همان بنفش پایه (dk-base.css)، بدون بازتعریف */

/* page-level aliases (--ch-*, --md-*, --tv-*) are declared on :root and
   resolve there, so they would keep the root indigo. Re-declare them on
   body so they follow the portal's accent. */
body:is(.sales-portal-active,.content-portal-active,.management-portal-active,.support-portal-active){
  --ch-accent:var(--dk-accent);     --ch-accent-soft:var(--dk-accent-soft);
  --md-accent:var(--dk-accent);     --md-accent-soft:var(--dk-accent-soft);
  --tv-accent:var(--dk-accent);     --tv-accent-soft:var(--dk-accent-soft);
}

/* ─────────────────────────────────────────────────────────────────────────
   Stat tones. Every stat tile gets a 3px bar on its top edge and a value
   in the matching text-safe colour, chosen by what the number means:
     money / success → ok · waiting / soon → warn · rejected / broken /
     expired → danger · time / running → info · special access → violet ·
     totals → the portal accent.
   Static tiles are matched by the id of their value (:has), generated ones
   by the type class their module already emits.
   ───────────────────────────────────────────────────────────────────── */
.dk-tone-ok,     :is(.ar-stat:has(#arStatPaid),.ar-stat:has(#arStatAmount),.ar-stat:has(#rrStatRefunded),.ar-stat:has(#rrStatAmount),.adm-stat:has(#admStatActive),.sa-stat-active,.ev-stat-active,.perfhub-kpi[data-kind="tasks"],.perfhub-kpi[data-kind="orders"],.tp-stat.is-ok,.noti-stat-card.is-ok){ --tone-bar:var(--dk-ok-mark); --tone-text:var(--dk-ok); }
.dk-tone-warn,   :is(.ar-stat:has(#arStatPending),.sa-stat-expiring,.tp-stat.is-warn,.cx-stat:has(#dashboardVariableCount)){ --tone-bar:var(--dk-warn-mark); --tone-text:var(--dk-text); }
.dk-tone-danger, :is(.ar-stat:has(#arStatRejected),.ar-stat:has(#rrStatRejected),.sa-stat-expired,.ev-stat-expired,.tp-stat.is-danger){ --tone-bar:var(--dk-danger-mark); --tone-text:var(--dk-text); }
.dk-tone-info,   :is(.ar-stat:has(#rrStatOpen),.adm-stat:has(#admStatVerified),.perfhub-kpi[data-kind="time"],.perfhub-kpi[data-kind="active"],.cx-stat:has(#dashboardApiState),.noti-stat-card.is-info){ --tone-bar:var(--dk-info); --tone-text:var(--dk-info); }
.dk-tone-violet, :is(.adm-stat:has(#admStatManagement),.cx-stat:has(#dashboardAiToolsCount),.perfhub-kpi[data-kind="comments"]){ --tone-bar:var(--dk-violet); --tone-text:var(--dk-violet); }
.dk-tone-accent, :is(.adm-stat:has(#admStatTotal),.sa-stat-products,.sa-stat-total,.ev-stat:not(.ev-stat-active):not(.ev-stat-expired),.perfhub-kpi[data-kind="admins"],.tp-stat.is-accent,.cx-stat:has(#dashboardProductsCount),.noti-stat-card.is-accent){ --tone-bar:var(--dk-accent-fill); --tone-text:var(--dk-accent); }

html body :is(#adminRequestsPage,#refundRequestsPage,#adminsPage,#studentAccountsPage,#performanceHubPage,#notificationsPage,#notificationsArchivePage,#reviewRequestsManagementPage,#eventsPage,#challengesPage,#projectsPage,#dashboardPage)
  :is(.ar-stat,.adm-stat,.sa-stat-card,.ev-stat,.perfhub-kpi,.tp-stat,.noti-stat-card,.cx-stat){
  position:relative !important;
}
html body :is(#adminRequestsPage,#refundRequestsPage,#adminsPage,#studentAccountsPage,#performanceHubPage,#notificationsPage,#notificationsArchivePage,#reviewRequestsManagementPage,#eventsPage,#challengesPage,#projectsPage,#dashboardPage)
  :is(.ar-stat,.adm-stat,.sa-stat-card,.ev-stat,.perfhub-kpi,.tp-stat,.noti-stat-card,.cx-stat)::before{
  content:"" !important; display:block !important; position:absolute !important; inset:0 0 auto 0 !important;
  width:auto !important; height:3px !important; border-radius:0 !important; opacity:1 !important; transform:none !important;
  background:var(--tone-bar, transparent) !important; box-shadow:none !important; filter:none !important;
}
html body :is(#adminRequestsPage,#refundRequestsPage,#adminsPage,#studentAccountsPage,#performanceHubPage,#notificationsPage,#notificationsArchivePage,#reviewRequestsManagementPage,#eventsPage,#challengesPage,#projectsPage,#dashboardPage)
  :is(.ar-stat,.adm-stat,.sa-stat-card,.ev-stat,.perfhub-kpi,.tp-stat,.noti-stat-card,.cx-stat)
  :is(.ar-stat-val,.adm-stat-val,.sa-stat-value,.ev-stat-value,.perfhub-kpi-value,.tp-stat-val,.noti-stat-value,b){
  color:var(--tone-text, var(--dk-text)) !important; -webkit-text-fill-color:currentColor !important;
}

/* warn/danger: the bar carries the tone; a red "۰" would raise a false alarm */
html body #performanceHubPage .perfhub-kpi[data-kind="time"] .perfhub-kpi-value{ font-size:18px !important; white-space:nowrap !important; }
