/**
 * Components - UI parts that use theme variables only.
 * No inline colors. No !important.
 */
.theme-bg-subtle {
  background-color: var(--bg-3);
}

/* ══════════════════════════════════════════════════════════════
   AI Center (aic-*) — reusable page components, theme-aware only.
   ══════════════════════════════════════════════════════════════ */

/* Bold identity header bar (dark surface in every theme, including light ones) */
.aic-topbar {
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  border-radius: var(--radius-base);
  padding: 1.15rem 1.5rem;
}
.aic-topbar h1, .aic-topbar h2, .aic-topbar h3 { color: var(--text-inverse); margin: 0; }
.aic-topbar .aic-topbar-sub { color: color-mix(in srgb, var(--text-inverse) 65%, transparent); }
@supports not (color: color-mix(in srgb, red, blue)) {
  .aic-topbar .aic-topbar-sub { color: var(--text-inverse); opacity: .7; }
}

/* Connected/status summary card (icon dot + title/sub + action on the trailing side) */
.aic-status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-base);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.aic-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.aic-status-dot.on { background: var(--status-success-bg); }
.aic-status-dot.off { background: var(--status-danger-bg); }

/* Section label (small caps, like "AUTOMATIONS") */
.aic-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-2);
  margin: 1.5rem 0 .6rem;
}

/* Toggle row list item: colored dot + title + description + trailing switch */
.aic-toggle-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-base);
  padding: .9rem 1.1rem;
}
.aic-toggle-row + .aic-toggle-row { margin-top: .6rem; }
.aic-toggle-icon { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.aic-toggle-body { flex: 1; min-width: 0; }
.aic-toggle-body strong { display: block; color: var(--text-1); }
.aic-toggle-body small { color: var(--text-2); }
.aic-toggle-row .form-switch { margin: 0; flex-shrink: 0; }

/* Icon-on-top grid card (soft, centered — for overview/category grids) */
.aic-icon-grid-card {
  background: var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-base);
  padding: 1.25rem 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .55rem;
  height: 100%;
  transition: box-shadow var(--transition), transform var(--transition);
}
.aic-icon-grid-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.aic-icon-grid-card .aic-icon-circle {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.aic-icon-grid-card strong { color: var(--text-1); font-size: .92rem; }
.aic-icon-grid-card p { color: var(--text-2); font-size: .78rem; margin: 0; }

/* ══════════════════════════════════════════════════════════════
   AI Center v2 — tone system + refined cards/sections/tiles.
   يحل محل التلوين اليدوي المتكرر (style="background:color-mix(...)")
   بكلاسات موحّدة، ويقلل الضوضاء البصرية بدون أي تغيير في الألوان
   الأساسية للتطبيق (بيستخدم نفس متغيرات design-tokens.css فقط).
   ══════════════════════════════════════════════════════════════ */

/* درجات لون دلالية — تُستخدَم مع .aic-icon-circle / .aic-featured / .aic-section-head */
.aic-tone-indigo  { --aic-tone: var(--accent-1); }
.aic-tone-violet  { --aic-tone: var(--accent-2); }
.aic-tone-success { --aic-tone: var(--status-success-bg); }
.aic-tone-warning { --aic-tone: var(--status-warning-bg); }
.aic-tone-danger  { --aic-tone: var(--status-danger-bg); }
.aic-tone-info    { --aic-tone: var(--status-info-bg); }
.aic-tone-neutral { --aic-tone: var(--text-2); }

.aic-icon-grid-card .aic-icon-circle,
.aic-icon-circle {
  background: color-mix(in srgb, var(--aic-tone, var(--accent-1)) 14%, var(--bg-2));
  color: var(--aic-tone, var(--accent-1));
}

/* بطاقة الشبكة — نسخة أهدأ وأوضح تدرجاً هرمياً من القديمة */
.aic-icon-grid-card {
  box-shadow: var(--shadow-sm);
}
.aic-icon-grid-card .aic-icon-circle { width: 50px; height: 50px; font-size: 21px; }
.aic-icon-grid-card strong { font-size: .93rem; font-weight: 700; }
.aic-icon-grid-card p { line-height: 1.5; }
.aic-icon-grid-card.aic-featured {
  border-color: var(--aic-tone, var(--accent-1));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--aic-tone, var(--accent-1)) 14%, transparent), var(--shadow-sm);
}

/* عنوان قسم — بديل نمط h6.text-uppercase المتكرر يدوياً، بحد جانبي ملوّن هادئ */
.aic-section-head {
  display: flex;
  align-items: baseline;
  gap: .55rem;
  margin: 2.1rem 0 .9rem;
  padding-inline-start: .8rem;
  border-inline-start: 3px solid var(--aic-tone, var(--accent-1));
}
.aic-section-head .aic-section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--aic-tone, var(--accent-1)) 16%, var(--bg-2));
  color: var(--aic-tone, var(--accent-1));
  font-size: 10.5px;
  font-weight: 800;
  flex-shrink: 0;
}
.aic-section-head h2 {
  font-size: .82rem;
  font-weight: 800;
  letter-spacing: .04em;
  margin: 0;
  color: var(--text-1);
  text-transform: uppercase;
}
.aic-section-head .aic-section-sub {
  font-size: .78rem;
  color: var(--text-2);
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}

/* بلاطة صغيرة (health grid / provider strip) — تلغي تكرار style="border-color:..." */
.aic-mini-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: calc(var(--radius-base) - 5px);
  padding: .65rem .85rem;
  height: 100%;
}

/* قسم قابل للطي (خريطة تدفق الـ AI) — مطوي افتراضياً لتقليل الازدحام البصري في اللوحة */
.aic-collapsible summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.aic-collapsible summary::-webkit-details-marker { display: none; }
.aic-collapsible summary .aic-chevron { transition: transform var(--transition); color: var(--text-2); }
.aic-collapsible[open] summary .aic-chevron { transform: rotate(180deg); }
.aic-collapsible summary:focus-visible { outline: 2px solid var(--accent-1); outline-offset: 2px; border-radius: 6px; }

.form-control-max-w-7 { max-width: 7rem; }
.chart-h-220 { height: 220px; }
.chart-h-260 { height: 260px; }
.chart-h-300 { height: 300px; }

/* Report stat boxes - theme-aware (replaces bg-light) */
.report-stat-box {
  background: var(--bg-table-header);
  color: var(--text-primary);
  border-radius: var(--radius-base, 0.375rem);
}
.report-stat-box .text-muted { color: var(--text-secondary); }
.report-stat-success { background: color-mix(in srgb, var(--status-success-bg) 12%, var(--bg-table-header)); color: var(--text-primary); border-radius: var(--radius-base, 0.375rem); }
.report-stat-success .text-success { color: var(--status-success-bg); }
.report-stat-warning { background: color-mix(in srgb, var(--status-warning-bg) 12%, var(--bg-table-header)); color: var(--text-primary); border-radius: var(--radius-base, 0.375rem); }
.report-stat-warning .text-warning { color: var(--status-warning-bg); }
@supports not (color: color-mix(in srgb, red, blue)) {
  .report-stat-success { background: var(--bg-table-header); }
  .report-stat-warning { background: var(--bg-table-header); }
}
.dash-focus-bar-fill { width: calc(var(--bar-pct, 50) * 1%); }
.dash-perf-bar { width: calc(var(--bar-pct, 0) * 1%); }
.w-130 { width: 130px; }
.select-width-auto { width: auto; }

/* Customer combobox: trigger + dropdown with search inside list */
.customer-combobox { position: relative; display: block; }
.combobox-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: var(--input-padding, 0.5rem 0.75rem);
  background: var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-base);
  color: var(--text-main);
  font-family: var(--font-primary);
  font-size: inherit;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.combobox-trigger:hover { border-color: var(--accent-1); }
.customer-combobox.combobox-open .combobox-trigger { border-color: var(--accent-1); box-shadow: 0 0 0 3px var(--focus-ring); }
.combobox-trigger-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combobox-arrow {
  flex-shrink: 0;
  width: 0;
  height: 0;
  margin-inline-start: 0.5rem;
  border: 5px solid transparent;
  border-top-color: var(--text-muted);
  transition: transform var(--transition);
}
.customer-combobox.combobox-open .combobox-arrow { transform: rotate(180deg); }
.combobox-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border-1);
  border-radius: var(--radius-base);
  box-shadow: var(--shadow-hover);
  overflow: hidden;
}
.combobox-search-wrap { padding: 8px; border-bottom: 1px solid var(--border-1); }
.combobox-search { width: 100%; }
.combobox-list { max-height: 220px; overflow-y: auto; }
.combobox-option {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  color: var(--text-main);
  transition: background var(--transition);
}
.combobox-option:hover { background: var(--row-hover); }
.combobox-option { border-bottom: 1px solid var(--border-1); }
.combobox-option:last-child { border-bottom: none; }

/* Overview report: status & shipping company cards (flat palette) */
.overview-stat-cards { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.overview-stat-card {
  display: flex; align-items: center; gap: 0.75rem;
  min-width: 140px; padding: 0.75rem 1rem; border-radius: var(--radius-base, 6px);
  color: var(--text-inverse); font-weight: 600; box-shadow: var(--shadow-sm);
}
.overview-stat-card.overview-stat-card-light { color: var(--text-primary); }
.overview-stat-card-icon { font-size: 1.5rem; opacity: 0.95; }
.overview-stat-card-body { flex: 1; min-width: 0; }
.overview-stat-card-label { font-size: 0.8rem; opacity: 0.9; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.overview-stat-card-count { font-size: 1.25rem; line-height: 1.2; }
.overview-stat-card-1 { background: #1ABC9C; }
.overview-stat-card-2 { background: #2ECC71; }
.overview-stat-card-3 { background: #3498DB; }
.overview-stat-card-4 { background: #9B59B6; }
.overview-stat-card-5 { background: #2C3E50; }
.overview-stat-card-6 { background: #16A085; }
.overview-stat-card-7 { background: #27AE60; }
.overview-stat-card-8 { background: #2980B9; }
.overview-stat-card-9 { background: #8E44AD; }
.overview-stat-card-10 { background: #2C3E50; }
.overview-stat-card-11 { background: #F1C40F; }
.overview-stat-card-12 { background: #E67E22; }
.overview-stat-card-13 { background: #E74C3C; }
.overview-stat-card-14 { background: var(--bg-table-header); color: var(--text-primary); }
.overview-stat-card-15 { background: #95A5A6; }
.overview-stat-card-16 { background: #F39C12; }
.overview-stat-card-17 { background: #D35400; }
.overview-stat-card-18 { background: #C0392B; }
.overview-stat-card-19 { background: var(--bg-table-header); color: var(--text-primary); }
.overview-stat-card-20 { background: #7F8C8D; }

/* Knowledge Base: sidebar + main + accordion */
.kb-page { display: flex; flex-direction: column; min-height: 0; }
.kb-page .kb-layout { display: flex; gap: var(--space-4, 1rem); flex: 1; min-height: 0; }
.kb-sidebar { flex: 0 0 220px; background: var(--bg-card); border: 1px solid var(--border-1); border-radius: var(--radius-base); padding: var(--space-3); }
.kb-sidebar .nav-link { padding: 0.5rem 0.75rem; border-radius: var(--radius-base); color: var(--text-main); }
.kb-sidebar .nav-link:hover { background: var(--row-hover); }
.kb-sidebar .nav-link.active { background: var(--primary-color); color: var(--text-inverse); }
.kb-main { flex: 1; min-width: 0; }
.kb-answer-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem; }
.kb-copy-feedback { font-size: 0.875rem; color: var(--accent-1); margin-inline-start: 0.5rem; }
.kb-cat-card-link { color: inherit; }
.kb-cat-card-link:hover .kb-cat-card { border-color: var(--accent-1); box-shadow: var(--shadow-hover, 0 2px 8px rgba(0,0,0,.08)); }

/* Notification dropdown — clean panel, soft shadow, unread highlight */
.notifications-dropdown {
  min-width: 320px;
  max-width: 360px;
  max-height: 70vh;
  overflow-y: auto;
  border-radius: var(--radius-base, 8px);
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,0.12));
  border: 1px solid var(--border-color);
  padding: 0.5rem 0;
  background-color: var(--bg-card);
}
.notifications-dropdown .dropdown-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95rem;
  color: var(--text-primary);
}
.notifications-dropdown .dropdown-item {
  padding: 0.75rem 1rem;
  border-radius: 0;
  transition: background 0.15s ease;
  color: var(--text-primary);
}
.notifications-dropdown .dropdown-item:hover {
  background: var(--row-hover);
  color: var(--text-primary);
}
.notifications-dropdown .dropdown-item.unread {
  background: var(--row-hover);
}
.notifications-dropdown .dropdown-item.unread:hover {
  background: var(--row-hover);
}
.notifications-dropdown .notification-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

/* ==========================================================================
   Shared UI Utilities — Theme-Aware
   كل الكلاسات دي مربوطة بمتغيرات الثيم تلقائياً
   تقدر تستخدمها في أي صفحة بدون ما تعرف ألوان جديدة
   ========================================================================== */

/* --- Avatar circles --- */
.ui-avatar {
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--text-inverse);
  flex-shrink: 0; letter-spacing: .5px;
  border-radius: 50%;
}
.ui-avatar-sm  { width: 32px; height: 32px; font-size: .78rem; }
.ui-avatar-md  { width: 40px; height: 40px; font-size: .88rem; }

/* Header user profile — زر نظيف: اسم | أفاتار دائري | سهم (بدون صندوق Bootstrap) */
.header-user-menu {
  position: relative;
}

.dashboard-header .header-user-menu button.header-user-trigger {
  display: inline-block;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  background-image: none;
  color: inherit;
  box-shadow: none;
  outline: none;
  cursor: pointer;
  vertical-align: middle;
  -webkit-appearance: none;
  appearance: none;
  line-height: 1;
  transition: opacity 0.2s ease;
}

.dashboard-header .header-user-menu button.header-user-trigger::before,
.dashboard-header .header-user-menu button.header-user-trigger::after {
  display: none;
  content: none;
}

.dashboard-header .header-user-menu button.header-user-trigger:hover,
.dashboard-header .header-user-menu button.header-user-trigger:focus,
.dashboard-header .header-user-menu button.header-user-trigger:active,
.dashboard-header .header-user-menu button.header-user-trigger.show {
  background: transparent;
  border: none;
  box-shadow: none;
  color: inherit;
  opacity: 0.9;
  outline: none;
}

.dashboard-header .header-user-menu .header-user-trigger-inner {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.625rem;
  direction: inherit;
}

.dashboard-header .header-user-menu .header-user-name {
  display: inline-block;
  max-width: 10rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font-primary);
  color: var(--text-inverse);
  line-height: 1.25;
}

.dashboard-header .header-user-menu .header-user-chevron {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--text-inverse);
  opacity: 0.85;
  line-height: 1;
  flex-shrink: 0;
}

.dashboard-header .header-user-menu .header-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2.5rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  border-radius: 50%;
  overflow: hidden;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  border: 2px solid var(--text-inverse);
  box-shadow: none;
  box-sizing: border-box;
  --header-avatar-bg: color-mix(in srgb, var(--status-info-bg) 22%, var(--bg-card));
  --header-avatar-fg: color-mix(in srgb, var(--primary-color) 75%, var(--text-primary));
  background-color: var(--header-avatar-bg);
  color: var(--header-avatar-fg);
}

.dashboard-header .header-user-menu .header-user-avatar-text {
  display: block;
  line-height: 1;
  font-size: inherit;
  font-weight: inherit;
}

.dashboard-header .header-user-menu .header-user-avatar[data-avatar-tone="1"] {
  --header-avatar-bg: color-mix(in srgb, var(--primary-color) 18%, var(--bg-card));
  --header-avatar-fg: var(--primary-color);
}

.dashboard-header .header-user-menu .header-user-avatar[data-avatar-tone="2"] {
  --header-avatar-bg: color-mix(in srgb, var(--accent-2) 16%, var(--bg-card));
  --header-avatar-fg: var(--accent-2);
}

.dashboard-header .header-user-menu .header-user-avatar[data-avatar-tone="3"] {
  --header-avatar-bg: color-mix(in srgb, var(--status-success-bg) 16%, var(--bg-card));
  --header-avatar-fg: var(--status-success-bg);
}

.dashboard-header .header-user-menu .header-user-avatar[data-avatar-tone="4"] {
  --header-avatar-bg: color-mix(in srgb, var(--accent-1) 15%, var(--bg-card));
  --header-avatar-fg: var(--accent-1);
}

.dashboard-header .header-user-menu .header-user-avatar[data-avatar-tone="5"] {
  --header-avatar-bg: color-mix(in srgb, var(--status-warning-bg) 18%, var(--bg-card));
  --header-avatar-fg: color-mix(in srgb, var(--status-warning-bg) 85%, var(--text-primary));
}

.dashboard-header .header-user-menu .header-user-avatar .bi {
  font-size: 1.1rem;
  opacity: 0.85;
}

[data-header-style="light"] .dashboard-header .header-user-menu .header-user-name,
[data-header-style="light"] .dashboard-header .header-user-menu .header-user-chevron {
  color: var(--text-primary);
}

[data-header-style="light"] .dashboard-header .header-user-menu .header-user-avatar {
  border-color: var(--bg-card);
  box-shadow: 0 0 0 1px var(--border-color);
}

/* القائمة المنسدلة — خلفية بيضاء، ظل ناعم، أيقونات يسار النص (RTL) */
.header-user-menu .header-user-dropdown {
  --header-user-menu-bg: var(--bg-card);
  min-width: 15.5rem;
  margin-top: 0.625rem;
  padding: 0.375rem 0;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--header-user-menu-bg);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--text-primary) 14%, transparent);
  font-family: var(--font-primary);
  overflow: hidden;
}

.header-user-menu .header-user-dropdown-identity {
  padding: 1rem 1.15rem 0.75rem;
  list-style: none;
  text-align: start;
}

.header-user-menu .header-user-dropdown-name {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text-primary);
}

.header-user-menu .header-user-dropdown-role {
  margin-top: 0.15rem;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.35;
  color: var(--text-secondary);
}

.header-user-menu .header-user-dropdown-divider-wrap {
  list-style: none;
  margin: 0;
  padding: 0;
}

.header-user-menu .header-user-dropdown-divider {
  margin: 0.35rem 0;
  border-top-color: var(--border-color);
  opacity: 1;
}

.header-user-menu .header-user-dropdown-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.15rem;
  border-radius: 0;
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.35;
  transition: background-color 0.18s ease;
}

.header-user-menu .header-user-dropdown-label {
  flex: 1 1 auto;
  text-align: start;
}

.header-user-menu .header-user-dropdown-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.25rem;
  font-size: 1.125rem;
  color: var(--text-secondary);
  transition: color 0.18s ease;
}

.header-user-menu .header-user-dropdown-item:hover,
.header-user-menu .header-user-dropdown-item:focus {
  background: color-mix(in srgb, var(--text-primary) 5%, var(--header-user-menu-bg));
  color: var(--text-primary);
}

.header-user-menu .header-user-dropdown-item:hover .header-user-dropdown-icon,
.header-user-menu .header-user-dropdown-item:focus .header-user-dropdown-icon {
  color: var(--text-primary);
}

.header-user-menu .header-user-dropdown-item--logout,
.header-user-menu .header-user-dropdown-item--logout .header-user-dropdown-icon {
  color: var(--text-primary);
}

.header-user-menu .header-user-dropdown-item--logout:hover,
.header-user-menu .header-user-dropdown-item--logout:focus {
  background: color-mix(in srgb, var(--text-primary) 5%, var(--header-user-menu-bg));
  color: var(--text-primary);
}

.dashboard-body .header-user-menu .header-user-dropdown {
  background: var(--header-user-menu-bg);
}

.dashboard-body .header-user-menu .header-user-dropdown-item:hover,
.dashboard-body .header-user-menu .header-user-dropdown-item:focus,
.dashboard-body .header-user-menu .header-user-dropdown-item:active {
  background: color-mix(in srgb, var(--text-primary) 5%, var(--header-user-menu-bg));
  color: var(--text-primary);
}

.dashboard-body .header-user-menu .header-user-dropdown-item--logout:hover,
.dashboard-body .header-user-menu .header-user-dropdown-item--logout:focus,
.dashboard-body .header-user-menu .header-user-dropdown-item--logout:active {
  background: color-mix(in srgb, var(--text-primary) 5%, var(--header-user-menu-bg));
  color: var(--text-primary);
}

@media (max-width: 575.98px) {
  .dashboard-header .header-user-menu .header-user-name {
    max-width: 5.5rem;
    font-size: 0.8125rem;
  }
  .dashboard-header .header-user-menu .header-user-avatar {
    width: 2.25rem;
    height: 2.25rem;
    font-size: 0.72rem;
  }
}

.ui-avatar-lg  { width: 48px; height: 48px; font-size: 1.1rem; }
.ui-avatar-xl  { width: 56px; height: 56px; font-size: 1.3rem; }

/* --- Stat / info icon boxes --- */
.ui-icon-box {
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-base); flex-shrink: 0;
}
.ui-icon-box-sm { width: 36px; height: 36px; font-size: 1rem; }
.ui-icon-box-md { width: 44px; height: 44px; font-size: 1.2rem; }
.ui-icon-box-lg { width: 52px; height: 52px; font-size: 1.4rem; }

/* لون الأيقونة تبعاً للحالة — يتبع متغيرات الثيم */
.ui-icon-primary   { background: color-mix(in srgb, var(--primary-color) 12%, transparent); color: var(--primary-color); }
.ui-icon-success   { background: color-mix(in srgb, var(--status-success-bg) 12%, transparent); color: var(--status-success-bg); }
.ui-icon-warning   { background: color-mix(in srgb, var(--status-warning-bg) 12%, transparent); color: var(--status-warning-bg); }
.ui-icon-danger    { background: color-mix(in srgb, var(--status-danger-bg) 12%, transparent); color: var(--status-danger-bg); }
.ui-icon-info      { background: color-mix(in srgb, var(--status-info-bg) 12%, transparent); color: var(--status-info-bg); }
.ui-icon-secondary { background: color-mix(in srgb, var(--text-secondary) 10%, transparent); color: var(--text-secondary); }
.ui-icon-accent2   { background: color-mix(in srgb, var(--accent-2) 10%, transparent); color: var(--accent-2); }

/* --- Subtle badge backgrounds --- */
.ui-bg-primary   { background: color-mix(in srgb, var(--primary-color) 10%, transparent); }
.ui-bg-success   { background: color-mix(in srgb, var(--status-success-bg) 10%, transparent); }
.ui-bg-warning   { background: color-mix(in srgb, var(--status-warning-bg) 12%, transparent); }
.ui-bg-danger    { background: color-mix(in srgb, var(--status-danger-bg) 10%, transparent); }
.ui-bg-info      { background: color-mix(in srgb, var(--status-info-bg) 10%, transparent); }
.ui-bg-secondary { background: color-mix(in srgb, var(--text-secondary) 10%, transparent); }
.ui-bg-accent2   { background: color-mix(in srgb, var(--accent-2) 8%, transparent); }
.ui-bg-muted     { background: var(--bg-table-header); }

/* --- Subtle text colors --- */
.ui-text-primary   { color: var(--primary-color) !important; }
.ui-text-success   { color: var(--status-success-bg) !important; }
.ui-text-warning   { color: var(--status-warning-bg) !important; }
.ui-text-danger    { color: var(--status-danger-bg) !important; }
.ui-text-info      { color: var(--status-info-bg) !important; }
.ui-text-accent2   { color: var(--accent-2) !important; }
.ui-text-muted     { color: var(--text-secondary) !important; }

/* --- Interactive chip / toggle button --- */
.ui-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px; cursor: pointer;
  border: 1.5px solid var(--border-color);
  font-size: .82rem; line-height: 1.3;
  transition: border-color .15s, background .15s;
  background: var(--bg-card); user-select: none; color: var(--text-primary);
}
.ui-chip:hover   { border-color: var(--primary-color); background: color-mix(in srgb, var(--primary-color) 5%, var(--bg-card)); }
.ui-chip.checked { border-color: var(--primary-color); background: color-mix(in srgb, var(--primary-color) 8%, var(--bg-card)); }
.ui-chip-on  { display: none; color: var(--primary-color); }
.ui-chip-off { display: block; color: var(--border-color); }
.ui-chip.checked .ui-chip-on  { display: block; }
.ui-chip.checked .ui-chip-off { display: none; }

/* --- Section card with collapse --- */
.ui-section-card { border: 1px solid var(--border-color); border-radius: var(--radius-base); overflow: hidden; background: var(--bg-card); }
.ui-section-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; cursor: pointer; user-select: none;
  transition: background .15s; font-weight: 600;
  color: var(--text-primary); border-radius: inherit;
}
.ui-section-header:hover { background: var(--bg-table-header); }
.ui-section-chevron { font-size: .85rem; color: var(--text-secondary); transition: transform .2s; flex-shrink: 0; }
.ui-section-card.collapsed .ui-section-chevron { transform: rotate(-90deg); }
.ui-section-card.collapsed .ui-section-body    { display: none; }
.ui-section-body { border-top: 1px solid var(--border-color); background: var(--bg-body); }

/* --- Stat / KPI card --- */
.ui-stat-card {
  background: var(--bg-card); border: 1px solid var(--border-color);
  border-radius: var(--radius-base); padding: 1.2rem;
  box-shadow: var(--shadow-sm);
}
.ui-stat-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.ui-stat-label { font-size: .8rem; color: var(--text-secondary); margin-top: 4px; }

/* --- Progress bar — theme-aware --- */
.ui-progress { height: 4px; border-radius: 2px; background: var(--border-color); overflow: hidden; }
.ui-progress-bar { height: 100%; border-radius: 2px; background: var(--primary-color); transition: width .4s; }

/* --- Unsaved changes indicator --- */
.ui-dirty-badge {
  display: none;
  background: color-mix(in srgb, var(--status-warning-bg) 15%, var(--bg-card));
  color: var(--status-warning-bg); border: 1px solid var(--status-warning-bg);
  border-radius: 6px; padding: 4px 10px; font-size: .78rem; font-weight: 600;
}
.ui-dirty-badge.visible { display: inline-flex; align-items: center; gap: 5px; }

/* --- Page header icon (shield, gear, etc.) --- */
.ui-page-icon {
  width: 48px; height: 48px; border-radius: 14px;
  background: color-mix(in srgb, var(--primary-color) 12%, transparent);
  color: var(--primary-color);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}

/* Fallback for browsers without color-mix */
@supports not (color: color-mix(in srgb, #000, #fff)) {
  .ui-icon-primary, .ui-bg-primary, .ui-page-icon { background: var(--bg-table-header); color: var(--primary-color); }
  .ui-icon-success, .ui-bg-success { background: var(--bg-table-header); color: var(--status-success-bg); }
  .ui-icon-warning, .ui-bg-warning { background: var(--bg-table-header); color: var(--status-warning-bg); }
  .ui-icon-danger,  .ui-bg-danger  { background: var(--bg-table-header); color: var(--status-danger-bg); }
  .ui-icon-info,    .ui-bg-info    { background: var(--bg-table-header); color: var(--status-info-bg); }
  .ui-chip:hover, .ui-chip.checked { background: var(--bg-table-header); }
}

/* ── قناة المحادثة في الـ CRM (فيسبوك / تيليجرام / واتساب) — أفاتار + Badge ركن + شيب مصدر ── */
/* الحاويات overflow:visible عشان بادج الركن ما يتقصّش — الصورة نفسها دايرية بـ border-radius */
.wa-avatar, .cp-wa-avatar, .ava,
.crm-chat-header-avatar, #crmHeaderWaAvatar, #cpHeaderWaAvatar { overflow: visible !important; }

.crm-ch-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--card-bg, #fff);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
  display: flex !important;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: #fff;
  font-size: 10px;
  z-index: 6;
  overflow: visible;
}
.crm-ch-badge i { font-size: 10px; line-height: 1; }
.crm-ch-fb { background: #0866FF; }
.crm-ch-tg { background: #2AABEE; }
.wa-num-badge { z-index: 6; }

.crm-src-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 7px;
  border-radius: 999px;
  white-space: nowrap;
  vertical-align: middle;
}
.crm-src-chip i { font-size: 10px; }
.crm-src-fb { background: rgba(8, 102, 255, .13); color: #0866FF; }
.crm-src-tg { background: rgba(42, 171, 238, .16); color: #1c93d1; }
.crm-src-wa { background: rgba(37, 211, 102, .16); color: #128C4B; }
.csrc { margin: 3px 0; }

img.crm-ch-photo {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
  max-height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  z-index: 1;
}
