:root {
  --sidebar-bg: #14080b;
  --sidebar-hover: #3a1218;
  --sidebar-active: #a52933;
  --accent: #f5c400;
  --page-bg: #f4eef0;
  --text: #1e1416;
  --muted: #7a5c62;
  --card-border: #ecd6da;
  --primary: #a52933;
  --primary-bright: #ff4b4e;
  --wine: #5d2333;
  --shadow: 0 10px 24px rgba(93, 35, 51, 0.12);
  --shadow-gold: 0 8px 20px rgba(245, 196, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page-bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

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

.sidebar,
.sidebar-offcanvas {
  width: 250px;
  background-color: var(--sidebar-bg);
  background-image:
    linear-gradient(180deg, rgba(20, 8, 11, 0.9), rgba(93, 35, 51, 0.78)),
    url("../img/am-crm-login-bg.png");
  background-size: cover;
  background-position: center;
  color: #f3dfe2;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.9rem;
  box-shadow: 10px 0 28px rgba(20, 8, 11, 0.38);
}

.sidebar-offcanvas {
  width: 260px;
}

.sidebar-brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0 0.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 196, 196, 0.12);
  margin-bottom: 1rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #1a1403;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(245, 196, 0, 0.4);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  box-shadow: 0 6px 14px rgba(245, 196, 0, 0.45);
}

.brand-title {
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: #e7b4ba;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.sidebar-nav .nav-link {
  color: #f3dfe2;
  border-radius: 8px;
  padding: 0.65rem 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 196, 196, 0.12);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  color: #f3dfe2;
}

.btn-logout {
  background: transparent;
  color: #f3dfe2;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18);
}

.btn-logout:hover {
  background: var(--primary);
  color: #fff;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--page-bg);
  background-image: url("../img/chart-pattern.svg");
  background-size: 420px 245px;
  background-repeat: repeat;
}

.topbar {
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 2px solid var(--primary);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 10px 24px rgba(93, 35, 51, 0.08);
}

.topbar-title {
  font-size: 1.25rem;
  margin: 0;
}

.topbar-subtitle {
  color: var(--muted);
  font-size: 0.875rem;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.app-content {
  padding: 1.5rem;
}

.crm-card {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: rgba(255, 255, 255, 0.96);
}

.crm-card .card-header {
  background: linear-gradient(180deg, #fff, #fbf4f5);
  border-bottom: 1px solid var(--card-border);
}

.btn {
  box-shadow: 0 6px 14px rgba(93, 35, 51, 0.12);
}

.btn-primary {
  background: linear-gradient(180deg, #c43a44, var(--primary));
  border-color: var(--primary);
  box-shadow: 0 8px 18px rgba(165, 41, 51, 0.38), 0 1px 0 rgba(245, 196, 0, 0.45);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #a52933, #7d1d26);
  border-color: #7d1d26;
  box-shadow: 0 12px 24px rgba(165, 41, 51, 0.45);
  transform: translateY(-1px);
}

.btn-outline-primary {
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-danger,
.btn-outline-dark {
  background: #fff;
  box-shadow: 0 6px 14px rgba(93, 35, 51, 0.1);
}

.btn-outline-primary:hover,
.btn-outline-secondary:hover,
.btn-outline-success:hover,
.btn-outline-danger:hover {
  box-shadow: 0 10px 20px rgba(93, 35, 51, 0.16);
  transform: translateY(-1px);
}

.stat-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  gap: 0.85rem;
  align-items: center;
  height: 100%;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--primary);
}

.stat-card-navy .stat-icon,
.stat-card-red .stat-icon { background: var(--primary); }
.stat-card-blue .stat-icon { background: #c43a44; }
.stat-card-gold .stat-icon { background: var(--accent); color: #1a1403; }
.stat-card-amber .stat-icon { background: #d97706; }
.stat-card-teal .stat-icon { background: #8b1e28; }
.stat-card-green .stat-icon { background: #15803d; }

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.table thead th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #fbf4f5;
}

.table thead th a {
  color: var(--primary);
  text-decoration: none;
}

.badge-status-new { background: #c43a44; }
.badge-status-contacted { background: #a52933; }
.badge-status-interested { background: #d97706; }
.badge-status-registered { background: #7c3aed; }
.badge-status-kyc_pending { background: #d97706; }
.badge-status-kyc_completed { background: #c2410c; }
.badge-status-deposited { background: #8b1e28; }
.badge-status-active { background: #15803d; }
.badge-status-inactive { background: #64748b; }
.badge-status-lost { background: #7d1d26; }

.badge-priority-low { background: #64748b; }
.badge-priority-medium { background: #d97706; }
.badge-priority-high { background: #b91c1c; }

.badge-task-pending { background: var(--primary); }
.badge-task-completed { background: #15803d; }
.badge-task-cancelled { background: #64748b; }

.badge {
  color: #fff;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}

.empty-state i {
  font-size: 2rem;
  color: var(--accent);
  display: block;
  margin-bottom: 0.75rem;
}

.empty-state-compact {
  padding: 1rem 0;
}

.empty-state-page {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 12px;
}

.info-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid #ecd6da;
}

.timeline-item {
  padding: 0 0 1.25rem 1rem;
  position: relative;
}

.timeline-item::before {
  content: "";
  width: 10px;
  height: 10px;
  background: var(--accent);
  border-radius: 50%;
  position: absolute;
  left: -6px;
  top: 0.35rem;
}

.timeline-date {
  font-size: 0.8rem;
  color: var(--muted);
}

.timeline-type {
  font-weight: 700;
  margin: 0.15rem 0;
}

.timeline-text {
  color: #4a2a30;
}

.timeline-user {
  font-size: 0.75rem;
  color: var(--muted);
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #0a0406;
  background-image:
    linear-gradient(160deg, rgba(10, 4, 6, 0.62), rgba(93, 35, 51, 0.42)),
    url("../img/am-crm-login-bg.png");
  background-size: cover;
  background-position: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 16px;
  padding: 2rem;
  border: 1px solid rgba(165, 41, 51, 0.28);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.login-brand .brand-logo {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  margin: 0 auto;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-brand h1 {
  margin: 0.75rem 0 0.4rem;
  font-size: 1.5rem;
}

.login-brand p {
  color: var(--muted);
  font-size: 0.9rem;
}

.login-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.login-inline-link,
.login-switch a {
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.login-inline-link:hover,
.login-switch a:hover {
  color: #7d1d26;
  text-decoration: underline;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.15rem 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #ecd6da;
}

.login-switch {
  margin: 1.1rem 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.stat-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  height: 100%;
}

.stat-card-link:hover .stat-card {
  border-color: var(--primary);
}

.row-overdue {
  background: #fff7ed;
}

.badge-activity-call { background: #c43a44; }
.badge-activity-email { background: #8b1e28; }
.badge-activity-telegram { background: #0284c7; }
.badge-activity-whatsapp { background: #15803d; }
.badge-activity-note { background: #64748b; }
.badge-activity-status_change { background: #7c3aed; }
.badge-activity-follow_up { background: #d97706; }

.copy-toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  background: #15803d;
  color: #fff;
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  z-index: 20;
}

.badge-activity-facebook_outbound { background: #1877f2; }

.badge-fb-new { background: #64748b; }
.badge-fb-ready { background: #2563eb; }
.badge-fb-contacted { background: #0ea5e9; }
.badge-fb-replied { background: #0891b2; }
.badge-fb-interested { background: #15803d; }
.badge-fb-not_interested { background: #b91c1c; }
.badge-fb-follow_up { background: #d97706; }
.badge-fb-converted { background: #0f766e; }
.badge-fb-do_not_contact { background: #111827; }

.list-group-item.active {
  background: var(--primary);
  border-color: var(--primary);
}

.badge-desk-call { background: #b91c1c; }
.badge-desk-followup { background: #d97706; }
.badge-desk-next_step { background: #0f766e; }
.badge-desk-quiet { background: #64748b; }

.desk-talk {
  max-width: 28rem;
  font-size: 0.92rem;
}

.badge-score-cold { background: #64748b; }
.badge-score-warm { background: #d97706; }
.badge-score-hot { background: #b91c1c; }

.note-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.note-item {
  background: #fbf4f5;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
}

.note-text {
  white-space: pre-wrap;
  margin-bottom: 0.35rem;
}

.pipeline-board {
  display: flex;
  gap: 0.85rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  align-items: flex-start;
}

.pipeline-column {
  min-width: 220px;
  width: 220px;
  background: #f6eef0;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 220px);
}

.pipeline-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--card-border);
  background: #fff;
  border-radius: 12px 12px 0 0;
}

.pipeline-column-body {
  padding: 0.65rem;
  overflow-y: auto;
  min-height: 120px;
  flex: 1;
}

.pipeline-column-body.is-drop-target {
  background: #f8dfe3;
}

.pipeline-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.65rem;
  cursor: grab;
  box-shadow: 0 8px 18px rgba(93, 35, 51, 0.1);
}

.pipeline-card.is-dragging {
  opacity: 0.55;
}

.pipeline-empty {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1.25rem 0.5rem;
}

.progress {
  height: 0.45rem;
  background: #ecd6da;
}

.progress-bar {
  background: linear-gradient(90deg, var(--primary-bright), var(--primary));
}

.chart-panel {
  position: relative;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 0.65rem;
  height: 220px;
  padding: 0.5rem 0.25rem 0;
  border-bottom: 2px solid var(--primary);
}

.chart-bar-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
}

.chart-bar {
  width: 100%;
  max-width: 42px;
  min-height: 6px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--primary-bright), var(--primary));
  box-shadow: 0 8px 16px rgba(165, 41, 51, 0.28);
}

.chart-bar-value {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
}

.chart-bar-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
}

.mini-bar {
  display: inline-block;
  height: 0.45rem;
  min-width: 0.45rem;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary-bright), var(--primary));
  vertical-align: middle;
  margin-right: 0.4rem;
}

.candle-strip {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 72px;
  padding: 0.25rem 0;
}

.candle {
  width: 8px;
  border-radius: 1px;
  background: var(--accent);
  position: relative;
  box-shadow: 0 0 0 1px rgba(165, 41, 51, 0.12);
}

.candle::before {
  content: "";
  position: absolute;
  left: 3px;
  width: 2px;
  background: var(--accent);
  top: -10px;
  bottom: -10px;
}

.sync-hint {
  background: #fff8e1;
  border: 1px solid #f0d56a;
  border-radius: 12px;
}

@media (max-width: 991px) {
  .topbar {
    flex-wrap: wrap;
  }

  .topbar-actions {
    width: 100%;
    margin-left: 0;
  }

  .app-content {
    padding: 1rem;
  }

  .table {
    font-size: 0.92rem;
  }

  .pipeline-column {
    max-height: none;
  }

  .chart-bars {
    overflow-x: auto;
  }

  .chart-bar-col {
    min-width: 52px;
  }
}
