/* ==========================================================================
   مُوكِّل — Design System v7 (theme.css)
   الطبقة الأخيرة والوحيدة المسؤولة عن الهوية. مستوحاة من اللوجو:
   كحلي عميق + ذهبي معدني + رماديات محايدة.
   (بتحل محل brand-theme.css — !important مستخدمة بس لما لازم نغلب طبقات قديمة)
   ========================================================================== */

/* -------------------------------------------------------------------------
   1) Tokens
   ------------------------------------------------------------------------- */
:root {
  /* Brand */
  --navy-950: #070C18;
  --navy-900: #0B1222;
  --navy-800: #121B30;
  --navy-700: #1C2640;
  --navy-600: #2A3654;
  --gold-600: #A8841F;
  --gold-500: #C9A227;
  --gold-400: #D4AF37;
  --gold-300: #E8CC72;
  --gold-100: #FAF3DD;
  --gold-50:  #FDFAF0;
  --gold-gradient: linear-gradient(135deg, #F2DA8B 0%, #D4AF37 42%, #A8841F 100%);
  --navy-gradient: linear-gradient(135deg, #0B1222 0%, #18233D 100%);

  /* Neutrals */
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F8F9FB;
  --border: #E4E7EC;
  --border-strong: #D0D5DD;
  --text: #101828;
  --text-2: #344054;
  --text-3: #667085;
  --text-4: #98A2B3;

  /* Status */
  --c-success: #067647; --c-success-bg: #ECFDF3; --c-success-bd: #ABEFC6;
  --c-danger:  #B42318; --c-danger-bg:  #FEF3F2; --c-danger-bd:  #FECDCA;
  --c-warning: #B54708; --c-warning-bg: #FFFAEB; --c-warning-bd: #FEDF89;
  --c-info:    #175CD3; --c-info-bg:    #EFF8FF; --c-info-bd:    #B2DDFF;

  /* Shape & depth */
  --r-xs: 6px; --r-sm: 8px; --r-md: 10px; --r-lg: 14px; --r-xl: 18px; --r-full: 999px;
  --sh-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --sh-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --sh-md: 0 12px 24px -8px rgba(16, 24, 40, .14), 0 4px 8px -4px rgba(16, 24, 40, .06);
  --sh-lg: 0 24px 48px -12px rgba(16, 24, 40, .22);
  --ring: 0 0 0 4px rgba(212, 175, 55, .22);
  --ease: cubic-bezier(.2, .7, .2, 1);

  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  --font-num: 'IBM Plex Sans Arabic', 'Segoe UI', system-ui, sans-serif;
  --sidebar-w: 264px;
  --topbar-h: 60px;

  /* Legacy aliases — عشان كل الملفات القديمة تاخد الألوان الجديدة */
  --primary: var(--navy-900);
  --primary-hover: var(--navy-700);
  --primary-light: var(--gold-100);
  --primary-50: var(--gold-50);
  --primary-500: var(--navy-800);
  --primary-600: var(--navy-900);
  --brand-navy: var(--navy-900);
  --brand-navy-light: var(--navy-700);
  --brand-gold: var(--gold-400);
  --brand-gold-hover: var(--gold-600);
  --brand-gold-light: var(--gold-300);
  --brass: var(--gold-400);
  --brass-deep: var(--gold-600);
  --ink: var(--text);
  --ink-soft: var(--text-3);
  --paper: var(--surface);
  --line: var(--border);
  --text-primary: var(--text);
  --text-soft: var(--text-3);
  --text-muted: var(--text-4);
  --border-soft: var(--border);
  --border-light: var(--border);
  --bg-body: var(--bg);
  --bg-surface: var(--surface);
  --bg-hover: var(--surface-2);
  --gray-50: var(--surface-2);
  --gray-100: #F2F4F7;
  --gray-200: var(--border);
  --gray-300: var(--border-strong);
  --success: var(--c-success);
  --success-50: var(--c-success-bg);
  --success-500: #12B76A;
  --success-600: var(--c-success);
  --ok: var(--c-success);
  --danger: var(--c-danger);
  --danger-50: var(--c-danger-bg);
  --danger-500: #F04438;
  --danger-600: var(--c-danger);
  --bad: var(--c-danger);
  --warning: var(--c-warning);
  --warning-50: var(--c-warning-bg);
  --warning-500: #F79009;
  --warning-600: var(--c-warning);
  --font-sans: var(--font);
  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius: var(--r-md);
  --radius-lg: var(--r-lg);
  --radius-xl: var(--r-xl);
  --radius-full: var(--r-full);
  --shadow-xs: var(--sh-xs);
  --shadow-sm: var(--sh-sm);
  --shadow-md: var(--sh-md);
  --shadow-lg: var(--sh-lg);
  --shadow-xl: var(--sh-lg);
  --status-success: var(--c-success);
  --status-danger: var(--c-danger);
  --status-warning: var(--c-warning);
}

/* -------------------------------------------------------------------------
   2) Base
   ------------------------------------------------------------------------- */
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
body {
  font-family: var(--font) !important;
  background: var(--bg) !important;
  color: var(--text-2) !important;
  font-size: 14.5px !important;
  line-height: 1.65 !important;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { color: var(--text) !important; font-weight: 700 !important; letter-spacing: 0 !important; line-height: 1.35 !important; }
h2 { font-size: 22px !important; }
h3 { font-size: 16px !important; margin: 0 0 14px !important; }
h4 { font-size: 14.5px !important; }
a { color: var(--navy-800); }
::selection { background: var(--gold-100); color: var(--navy-900); }
.mono, .num, .stat .n { font-variant-numeric: tabular-nums; }
*:focus-visible { outline: none; box-shadow: var(--ring) !important; }

/* Mo icons (from js/icons.js) */
.mi { width: 1.15em; height: 1.15em; display: inline-block; vertical-align: -0.2em; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
h2 .mi, h3 .mi, h4 .mi { color: var(--gold-500); margin-inline-end: 6px; }
button .mi, .btn .mi { margin-inline-end: 6px; }

/* -------------------------------------------------------------------------
   3) App shell: topbar + sidebar + content
   ------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--navy-950) !important;
  border-bottom: 1px solid rgba(212, 175, 55, .28) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .03), 0 6px 18px rgba(7, 12, 24, .18) !important;
  padding: 0 20px !important;
  display: flex !important; align-items: center !important; gap: 12px;
}
.topbar .brand { display: flex !important; align-items: center !important; gap: 10px !important; margin-inline-end: auto; }
.topbar .brand-logo img { width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 2px 6px rgba(212, 175, 55, .35)); }
.topbar .brand h1 {
  display: block !important;
  font-size: 18px !important; font-weight: 700 !important; margin: 0 !important;
  background: var(--gold-gradient); -webkit-background-clip: text; background-clip: text; color: transparent !important;
}
.topbar-actions { display: flex !important; align-items: center !important; gap: 4px !important; margin: 0 !important; }
.topbar .icon-btn, .topbar .menu-btn, #logout-btn {
  width: 38px !important; height: 38px !important; padding: 0 !important; margin: 0 !important;
  display: inline-flex !important; align-items: center !important; justify-content: center !important;
  border-radius: var(--r-md) !important; border: 1px solid transparent !important;
  background: transparent !important; color: #C3CAD9 !important; transition: background .15s var(--ease), color .15s var(--ease) !important;
}
.topbar .icon-btn:hover, .topbar .menu-btn:hover { background: rgba(255, 255, 255, .06) !important; color: var(--gold-300) !important; }
#logout-btn:hover { background: rgba(240, 68, 56, .14) !important; color: #FDA29B !important; }
.topbar svg { width: 19px !important; height: 19px !important; stroke: currentColor !important; }
.topbar .search-trigger {
  display: inline-flex !important; align-items: center !important; gap: 10px !important;
  height: 38px !important; min-width: 240px; max-width: 320px !important; padding: 0 12px !important; margin: 0 8px !important;
  background: rgba(255, 255, 255, .05) !important; border: 1px solid rgba(255, 255, 255, .09) !important;
  border-radius: var(--r-md) !important; color: #98A2B3 !important; font-size: 13.5px !important; cursor: pointer;
}
.topbar .search-trigger:hover { border-color: rgba(212, 175, 55, .5) !important; color: #E4E7EC !important; }
.topbar .search-trigger svg { stroke: var(--gold-400) !important; width: 17px !important; height: 17px !important; }
.topbar .search-trigger-text { flex: 1; text-align: start; color: inherit !important; }
.topbar .search-trigger-kbd {
  font-family: var(--font) !important; font-size: 11px !important; color: #98A2B3 !important;
  border: 1px solid rgba(255, 255, 255, .12) !important; background: rgba(0, 0, 0, .25) !important;
  border-radius: 6px !important; padding: 1px 6px !important;
}

/* iPhone notch / status bar (apple-mobile-web-app-status-bar-style: black-translucent) */
@supports (padding-top: env(safe-area-inset-top)) {
  .topbar { padding-top: env(safe-area-inset-top) !important; height: calc(var(--topbar-h) + env(safe-area-inset-top)) !important; }
  .bottom-nav { padding-bottom: env(safe-area-inset-bottom) !important; }
}

/* Sidebar (drawer) */
.drawer {
  background: var(--navy-950) !important;
  border-inline-start: 1px solid rgba(212, 175, 55, .16);
  width: var(--sidebar-w) !important;
  display: flex; flex-direction: column;
}
.drawer, .drawer * { color: #C3CAD9; }
.drawer-header {
  background: transparent !important; padding: 18px 18px 14px !important;
  border-bottom: 1px solid rgba(255, 255, 255, .06) !important;
  display: flex; align-items: center; gap: 12px;
}
.drawer-logo { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; }
.drawer-title { color: #FFFFFF !important; font-weight: 700 !important; font-size: 15px !important; }
.drawer-subtitle { color: var(--gold-300) !important; font-size: 12px !important; }
.drawer-nav { padding: 10px !important; overflow-y: auto; flex: 1; }
.drawer-item {
  display: flex !important; align-items: center; gap: 12px;
  padding: 10px 12px !important; margin: 2px 0 !important; border-radius: var(--r-md) !important;
  color: #AEB6C6 !important; font-weight: 500 !important; font-size: 14px !important;
  border: none !important; background: transparent !important; width: 100%; text-align: start; cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.drawer-item svg { width: 19px !important; height: 19px !important; stroke: currentColor !important; opacity: .9; }
.drawer-item:hover { background: rgba(255, 255, 255, .05) !important; color: #FFFFFF !important; }
.drawer-item.active {
  background: linear-gradient(90deg, rgba(212, 175, 55, 0) 0%, rgba(212, 175, 55, .14) 100%) !important;
  color: var(--gold-300) !important; font-weight: 600 !important;
  box-shadow: inset -3px 0 0 var(--gold-400);
  border: none !important;
}
.drawer-item.active svg { stroke: var(--gold-400) !important; }
.drawer-sub, .drawer-subitem, .drawer-item-sub { font-size: 13px !important; }
.drawer-footer { background: transparent !important; border-top: 1px solid rgba(255, 255, 255, .06) !important; padding: 14px 16px !important; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--gold-gradient) !important; color: var(--navy-950) !important; font-weight: 700;
}
.user-name { color: #FFFFFF !important; font-weight: 600; font-size: 13.5px; }
.user-role { color: #8A94A6 !important; font-size: 12px; }

/* Content area */
#app { padding: 28px 28px 96px !important; max-width: 1320px !important; margin: 0 auto !important; }
#app > footer, #app-body > footer {
  text-align: center; color: var(--text-4) !important; font-size: 12.5px; padding: 18px 0 90px;
}

/* Desktop: sidebar ثابت + مفيش bottom nav */
@media (min-width: 1100px) {
  .drawer {
    position: fixed !important; top: var(--topbar-h) !important; right: 0 !important; bottom: 0 !important;
    transform: none !important; display: flex !important; z-index: 90 !important; box-shadow: none !important;
    height: auto !important;
  }
  .drawer-backdrop { display: none !important; }
  .topbar .menu-btn { display: none !important; }
  #app-body > main, #app { margin-inline-start: 0 !important; }
  #app-body { padding-right: var(--sidebar-w); }
  #app-body > .topbar { margin-right: calc(-1 * var(--sidebar-w)); }
  .bottom-nav { display: none !important; }
  #app-body > footer { padding-bottom: 24px; }
}

/* Superadmin mode: لوحة المنصة من غير قائمة وأزرار المكتب */
body.sa-mode .drawer, body.sa-mode .drawer-backdrop, body.sa-mode .bottom-nav,
body.sa-mode .topbar .menu-btn, body.sa-mode .topbar .search-trigger, body.sa-mode #notif-btn,
body.sa-mode #cfg-btn, body.sa-mode #pwa-install-btn, body.sa-mode .topbar a.icon-btn,
body.sa-mode #logout-btn, body.sa-mode #view-host { display: none !important; }
body.sa-mode #app-body { padding-right: 0 !important; }
body.sa-mode #app-body > .topbar { margin-right: 0 !important; }
body.sa-mode .topbar .brand::after {
  content: 'لوحة المنصة'; margin-inline-start: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  color: var(--gold-300); border: 1px solid rgba(212, 175, 55, .4); background: rgba(212, 175, 55, .08);
}

/* Bottom nav (mobile) */
.bottom-nav {
  background: rgba(7, 12, 24, .96) !important; backdrop-filter: blur(10px);
  border-top: 1px solid rgba(212, 175, 55, .22) !important; box-shadow: 0 -8px 24px rgba(7, 12, 24, .25) !important;
}
.bottom-nav-item { color: #8A94A6 !important; font-size: 11px !important; font-weight: 500 !important; }
.bottom-nav-item svg { stroke-width: 1.9 !important; }
.bottom-nav-item.active { color: var(--gold-300) !important; }
.bottom-nav-item.active .bottom-nav-icon { background: rgba(212, 175, 55, .14) !important; color: var(--gold-300) !important; }

/* -------------------------------------------------------------------------
   4) Page header
   ------------------------------------------------------------------------- */
.app-top {
  display: flex !important; align-items: center !important; justify-content: space-between !important;
  gap: 12px; flex-wrap: wrap; margin-bottom: 20px !important; padding: 0 !important;
  background: none !important; border: none !important;
}
.app-top h2 { margin: 0 !important; }
.section-header {
  display: flex !important; align-items: center !important; justify-content: space-between !important;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px !important;
}
.section-header h3 { margin: 0 !important; }

/* -------------------------------------------------------------------------
   5) Surfaces
   ------------------------------------------------------------------------- */
.card, .chart-card, .settings-content .card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--sh-xs) !important;
  padding: 20px !important;
  margin-bottom: 16px !important;
  color: var(--text-2) !important;
  transform: none !important;
}
.card:hover, .chart-card:hover { transform: none !important; box-shadow: var(--sh-xs) !important; }
.card[style*="gray-50"], .card[style*="--gray-50"] { background: var(--surface-2) !important; box-shadow: none !important; }
.card h3, .chart-card h3 { display: flex; align-items: center; gap: 8px; color: var(--text) !important; }
.card h1, .card h2, .card h3, .card h4 { color: var(--text) !important; }
.card p, .card span:not(.badge) { color: inherit; }

/* Stats */
.stats { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)) !important; gap: 14px !important; margin-bottom: 18px !important; }
.stat {
  background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--r-lg) !important;
  box-shadow: var(--sh-xs) !important; padding: 16px 18px !important; transform: none !important;
  display: flex !important; flex-direction: column; gap: 6px; position: relative; overflow: hidden;
  border-right-width: 1px !important; /* إلغاء الشرايط الملونة القديمة */
}
.stat:hover { transform: none !important; box-shadow: var(--sh-sm) !important; }
.stat .l { color: var(--text-3) !important; font-size: 13px !important; font-weight: 500 !important; display: flex; align-items: center; gap: 6px; }
.stat .n { color: var(--text) !important; font-size: 26px !important; font-weight: 700 !important; line-height: 1.2 !important; }
.stat .n.success { color: var(--c-success) !important; }
.stat .n.danger { color: var(--c-danger) !important; }
.stat .n.warning { color: var(--c-warning) !important; }
.stat .n.primary { color: var(--navy-900) !important; }
.stat:has(.stat-icon) { flex-direction: row !important; align-items: center; gap: 14px; }
.stat-icon {
  width: 44px !important; height: 44px !important; border-radius: 12px !important; flex-shrink: 0;
  display: inline-flex !important; align-items: center !important; justify-content: center !important;
  background: var(--gold-50) !important; color: var(--gold-600) !important; border: 1px solid var(--gold-100);
  font-size: 20px;
}
.stat-icon .mi { width: 22px; height: 22px; }
.stat-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* List rows */
.item {
  background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--r-md) !important;
  box-shadow: none !important; padding: 14px 16px !important; margin-bottom: 8px !important; transform: none !important;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease) !important; color: var(--text-2) !important;
}
.item:hover { border-color: var(--border-strong) !important; box-shadow: var(--sh-sm) !important; transform: none !important; }
.item .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.item .name { color: var(--text) !important; font-weight: 600 !important; font-size: 14.5px; }
.item .num { color: var(--text-3) !important; font-size: 13px; }
.item .meta, .meta { color: var(--text-3) !important; font-size: 13px !important; margin-top: 4px; }
.item .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.card .item { box-shadow: none !important; }

/* Info grid / rows */
.info-item, .info-row, .report-row, .settings-info-row {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.info-label { color: var(--text-3) !important; font-size: 13px; }
.info-value { color: var(--text) !important; font-weight: 600; }

/* -------------------------------------------------------------------------
   6) Buttons
   ------------------------------------------------------------------------- */
.btn, button.primary, button.ghost, .btn-primary, .btn-ghost, .btn-danger, .btn-secondary, .btn-outline {
  font-family: var(--font) !important; font-weight: 600 !important; font-size: 14px !important;
  min-height: 40px !important; padding: 0 16px !important; border-radius: var(--r-md) !important;
  display: inline-flex !important; align-items: center !important; justify-content: center !important; gap: 6px;
  cursor: pointer; text-shadow: none !important; transform: none !important; line-height: 1 !important;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease) !important;
}
.btn-block { display: flex !important; width: 100% !important; }
.btn-sm { min-height: 32px !important; padding: 0 12px !important; font-size: 13px !important; }

.btn-primary, button.primary, .btn-accent, .btn-gold, .btn-details {
  background: var(--navy-900) !important; background-image: none !important; color: #FFFFFF !important;
  border: 1px solid var(--navy-900) !important; box-shadow: var(--sh-xs), inset 0 1px 0 rgba(255, 255, 255, .06) !important;
}
.btn-primary:hover, button.primary:hover, .btn-accent:hover, .btn-gold:hover { background: var(--navy-700) !important; border-color: var(--navy-700) !important; }
.btn-primary:disabled, button.primary:disabled { opacity: .55; cursor: not-allowed; }
/* زرار مميز بالذهبي (CTA) */
.btn-gold, .landing-cta-primary {
  background: var(--gold-gradient) !important; color: var(--navy-950) !important; border: 1px solid var(--gold-500) !important;
}
.btn-gold:hover, .landing-cta-primary:hover { filter: brightness(1.04); box-shadow: 0 6px 16px rgba(212, 175, 55, .3) !important; }

.btn-ghost, button.ghost, .btn-secondary, .btn-outline, .btn-light {
  background: var(--surface) !important; color: var(--text-2) !important; border: 1px solid var(--border-strong) !important;
  box-shadow: var(--sh-xs) !important;
}
.btn-ghost:hover, button.ghost:hover, .btn-secondary:hover, .btn-outline:hover { background: var(--surface-2) !important; color: var(--text) !important; }
.item .acts button.ghost, .acts .ghost { min-height: 32px !important; padding: 0 10px !important; font-size: 13px !important; box-shadow: none !important; }
button.ghost[style*="danger"], .btn-ghost[style*="danger"] { color: var(--c-danger) !important; }
button.ghost[style*="danger"]:hover { background: var(--c-danger-bg) !important; border-color: var(--c-danger-bd) !important; }
.btn-danger { background: #D92D20 !important; color: #fff !important; border: 1px solid #D92D20 !important; }
.btn-danger:hover { background: #B42318 !important; }
.icon-btn { border-radius: var(--r-md); }

/* -------------------------------------------------------------------------
   7) Forms
   ------------------------------------------------------------------------- */
label, .label, .filter-label {
  display: block; color: var(--text-2) !important; font-size: 13px !important; font-weight: 500 !important; margin: 10px 0 6px !important;
}
.input, input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea, .filter-input, .select {
  width: 100%; background: var(--surface) !important; color: var(--text) !important;
  border: 1px solid var(--border-strong) !important; border-radius: var(--r-md) !important;
  padding: 9px 12px !important; min-height: 40px; font-family: var(--font) !important; font-size: 14px !important;
  box-shadow: var(--sh-xs) !important; transition: border-color .15s var(--ease), box-shadow .15s var(--ease) !important;
}
textarea { min-height: 90px; line-height: 1.6; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-4) !important; }
.input:focus, input:focus, select:focus, textarea:focus, .filter-input:focus {
  border-color: var(--gold-400) !important; box-shadow: var(--ring) !important; outline: none !important;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--navy-900); width: 16px; height: 16px; }
.row { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important; gap: 12px !important; }
.row > div > label:first-child { margin-top: 4px !important; }

/* Filter bar → toolbar */
.filter-bar {
  background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--r-lg) !important;
  padding: 12px !important; margin-bottom: 14px !important; box-shadow: var(--sh-xs) !important;
}
.filter-bar-inner { display: flex !important; flex-direction: row !important; flex-wrap: wrap !important; gap: 10px !important; align-items: flex-end !important; }
.filter-item { flex: 1 1 180px !important; min-width: 150px; width: auto !important; height: auto !important; }
.filter-bar-inner > .filter-reset { width: auto !important; flex: 0 0 auto !important; }
@media (max-width: 640px) { .filter-item { flex-basis: 100% !important; } .filter-bar-inner > .filter-reset { width: 100% !important; } }
.filter-item .filter-label { margin: 0 0 4px !important; font-size: 12px !important; color: var(--text-3) !important; }
.filter-reset { flex: 0 0 auto; }

/* -------------------------------------------------------------------------
   8) Tabs / segmented controls
   ------------------------------------------------------------------------- */
.filter-tabs, .case-tabs, .tabs, .money-tabs, .accounting-tabs {
  display: inline-flex !important; gap: 2px !important; padding: 3px !important; flex-wrap: nowrap; overflow-x: auto;
  background: #EAECF0 !important; border-radius: var(--r-md) !important; border: none !important; max-width: 100%;
  scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar, .case-tabs::-webkit-scrollbar { display: none; }
.case-tabs { display: flex !important; margin-bottom: 16px !important; }
.filter-tabs button, .case-tab, .tabs button, .money-tabs button, .accounting-tabs button, .period-btn {
  background: transparent !important; border: none !important; color: var(--text-3) !important;
  font-family: var(--font) !important; font-weight: 600 !important; font-size: 13.5px !important;
  padding: 7px 14px !important; border-radius: 8px !important; white-space: nowrap; cursor: pointer; min-height: 0 !important;
  box-shadow: none !important; transition: background .15s var(--ease), color .15s var(--ease);
}
.filter-tabs button:hover, .case-tab:hover, .tabs button:hover, .period-btn:hover { color: var(--text) !important; }
.filter-tabs button.active, .case-tab.active, .tabs button.active, .money-tabs button.active, .accounting-tabs button.active, .period-btn.active {
  background: var(--surface) !important; color: var(--navy-900) !important; box-shadow: var(--sh-sm) !important; border: none !important;
}
.period-btn { background: #EAECF0 !important; }
.period-btn.active { background: var(--navy-900) !important; color: #fff !important; }

/* -------------------------------------------------------------------------
   9) Badges / status
   ------------------------------------------------------------------------- */
.badge {
  display: inline-flex !important; align-items: center; gap: 4px; padding: 2px 10px !important; border-radius: var(--r-full) !important;
  font-size: 12px !important; font-weight: 600 !important; line-height: 1.6 !important; border: 1px solid transparent;
  background: #F2F4F7; color: var(--text-2);
}
.badge.active  { background: var(--c-success-bg) !important; color: var(--c-success) !important; border-color: var(--c-success-bd) !important; }
.badge.suspended { background: var(--c-danger-bg) !important; color: var(--c-danger) !important; border-color: var(--c-danger-bd) !important; }
.badge.trial   { background: var(--c-warning-bg) !important; color: var(--c-warning) !important; border-color: var(--c-warning-bd) !important; }
.status { font-size: 13px; color: var(--text-3); margin-top: 6px; }
.status.ok, .status.success { color: var(--c-success) !important; }
.status.bad { color: var(--c-danger) !important; }
.warn {
  background: var(--c-warning-bg) !important; border: 1px solid var(--c-warning-bd) !important; color: var(--c-warning) !important;
  border-radius: var(--r-md) !important; padding: 12px 14px !important; font-size: 13.5px;
}

/* Empty state */
.empty-state {
  text-align: center; padding: 28px 16px; color: var(--text-3);
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--r-lg);
}
.empty-state .empty-icon { display: flex; justify-content: center; margin-bottom: 8px; color: var(--text-4); font-size: 28px; }
.empty-state .empty-icon .mi { width: 32px; height: 32px; stroke-width: 1.6; }
.empty-state .empty-message { font-size: 13.5px; color: var(--text-3); }
.empty-state .empty-action { margin-top: 12px; }
.empty {
  text-align: center; padding: 36px 16px !important; color: var(--text-3) !important;
  background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--r-lg);
}
.empty .empty-icon, .empty > div:first-child { font-size: 0; }
.empty .mi { width: 36px; height: 36px; color: var(--text-4); display: block; margin: 0 auto 10px; }

/* -------------------------------------------------------------------------
   10) Welcome hero (لوحة التحكم)
   ------------------------------------------------------------------------- */
.welcome-hero {
  position: relative; overflow: hidden;
  background: var(--navy-gradient) !important; color: #fff !important;
  border-radius: var(--r-xl) !important; padding: 22px 26px !important; margin-bottom: 18px !important;
  display: flex !important; flex-direction: row !important; text-align: start !important;
  align-items: center !important; justify-content: space-between !important; gap: 16px; flex-wrap: wrap;
  border: 1px solid rgba(212, 175, 55, .22) !important; box-shadow: var(--sh-md) !important;
  min-height: 0 !important;
}
.welcome-hero > div { text-align: start !important; }
.welcome-hero::after {
  content: ''; position: absolute; inset-inline-start: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, .22) 0%, rgba(212, 175, 55, 0) 70%); pointer-events: none;
}
.welcome-hero::before { display: none !important; }
.welcome-label { color: var(--gold-300) !important; font-size: 13px !important; font-weight: 600 !important; }
.welcome-title { color: #FFFFFF !important; font-size: 24px !important; font-weight: 700 !important; margin-top: 2px; }
.welcome-sub { color: #AEB6C6 !important; font-size: 13px !important; }
.welcome-badge {
  position: relative; z-index: 1; background: rgba(255, 255, 255, .06) !important; border: 1px solid rgba(212, 175, 55, .35) !important;
  border-radius: var(--r-lg) !important; padding: 10px 16px !important;
  width: auto !important; min-width: 160px !important; max-width: none !important; height: auto !important; margin: 0 !important;
  text-align: start !important;
}
.badge-label { color: #AEB6C6 !important; font-size: 12px !important; }
.badge-value { color: var(--gold-300) !important; font-size: 22px !important; font-weight: 700 !important; }

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.quick-action-btn {
  display: flex !important; align-items: center !important; gap: 10px !important; justify-content: flex-start !important; flex-direction: row !important;
  background: var(--surface) !important; color: var(--text) !important; border: 1px solid var(--border) !important;
  border-radius: var(--r-md) !important; padding: 12px 14px !important; font-weight: 600 !important; font-size: 14px !important;
  box-shadow: none !important; text-shadow: none !important; cursor: pointer; transform: none !important;
}
.quick-action-btn * { color: inherit !important; text-shadow: none !important; -webkit-text-fill-color: currentColor !important; }
.quick-action-btn:hover { border-color: var(--gold-400) !important; background: var(--gold-50) !important; }
.quick-action-btn .qa-icon {
  width: 34px; height: 34px; border-radius: 9px; display: inline-flex !important; align-items: center; justify-content: center;
  background: var(--navy-900); color: var(--gold-300) !important;
}
.quick-action-btn .qa-icon .mi { stroke: var(--gold-300) !important; width: 18px; height: 18px; margin: 0; }

/* -------------------------------------------------------------------------
   11) Charts
   ------------------------------------------------------------------------- */
.charts-grid { display: grid !important; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)) !important; gap: 16px !important; }
.row { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)) !important; }
.chart-card h3 { font-size: 15px !important; margin-bottom: 12px !important; }
.chart-card h3 span { color: var(--text-3) !important; font-weight: 500 !important; font-size: 12.5px !important; }
.chart-wrapper { position: relative; height: 260px; }
.chart-wrapper.lg { height: 320px; }
.chart-wrapper.sm { height: 230px; }

/* Dashboard grid */
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------------------
   12) Modals
   ------------------------------------------------------------------------- */
.modal-overlay { background: rgba(7, 12, 24, .55) !important; backdrop-filter: blur(3px); }
.modal-card, .modal {
  background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--r-xl) !important;
  box-shadow: var(--sh-lg) !important; padding: 22px !important;
}
.modal-header { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 16px !important; }
.modal-header h3 { margin: 0 !important; }
.modal-footer { border-top: 1px solid var(--border); padding-top: 12px; display: flex; gap: 8px; justify-content: flex-end; }

/* Toast */
.toast-host .toast, .toast {
  font-family: var(--font) !important; border-radius: var(--r-md) !important; box-shadow: var(--sh-md) !important;
  background: var(--navy-900) !important; color: #fff !important; border: 1px solid rgba(212, 175, 55, .3) !important;
}

/* Skeleton */
.skeleton, .sk-line, .sk-bar {
  background: linear-gradient(90deg, #EEF0F3 0%, #F7F8FA 50%, #EEF0F3 100%) !important; background-size: 200% 100% !important;
  border-radius: 8px !important;
}

/* "المزيد" grid */
.more-grid { display: grid !important; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important; gap: 10px !important; }
.more-item {
  display: flex !important; flex-direction: column; align-items: center; gap: 10px; padding: 18px 10px !important;
  background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--r-lg) !important;
  cursor: pointer; box-shadow: none !important; transform: none !important;
}
.more-item:hover { border-color: var(--gold-400) !important; background: var(--gold-50) !important; }
.more-icon {
  width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--navy-900); color: var(--gold-300); font-size: 20px;
}
.more-icon .mi { width: 22px; height: 22px; stroke: var(--gold-300); }
.more-label { color: var(--text) !important; font-weight: 600; font-size: 13.5px; }

/* Calendar (Toast UI): لازم ارتفاع فعلي، وإلا كل أسابيع الشهر بتتراكب في صف واحد */
.calendar-host {
  height: 720px !important; min-height: 0 !important; padding: 8px !important;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden;
}
.calendar-host > .toastui-calendar-layout { height: 100% !important; }
.calendar-legends { display: flex; gap: 16px; margin: 4px 0 10px; font-size: 13px; color: var(--text-3); }
.cal-legend { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.calendar-actions { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 768px) {
  .calendar-host { height: 560px !important; }
  .calendar-actions { width: 100%; }
  .calendar-actions .btn { flex: 1 1 auto; }
}

/* Export menu */
.export-menu [role="menu"] { box-shadow: var(--sh-md) !important; border-color: var(--border) !important; }

/* -------------------------------------------------------------------------
   13) Login gate
   ------------------------------------------------------------------------- */
.gate-card-login {
  background: var(--surface) !important; border: 1px solid var(--border) !important; border-radius: var(--r-xl) !important;
  box-shadow: var(--sh-lg) !important; padding: 36px !important;
}
.gate-card-login h1 { color: var(--navy-900) !important; font-weight: 700 !important; }

/* -------------------------------------------------------------------------
   14) Responsive
   ------------------------------------------------------------------------- */
@media (max-width: 1099px) {
  .topbar .search-trigger { min-width: 0; }
}
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
@media (max-width: 768px) {
  #app { padding: 16px 14px 100px !important; }
  .topbar { padding: 0 8px !important; gap: 4px !important; }
  /* الشريط العلوي: الأسعار والإعدادات موجودين في القائمة الجانبية */
  .topbar a.icon-btn, #cfg-btn { display: none !important; }
  .topbar-actions { gap: 0 !important; flex-shrink: 0; }
  .topbar .icon-btn, .topbar .menu-btn, #logout-btn, .topbar .search-trigger { width: 36px !important; height: 36px !important; }
  .topbar .brand { min-width: 0; overflow: hidden; }
  .topbar .brand-logo img { width: 30px; height: 30px; }
  .topbar .brand h1 { font-size: 16px !important; white-space: nowrap; }
  /* تابات الإعدادات: صف أفقي بيتسحب */
  .settings-layout { display: block !important; }
  .settings-sidebar {
    display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; overflow-x: auto !important;
    position: static !important; width: auto !important; padding: 6px !important; gap: 6px !important; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .settings-sidebar::-webkit-scrollbar { display: none; }
  .settings-tab { flex-shrink: 0 !important; white-space: nowrap; width: auto !important; }
}
@media (max-width: 380px) {
  .topbar .brand h1 { display: none !important; }
}
@media (max-width: 768px) {
  .topbar .search-trigger { width: 38px !important; min-width: 0 !important; padding: 0 !important; justify-content: center !important; background: transparent !important; border-color: transparent !important; margin: 0 !important; }
  .topbar .search-trigger-text, .topbar .search-trigger-kbd { display: none !important; }
  .stat { padding: 14px !important; }
  .stat .n { font-size: 22px !important; }
  .stat-icon { width: 38px !important; height: 38px !important; }
  .welcome-hero { padding: 18px !important; flex-direction: column !important; align-items: stretch !important; }
  .welcome-badge { min-width: 0; flex: 1; }
  .welcome-title { font-size: 20px !important; }
  .card, .chart-card { padding: 16px !important; }
  h2 { font-size: 19px !important; }
}

/* Print */
@media print {
  .topbar, .drawer, .bottom-nav, .export-menu, .no-print { display: none !important; }
  #app-body { padding: 0 !important; }
  body { background: #fff !important; }
}

/* -------------------------------------------------------------------------
   15) خصوصية الذكاء الاصطناعي + مراجعة الأسانيد
   ------------------------------------------------------------------------- */
.ai-privacy-picker { display: grid; gap: 10px; }
.aip-option {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface);
  transition: border-color .2s, background .2s;
}
.aip-option:hover { border-color: var(--border-strong); }
.aip-option.selected { border-color: var(--gold-400); background: var(--gold-50); box-shadow: var(--ring); }
.aip-option input { margin-top: 4px; accent-color: var(--navy-900); flex-shrink: 0; }
.aip-title { font-weight: 700; color: var(--navy-900); margin-bottom: 2px; }
.aip-body { font-size: 13.5px; color: var(--text-2); line-height: 1.7; }
.aip-note { font-size: 12.5px; color: var(--c-warning); line-height: 1.7; margin-top: 4px; }
.aip-consent { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.7; color: var(--text-2); margin: 4px 0 2px; cursor: pointer; }
.aip-consent input { margin-top: 5px; flex-shrink: 0; accent-color: var(--navy-900); }
.cite-check { border-inline-start: 3px solid var(--gold-400); }
.cite-check .cite-ok { color: var(--c-success); font-weight: 600; }
.cite-check .cite-warn { color: var(--c-warning); font-weight: 600; }
.cite-badge { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; margin-inline-start: 6px; font-weight: 600; border: 1px solid transparent; }
.cite-badge.ok { background: var(--c-success-bg); color: var(--c-success); border-color: var(--c-success-bd); }
.cite-badge.warn { background: var(--c-warning-bg); color: var(--c-warning); border-color: var(--c-warning-bd); }
.cite-badge.info { background: var(--c-info-bg); color: var(--c-info); border-color: var(--c-info-bd); }

/* رمز زخرفي قديم في الفوتر كان بيظهر مكسور (□ آ ـ) */
footer::before { content: none !important; display: none !important; }

/* -------------------------------------------------------------------------
   16) الفريق والصلاحيات
   ------------------------------------------------------------------------- */
.perm-hidden { display: none !important; }
.team-list { display: grid; gap: 8px; }
.team-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface);
}
.team-row.inactive { opacity: .6; background: var(--surface-2); }
.team-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: var(--navy-gradient); color: var(--gold-300); font-weight: 700;
}
.team-info { flex: 1 1 200px; min-width: 0; }
.team-name { font-weight: 700; color: var(--navy-900); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.team-controls { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.team-controls select { height: 36px; min-width: 150px; }
.btn-sm { height: 34px !important; padding: 0 10px !important; font-size: 13px !important; }
.role-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.role-card { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.role-card.locked { opacity: .65; }
.role-title { font-weight: 700; color: var(--navy-900); }
.table-wrap { overflow-x: auto; }
.perm-matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm-matrix th, .perm-matrix td { border: 1px solid var(--border); padding: 7px 9px; text-align: right; vertical-align: top; }
.perm-matrix thead th { background: var(--surface-2); color: var(--navy-900); white-space: nowrap; }
.perm-matrix tbody th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.perm-matrix td.none { color: var(--text-4); text-align: center; }
.perm-matrix.editable td { display: flex; flex-wrap: wrap; gap: 4px 14px; border: 0; border-bottom: 1px solid var(--border); }
.perm-check { display: inline-flex; gap: 5px; align-items: center; font-size: 13px; cursor: pointer; }
.cr-editor { margin-top: 14px; padding: 14px; border: 1px dashed var(--gold-400); border-radius: var(--r-lg); background: var(--gold-50); }
.card.upsell { border-inline-start: 3px solid var(--gold-400); }
@media (max-width: 640px) { .team-controls select { min-width: 0; flex: 1 1 140px; } }

/* -------------------------------------------------------------------------
   17) الشغل من غير إنترنت — شريط الحالة
   ------------------------------------------------------------------------- */
#offline-banner {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 9000;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); text-align: center;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 -6px 18px rgba(16, 24, 40, .12);
}
#offline-banner.offline { background: var(--navy-900); color: var(--gold-300); }
#offline-banner.pending { background: var(--c-warning-bg); color: var(--c-warning); border-top: 1px solid var(--c-warning-bd); }
#offline-banner button {
  margin-inline-start: 10px; padding: 4px 12px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 12.5px;
  border: 1px solid currentColor; background: transparent; color: inherit;
}
@media (max-width: 768px) { #offline-banner { bottom: 64px; } } /* فوق شريط التنقل السفلي */

/* -------------------------------------------------------------------------
   18) مكان حفظ المستندات (سحابة / كمبيوتر المكتب)
   ------------------------------------------------------------------------- */
.att-storage { display: grid; gap: 6px; margin-top: 10px; }
.att-opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); font-size: 13.5px;
}
.att-opt:has(input:checked) { border-color: var(--gold-400); background: var(--gold-50); }
.att-opt input { margin-top: 4px; accent-color: var(--navy-900); }
.store-badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; border: 1px solid transparent; }
.store-badge.cloud { background: var(--c-info-bg); color: var(--c-info); border-color: var(--c-info-bd); }
.store-badge.device { background: var(--gold-50); color: var(--gold-600); border-color: rgba(212, 175, 55, .45); }

/* ==========================================================
   19) رسايل واتساب الجاهزة
   ========================================================== */
.wa-card { max-width: 520px; width: calc(100vw - 32px); }
.wa-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.wa-kinds { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.wa-kind {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  padding: 6px 12px; border-radius: 999px; font: 600 13px var(--font); cursor: pointer;
}
.wa-kind:hover { border-color: var(--gold-400); }
.wa-kind.active { background: var(--navy-gradient); color: #fff; border-color: transparent; }
.wa-warn {
  background: var(--c-warning-bg, #fff7e6); color: var(--c-warning, #9a6700); border: 1px solid var(--c-warning-bd, #f5d48a);
  padding: 8px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 10px;
}
.wa-label { display: block; font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.wa-text {
  width: 100%; box-sizing: border-box; min-height: 170px; resize: vertical; line-height: 1.8;
  padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2, var(--surface));
  color: var(--text); font: 14.5px var(--font);
}
.wa-text:focus { outline: none; border-color: #25d366; box-shadow: 0 0 0 3px rgba(37, 211, 102, .18); }
.wa-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.wa-btns { display: flex; gap: 8px; margin-inline-start: auto; }
.btn.wa-send, button.wa-send {
  background: #1fa855 !important; color: #fff !important; border: 0 !important; font-weight: 700;
}
.btn.wa-send:hover, button.wa-send:hover { background: #178a45 !important; }
.wa-ghost { color: #178a45 !important; }
[data-theme="dark"] .wa-ghost { color: #4ade80 !important; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .wa-ghost { color: #4ade80 !important; } }
.wa-list { display: grid; gap: 8px; max-height: 55vh; overflow: auto; }
.wa-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.wa-row.done { opacity: .7; }
.wa-row-info { display: flex; flex-direction: column; min-width: 0; }
.wa-row-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-tpl { display: grid; gap: 14px; }
.wa-tpl textarea { min-height: 150px; }
.wa-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.wa-chips code { background: var(--gold-50); color: var(--gold-600); padding: 2px 8px; border-radius: 6px; font-size: 12px; cursor: pointer; }

/* ==========================================================
   20) عدّاد رصيد الذكاء الاصطناعي
   ========================================================== */
.ai-meter {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px;
  padding: 10px 14px; border-radius: 12px; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2);
}
.ai-meter strong { color: var(--navy-900); font-variant-numeric: tabular-nums; }
[data-theme="dark"] .ai-meter strong { color: var(--gold-300); }
.ai-meter-bar { flex: 1 1 120px; min-width: 90px; height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.ai-meter-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--gold-gradient, #d4af37); transition: width .4s ease; }
.ai-meter-sub { font-size: 12px; color: var(--text-3); }
.ai-meter.compact { padding: 7px 12px; font-size: 12.5px; }
.ai-meter.low { border-color: var(--c-warning-bd); background: var(--c-warning-bg); }
.ai-meter.low .ai-meter-bar > span { background: var(--c-warning); }
.ai-meter.out { border-color: var(--c-danger-bd, #fecdca); background: var(--c-danger-bg, #fef3f2); }
.ai-meter.out .ai-meter-bar > span { background: var(--c-danger, #d92d20); }

/* ==========================================================
   21) الأجندة
   ========================================================== */
.ag-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.ag-title h2 { margin: 0; }
.ag-range { font-size: 15px; font-weight: 700; color: var(--gold-600); margin-top: 4px; }
.ag-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ag-nav { display: flex; gap: 4px; }
.ag-nav .btn { min-width: 40px; font-size: 16px; }
.ag-views { display: inline-flex; padding: 3px; gap: 2px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.ag-view { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font: 600 13px var(--font); color: var(--text-3); cursor: pointer; }
.ag-view:hover:not(.active) { color: var(--navy-900); }
.ag-view.active { background: var(--navy-gradient); color: #fff; }
.ag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.ag-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: 600 12.5px var(--font);
  transition: opacity .15s, background .15s;
}
.ag-chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex-shrink: 0; }
.ag-chip:not(.off):not(.ghost) { border-color: var(--c); background: color-mix(in srgb, var(--c) 9%, var(--surface)); }
.ag-chip.off { opacity: .5; text-decoration: line-through; }
.ag-chip.ghost { color: var(--text-3); }
.calendar-host { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 8px; min-height: 560px; }
.ag-ev-time { font-weight: 700; opacity: .85; }
.ag-allday-title { font-size: 11px; color: var(--text-3); }

/* عرض القائمة */
.ag-list { display: grid; gap: 14px; }
.ag-day { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.ag-day.today { border-color: var(--gold-400); box-shadow: 0 0 0 3px rgba(212, 175, 55, .15); }
.ag-day.past { opacity: .75; }
.ag-day-head { display: flex; align-items: center; gap: 10px; padding: 2px 2px 8px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.ag-day-num { font-size: 22px; font-weight: 800; color: var(--navy-900); min-width: 30px; text-align: center; }
.ag-day-name { font-size: 13.5px; color: var(--text-2); font-weight: 600; }
.ag-item {
  display: flex; gap: 12px; width: 100%; text-align: start; padding: 10px 8px; border: 0; background: transparent; cursor: pointer;
  border-radius: 10px; border-inline-start: 4px solid var(--c); margin: 4px 0; font: inherit; color: inherit;
}
.ag-item:hover { background: var(--surface-2, #f8fafc); }
.ag-item-time { min-width: 74px; font-size: 12.5px; font-weight: 700; color: var(--text-2); padding-top: 2px; }
.ag-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ag-item-kind { font-size: 11.5px; color: var(--c); font-weight: 700; }
.ag-item-title { font-size: 14.5px; font-weight: 700; color: var(--text); }
.ag-item-body { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-empty { text-align: center; padding: 40px 16px; color: var(--text-3); display: grid; gap: 10px; justify-items: center;
  background: var(--surface); border: 1px dashed var(--border); border-radius: 14px; }

/* التفاصيل والنموذج */
.ag-detail, .ag-form { width: calc(100vw - 32px); }
.ag-detail { max-width: 480px; border-top: 5px solid var(--c); }
.ag-form { max-width: 600px; max-height: 90vh; overflow: auto; }
.ag-detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.ag-detail-head h3 { margin: 4px 0 0; font-size: 18px; }
.ag-detail-kind { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--text-3); }
.ag-detail-kind .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.ag-detail-rows { display: grid; gap: 8px; margin-bottom: 12px; }
.ag-detail-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.ag-detail-row span { color: var(--text-3); white-space: nowrap; }
.ag-detail-row strong { text-align: end; }
.ag-detail-notes { background: var(--surface-2, #f8fafc); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; line-height: 1.8; white-space: pre-line; margin-bottom: 12px; }
.ag-resched { margin-bottom: 12px; }
.ag-resched summary { cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--navy-900); }
.ag-resched-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.ag-resched-row .input { flex: 1; min-width: 130px; }
.ag-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ag-kinds { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; margin-bottom: 14px; }
.ag-kind {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 12px; cursor: pointer; text-align: start;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: 600 12.5px var(--font); line-height: 1.4;
}
.ag-kind:hover { border-color: var(--c); }
.ag-kind.active { border: 2px solid var(--c); background: color-mix(in srgb, var(--c) 10%, var(--surface)); color: var(--text); padding: 8px 9px; }
.ag-kind-ic { font-size: 17px; }
.ag-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.ag-field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.ag-field .input { width: 100%; box-sizing: border-box; }
.ag-wide { grid-column: 1 / -1; }
.ag-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.ag-check input { width: auto; accent-color: var(--navy-900); }
.ag-form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
@media (max-width: 640px) {
  .ag-fields { grid-template-columns: 1fr; }
  .ag-kinds { grid-template-columns: 1fr 1fr; }
  .ag-controls { width: 100%; justify-content: space-between; }
  .calendar-host { min-height: 460px; padding: 4px; }
}
.ag-item.done .ag-item-title { text-decoration: line-through; color: var(--text-3); } .ag-item.done { opacity: .7; }

/* ==========================================================
   22) الإشعارات (قايمة الجرس) + إعدادات الإشعارات + نافذة البحث
   ========================================================== */
.np-backdrop { display: none; }
.np {
  position: fixed; z-index: 1200; display: flex; flex-direction: column;
  max-height: min(620px, calc(100vh - 90px)); background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 24px 60px -18px rgba(11, 18, 34, .45);
  opacity: 0; transform: translateY(-6px); transition: opacity .15s ease, transform .15s ease;
}
.np.open { opacity: 1; transform: none; }
.np::before {
  content: ''; position: absolute; top: -7px; left: calc(var(--arrow-x, 40px) - 7px); width: 14px; height: 14px;
  background: var(--surface); border-top: 1px solid var(--border); border-left: 1px solid var(--border); transform: rotate(45deg);
}
.np-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px 10px; }
.np-title { font-weight: 800; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.np-unread-count:not(:empty) { background: var(--c-danger, #d92d20); color: #fff; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; }
.np-head-actions { display: flex; align-items: center; gap: 4px; }
.np-link { border: 0; background: none; color: var(--navy-900); font: 600 12.5px var(--font); cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.np-link:hover { background: var(--surface-2, #f2f4f7); }
.np-link.danger { color: var(--c-danger, #d92d20); }
.np-icon-btn { border: 0; background: none; width: 32px; height: 32px; border-radius: 8px; cursor: pointer; color: var(--text-3); display: grid; place-items: center; }
.np-icon-btn:hover { background: var(--surface-2, #f2f4f7); color: var(--text); }
.np-close { display: none; }
.np-tabs { display: flex; gap: 4px; padding: 0 16px 10px; border-bottom: 1px solid var(--border); }
.np-tab { border: 0; background: none; padding: 6px 12px; border-radius: 999px; font: 600 13px var(--font); color: var(--text-3); cursor: pointer; }
.np-tab.active { background: var(--navy-gradient); color: #fff; }
.np-list { overflow-y: auto; flex: 1; outline: none; padding: 4px 0 6px; overscroll-behavior: contain; border-radius: 0 0 16px 16px; }
.np-group { font-size: 11.5px; font-weight: 700; color: var(--text-3); padding: 10px 16px 4px; }
.np-item {
  position: relative; display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: start;
  padding: 10px 16px; cursor: pointer; transition: background .12s; outline: none;
}
.np-item:hover, .np-item:focus-visible { background: var(--surface-2, #f8fafc); }
.np-item.unread { background: color-mix(in srgb, var(--gold-400, #d4af37) 7%, var(--surface)); }
.np-item.unread:hover { background: color-mix(in srgb, var(--gold-400, #d4af37) 12%, var(--surface)); }
.np-item.urgent::before { content: ''; position: absolute; top: 8px; bottom: 8px; inset-inline-start: 0; width: 3px; border-radius: 3px; background: var(--c-danger, #d92d20); }
.np-ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
.np-body { min-width: 0; }
.np-item-title { font-size: 13.5px; font-weight: 700; line-height: 1.5; color: var(--text); }
.np-item.read .np-item-title { font-weight: 600; color: var(--text-2); }
.np-item-text { font-size: 12.5px; color: var(--text-3); line-height: 1.6; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.np-meta { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 11.5px; color: var(--text-3); flex-wrap: wrap; }
.np-chip { padding: 0 7px; border-radius: 999px; background: color-mix(in srgb, var(--c) 12%, var(--surface)); color: var(--c); font-weight: 700; }
.np-chip.urgent { background: var(--c-danger-bg, #fef3f2); color: var(--c-danger, #d92d20); }
.np-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.np-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--gold-500, #c9a227); margin-top: 6px; }
.np-act { border: 0; background: none; width: 26px; height: 26px; border-radius: 8px; cursor: pointer; color: var(--text-3); font-size: 12px; opacity: 0; transition: opacity .12s; }
.np-item:hover .np-act, .np-item:focus-within .np-act { opacity: 1; }
.np-act:hover { background: var(--border); color: var(--text); }
.np-more { display: block; width: calc(100% - 32px); margin: 8px 16px; padding: 8px; border: 1px dashed var(--border); border-radius: 10px; background: none; color: var(--text-2); font: 600 12.5px var(--font); cursor: pointer; }
.np-foot { border-top: 1px solid var(--border); padding: 6px 10px; display: flex; justify-content: center; }
.np-empty { text-align: center; padding: 36px 20px; color: var(--text-3); display: grid; gap: 6px; justify-items: center; }
.np-empty-ic { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2, #f2f4f7); color: var(--text-3); font-size: 24px; }
.np-empty-title { font-weight: 700; color: var(--text-2); }
.np-empty-sub { font-size: 12.5px; max-width: 260px; line-height: 1.7; }
.np-skel { padding: 6px 16px; display: grid; gap: 14px; }
.np-skel-row { display: grid; grid-template-columns: 38px 1fr; gap: 10px; }
.np-skel-row span, .np-skel-row i { display: block; border-radius: 10px; background: var(--border); animation: npPulse 1.2s ease-in-out infinite; }
.np-skel-row span { height: 38px; }
.np-skel-row i { height: 10px; margin: 6px 0; }
.np-skel-row i + i { width: 60%; }
@keyframes npPulse { 50% { opacity: .45; } }
@media (hover: none) { .np-act { opacity: 1; } }
@media (max-width: 640px) {
  .np.sheet { top: auto !important; left: 0 !important; right: 0 !important; bottom: 0 !important; width: auto !important; max-height: 82vh; border-radius: 20px 20px 0 0; transform: translateY(20px); padding-bottom: env(safe-area-inset-bottom, 0); }
  .np.sheet.open { transform: none; }
  .np.sheet::before { display: none; }
  .np-close { display: grid; }
  .np-backdrop { display: block; position: fixed; inset: 0; z-index: 1199; background: rgba(11, 18, 34, .45); opacity: 0; transition: opacity .15s; }
  .np-backdrop.open { opacity: 1; }
}

/* إعدادات الإشعارات */
.nt-card { margin-bottom: 16px; }
.nt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.nt-head h3 { margin: 0 0 4px; }
.nt-head .meta { margin: 0; line-height: 1.8; max-width: 620px; }
.nt-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; padding: 14px 0; border-top: 1px solid var(--border); cursor: pointer; }
.nt-row.off .nt-row-title, .nt-row.off .nt-row-desc { opacity: .55; }
.nt-row-ic { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2, #f2f4f7); font-size: 18px; }
.nt-row-title { font-weight: 700; font-size: 14.5px; color: var(--text); cursor: pointer; }
.nt-row-desc { font-size: 12.5px; color: var(--text-3); line-height: 1.7; margin-top: 2px; }
.nt-extra { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.nt-extra .input { width: auto; min-width: 170px; padding: 6px 10px; }
.nt-switch { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.nt-switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; width: 100%; height: 100%; }
.nt-slider { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong, #d0d5dd); transition: background .2s; }
.nt-slider::after { content: ''; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.nt-switch input:checked + .nt-slider { background: #12B76A; }
.nt-switch input:checked + .nt-slider::after { transform: translateX(-20px); }
.nt-switch input:focus-visible + .nt-slider { box-shadow: 0 0 0 3px rgba(18, 183, 106, .3); }
.nt-switch input:disabled + .nt-slider { opacity: .5; }
.nt-saved { font-size: 12.5px; font-weight: 700; color: #039855; opacity: 0; transition: opacity .2s; }
.nt-saved.show { opacity: 1; }
.nt-saved.bad { color: var(--c-danger, #d92d20); }

/* نافذة البحث: على الكمبيوتر كارت في النص فوق خلفية معتمة (على الموبايل تفضل شاشة كاملة) */
@media (min-width: 641px) {
  body .search-modal { position: fixed !important; inset: 0 !important; z-index: 99999; display: flex !important; align-items: flex-start !important; justify-content: center !important; padding: 9vh 16px 16px !important; }
  body .search-backdrop { position: absolute; inset: 0; background: rgba(11, 18, 34, .55); backdrop-filter: blur(6px); }
  body .search-panel {
    position: relative !important; width: min(680px, 100%) !important; max-width: 680px !important; height: auto !important; max-height: 74vh !important;
    border-radius: 18px !important; overflow: hidden; display: flex !important; flex-direction: column; background: var(--surface) !important;
    border: 1px solid var(--border); box-shadow: 0 30px 80px -20px rgba(11, 18, 34, .55) !important; animation: gsIn .16s ease-out !important;
  }
  body .search-results { flex: 1; overflow-y: auto; max-height: none !important; }
  body .search-footer { display: flex !important; }
}
@keyframes gsIn { from { opacity: 0; transform: translateY(-8px) scale(.99); } to { opacity: 1; transform: none; } }
body .search-result-item.selected, body .search-result-item:hover { background: color-mix(in srgb, var(--gold-400, #d4af37) 12%, var(--surface)) !important; }
.view-page { display: contents; }

/* ==========================================================
   23) الإدارة المالية — الوضع المبسط + كشف حساب الموكل
   ========================================================== */
.ms-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ms-top h2 { margin: 0 0 6px; }
.ms-month { display: flex; align-items: center; gap: 8px; }
.ms-month strong { font-size: 15px; color: var(--gold-600); min-width: 120px; text-align: center; }
.ms-acc { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer;
  padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.ms-acc input { width: auto; accent-color: var(--navy-900); }
.ms-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.ms-card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px; display: grid; gap: 6px; }
.ms-card span { font-size: 13px; font-weight: 700; color: var(--text-2); }
.ms-card strong { font-size: 26px; font-weight: 800; color: var(--navy-900); font-variant-numeric: tabular-nums; }
.ms-card small { font-size: 12px; color: var(--text-3); line-height: 1.6; }
.ms-card.in { border-top: 4px solid #12B76A; }
.ms-card.out { border-top: 4px solid #F79009; }
.ms-card.net.pos { border-top: 4px solid var(--gold-400); background: color-mix(in srgb, var(--gold-400) 6%, var(--surface)); }
.ms-card.net.neg { border-top: 4px solid var(--c-danger, #d92d20); }
.ms-card.net.neg strong { color: var(--c-danger, #d92d20); }
.ms-row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 12px; }
.ms-have-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.ms-have-grid div { background: var(--surface-2, #f8fafc); border-radius: 12px; padding: 12px; display: grid; gap: 4px; }
.ms-have-grid span { font-size: 12.5px; color: var(--text-3); }
.ms-have-grid strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.ms-quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ms-debtors { display: grid; gap: 4px; }
.ms-debtor { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); }
.ms-debtor:last-child { border-bottom: 0; }
.ms-debtor-info { display: grid; min-width: 0; }
.ms-debtor-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-debtor-amt { font-weight: 800; color: var(--c-danger, #d92d20); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ms-debtor-acts { display: flex; gap: 6px; }
.exp-who { font-weight: 700; }
.exp-who.client { color: #6172F3; }
.exp-who.office { color: var(--text-3); }
.st-card { max-width: 780px; width: calc(100vw - 32px); max-height: 90vh; display: flex; flex-direction: column; }
.st-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.st-head h3 { margin: 2px 0 0; }
.st-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.st-totals div { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; }
.st-totals span { font-size: 12px; color: var(--text-3); }
.st-totals strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.st-totals .ok, .st-table .ok { color: #039855; }
.st-totals .due { border-color: color-mix(in srgb, var(--c-danger, #d92d20) 40%, var(--border)); }
.st-totals .due strong { color: var(--c-danger, #d92d20); }
.st-totals .clear strong { color: #039855; }
.st-table-wrap { overflow: auto; flex: 1; border: 1px solid var(--border); border-radius: 12px; }
.st-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.st-table th { position: sticky; top: 0; background: var(--surface-2, #f2f4f7); text-align: right; padding: 8px 10px; font-weight: 700; }
.st-table td { padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: top; }
.st-table td.mono { white-space: nowrap; font-variant-numeric: tabular-nums; }
.st-kind { display: inline-block; font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 6px; background: var(--surface-2, #f2f4f7); color: var(--text-2); margin-inline-end: 4px; }
.st-kind.payment { background: #ecfdf3; color: #027a48; }
.st-kind.expense { background: #eef4ff; color: #3538cd; }
.st-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
@media (max-width: 760px) {
  .ms-cards { grid-template-columns: 1fr; }
  .ms-row { grid-template-columns: 1fr; }
  .ms-debtor { grid-template-columns: 1fr auto; }
  .ms-debtor-acts { grid-column: 1 / -1; }
  .st-totals { grid-template-columns: 1fr 1fr; }
  .st-totals div:last-child { grid-column: 1 / -1; }
}

.st-trust { border: 1px dashed var(--border); border-radius: 12px; padding: 10px 12px; margin-top: 10px; display: grid; gap: 6px; }
.st-trust-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.ms-adv { display: grid; gap: 4px; }
.ms-adv-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.ms-adv-acts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ms-adv-acts .input { width: auto; padding: 6px 10px; }
.ms-branches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ms-branch { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2, var(--bg)); font-size: 13px; }
.ms-branch .icon-btn { width: 24px; height: 24px; font-size: 12px; padding: 0; }
.exp-pending { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: color-mix(in srgb, var(--warn, #d97706) 15%, transparent); color: var(--warn, #b45309); }
.exp-rejected { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: color-mix(in srgb, var(--danger, #dc2626) 12%, transparent); color: var(--danger, #b91c1c); }
.exp-branch { display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px; background: var(--surface-2, var(--bg)); border: 1px solid var(--border); color: var(--muted, inherit); }

/* ===== الأجندة: المكتبة بتحسب الأماكن من الشمال لليمين =====
   لو اتجاه الحاوية rtl عمود الساعات بيتنقل فوق يوم الجمعة.
   فالهيكل يفضل ltr، والكلام جوّه بس هو اللي rtl */
.calendar-host .toastui-calendar-layout,
.calendar-host .toastui-calendar-week,
.calendar-host .toastui-calendar-day,
.calendar-host .toastui-calendar-month,
.calendar-host .toastui-calendar-month-weekday,
.calendar-host .toastui-calendar-weekday,
.calendar-host .toastui-calendar-daygrid,
.calendar-host .toastui-calendar-timegrid,
.calendar-host .toastui-calendar-panel,
.calendar-host .toastui-calendar-grid-cell,
.calendar-host .toastui-calendar-daynames,
.calendar-host .toastui-calendar-day-names { direction: ltr !important; }
.calendar-host .toastui-calendar-weekday-event,
.calendar-host .toastui-calendar-time-event,
.calendar-host .toastui-calendar-weekday-event-title,
.calendar-host .toastui-calendar-event-title,
.calendar-host .toastui-calendar-day-name-item,
.calendar-host .toastui-calendar-timegrid-time,
.calendar-host .toastui-calendar-panel-title,
.calendar-host .toastui-calendar-weekday-exceed-in-week,
.calendar-host .toastui-calendar-weekday-exceed-in-month { direction: rtl; }
/* "+N" يبقى زرار واضح لوحده مش فوق كلام موعد */
.calendar-host .toastui-calendar-weekday-exceed-in-week {
  background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 999px;
  padding: 0 8px; font-weight: 700; font-size: 11px; line-height: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.12); z-index: 2;
}

/* رأس أيام الأسبوع: الرقم فوق واسم اليوم تحته في نص العمود — من غير ما الأسامي تدخل في بعض */
.calendar-host .toastui-calendar-day-name-item {
  text-align: center !important; padding: 0 2px !important; overflow: hidden; display: flex; align-items: center; justify-content: center;
}
.calendar-host .toastui-calendar-day-names { overflow: hidden !important; }
.calendar-host .toastui-calendar-template-weekDayName { line-height: normal !important; height: 100%; display: flex; align-items: center; justify-content: center; }
.calendar-host .toastui-calendar-day-name-item > span { height: 100%; display: flex; align-items: center; justify-content: center; line-height: normal; }
.ag-wdn { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1; gap: 1px; padding: 2px 7px; border-radius: 9px; }
.ag-wdn b { font-size: 14px; font-weight: 800; color: var(--text); }
.ag-wdn small { font-size: 10.5px; font-weight: 600; color: var(--text-soft); white-space: nowrap; }
.ag-wdn.today { background: var(--primary, #0B1222); }
.ag-wdn.today b, .ag-wdn.today small { color: #fff; }
.ag-wdn-short { display: none; }
@media (max-width: 900px) {
  .ag-wdn-long { display: none; }
  .ag-wdn-short { display: inline; }
  .ag-wdn b { font-size: 14px; }
}
@media (max-width: 480px) {
  .ag-wdn { padding: 2px 1px; }
  .ag-wdn b { font-size: 13px; }
  .ag-wdn small { font-size: 10px; }
}

/* ===== السوبر أدمن: متابعة الفترة التجريبية ===== */
.fu-chips, .fu-ph { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.fu-chip { border: 1px solid var(--border); background: var(--surface, #fff); color: var(--text); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; font-family: inherit; }
.fu-chip b { margin-inline-start: 4px; }
.fu-chip.active { background: var(--primary, #0B1222); color: #fff; border-color: transparent; }
.fu-ph .fu-chip { font-size: 12px; padding: 3px 10px; }
.fu-seg { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface-2, #f2f4f7); white-space: nowrap; }
.fu-not_started { background: #FEE4E2; color: #B42318; }
.fu-stalled { background: #FEF0C7; color: #B54708; }
.fu-active { background: #D1FADF; color: #027A48; }
.fu-ending { background: #E0EAFF; color: #3538CD; }
.fu-expired { background: #F2F4F7; color: #475467; }
.fu-note { background: var(--surface-2, #f9fafb); border-radius: 8px; padding: 4px 8px; }
.fu-segs { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 10px; font-size: 13px; }
.fu-segs label { display: inline-flex; align-items: center; gap: 4px; }
.fu-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fu-preview { white-space: pre-wrap; background: #E7FFDB; color: #111B21; border-radius: 10px 10px 2px 10px; padding: 10px 12px; font-size: 13.5px; line-height: 1.6; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.fu-tpl { margin-bottom: 10px; }
@media (max-width: 700px) { .fu-edit { grid-template-columns: 1fr; } }

/* ===== خطوات البداية (الرئيسية) ===== */
.onb-card { border: 1px solid var(--gold-100, #F3E4A8) !important; background: linear-gradient(180deg, var(--gold-50, #FFFBEB), var(--surface, #fff)) !important; }
.onb-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.onb-bar { height: 6px; border-radius: 999px; background: var(--border, #EAECF0); margin: 12px 0; overflow: hidden; }
.onb-bar span { display: block; height: 100%; border-radius: inherit; background: var(--gold, #D4AF37); transition: width .4s; }
.onb-steps { display: grid; gap: 8px; }
.onb-step { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface, #fff); border: 1px solid var(--border); }
.onb-step.next { border-color: var(--gold, #D4AF37); box-shadow: 0 0 0 3px rgba(212,175,55,.15); }
.onb-step.done { opacity: .65; }
.onb-step.done strong { text-decoration: line-through; }
.onb-check { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 13px; background: var(--surface-2, #F2F4F7); color: var(--text-soft); }
.onb-step.done .onb-check { background: var(--success, #12B76A); color: #fff; }
.onb-step.next .onb-check { background: var(--gold, #D4AF37); color: #0B1222; }
.onb-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.onb-text span { font-size: 12.5px; color: var(--text-soft); }
@media (min-width: 900px) { .onb-steps { grid-template-columns: 1fr 1fr; } }
/* الزرار اللي الكارت بيشاور عليه (زي "إرسال دعوة") */
.onb-pulse { position: relative; animation: onbPulse 1.2s ease-in-out 5; box-shadow: 0 0 0 0 rgba(212,175,55,.7); border-radius: 10px; }
@keyframes onbPulse { 0% { box-shadow: 0 0 0 0 rgba(212,175,55,.7); } 70% { box-shadow: 0 0 0 12px rgba(212,175,55,0); } 100% { box-shadow: 0 0 0 0 rgba(212,175,55,0); } }
@media (prefers-reduced-motion: reduce) { .onb-pulse { animation: none; outline: 3px solid var(--gold, #D4AF37); } }

/* ===== التاريخ الهجري (المكاتب السعودية) ===== */
.ag-hijri { font-size: 12px; font-weight: 600; color: var(--text-soft); margin-inline-start: 6px; }
.calendar-host .ag-mcell { display: inline-flex; align-items: center; gap: 6px; direction: ltr; }
/* خانة رقم اليوم في المكتبة عرضها ثابت — لما فيها الهجري كمان لازم تكبر عشان متطلعش على اليوم اللي جنبها */
.calendar-host .toastui-calendar-grid-cell-date:has(.ag-mcell) { width: auto !important; min-width: 0 !important; direction: ltr !important; display: inline-block; }
.calendar-host .ag-hday { direction: rtl; unicode-bidi: isolate; font-size: 10.5px; line-height: 1.5; color: #027A48; background: #ECFDF3; border-radius: 6px; padding: 0 5px; font-weight: 700; }
.calendar-host .ag-hday.first { color: #fff; background: #12B76A; }
.ag-wdn-h { font-size: 10.5px; font-weight: 700; color: #027A48; background: #ECFDF3; border-radius: 6px; padding: 0 4px; margin-inline-start: 4px; vertical-align: middle; }
.ag-wdn.today .ag-wdn-h { background: rgba(255,255,255,.2); color: #fff; }

/* ===== اختيار دولة المكتب (التسجيل والإعدادات) ===== */
.country-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.date-mode-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.date-mode-pick .country-opt { font-size: 14px; padding: 10px 6px; }
@media (max-width: 480px) { .date-mode-pick { grid-template-columns: 1fr; } }
/* التاريخ الهجري المقابل تحت خانات إدخال التاريخ */
.hijri-hint { display: block; font-size: 12px; font-weight: 600; color: #027A48; margin-top: 4px; }
.country-opt { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; border: 1.5px solid var(--border); border-radius: 12px; background: var(--surface, #fff); color: var(--text); font: inherit; font-weight: 700; font-size: 15px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.country-opt .cf { font-size: 20px; line-height: 1; }
/* ويندوز مبيرسمش أعلام الدول (بيكتب EG / SA) — نخفيها هناك */
html.no-flags .country-opt .cf { display: none; }
.country-opt:hover { border-color: var(--gold, #D4AF37); }
.country-opt.active { border-color: var(--gold, #D4AF37); box-shadow: 0 0 0 3px rgba(212,175,55,.18); background: var(--gold-50, #FFFBEB); }

/* شارة دولة المكتب في السوبر أدمن */
.sa-country { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; vertical-align: middle; margin-inline-start: 6px; }
.sa-country-SA { background: #ECFDF3; color: #027A48; }
.sa-country-EG { background: var(--surface-2, #F2F4F7); color: var(--text-soft); }

/* ===== السوبر أدمن: التابات ===== */
.sa-tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin: 6px 0 16px; padding: 4px; background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 14px; position: sticky; top: 0; z-index: 5; }
.sa-tabs::-webkit-scrollbar { display: none; }
.sa-tab { flex: 1 0 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: transparent; color: var(--text-soft); font: inherit; font-size: 14px; font-weight: 600; padding: 10px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.sa-tab:hover { background: var(--surface-2, #F2F4F7); color: var(--text); }
.sa-tab.active { background: var(--primary, #0B1222); color: #fff; }
.sa-tab-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--danger, #D92D20); color: #fff; font-size: 11.5px; font-weight: 800; display: inline-grid; place-items: center; }
.sa-tab.active .sa-tab-badge { background: var(--gold, #D4AF37); color: #0B1222; }
.sa-pane { margin-bottom: 20px; }

/* ===== السوبر أدمن: مصادر التسجيل ===== */
.src-table td, .src-table th { white-space: nowrap; }
.src-table td:first-child { white-space: normal; min-width: 140px; }
.src-table tfoot td { font-weight: 800; border-top: 2px solid var(--border); }
.src-bar { display: inline-block; width: 70px; height: 6px; border-radius: 999px; background: var(--border, #EAECF0); margin-inline-end: 8px; vertical-align: middle; overflow: hidden; }
.src-bar span { display: block; height: 100%; background: var(--gold, #D4AF37); border-radius: inherit; }
.src-help { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.src-help summary { cursor: pointer; font-weight: 700; }
.src-code { direction: ltr; text-align: left; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--surface-2, #F2F4F7); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; word-break: break-all; }

/* ============================================================
   نتايج التحليل الذكي (عقد / قضية / مستند / حكم / مقارنة)
   الكلاسات دي كانت مستخدمة من غير تنسيق — النتيجة كانت بتطلع نص مرصوص
   ============================================================ */
.analysis-header { display: flex; gap: 12px; align-items: center; padding: 14px 16px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-xs); }
.analysis-icon { font-size: 26px; width: 48px; height: 48px; display: grid; place-items: center; flex: 0 0 auto;
  border-radius: var(--r-md); background: var(--primary-light, #FBF3D5); }
.analysis-title { font-weight: 700; font-size: 15px; line-height: 1.6; color: var(--text); }
.analysis-type { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.ai-result-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  margin-bottom: 12px; overflow: hidden; box-shadow: var(--sh-xs); }
.ai-result-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-weight: 700; font-size: 14px;
  border-bottom: 1px solid var(--border); background: var(--bg); }
.ai-result-body { padding: 12px 14px; line-height: 1.9; font-size: 13.5px; color: var(--text); }
.ai-result-list { margin: 0; padding-inline-start: 20px; }
.ai-result-list li { margin: 4px 0; }
.ai-result-success .ai-result-header { background: var(--c-success-bg); color: var(--c-success); border-color: var(--c-success-bd); }
.ai-result-danger .ai-result-header { background: var(--c-danger-bg); color: var(--c-danger); border-color: var(--c-danger-bd); }
.ai-result-info .ai-result-header { background: var(--c-info-bg); color: var(--c-info); border-color: var(--c-info-bd); }
.defense-item, .term-item, .risk-item { padding: 10px 0; border-bottom: 1px dashed var(--border); }
.defense-item:last-child, .term-item:last-child, .risk-item:last-child { border-bottom: 0; }
.defense-type { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: var(--r-full);
  background: var(--c-info-bg); color: var(--c-info); margin-bottom: 4px; }
.defense-basis { font-size: 12.5px; color: var(--text-3); margin-top: 4px; }
.risk-header { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.risk-severity { font-size: 12px; white-space: nowrap; }
.risk-explanation { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.risk-high { border-inline-start: 3px solid var(--c-danger); padding-inline-start: 10px; }
.risk-medium { border-inline-start: 3px solid var(--c-warning); padding-inline-start: 10px; }
.risk-low { border-inline-start: 3px solid var(--c-success); padding-inline-start: 10px; }
.term-clause { font-weight: 600; }
.term-issue { color: var(--c-danger); font-size: 13px; margin-top: 4px; }
.term-suggestion { color: var(--c-success); font-size: 13px; margin-top: 4px; }
.success-probability { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px;
  border-radius: var(--r-lg); margin-bottom: 12px; font-weight: 700; border: 1px solid var(--border); }
.success-high { background: var(--c-success-bg); color: var(--c-success); border-color: var(--c-success-bd); }
.success-medium { background: var(--c-warning-bg); color: var(--c-warning); border-color: var(--c-warning-bd); }
.success-low { background: var(--c-danger-bg); color: var(--c-danger); border-color: var(--c-danger-bd); }

/* بوابات حكومية رسمية (تاب المساعد) — كانت بتطلع نص مرصوص من غير تنسيق */
.gov-links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 10px; }
.gov-link { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--r-md); background: var(--surface); color: var(--text); text-decoration: none;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease); }
.gov-link:hover { border-color: var(--gold-400, #D4AF37); box-shadow: var(--sh-sm); }
.gov-link-icon { font-size: 22px; width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto;
  border-radius: var(--r-sm); background: var(--bg); }
.gov-link-body { flex: 1; min-width: 0; }
.gov-link-name { font-weight: 700; font-size: 13.5px; }
.gov-link-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; line-height: 1.5; }
.gov-link-arrow { color: var(--text-3); font-size: 14px; }
