/* ==========================================================================
   IONITY CENTRAL - CRM PIPELINE & CONTACT MANAGEMENT
   ========================================================================== */

.crm-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* CRM Top Telemetry Bar */
.crm-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.stat-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(51, 102, 255, 0.15);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #3366FF, #60A5FA);
}

.stat-card.won::before { background: linear-gradient(90deg, #00E676, #69F0AE); }
.stat-card.negotiation::before { background: linear-gradient(90deg, #FFA000, #FFD54F); }
.stat-card.pipeline::before { background: linear-gradient(90deg, #A855F7, #C084FC); }

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  font-family: var(--font-sans);
  letter-spacing: -0.5px;
}

.stat-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* View Tabs & Controls */
.crm-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.view-tabs {
  display: flex;
  background: var(--bg-surface);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.view-tab-btn {
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-tab-btn.active {
  background: var(--bg-surface-elevated);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Kanban Board Columns */
.crm-pipeline-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(250px, 1fr));
  gap: 18px;
  overflow-x: auto;
  padding-bottom: 16px;
  min-height: 520px;
}

.crm-stage-column {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 270px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: border-color 0.2s;
}

.stage-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}

.stage-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.stage-dot.lead { background: #3366FF; color: #3366FF; }
.stage-dot.contacted { background: #3366FF; color: #3366FF; }
.stage-dot.proposal { background: #FFA000; color: #FFA000; }
.stage-dot.negotiation { background: #A855F7; color: #A855F7; }
.stage-dot.won { background: #00E676; color: #00E676; }

.stage-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.stage-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-surface-elevated);
  padding: 2px 8px;
  border-radius: 12px;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stage-total {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  font-family: var(--font-mono);
}

.stage-cards-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage-cards-list.drag-over {
  background: rgba(51, 102, 255, 0.08);
  border: 1px dashed var(--accent-primary);
  border-radius: var(--radius-md);
}

/* Individual Deal Card */
.deal-card {
  background: var(--bg-surface-elevated);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: grab;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  overflow: hidden;
}

.deal-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 0 16px rgba(51, 102, 255, 0.2);
}

.deal-card:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.deal-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.deal-company {
  font-size: 11px;
  color: var(--accent-hover);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.deal-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
}

.deal-value-tag {
  font-size: 13px;
  font-weight: 800;
  color: var(--status-green);
  font-family: var(--font-mono);
  text-shadow: 0 0 8px rgba(0, 230, 118, 0.3);
}

.deal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11.5px;
  color: var(--text-muted);
}

.deal-contact {
  display: flex;
  align-items: center;
  gap: 6px;
}

.deal-probability-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 2px;
}

.deal-probability-fill {
  height: 100%;
  background: linear-gradient(90deg, #3366FF 0%, #00E676 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Contacts Table View */
.crm-table-container {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.crm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.crm-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 14px 18px;
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.crm-table td {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.crm-table tr:hover td {
  background: rgba(51, 102, 255, 0.06);
}

/* Revenue Forecast Bar Chart */
.crm-forecast-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.forecast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.forecast-bars-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: flex-end;
  height: 130px;
  padding: 10px 16px 0;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.forecast-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  gap: 6px;
}

.forecast-bar-val {
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
}

.forecast-bar-track {
  flex: 1;
  width: 36px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.forecast-bar-fill.total {
  width: 100%;
  background: linear-gradient(180deg, rgba(51, 102, 255, 0.6) 0%, rgba(51, 102, 255, 0.2) 100%);
  border-radius: 4px 4px 0 0;
  position: absolute;
  bottom: 0;
  left: 0;
  transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.forecast-bar-fill.weighted {
  width: 65%;
  background: linear-gradient(180deg, #00E676 0%, #00B0FF 100%);
  border-radius: 3px 3px 0 0;
  position: absolute;
  bottom: 0;
  z-index: 2;
  box-shadow: 0 0 10px rgba(0, 230, 118, 0.4);
  transition: height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.forecast-bar-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
}

.forecast-bar-prob {
  font-size: 10px;
  color: var(--accent-hover);
  font-family: var(--font-mono);
  font-weight: 600;
}

/* Deal Inspector Probability Slider */
.prob-slider-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-range {
  flex: 1;
  accent-color: var(--accent-primary);
}

