:root {
  --bg: #edf3fb;
  --bg-deep: #0d1f4a;
  --card: rgba(255, 255, 255, 0.94);
  --card-strong: #ffffff;
  --line: rgba(20, 54, 118, 0.12);
  --text: #102449;
  --muted: #6178a4;
  --brand: #1f5eff;
  --brand-deep: #163a9a;
  --brand-soft: rgba(31, 94, 255, 0.1);
  --cyan: #6ad7ff;
  --cyan-soft: rgba(106, 215, 255, 0.18);
  --green: #0f9a73;
  --amber: #c57d18;
  --danger: #c73636;
  --shadow: 0 24px 60px rgba(15, 34, 84, 0.14);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Be Vietnam Pro", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(106, 215, 255, 0.35), transparent 24%),
    radial-gradient(circle at right 20%, rgba(31, 94, 255, 0.22), transparent 20%),
    linear-gradient(180deg, #f5f8fe 0%, #e3ecf8 100%);
}

a {
  text-decoration: none;
}

.crm-loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand-deep);
}

.crm-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 28px;
  min-height: 100vh;
  padding: 22px;
}

.crm-sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 22px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(7, 20, 56, 0.97) 0%, rgba(13, 31, 74, 0.94) 58%, rgba(31, 94, 255, 0.9) 100%);
  color: #ffffff;
  box-shadow: 0 28px 70px rgba(9, 18, 46, 0.3);
  position: sticky;
  top: 22px;
  height: calc(100vh - 44px);
}

.crm-brand {
  display: grid;
  gap: 14px;
}

.crm-logo {
  width: 188px;
  max-width: 100%;
  border-radius: 22px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.26);
}

.crm-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  font-weight: 700;
  color: #7fdcff;
}

.crm-brand h1,
.crm-topbar h2,
.crm-hero h3,
.crm-card h4 {
  margin: 0;
}

.crm-brand h1 {
  font-size: 1.8rem;
  font-weight: 800;
}

.crm-copy {
  margin: 0;
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.65;
}

.crm-nav {
  display: grid;
  gap: 8px;
  margin-top: 24px;
}

.crm-nav .nav-link {
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 13px 14px;
  color: rgba(255, 255, 255, 0.84);
  text-align: left;
  font-weight: 600;
  transition: 0.2s ease;
}

.crm-nav .nav-link:hover,
.crm-nav .nav-link.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateX(4px);
}

.crm-sidecard {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.crm-sidecard span {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.62);
}

.crm-sidecard strong {
  display: block;
  margin-top: 6px;
  font-size: 0.98rem;
}

.crm-content {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.crm-topbar,
.crm-hero,
.crm-card {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
}

.crm-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 24px 28px;
  border-radius: var(--radius-xl);
}

.crm-top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.crm-user {
  padding: 10px 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(31, 94, 255, 0.12), rgba(106, 215, 255, 0.18));
  border: 1px solid rgba(31, 94, 255, 0.14);
  min-width: 210px;
}

.crm-user strong,
.crm-user span {
  display: block;
}

.crm-user span {
  color: var(--muted);
  font-size: 0.86rem;
}

.crm-hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  padding: 28px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(120deg, rgba(19, 58, 154, 0.98), rgba(31, 94, 255, 0.96) 55%, rgba(106, 215, 255, 0.92));
  color: #ffffff;
}

.crm-hero p {
  max-width: 840px;
  margin-top: 12px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.84);
}

.crm-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.crm-badges span {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.88rem;
  font-weight: 600;
}

.crm-section {
  display: none;
}

.crm-section.active {
  display: block;
}

.crm-card {
  padding: 24px;
  border-radius: var(--radius-xl);
}

.crm-card + .crm-card {
  margin-top: 20px;
}

.crm-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.crm-card-head h4 {
  font-size: 1.18rem;
  font-weight: 800;
}

.crm-empty {
  padding: 26px;
  border: 1px dashed rgba(22, 58, 154, 0.25);
  border-radius: 20px;
  color: var(--muted);
  background: rgba(31, 94, 255, 0.04);
}

.crm-kpi {
  height: 100%;
  padding: 22px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(242, 247, 255, 0.9));
  box-shadow: var(--shadow);
}

.crm-kpi p {
  margin: 0;
  color: var(--muted);
}

.crm-kpi strong {
  display: block;
  margin-top: 12px;
  font-size: 2rem;
  font-weight: 800;
}

.crm-kpi small {
  display: inline-block;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-deep);
}

.crm-funnel {
  display: grid;
  gap: 12px;
}

.funnel-row {
  display: grid;
  grid-template-columns: 160px 1fr 90px;
  gap: 16px;
  align-items: center;
}

.funnel-row span,
.funnel-row strong {
  font-weight: 700;
}

.funnel-track {
  overflow: hidden;
  height: 14px;
  border-radius: 999px;
  background: rgba(19, 58, 154, 0.08);
}

.funnel-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-deep), var(--cyan));
}

.crm-stack {
  display: grid;
  gap: 12px;
}

.alert-card,
.timeline-card,
.detail-metric,
.customer360-grid article,
.detail-panel,
.rule-card {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
}

.alert-card {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.alert-card strong,
.timeline-card strong,
.detail-panel strong {
  display: block;
  margin-bottom: 6px;
}

.alert-card span,
.timeline-card span,
.detail-panel span,
.meta-list span,
.meta-list strong {
  color: var(--muted);
}

.customer360-grid,
.detail-grid,
.meta-list {
  display: grid;
  gap: 12px;
}

.customer360-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 16px;
}

.customer360-grid article strong {
  display: block;
  font-size: 1.35rem;
  color: var(--brand-deep);
}

.detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.meta-list {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.meta-list div {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(31, 94, 255, 0.05);
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(8, minmax(240px, 1fr));
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.pipeline-column {
  min-height: 520px;
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(244, 248, 255, 0.98), rgba(233, 240, 252, 0.95));
  border: 1px solid var(--line);
}

.pipeline-column.drag-over {
  border-color: rgba(31, 94, 255, 0.55);
  box-shadow: inset 0 0 0 2px rgba(31, 94, 255, 0.1);
}

.pipeline-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.pipeline-head h5 {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
}

.pipeline-count {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--card-strong);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}

.pipeline-list {
  display: grid;
  gap: 12px;
}

.pipeline-card {
  padding: 16px;
  border-radius: 18px;
  background: var(--card-strong);
  border: 1px solid rgba(22, 58, 154, 0.1);
  box-shadow: 0 18px 36px rgba(15, 34, 84, 0.08);
  cursor: grab;
}

.pipeline-card h6 {
  margin: 0 0 10px;
  font-size: 0.98rem;
  font-weight: 800;
}

.pipeline-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.pipeline-meta,
.pipeline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pipeline-meta span,
.status-chip,
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.pipeline-meta span,
.tag-chip {
  background: rgba(31, 94, 255, 0.07);
  color: var(--brand-deep);
}

.pipeline-actions {
  margin-top: 12px;
}

.status-chip {
  border: 1px solid transparent;
}

.status-raw,
.status-new {
  background: rgba(31, 94, 255, 0.1);
  color: var(--brand-deep);
}

.status-qualified,
.status-won,
.status-paid,
.status-done,
.status-signed,
.status-active,
.status-running {
  background: rgba(15, 154, 115, 0.12);
  color: var(--green);
}

.status-rejected,
.status-lost,
.status-overdue,
.status-paused,
.status-cancelled {
  background: rgba(199, 54, 54, 0.12);
  color: var(--danger);
}

.status-contacted,
.status-demo,
.status-quoted,
.status-pending {
  background: rgba(197, 125, 24, 0.12);
  color: var(--amber);
}

.table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: rgba(31, 94, 255, 0.03);
  margin-bottom: 0;
}

.table thead th {
  border-bottom-color: rgba(20, 54, 118, 0.15);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.table tbody td {
  border-bottom-color: rgba(20, 54, 118, 0.08);
  vertical-align: middle;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-actions .btn,
.pipeline-actions .btn {
  --bs-btn-padding-y: 0.35rem;
  --bs-btn-padding-x: 0.7rem;
  --bs-btn-font-size: 0.82rem;
  border-radius: 999px;
}

.timeline-card {
  position: relative;
  padding-left: 20px;
}

.timeline-card::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 18px;
  bottom: -12px;
  width: 2px;
  background: rgba(31, 94, 255, 0.16);
}

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

.timeline-card::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 18px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--cyan));
  box-shadow: 0 0 0 4px rgba(31, 94, 255, 0.1);
}

.rule-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.rule-card p {
  margin: 0;
  color: var(--muted);
}

.section-note {
  margin-top: 12px;
  color: var(--muted);
}

@media (max-width: 1400px) {
  .crm-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}

@media (max-width: 1180px) {
  .crm-shell {
    grid-template-columns: 1fr;
  }

  .crm-sidebar {
    position: static;
    height: auto;
  }

  .pipeline-board {
    grid-template-columns: repeat(4, minmax(240px, 1fr));
  }
}

@media (max-width: 900px) {
  .crm-shell {
    padding: 14px;
    gap: 16px;
  }

  .crm-topbar,
  .crm-hero,
  .crm-card {
    padding: 18px;
  }

  .crm-topbar,
  .crm-hero {
    flex-direction: column;
    align-items: stretch;
  }

  .crm-top-actions {
    justify-content: stretch;
  }

  .crm-top-actions > * {
    flex: 1 1 auto;
  }

  .pipeline-board {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }

  .funnel-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .crm-shell {
    padding: 10px;
  }

  .crm-sidebar {
    padding: 20px 16px;
  }

  .crm-brand h1 {
    font-size: 1.4rem;
  }

  .crm-topbar h2,
  .crm-hero h3 {
    font-size: 1.3rem;
  }

  .pipeline-board {
    grid-template-columns: 1fr;
  }
}
