:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --primary-light: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --purple: #8b5cf6;
  --pink: #ec4899;
  --dark: #1f2937;
  --gray: #6b7280;
  --light: #f3f4f6;
  --bg: #f8fafc;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --card-shadow: 0 4px 20px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 10px 40px rgba(0,0,0,0.12);
}

* { font-family: 'Vazirmatn', sans-serif; }

body {
  background: var(--bg);
  color: var(--dark);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 260px;
  height: 100vh;
  background: var(--sidebar-bg);
  color: #fff;
  padding: 20px 0;
  transition: all 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid #1e293b;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand .logo {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.sidebar-brand h5 { margin: 0; font-weight: 700; font-size: 15px; }
.sidebar-brand small { color: #94a3b8; font-size: 11px; }

.sidebar-menu { padding: 16px 12px; list-style: none; margin: 0; }
.sidebar-menu .menu-title {
  font-size: 11px; color: #64748b;
  padding: 12px 12px 6px;
  font-weight: 600; letter-spacing: 0.5px;
}
.sidebar-menu li a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  color: #cbd5e1; text-decoration: none;
  border-radius: 10px; font-size: 13.5px; font-weight: 500;
  transition: all 0.2s; margin-bottom: 2px;
}
.sidebar-menu li a i { width: 20px; text-align: center; font-size: 15px; }
.sidebar-menu li a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-menu li a.active {
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  color: #fff;
  box-shadow: 0 4px 15px rgba(37,99,235,0.4);
}
.sidebar-menu li a .badge {
  margin-right: auto; background: var(--danger);
  font-size: 10px; padding: 3px 7px;
}

/* ===== MAIN ===== */
.main-content { margin-right: 260px; min-height: 100vh; transition: all 0.3s; }

.topbar {
  background: #fff;
  padding: 14px 28px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  position: sticky; top: 0; z-index: 999;
}
.topbar-search { position: relative; width: 320px; }
.topbar-search input {
  width: 100%; padding: 9px 40px 9px 16px;
  border: 1px solid #e5e7eb; border-radius: 10px;
  background: var(--bg); font-size: 13px; transition: all 0.2s;
}
.topbar-search input:focus {
  outline: none; border-color: var(--primary);
  background: #fff; box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.topbar-search i {
  position: absolute; right: 14px; top: 50%;
  transform: translateY(-50%); color: var(--gray); font-size: 13px;
}

.topbar-actions { display: flex; align-items: center; gap: 16px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  border: none; background: var(--light); color: var(--dark);
  display: flex; align-items: center; justify-content: center;
  position: relative; transition: all 0.2s; cursor: pointer;
}
.icon-btn:hover { background: #e5e7eb; }
.icon-btn .dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; background: var(--danger);
  border-radius: 50%; border: 2px solid #fff;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px 6px 6px; background: var(--light);
  border-radius: 50px; cursor: pointer; transition: all 0.2s;
}
.user-chip:hover { background: #e5e7eb; }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.user-chip .info { line-height: 1.2; }
.user-chip .info strong { font-size: 13px; display: block; }
.user-chip .info small { font-size: 11px; color: var(--gray); }

/* ===== PAGE ===== */
.page { padding: 28px; animation: fadeInUp 0.4s ease; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 800; margin: 0; color: var(--dark); }
.page-header p { color: var(--gray); font-size: 13px; margin: 4px 0 0; }

.btn-primary-custom {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border: none; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.2s; box-shadow: 0 4px 15px rgba(37,99,235,0.3); cursor: pointer;
}
.btn-primary-custom:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37,99,235,0.4); color: #fff;
}
.btn-outline-custom {
  background: #fff; border: 1.5px solid #e5e7eb; color: var(--dark);
  padding: 9px 18px; border-radius: 10px; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.2s; cursor: pointer;
}
.btn-outline-custom:hover { border-color: var(--primary); color: var(--primary); }

/* ===== STAT CARDS ===== */
.stat-card {
  background: #fff; border-radius: 16px; padding: 22px;
  box-shadow: var(--card-shadow); transition: all 0.3s;
  position: relative; overflow: hidden; height: 100%;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--card-shadow-hover); }
.stat-card::before {
  content: ''; position: absolute; top: 0; right: 0;
  width: 4px; height: 100%;
}
.stat-card.c-primary::before { background: var(--primary); }
.stat-card.c-success::before { background: var(--success); }
.stat-card.c-warning::before { background: var(--warning); }
.stat-card.c-danger::before { background: var(--danger); }
.stat-card.c-info::before { background: var(--info); }
.stat-card.c-purple::before { background: var(--purple); }
.stat-card.c-pink::before { background: var(--pink); }

.stat-icon {
  width: 50px; height: 50px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin-bottom: 14px;
}
.stat-icon.bg-primary-soft { background: rgba(37,99,235,0.1); color: var(--primary); }
.stat-icon.bg-success-soft { background: rgba(16,185,129,0.1); color: var(--success); }
.stat-icon.bg-warning-soft { background: rgba(245,158,11,0.1); color: var(--warning); }
.stat-icon.bg-danger-soft { background: rgba(239,68,68,0.1); color: var(--danger); }
.stat-icon.bg-info-soft { background: rgba(6,182,212,0.1); color: var(--info); }
.stat-icon.bg-purple-soft { background: rgba(139,92,246,0.1); color: var(--purple); }
.stat-icon.bg-pink-soft { background: rgba(236,72,153,0.1); color: var(--pink); }

.stat-label { font-size: 12.5px; color: var(--gray); font-weight: 500; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--dark); line-height: 1.2; }
.stat-trend { font-size: 11.5px; margin-top: 8px; display: flex; align-items: center; gap: 5px; }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ===== CARDS ===== */
.card-custom {
  background: #fff; border-radius: 16px;
  box-shadow: var(--card-shadow); border: none; overflow: hidden;
}
.card-custom .card-header-custom {
  padding: 18px 22px; border-bottom: 1px solid #f1f5f9;
  display: flex; align-items: center; justify-content: space-between;
}
.card-custom .card-header-custom h6 {
  margin: 0; font-weight: 700; font-size: 14.5px; color: var(--dark);
  display: flex; align-items: center; gap: 8px;
}
.card-custom .card-body-custom { padding: 22px; }

/* ===== KANBAN ===== */
.kanban-board {
  display: flex; gap: 18px; overflow-x: auto;
  padding-bottom: 20px; min-height: calc(100vh - 260px);
}
.kanban-board::-webkit-scrollbar { height: 8px; }
.kanban-board::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.kanban-column {
  min-width: 300px; max-width: 300px;
  background: #f1f5f9; border-radius: 16px;
  padding: 14px; display: flex; flex-direction: column;
  transition: all 0.2s;
}
.kanban-column.drag-over {
  background: rgba(37,99,235,0.08);
  outline: 2px dashed var(--primary);
}

.kanban-column-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 8px 14px;
}
.kanban-column-header .title {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 13.5px;
}
.kanban-column-header .count {
  background: #fff; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; color: var(--gray);
}
.kanban-column-header .dot-color { width: 10px; height: 10px; border-radius: 50%; }

.kanban-cards {
  flex: 1; overflow-y: auto; min-height: 100px;
  display: flex; flex-direction: column; gap: 10px;
}
.kanban-cards::-webkit-scrollbar { width: 4px; }
.kanban-cards::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.kanban-card {
  background: #fff; border-radius: 12px; padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: grab; transition: all 0.2s;
  border: 1px solid transparent;
}
.kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-color: var(--primary-light);
}
.kanban-card.dragging { opacity: 0.5; cursor: grabbing; }
.kanban-card .company-name { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; color: var(--dark); }
.kanban-card .contact-name {
  font-size: 12px; color: var(--gray); margin-bottom: 10px;
  display: flex; align-items: center; gap: 5px;
}
.kanban-card .card-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 10px; border-top: 1px solid #f1f5f9;
}
.kanban-card .amount { font-size: 12.5px; font-weight: 700; color: var(--success); }
.kanban-card .avatar-sm {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700;
}
.kanban-card .tags { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.kanban-card .tag {
  font-size: 10px; padding: 2px 8px; border-radius: 6px; font-weight: 600;
}
.tag-hot { background: rgba(239,68,68,0.1); color: var(--danger); }
.tag-warm { background: rgba(245,158,11,0.1); color: var(--warning); }
.tag-cold { background: rgba(6,182,212,0.1); color: var(--info); }
.tag-new { background: rgba(139,92,246,0.1); color: var(--purple); }

/* ===== TABLE ===== */
.table-custom { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-custom thead th {
  background: #f8fafc; padding: 12px 16px;
  font-size: 12px; font-weight: 700; color: var(--gray);
  text-align: right; border-bottom: 1px solid #e5e7eb; white-space: nowrap;
}
.table-custom tbody td {
  padding: 14px 16px; font-size: 13px;
  border-bottom: 1px solid #f1f5f9; vertical-align: middle;
}
.table-custom tbody tr { transition: all 0.15s; }
.table-custom tbody tr:hover { background: #f8fafc; }

.badge-soft {
  padding: 4px 10px; border-radius: 8px; font-size: 11px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px;
}
.badge-soft.primary { background: rgba(37,99,235,0.1); color: var(--primary); }
.badge-soft.success { background: rgba(16,185,129,0.1); color: var(--success); }
.badge-soft.warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.badge-soft.danger { background: rgba(239,68,68,0.1); color: var(--danger); }
.badge-soft.info { background: rgba(6,182,212,0.1); color: var(--info); }
.badge-soft.purple { background: rgba(139,92,246,0.1); color: var(--purple); }
.badge-soft.gray { background: #f1f5f9; color: var(--gray); }

/* ===== FUNNEL ===== */
.funnel-stage {
  background: #fff; border-radius: 14px; padding: 18px;
  margin-bottom: 12px; box-shadow: var(--card-shadow);
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden; transition: all 0.2s;
}
.funnel-stage:hover { transform: translateX(-4px); }
.funnel-stage .stage-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.funnel-stage .stage-info { flex: 1; }
.funnel-stage .stage-info h6 { margin: 0 0 4px; font-weight: 700; font-size: 14px; }
.funnel-stage .stage-info small { color: var(--gray); font-size: 12px; }
.funnel-stage .stage-count { font-size: 24px; font-weight: 800; }
.funnel-stage .stage-bar {
  position: absolute; bottom: 0; right: 0;
  height: 4px; transition: width 0.5s;
}

/* ===== CAMPAIGN ===== */
.campaign-card {
  background: #fff; border-radius: 16px; padding: 22px;
  box-shadow: var(--card-shadow); transition: all 0.3s;
  height: 100%; border-right: 4px solid var(--primary);
}
.campaign-card:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-3px); }
.campaign-card .campaign-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px;
}
.campaign-card h6 { font-weight: 700; margin: 0 0 4px; font-size: 15px; }
.campaign-card .campaign-meta { font-size: 12px; color: var(--gray); }
.campaign-stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 10px; margin: 16px 0; padding: 14px;
  background: #f8fafc; border-radius: 12px;
}
.campaign-stats .cs-item { text-align: center; }
.campaign-stats .cs-item .val { font-size: 18px; font-weight: 800; color: var(--dark); }
.campaign-stats .cs-item .lbl { font-size: 11px; color: var(--gray); }

/* ===== TIMELINE ===== */
.timeline { position: relative; padding-right: 30px; }
.timeline::before {
  content: ''; position: absolute; right: 10px;
  top: 0; bottom: 0; width: 2px; background: #e5e7eb;
}
.timeline-item { position: relative; margin-bottom: 24px; }
.timeline-item::before {
  content: ''; position: absolute; right: -25px; top: 4px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--primary); border: 3px solid #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.timeline-item.success::before { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }
.timeline-item.warning::before { background: var(--warning); box-shadow: 0 0 0 3px rgba(245,158,11,0.15); }
.timeline-item.danger::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,0.15); }
.timeline-item .tl-time { font-size: 11px; color: var(--gray); margin-bottom: 4px; }
.timeline-item .tl-title { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; }
.timeline-item .tl-desc { font-size: 12.5px; color: var(--gray); line-height: 1.6; }

/* ===== CONTRACT ===== */
.contract-card {
  background: #fff; border-radius: 16px; padding: 20px;
  box-shadow: var(--card-shadow); margin-bottom: 16px;
  border-right: 4px solid var(--success);
}
.contract-card .contract-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 14px; padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
}
.contract-card h6 { font-weight: 700; margin: 0; font-size: 15px; }
.contract-details {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}
.contract-details .cd-item .cd-lbl { font-size: 11px; color: var(--gray); margin-bottom: 4px; }
.contract-details .cd-item .cd-val { font-size: 13.5px; font-weight: 700; }

/* ===== MODAL ===== */
.modal-content { border-radius: 18px; border: none; }
.modal-header { border-bottom: 1px solid #f1f5f9; padding: 20px 24px; }
.modal-header h5 { font-weight: 800; font-size: 17px; }
.modal-body { padding: 24px; }
.modal-footer { border-top: 1px solid #f1f5f9; padding: 16px 24px; }
.form-label { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--dark); }
.form-control, .form-select {
  border-radius: 10px; border: 1.5px solid #e5e7eb;
  padding: 9px 14px; font-size: 13px; transition: all 0.2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ===== CHART ===== */
.chart-placeholder {
  height: 260px;
  background: linear-gradient(135deg, #f8fafc, #f1f5f9);
  border-radius: 12px; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--gray); position: relative; overflow: hidden;
}
.chart-bars {
  display: flex; align-items: flex-end; gap: 12px;
  height: 160px; margin-top: 20px;
}
.chart-bar {
  width: 32px; border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--primary-light), var(--primary));
  transition: all 0.3s; position: relative;
}
.chart-bar:hover { transform: scaleY(1.05); }
.chart-bar::after {
  content: attr(data-value); position: absolute;
  top: -22px; left: 50%; transform: translateX(-50%);
  font-size: 10px; font-weight: 700; color: var(--dark); white-space: nowrap;
}

/* ===== ACTIVITY ===== */
.activity-item {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid #f8fafc;
}
.activity-item:last-child { border-bottom: none; }
.activity-item .act-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.activity-item .act-content { flex: 1; }
.activity-item .act-content .act-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.activity-item .act-content .act-time { font-size: 11px; color: var(--gray); }

/* ===== PROGRESS ===== */
.progress-custom {
  height: 8px; background: #f1f5f9;
  border-radius: 10px; overflow: hidden;
}
.progress-custom .bar {
  height: 100%; border-radius: 10px;
  background: linear-gradient(90deg, var(--primary), var(--purple));
  transition: width 0.5s;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; }
  .topbar-search { width: 200px; }
}
@media (max-width: 576px) {
  .page { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .topbar-search { display: none; }
}

.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 999;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }