@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');
@import url('flatpickr.min.css');

/* ==========================================================================
   Design System Tokens & Themes (Light / Dark)
   ========================================================================== */
:root {
  --font-ar: 'Cairo', system-ui, -apple-system, sans-serif;
  --font-en: 'Inter', -apple-system, sans-serif;
  --font-num: 'Plus Jakarta Sans', system-ui, sans-serif;

  /* Executive Corporate Light Theme */
  --bg-app: #f4f6fa;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f8fafc;
  --bg-surface-hover: #f1f5f9;
  --bg-sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-item-hover: rgba(255, 255, 255, 0.06);
  --sidebar-item-active: rgba(99, 102, 241, 0.18);
  --sidebar-border: rgba(255, 255, 255, 0.08);

  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-focus: #6366f1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-white: #ffffff;

  /* Vibrant Accent Palette */
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-glow: rgba(79, 70, 229, 0.25);

  --emerald: #10b981;
  --emerald-light: #ecfdf5;
  --emerald-border: #a7f3d0;
  --emerald-dark: #065f46;

  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --amber-border: #fde68a;
  --amber-dark: #92400e;

  --rose: #ef4444;
  --rose-light: #fef2f2;
  --rose-border: #fecaca;
  --rose-dark: #991b1b;

  --cyan: #06b6d4;
  --cyan-light: #ecfeff;
  --cyan-border: #a5f3fc;
  --cyan-dark: #155e75;

  --purple: #8b5cf6;
  --purple-light: #f5f3ff;
  --purple-border: #ddd6fe;
  --purple-dark: #5b21b6;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 6px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 18px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 14px 34px rgba(15, 23, 42, 0.09);
  --shadow-xl: 0 20px 45px rgba(15, 23, 42, 0.14);

  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Corporate Dark Mode */
[data-theme="dark"] {
  --bg-app: #090d16;
  --bg-surface: #111827;
  --bg-surface-elevated: #1a2234;
  --bg-surface-hover: #222d42;
  --bg-sidebar: #0b0f19;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-item-hover: rgba(255, 255, 255, 0.05);
  --sidebar-item-active: rgba(99, 102, 241, 0.25);
  --sidebar-border: rgba(255, 255, 255, 0.06);

  --border-subtle: #202b3d;
  --border-strong: #334155;
  --border-focus: #818cf8;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;

  --primary-light: rgba(99, 102, 241, 0.15);
  --emerald-light: rgba(16, 185, 129, 0.15);
  --amber-light: rgba(245, 158, 11, 0.15);
  --rose-light: rgba(239, 68, 68, 0.15);
  --cyan-light: rgba(6, 182, 212, 0.15);
  --purple-light: rgba(139, 92, 246, 0.15);

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* Base Resets */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  direction: rtl;
  font-family: var(--font-ar);
  font-size: 14.5px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-ar);
  background-color: var(--bg-app);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

button, input, select, textarea {
  font-family: inherit;
}

/* ==========================================================================
   Executive App Layout (Sidebar + Topbar + Main Area)
   ========================================================================== */
.crm-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Corporate Sidebar */
.crm-sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
  transition: var(--transition-slow);
}

.sidebar-header {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-logo-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  flex-shrink: 0;
}

.brand-info {
  overflow: hidden;
}

.brand-name {
  font-size: 1.15rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.25);
  color: #a5b4fc;
  letter-spacing: 0.5px;
}

.brand-subtitle {
  font-size: 0.76rem;
  color: #64748b;
  margin-top: 1px;
  white-space: nowrap;
}

/* Sidebar Nav Groups */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.sidebar-content::-webkit-scrollbar {
  width: 4px;
}
.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.nav-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  padding: 0 10px 8px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--sidebar-text);
  font-family: var(--font-ar);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: right;
  text-decoration: none;
}

.nav-item-btn:hover {
  background: var(--sidebar-item-hover);
  color: #ffffff;
  transform: translateX(-2px);
}

.nav-item-btn.active {
  background: var(--sidebar-item-active);
  color: #ffffff;
  border-color: rgba(99, 102, 241, 0.4);
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.2);
}

.nav-item-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}

.nav-item-btn.active .nav-icon {
  opacity: 1;
  color: #818cf8;
}

.nav-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
}

.nav-badge.badge-primary {
  background: #4f46e5;
  color: #ffffff;
}

.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-mini-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid rgba(255, 255, 255, 0.15);
}

.user-meta-name {
  font-size: 0.86rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.2;
}

.user-meta-role {
  font-size: 0.72rem;
  color: #64748b;
}

.btn-sidebar-action {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--sidebar-border);
  color: #94a3b8;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-sidebar-action:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

/* ==========================================================================
   Main Content Area & Topbar
   ========================================================================== */
.crm-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.crm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(10px);
}

.topbar-right-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-title-wrap h1 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-subtitle-crumb {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Live Currency Widget */
.currency-badge-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-family: var(--font-num);
  font-weight: 700;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  direction: ltr !important;
  unicode-bidi: isolate;
}

#rateTicker {
  direction: ltr !important;
  unicode-bidi: isolate;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-num);
}

.rate-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-primary);
  white-space: nowrap;
}

.rate-chip .rate-cur {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.rate-chip .rate-val {
  color: var(--primary);
  font-weight: 800;
  font-family: var(--font-num);
}

.rate-sep {
  color: var(--border-strong);
  font-weight: 400;
  margin: 0 2px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseGreen 2s infinite;
}

@keyframes pulseGreen {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.btn-icon-soft {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  padding: 2px;
  transition: var(--transition);
}

.btn-icon-soft:hover {
  color: var(--primary);
  transform: rotate(45deg);
}

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

/* Search Bar in Topbar */
.global-search-box {
  position: relative;
  width: 280px;
}

.global-search-box input {
  width: 100%;
  padding: 8px 36px 8px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.86rem;
  outline: none;
  transition: var(--transition);
}

.global-search-box input:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-icon-pos {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-shortcut {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-num);
}

/* Topbar Buttons */
.btn-topbar-new {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff;
  border: none;
  font-family: var(--font-ar);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
  transition: var(--transition);
}

.btn-topbar-new:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(79, 70, 229, 0.45);
}

.btn-topbar-new:active {
  transform: translateY(0);
}

.btn-topbar-tool {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-topbar-tool:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ==========================================================================
   Views Navigation Tabs (Dashboard, Table, Kanban, Gallery, Companies)
   ========================================================================== */
.view-nav-tabs-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

.nav-tabs-list {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.nav-tab-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-ar);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.nav-tab-pill:hover {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
}

.nav-tab-pill.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.3);
  font-weight: 700;
}

/* ==========================================================================
   Smart Filtration Engine (Toolbar & Controls)
   ========================================================================== */
.filter-bar-container {
  padding: 14px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-controls-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-select-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
}

.filter-select-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.filter-select {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  padding-right: 4px;
  padding-left: 20px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left center;
  background-size: 14px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-width: 100px;
}

.filter-select option {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-filter-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-secondary);
  font-family: var(--font-ar);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-filter-reset:hover {
  background: var(--rose-light);
  color: var(--rose);
  border-color: var(--rose);
}

.filter-stats-badge {
  margin-right: auto;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface-elevated);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-stats-count {
  color: var(--primary);
  font-weight: 800;
  font-family: var(--font-num);
}

/* ==========================================================================
   Executive KPI Overview Cards
   ========================================================================== */
.executive-dashboard-wrap {
  padding: 24px 32px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.kpi-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 4px;
  background: var(--accent-bar, var(--primary));
}

.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.kpi-icon-badge {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--icon-bg, var(--primary-light));
  color: var(--icon-color, var(--primary));
}

.kpi-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.kpi-big-number {
  font-family: var(--font-num);
  font-size: 1.85rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.kpi-currency {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
}

.kpi-bottom-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

.kpi-tag-positive {
  color: var(--emerald);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.kpi-tag-neutral {
  color: var(--text-muted);
  font-weight: 600;
}

/* ==========================================================================
   Visual Analytics & Insights Grid (Wide 1.65fr : 1fr Proportions)
   ========================================================================== */
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 24px;
  align-items: stretch;
}

@media (max-width: 1100px) {
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

.analytics-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevent grid overflow */
}

.analytics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.analytics-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.analytics-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Interactive SVG Bar & Trend Chart */
.chart-container {
  height: 280px;
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 24px 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.chart-container::-webkit-scrollbar { height: 4px; }
.chart-container::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.chart-bar-group {
  flex: 1 1 0;
  min-width: 44px;
  max-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 4px 1px 0;
  transition: background 0.18s ease;
}

.chart-bar-group:hover {
  background: rgba(99, 102, 241, 0.06);
}

.chart-bar-track {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  position: relative;
  min-height: 0;
  padding-bottom: 6px;
}

.chart-bar-pill {
  width: 100%;
  max-width: 38px;
  min-width: 16px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #6366f1 0%, rgba(99, 102, 241, 0.45) 100%);
  transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.2s ease, filter 0.2s ease;
  position: relative;
  min-height: 8px;
  flex-shrink: 0;
  cursor: pointer;
}

.chart-bar-pill:hover {
  filter: brightness(1.2) drop-shadow(0 4px 12px rgba(99, 102, 241, 0.5));
  transform: scaleY(1.02);
  transform-origin: bottom;
}

.chart-bar-val-badge {
  font-size: 0.7rem;
  font-family: var(--font-num);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 5px;
  white-space: nowrap;
  pointer-events: none;
  line-height: 1;
  transition: color 0.18s ease;
}

.chart-bar-group:hover .chart-bar-val-badge {
  color: var(--primary);
}

.chart-bar-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
  height: 34px;
  width: 100%;
  padding-top: 5px;
  border-top: 2px solid var(--border-subtle);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  transition: color 0.18s ease, border-top-color 0.18s ease;
  flex-shrink: 0;
}

.chart-bar-group:hover .chart-bar-label {
  color: var(--text-primary);
  border-top-color: var(--primary);
}

@media (max-width: 768px) {
  .chart-bar-group {
    min-width: 48px;
  }
}

/* Universal Floating Chart Tooltip */
.chart-floating-tooltip {
  position: fixed;
  z-index: 999999;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font-size: 0.8rem;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4);
  transition: opacity 0.15s ease, transform 0.15s ease;
  opacity: 0;
  transform: translate(-50%, -100%) scale(0.96);
  line-height: 1.45;
  direction: rtl;
}
.chart-floating-tooltip.visible {
  opacity: 1;
  transform: translate(-50%, -100%) scale(1);
}
.chart-floating-tooltip .cft-title {
  font-weight: 800;
  font-size: 0.85rem;
  color: #f8fafc;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chart-floating-tooltip .cft-val {
  font-family: var(--font-num);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--emerald);
}
.chart-floating-tooltip .cft-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 2px;
}
.chart-floating-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: rgba(15, 23, 42, 0.95) transparent transparent transparent;
}

/* ==========================================================================
   Financial Pyramid & Capital Flow Section
   ========================================================================== */
.financial-pyramid-section {
  margin-top: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.pyramid-layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 28px;
  align-items: stretch;
  margin-top: 20px;
}

@media (max-width: 1100px) {
  .pyramid-layout-grid {
    grid-template-columns: 1fr;
  }
}

.pyramid-funnel-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
}

.pyramid-tier-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 13px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-xs);
  margin: 0 auto;
}

.pyramid-tier-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.pyramid-tier-card.tier-1 { width: 100%; border-right: 4px solid var(--primary); }
.pyramid-tier-card.tier-2 { width: 93%;  border-right: 4px solid var(--purple); }
.pyramid-tier-card.tier-3 { width: 86%;  border-right: 4px solid var(--emerald); }
.pyramid-tier-card.tier-4 { width: 79%;  border-right: 4px solid var(--amber); }
.pyramid-tier-card.tier-5 { width: 72%;  border-right: 4px solid var(--cyan); }

.pyramid-tier-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.pyramid-tier-step-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.82rem;
  font-family: var(--font-num);
  flex-shrink: 0;
}

.tier-step-1 { background: var(--primary-light); color: var(--primary); }
.tier-step-2 { background: var(--purple-light); color: var(--purple); }
.tier-step-3 { background: var(--emerald-light); color: var(--emerald); }
.tier-step-4 { background: var(--amber-light); color: var(--amber-dark); }
.tier-step-5 { background: var(--cyan-light); color: var(--cyan-dark); }

.pyramid-tier-names {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pyramid-tier-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-primary);
}

.pyramid-tier-desc {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.pyramid-tier-metrics {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
}

.pyramid-tier-value {
  font-size: 1.18rem;
  font-weight: 800;
  font-family: var(--font-num);
  color: var(--text-primary);
  white-space: nowrap;
}

.pyramid-tier-pct-badge {
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 800;
  font-family: var(--font-num);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pyramid-side-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.pyramid-stat-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.pyramid-stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.pyramid-stat-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pyramid-stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.pyramid-stat-val {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: var(--font-num);
  color: var(--text-primary);
}

.pyramid-stat-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Company Progress List in Widget */
.company-share-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.company-share-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.company-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.86rem;
  font-weight: 700;
}

.company-item-val {
  font-family: var(--font-num);
  color: var(--text-secondary);
}

.company-progress-bg {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-hover);
  overflow: hidden;
}

.company-progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--item-color, var(--primary));
  transition: width 0.8s ease;
}

/* Urgency & Attention Alerts Widget */
.urgent-alerts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.urgent-alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  transition: var(--transition);
}

.urgent-alert-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

.alert-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-item-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.alert-item-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.alert-item-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Executive SaaS Data Table
   ========================================================================== */
.saas-card-table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--bg-surface-elevated);
}

.saas-card-table-wrap::-webkit-scrollbar {
  height: 8px;
}
.saas-card-table-wrap::-webkit-scrollbar-track {
  background: var(--bg-surface-elevated);
  border-radius: 4px;
}
.saas-card-table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}
.saas-card-table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

.saas-table {
  width: 100%;
  min-width: 1280px;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.86rem;
}

/* Sticky Action Column in RTL */
.saas-table td:last-child,
.saas-table th:last-child {
  min-width: 160px;
  text-align: center;
  position: sticky;
  left: 0;
  z-index: 5;
  background: var(--bg-surface);
  box-shadow: -4px 0 10px rgba(0, 0, 0, 0.05);
}

.saas-table th:last-child {
  z-index: 15;
  background: var(--bg-surface-elevated);
}

.saas-table tbody tr:hover td:last-child {
  background: var(--bg-surface-hover);
}

.saas-table thead {
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 10;
}

.saas-table th {
  padding: 14px 16px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.saas-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: var(--transition);
  cursor: pointer;
}

.saas-table tbody tr:hover {
  background: var(--bg-surface-hover);
}

.saas-table td {
  padding: 14px 16px;
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
}

.td-project-main {
  min-width: 220px;
}

.project-title-text {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-client-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Status & Category Pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-completed {
  background: var(--emerald-light);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
}

.status-in-progress {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.status-under-review {
  background: var(--purple-light);
  color: var(--purple);
  border: 1px solid var(--purple-border);
}

.status-pending {
  background: var(--amber-light);
  color: var(--amber-dark);
  border: 1px solid var(--amber-border);
}

.status-cancelled {
  background: var(--rose-light);
  color: var(--rose);
  border: 1px solid var(--rose-border);
}

.company-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.company-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.payment-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-xs);
}

.payment-paid {
  background: var(--emerald-light);
  color: var(--emerald);
}

.payment-unpaid {
  background: var(--rose-light);
  color: var(--rose);
}

.payment-partial {
  background: var(--amber-light);
  color: var(--amber-dark);
}

/* Action Button Group */
.table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-action-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-action-icon:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.btn-action-icon.btn-action-delete:hover {
  background: var(--rose);
  color: #ffffff;
  border-color: var(--rose);
}

/* ==========================================================================
   Kanban Stage Board View
   ========================================================================== */
.kanban-board-container {
  padding: 20px 32px 40px;
  overflow-x: auto;
}

.kanban-columns-wrap {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  min-width: 1000px;
}

.kanban-col {
  flex: 1;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.kanban-col-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-col-title {
  font-size: 0.92rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kanban-col-count {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.kanban-cards-body {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 150px;
  transition: var(--transition);
}

.kanban-cards-body.drag-over {
  background: var(--primary-light);
  border: 2px dashed var(--primary);
  border-radius: var(--radius-md);
}

.kanban-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  cursor: grab;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 10px;
  user-select: none;
}

.kanban-card:active {
  cursor: grabbing;
}

.kanban-card.dragging {
  opacity: 0.45;
  transform: scale(0.96);
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.kanban-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  padding-top: 8px;
}

/* Receipt & Invoices Buttons */
.btn-receipt-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--emerald-light);
  color: var(--emerald);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid var(--emerald-border);
  transition: var(--transition);
  white-space: nowrap;
}

.btn-receipt-link:hover {
  background: var(--emerald);
  color: #ffffff;
}

.btn-quick-receipt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px dashed var(--border-strong);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: var(--font-ar) !important;
}

.btn-quick-receipt:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ==========================================================================
   Gallery Grid View
   ========================================================================== */
.gallery-grid-container {
  padding: 20px 32px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 18px;
}

.gallery-project-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.gallery-project-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

/* ==========================================================================
   Multi-Step Wizard Modal ("Next / Previous Steps")
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 820px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: scale(0.96);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-modal-close:hover {
  background: var(--rose-light);
  color: var(--rose);
  border-color: var(--rose-border);
}

/* Stepper Progress Bar */
.wizard-stepper-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  gap: 12px;
  min-height: 80px;
  box-sizing: border-box;
}

.wizard-stepper-bar::-webkit-scrollbar {
  display: none;
}

.wizard-step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  flex-shrink: 0;
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-num);
  font-weight: 800;
  font-size: 0.84rem;
  color: var(--text-muted);
  transition: var(--transition);
}

.step-label-wrap {
  display: flex;
  flex-direction: column;
}

.step-num-text {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
}

.step-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Active & Completed Stepper states */
.wizard-step-item.active .step-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.wizard-step-item.active .step-title {
  color: var(--primary);
  font-weight: 800;
}

.wizard-step-item.completed .step-circle {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #ffffff;
}

.wizard-step-item.completed .step-title {
  color: var(--emerald);
}

.wizard-step-content {
  display: none;
  padding: 28px;
  flex: 1;
}

.wizard-step-content.active {
  display: block;
  animation: fadeInStep 0.25s ease;
}

@keyframes fadeInStep {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Modal Footer */
.modal-footer {
  padding: 16px 28px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   Form Components
   ========================================================================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.col-span-2 {
  grid-column: span 2;
}

.form-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-input, .form-textarea {
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
  width: 100%;
}

.form-input:focus, .form-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ==========================================================================
   Comprehensive Modern Select & Dropdown Overhaul (Zero Emojis, 100% SVG)
   ========================================================================== */
select.form-select, select.form-input, select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--bg-surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 14px center;
  background-size: 16px;
  padding-left: 40px !important;
  padding-right: 14px !important;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  width: 100%;
  height: 42px;
  line-height: 1.5;
  box-sizing: border-box;
}

select.form-select:hover, select:hover {
  border-color: var(--border-hover);
  background-color: var(--bg-surface-elevated);
}

select.form-select:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background-color: var(--bg-surface);
}

select.form-select option, select option {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 500;
}

/* ==========================================================================
   TomSelect Searchable Controls Luxury Styling (Single-Clean-Border, No Nested Selects)
   ========================================================================== */
.ts-wrapper,
.ts-wrapper.form-select,
div.ts-wrapper {
  width: 100% !important;
  position: relative !important;
  direction: rtl !important;
  font-family: var(--font-ar) !important;
  border: none !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  height: auto !important;
  min-height: unset !important;
  outline: none !important;
}

/* Remove default TomSelect pseudo-arrow so only our custom SVG chevron is displayed */
.ts-wrapper.single .ts-control::after,
.ts-wrapper .ts-control::after,
.ts-control:after,
.ts-wrapper .ts-control:after {
  display: none !important;
  content: none !important;
}

.ts-wrapper .ts-control,
.full .ts-control,
.ts-control {
  background-color: var(--bg-surface) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: left 14px center !important;
  background-size: 16px !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--radius-sm) !important;
  padding: 0 14px 0 38px !important;
  color: var(--text-primary) !important;
  font-family: var(--font-ar) !important;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  height: 42px !important;
  min-height: 42px !important;
  display: flex !important;
  align-items: center !important;
  box-shadow: none !important;
  outline: none !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease !important;
  box-sizing: border-box !important;
  cursor: pointer !important;
}

.ts-wrapper.focus .ts-control,
.ts-wrapper.input-active .ts-control,
.ts-wrapper.dropdown-active .ts-control {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px var(--primary-glow) !important;
  background-color: var(--bg-surface) !important;
}

.ts-control input,
.ts-control > input {
  color: var(--text-primary) !important;
  font-family: var(--font-ar) !important;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important;
  margin: 0 !important;
  height: 100% !important;
}

.ts-control .item,
.ts-wrapper.single .ts-control .item,
.ts-wrapper.single .ts-control > div {
  color: var(--text-primary) !important;
  font-family: var(--font-ar) !important;
  font-size: 0.9rem !important;
  font-weight: 600 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  outline: none !important;
  padding: 0 !important;
  margin: 0 !important;
  line-height: normal !important;
  display: inline-flex !important;
  align-items: center !important;
}

.ts-dropdown {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-xl) !important;
  padding: 6px !important;
  margin-top: 4px !important;
  z-index: 10000 !important;
  font-family: var(--font-ar) !important;
  backdrop-filter: blur(12px) !important;
  min-width: 220px !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

.ts-dropdown .option {
  padding: 9px 14px !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-primary) !important;
  font-size: 0.88rem !important;
  font-weight: 600 !important;
  transition: all 0.15s ease !important;
  cursor: pointer !important;
  text-align: right !important;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
  background: var(--primary-subtle) !important;
  color: var(--primary) !important;
}

.ts-dropdown .option.selected {
  background: var(--primary) !important;
  color: #ffffff !important;
}

/* Input validation error pulse effect */
@keyframes errorPulse {
  0%, 100% {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.35) !important;
  }
  50% {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.15) !important;
  }
}

.input-error-pulse,
.ts-wrapper.input-error-pulse .ts-control,
.custom-searchable-select .select-trigger.input-error-pulse,
.form-input.input-error-pulse,
.form-select.input-error-pulse {
  animation: errorPulse 0.5s ease-in-out 3 !important;
  border-color: var(--danger) !important;
}

/* ==========================================================================
   Custom Searchable Company Select (Search in Dropdown, Zero Collisions)
   ========================================================================== */
.custom-searchable-select {
  position: relative;
  width: 100%;
  direction: rtl;
  font-family: var(--font-ar);
}

.custom-searchable-select .select-trigger {
  width: 100%;
  height: 42px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0 16px 0 40px; /* Generous 16px right padding so text NEVER touches border, 40px left for arrow */
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  user-select: none;
  box-sizing: border-box;
  position: relative;
}

.custom-searchable-select .select-trigger:hover {
  border-color: var(--border-hover);
  background-color: var(--bg-surface-elevated);
}

.custom-searchable-select .select-trigger:focus,
.custom-searchable-select.is-open .select-trigger {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background-color: var(--bg-surface);
}

.custom-searchable-select .select-value-text {
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  flex: 1;
}

.custom-searchable-select .select-arrow-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  transition: transform 0.2s ease, stroke 0.2s ease;
  stroke: #64748b;
  flex-shrink: 0;
}

.custom-searchable-select.is-open .select-arrow-icon {
  transform: translateY(-50%) rotate(180deg);
  stroke: var(--primary);
}

.custom-searchable-select .select-dropdown-menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  z-index: 10000;
  display: none;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(16px);
  animation: dropdownSlideIn 0.18s ease-out;
}

.custom-searchable-select.is-open .select-dropdown-menu {
  display: flex;
}

@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Dedicated Search Bar inside the Dropdown (في المنطوق منه) */
.custom-searchable-select .dropdown-search-header {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-elevated);
}

.custom-searchable-select .dropdown-search-header svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.custom-searchable-select .dropdown-search-field {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.88rem;
  font-weight: 600;
  outline: none;
  padding: 4px 0;
}

.custom-searchable-select .dropdown-search-field::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.custom-searchable-select .clear-search-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.85rem;
  border-radius: 4px;
}

.custom-searchable-select .clear-search-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.custom-searchable-select .dropdown-options-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 6px;
}

.custom-searchable-select .select-opt-item {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color 0.15s ease, color 0.15s ease;
  text-align: right;
}

.custom-searchable-select .select-opt-item:hover {
  background: var(--primary-subtle);
  color: var(--primary);
}

.custom-searchable-select .select-opt-item.is-selected {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

.custom-searchable-select .dropdown-add-action {
  padding: 10px 14px;
  border-top: 1px dashed var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--primary);
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background-color 0.15s ease;
}

.custom-searchable-select .dropdown-add-action:hover {
  background: var(--primary-subtle);
}

.form-textarea {
  min-height: 90px;
  resize: vertical;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-ar);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-surface-hover);
}

.btn-danger {
  background: var(--rose-light);
  color: var(--rose);
  border-color: var(--rose-border);
}

.btn-danger:hover {
  background: var(--rose);
  color: #ffffff;
}

/* Installment Plan Presets */
.plan-presets-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-preset-pill {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-preset-pill.active, .btn-preset-pill:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.installments-table-header {
  display: grid;
  grid-template-columns: 2fr 1.1fr 1.2fr 1.4fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.installment-row {
  display: grid;
  grid-template-columns: 2fr 1.1fr 1.2fr 1.4fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.installment-row:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}

@media (max-width: 768px) {
  .installments-table-header {
    display: none;
  }
  .installment-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* ==========================================================================
   Modern Toast Notifications Engine ("إشعارات الأخطاء والنجاح بشكل لذيذ")
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: 400px;
  width: calc(100% - 48px);
}

.toast-card {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
  animation: slideInToast 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.toast-card.hide {
  transform: translateX(-120%);
  opacity: 0;
}

@keyframes slideInToast {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.toast-message {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.toast-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  color: var(--text-primary);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: var(--toast-accent, var(--primary));
  animation: toastProgress linear forwards;
}

@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

/* Toast Varieties */
.toast-success {
  --toast-accent: var(--emerald);
  border-right: 4px solid var(--emerald);
}
.toast-success .toast-icon {
  background: var(--emerald-light);
  color: var(--emerald);
}

.toast-error {
  --toast-accent: var(--rose);
  border-right: 4px solid var(--rose);
}
.toast-error .toast-icon {
  background: var(--rose-light);
  color: var(--rose);
}

.toast-warning {
  --toast-accent: var(--amber);
  border-right: 4px solid var(--amber);
}
.toast-warning .toast-icon {
  background: var(--amber-light);
  color: var(--amber);
}

.toast-info {
  --toast-accent: var(--primary);
  border-right: 4px solid var(--primary);
}
.toast-info .toast-icon {
  background: var(--primary-light);
  color: var(--primary);
}

/* ==========================================================================
   Custom Confirmation Dialog (Replaces native confirm())
   ========================================================================== */
.confirm-dialog-card {
  max-width: 440px;
  padding: 26px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.confirm-icon-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--rose-light);
  color: var(--rose);
  display: flex;
  align-items: center;
  justify-content: center;
}

.confirm-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
}

.confirm-message {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.confirm-actions button {
  flex: 1;
}

/* Details Modal Tab Headers */
.details-tab-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 24px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.details-tab-btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  font-family: var(--font-ar);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.details-tab-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.details-tab-content {
  display: none;
  padding: 24px;
}

.details-tab-content.active {
  display: block;
}

/* ==========================================================================
   Date Presets & Helper Chips
   ========================================================================== */
.btn-preset-chip {
  transition: var(--transition);
  font-family: var(--font-ar);
}
.btn-preset-chip:hover {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

/* ==========================================================================
   Tom Select Custom Enterprise Styling (RTL & Dark/Light Theme Support)
   ========================================================================== */
.ts-wrapper {
  direction: rtl !important;
  font-family: var(--font-ar) !important;
  font-size: 0.88rem !important;
  width: 100% !important;
}

.ts-control {
  background: var(--bg-surface-elevated) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-primary) !important;
  padding: 8px 14px !important;
  min-height: 42px !important;
  display: flex !important;
  align-items: center !important;
  box-shadow: none !important;
  transition: var(--transition) !important;
  cursor: pointer;
}

.ts-wrapper.focus .ts-control {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15) !important;
}

.ts-control input {
  color: var(--text-primary) !important;
  font-family: var(--font-ar) !important;
  text-align: right !important;
}

.ts-control .item {
  color: var(--text-primary) !important;
  font-weight: 600 !important;
}

.ts-dropdown {
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-subtle) !important;
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text-primary) !important;
  margin-top: 4px !important;
  z-index: 1000 !important;
  overflow: hidden !important;
  direction: rtl !important;
}

.ts-dropdown .option {
  padding: 10px 14px !important;
  color: var(--text-primary) !important;
  font-size: 0.86rem !important;
  cursor: pointer !important;
  transition: var(--transition) !important;
  text-align: right !important;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
  background: var(--bg-surface-hover) !important;
  color: var(--primary) !important;
  font-weight: 600 !important;
}

.ts-dropdown .option.selected {
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  font-weight: 700 !important;
}

.ts-dropdown .create {
  padding: 10px 14px !important;
  color: var(--primary) !important;
  font-weight: 700 !important;
  background: var(--bg-surface-elevated) !important;
  border-top: 1px dashed var(--border-subtle) !important;
  text-align: right !important;
}

/* Custom indicator / arrow */
.ts-wrapper .ts-control::after {
  content: "" !important;
  display: block !important;
  width: 7px !important;
  height: 7px !important;
  border-left: 2px solid var(--text-secondary) !important;
  border-bottom: 2px solid var(--text-secondary) !important;
  transform: rotate(-45deg) !important;
  margin-right: auto !important;
  margin-left: 4px !important;
  transition: transform 0.2s ease !important;
}

.ts-wrapper.dropdown-active .ts-control::after {
  transform: rotate(135deg) !important;
}

/* ==========================================================================
   Project Details Modal Modern Tab Bar & Centered SVG Icons
   ========================================================================== */
.details-tab-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 28px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-wrap: wrap;
}

.details-tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.2;
  vertical-align: middle;
  text-decoration: none;
}

.details-tab-btn svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  stroke-width: 2.2;
}

.details-tab-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.details-tab-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.25);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   Time Range Quick Filter Strip
   ========================================================================== */
.time-filter-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.time-filter-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.time-filter-icon {
  display: flex;
  align-items: center;
  color: var(--primary);
}

.time-filter-segmented {
  display: inline-flex;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 3px;
  flex-wrap: wrap;
}

.time-filter-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-ar) !important;
}

.time-filter-btn:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

.time-filter-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px var(--primary-glow);
}

.time-filter-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  font-family: var(--font-ar) !important;
}

/* ==========================================================================
   Settings Modal Tabs
   ========================================================================== */
.settings-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.settings-tab-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.settings-tab-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.25);
}

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
}

/* ==========================================================================
   Receipt Viewer Thumbnails & Tabs
   ========================================================================== */
.btn-receipt-thumb-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-receipt-thumb-tab:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.btn-receipt-thumb-tab.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.3);
}

.btn-receipt-view {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid rgba(99, 102, 241, 0.2);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-receipt-view:hover {
  background: var(--primary);
  color: #ffffff;
}

.btn-invoice-print {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--cyan-light);
  color: var(--cyan);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1px solid rgba(6, 182, 212, 0.2);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-invoice-print:hover {
  background: var(--cyan);
  color: #ffffff;
}

/* ==========================================================================
   Printable Invoice Paper Sheet Styles
   ========================================================================== */
.invoice-paper {
  background: #ffffff;
  color: #1e293b;
  border-radius: var(--radius-md);
  padding: 36px 40px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
  font-family: inherit;
  direction: rtl;
  text-align: right;
}

.inv-paper-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.inv-brand-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: #0f172a;
  letter-spacing: -0.5px;
}

.inv-brand-tagline {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 3px;
}

.inv-brand-contact {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 4px;
}

.inv-doc-details {
  text-align: left;
}

.inv-heading-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: #2563eb;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.inv-meta-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  font-size: 0.82rem;
  color: #64748b;
  margin-bottom: 3px;
}

.inv-meta-val {
  color: #0f172a;
  font-weight: 700;
}

.inv-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 20px 0;
}

.inv-parties-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.inv-party-card {
  background: #f8fafc;
  border: 1px solid #edf2f7;
  border-radius: 8px;
  padding: 16px;
}

.inv-party-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.inv-party-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 4px;
}

.inv-party-desc {
  font-size: 0.85rem;
  color: #475569;
}

.inv-party-company {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 4px;
}

.inv-status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.inv-status-paid {
  background: #dcfce7;
  color: #166534;
}

.inv-status-pending {
  background: #fef3c7;
  color: #92400e;
}

.inv-payment-meta {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 6px;
}

.inv-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
}

.inv-table th {
  background: #f1f5f9;
  color: #475569;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  text-align: right;
}

.inv-table td {
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  font-size: 0.88rem;
}

.inv-item-desc {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 3px;
}

.inv-summary-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  margin-bottom: 30px;
}

.inv-payment-info-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 18px;
}

.inv-info-box-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #334155;
  margin-bottom: 6px;
}

.inv-info-row {
  font-size: 0.82rem;
  color: #475569;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
}

.inv-notes-text {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 8px;
  line-height: 1.4;
}

.inv-totals-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 18px;
}

.inv-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 8px;
}

.inv-grand-total {
  border-top: 2px solid #cbd5e1;
  padding-top: 10px;
  font-size: 1.1rem;
  font-weight: 900;
  color: #0f172a;
}

.inv-footer-stamp-area {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 20px;
  border-top: 1px dashed #cbd5e1;
}

.inv-stamp-badge {
  border: 2px solid #16a34a;
  color: #16a34a;
  padding: 8px 18px;
  border-radius: 6px;
  text-align: center;
  transform: rotate(-3deg);
  display: inline-block;
}

.inv-stamp-inner {
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: 0.5px;
}

.inv-stamp-date {
  font-size: 0.72rem;
  margin-top: 2px;
}

.inv-signature-box {
  text-align: center;
  width: 160px;
}

.inv-signature-title {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 24px;
}

.inv-signature-line {
  border-bottom: 1px solid #64748b;
  margin-bottom: 4px;
}

.inv-signature-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #334155;
}

/* Print stylesheet: isolates invoice sheet on paper cleanly without blank page clipping */
@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }
  
  html, body {
    background: #ffffff !important;
    color: #0f172a !important;
    height: auto !important;
    overflow: visible !important;
    font-size: 11pt !important;
  }

  /* Hide CRM dashboard and chrome */
  .crm-layout, .crm-sidebar, .crm-topbar, .modal-overlay:not(#invoiceModal), .no-print, .btn-modal-close, .modal-header, .toast-container {
    display: none !important;
  }

  #invoiceModal {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    display: block !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    z-index: 999999 !important;
  }

  #invoiceModal .modal-card {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
  }

  .invoice-sheet-container {
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
  }

  #invoicePrintArea, .invoice-paper {
    display: block !important;
    position: static !important;
    box-shadow: none !important;
    border: 1px solid #e2e8f0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 12mm !important;
    background: #ffffff !important;
    color: #0f172a !important;
    visibility: visible !important;
  }

  #invoicePrintArea * {
    visibility: visible !important;
  }

  .inv-paper-header, .inv-parties-grid, .inv-table, .inv-summary-grid, .inv-footer-stamp-area {
    page-break-inside: avoid;
  }
}

/* ==========================================================================
   Project Audit History Timeline Styles
   ========================================================================== */
.history-timeline-wrap {
  position: relative;
  padding: 8px 4px 8px 12px;
  display: flex;
  flex-direction: column;
}

.history-timeline-item {
  position: relative;
  margin-bottom: 20px;
  padding-right: 32px;
}

.history-timeline-item::before {
  content: '';
  position: absolute;
  right: 11px;
  top: 24px;
  bottom: -20px;
  width: 2px;
  background: var(--border-subtle);
}

.history-timeline-item:last-child::before {
  display: none;
}

.timeline-dot {
  position: absolute;
  right: 0;
  top: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-surface-elevated);
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  z-index: 2;
  box-shadow: 0 0 0 3px var(--bg-surface);
}

.timeline-dot.dot-payment {
  border-color: var(--emerald);
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.1);
}

.timeline-dot.dot-discount {
  border-color: var(--rose);
  color: var(--rose);
  background: rgba(244, 63, 94, 0.1);
}

.timeline-dot.dot-split {
  border-color: #8b5cf6;
  color: #8b5cf6;
  background: rgba(139, 92, 246, 0.1);
}

.timeline-dot.dot-delete {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.timeline-dot.dot-postpone {
  border-color: var(--amber);
  color: var(--amber);
  background: rgba(245, 158, 11, 0.1);
}

.timeline-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s ease;
}

.timeline-card:hover {
  border-color: var(--border-hover);
}

.timeline-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.timeline-card-title {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-card-time {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-family: var(--font-num);
}

.timeline-card-details {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.55;
  margin-bottom: 8px;
  background: var(--bg-surface-elevated);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border-right: 3px solid var(--primary);
}

.timeline-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.timeline-user-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--primary-subtle);
  color: var(--primary);
  padding: 3px 9px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.74rem;
}

.timeline-amount-badge {
  font-family: var(--font-num);
  font-weight: 800;
  font-size: 0.82rem;
}

/* ==========================================================================
   Split Installment Modal Components
   ========================================================================== */
.split-row {
  display: grid;
  grid-template-columns: 2fr 1.3fr 1.5fr auto;
  gap: 8px;
  align-items: center;
  background: var(--bg-surface-elevated);
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  animation: fadeInRow 0.2s ease-out;
}

@keyframes fadeInRow {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.split-remove-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.split-remove-btn:hover {
  background: var(--rose-light);
  color: var(--rose);
}

/* ==========================================================================
   Compact Table Action Buttons
   ========================================================================== */
.btn-table-action {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-table-action:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-subtle);
}

.btn-table-action.danger:hover {
  border-color: var(--rose);
  color: var(--rose);
  background: var(--rose-light);
}

.btn-danger {
  background: var(--rose) !important;
  color: #ffffff !important;
  border: 1px solid var(--rose) !important;
}

.btn-danger:hover {
  background: #e11d48 !important;
  border-color: #e11d48 !important;
  color: #ffffff !important;
}

/* ==========================================================================
   Project Details Modal — Tab Navigation Bar
   ========================================================================== */
.details-tab-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}
.details-tab-bar::-webkit-scrollbar { display: none; }

.details-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 13px 16px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.18s ease, border-color 0.18s ease;
  margin-bottom: -1px;
}
.details-tab-btn:hover { color: var(--text-secondary); }
.details-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 700;
}
.details-tab-btn svg { opacity: 0.7; }
.details-tab-btn.active svg { opacity: 1; }

.details-tab-content { display: none; }
.details-tab-content.active { display: block; }

/* ==========================================================================
   Project Details — KPI Financial Cards
   ========================================================================== */
.kpi-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.kpi-cards-grid.has-discount { grid-template-columns: repeat(5, 1fr); }

.kpi-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px 12px;
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.kpi-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.07); }

.kpi-card-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.kpi-card-value {
  font-size: 1.15rem;
  font-weight: 900;
  font-family: var(--font-num);
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 10px;
}
.kpi-card-value.positive { color: var(--emerald); }
.kpi-card-value.negative { color: var(--rose); }
.kpi-card-value.accent   { color: var(--primary); }
.kpi-card-value.warn     { color: var(--amber); }

.kpi-card-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-family: var(--font-num);
}

/* Thin progress bar at the bottom of each KPI card */
.kpi-progress-track {
  height: 4px;
  background: var(--border-subtle);
  border-radius: 100px;
  overflow: hidden;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
}
.kpi-progress-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
}
.kpi-progress-fill.fill-primary   { background: var(--primary); }
.kpi-progress-fill.fill-emerald   { background: var(--emerald); }
.kpi-progress-fill.fill-rose      { background: var(--rose); }
.kpi-progress-fill.fill-amber     { background: var(--amber); }

/* Accent left border strip */
.kpi-card::before {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: var(--border-subtle);
  transition: background 0.2s ease;
}
.kpi-card.border-primary::before { background: var(--primary); }
.kpi-card.border-emerald::before { background: var(--emerald); }
.kpi-card.border-rose::before    { background: var(--rose); }
.kpi-card.border-amber::before   { background: var(--amber); }

/* ==========================================================================
   Installment Table — Enhanced Status & Delay Badges
   ========================================================================== */
.inst-status-paid {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(16,185,129,0.12); color: #059669;
  border: 1px solid rgba(16,185,129,0.25);
  padding: 3px 9px; border-radius: 100px;
  font-size: 0.77rem; font-weight: 700;
}
.inst-status-pending {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(99,102,241,0.08); color: var(--primary);
  border: 1px solid rgba(99,102,241,0.2);
  padding: 3px 9px; border-radius: 100px;
  font-size: 0.77rem; font-weight: 700;
}
.inst-status-overdue {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(239,68,68,0.1); color: #dc2626;
  border: 1px solid rgba(239,68,68,0.25);
  padding: 3px 9px; border-radius: 100px;
  font-size: 0.77rem; font-weight: 700;
  animation: overdueGlow 2s ease-in-out infinite;
}
@keyframes overdueGlow {
  0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
  50%      { box-shadow: 0 0 0 3px rgba(239,68,68,0.18); }
}
.inst-delay-badge {
  display: inline-block;
  background: rgba(245,158,11,0.12); color: #b45309;
  border: 1px solid rgba(245,158,11,0.3);
  padding: 2px 8px; border-radius: 100px;
  font-size: 0.72rem; font-weight: 700;
  font-family: var(--font-num);
}

/* Per-installment micro progress strip */
.inst-amount-wrap {
  display: flex; flex-direction: column; gap: 5px;
}
.inst-progress-strip {
  height: 3px;
  background: var(--border-subtle);
  border-radius: 100px;
  overflow: hidden;
  min-width: 60px;
}
.inst-progress-fill-green {
  height: 100%; background: var(--emerald);
  border-radius: 100px;
  transition: width 0.6s ease;
}

/* ==========================================================================
   Receipt & Invoice Compact Buttons
   ========================================================================== */
.btn-receipt-view, .btn-quick-receipt, .btn-invoice-print {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; font-size: 0.77rem; font-weight: 600;
  border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  transition: all 0.18s ease;
  white-space: nowrap;
}
.btn-receipt-view:hover {
  border-color: var(--primary); color: var(--primary);
  background: var(--primary-subtle);
}
.btn-quick-receipt:hover {
  border-color: var(--emerald); color: var(--emerald);
  background: rgba(16,185,129,0.08);
}
.btn-invoice-print:hover {
  border-color: #8b5cf6; color: #8b5cf6;
  background: rgba(139,92,246,0.08);
}

/* ==========================================================================
   Attachment File Cards
   ========================================================================== */
.file-card {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.18s ease;
  cursor: pointer;
}
.file-card:hover {
  border-color: var(--primary); background: var(--primary-subtle);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.08);
}
.file-card-icon {
  width: 32px; height: 32px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.file-card-icon.pdf   { background: rgba(220,38,38,0.1); color: #dc2626; }
.file-card-icon.image { background: rgba(99,102,241,0.1); color: var(--primary); }
.file-card-icon.doc   { background: rgba(16,185,129,0.1); color: var(--emerald); }
.file-card-label {
  font-size: 0.8rem; font-weight: 700; color: var(--text-primary);
}
.file-card-sub {
  font-size: 0.7rem; color: var(--text-muted); margin-top: 1px;
}

/* ==========================================================================
   Analytics Tab — Chart Container
   ========================================================================== */
.modal-analytics-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}
.analytics-chart-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex; flex-direction: column; align-items: center;
}
.analytics-chart-title {
  font-size: 0.82rem; font-weight: 700; color: var(--text-secondary);
  margin-bottom: 16px; align-self: flex-start;
}
.analytics-legend {
  width: 100%; margin-top: 16px; display: flex; flex-direction: column; gap: 7px;
}
.analytics-legend-item {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.8rem;
}
.analytics-legend-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.analytics-legend-label { flex: 1; margin-right: 8px; color: var(--text-secondary); font-weight: 600; }
.analytics-legend-val   { font-family: var(--font-num); font-weight: 800; color: var(--text-primary); }

.analytics-bars-box {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
}
.analytics-bars-title {
  font-size: 0.82rem; font-weight: 700; color: var(--text-secondary);
  margin-bottom: 14px;
}
.analytics-bar-row {
  display: grid; grid-template-columns: 130px 1fr 80px;
  align-items: center; gap: 10px; margin-bottom: 10px;
}
.analytics-bar-name { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.analytics-bar-track { height: 8px; background: var(--border-subtle); border-radius: 100px; overflow: hidden; }
.analytics-bar-fill  { height: 100%; border-radius: 100px; transition: width 0.7s cubic-bezier(0.4,0,0.2,1); }
.analytics-bar-pct   { font-size: 0.76rem; font-weight: 700; font-family: var(--font-num); color: var(--text-muted); text-align: left; }

/* Financial completion ring label */
.analytics-ring-center {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center; pointer-events: none;
}
.analytics-ring-pct  { font-size: 1.5rem; font-weight: 900; font-family: var(--font-num); color: var(--text-primary); line-height: 1; }
.analytics-ring-sub  { font-size: 0.68rem; font-weight: 700; color: var(--text-muted); margin-top: 2px; }
.analytics-canvas-wrap { position: relative; display: flex; align-items: center; justify-content: center; }

/* ==========================================================================
   Comprehensive Responsive System (Phones, Tablets & Small Laptops)
   ========================================================================== */

/* Mobile Hamburger Toggle Button (Hidden on Desktop) */
.btn-sidebar-toggle-mobile {
  display: none;
}

/* Mobile Sidebar Close Button (Hidden on Desktop) */
.btn-sidebar-close-mobile {
  display: none;
}

/* Mobile Backdrop Overlay */
.sidebar-mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-mobile-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Scoped KPI Grid for Dashboard vs Details Modal */
.executive-dashboard-wrap .kpi-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

/* --------------------------------------------------------------------------
   Breakpoint 1: <= 1280px (Laptops & Standard Screens)
   -------------------------------------------------------------------------- */
@media (max-width: 1280px) {
  .executive-dashboard-wrap .kpi-cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .analytics-grid,
  .pyramid-layout-grid {
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
  }
}

/* --------------------------------------------------------------------------
   Breakpoint 2: <= 1024px (Tablets / iPad Pro & Air)
   -------------------------------------------------------------------------- */
@media (max-width: 1024px) {
  /* Layout: Convert Sidebar into Off-Canvas Drawer (RTL: slides from right) */
  .crm-layout {
    position: relative;
    overflow-x: hidden;
  }

  .crm-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 290px;
    max-width: 86vw;
    height: 100vh;
    height: 100dvh;
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.35);
    background: var(--bg-sidebar);
  }

  .crm-sidebar.open {
    transform: translateX(0);
  }

  .crm-main {
    width: 100%;
    min-width: 0;
    margin-right: 0;
  }

  /* Hamburger Toggle & Close Buttons */
  .btn-sidebar-toggle-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
  }

  .btn-sidebar-toggle-mobile:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-strong);
    color: var(--primary);
  }

  .btn-sidebar-close-mobile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--sidebar-border);
    color: #cbd5e1;
    cursor: pointer;
    margin-right: auto;
    transition: var(--transition);
  }

  .btn-sidebar-close-mobile:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.4);
  }

  /* Topbar Navigation */
  .crm-topbar {
    padding: 12px 20px;
    gap: 14px;
  }

  .page-title-wrap h1 {
    font-size: 1.2rem;
  }

  .currency-badge-strip {
    font-size: 0.78rem;
    padding: 4px 10px;
  }

  .global-search-box {
    width: 220px;
  }

  /* Views Navigation Tabs */
  .view-nav-tabs-bar {
    padding: 8px 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .view-nav-tabs-bar::-webkit-scrollbar {
    display: none;
  }

  .nav-tabs-list {
    flex-wrap: nowrap;
    width: max-content;
  }

  /* Filter Bar Container */
  .filter-bar-container {
    padding: 12px 20px;
  }

  .filter-controls-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Dashboard Container & KPI Cards */
  .executive-dashboard-wrap {
    padding: 20px 20px 36px;
    gap: 20px;
  }

  .executive-dashboard-wrap .kpi-cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  /* Charts & Pyramid Grids: Switch to 1 Column Stack */
  .analytics-grid,
  .pyramid-layout-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .timeline-bars-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }

  /* Modals */
  .modal-card {
    max-width: 92vw;
  }
}

/* --------------------------------------------------------------------------
   Breakpoint 3: <= 768px (Mobile Phones & Small Tablets)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  /* Prevent iOS zoom on input focus */
  input, select, textarea {
    font-size: 16px !important;
  }

  /* Topbar Mobile Layout: Neat 2-row stacking */
  .crm-topbar {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .topbar-right-area {
    width: 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .page-title-wrap {
    min-width: 0;
    flex: 1;
  }

  .page-title-wrap h1 {
    font-size: 1.05rem;
    flex-wrap: wrap;
    gap: 6px;
  }

  .currency-badge-strip {
    font-size: 0.72rem;
    padding: 3px 8px;
    gap: 6px;
  }

  .topbar-actions {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .global-search-box {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .global-search-box input {
    font-size: 0.84rem !important;
    padding: 7px 32px 7px 10px;
    height: 38px;
  }

  .search-shortcut {
    display: none;
  }

  .btn-topbar-new {
    padding: 7px 14px;
    font-size: 0.82rem;
    white-space: nowrap;
    height: 38px;
    flex-shrink: 0;
  }

  .btn-topbar-tool {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
  }

  /* Filter Bar Row */
  .filter-bar-container {
    padding: 10px 14px;
  }

  .filter-select-wrap {
    flex: 1 1 calc(50% - 6px);
    min-width: 130px;
  }

  .filter-select {
    font-size: 0.82rem;
    width: 100%;
  }

  .filter-stats-badge {
    width: 100%;
    justify-content: center;
    margin-top: 4px;
    font-size: 0.78rem;
  }

  /* Time Filter Strip */
  .time-filter-strip {
    padding: 10px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .time-filter-segmented {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
    padding-bottom: 2px;
  }

  .time-filter-segmented::-webkit-scrollbar {
    display: none;
  }

  .time-filter-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 6px 12px;
    font-size: 0.78rem;
  }

  .time-filter-summary {
    font-size: 0.74rem;
    text-align: right;
  }

  /* Dashboard Viewport & KPI Cards */
  .executive-dashboard-wrap {
    padding: 14px 12px 28px;
    gap: 14px;
  }

  .executive-dashboard-wrap .kpi-cards-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .kpi-card {
    padding: 14px 16px;
  }

  .kpi-big-number {
    font-size: 1.55rem;
  }

  .kpi-icon-badge {
    width: 38px;
    height: 38px;
  }

  /* Section 1: Analytics */
  .analytics-card {
    padding: 14px;
  }

  .analytics-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .analytics-title {
    font-size: 0.95rem;
  }

  /* Section 2: Financial Progress Timeline */
  .timeline-bars-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 8px;
  }

  /* Section 3: Financial Pyramid */
  .financial-pyramid-section {
    padding: 14px;
  }

  .pyramid-tier-card {
    padding: 10px 12px;
    gap: 10px;
  }

  .pyramid-tier-card.tier-1,
  .pyramid-tier-card.tier-2,
  .pyramid-tier-card.tier-3,
  .pyramid-tier-card.tier-4,
  .pyramid-tier-card.tier-5 {
    width: 100% !important;
  }

  .pyramid-tier-desc {
    display: none;
  }

  .pyramid-tier-title {
    font-size: 0.82rem;
  }

  .pyramid-tier-value {
    font-size: 0.98rem;
  }

  .pyramid-tier-pct-badge {
    padding: 2px 7px;
    font-size: 0.72rem;
  }

  .pyramid-side-metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* Kanban & Gallery Views */
  .kanban-board-container {
    padding: 12px 12px 24px;
  }

  .kanban-columns-wrap {
    min-width: 880px;
    gap: 12px;
  }

  .gallery-grid-container {
    padding: 14px 12px 28px;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* All Modals: Multi-step Wizard & Project Details */
  .modal-overlay {
    padding: 8px;
    align-items: center;
  }

  .modal-card {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 94vh;
    max-height: 94dvh;
    border-radius: var(--radius-lg);
    margin: 0;
  }

  .modal-header {
    padding: 14px 16px;
  }

  .modal-title {
    font-size: 1.05rem;
  }

  .wizard-stepper-bar {
    padding: 10px 12px;
    gap: 8px;
    min-height: 58px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .wizard-step-item {
    gap: 6px;
    flex-shrink: 0;
  }

  .step-circle {
    width: 28px;
    height: 28px;
    font-size: 0.76rem;
  }

  .step-num-text {
    font-size: 0.62rem;
  }

  .step-title {
    font-size: 0.76rem;
  }

  .wizard-step-content {
    padding: 16px 14px;
  }

  .modal-footer {
    padding: 12px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .modal-footer .btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
    font-size: 0.82rem;
    padding: 9px 12px;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  .form-group.col-span-2 {
    grid-column: span 1 !important;
  }

  /* Project Details Modal specifics */
  #detailsFinances .kpi-cards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }

  .details-tab-bar {
    padding: 0 12px !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    display: flex;
    flex-wrap: nowrap;
    border-bottom: 1px solid var(--border-subtle);
  }

  .details-tab-bar::-webkit-scrollbar {
    display: none;
  }

  .details-tab-btn {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.78rem;
    padding: 10px 12px;
  }

  #tabContent_overview {
    padding: 14px 12px !important;
  }

  .modal-analytics-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
  }

  .analytics-chart-box,
  .analytics-bars-box {
    padding: 14px;
  }

  .analytics-bar-row {
    grid-template-columns: 90px 1fr 60px;
    gap: 6px;
  }
}

/* --------------------------------------------------------------------------
   Breakpoint 4: <= 480px (Compact Mobile Screens: 360px - 480px)
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
  .page-title-wrap h1 {
    font-size: 0.95rem;
  }

  .currency-badge-strip {
    display: none; /* Hide exchange ticker on compact mobile to save room */
  }

  .filter-select-wrap {
    flex: 1 1 100%;
  }

  .btn-filter-reset {
    width: 100%;
    justify-content: center;
  }

  .pyramid-side-metrics {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .pyramid-stat-card {
    padding: 12px;
  }

  .pyramid-stat-val {
    font-size: 1.15rem;
  }

  #detailsFinances .kpi-cards-grid {
    grid-template-columns: 1fr !important;
  }

  .modal-footer .btn {
    flex: 1 1 100%;
  }
}

/* ==========================================================================
   Google Gemini AI Autonomous Agent & Chatbot Styling
   Zero-Emoji Policy Enforced | Premium Executive SaaS Aesthetics
   ========================================================================== */

/* Topbar AI Badge */
.ai-topbar-badge {
  position: relative;
  background: var(--primary-light) !important;
  color: var(--primary) !important;
  border-color: rgba(79, 70, 229, 0.3) !important;
}

.ai-topbar-badge:hover {
  background: var(--primary) !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px var(--primary-glow);
}

/* Floating AI Launcher Button */
.ai-floating-btn {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 995;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 14px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 50%, #7c3aed 100%);
  color: #ffffff;
  box-shadow: 0 8px 24px -4px rgba(79, 70, 229, 0.45), 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  user-select: none;
}

.ai-floating-btn:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 30px -4px rgba(79, 70, 229, 0.6), 0 4px 10px rgba(0, 0, 0, 0.2);
}

.ai-floating-btn:active {
  transform: translateY(0) scale(0.98);
}

.ai-floating-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ai-sparkle-rotate 6s linear infinite;
}

@keyframes ai-sparkle-rotate {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(180deg) scale(1.08); }
  100% { transform: rotate(360deg); }
}

.ai-floating-label {
  font-family: var(--font-ar);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.ai-status-pulse {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 2px #ffffff;
  animation: ai-pulse 2s infinite;
}

@keyframes ai-pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* AI Chat Drawer Window */
.ai-chat-drawer {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 480px;
  max-width: calc(100vw - 32px);
  height: 640px;
  max-height: calc(100vh - 40px);
  z-index: 1000;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.32), 0 8px 20px -4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ai-drawer-open 0.26s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes ai-drawer-open {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Drawer Header */
.ai-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

.ai-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.ai-avatar-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(79, 70, 229, 0.3);
  flex-shrink: 0;
}

.ai-header-text-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ai-header-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.ai-model-pill {
  font-size: 0.66rem;
  font-weight: 700;
  font-family: var(--font-num);
  padding: 1px 7px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.2);
  direction: ltr;
  white-space: nowrap;
}

.ai-header-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.btn-ai-header-tool {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
}

.btn-ai-header-tool:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-ai-close:hover {
  background: var(--rose-light);
  color: var(--rose);
}

/* AI Execution Mode Segmented Selector Bar */
.ai-mode-bar {
  padding: 8px 14px 6px 14px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.ai-mode-pills-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--bg-body);
  padding: 3px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
}

.ai-mode-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-ar);
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  user-select: none;
}

.ai-mode-pill:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.ai-mode-pill.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
}

.ai-mode-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-auto { background: #6366f1; box-shadow: 0 0 6px rgba(99, 102, 241, 0.6); }
.dot-chat { background: #0ea5e9; box-shadow: 0 0 6px rgba(14, 165, 233, 0.6); }
.dot-plan { background: #f59e0b; box-shadow: 0 0 6px rgba(245, 158, 11, 0.6); }
.dot-full { background: #10b981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.6); }

/* Suggestion Quick Chips */
.ai-chips-container {
  display: flex;
  gap: 6px;
  padding: 6px 14px 8px 14px;
  background: transparent;
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.ai-chips-container::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.ai-chip {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-ar);
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.ai-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

/* Messages Box */
.ai-messages-box {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--bg-body);
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.25) transparent;
}

.ai-messages-box::-webkit-scrollbar {
  width: 5px;
}

.ai-messages-box::-webkit-scrollbar-track {
  background: transparent;
}

.ai-messages-box::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.22);
  border-radius: 10px;
}

.ai-messages-box::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 70, 229, 0.4);
}

.ai-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: ai-msg-appear 0.2s ease-out;
}

@keyframes ai-msg-appear {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg-user {
  align-self: flex-start; /* RTL: right side */
}

.ai-msg-assistant {
  align-self: flex-end; /* RTL: left side */
}

.ai-msg-user .ai-msg-bubble {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.22);
}

.ai-msg-assistant .ai-msg-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-msg-bubble {
  padding: 12px 16px;
  font-size: 0.85rem;
  line-height: 1.6;
}

.ai-msg-content p {
  margin-bottom: 8px;
}

.ai-msg-content p:last-child {
  margin-bottom: 0;
}

.ai-msg-content strong {
  font-weight: 800;
  color: inherit;
}

.ai-msg-content ul, .ai-msg-content ol {
  padding-right: 18px;
  margin: 6px 0;
}

.ai-msg-content li {
  margin-bottom: 4px;
}

.ai-msg-content code {
  font-family: var(--font-num);
  font-size: 0.8em;
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

.ai-msg-user .ai-msg-content code {
  background: rgba(255, 255, 255, 0.2);
}

/* Action Executed Card */
.ai-action-card {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-right: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-action-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ai-action-btn {
  padding: 4px 10px;
  font-size: 0.74rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.ai-action-btn:hover {
  background: var(--primary-hover);
}

/* Typing Indicator */
.ai-typing-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ai-typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  animation: ai-dot-bounce 1.4s infinite ease-in-out both;
}

.ai-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input Wrapper */
.ai-input-wrapper {
  padding: 10px 14px 12px 14px;
  background: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  position: relative;
}

.ai-input-tools-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ai-tools-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-ai-mention-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-ar);
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-ai-mention-tool:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.ai-chat-input-box {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  position: relative;
}

.ai-rich-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.86rem;
  line-height: 1.5;
  outline: none;
  overflow-y: auto;
  word-break: break-word;
  white-space: pre-wrap;
  transition: all 0.2s ease;
  scrollbar-width: thin;
  box-sizing: border-box;
}

.ai-rich-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.16);
  background: var(--bg-surface-elevated);
}

.ai-rich-input:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
  display: block;
}

.ai-mention-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.14), rgba(79, 70, 229, 0.22));
  border: 1px solid rgba(99, 102, 241, 0.45);
  color: var(--primary);
  border-radius: var(--radius-full);
  padding: 1px 8px 2px 8px;
  margin: 0 2px;
  font-weight: 700;
  font-size: 0.82rem;
  vertical-align: middle;
  cursor: default;
  user-select: none;
  direction: rtl;
  transition: all 0.15s ease;
}

.ai-mention-badge:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(79, 70, 229, 0.35));
  border-color: var(--primary);
}

.ai-mention-badge svg {
  color: var(--primary);
  flex-shrink: 0;
}

.ai-badge-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  border-radius: 50%;
}

.ai-badge-remove:hover {
  color: var(--rose);
}

.ai-input-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Circular Voice Dictation Button with Waveform Equalizer (Images 3 & 4) */
.ai-btn-mic {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface-elevated, #f1f5f9);
  border: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.08));
  color: var(--primary, #4f46e5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.ai-btn-mic:hover {
  background: rgba(99, 102, 241, 0.14);
  transform: scale(1.06);
}

.ai-mic-icon-idle {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

.ai-mic-wave-bars {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 20px;
}

.ai-mic-wave-bars span {
  display: inline-block;
  width: 3.5px;
  background: #ffffff;
  border-radius: 3px;
  min-height: 6px;
}

/* Active Recording State (Red Circle with Pulsating Equalizer Bars) */
.ai-btn-mic.recording {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.25), 0 4px 14px rgba(239, 68, 68, 0.45) !important;
  animation: ai-mic-recording-pulse 1.3s infinite ease-in-out;
  transform: scale(1.06);
}

.ai-btn-mic.recording .ai-mic-icon-idle {
  display: none !important;
}

.ai-btn-mic.recording .ai-mic-wave-bars {
  display: flex !important;
}

.ai-btn-mic.recording .ai-mic-wave-bars span:nth-child(1) {
  height: 10px;
  animation: ai-equalizer-bar 0.7s infinite alternate ease-in-out;
}

.ai-btn-mic.recording .ai-mic-wave-bars span:nth-child(2) {
  height: 18px;
  animation: ai-equalizer-bar 0.7s infinite alternate ease-in-out 0.2s;
}

.ai-btn-mic.recording .ai-mic-wave-bars span:nth-child(3) {
  height: 12px;
  animation: ai-equalizer-bar 0.7s infinite alternate ease-in-out 0.4s;
}

@keyframes ai-mic-recording-pulse {
  0% { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25), 0 4px 12px rgba(239, 68, 68, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0.15), 0 6px 18px rgba(239, 68, 68, 0.5); }
  100% { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25), 0 4px 12px rgba(239, 68, 68, 0.35); }
}

@keyframes ai-equalizer-bar {
  0% { height: 6px; }
  100% { height: 20px; }
}

/* Multi-Attachment Preview Strip */
.ai-attachment-preview-bar {
  background: var(--bg-surface-elevated, #f8fafc);
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 14px;
  padding: 8px 12px;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-attachment-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 700;
}

.btn-clear-all-attachments {
  background: transparent;
  border: none;
  color: var(--rose, #f43f5e);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}

.btn-clear-all-attachments:hover {
  background: rgba(244, 63, 94, 0.1);
}

.ai-attachment-preview-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0;
  scrollbar-width: thin;
}

.ai-attachment-preview-chips::-webkit-scrollbar {
  height: 4px;
}

.ai-attachment-preview-chips::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.2);
  border-radius: 4px;
}

.ai-attachment-preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface, #ffffff);
  border: 1px solid var(--border-subtle, #e2e8f0);
  border-radius: 10px;
  padding: 4px 8px;
  flex-shrink: 0;
  max-width: 220px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.ai-attachment-thumb {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border-subtle, #e2e8f0);
  flex-shrink: 0;
  background: #f1f5f9;
}

.ai-attachment-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.ai-attachment-name {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.ai-attachment-size {
  font-size: 0.64rem;
  color: var(--text-muted);
}

.btn-remove-ai-attachment {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 2px 4px;
  border-radius: 50%;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove-ai-attachment:hover {
  color: var(--rose, #f43f5e);
  background: rgba(244, 63, 94, 0.1);
}

/* Donut Chart Responsive Container & Side Legend */
.ai-chart-donut-wrap {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 24px !important;
  flex-wrap: wrap !important;
  margin: 12px auto !important;
  width: 100% !important;
}

.ai-chart-donut-canvas-container {
  width: 200px !important;
  height: 200px !important;
  max-width: 100% !important;
  position: relative !important;
  flex-shrink: 0 !important;
  aspect-ratio: 1 / 1 !important;
}

.ai-chart-side-legend {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  min-width: 200px !important;
  flex: 1 !important;
}

.ai-legend-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px !important;
  padding: 8px 12px !important;
  border-radius: 10px !important;
  background: var(--bg-surface, #f8fafc) !important;
  border: 1px solid var(--border-subtle, #e2e8f0) !important;
  transition: all 0.18s ease !important;
}

.ai-legend-row:hover {
  transform: translateX(-3px) !important;
  border-color: var(--primary, #4f46e5) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

.ai-legend-left {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

.ai-legend-color-dot {
  width: 10px !important;
  height: 10px !important;
  border-radius: 50% !important;
  flex-shrink: 0 !important;
}

.ai-legend-label {
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  color: var(--text-primary) !important;
}

.ai-legend-right {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

.ai-legend-val {
  font-size: 0.84rem !important;
  font-weight: 800 !important;
  color: var(--text-primary) !important;
  font-family: var(--font-num, sans-serif) !important;
}

.ai-legend-pct {
  font-size: 0.74rem !important;
  font-weight: 800 !important;
  padding: 2px 8px !important;
  border-radius: 12px !important;
  background: rgba(99, 102, 241, 0.12) !important;
  color: var(--primary, #4f46e5) !important;
  font-family: var(--font-num, sans-serif) !important;
}

.ai-btn-send {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.ai-btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.38);
}

.ai-btn-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ai-input-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 6px;
  padding: 0 2px;
}

.ai-live-badge {
  color: var(--emerald);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ai-live-badge::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--emerald);
}

/* Active Project In Focus Context Bar (Multi-Mention Support) */
.ai-active-project-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(99, 102, 241, 0.06);
  border-bottom: 1px solid rgba(79, 70, 229, 0.15);
  font-size: 0.78rem;
  color: var(--primary);
  animation: ai-msg-appear 0.2s ease-out;
}

.ai-active-project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-active-project-text {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--primary);
}

.ai-mentioned-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 85px;
  overflow-y: auto;
}

.ai-mentioned-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  border: 1px solid rgba(79, 70, 229, 0.25);
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.2s ease;
}

.ai-mentioned-chip:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.15);
}

.ai-mentioned-chip-title {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-primary);
}

.ai-mentioned-chip-title:hover {
  color: var(--primary);
}

.ai-mentioned-chip-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s ease;
}

.ai-mentioned-chip-remove:hover {
  color: var(--rose);
}

.ai-mentioned-all-chip {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-clear-ai-context {
  background: transparent;
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: var(--rose);
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-clear-ai-context:hover {
  background: var(--rose);
  color: #ffffff;
  border-color: var(--rose);
}

/* Interactive Project Mention Buttons */
.ai-project-mention-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  margin: 1px 3px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  border: 1px solid rgba(79, 70, 229, 0.25);
  color: var(--primary);
  font-family: var(--font-ar);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.18s ease;
  box-shadow: 0 1px 3px rgba(79, 70, 229, 0.08);
  flex-direction: row-reverse;
}

.ai-project-mention-btn:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px var(--primary-glow);
}

.ai-project-mention-btn svg {
  flex-shrink: 0;
}

/* Markdown Tables in AI Output */
.ai-table-wrap {
  margin: 10px 0;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.ai-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  text-align: right;
}

.ai-table th {
  background: var(--bg-surface-elevated);
  padding: 8px 10px;
  font-weight: 800;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.ai-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.ai-table tr:last-child td {
  border-bottom: none;
}

.ai-table tr:hover td {
  background: var(--bg-surface-hover);
}

/* Input Bar Tools & Mention Picker */
.ai-input-tools-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.btn-ai-mention-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.btn-ai-mention-tool:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.ai-tool-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.ai-mention-picker {
  position: absolute;
  bottom: 120px;
  left: 16px;
  right: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  z-index: 1050;
  overflow: hidden;
  animation: ai-msg-appear 0.2s ease-out;
}

.ai-mention-picker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.btn-close-picker {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 6px;
}

.ai-mention-picker-list {
  max-height: 200px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.ai-mention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition);
}

.ai-mention-item:last-child {
  border-bottom: none;
}

.ai-mention-item:hover {
  background: var(--primary-light);
}

.ai-mention-item-title {
  font-size: 0.82rem;
  color: var(--text-primary);
  display: block;
}

.ai-mention-item-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.ai-mention-item-id {
  font-family: var(--font-num);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(79, 70, 229, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

/* In-line @ Floating Autocomplete Menu */
.ai-inline-mention-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 14px;
  left: 14px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.28), 0 4px 12px rgba(0, 0, 0, 0.08);
  z-index: 1100;
  scrollbar-width: thin;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  direction: rtl;
  text-align: right;
  animation: ai-msg-appear 0.18s ease-out;
}

.ai-inline-item {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  direction: rtl;
  text-align: right;
  user-select: none;
}

.ai-inline-item:hover, .ai-inline-item.active {
  background: var(--primary-light);
  border-color: rgba(79, 70, 229, 0.2);
}

.ai-inline-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.ai-inline-item-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-inline-item-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-inline-item-badge {
  font-family: var(--font-num);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  background: rgba(79, 70, 229, 0.1);
  border: 1px solid rgba(79, 70, 229, 0.18);
  padding: 2px 7px;
  border-radius: 6px;
  flex-shrink: 0;
}

/* Attachment Preview Bar */
.ai-attachment-preview-bar {
  margin-bottom: 8px;
}

.ai-attachment-preview-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.ai-attachment-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
}

.ai-attachment-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.ai-attachment-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-attachment-size {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-num);
}

.btn-remove-ai-attachment {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 4px;
  transition: var(--transition);
}

.btn-remove-ai-attachment:hover {
  color: var(--rose);
}

/* Interactive Human-in-the-Loop Confirmation Card */
.ai-confirm-card {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  border-right: 4px solid var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-confirm-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 0.84rem;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.ai-confirm-body {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 10px;
}

.ai-confirm-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-ai-confirm-action {
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-ai-confirm-action:hover {
  background: var(--primary-hover);
}

.btn-ai-cancel-action {
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}

.btn-ai-cancel-action:hover {
  color: var(--rose);
  border-color: var(--rose);
}

/* Stepped Live Progress Indicator */
.ai-step-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(79, 70, 229, 0.05);
  border: 1px dashed rgba(79, 70, 229, 0.25);
  font-size: 0.75rem;
}

.ai-step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.ai-step-item.active {
  color: var(--primary);
  font-weight: 700;
}

.ai-step-item.done {
  color: var(--emerald);
}

/* AI Modals Custom Styling (AI Memory & Chat Sessions) */
.ai-custom-modal-card {
  border-radius: 20px !important;
  overflow: hidden;
  box-shadow: 0 24px 60px -10px rgba(0, 0, 0, 0.4), 0 8px 24px -4px rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.ai-modal-header-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.ai-memory-add-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  background: var(--bg-body);
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
}

.ai-memory-input {
  flex: 1;
  background: var(--bg-surface) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 10px !important;
  padding: 9px 14px !important;
  font-size: 0.86rem !important;
  color: var(--text-primary) !important;
  font-family: var(--font-ar) !important;
  outline: none;
}

.ai-memory-input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15) !important;
}

.ai-btn-save-memory {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px !important;
  white-space: nowrap;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  border-radius: 10px !important;
  cursor: pointer;
}

.ai-memories-list-box, .ai-sessions-list-box {
  max-height: 340px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  padding-right: 2px;
}

.ai-memory-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  transition: all 0.18s ease;
}

.ai-memory-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-hover);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.ai-memory-item-content {
  flex: 1;
  min-width: 0;
}

.ai-memory-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.ai-memory-category-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.18);
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-ar);
}

.ai-memory-item-date {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-num);
}

.ai-memory-item-text {
  font-size: 0.84rem;
  color: var(--text-primary);
  line-height: 1.45;
  word-break: break-word;
}

.btn-ai-item-delete {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.btn-ai-item-delete:hover {
  background: var(--rose-light);
  color: var(--rose);
  border-color: rgba(244, 63, 94, 0.25);
  transform: scale(1.05);
}

.ai-sessions-action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-body);
  border-radius: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border-subtle);
}

.ai-session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  transition: all 0.18s ease;
}

.ai-session-item:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.ai-session-item.active {
  background: rgba(79, 70, 229, 0.06);
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.ai-session-item-main {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.ai-session-header-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.ai-session-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-session-current-badge {
  font-size: 0.66rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.2);
  white-space: nowrap;
}

.ai-session-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Fullscreen / Executive Workspace Mode */
.ai-chat-drawer.ai-fullscreen-mode {
  position: fixed !important;
  inset: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  bottom: 0 !important;
  left: 0 !important;
  border-radius: 0 !important;
  z-index: 2000 !important;
  box-shadow: none !important;
  animation: none !important;
}

.ai-drawer-body-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.ai-chat-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.ai-side-overview {
  width: 380px;
  border-right: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
}

.ai-side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.ai-side-header h4 {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.ai-side-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ai-overview-kpi-card {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.ai-overview-kpi-label {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.ai-overview-kpi-val {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: var(--font-num);
  color: var(--text-primary);
  margin-top: 4px;
}

/* Mobile Responsiveness for AI Chat */
@media (max-width: 480px) {
  .ai-chat-drawer {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    height: 86vh;
    max-height: 86vh;
    border-radius: 20px 20px 0 0;
  }
  
  .ai-floating-btn {
    bottom: 16px;
    left: 16px;
    padding: 10px 14px;
  }
  
  .ai-floating-label {
    display: none;
  }

  .ai-side-overview {
    display: none !important;
  }
}

/* ==========================================================================
   Facebook / Notion-Style Interactive Project Mention Popover Card
   ========================================================================== */
.ai-project-mention-popover {
  position: fixed;
  z-index: 3200;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 16px;
  box-shadow: 0 20px 45px -10px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(79, 70, 229, 0.08);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateY(6px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  direction: rtl;
  text-align: right;
  font-family: var(--font-ar);
}

.ai-project-mention-popover.active {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

[data-theme="dark"] .ai-project-mention-popover {
  background: rgba(30, 41, 59, 0.98);
  border-color: rgba(51, 65, 85, 0.9);
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(99, 102, 241, 0.2);
}

.ai-popover-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ai-popover-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.ai-popover-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-popover-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-popover-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.ai-popover-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.ai-popover-client {
  font-weight: 600;
  color: var(--text-secondary);
}

.ai-popover-progress-wrap {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-popover-progress-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
}

.ai-popover-progress-bar {
  height: 6px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 3px;
  overflow: hidden;
}

.ai-popover-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #059669);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.ai-popover-footer-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.ai-popover-btn {
  flex: 1;
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.ai-popover-btn-primary {
  background: var(--primary);
  color: #ffffff;
  border: 1px solid var(--primary);
}

.ai-popover-btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.ai-popover-btn-secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.ai-popover-btn-secondary:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ==========================================================================
   Voice Dictation / Speech-to-Text Pulse Animation
   ========================================================================== */
.btn-ai-voice-btn {
  position: relative;
  transition: all 0.2s ease;
}

.btn-ai-voice-btn.ai-voice-recording {
  background: #f43f5e !important;
  color: #ffffff !important;
  border-color: #f43f5e !important;
  animation: aiVoicePulse 1.2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes aiVoicePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(244, 63, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(244, 63, 94, 0);
  }
}

/* ==========================================================================
   Drag-and-Drop Overlay for Chat Drawer
   ========================================================================== */
.ai-chat-dropzone-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(79, 70, 229, 0.08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 2px dashed var(--primary);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.95rem;
  pointer-events: none;
  animation: dropzoneFade 0.2s ease;
}

@keyframes dropzoneFade {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

/* ==========================================================================
   Project Documents & PRD Generator Tab (Project Details Modal)
   ========================================================================== */
.project-docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.project-doc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
  position: relative;
}

.project-doc-card:hover {
  border-color: rgba(79, 70, 229, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.project-doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.project-doc-type-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}

.project-doc-type-prd {
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.project-doc-type-contract {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.project-doc-type-spec {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.project-doc-type-note {
  background: rgba(100, 116, 139, 0.1);
  color: #64748b;
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.project-doc-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.project-doc-snippet {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.project-doc-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.76rem;
  color: var(--text-muted);
}

.project-doc-btns {
  display: flex;
  gap: 6px;
}

/* Document Viewer & Editor Modal */
.doc-editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  height: 520px;
}

@media (max-width: 768px) {
  .doc-editor-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.doc-editor-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-editor-textarea {
  flex: 1;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  font-family: monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  resize: none;
}

.doc-preview-pane {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg-surface);
  overflow-y: auto;
  font-size: 0.88rem;
  line-height: 1.7;
}

/* Print Styling for Project Documents */
@media print {
  body * {
    visibility: hidden;
  }
  #printableProjectDoc, #printableProjectDoc * {
    visibility: visible;
  }
  #printableProjectDoc {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    padding: 30px;
    background: #ffffff !important;
    color: #000000 !important;
  }
}

/* =========================================================================
   EduLood AI Agent Upgrade: Facebook-Style Mentions, Modes, Charts & Pages
   ========================================================================= */



/* Voice Dictation Pulsing Wave Indicator */
.ai-voice-recording-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  animation: ai-pulse-glow 1.5s infinite alternate;
}

@keyframes ai-pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.2); }
  100% { box-shadow: 0 0 12px 2px rgba(239, 68, 68, 0.35); }
}

.ai-voice-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 18px;
}

.ai-voice-wave span {
  width: 3px;
  height: 100%;
  background: var(--rose);
  border-radius: 3px;
  animation: ai-equalizer 0.8s ease-in-out infinite alternate;
}

.ai-voice-wave span:nth-child(2) { animation-delay: 0.15s; }
.ai-voice-wave span:nth-child(3) { animation-delay: 0.3s; }
.ai-voice-wave span:nth-child(4) { animation-delay: 0.45s; }
.ai-voice-wave span:nth-child(5) { animation-delay: 0.6s; }

@keyframes ai-equalizer {
  0% { height: 4px; }
  100% { height: 18px; }
}

.ai-voice-text {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--rose);
}

.btn-ai-stop-voice {
  background: var(--rose);
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}

/* Interactive Plan Card */
.ai-plan-card {
  margin-top: 14px;
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(139, 92, 246, 0.35);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  position: relative;
  overflow: hidden;
}

.ai-plan-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #8b5cf6, #6366f1, #3b82f6);
}

.ai-plan-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ai-plan-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-plan-summary {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
}

.ai-plan-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.ai-plan-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 0.82rem;
}

.ai-plan-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.2);
  color: #8b5cf6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.ai-plan-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-plan-approve {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-plan-approve:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.btn-plan-save-page {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: transform 0.15s;
}

.btn-plan-save-page:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

/* Hierarchical Visual Pyramid Chart & Interactive AI Charts */
.ai-chart-card {
  margin-top: 14px;
  background: var(--bg-surface-elevated, #ffffff);
  border: 1px solid var(--border-subtle, rgba(226, 232, 240, 0.8));
  border-radius: 16px;
  padding: 16px 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  direction: rtl;
  box-sizing: border-box;
  width: 100%;
}

.ai-chart-card-header,
.ai-chart-header {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle, rgba(0, 0, 0, 0.06));
  flex-wrap: nowrap;
  gap: 12px;
}

.ai-chart-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 0;
}

.ai-chart-card-title span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-chart-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.12);
  color: #6366f1;
  flex-shrink: 0;
}

.btn-ai-chart-export,
.btn-chart-export {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 6px 14px !important;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  border-radius: 20px !important;
  background: var(--bg-surface, #f8fafc) !important;
  border: 1px solid var(--border-subtle, #e2e8f0) !important;
  color: var(--text-secondary, #475569) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

.btn-ai-chart-export:hover,
.btn-chart-export:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%) !important;
  color: #ffffff !important;
  border-color: #4f46e5 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25) !important;
}

.btn-ai-chart-export svg,
.btn-chart-export svg {
  stroke-width: 2.2;
}

/* Pyramid Container & Symmetrical Centered Tiers */
.ai-pyramid-container,
.ai-pyramid-visual {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 10px !important;
  padding: 12px 0 !important;
  width: 100% !important;
  margin: 0 auto !important;
  direction: rtl !important;
  box-sizing: border-box !important;
}

.ai-pyramid-tier {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin-left: auto !important;
  margin-right: auto !important; /* Strict symmetrical horizontal centering */
  padding: 10px 20px !important;
  border-radius: 12px !important;
  color: #ffffff !important;
  font-size: 0.86rem !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), filter 0.2s ease !important;
  cursor: default !important;
  box-sizing: border-box !important;
}

.ai-pyramid-tier:hover {
  transform: scale(1.02) !important;
  filter: brightness(1.08) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18) !important;
}

.ai-pyramid-tier-content {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  gap: 14px !important;
}

.ai-pyramid-tier-label {
  font-size: 0.88rem !important;
  font-weight: 700 !important;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
}

.ai-pyramid-tier-val {
  font-family: 'Inter', -apple-system, sans-serif !important;
  font-weight: 800 !important;
  font-size: 0.94rem !important;
  color: #ffffff !important;
  background: rgba(0, 0, 0, 0.22) !important;
  padding: 3px 12px !important;
  border-radius: 20px !important;
  backdrop-filter: blur(4px) !important;
  letter-spacing: 0.02em !important;
}

/* Project Header Quick Actions Bar */
.project-header-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
  margin-inline-end: 12px;
  flex-wrap: wrap;
}

.btn-header-quick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-header-quick:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-header-quick-primary {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(79, 70, 229, 0.25));
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--primary);
}

.btn-header-quick-primary:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Rich Document Editor Toolbar */
.doc-rich-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  flex-wrap: wrap;
}

.btn-toolbar-tool {
  padding: 4px 8px;
  font-size: 0.76rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-toolbar-tool:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.toolbar-divider {
  width: 1px;
  height: 16px;
  background: var(--border-subtle);
  margin: 0 4px;
}

/* ==========================================================================
   VIEW 6: CALENDAR VIEW STYLING (التقويم الزمني والأجندة التفاعلية)
   ========================================================================== */
.calendar-view-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Calendar Quick KPI Strip */
.calendar-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.cal-kpi-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: var(--transition);
}

.cal-kpi-item:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.cal-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--c-accent, var(--primary)) 15%, transparent);
  color: var(--c-accent, var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.cal-kpi-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.cal-kpi-val {
  font-family: var(--font-num);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

/* Calendar Card Panel */
.calendar-card-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Calendar Toolbar */
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  flex-wrap: wrap;
  gap: 14px;
}

.cal-toolbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cal-nav-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
}

.cal-btn-nav, .cal-btn-today {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.cal-btn-nav:hover, .cal-btn-today:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.cal-btn-today {
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-radius: 0;
}

.cal-title-heading {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  min-width: 140px;
}

.cal-toolbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.cal-type-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cal-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.cal-filter-pill:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.cal-filter-pill.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.cal-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.cal-view-modes {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 3px;
}

.cal-mode-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.cal-mode-btn:hover {
  color: var(--text-primary);
}

.cal-mode-btn.active {
  background: var(--primary);
  color: #ffffff;
}

/* Weekday Header Strip */
.cal-weekdays-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.cal-weekday-cell {
  padding: 10px 6px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-muted);
}

/* Month Days Grid */
.cal-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--border-subtle);
  gap: 1px;
}

.cal-day-cell {
  min-height: 125px;
  background: var(--bg-surface);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background 0.15s ease;
  position: relative;
}

.cal-day-cell.other-month {
  background: rgba(0, 0, 0, 0.12);
  opacity: 0.45;
}

.cal-day-cell.today {
  background: rgba(99, 102, 241, 0.05);
}

.cal-day-cell.today .cal-day-num {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px var(--primary-glow);
}

.cal-day-cell:hover:not(.other-month) {
  background: var(--bg-surface-hover);
}

.cal-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.cal-day-num {
  font-family: var(--font-num);
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-primary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cal-day-events-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

/* Event Pill inside Calendar Cell */
.cal-event-pill {
  padding: 3px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  line-height: 1.3;
}

.cal-event-pill:hover {
  transform: translateY(-1px);
  filter: brightness(1.15);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.cal-event-pill.project {
  background: rgba(99, 102, 241, 0.16);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.cal-event-pill.installment.emerald {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.cal-event-pill.installment.amber {
  background: rgba(245, 158, 11, 0.16);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.cal-event-pill.installment.rose {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.cal-event-pill.task {
  background: rgba(168, 85, 247, 0.16);
  color: #d8b4fe;
  border: 1px solid rgba(168, 85, 247, 0.35);
}

.cal-event-pill.meeting {
  background: rgba(6, 182, 212, 0.16);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.35);
}

.cal-event-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-event-badge-amt {
  font-family: var(--font-num);
  font-size: 0.68rem;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.25);
}

.cal-more-events-btn {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 0;
  text-align: right;
  transition: var(--transition);
}

.cal-more-events-btn:hover {
  text-decoration: underline;
}

/* Agenda Timeline View */
.cal-agenda-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.cal-agenda-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cal-agenda-date-header {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.cal-agenda-items-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cal-agenda-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  cursor: pointer;
  transition: var(--transition);
  gap: 12px;
}

.cal-agenda-item-card:hover {
  background: var(--bg-surface-hover);
  border-color: var(--primary);
  transform: translateX(-3px);
}

.cal-agenda-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cal-agenda-type-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cal-agenda-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cal-agenda-main-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cal-agenda-sub-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.cal-agenda-item-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cal-agenda-amt {
  font-family: var(--font-num);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* Day Detail Modal */
.cal-day-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease-out;
}

.cal-day-modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.cal-day-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}

.cal-day-modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: var(--transition);
}

.cal-day-modal-close:hover {
  color: var(--rose);
}

.cal-day-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 768px) {
  .calendar-kpi-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .cal-day-cell {
    min-height: 80px;
    padding: 4px;
  }
  .cal-event-pill {
    padding: 2px 4px;
    font-size: 0.65rem;
  }
  .cal-event-badge-amt {
    display: none;
  }
  .cal-weekday-cell {
    font-size: 0.7rem;
    padding: 6px 2px;
  }
}

/* ==========================================================================
   AI Execution Mode Compact Selector (Right of Input Field)
   ========================================================================== */
.ai-mode-select-wrap {
  position: relative;
  flex-shrink: 0;
  align-self: flex-end;
}

.ai-mode-select-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 44px;
  padding: 0 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  color: var(--text-primary);
  font-family: var(--font-ar);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
  user-select: none;
  box-sizing: border-box;
}

.ai-mode-select-btn:hover {
  border-color: var(--primary);
  background: var(--bg-surface-elevated);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.14);
  transform: translateY(-1px);
}

.ai-mode-btn-chevron {
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.ai-mode-select-wrap.open .ai-mode-btn-chevron {
  transform: rotate(180deg);
}

.ai-mode-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 250px;
  background: var(--bg-surface-elevated, #1e293b);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 1000;
  animation: aiModePopUp 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes aiModePopUp {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-mode-dropdown-header {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  padding: 6px 10px 4px 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 4px;
}

.ai-mode-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.ai-mode-option:hover {
  background: rgba(255, 255, 255, 0.06);
}

.ai-mode-option.active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.16), rgba(99, 102, 241, 0.26));
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.ai-mode-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ai-mode-opt-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.ai-mode-opt-desc {
  font-size: 0.69rem;
  color: var(--text-muted);
  line-height: 1.25;
}

/* Quick Chips Container inside input wrapper */
.ai-input-wrapper .ai-chips-container {
  padding: 4px 0 8px 0;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Company & All-Projects Mentions Interactive Buttons
   ========================================================================== */
.ai-company-mention-btn,
.ai-all-mention-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 3px 9px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.12), rgba(37, 99, 235, 0.18));
  border: 1px solid rgba(14, 165, 233, 0.4);
  color: #38bdf8;
  border-radius: var(--radius-full);
  font-family: var(--font-ar);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  vertical-align: middle;
  margin: 0 2px;
  text-decoration: none;
  direction: rtl;
  flex-direction: row-reverse;
}

.ai-company-mention-btn:hover,
.ai-all-mention-btn:hover {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.25), rgb(37 99 235 / 2%));
    border-color: #0284c7;
    color: #00adff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.25);
}

.ai-all-mention-btn {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.12), rgba(124, 58, 237, 0.2));
  border-color: rgba(139, 92, 246, 0.4);
  color: #c084fc;
}

.ai-all-mention-btn:hover {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(124, 58, 237, 0.32));
  border-color: #9333ea;
  color: #8124df;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.25);
}

/* ==========================================================================
   Company Projects Explorer Modal
   ========================================================================== */
.ai-company-modal-card {
  max-width: 680px;
  width: 95%;
  border-radius: 18px;
}

.ai-company-kpis-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 8px;
}

.ai-company-kpi-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-company-kpi-box .kpi-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.ai-company-kpi-box .kpi-num {
  font-size: 1.1rem;
  font-family: var(--font-num);
  font-weight: 800;
  color: var(--text-primary);
}

.ai-company-projects-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* max-height: 420px; */
  overflow-y: auto;
  padding-right: 4px;
}

.ai-company-proj-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all 0.2s ease;
}

.ai-company-proj-card:hover {
  border-color: var(--border-strong);
  background: var(--bg-surface-elevated);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.ai-company-proj-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ai-company-proj-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ai-company-proj-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-primary);
  cursor: pointer;
}

.ai-company-proj-title:hover {
  color: var(--primary);
  text-decoration: underline;
}

.ai-company-proj-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.78rem;
}

.btn-open-proj-details {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--primary-light);
  border: 1px solid rgba(99, 102, 241, 0.35);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-open-proj-details:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

@media (max-width: 640px) {
  .ai-company-kpis-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}


#themeIcon {
  display: flex;
  align-items: center;
}

/* ==========================================================================
   Account Security, Password Management & Session Auditing Styles
   ========================================================================== */
.sec-kpi-card {
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.sec-kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.session-device-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--text-primary);
}

.session-device-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--primary);
  flex-shrink: 0;
}

.session-device-icon.mobile {
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.25);
}

.session-device-icon.desktop {
  color: #818cf8;
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.25);
}

.session-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}

.session-status-current {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.session-status-current .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  animation: pulse 1.8s infinite;
}

.session-status-active {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.session-status-loggedout {
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.session-status-revoked {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.session-status-failed {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-revoke-session {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-revoke-session:hover {
  background: #ef4444;
  color: #ffffff;
  border-color: #ef4444;
  transform: translateY(-1px);
}