/* ============================================================
   KPI Dashboard — Design System & Styles
   Color palette: Teal/Cyan accent, dark mode, glassmorphism
   ============================================================ */

:root {
  /* Colors */
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.85);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);

  --accent: #00d4aa;
  --accent-dim: rgba(0, 212, 170, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);
  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --cyan: #06b6d4;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(0, 212, 170, 0.3);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.4);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ============ HEADER ============ */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}
.header__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.header__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.header__logo {
  display: flex;
  align-items: center;
}
.header__title {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}
.header__sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}
.header__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.header__meta {
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---- Search Box ---- */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.search-box__icon {
  position: absolute;
  left: 0.75rem;
  color: var(--text-muted);
  pointer-events: none;
}
.search-box__input {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem 0.5rem 2.5rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font);
  width: 220px;
  transition: var(--transition);
  outline: none;
}
.search-box__input:focus {
  border-color: var(--accent);
  background: var(--bg-glass-hover);
  box-shadow: 0 0 0 3px var(--accent-dim);
  width: 280px;
}
.search-box__input::placeholder {
  color: var(--text-muted);
}

/* ============ OVERVIEW CARDS ============ */
.overview {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.overview__card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  backdrop-filter: blur(10px);
  transition: var(--transition);
}
.overview__card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.overview__card--accent {
  border-color: var(--border-accent);
}
.overview__icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.overview__icon--blue { background: var(--blue-dim); color: var(--blue); }
.overview__icon--green { background: var(--green-dim); color: var(--green); }
.overview__icon--amber { background: var(--amber-dim); color: var(--amber); }
.overview__value {
  font-size: 1.5rem;
  font-weight: 700;
  display: block;
  line-height: 1.2;
}
.overview__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============ FILTERS ============ */
.filters {
  max-width: 1400px;
  margin: 0 auto 1rem;
  padding: 0 1.5rem;
}
.filters__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.filter-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.filter-tab {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.filter-tab:hover {
  background: var(--bg-glass-hover);
  color: var(--text-primary);
}
.filter-tab--active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}
.sort-select {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
}
.sort-select:focus {
  border-color: var(--accent);
}
.sort-select option {
  background: var(--bg-secondary);
}

/* ============ TEAMS SUMMARY ============ */
.teams-summary {
  max-width: 1400px;
  margin: 0 auto 1.5rem;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
.team-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
  cursor: pointer;
}
.team-card:hover {
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.team-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  opacity: 0;
  transition: var(--transition);
}
.team-card:hover::before { opacity: 1; }
.team-card__name {
  font-weight: 600;
  font-size: 1rem;
  margin-bottom: 0.75rem;
}
.team-card__stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.team-card__stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.team-card__stat-value {
  font-size: 1.1rem;
  font-weight: 600;
}

/* ============ EMPLOYEE GRID ============ */
.employees-grid {
  max-width: 1400px;
  margin: 0 auto 2rem;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.emp-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}
.emp-card:hover {
  border-color: var(--border-accent);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.emp-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.emp-card__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.emp-card__info {
  flex: 1;
  margin-left: 0.75rem;
  min-width: 0;
}
.emp-card__name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.emp-card__team {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.emp-card__badge {
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.emp-card__badge--great {
  background: var(--green-dim);
  color: var(--green);
}
.emp-card__badge--good {
  background: var(--blue-dim);
  color: var(--blue);
}
.emp-card__badge--warn {
  background: var(--amber-dim);
  color: var(--amber);
}
.emp-card__badge--low {
  background: var(--red-dim);
  color: var(--red);
}

/* KPI Ring */
.emp-card__kpi {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
}
.kpi-ring {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}
.kpi-ring svg {
  transform: rotate(-90deg);
}
.kpi-ring__bg {
  fill: none;
  stroke: var(--bg-glass);
  stroke-width: 5;
}
.kpi-ring__progress {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.kpi-ring__text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.kpi-ring__value {
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}
.kpi-ring__label {
  font-size: 0.55rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Progress bars */
.emp-card__bars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}
.progress-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.progress-row__label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  width: 52px;
  flex-shrink: 0;
}
.progress-row__bar {
  flex: 1;
  height: 6px;
  background: var(--bg-glass);
  border-radius: 3px;
  overflow: hidden;
}
.progress-row__fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-row__fill--support { background: linear-gradient(90deg, var(--accent), var(--cyan)); }
.progress-row__fill--deploy { background: linear-gradient(90deg, var(--blue), #818cf8); }
.progress-row__value {
  font-size: 0.7rem;
  font-weight: 600;
  width: 42px;
  text-align: right;
  flex-shrink: 0;
}

/* Card footer stats */
.emp-card__footer {
  display: flex;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  gap: 0.25rem;
}
.emp-card__stat {
  text-align: center;
  flex: 1;
}
.emp-card__stat-val {
  font-size: 0.85rem;
  font-weight: 600;
  display: block;
}
.emp-card__stat-lbl {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* ============ CHART SECTION ============ */
.chart-section, .themes-section {
  max-width: 1400px;
  margin: 0 auto 2rem;
  padding: 0 1.5rem;
}
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
}
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  overflow-x: auto;
  min-height: 200px;
}
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 180px;
  padding-top: 1rem;
}
.chart-bar {
  flex: 1;
  min-width: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
}
.chart-bar__fill {
  width: 100%;
  max-width: 32px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(180deg, var(--accent), var(--cyan));
  transition: height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: pointer;
}
.chart-bar__fill:hover {
  opacity: 0.85;
}
.chart-bar__fill:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  white-space: nowrap;
  z-index: 10;
}
.chart-bar__label {
  font-size: 0.55rem;
  color: var(--text-muted);
  transform: rotate(-45deg);
  white-space: nowrap;
  margin-top: 2px;
}

/* ============ THEMES ============ */
.themes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}
.theme-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: var(--transition);
}
.theme-item:hover {
  border-color: var(--border-accent);
}
.theme-item__rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.theme-item__rank--top { background: var(--accent-dim); color: var(--accent); }
.theme-item__name {
  flex: 1;
  font-size: 0.85rem;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.theme-item__count {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
  flex-shrink: 0;
}
.theme-item__bar {
  width: 60px;
  height: 4px;
  background: var(--bg-glass);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.theme-item__bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s ease;
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay--open {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s ease;
}
.modal-overlay--open .modal {
  transform: translateY(0) scale(1);
}
.modal__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
}
.modal__close:hover {
  background: var(--red-dim);
  color: var(--red);
}

/* Modal content detail */
.modal-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.modal-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.25rem;
}
.modal-name {
  font-size: 1.3rem;
  font-weight: 700;
}
.modal-team {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.modal-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.modal-kpi-cell {
  background: var(--bg-glass);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}
.modal-kpi-cell__value {
  font-size: 1.4rem;
  font-weight: 700;
  display: block;
}
.modal-kpi-cell__label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.modal-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
  margin-top: 1.25rem;
}
.modal-products {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.modal-product-tag {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
}
.modal-product-tag strong {
  color: var(--accent);
}

/* ============ FOOTER ============ */
.footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state__icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}
.empty-state__text {
  font-size: 0.9rem;
}

/* ============ ANIMATIONS ============ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in {
  animation: fadeInUp 0.4s ease forwards;
}
.emp-card { animation: fadeInUp 0.4s ease forwards; }
.emp-card:nth-child(2) { animation-delay: 0.03s; }
.emp-card:nth-child(3) { animation-delay: 0.06s; }
.emp-card:nth-child(4) { animation-delay: 0.09s; }
.emp-card:nth-child(5) { animation-delay: 0.12s; }
.emp-card:nth-child(6) { animation-delay: 0.15s; }
.emp-card:nth-child(n+7) { animation-delay: 0.18s; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .overview { grid-template-columns: repeat(2, 1fr); }
  .teams-summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  html { font-size: 14px; }
  .header__inner { flex-wrap: wrap; }
  .header__actions { width: 100%; }
  .search-box__input { width: 100%; }
  .search-box__input:focus { width: 100%; }
  .overview { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .teams-summary { grid-template-columns: 1fr; }
  .employees-grid { grid-template-columns: 1fr; }
  .modal { padding: 1.5rem; width: 95%; }
}
@media (max-width: 480px) {
  .overview { grid-template-columns: 1fr; }
  .filters__inner { flex-direction: column; align-items: flex-start; }
  .emp-card__kpi { flex-direction: column; align-items: flex-start; }
}
