:root {
  --bg-primary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-border: rgba(15, 23, 42, 0.08);
  --bg-subtle: rgba(15, 23, 42, 0.04);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent-blue: #0ea5e9;
  --accent-green: #16a34a;
  --accent-red: #dc2626;
  --accent-orange: #ea580c;
  --accent-purple: #9333ea;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  padding: 24px;
  line-height: 1.5;
}

/* Header */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--bg-card-border);
  flex-wrap: wrap;
  gap: 16px;
}

.header-title h1 {
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-title p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 4px;
}

/* KPI Scorecards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.1);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.kpi-card.blue::before { background: var(--accent-blue); }
.kpi-card.green::before { background: var(--accent-green); }
.kpi-card.orange::before { background: var(--accent-orange); }
.kpi-card.gray::before { background: #64748b; }
.kpi-card.red::before { background: var(--accent-red); }

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 8px 0 4px;
  color: var(--text-main);
}

.kpi-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  display: flex;
  flex-direction: column;
}

.chart-card.col-4 { grid-column: span 4; }
.chart-card.col-6 { grid-column: span 6; }
.chart-card.col-8 { grid-column: span 8; }
.chart-card.col-12 { grid-column: span 12; }

@media (max-width: 1024px) {
  .chart-card.col-4, .chart-card.col-6, .chart-card.col-8 {
    grid-column: span 12;
  }
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.chart-container {
  position: relative;
  flex: 1;
  min-height: 260px;
  width: 100%;
}

.chart-container-tall {
  min-height: 460px;
}

.sort-select {
  background: var(--bg-subtle);
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  outline: none;
}

.header-meta {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.table-footer {
  margin-top: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Data Table Styling */
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.search-input {
  background: var(--bg-subtle);
  border: 1px solid var(--bg-card-border);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  width: 260px;
  outline: none;
}

.search-input:focus {
  border-color: var(--accent-blue);
}

.download-btn {
  background: var(--accent-blue);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

.download-btn:hover {
  background: #0284c7;
}

.table-wrapper {
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 14px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--bg-card-border);
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--bg-card-border);
}

tr:hover td {
  background: var(--bg-subtle);
}

/* Badge System */
.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green { background: rgba(22, 163, 74, 0.12); color: #15803d; }
.badge-orange { background: rgba(234, 88, 12, 0.12); color: #c2410c; }
.badge-gray { background: rgba(100, 116, 139, 0.12); color: #475569; }
.badge-red { background: rgba(220, 38, 38, 0.12); color: #b91c1c; }

.progress-bar-bg {
  background: var(--bg-subtle);
  border-radius: 4px;
  height: 6px;
  width: 100px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #0ea5e9, #16a34a);
}
