:root {
  --primary: #4361ee;
  --secondary: #3f37c9;
  --success: #4cc9f0;
  --light: #f8f9fa;
  --dark: #212529;
  --gray: #6c757d;
  --light-gray: #e9ecef;
  --warning: #ffc107;
  --danger: #e74c3c;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: #f5f7fb;
  color: var(--dark);
  line-height: 1.6;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--light-gray);
}

.logo {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

/* Filter Section */
.filter-section {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
  padding: 15px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.filter-section span {
  font-weight: 600;
  color: var(--gray);
}

.filter-section select {
  padding: 8px 12px;
  border: 1px solid var(--light-gray);
  border-radius: 4px;
  background-color: white;
  min-width: 150px;
}

/* Tab Navigation */
.tab-navigation {
  display: flex;
  margin-bottom: 25px;
  border-bottom: 2px solid var(--light-gray);
}

.tab-button {
  padding: 12px 24px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 16px;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.3s ease;
}

.tab-button:hover {
  color: var(--primary);
  background-color: rgba(67, 97, 238, 0.05);
}

.tab-button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background-color: rgba(67, 97, 238, 0.1);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.kpi-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.kpi-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  border-left: 4px solid var(--primary);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
}

.kpi-card h3 {
  font-size: 14px;
  margin-bottom: 10px;
  /* Default color, overridden by specific header classes below */
}

.kpi-header-total {
  color: var(--primary);
  /* Color for Total Opportunities */
}

.kpi-header-active {
  color: var(--success);
  /* Color for Active Opportunities */
}

.kpi-header-closure {
  color: var(--warning);
  /* Color for Closure Rate */
}

.kpi-header-lost {
  color: var(--danger);
  /* Color for Lost Opportunities */
}

.kpi-header-won {
  color: #2ecc71;
  /* Different green for Won Opportunities */
}

.kpi-count {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 5px;
  /* Space between count and value */
  /* Color will be applied via JS/CSS classes like .count-lost, .count-won */
}

.kpi-value {
  font-size: 16px;
  /* Smaller font for value */
  font-weight: 500;
  color: var(--gray);
  /* Muted color for value */
  /* Optional: Italic or different style for value */
  font-style: italic;
}

.kpi-trend {
  font-size: 14px;
  display: flex;
  align-items: center;
}

.trend-up {
  color: #2ecc71;
}

.trend-down {
  color: #e74c3c;
}

/* Full Width Chart Section */
.full-width-chart {
  grid-column: 1 / -1;
  margin-bottom: 30px;
}

.full-width-chart .chart-container {
  background: white;
  border-radius: 8px;
  padding: 25px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease;
}

.full-width-chart .chart-container:hover {
  transform: translateY(-2px);
}

.full-width-chart .chart-container h2 {
  font-size: 20px;
  margin-bottom: 20px;
  color: var(--dark);
  text-align: center;
}

.full-width-chart .chart-wrapper {
  position: relative;
  height: 400px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  /* Adjusted for responsiveness */
  gap: 25px;
  margin-bottom: 30px;
}

@media (max-width: 992px) {
  .charts-grid {
    grid-template-columns: 1fr;
    /* Stack charts in a single column on smaller screens */
  }

  .full-width-chart .chart-wrapper {
    height: 350px;
  }
}

.chart-container {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease;
  position: relative;
}

.chart-container:hover {
  transform: translateY(-2px);
}

.chart-container h2 {
  font-size: 18px;
  margin-bottom: 15px;
  color: var(--dark);
}

.chart-wrapper {
  position: relative;
  height: 280px;
}

/* Chart Legend */
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 15px;
  padding: 10px;
  background: var(--light);
  border-radius: 6px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-label {
  color: var(--dark);
  font-weight: 500;
}

.legend-value {
  color: var(--gray);
  margin-left: 5px;
}

.table-container {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  overflow-x: auto;
  margin-bottom: 30px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 12px 15px;
  border-bottom: 2px solid var(--light-gray);
  color: var(--gray);
  font-weight: 600;
}

td {
  padding: 12px 15px;
  border-bottom: 1px solid var(--light-gray);
}

tr:hover {
  background-color: var(--light-gray);
}

tr:last-child td {
  border-bottom: none;
}

.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

/* Opportunity Status Badges - Updated to handle dynamic status */
.status-stage-closed {
  background-color: #e7f7ef;
  color: #2ecc71;
}

.status-stage-won {
  background-color: #e7f7ef;
  color: #2ecc71;
}

.status-stage-open {
  background-color: #e8f4fd;
  color: #3498db;
}

.status-stage-pending {
  background-color: #fff4e6;
  color: #f39c12;
}

.status-stage-lost {
  background-color: #fbeeee;
  color: #e74c3c;
}

.status-stage-unknown {
  /* For cases where status is missing or not recognized */
  background-color: #e9ecef;
  color: var(--dark);
}

/* Sales Order Status Badges (remains unchanged) */
.status-delivered {
  background-color: #e7f7ef;
  color: #2ecc71;
}

.status-shipped {
  background-color: #e8f4fd;
  color: #3498db;
}

.status-processing {
  background-color: #fff4e6;
  color: #f39c12;
}

.status-pending {
  background-color: #fbeeee;
  color: #e74c3c;
}

/* Developer Notes Section */
.dev-notes-section {
  background: white;
  border-radius: 8px;
  padding: 25px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  margin-top: 20px;
  border-left: 4px solid var(--success);
}

.dev-notes-section h2 {
  color: var(--dark);
  margin-bottom: 20px;
  font-size: 22px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dev-notes-section h2::before {
  content: "💡";
  font-size: 24px;
}

.dev-notes-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.note-card {
  background: var(--light);
  border-radius: 6px;
  padding: 20px;
  border: 1px solid var(--light-gray);
}

.note-card h3 {
  color: var(--primary);
  margin-bottom: 12px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.note-card ul {
  list-style: none;
  padding-left: 0;
}

.note-card li {
  padding: 6px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-size: 14px;
  line-height: 1.4;
}

.note-card li:last-child {
  border-bottom: none;
}

.note-card li::before {
  content: "•";
  color: var(--primary);
  font-weight: bold;
  display: inline-block;
  width: 1em;
  margin-left: -1em;
}

/* Data computation specific styles */
.note-card li strong {
  color: var(--dark);
  font-weight: 600;
}

/* Color-coded KPI values */
.count-lost {
  color: var(--danger);
  /* Uses the --danger variable defined in :root */
}

.count-won {
  color: var(--success);
  /* Uses the --success variable defined in :root */
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .container {
    padding: 15px;
  }

  header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

  .tab-navigation {
    flex-direction: column;
  }

  .tab-button {
    text-align: left;
    border-bottom: 1px solid var(--light-gray);
    border-left: 3px solid transparent;
  }

  .tab-button.active {
    border-left-color: var(--primary);
    border-bottom-color: var(--light-gray);
  }

  .kpi-cards {
    grid-template-columns: 1fr;
  }

  .dev-notes-content {
    grid-template-columns: 1fr;
  }

  .kpi-count {
    font-size: 24px;
  }

  .kpi-value {
    font-size: 14px;
  }

  .full-width-chart .chart-wrapper {
    height: 300px;
  }

  .full-width-chart .chart-container h2 {
    font-size: 18px;
  }

  .chart-wrapper {
    height: 250px;
  }

  .filter-section {
    flex-direction: column;
    align-items: flex-start;
  }
}