/* ─── RESET & BASE ────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --navy: #1a2744;
  --navy-light: #2d3e5c;
  --slate: #4a5568;
  --blue: #3182ce;
  --light-blue: #63b3ed;
  --green: #38a169;
  --green-bg: #f0fff4;
  --amber: #d69e2e;
  --amber-bg: #fefcbf;
  --red: #e53e3e;
  --red-bg: #fff5f5;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f7fafc;
  --gray-200: #edf2f7;
  --gray-300: #e2e8f0;
  --gray-400: #cbd5e0;
  --gray-500: #a0aec0;
  --gray-600: #718096;
  --gray-700: #4a5568;
  --gray-800: #2d3748;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --radius: 8px;
  --radius-lg: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── TOP NAVIGATION ─────────────────────────────────── */
.top-nav {
  display: flex;
  align-items: center;
  background: var(--navy);
  color: var(--white);
  padding: 0 24px;
  height: 56px;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 40px;
}

.brand-icon {
  font-size: 22px;
  color: var(--light-blue);
}

.brand-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-sub {
  font-size: 12px;
  color: var(--gray-400);
  margin-left: 4px;
}

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav-link {
  color: var(--gray-400);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-link:hover {
  color: var(--white);
  background: var(--navy-light);
}

.nav-link.active {
  color: var(--white);
  background: var(--blue);
}

.nav-user {
  display: flex;
  align-items: center;
}

.user-select {
  background: var(--navy-light);
  color: var(--white);
  border: 1px solid var(--gray-600);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  min-width: 200px;
}

.user-select:focus {
  outline: none;
  border-color: var(--blue);
}

/* ─── DASHBOARD CONTAINER ────────────────────────────── */
.dashboard-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ─── DASHBOARD HEADER ───────────────────────────────── */
.dashboard-header {
  margin-bottom: 24px;
}

.dashboard-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}

.dashboard-header .subtitle {
  font-size: 14px;
  color: var(--gray-600);
}

/* ─── STAT CARDS ROW ─────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}

.stat-card .stat-detail {
  font-size: 12px;
  color: var(--gray-600);
  margin-top: 4px;
}

.stat-card .stat-trend {
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
}

.stat-trend.positive { color: var(--green); }
.stat-trend.negative { color: var(--red); }
.stat-trend.neutral { color: var(--gray-500); }

/* ─── CARD PANELS ────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy);
}

.card-header .card-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--gray-200);
  color: var(--gray-600);
}

.card-body {
  padding: 20px;
}

/* ─── GRID LAYOUTS ───────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}

.grid-1-2 {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
}

/* ─── CHART CONTAINERS ───────────────────────────────── */
.chart-container {
  position: relative;
  height: 280px;
}

.chart-container-sm {
  position: relative;
  height: 200px;
}

.chart-container-lg {
  position: relative;
  height: 360px;
}

/* ─── SKILL HEATMAP ──────────────────────────────────── */
.heatmap {
  display: grid;
  gap: 8px;
}

.heatmap-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  align-items: center;
  gap: 12px;
}

.heatmap-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.heatmap-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.heatmap-bar {
  height: 24px;
  border-radius: 4px;
  min-width: 4px;
  transition: width 0.3s ease;
}

.heatmap-value {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  min-width: 48px;
}

/* ─── TABLES ─────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-700);
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* ─── BADGES & TAGS ──────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: #ebf8ff; color: var(--blue); }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }

/* ─── STATUS INDICATORS ──────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-dot.green { background: var(--green); }
.status-dot.amber { background: var(--amber); }
.status-dot.red { background: var(--red); }
.status-dot.blue { background: var(--blue); }
.status-dot.gray { background: var(--gray-400); }

/* ─── RANKING DISPLAY ────────────────────────────────── */
.ranking {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-200);
}

.ranking:last-child { border-bottom: none; }

.ranking-position {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--gray-200);
  color: var(--gray-600);
  flex-shrink: 0;
}

.ranking-position.top-3 {
  background: var(--blue);
  color: var(--white);
}

.ranking-info {
  flex: 1;
}

.ranking-metric {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
}

.ranking-detail {
  font-size: 11px;
  color: var(--gray-500);
}

/* ─── CONFIDENCE METER ───────────────────────────────── */
.confidence-meter {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.confidence-label {
  font-size: 13px;
  color: var(--gray-600);
  min-width: 60px;
}

.confidence-dots {
  display: flex;
  gap: 4px;
}

.confidence-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
}

.confidence-dot.filled {
  border-color: var(--blue);
  background: var(--blue);
}

.confidence-dot.filled.after {
  border-color: var(--green);
  background: var(--green);
}

/* ─── ATTRIBUTION DISPLAY ────────────────────────────── */
.attribution-bar {
  display: flex;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.attribution-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--white);
  min-width: 20px;
}

.attribution-direct { background: var(--green); }
.attribution-correlation { background: var(--amber); }
.attribution-unknown { background: var(--gray-400); }

.attribution-legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--gray-600);
}

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

.attribution-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

/* ─── BUTTONS ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--blue);
  color: var(--white);
}

.btn-primary:hover {
  background: #2b6cb0;
}

/* ─── LOADING & ERROR STATES ─────────────────────────── */
.loading-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--gray-500);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-300);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--red-bg);
  color: var(--red);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 16px;
}

.error-message {
  font-size: 14px;
  color: var(--gray-600);
  margin-bottom: 16px;
}

/* ─── EMPTY STATE ────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 32px;
  color: var(--gray-500);
  font-size: 14px;
}

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-2, .grid-2-1, .grid-1-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .top-nav {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }
  .nav-brand { margin-right: auto; }
  .nav-links { order: 3; width: 100%; }
  .stats-row { grid-template-columns: 1fr; }
  .dashboard-container { padding: 16px; }
}
