/* Lead Management CRM — layout and small overrides on top of Bootstrap 5 */

:root {
  --accent: #0f766e;          /* single accent colour */
  --accent-dark: #0b5c55;
  --sidebar-bg: #14202b;
  --sidebar-text: #a9b6c3;
  --page-bg: #f4f6f8;
  --line: #e3e8ee;
}

body {
  background: var(--page-bg);
  color: #1f2933;
  font-size: 0.94rem;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

/* ---------------------------------------------------------------- layout */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 0 0 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  color: #fff; font-weight: 600; font-size: 1.02rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand i { font-size: 1.3rem; color: #4ecdc0; }

.sidebar .nav-heading {
  padding: 16px 18px 6px;
  font-size: .7rem; letter-spacing: .08em;
  color: #61748a;
}

.sidebar .nav-link {
  color: var(--sidebar-text);
  padding: 9px 18px;
  display: flex; align-items: center; gap: 10px;
  border-left: 3px solid transparent;
}
.sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar .nav-link.active {
  color: #fff; background: rgba(78,205,192,.12);
  border-left-color: #4ecdc0;
}
.sidebar .nav-link i { width: 18px; text-align: center; }

.content-area { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 10px 18px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-search { position: relative; flex: 1 1 auto; max-width: 460px; }
.topbar-search i { position: absolute; left: 12px; top: 9px; color: #8a97a6; }
.topbar-search input { padding-left: 34px; background: var(--page-bg); border-color: var(--line); }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .82rem; font-weight: 600;
}

.notif-dot {
  position: absolute; top: 1px; right: 1px;
  background: #dc3545; color: #fff;
  border-radius: 10px; padding: 0 5px;
  font-size: .64rem; line-height: 15px;
}
.notif-menu { width: 320px; max-width: 92vw; }

.page { padding: 20px; flex: 1 1 auto; }
.page-footer { padding: 14px 20px; color: #7b8794; font-size: .82rem; border-top: 1px solid var(--line); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 1.35rem; margin: 0; font-weight: 600; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- cards */

.card { border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 600; }

.stat { padding: 14px 16px; }
.stat .label { color: #7b8794; font-size: .78rem; margin-bottom: 4px; }
.stat .value { font-size: 1.35rem; font-weight: 600; line-height: 1.2; }
.stat .sub { font-size: .76rem; color: #7b8794; margin-top: 2px; }
.stat i { font-size: 1.1rem; color: var(--accent); }

.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover, .btn-primary:focus { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-outline-primary { color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover { background: var(--accent); border-color: var(--accent); }
.text-accent { color: var(--accent); }

.table { font-size: .88rem; }
.table > :not(caption) > * > * { padding: .6rem .65rem; }
.table thead th { color: #64748b; font-weight: 600; font-size: .76rem; letter-spacing: .02em; background: #fbfcfd; }
.table-wrap { overflow-x: auto; }

.badge { font-weight: 500; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.filters .form-control, .filters .form-select { min-width: 140px; }

.form-label { font-size: .82rem; font-weight: 500; color: #48505a; margin-bottom: .25rem; }
.form-section { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 14px; }
.form-section:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.form-section h6 { font-weight: 600; margin-bottom: 12px; }
.required::after { content: " *"; color: #dc3545; }

.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 16px 16px; }
.timeline li::before {
  content: ""; position: absolute; left: -25px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid #fff;
}
.timeline .when { font-size: .76rem; color: #7b8794; }

  white-space: pre-wrap; line-height: 1.5; }
.chat-msg.user { margin-left: auto; background: var(--accent); color: #fff; }
.chat-msg.bot { background: #eef2f5; }
.chat-msg.bot.error { background: #fdecec; color: #8f2020; }

.sidebar-backdrop { display: none; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed; z-index: 1045; left: -260px; transition: left .2s ease;
  }
  .sidebar.open { left: 0; }
  .sidebar-backdrop.show {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1040;
  }
  .page { padding: 14px; }
  .card-body { padding: 14px; }
}

@media (max-width: 575.98px) {
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
}

/* ------------------------------------------------------------------ print */

@media print {
  .sidebar, .topbar, .page-footer, .no-print, .btn { display: none !important; }
  .page { padding: 0; }
  .card { border: 0; box-shadow: none; }
  body { background: #fff; }
}

/* ------------------------------------------------------- lead tables */

.sort-link { color: inherit; text-decoration: none; white-space: nowrap; }
.sort-link:hover { color: var(--accent); }

.table-compact td, .table-compact th { padding: .5rem .6rem; vertical-align: middle; }
.table-compact tbody tr:hover { background: #f8fafb; }

.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #eef7f6; border: 1px solid #cbe6e2; border-radius: .5rem;
  padding: 10px 14px; margin-bottom: 12px;
}
.bulk-bar .count { font-weight: 600; color: var(--accent-dark); }

.muted-cell { color: #7b8794; font-size: .84rem; }

.lead-head-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .84rem; color: #64748b; }

.note-box {
  background: #fffdf2; border: 1px solid #f0e6c8; border-radius: .5rem;
  padding: 10px 12px; white-space: pre-wrap;
}

.activity-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-icon {
  flex: 0 0 30px; height: 30px; width: 30px; border-radius: 50%;
  background: #eef2f5; color: #52606d;
  display: flex; align-items: center; justify-content: center; font-size: .85rem;
}
.activity-body { flex: 1 1 auto; min-width: 0; }
.activity-body .when { font-size: .75rem; color: #7b8794; }

/* ------------------------------------------------------------ import */

.import-steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.import-steps .step {
  padding: 6px 12px; border-radius: 999px; background: #eef2f5;
  color: #52606d; font-size: .82rem;
}
.import-steps .step.current { background: var(--accent); color: #fff; }
.import-steps .step.done { background: #d7efec; color: var(--accent-dark); }

.drop-zone {
  border: 2px dashed #c6d2dd; border-radius: .6rem; padding: 28px; text-align: center;
  background: #fbfdfe;
}
.drop-zone.dragover { border-color: var(--accent); background: #eef7f6; }

.busy-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,.75);
  display: none; align-items: center; justify-content: center; z-index: 1080;
}
.busy-overlay.show { display: flex; }

/* ------------------------------------------------------------- login */

.login-page { background: var(--sidebar-bg); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; border: 0; box-shadow: 0 18px 40px rgba(0,0,0,.28); }
