/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --primary:       #1B3A6B;
  --primary-hover: #152d54;
  --primary-light: #EBF0FB;
  --accent:        #C9A84C;
  --accent-hover:  #b8952f;
  --success:       #16A34A;
  --danger:        #DC2626;
  --warning:       #D97706;
  --info:          #0891B2;
  --sidebar-bg:    #0F2445;
  --sidebar-w:     260px;
  --topbar-h:      60px;
  --bg:            #F1F5F9;
  --card:          #FFFFFF;
  --text:          #1E293B;
  --muted:         #64748B;
  --border:        #E2E8F0;
  --radius:        10px;
  --shadow:        0 1px 4px rgba(0,0,0,.08);
}

/* ── Reset / Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: .9rem;
  line-height: 1.6;
  margin: 0;
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-logo {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: #fff;
  flex-shrink: 0;
}
.brand-name { display: block; color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.2; }
.brand-sub  { display: block; color: rgba(255,255,255,.45); font-size: .72rem; }

.sidebar-nav { padding: 12px 12px; flex: 1; }
.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: rgba(255,255,255,.3);
  padding: 8px 8px 4px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-item i { font-size: 1rem; flex-shrink: 0; }
.nav-item span { flex: 1; }
.nav-badge {
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: .7rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.user-name { display: block; color: #fff; font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; color: rgba(255,255,255,.45); font-size: .7rem; }
.btn-logout { color: rgba(255,255,255,.4); font-size: 1.1rem; text-decoration: none; transition: color .15s; }
.btn-logout:hover { color: var(--danger); }

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-search {
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  width: 280px;
}
.topbar-search i { color: var(--muted); font-size: .9rem; }
.topbar-search input { border: none; background: transparent; outline: none; font-size: .875rem; color: var(--text); width: 100%; }
.sidebar-toggle { background: none; border: none; font-size: 1.4rem; color: var(--text); padding: 4px 8px; }
.topbar-user-btn {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 10px; display: flex; align-items: center; gap: 8px;
  font-size: .875rem; cursor: pointer; color: var(--text);
}
.topbar-user-btn:hover { background: var(--bg); }

/* ── Avatar ────────────────────────────────────────────────────────────────── */
.user-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
}
.user-avatar.sm { width: 28px; height: 28px; font-size: .65rem; }
.user-avatar.lg { width: 56px; height: 56px; font-size: 1.2rem; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }

/* ── Stat Cards ────────────────────────────────────────────────────────────── */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: #DCFCE7; color: var(--success); }
.stat-icon.warning { background: #FEF3C7; color: var(--warning); }
.stat-icon.info    { background: #E0F7FA; color: var(--info); }
.stat-icon.accent  { background: #FEF9EC; color: var(--accent); }

.stat-label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-change { font-size: .75rem; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Tables ────────────────────────────────────────────────────────────────── */
.table { font-size: .875rem; }
.table thead th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}
.table tbody td { padding: 12px 12px; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg); }

/* ── Pipeline Kanban ───────────────────────────────────────────────────────── */
.pipeline-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding: 4px 0 16px;
  min-height: calc(100vh - 160px);
}
.pipeline-column {
  flex-shrink: 0;
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.column-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: .85rem;
}
.column-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.column-count {
  margin-left: auto;
  background: var(--bg);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}
.column-cards {
  flex: 1;
  background: rgba(0,0,0,.02);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px;
  min-height: 100px;
}
.column-cards.drag-over { background: var(--primary-light); border-color: var(--primary); }

.lead-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  cursor: grab;
  transition: box-shadow .15s, transform .15s;
  margin-bottom: 8px;
}
.lead-card:last-child { margin-bottom: 0; }
.lead-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); transform: translateY(-1px); }
.lead-card.dragging { opacity: .5; transform: rotate(2deg); }
.lead-card-name { font-weight: 600; font-size: .875rem; }
.lead-card-email { font-size: .78rem; color: var(--muted); }
.lead-card-actions { display: flex; gap: 6px; margin-top: 10px; }
.lead-card-actions a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  text-decoration: none; font-size: .8rem;
  transition: all .15s;
}
.lead-card-actions a:hover { background: var(--primary); color: #fff; }
.stage-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: .825rem; color: var(--text); margin-bottom: 5px; }
.form-control, .form-select {
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .875rem;
  padding: 8px 12px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,58,107,.1);
  outline: none;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn { border-radius: 8px; font-size: .875rem; font-weight: 600; padding: 8px 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-icon { padding: 7px 10px; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge-stage {
  font-size: .72rem; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
}

/* ── Page Header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-title { font-size: 1.35rem; font-weight: 700; color: var(--text); margin: 0; }
.page-subtitle { font-size: .825rem; color: var(--muted); margin: 0; }

/* ── Email Compose ─────────────────────────────────────────────────────────── */
.compose-wrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
  overflow: hidden;
}
.compose-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.compose-field {
  display: flex;
  align-items: flex-start;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.compose-field label { font-size: .8rem; color: var(--muted); font-weight: 600; min-width: 60px; padding-top: 2px; }
.compose-field input, .compose-field select {
  border: none; outline: none;
  font-size: .875rem; flex: 1;
  background: transparent;
  color: var(--text);
}
.compose-body { padding: 16px; min-height: 320px; }

/* ── Email Builder ─────────────────────────────────────────────────────────── */
.builder-wrap { display: flex; gap: 0; height: calc(100vh - 120px); }
.builder-blocks-panel {
  width: 220px; flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}
.builder-canvas {
  flex: 1; overflow-y: auto;
  background: var(--bg);
  padding: 20px;
  display: flex; justify-content: center;
}
.builder-props-panel {
  width: 260px; flex-shrink: 0;
  background: #fff;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
}
.block-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 12px; margin-bottom: 6px;
  border: 1px dashed var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-size: .825rem; font-weight: 600;
  cursor: pointer; text-align: left; transition: all .15s;
}
.block-btn:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.email-canvas {
  width: 600px; background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  min-height: 500px;
  overflow: hidden;
}
.email-block {
  position: relative;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s;
}
.email-block:hover, .email-block.selected { border-color: var(--primary); }
.email-block .block-actions {
  position: absolute; top: 4px; right: 4px;
  display: none; gap: 4px; z-index: 10;
}
.email-block:hover .block-actions,
.email-block.selected .block-actions { display: flex; }
.block-action-btn {
  width: 24px; height: 24px;
  background: var(--primary); color: #fff;
  border: none; border-radius: 4px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
}
.block-action-btn.danger { background: var(--danger); }

/* ── Activity Timeline ─────────────────────────────────────────────────────── */
.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: ''; position: absolute; left: 6px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-dot {
  position: absolute; left: -17px; top: 3px;
  width: 12px; height: 12px;
  background: #fff; border: 2px solid var(--primary);
  border-radius: 50%;
}
.timeline-time { font-size: .72rem; color: var(--muted); }
.timeline-text { font-size: .83rem; }

/* ── Campaign Steps ────────────────────────────────────────────────────────── */
.step-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; margin-bottom: 12px; position: relative;
}
.step-number {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; flex-shrink: 0;
}
.step-connector {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 0; color: var(--muted); font-size: .78rem;
}
.step-connector i { color: var(--border); font-size: 1.4rem; }

/* ── Misc ──────────────────────────────────────────────────────────────────── */
.search-bar { position: relative; }
.search-bar i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-bar input { padding-left: 36px; }
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 600;
  background: var(--primary-light); color: var(--primary);
}
.verified-badge { color: var(--success); font-size: .8rem; }
.unverified-badge { color: var(--muted); font-size: .8rem; }
.page-content { padding: 24px; flex: 1; }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); transition: transform .3s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

/* ── Login Page ────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary) 0%, #2563EB 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px;
  padding: 40px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.login-logo {
  width: 56px; height: 56px;
  background: var(--primary); border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800; color: #fff;
  margin: 0 auto 20px;
}

/* ── Quill override ────────────────────────────────────────────────────────── */
.ql-container { font-family: inherit; font-size: .875rem; border: none !important; }
.ql-toolbar { border: 1px solid var(--border) !important; border-radius: 8px 8px 0 0; }
.ql-container.ql-snow { border: 1px solid var(--border) !important; border-top: none !important; border-radius: 0 0 8px 8px; }
