/* Dashboard Styles */
.dash-wrapper {
  min-height: 100vh;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  padding: 0;
}

/* Header */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}
.dash-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dash-back {
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s;
}
.dash-back:hover { background: var(--bg-hover); }
.dash-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
}
.dash-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dash-period-select {
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.dash-period-select:focus { border-color: var(--accent); }

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  padding: 24px;
}
.kpi-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}
.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.kpi-messages .kpi-icon { background: linear-gradient(135deg, #3b82f6, #6366f1); color: white; }
.kpi-conversations .kpi-icon { background: linear-gradient(135deg, #10b981, #06b6d4); color: white; }
.kpi-senders .kpi-icon { background: linear-gradient(135deg, #f59e0b, #ef4444); color: white; }
.kpi-period .kpi-icon { background: linear-gradient(135deg, #ec4899, #8b5cf6); color: white; }
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}
.kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  padding: 0 24px 16px;
}
.chart-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
}
.chart-bar-full {
  margin: 0 24px 24px;
}
.chart-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}
.chart-container {
  position: relative;
  height: 260px;
}
.chart-container-bar {
  height: 320px;
}

/* Loading overlay */
.dash-loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  font-size: 14px;
  color: var(--text-secondary);
  backdrop-filter: blur(4px);
}
.dash-loading.hidden { display: none; }

/* Thread Intelligence (Phase 4) */
.section-divider {
  padding: 8px 24px 0;
  margin-top: 8px;
}
.section-heading {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700;
  color: var(--text-primary);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 10px;
  margin-bottom: 0;
}
.group-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.group-table th {
  font-weight: 600; font-size: 12px; color: var(--text-muted);
  padding: 8px 10px; text-align: left;
  border-bottom: 1px solid var(--border-color);
}
.group-table td {
  padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.group-table tbody tr:hover { background: var(--bg-hover); }
.group-rank { font-weight: 700; color: var(--text-muted); }
.group-name { font-weight: 500; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender-chip {
  display: inline-block;
  background: rgba(59,130,246,0.12);
  color: #3b82f6; font-size: 11px; padding: 2px 6px;
  border-radius: 4px; margin: 1px 2px; white-space: nowrap;
}
.heat-bar {
  display: inline-block; height: 20px; border-radius: 3px; min-width: 2px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
}
.sender-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.sender-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sender-count { font-weight: 600; color: var(--accent); min-width: 40px; text-align: right; }
.sender-bar-bg { flex: 1; height: 6px; background: rgba(255,255,255,0.05); border-radius: 3px; }
.sender-bar { height: 100%; border-radius: 3px; }

/* Responsive */
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); padding: 16px; gap: 12px; }
  .charts-grid { grid-template-columns: 1fr; padding: 0 16px 16px; }
  .chart-bar-full { margin: 0 16px 16px; }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 22px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
