/* ====================================================
   MASAR CORE — نظام التصميم الرسمي
   هوية: أخضر مسار الخبرة + ذهبي + كريمي
   ==================================================== */

:root {
  /* Brand Identity */
  --green-950: #0B2516;
  --green-900: #133A22;
  --green-800: #1F4D2E;      /* Primary brand */
  --green-700: #2A6A40;
  --green-600: #387C50;
  --green-500: #4A9266;

  --gold: #D4A017;
  --gold-l: #E5B743;
  --gold-d: #B0840A;
  --gold-soft: rgba(212, 160, 23, 0.12);

  --cream: #F5F2EA;
  --cream-d: #EBE5D3;
  --cream-deep: #D4CCB3;

  --ink-50: #FAFAF8;
  --ink-100: #F0EFEB;
  --ink-200: #DCD9D2;
  --ink-300: #A8A49B;
  --ink-400: #6B6760;
  --ink-500: #4A463F;
  --ink-700: #2B2823;
  --ink-900: #1A1A1A;

  /* Functional */
  --success: #16A34A;
  --success-soft: rgba(22, 163, 74, 0.1);
  --warning: #EAB308;
  --warning-soft: rgba(234, 179, 8, 0.1);
  --danger: #DC2626;
  --danger-soft: rgba(220, 38, 38, 0.1);
  --info: #0EA5E9;
  --info-soft: rgba(14, 165, 233, 0.1);
  --purple: #8B5CF6;
  --purple-soft: rgba(139, 92, 246, 0.1);

  /* Light theme (default) */
  --bg: #F5F2EA;
  --bg-2: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #FAF8F2;
  --surface-hover: #F0EDE4;
  --border: rgba(31, 77, 46, 0.1);
  --border-strong: rgba(31, 77, 46, 0.2);
  --text: #1A1A1A;
  --text-2: #4A463F;
  --text-3: #6B6760;
  --text-muted: #A8A49B;

  /* Typography */
  --font: 'Tajawal', 'Cairo', system-ui, sans-serif;
  --font-serif: 'Amiri', 'Times New Roman', serif;

  /* Sizing */
  --radius: 14px;
  --radius-lg: 20px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 3px rgba(31, 77, 46, 0.06), 0 1px 2px rgba(31, 77, 46, 0.04);
  --shadow-2: 0 8px 24px rgba(31, 77, 46, 0.08), 0 2px 4px rgba(31, 77, 46, 0.04);
  --shadow-3: 0 20px 60px rgba(31, 77, 46, 0.15);
  --shadow-gold: 0 8px 24px rgba(212, 160, 23, 0.3);

  /* Layout */
  --topbar-h: 68px;
  --sidebar-w: 290px;
  --bottom-nav-h: 70px;
}

/* Dark theme */
body.theme-dark {
  --bg: #0A1611;
  --bg-2: #0F2118;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.09);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #F5F2EA;
  --text-2: #C5C2BA;
  --text-3: #9A968E;
  --text-muted: #6B6760;
}

/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  background-image:
    radial-gradient(1200px 600px at 100% -10%, rgba(31, 77, 46, 0.04), transparent 60%),
    radial-gradient(1000px 500px at -10% 100%, rgba(212, 160, 23, 0.04), transparent 60%);
  background-attachment: fixed;
}
body.theme-dark {
  background-image:
    radial-gradient(1200px 600px at 100% -10%, rgba(42, 106, 64, 0.12), transparent 60%),
    radial-gradient(1000px 500px at -10% 100%, rgba(212, 160, 23, 0.06), transparent 60%);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; color: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }
img, svg { max-width: 100%; display: block; }

/* ============ SPLASH ============ */
.splash {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, var(--cream), var(--bg-2), var(--cream-d));
  display: grid; place-content: center; justify-items: center;
  z-index: 9999;
  animation: splash-out 0.5s ease 1.6s forwards;
  gap: 18px;
}
.splash-logo { animation: pulse-soft 2s ease-in-out infinite; }
.splash-text {
  font-size: 38px; font-weight: 800;
  color: var(--green-800);
  letter-spacing: -0.5px;
}
.splash-sub {
  color: var(--gold-d);
  font-size: 14px;
  font-weight: 600;
}
.splash-tag {
  margin-top: 8px;
  padding: 6px 14px;
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 999px;
  color: var(--green-800);
  font-size: 12px;
  font-weight: 700;
}
@keyframes pulse-soft { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes splash-out { to { opacity: 0; visibility: hidden; transform: scale(1.04); } }

/* ============ TOPBAR ============ */
.topbar {
  position: fixed; top: 0; right: 0; left: 0;
  height: var(--topbar-h);
  z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
body.theme-dark .topbar {
  background: rgba(10, 22, 17, 0.85);
}

.menu-btn { display: none; }

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px;
  border-radius: var(--radius);
}
.brand-logo {
  width: 48px; height: 48px;
  background: var(--cream);
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(31, 77, 46, 0.1);
  overflow: hidden;
  padding: 4px;
  transition: 0.2s;
}
.brand-logo:hover {
  box-shadow: 0 4px 14px rgba(212, 160, 23, 0.25);
  transform: translateY(-1px);
}
.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
body.theme-dark .brand-logo {
  background: var(--cream);
  border-color: var(--gold);
}
.sidebar-firm img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  flex-shrink: 0;
}
.splash-logo {
  width: 140px !important;
  height: 140px !important;
  object-fit: contain !important;
  filter: drop-shadow(0 8px 24px rgba(31, 77, 46, 0.3));
}
.brand-logo-large img {
  width: 90px !important;
  height: 90px !important;
  object-fit: contain;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-weight: 800; font-size: 18px;
  color: var(--green-800);
  letter-spacing: -0.3px;
}
body.theme-dark .brand-name { color: var(--cream); }
.brand-sub {
  font-size: 10.5px;
  color: var(--gold-d);
  font-weight: 600;
}

.topbar-search {
  flex: 1; max-width: 580px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0 14px;
  height: 42px;
  transition: 0.2s;
}
.topbar-search:focus-within {
  border-color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(42, 106, 64, 0.12);
}
.topbar-search i { color: var(--text-3); font-size: 18px; }
.topbar-search input {
  flex: 1; border: 0; background: transparent;
  font-size: 14px; outline: none;
  color: var(--text);
}
.topbar-search kbd {
  font-size: 11px; padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-3);
  font-family: inherit;
}

.topbar-actions { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  color: var(--text-2);
  font-size: 19px;
  transition: 0.18s;
  position: relative;
}
.icon-btn:hover {
  background: var(--surface-2);
  color: var(--green-800);
}
body.theme-dark .icon-btn:hover { color: var(--gold-l); }
.icon-btn .ai-icon {
  background: linear-gradient(120deg, var(--gold-l), var(--gold-d));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.icon-btn .badge {
  position: absolute; top: 4px; left: 4px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 5px; border-radius: 999px;
  min-width: 16px; height: 16px;
  display: grid; place-items: center;
}

.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 14px 4px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: 0.18s;
}
.user-chip:hover { background: var(--surface-hover); border-color: var(--green-700); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green-700), var(--green-800));
  color: var(--cream);
  display: grid; place-items: center;
  font-weight: 800; font-size: 14px;
  flex: 0 0 36px;
}
.avatar.gold {
  background: linear-gradient(135deg, var(--gold-l), var(--gold-d));
  color: var(--green-950);
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; flex: 0 0 28px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; flex: 0 0 56px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-name { font-weight: 700; font-size: 13px; color: var(--text); }
.user-role { font-size: 11px; color: var(--gold-d); font-weight: 600; }

/* ============ SIDEBAR ============ */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
  z-index: 40;
  transition: transform 0.3s ease;
}
body.theme-dark .sidebar { background: rgba(15, 33, 24, 0.7); backdrop-filter: blur(20px); }

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }

.sidebar-firm {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  margin: 14px 12px 6px;
  background: linear-gradient(135deg, rgba(212, 160, 23, 0.08), rgba(31, 77, 46, 0.08));
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.firm-name { font-weight: 700; font-size: 13.5px; color: var(--green-800); }
body.theme-dark .firm-name { color: var(--gold-l); }
.firm-sub { font-size: 10.5px; color: var(--gold-d); font-weight: 500; }

.firm-tagline {
  margin: 8px 12px 14px;
  padding: 10px 14px;
  text-align: center;
  background: var(--green-800);
  color: var(--cream);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  background-image: linear-gradient(135deg, var(--green-700), var(--green-800), var(--green-900));
}
.firm-tagline em { color: var(--gold-l); font-style: normal; font-weight: 800; }

.sidenav { padding: 4px 8px; flex: 1; }
.sidenav-group { margin-bottom: 14px; }
.group-title {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 800;
  padding: 10px 14px 6px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 500; font-size: 13px;
  margin-bottom: 1px;
  cursor: pointer;
  transition: 0.15s;
  position: relative;
}
.nav-item i { font-size: 18px; color: var(--text-3); }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover i { color: var(--green-700); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(212, 160, 23, 0.1), transparent);
  color: var(--green-800);
  font-weight: 700;
}
body.theme-dark .nav-item.active { color: var(--gold-l); }
.nav-item.active i { color: var(--gold); }
.nav-item.active::before {
  content: '';
  position: absolute; right: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: linear-gradient(180deg, var(--gold-l), var(--gold-d));
  border-radius: 0 4px 4px 0;
}
.nav-item span { flex: 1; }
.nav-item .count {
  font-size: 11px; font-weight: 700;
  padding: 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-3);
  font-style: normal;
}
.nav-item.active .count {
  background: var(--gold-soft);
  color: var(--gold-d);
  border-color: var(--gold);
}
.nav-item .badge-new {
  font-size: 10px; font-weight: 800;
  padding: 2px 7px;
  background: linear-gradient(120deg, var(--gold-l), var(--gold-d));
  color: var(--green-950);
  border-radius: 999px;
  font-style: normal;
}
.nav-subgroup {
  margin-right: 14px;
  padding-right: 8px;
  border-right: 2px dashed var(--border);
}
.nav-subgroup .nav-item {
  font-size: 12.5px;
  padding: 7px 12px;
}

.sidebar-foot { padding: 12px; }
.ai-credit {
  display: flex; gap: 10px; align-items: center;
  padding: 12px;
  background: linear-gradient(135deg, var(--green-800), var(--green-900));
  color: var(--cream);
  border-radius: var(--radius);
}
.ai-credit > i {
  font-size: 22px;
  color: var(--gold-l);
  background: rgba(212, 160, 23, 0.2);
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
}
.ac-title { font-size: 12px; font-weight: 700; }
.ac-bar {
  height: 5px; background: rgba(255,255,255,0.15); border-radius: 999px;
  margin: 6px 0; overflow: hidden;
}
.ac-bar span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--gold-l), var(--gold));
  border-radius: 999px;
}
.ac-sub { font-size: 11px; opacity: 0.8; }

.firm-credits {
  margin-top: 14px;
  padding: 12px 8px 4px;
  text-align: center;
  border-top: 1px dashed var(--border);
}
.fc-tagline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--gold-d);
  margin-bottom: 6px;
}
body.theme-dark .fc-tagline { color: var(--gold-l); }
.fc-tagline i { font-size: 14px; }
.fc-text {
  font-size: 10px;
  color: var(--text-3);
  line-height: 1.6;
  opacity: 0.85;
}

/* ============ CONTENT ============ */
.content {
  margin-right: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 24px) 28px 100px;
  min-height: 100vh;
}
.view { display: none; animation: fade-in 0.3s ease; }
.view.active { display: block; }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============ PAGE HEAD ============ */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 16px; margin-bottom: 22px;
  flex-wrap: wrap;
}
.crumbs { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.crumbs i { font-size: 12px; margin: 0 4px; }
.page-head h1 {
  margin: 0;
  font-size: 28px; font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text);
}
.page-head h1 .muted { color: var(--text-3); font-weight: 500; }
.page-sub { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700; font-size: 13px;
  transition: 0.18s; cursor: pointer;
  border: 1px solid transparent;
}
.btn i { font-size: 16px; }
.btn-primary {
  background: linear-gradient(135deg, var(--green-700), var(--green-800));
  color: var(--cream);
  box-shadow: 0 4px 14px rgba(31, 77, 46, 0.25);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(31, 77, 46, 0.35);
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold-l), var(--gold-d));
  color: var(--green-950);
  box-shadow: 0 4px 14px rgba(212, 160, 23, 0.3);
}
.btn-gold:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(212, 160, 23, 0.4);
}
.btn-ghost {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 11.5px; }
.btn-ai {
  background: linear-gradient(135deg, var(--gold-l), var(--gold), var(--green-700));
  background-size: 200% 200%;
  animation: gradient-shift 4s ease infinite;
  color: white;
  box-shadow: 0 8px 24px rgba(212, 160, 23, 0.4);
}
@keyframes gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.chip-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px; font-weight: 600;
  transition: 0.18s;
}
.chip-btn:hover { background: var(--surface-hover); color: var(--green-800); }
.chip-btn.active {
  background: linear-gradient(135deg, var(--gold-l), var(--gold-d));
  color: var(--green-950);
  border-color: var(--gold);
}

/* ============ KPI ============ */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  margin-bottom: 22px;
}
.kpi-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  overflow: hidden;
  transition: 0.25s;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  box-shadow: var(--shadow-1);
}
.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
  border-color: var(--green-700);
}
.kpi-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 24px;
}
.kpi-card.grad-green .kpi-icon { background: linear-gradient(135deg, var(--green-700), var(--green-800)); color: var(--cream); }
.kpi-card.grad-gold .kpi-icon { background: linear-gradient(135deg, var(--gold-l), var(--gold-d)); color: var(--green-950); }
.kpi-card.grad-red .kpi-icon { background: linear-gradient(135deg, #F87171, var(--danger)); color: white; }
.kpi-card.grad-blue .kpi-icon { background: linear-gradient(135deg, #38BDF8, #0284C7); color: white; }
.kpi-val { font-size: 30px; font-weight: 800; line-height: 1; letter-spacing: -0.5px; color: var(--text); }
.kpi-label { font-size: 12.5px; color: var(--text-3); margin-top: 6px; font-weight: 500; }
.kpi-trend {
  font-size: 11.5px; font-weight: 700;
  padding: 4px 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
}
.kpi-trend.up { background: var(--success-soft); color: var(--success); }
.kpi-trend.down { background: var(--danger-soft); color: var(--danger); }
.spark {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 38px; width: 100%; opacity: 0.4;
}
.kpi-card.grad-green .spark { color: var(--green-700); }
.kpi-card.grad-gold .spark { color: var(--gold); }
.kpi-card.grad-red .spark { color: var(--danger); }
.kpi-card.grad-blue .spark { color: #38BDF8; }

/* ============ HERO BANNER ============ */
.hero-banner {
  position: relative;
  margin-bottom: 22px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--green-800), var(--green-900));
  color: var(--cream);
  overflow: hidden;
}
.hero-banner-glow {
  position: absolute; top: -50%; right: -10%;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(212, 160, 23, 0.25), transparent 60%);
  filter: blur(40px);
  pointer-events: none;
}
.hero-banner-content {
  position: relative; display: flex; align-items: center; gap: 22px;
  flex-wrap: wrap;
}
.hero-banner-icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--gold-l), var(--gold-d));
  border-radius: 18px;
  display: grid; place-items: center;
  font-size: 30px; color: var(--green-950);
  flex-shrink: 0;
}
.hero-banner-title { font-size: 20px; font-weight: 800; color: var(--gold-l); }
.hero-banner-sub { font-size: 13.5px; opacity: 0.9; margin-top: 4px; }
.hero-banner-text { flex: 1; min-width: 220px; }
.hero-banner-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-banner .chip-btn {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.2);
  color: var(--cream);
}
.hero-banner .chip-btn:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-l);
}

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-1);
}
.card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px; gap: 12px;
}
.card-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 15px;
  color: var(--text);
}
.card-title i { color: var(--gold-d); font-size: 18px; }
.card-sub { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.link-more {
  display: inline-flex; align-items: center; gap: 2px;
  color: var(--green-700); font-size: 12.5px; font-weight: 700;
  cursor: pointer;
}
.link-more:hover { color: var(--gold-d); }

.grid-3-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
.grid-2-3 {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 18px;
  margin-bottom: 22px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

/* ============ TIMELINE ============ */
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px; padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: 0.18s;
  align-items: center;
}
.tl-item:hover { background: var(--surface-hover); border-color: var(--green-700); transform: translateX(-3px); }
.tl-item.tl-urgent {
  border-color: rgba(220, 38, 38, 0.3);
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.04), var(--surface-2));
}
.tl-date {
  background: linear-gradient(135deg, var(--gold-soft), transparent);
  border: 1px solid var(--gold-soft);
  border-radius: 12px;
  padding: 8px 12px;
  text-align: center;
  min-width: 60px;
}
.tl-date strong { display: block; font-size: 20px; color: var(--gold-d); font-weight: 800; }
.tl-date span { font-size: 10px; color: var(--text-3); }
.tl-title { font-weight: 700; font-size: 14px; color: var(--text); }
.tl-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.tl-meta i { vertical-align: middle; margin-left: 2px; color: var(--green-700); }
.tl-meta .dot { margin: 0 6px; color: var(--text-muted); }
.tl-tags { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.tl-actions { display: flex; gap: 4px; }

.tag {
  font-size: 11px; padding: 3px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 600;
  color: var(--text-2);
}
.tag-red { background: var(--danger-soft); color: var(--danger); border-color: rgba(220, 38, 38, 0.2); }
.tag-amber { background: var(--warning-soft); color: var(--gold-d); border-color: rgba(234, 179, 8, 0.2); }
.tag-green { background: var(--success-soft); color: var(--success); border-color: rgba(22, 163, 74, 0.2); }
.tag-blue { background: var(--info-soft); color: var(--info); border-color: rgba(14, 165, 233, 0.2); }
.tag-gold { background: var(--gold-soft); color: var(--gold-d); border-color: rgba(212, 160, 23, 0.3); }

/* ============ TASKS ============ */
.tasks { display: flex; flex-direction: column; gap: 8px; }
.task {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px; padding: 11px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: 0.18s;
  align-items: center;
}
.task input { display: none; }
.task .check {
  width: 18px; height: 18px;
  border-radius: 6px;
  border: 2px solid var(--border-strong);
  display: grid; place-items: center;
  transition: 0.15s;
}
.task input:checked + .check {
  background: var(--green-700); border-color: var(--green-700);
}
.task input:checked + .check::after {
  content: '✓'; color: var(--cream); font-weight: 800; font-size: 12px;
}
.t-title { font-size: 13.5px; font-weight: 600; color: var(--text); }
.t-title.done { text-decoration: line-through; color: var(--text-3); }
.t-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.t-prio {
  font-size: 11px; padding: 3px 9px; border-radius: 999px; font-weight: 700;
}
.prio-high { background: var(--danger-soft); color: var(--danger); }
.prio-med { background: var(--warning-soft); color: var(--gold-d); }
.prio-low { background: var(--info-soft); color: var(--info); }
.task.overdue { border-color: rgba(220, 38, 38, 0.25); }

/* ============ ACTIVITY ============ */
.activity { display: flex; flex-direction: column; gap: 14px; }
.act {
  display: grid; grid-template-columns: auto 1fr; gap: 12px;
  align-items: flex-start;
}
.act-dot {
  width: 10px; height: 10px; border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
  position: relative;
}
.act-dot::after {
  content: '';
  position: absolute; top: 14px; right: 4px;
  width: 2px; height: 18px;
  background: var(--border);
}
.act:last-child .act-dot::after { display: none; }
.act-dot.green { background: var(--green-700); box-shadow: 0 0 0 4px rgba(31, 77, 46, 0.1); }
.act-dot.gold { background: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.act-dot.blue { background: var(--info); box-shadow: 0 0 0 4px var(--info-soft); }
.act-dot.purple { background: var(--purple); box-shadow: 0 0 0 4px var(--purple-soft); }
.act-body div { font-size: 13px; color: var(--text); }
.act-time { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ============ CHARTS ============ */
.chart-wrap { padding: 8px 0; }
.bars {
  display: grid; grid-auto-flow: column;
  grid-auto-columns: 1fr; gap: 16px;
  align-items: flex-end;
  height: 220px;
  padding: 0 4px;
}
.bar {
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end;
  height: 100%;
  position: relative;
}
.bar span {
  display: block; width: 70%; max-width: 36px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--green-700), var(--green-800));
  transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.bar.gold span {
  background: linear-gradient(180deg, var(--gold-l), var(--gold-d));
}
.bar b {
  font-size: 11px; font-weight: 700;
  color: var(--text-2);
  position: absolute; top: 0; transform: translateY(-18px);
}
.bar label {
  font-size: 11px; color: var(--text-3);
  margin-top: 6px;
}

/* ============ FILTERS BAR ============ */
.filters-bar {
  display: flex; gap: 10px; flex-wrap: wrap;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
  align-items: center;
  box-shadow: var(--shadow-1);
}
.search-mini {
  flex: 1; min-width: 240px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 40px;
}
.search-mini i { color: var(--text-3); }
.search-mini input {
  flex: 1; border: 0; background: transparent;
  outline: none; font-size: 13px;
}

.seg {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}
.seg button {
  padding: 7px 14px;
  font-size: 12.5px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 600;
  transition: 0.18s;
}
.seg button em {
  font-style: normal; font-size: 10px;
  margin-right: 4px;
  padding: 1px 6px;
  background: var(--surface);
  border-radius: 999px;
  color: var(--text-3);
}
.seg button.active {
  background: linear-gradient(135deg, var(--green-700), var(--green-800));
  color: var(--cream);
  box-shadow: 0 2px 6px rgba(31, 77, 46, 0.2);
}
.seg button.active em { background: rgba(255,255,255,0.2); color: white; }

.select-wrap {
  position: relative;
}
.select-wrap select {
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  padding-left: 30px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  min-width: 160px;
}
.select-wrap.small select { padding: 8px 14px; min-width: 140px; }
.select-wrap::after {
  content: '\f136';
  font-family: 'remixicon';
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-3);
}

/* ============ DATA TABLE ============ */
.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: right;
  padding: 14px 16px;
  font-weight: 800;
  color: var(--text-2);
  font-size: 11.5px;
  background: var(--surface-2);
  border-bottom: 2px solid var(--green-700);
  letter-spacing: 0.3px;
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: var(--surface-2); }
.data-table.compact th, .data-table.compact td { padding: 10px 14px; }

.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user b { display: block; font-size: 13px; }
.cell-user span { font-size: 11px; color: var(--text-3); }

.badge-soft {
  font-size: 11px; padding: 3px 9px;
  border-radius: 999px;
  font-weight: 600;
}
.badge-soft.green { background: var(--success-soft); color: var(--success); }
.badge-soft.gold { background: var(--gold-soft); color: var(--gold-d); }
.badge-soft.blue { background: var(--info-soft); color: var(--info); }
.badge-soft.purple { background: var(--purple-soft); color: var(--purple); }
.badge-soft.red { background: var(--danger-soft); color: var(--danger); }
.badge-soft.amber { background: var(--warning-soft); color: var(--gold-d); }

.dot-status {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-left: 6px; vertical-align: middle;
}
.dot-status.green { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.dot-status.amber { background: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.dot-status.gold { background: var(--gold-l); box-shadow: 0 0 0 3px var(--gold-soft); }
.dot-status.red { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.positive { color: var(--success); font-weight: 700; }
.negative { color: var(--danger); font-weight: 700; }

/* ============ CASE CARDS ============ */
.cases-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.case-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: 0.2s;
  cursor: pointer;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-1);
}
.case-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: var(--shadow-2);
}
.case-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.case-id {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: 13px;
  color: var(--gold-d);
  background: var(--gold-soft);
  padding: 2px 8px;
  border-radius: 6px;
}
.case-title {
  font-size: 15.5px; font-weight: 700;
  margin: 4px 0 12px;
  line-height: 1.5;
  color: var(--text);
}
.case-meta {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 14px;
  color: var(--text-3); font-size: 12px;
}
.case-meta i { color: var(--green-700); margin-left: 4px; }
.case-progress {
  height: 5px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}
.case-progress span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--gold-l), var(--gold-d));
  border-radius: 999px;
  transition: 0.6s;
}
.case-progress span.green {
  background: linear-gradient(90deg, var(--green-600), var(--green-800));
}
.case-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: auto;
}
.case-tags { display: flex; gap: 4px; }
.case-team {
  display: flex;
  flex-direction: row-reverse;
}
.case-team .avatar.sm {
  margin-right: -8px;
  border: 2px solid var(--bg-2);
}

.pagination {
  display: flex; justify-content: center;
  gap: 4px;
  align-items: center;
}
.page-btn {
  min-width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12.5px; font-weight: 600;
  padding: 0 8px;
}
.page-btn.active {
  background: linear-gradient(135deg, var(--green-700), var(--green-800));
  color: var(--cream);
  border-color: var(--green-800);
}

/* ============ AI ASSISTANT ============ */
.ai-templates {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.ai-tpl {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: right;
  transition: 0.2s;
  cursor: pointer;
  box-shadow: var(--shadow-1);
}
.ai-tpl:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
  background: linear-gradient(135deg, var(--gold-soft), var(--surface));
}
.ai-tpl > i {
  font-size: 26px;
  background: var(--gold-soft);
  color: var(--gold-d);
  width: 48px; height: 48px;
  display: grid; place-items: center;
  border-radius: 12px;
  margin-bottom: 12px;
}
.ai-tpl-title { font-weight: 700; font-size: 14.5px; margin-bottom: 4px; color: var(--text); }
.ai-tpl-sub { font-size: 11.5px; color: var(--text-3); line-height: 1.5; }

.ai-workspace {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: span 2; }
.field label {
  font-size: 12px; font-weight: 700; color: var(--text-2);
}
.field label .req { color: var(--danger); }
.field input, .field textarea, .field select {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  transition: 0.15s;
  color: var(--text);
  font-family: inherit;
  resize: vertical;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(42, 106, 64, 0.1);
}

.tags-input {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  min-height: 42px;
}
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  background: var(--gold-soft);
  color: var(--gold-d);
  border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.tags-input input {
  border: 0; background: transparent;
  outline: none; font-size: 12px;
  min-width: 80px; flex: 1;
}

.ai-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.ai-output {
  background: linear-gradient(135deg, var(--cream), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
  max-height: 480px;
  overflow-y: auto;
}
body.theme-dark .ai-output { background: var(--surface-2); }
.ai-output p { margin: 0 0 12px; }
.ai-output .hl {
  background: var(--gold-soft);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--gold-d);
  font-weight: 700;
}

.ai-citations {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.cite-title { font-size: 12px; font-weight: 700; margin-bottom: 8px; color: var(--text-2); }
.cite-list { display: flex; flex-wrap: wrap; gap: 6px; }
.cite {
  padding: 5px 10px;
  background: var(--info-soft);
  color: var(--info);
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.18s;
}
.cite:hover { background: rgba(14, 165, 233, 0.2); }

/* ============ CALENDAR ============ */
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.cal-month { font-size: 20px; font-weight: 800; color: var(--green-800); }
body.theme-dark .cal-month { color: var(--gold-l); }
.cal-weeks {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px; margin-bottom: 8px;
}
.cal-weeks div {
  text-align: center; font-size: 11.5px;
  color: var(--text-3); font-weight: 800;
  padding: 8px 0;
  text-transform: uppercase;
}
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.cal-day {
  min-height: 92px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  font-size: 13px; font-weight: 600;
  position: relative;
  display: flex; flex-direction: column;
  gap: 3px;
  cursor: pointer;
  transition: 0.15s;
}
.cal-day:hover { background: var(--surface-hover); border-color: var(--green-700); }
.cal-day.off { opacity: 0.4; }
.cal-day.weekend { background: rgba(212, 160, 23, 0.03); }
.cal-day.today {
  background: linear-gradient(135deg, var(--gold-soft), transparent);
  border-color: var(--gold);
}
.cal-day.today::before {
  content: '';
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}
.ev {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.ev-red { background: var(--danger-soft); color: var(--danger); }
.ev-blue { background: var(--info-soft); color: var(--info); }
.ev-gold { background: var(--gold-soft); color: var(--gold-d); }
.ev-green { background: var(--success-soft); color: var(--success); }
.ev-purple { background: var(--purple-soft); color: var(--purple); }

/* ============ MAIL-LIKE (صادر/وارد) ============ */
.mail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 10px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  cursor: pointer;
  transition: 0.18s;
  position: relative;
}
.mail-card:hover { background: var(--surface-2); border-color: var(--green-700); transform: translateX(-3px); }
.mail-code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green-800), var(--green-900));
  color: var(--cream);
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
}
.mail-title { font-weight: 700; font-size: 14px; color: var(--text); }
.mail-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.mail-meta span { margin-left: 12px; }
.mail-meta i { font-size: 13px; margin-left: 3px; vertical-align: middle; }
.mail-channels {
  display: flex; gap: 4px;
}
.mail-channel {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 14px;
}
.mail-channel.wa { background: rgba(37, 211, 102, 0.15); color: #25D366; }
.mail-channel.em { background: var(--info-soft); color: var(--info); }
.mail-channel.sms { background: var(--purple-soft); color: var(--purple); }
.mail-channel.pt { background: var(--ink-100); color: var(--ink-700); }
body.theme-dark .mail-channel.pt { background: var(--surface-2); color: var(--text-3); }

/* ============ EMPTY STATE ============ */
.empty-state-pro {
  text-align: center;
  padding: 80px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.empty-state-pro > i {
  font-size: 56px;
  color: var(--gold-d);
  background: var(--gold-soft);
  width: 110px; height: 110px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  margin-bottom: 18px;
}
.empty-state-pro h3 { font-size: 22px; margin: 0 0 8px; color: var(--text); }
.empty-state-pro p {
  color: var(--text-3); margin: 0 auto;
  max-width: 480px; line-height: 1.7;
}
.empty-state-pro .btn { margin-top: 18px; }

/* ============ HR specific ============ */
.hr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.hr-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: 0.2s;
  text-align: center;
  box-shadow: var(--shadow-1);
}
.hr-card:hover { transform: translateY(-3px); border-color: var(--green-700); }
.hr-card .avatar.lg { margin: 0 auto 12px; }
.hr-name { font-weight: 700; font-size: 14.5px; }
.hr-role { font-size: 11.5px; color: var(--gold-d); font-weight: 600; margin-top: 2px; }
.hr-stats {
  display: flex; justify-content: space-around;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.hr-stat b { display: block; font-weight: 800; color: var(--green-800); }
.hr-stat span { font-size: 10.5px; color: var(--text-3); }

/* Biometric */
.bio-display {
  padding: 26px;
  background: linear-gradient(135deg, var(--green-800), var(--green-900));
  color: var(--cream);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; gap: 22px;
  position: relative;
  overflow: hidden;
}
.bio-display::after {
  content: ''; position: absolute; top: -50%; left: -10%;
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(212, 160, 23, 0.25), transparent 60%);
  filter: blur(40px);
}
.bio-icon {
  width: 90px; height: 90px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 44px;
  color: var(--gold-l);
  border: 3px solid var(--gold);
  position: relative;
  z-index: 1;
}
.bio-time { font-size: 36px; font-weight: 800; letter-spacing: -0.5px; color: var(--gold-l); }
.bio-status { font-size: 13px; opacity: 0.9; margin-top: 4px; }

/* Library */
.lib-hero {
  position: relative;
  padding: 36px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--green-800), var(--green-900));
  margin-bottom: 22px;
  overflow: hidden;
}
.lib-hero-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(600px 300px at 20% 0%, rgba(212, 160, 23, 0.18), transparent),
    radial-gradient(400px 200px at 80% 100%, rgba(42, 106, 64, 0.4), transparent);
  pointer-events: none;
}
.lib-search {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  padding: 6px 6px 6px 18px;
}
.lib-search > i { font-size: 22px; color: var(--gold-l); }
.lib-search input {
  flex: 1; border: 0; background: transparent;
  outline: none; font-size: 14px;
  padding: 14px 8px;
  color: white;
}
.lib-search input::placeholder { color: rgba(255,255,255,0.5); }
.lib-chips {
  position: relative; z-index: 1;
  margin-top: 14px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.lib-chips .chip {
  padding: 7px 14px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85);
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: 0.18s;
}
.lib-chips .chip:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
  color: var(--gold-l);
}

.lib-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
.lib-card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: 0.2s;
  cursor: pointer;
  box-shadow: var(--shadow-1);
}
.lib-card:hover { transform: translateY(-4px); border-color: var(--gold); }
.lib-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 24px;
  margin-bottom: 14px;
}
.lib-icon.green { background: var(--success-soft); color: var(--green-700); }
.lib-icon.gold { background: var(--gold-soft); color: var(--gold-d); }
.lib-icon.blue { background: var(--info-soft); color: var(--info); }
.lib-icon.purple { background: var(--purple-soft); color: var(--purple); }
.lib-title { font-weight: 700; font-size: 16px; color: var(--text); }
.lib-sub { font-size: 12px; color: var(--text-3); margin: 4px 0 12px; }
.lib-bar {
  height: 5px; background: var(--surface-2);
  border-radius: 999px; overflow: hidden;
}
.lib-bar span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--gold-l), var(--gold-d));
  border-radius: 999px;
}

/* ============ BOTTOM NAV ============ */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  z-index: 45;
  padding-bottom: env(safe-area-inset-bottom);
}
body.theme-dark .bottom-nav { background: rgba(10, 22, 17, 0.92); }

.bn-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 10.5px; font-weight: 600;
  padding: 8px 0;
  transition: 0.18s;
  cursor: pointer;
}
.bn-item i { font-size: 22px; }
.bn-item.active { color: var(--green-800); }
body.theme-dark .bn-item.active { color: var(--gold-l); }
.bn-item.active i {
  background: var(--gold-soft);
  padding: 5px 12px;
  border-radius: 14px;
  color: var(--gold-d);
}

.bn-fab {
  width: 58px; height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-l), var(--gold-d));
  color: var(--green-950);
  font-size: 26px;
  margin-top: -22px;
  box-shadow: 0 8px 24px rgba(212, 160, 23, 0.5);
  flex-shrink: 0;
  display: grid; place-items: center;
}

/* ============ SEND PANEL (Channel selector) ============ */
.send-panel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 16px 0;
}
.send-opt {
  padding: 14px 12px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: 0.18s;
  text-align: center;
}
.send-opt:hover { border-color: var(--green-700); }
.send-opt.selected {
  border-color: var(--green-700);
  background: linear-gradient(135deg, var(--gold-soft), var(--surface));
}
.send-opt i { font-size: 26px; margin-bottom: 6px; display: block; }
.send-opt b { display: block; font-size: 12.5px; }
.send-opt span { font-size: 10.5px; color: var(--text-3); }
.send-opt.wa i { color: #25D366; }
.send-opt.em i { color: var(--info); }
.send-opt.sms i { color: var(--purple); }
.send-opt.pt i { color: var(--text-2); }

.backdrop {
  position: fixed; inset: 0;
  background: rgba(31, 77, 46, 0.5);
  z-index: 35;
  opacity: 0; visibility: hidden;
  transition: 0.2s;
  backdrop-filter: blur(4px);
}
.backdrop.show { opacity: 1; visibility: visible; }

/* ============ ONLINE USERS (Collaboration) ============ */
.online-users {
  display: flex;
  flex-direction: row-reverse;
  margin-left: 8px;
  padding-right: 8px;
  border-right: 1px solid var(--border);
}
.online-users .avatar.sm {
  margin-right: -8px;
  border: 2px solid var(--bg-2);
  position: relative;
  cursor: pointer;
  transition: 0.2s;
}
.online-users .avatar.sm:hover { transform: translateY(-2px); z-index: 2; }
.online-users .avatar.sm::after {
  content: '';
  position: absolute; bottom: -1px; right: -1px;
  width: 9px; height: 9px;
  background: var(--success);
  border: 2px solid var(--bg-2);
  border-radius: 50%;
}

/* ============ BOE LAW CARDS (هيئة الخبراء) ============ */
.boe-law-card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: 0.2s;
  box-shadow: var(--shadow-1);
}
.boe-law-card:hover {
  transform: translateY(-3px);
  border-color: var(--green-700);
  box-shadow: var(--shadow-2);
}
.boe-law-head {
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 12px;
}
.boe-law-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--success-soft);
  color: var(--green-700);
  display: grid; place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}
.boe-law-title {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--text);
}
.boe-law-meta {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
  line-height: 1.5;
}
.boe-law-stats {
  display: flex; gap: 14px;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.boe-law-stats span { display: inline-flex; align-items: center; gap: 4px; }
.boe-law-stats i { color: var(--gold-d); }
.boe-law-actions {
  display: flex; gap: 8px;
}
.boe-law-actions .btn {
  flex: 1;
  justify-content: center;
}

.cite[href]:hover {
  background: var(--gold-soft);
  color: var(--gold-d);
}

/* ============ COMMENT THREAD (Collaboration) ============ */
.comments-thread {
  display: flex; flex-direction: column; gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.comment {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
}
.comment-body {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 10px 14px;
}
.comment-author {
  font-weight: 700;
  font-size: 13px;
  color: var(--green-800);
}
body.theme-dark .comment-author { color: var(--gold-l); }
.comment-time {
  font-size: 11px;
  color: var(--text-3);
  margin-right: 8px;
}
.comment-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.7;
  margin-top: 4px;
}
.comment-text .mention {
  background: var(--gold-soft);
  color: var(--gold-d);
  padding: 1px 6px;
  border-radius: 6px;
  font-weight: 600;
}

/* ============ SOURCE CARDS (Knowledge Sources) ============ */
.src-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 18px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  transition: 0.2s;
  align-items: center;
}
.src-card:hover {
  border-color: var(--green-700);
  box-shadow: var(--shadow-1);
}
.src-card-add {
  border-style: dashed;
  background: var(--surface-2);
}
.src-card-add:hover {
  background: var(--surface);
}
.src-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 26px;
  flex-shrink: 0;
}
.src-body { min-width: 0; }
.src-name {
  font-weight: 700;
  font-size: 15.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 3px;
}
.src-url {
  font-size: 12px;
  color: var(--gold-d);
  font-weight: 600;
  font-family: 'Courier New', monospace;
  margin-bottom: 6px;
}
.src-desc {
  font-size: 13px;
  color: var(--text-3);
  line-height: 1.6;
  margin-bottom: 10px;
}
.src-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-2);
}
.src-stats span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.src-stats i {
  color: var(--green-700);
}
.src-folders {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.src-folders .chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
}
.src-folders .chip:hover {
  background: var(--gold-soft);
  color: var(--gold-d);
  border-color: var(--gold);
}
.src-actions {
  display: flex;
  gap: 6px;
  flex-direction: column;
}

/* ============ DRIVE FOLDERS ============ */
.drive-folder {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: var(--shadow-1);
}
.drive-folder:hover {
  transform: translateY(-3px);
  border-color: #4285F4;
  box-shadow: 0 8px 24px rgba(66, 133, 244, 0.15);
}
.drive-folder-name {
  font-weight: 700;
  font-size: 14px;
  margin-top: 10px;
  color: var(--text);
}
.drive-folder-meta {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ============ NOTIFICATIONS PANEL ============ */
.notif-panel {
  position: fixed;
  top: calc(var(--topbar-h) + 8px);
  left: 16px;
  width: 380px;
  max-height: calc(100vh - var(--topbar-h) - 24px);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  z-index: 60;
  transform: translateY(-12px) scale(0.96);
  opacity: 0;
  visibility: hidden;
  transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
body.theme-dark .notif-panel { background: rgba(15, 33, 24, 0.95); backdrop-filter: blur(20px); }
.notif-panel.open {
  opacity: 1; visibility: visible;
  transform: translateY(0) scale(1);
}
.np-head {
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.np-title {
  font-weight: 800;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.np-title i { color: var(--gold-d); }
.np-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.np-tab {
  padding: 6px 12px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.np-tab em {
  font-style: normal;
  font-size: 10px;
  margin-right: 4px;
  padding: 1px 6px;
  background: var(--danger);
  color: white;
  border-radius: 999px;
}
.np-tab.active {
  background: var(--surface);
  color: var(--green-800);
  box-shadow: var(--shadow-1);
}
body.theme-dark .np-tab.active { color: var(--gold-l); }
.np-list {
  flex: 1;
  overflow-y: auto;
  max-height: 480px;
}
.np-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: 0.15s;
}
.np-item:hover { background: var(--surface-2); }
.np-item.unread {
  background: linear-gradient(90deg, var(--gold-soft), transparent);
  border-right: 3px solid var(--gold);
}
.np-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.np-icon.red { background: var(--danger-soft); color: var(--danger); }
.np-icon.blue { background: var(--info-soft); color: var(--info); }
.np-icon.green { background: var(--success-soft); color: var(--success); }
.np-icon.amber { background: var(--warning-soft); color: var(--gold-d); }
.np-item b { display: block; font-size: 13.5px; font-weight: 700; color: var(--text); }
.np-item span { font-size: 12px; color: var(--text-3); display: block; margin-top: 2px; }
.np-item em {
  font-style: normal;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 5px;
  display: block;
}
.np-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  text-align: center;
}

/* ============ KANBAN BOARD ============ */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 18px;
}
.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 400px;
}
.kanban-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px 12px;
  font-weight: 700;
  color: var(--text);
  font-size: 13.5px;
}
.kanban-head i { color: var(--gold-d); margin-left: 4px; }
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  cursor: grab;
  transition: 0.2s;
  box-shadow: var(--shadow-1);
}
.kanban-card:hover {
  transform: translateY(-2px);
  border-color: var(--green-700);
  box-shadow: var(--shadow-2);
}
.kanban-card.done { opacity: 0.7; }
.kanban-card.prio-high { border-right: 4px solid var(--danger); }
.kc-tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  margin-bottom: 8px;
}
.kanban-card h4 {
  font-size: 13.5px;
  margin: 0 0 6px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.5;
}
.kanban-card p {
  font-size: 12px;
  color: var(--text-3);
  margin: 0 0 10px;
}
.kc-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-3);
}
.kc-foot i { color: var(--green-700); margin-left: 3px; }

/* ---- Kanban drag & drop (المهام الحيّة) ---- */
.kc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.kc-edit { width: 26px; height: 26px; opacity: 0.5; }
.kc-edit:hover { opacity: 1; }
.kc-over { color: var(--danger) !important; font-weight: 700; }
.kanban-card .kc-tag.tag-red { background: var(--danger-soft, #fde8e8); color: var(--danger); }
.kanban-card { user-select: none; }
.kanban-card.dragging { opacity: 0.45; transform: rotate(1.5deg) scale(0.98); cursor: grabbing; box-shadow: var(--shadow-2); }
.kanban-dropzone { min-height: 120px; border-radius: var(--radius-sm); transition: background 0.15s, box-shadow 0.15s; }
.kanban-dropzone.drag-over { background: var(--green-50, rgba(31,77,46,0.06)); box-shadow: inset 0 0 0 2px var(--green-700); }
.kanban-empty {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
  padding: 22px 8px;
}

/* ---- Contract wizard & document preview ---- */
.modal-dialog.modal-lg { max-width: 920px; width: 95%; }
.wz-body { max-height: 62vh; overflow-y: auto; }
.doc-preview { max-height: 60vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.contract-doc { box-shadow: none; }
.lib-card { transition: 0.2s; }
.lib-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--green-700); }

/* ============ INTEGRATIONS ============ */
.int-card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: 0.2s;
  box-shadow: var(--shadow-1);
  text-align: center;
}
.int-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
}
.int-icon {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 26px;
  margin: 0 auto 14px;
}
.int-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
.int-desc {
  font-size: 12.5px;
  color: var(--text-3);
  margin-bottom: 14px;
  line-height: 1.6;
}

/* ============ AI ATTACHMENTS ============ */
.ai-attachments {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0;
  padding: 12px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.ai-attachments:empty { display: none; }
.ai-attachment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  animation: fade-in 0.3s ease;
}

/* Tag suggestions */
.tag-suggestions {
  position: fixed;
  z-index: 80;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-3);
  max-height: 300px;
  overflow-y: auto;
}
.ts-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  transition: 0.15s;
}
.ts-item:hover {
  background: var(--gold-soft);
  color: var(--gold-d);
}
.tag-chip .remove-tag i { font-size: 14px; }
.tag-chip .remove-tag:hover { opacity: 1 !important; color: var(--danger); }

/* ============ GLOBAL SEARCH RESULTS ============ */
.global-search-results {
  position: fixed;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  z-index: 100;
  max-height: 480px;
  overflow-y: auto;
  animation: fade-in 0.18s ease;
}
.gsr-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  background: var(--surface-2);
}
.gsr-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: 0.15s;
}
.gsr-item:last-child { border-bottom: 0; }
.gsr-item:hover { background: var(--surface-2); }
.gsr-item > i:first-child {
  font-size: 22px;
  width: 36px;
  text-align: center;
}
.gsr-item b { display: block; font-size: 13.5px; color: var(--text); }
.gsr-item span { font-size: 11.5px; color: var(--text-3); }

/* ============ MODAL ============ */
.app-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: 0.25s;
}
.app-modal.open { opacity: 1; visibility: visible; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(11, 37, 22, 0.7);
  backdrop-filter: blur(8px);
}
.modal-dialog {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
  transform: scale(0.95) translateY(20px);
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.app-modal.open .modal-dialog {
  transform: scale(1) translateY(0);
}
.modal-sm { max-width: 420px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.modal-head i { color: var(--gold-d); }
.modal-body {
  padding: 22px;
  overflow-y: auto;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ============ ACTION MENU ============ */
.action-menu {
  position: fixed;
  z-index: 70;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-3);
  min-width: 180px;
  padding: 6px;
  animation: fade-in 0.15s ease;
}
.am-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}
.am-item i { font-size: 16px; color: var(--text-3); }
.am-item:hover {
  background: var(--surface-2);
  color: var(--text);
}
.am-item:hover i { color: var(--green-700); }
.am-item.danger { color: var(--danger); }
.am-item.danger i { color: var(--danger); }
.am-item.danger:hover { background: var(--danger-soft); }
.am-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ============ WELCOME TOUR ============ */
.welcome-tour {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: 0.3s;
}
.welcome-tour.show { opacity: 1; visibility: visible; }
.wt-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 37, 22, 0.85);
  backdrop-filter: blur(10px);
}
.wt-card {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--gold);
  border-radius: 24px;
  padding: 40px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.welcome-tour.show .wt-card { transform: scale(1); }
.wt-emoji { font-size: 64px; margin-bottom: 12px; }
.wt-card h2 {
  font-size: 26px;
  color: var(--green-800);
  margin: 0 0 10px;
  font-weight: 800;
}
body.theme-dark .wt-card h2 { color: var(--gold-l); }
.wt-card p {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.7;
  margin: 0 0 24px;
}
.wt-features {
  display: grid;
  gap: 10px;
  margin-bottom: 28px;
}
.wt-feat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: 12px;
  text-align: right;
}
.wt-feat i { font-size: 22px; }
.wt-feat span { font-size: 13.5px; font-weight: 600; color: var(--text); }
.wt-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.wt-actions .btn { padding: 12px 24px; }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--green-800);
  color: var(--cream);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast-success { background: var(--success); }
.toast-info { background: var(--info); }
.toast-warning { background: var(--gold-d); color: var(--green-950); }
.toast-error { background: var(--danger); }

/* ============ USERS MANAGER ============ */
.role-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
}
.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.role-card {
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-right: 4px solid;
  border-radius: var(--radius);
}
.role-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.role-name { font-weight: 800; font-size: 14.5px; }
.role-count {
  font-size: 11px;
  color: var(--text-3);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}
.role-desc {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 10px;
}
.role-perms {
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 11.5px;
}
.perm-line {
  margin-bottom: 4px;
  color: var(--text-2);
  line-height: 1.6;
}
.perm-line b { color: var(--text); }
.perm-line span { color: var(--text-3); }

/* Permission Editor */
.perms-table {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.perm-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
}
.perm-mod {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}
.perm-mod i {
  font-size: 20px;
  color: var(--gold-d);
  width: 32px;
  height: 32px;
  background: var(--gold-soft);
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.perm-ops {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.perm-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-2);
}
.perm-check input { accent-color: var(--green-700); width: 16px; height: 16px; }
.perm-check input:checked + span { color: var(--green-700); }

/* Info Note */
.info-note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--info-soft);
  border-right: 3px solid var(--info);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  color: var(--info);
  margin-top: 12px;
}
.info-note i { font-size: 18px; }

.modal-lg { max-width: 820px !important; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1280px) {
  .lib-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3-2, .grid-2-3 { grid-template-columns: 1fr; }
  .ai-workspace { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .field.full { grid-column: span 1; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .send-panel { grid-template-columns: repeat(2, 1fr); }
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
  .src-card { grid-template-columns: auto 1fr; }
  .src-actions { grid-column: 2; flex-direction: row; margin-top: 8px; }
  .online-users { display: none; }
}

@media (max-width: 760px) {
  .kanban-board { grid-template-columns: 1fr; }
  .notif-panel { left: 8px; right: 8px; width: auto; }
}

@media (max-width: 880px) {
  :root { --sidebar-w: 0px; }
  .menu-btn { display: inline-flex; }
  .sidebar {
    width: 300px;
    transform: translateX(100%);
    box-shadow: var(--shadow-3);
  }
  .sidebar.open { transform: translateX(0); }
  .content { margin-right: 0; padding: calc(var(--topbar-h) + 16px) 16px calc(var(--bottom-nav-h) + 20px); }
  .topbar-search { display: none; }
  .topbar { padding: 0 12px; gap: 6px; }
  .user-meta { display: none; }
  .user-chip { padding: 4px; }
  .bottom-nav { display: flex; align-items: center; }
  .notif-panel { left: 8px; right: 8px; width: auto; }
  .page-head h1 { font-size: 22px; }
  .ai-banner-content { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 14px; gap: 10px; }
  .kpi-val { font-size: 22px; }
  .kpi-icon { width: 40px; height: 40px; font-size: 18px; }
  .mini-stats { grid-template-columns: 1fr 1fr; }
  .lib-grid { grid-template-columns: 1fr 1fr; }
  .ai-templates { grid-template-columns: 1fr 1fr; }
  .cases-grid { grid-template-columns: 1fr; }
  .data-table th, .data-table td { padding: 10px 8px; font-size: 12px; }
  .data-table th:nth-child(4),
  .data-table td:nth-child(4),
  .data-table th:nth-child(5),
  .data-table td:nth-child(5) { display: none; }
  .page-head { gap: 8px; }
  .page-head h1 { font-size: 20px; }
  .filters-bar { padding: 10px; gap: 8px; }
  .cal-day { min-height: 60px; padding: 4px; font-size: 11px; }
  .cal-day .ev { font-size: 9px; padding: 1px 4px; }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .lib-grid, .ai-templates, .mini-stats { grid-template-columns: 1fr 1fr; }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ---- Interactive Calendar (v2) ---- */
.cal-grid{display:grid !important;grid-template-columns:repeat(7,1fr);gap:6px}
.cal-wd{text-align:center;font-weight:700;font-size:12px;color:var(--text-3);padding:4px}
.cal-cell{min-height:84px;border:1px solid var(--border);border-radius:10px;padding:5px;background:var(--surface);display:flex;flex-direction:column;gap:3px;overflow:hidden}
.cal-cell.cal-empty{background:transparent;border:none}
.cal-cell.cal-today{border-color:var(--green-700);box-shadow:inset 0 0 0 1px var(--green-700);background:var(--green-50,rgba(31,77,46,.05))}
.cal-daynum{font-weight:700;font-size:13px;color:var(--text-2,#555)}
.cal-ev{font-size:10.5px;padding:2px 6px;border-radius:6px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#fff}
.cal-ev.session{background:var(--green-700)}
.cal-ev.task{background:var(--gold-d)}
.cal-more{font-size:10px;color:var(--text-3)}
.cal-dot{display:inline-block;width:10px;height:10px;border-radius:3px;margin-left:4px}
.cal-dot.session{background:var(--green-700)}
.cal-dot.task{background:var(--gold-d)}

.cd-tab:hover{color:var(--green-800) !important}

/* ===== المهام: شارات الكروت + نافذة التفاصيل ===== */
.kc-case{display:inline-flex;align-items:center;gap:5px;font-size:12px;color:var(--text-2);background:var(--bg-2,#f4f6fa);border:1px solid var(--border,#e6e9f0);padding:3px 9px;border-radius:8px;margin-top:6px}
.kc-case.daily{color:#8a6d00;background:#fff7e0;border-color:#ffe7a3}
.kc-meta{display:flex;gap:12px;margin-top:8px;font-size:12px;color:var(--text-3)}
.kc-meta span{display:inline-flex;align-items:center;gap:4px}

.modal-dialog.lg{max-width:760px;width:94vw}
.tk-sub{display:flex;align-items:center;gap:8px;margin-top:6px;flex-wrap:wrap}
.tk-tabs{display:flex;gap:4px;padding:0 18px;border-bottom:1px solid var(--border,#e6e9f0);background:var(--bg-1,#fff)}
.tk-tab{display:inline-flex;align-items:center;gap:6px;border:none;background:none;padding:12px 14px;cursor:pointer;font:inherit;color:var(--text-2);border-bottom:2px solid transparent;font-size:14px}
.tk-tab.active{color:var(--primary,#1f5eff);border-bottom-color:var(--primary,#1f5eff);font-weight:600}
.tk-tab .badge-soft{font-size:11px}

.tk-info .tk-row{display:flex;justify-content:space-between;gap:12px;padding:9px 2px;border-bottom:1px dashed var(--border,#eef0f5)}
.tk-row .tk-k{color:var(--text-3);font-size:13px}
.tk-row .tk-v{font-weight:600;font-size:14px}
.tk-notes-box{margin-top:12px;background:var(--bg-2,#f7f8fb);border:1px solid var(--border,#e6e9f0);border-radius:10px;padding:12px;font-size:14px;line-height:1.7}

.tk-section{display:flex;flex-direction:column;gap:14px}
.tk-empty{text-align:center;color:var(--text-3);padding:22px;font-size:13px}
.tk-att-list{display:flex;flex-direction:column;gap:8px}
.tk-att{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--border,#e6e9f0);border-radius:10px;background:var(--bg-1,#fff)}
.tk-att i{font-size:18px;color:var(--primary,#1f5eff)}
.tk-att a{font-weight:600;color:var(--text-1);text-decoration:none;flex:0 1 auto}
.tk-att a:hover{text-decoration:underline}
.tk-att-meta{margin-inline-start:auto;font-size:12px;color:var(--text-3)}

.tk-add{display:flex;gap:8px;align-items:flex-end}
.tk-add textarea{flex:1;resize:vertical;border:1px solid var(--border,#e6e9f0);border-radius:10px;padding:10px;font:inherit}
.tk-timeline{display:flex;flex-direction:column;gap:0;position:relative}
.tk-tl-item{display:flex;gap:12px;padding:0 0 16px 0;position:relative}
.tk-tl-dot{width:11px;height:11px;border-radius:50%;background:var(--primary,#1f5eff);margin-top:5px;flex:0 0 auto;box-shadow:0 0 0 3px var(--primary-100,#e6efff)}
.tk-tl-item:not(:last-child)::before{content:'';position:absolute;inset-inline-start:5px;top:14px;bottom:0;width:1px;background:var(--border,#e6e9f0)}
.tk-tl-body{flex:1}
.tk-tl-head{display:flex;gap:8px;align-items:center;font-size:12px;color:var(--text-3)}
.tk-tl-head b{color:var(--text-1);font-size:13px}
.tk-tl-body p{margin:3px 0 0;font-size:14px;line-height:1.6}

.tk-chat{display:flex;flex-direction:column;gap:10px;max-height:320px;overflow-y:auto;padding:4px}
.tk-msg{align-self:flex-start;max-width:80%;background:var(--bg-2,#f4f6fa);border:1px solid var(--border,#e6e9f0);border-radius:12px;padding:9px 12px}
.tk-msg.mine{align-self:flex-end;background:var(--primary-100,#e6efff);border-color:var(--primary-200,#cfe0ff)}
.tk-msg-head{display:flex;gap:8px;font-size:11px;color:var(--text-3);margin-bottom:3px}
.tk-msg-head b{color:var(--text-1)}
.tk-msg p{margin:0;font-size:14px;line-height:1.6}
.tk-approved{display:inline-flex;align-items:center;gap:6px;color:var(--success,#1a9d57);font-size:13px;margin-inline-start:auto}

.btn-outline{background:transparent;border:1px solid var(--primary,#1f5eff);color:var(--primary,#1f5eff)}
.btn-outline:hover{background:var(--primary-100,#e6efff)}

/* ===== لوحة التحكم: KPIs قابلة للنقر + شريط ملخص اليوم ===== */
.kpi-click{cursor:pointer;transition:transform .15s ease,box-shadow .15s ease}
.kpi-click:hover{transform:translateY(-3px);box-shadow:0 10px 28px rgba(0,0,0,.16)}
.kpi-click::after{content:'\ea4d';font-family:'remixicon';position:absolute;inset-inline-start:12px;bottom:10px;opacity:.45;font-size:14px}

.today-strip{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:14px;margin:18px 0}
.today-tile{display:flex;gap:12px;align-items:center;background:var(--surface,#fff);border:1px solid var(--border,#e6e9f0);border-radius:16px;padding:14px 16px;cursor:pointer;transition:transform .15s ease,box-shadow .15s ease}
.today-tile:hover{transform:translateY(-2px);box-shadow:0 8px 22px rgba(0,0,0,.10)}
.tt-ic{width:46px;height:46px;border-radius:13px;display:grid;place-items:center;color:#fff;font-size:22px;flex:0 0 auto}
.tt-ic.grn{background:linear-gradient(135deg,#1f9d57,#0c6b39)}
.tt-ic.blu{background:linear-gradient(135deg,#2f7bf6,#1551c4)}
.tt-ic.gld{background:linear-gradient(135deg,#e0a948,#b9851f)}
.tt-ic.red{background:linear-gradient(135deg,#e15b5b,#b32d2d)}
.tt-body{min-width:0}
.tt-num{font-size:26px;font-weight:800;line-height:1}
.tt-lbl{font-size:13px;color:var(--text-2);margin-top:2px}
.tt-split{display:flex;flex-wrap:wrap;gap:6px;margin-top:7px;font-size:11px}
.tt-split span{background:var(--bg-2,#f4f6fa);border:1px solid var(--border,#e6e9f0);border-radius:7px;padding:2px 7px;color:var(--text-2)}
.tt-split .ok{color:#0c6b39;background:#e9f7ef;border-color:#c7ead4}
.tt-split .wait{color:#8a6d00;background:#fff7e0;border-color:#ffe7a3}
.tt-split .stage{color:#1551c4;background:#eaf1fe;border-color:#cfe0ff}
.tt-split .muted{color:var(--text-3)}

/* ===== ملخص اليوم: شبكة بطاقات (تعزيز) ===== */
#view-dashboard .today-strip{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:14px;margin:18px 0}
#view-dashboard .today-tile{position:relative;overflow:hidden;display:flex;gap:14px;align-items:flex-start;min-height:96px;background:var(--surface,#fff);border:1px solid var(--border,#e6e9f0);border-radius:16px;padding:16px;box-shadow:0 1px 2px rgba(16,24,40,.04)}
#view-dashboard .today-tile::before{content:'';position:absolute;inset-inline-start:0;top:0;bottom:0;width:4px;background:var(--gold,#DD9B27);opacity:.85}
#view-dashboard .today-tile .tt-body{flex:1;min-width:0}
#view-dashboard .today-tile .tt-num{font-variant-numeric:tabular-nums}
#view-dashboard .today-tile .tt-lbl{font-weight:600}
@media (max-width:640px){#view-dashboard .today-strip{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}#view-dashboard .today-tile{padding:12px;gap:10px;min-height:0}.tt-ic{width:38px;height:38px;font-size:18px}.tt-num{font-size:22px}}
/* إخفاء العدّادات الفارغة حتى تُحسب من البيانات */
.nav-item em.count:empty,#notifBtn .badge:empty,.np-tab em:empty,.seg button em:empty,.kanban-head .badge-soft:empty{display:none}

/* القوائم المنسدلة: خيارات مقروءة في الوضعين (كان النص أبيض على خلفية بيضاء في الوضع الداكن) */
select option, select optgroup { color: #1F2A22; background: #FFFFFF; }
body.theme-dark { color-scheme: dark; }
body.theme-dark select option, body.theme-dark select optgroup { color: #F3EFE6; background: #1F2A22; }
/* بطاقات المهام: أزرار الإجراءات السريعة */
.kanban-card .kc-acts .icon-btn { width: 26px; height: 26px; font-size: 14px; }
.kanban-card { cursor: grab; } .kanban-card.dragging { opacity: .45; cursor: grabbing; }
