/* ============================================
   People & HR — Dark Dashboard Theme
   ============================================ */

:root {
  --bg-root: #0a0a0f;
  --bg-surface: #12121a;
  --bg-elevated: #1a1a25;
  --bg-hover: #22222f;
  --bg-active: #2a2a38;
  --border: #2a2a38;
  --border-light: #1e1e2a;
  --text-primary: #fafafa;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --green-muted: rgba(34,197,94,0.15);
  --yellow: #eab308;
  --yellow-muted: rgba(234,179,8,0.15);
  --red: #ef4444;
  --red-muted: rgba(239,68,68,0.15);
  --purple: #a855f7;
  --purple-muted: rgba(168,85,247,0.15);
  --cyan: #06b6d4;
  --cyan-muted: rgba(6,182,212,0.15);
  --orange: #f97316;
  --orange-muted: rgba(249,115,22,0.15);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Layout ── */
.people-page {
  margin-left: 72px;
  padding: 24px 32px 60px;
  max-width: 1600px;
}

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-header h1 span.emoji { font-size: 32px; }

.header-actions {
  display: flex;
  gap: 10px;
}

.search-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  color: var(--text-primary);
  font-size: 14px;
  width: 260px;
  outline: none;
  transition: border-color 0.2s;
}

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

.filter-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover, .filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59,130,246,0.08);
}

/* ── Section Tabs ── */
.section-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  background: var(--bg-surface);
  border-radius: 12px;
  padding: 4px;
  width: fit-content;
}

.section-tab {
  padding: 8px 20px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.section-tab:hover {
  color: var(--text-secondary);
}

.section-tab.active {
  background: var(--accent);
  color: #fff;
}

/* ── Stats Cards ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ── Award Cards ── */
.awards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.award-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.25s;
}

.award-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.award-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.award-icon.gold { background: rgba(234,179,8,0.15); }
.award-icon.fire { background: rgba(239,68,68,0.15); }
.award-icon.star { background: rgba(168,85,247,0.15); }
.award-icon.warn { background: rgba(249,115,22,0.15); }

.award-info h4 {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 3px;
}

.award-info .award-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.award-info .award-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── Employee Grid ── */
.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title .count {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.employee-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.emp-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
  border-left: 4px solid var(--border);
}

.emp-card:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.emp-card.dept-sales { border-left-color: #3b82f6; }
.emp-card.dept-operations { border-left-color: #22c55e; }
.emp-card.dept-marketing { border-left-color: #a855f7; }
.emp-card.dept-leadership { border-left-color: #eab308; }
.emp-card.dept-hr { border-left-color: #06b6d4; }
.emp-card.dept-purchasing { border-left-color: #f97316; }
.emp-card.dept-contractor { border-left-color: #71717a; }

.emp-card-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.emp-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  position: relative;
}

.emp-avatar.sales { background: rgba(59,130,246,0.15); color: #3b82f6; }
.emp-avatar.operations { background: rgba(34,197,94,0.15); color: #22c55e; }
.emp-avatar.marketing { background: rgba(168,85,247,0.15); color: #a855f7; }
.emp-avatar.leadership { background: rgba(234,179,8,0.15); color: #eab308; }
.emp-avatar.hr { background: rgba(6,182,212,0.15); color: #06b6d4; }
.emp-avatar.purchasing { background: rgba(249,115,22,0.15); color: #f97316; }
.emp-avatar.contractor { background: rgba(113,113,122,0.15); color: #71717a; }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  position: absolute;
  bottom: -1px;
  right: -1px;
  border: 2px solid var(--bg-surface);
}

.status-dot.online { background: var(--green); }
.status-dot.offline { background: var(--text-tertiary); }
.status-dot.away { background: var(--yellow); }

.emp-name {
  font-size: 15px;
  font-weight: 600;
}

.emp-role {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.emp-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dept-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.dept-badge.sales { background: rgba(59,130,246,0.12); color: #60a5fa; }
.dept-badge.operations { background: rgba(34,197,94,0.12); color: #4ade80; }
.dept-badge.marketing { background: rgba(168,85,247,0.12); color: #c084fc; }
.dept-badge.leadership { background: rgba(234,179,8,0.12); color: #fde047; }
.dept-badge.hr { background: rgba(6,182,212,0.12); color: #22d3ee; }
.dept-badge.purchasing { background: rgba(249,115,22,0.12); color: #fb923c; }
.dept-badge.contractor { background: rgba(113,113,122,0.12); color: #a1a1aa; }

.emp-score {
  font-size: 14px;
  font-weight: 700;
}

.emp-score.green { color: var(--green); }
.emp-score.yellow { color: var(--yellow); }
.emp-score.red { color: var(--red); }

.emp-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-tertiary);
}

.trend-arrow {
  font-weight: 600;
  font-size: 13px;
}

.trend-arrow.up { color: var(--green); }
.trend-arrow.steady { color: var(--yellow); }
.trend-arrow.down { color: var(--red); }

.badge-icon {
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 16px;
}

/* ── Detail Panel ── */
.detail-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 100000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  backdrop-filter: blur(4px);
}

.detail-overlay.show {
  opacity: 1;
  visibility: visible;
}

.detail-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 680px;
  max-width: 100vw;
  background: var(--bg-root);
  border-left: 1px solid var(--border);
  z-index: 100001;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.detail-panel.show {
  transform: translateX(0);
}

.detail-header {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--bg-root);
  z-index: 2;
}

.detail-person {
  display: flex;
  align-items: center;
  gap: 16px;
}

.detail-avatar {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 22px;
}

.detail-name {
  font-size: 22px;
  font-weight: 700;
}

.detail-role-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.detail-dept {
  margin-top: 6px;
}

.detail-close {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 20px;
  transition: all 0.2s;
}

.detail-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.detail-body {
  padding: 24px 28px;
  flex: 1;
}

.detail-section {
  margin-bottom: 28px;
}

.detail-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-field {
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 12px 14px;
}

.detail-field.full {
  grid-column: 1 / -1;
}

.detail-field-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.detail-field-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

/* Performance metrics in detail */
.perf-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.perf-metric {
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.perf-metric-value {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.perf-metric-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

/* Score bar */
.score-bar-wrap {
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}

.score-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.score-bar-label {
  font-size: 13px;
  font-weight: 500;
}

.score-bar-value {
  font-size: 20px;
  font-weight: 700;
}

.score-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-active);
  border-radius: 4px;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}

/* Activity timeline */
.timeline {
  position: relative;
}

.timeline-item {
  display: flex;
  gap: 14px;
  padding: 10px 0;
  position: relative;
}

.timeline-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 15px;
  top: 36px;
  bottom: -2px;
  width: 2px;
  background: var(--border);
}

.timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  z-index: 1;
}

.timeline-content {
  flex: 1;
}

.timeline-text {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}

.timeline-time {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Documents list */
.doc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.doc-item:hover {
  background: var(--bg-hover);
}

.doc-icon {
  font-size: 18px;
}

.doc-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}

.doc-date {
  font-size: 11px;
  color: var(--text-tertiary);
}

.upload-btn-inline {
  margin-left: auto;
  cursor: pointer;
}

.upload-btn-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #3b82f6;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.upload-btn-label:hover {
  background: #2563eb;
}

.uploaded-doc {
  border: 1px dashed #3b82f620;
}

/* Notes area */
.notes-textarea {
  width: 100%;
  min-height: 100px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.notes-textarea:focus {
  border-color: var(--accent);
}

/* ── Leaderboard ── */
.leaderboard-section {
  margin-bottom: 40px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
}

.leaderboard-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

.leaderboard-table th:hover {
  color: var(--text-secondary);
}

.leaderboard-table th.sorted {
  color: var(--accent);
}

.leaderboard-table th .sort-icon {
  margin-left: 4px;
  font-size: 10px;
}

.leaderboard-table tr.lb-row {
  background: var(--bg-surface);
  cursor: pointer;
  transition: all 0.2s;
}

.leaderboard-table tr.lb-row:hover {
  background: var(--bg-elevated);
}

.leaderboard-table tr.lb-row td {
  padding: 14px;
  font-size: 13px;
  border-top: 1px solid transparent;
  border-bottom: 1px solid transparent;
}

.leaderboard-table tr.lb-row td:first-child {
  border-radius: 10px 0 0 10px;
  border-left: 1px solid transparent;
}

.leaderboard-table tr.lb-row td:last-child {
  border-radius: 0 10px 10px 0;
  border-right: 1px solid transparent;
}

.leaderboard-table tr.lb-row.rank-1 {
  border-color: rgba(234,179,8,0.3);
}

.leaderboard-table tr.lb-row.rank-2 {
  border-color: rgba(192,192,192,0.3);
}

.leaderboard-table tr.lb-row.rank-3 {
  border-color: rgba(205,127,50,0.3);
}

.rank-medal {
  font-size: 18px;
}

.lb-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.lb-badges {
  display: flex;
  gap: 4px;
  margin-left: 6px;
}

.lb-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}

.lb-badge.most-improved { background: rgba(168,85,247,0.15); color: #c084fc; }
.lb-badge.iron-man { background: rgba(113,113,122,0.15); color: #d4d4d8; }
.lb-badge.rookie { background: rgba(6,182,212,0.15); color: #22d3ee; }
.lb-badge.coaching { background: rgba(239,68,68,0.15); color: #f87171; }

/* ── Analytics ── */
.analytics-section {
  margin-bottom: 40px;
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.chart-card.full {
  grid-column: 1 / -1;
}

.chart-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Canvas charts */
.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}

.chart-canvas-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Bar chart (CSS-based) */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 180px;
  padding-top: 10px;
}

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

.bar {
  width: 100%;
  max-width: 40px;
  border-radius: 6px 6px 0 0;
  transition: height 0.6s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  min-height: 4px;
}

.bar:hover {
  opacity: 0.85;
}

.bar-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-align: center;
  max-width: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-value {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Line chart (CSS/SVG) */
.line-chart-wrap {
  position: relative;
  height: 180px;
}

.line-chart-svg {
  width: 100%;
  height: 100%;
}

/* Pie chart (CSS) */
.pie-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
}

.pie-chart {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
}

.pie-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pie-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.pie-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.pie-legend-count {
  color: var(--text-tertiary);
  font-size: 12px;
  margin-left: auto;
}

/* Attendance summary */
.attendance-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.attendance-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.attendance-value {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.attendance-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .stats-row, .awards-row { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .people-page {
    margin-left: 0;
    padding: 16px;
    padding-bottom: 80px;
  }
  .stats-row, .awards-row, .attendance-grid { grid-template-columns: 1fr; }
  .employee-grid { grid-template-columns: 1fr; }
  .detail-panel { width: 100vw; }
  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .search-box { width: 100%; }
  .perf-metrics { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .leaderboard-table { font-size: 12px; }
  .pie-wrap { flex-direction: column; }