/* ========================================
   Data Quality Hub — Styles
   Dark theme, compact layout
   ======================================== */

/* --- CSS Custom Properties --- */
:root {
  --bg-body: #0F1117;
  --bg-card: #1A1D27;
  --bg-elevated: #242836;
  --bg-hover: #2A2F3E;
  --border: #2E3348;
  --text-primary: #E8EAF0;
  --text-secondary: #9BA1B5;
  --text-tertiary: #6B7185;
  --accent: #6C8EFF;
  --success: #34D399;
  --warning: #FBBF24;
  --danger: #F87171;
}

/* --- Light Theme --- */
[data-theme="light"] {
  --bg-body: #F7F8FA;
  --bg-card: #FFFFFF;
  --bg-elevated: #F0F1F5;
  --bg-hover: #E8EAF0;
  --border: #D8DAE5;
  --text-primary: #1A1D27;
  --text-secondary: #4A5068;
  --text-tertiary: #8890A5;
  --accent: #4A6EE0;
  --success: #16A34A;
  --warning: #B45309;
  --danger: #DC2626;
}

[data-theme="light"] .chart-card,
[data-theme="light"] .studies-tree {
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-primary);
  background: var(--bg-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Header (compact: title + desc + stats) --- */
.header {
  padding: 40px 0 24px;
  border-bottom: 2px solid var(--border);
  background: var(--bg-card) url('../background/background_dark.png') center center / cover no-repeat;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .header {
  background-image: url('../background/background_light.png');
}

.header::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 150% at center, rgba(10,12,18,0.90) 0%, rgba(10,12,18,0.60) 45%, rgba(10,12,18,0.18) 75%, rgba(10,12,18,0.0) 100%);
  pointer-events: none;
  z-index: 0;
}

[data-theme="light"] .header::before {
  background: radial-gradient(ellipse 50% 110% at center, rgba(255,255,255,0.80) 0%, rgba(255,255,255,0.04) 100%);
}

.header > .container {
  position: relative;
  z-index: 1;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 12px;
}

.header-top .theme-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  width: 46px;
  height: 46px;
  background: linear-gradient(135deg, #4A6EE0 0%, #6C8EFF 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  font-size: 22px;
  line-height: 1;
}

.header-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0;
  color: #ffffff;
}

[data-theme="light"] .header-title {
  color: #3A5CC5;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-icon-moon { display: none; }
.theme-icon-sun { display: block; }

[data-theme="light"] .theme-icon-moon { display: block; }
[data-theme="light"] .theme-icon-sun { display: none; }

.header-desc {
  font-size: 1rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.7;
  text-align: center;
}

[data-theme="light"] .header-desc {
  color: var(--text-secondary);
}

.header-desc p:first-child {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #ffffff;
}

[data-theme="light"] .header-desc p:first-child {
  color: #3A5CC5;
}

.header-desc p + p {
  font-size: 0.95rem;
}

.header-expanded {
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.header-expanded .about-content {
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.about-intro h3,
.about-references h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.about-intro > p,
.about-references p {
  font-size: 0.925rem;
  color: var(--text-secondary);
  line-height: 1.75;
}

.about-intro > p + p {
  margin-top: 10px;
}

/* --- Concern cards --- */
.concern-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 14px 0;
}

.concern-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.concern-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.concern-card-attention .concern-card-icon {
  background: rgba(52, 211, 153, 0.15);
  color: #34D399;
}

.concern-card-ai .concern-card-icon {
  background: rgba(108, 142, 255, 0.15);
  color: #6C8EFF;
}

.concern-card-fraud .concern-card-icon {
  background: rgba(251, 191, 36, 0.15);
  color: #FBBF24;
}

.concern-card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.concern-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: fit-content;
  background: rgba(108, 142, 255, 0.14);
  border: 1px solid rgba(108, 142, 255, 0.32);
  border-radius: 20px;
  padding: 6px 16px;
}

[data-theme="light"] .header-stats {
  background: var(--bg-elevated);
  border-color: var(--border);
}

.header-stat {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
}

[data-theme="light"] .header-stat {
  color: var(--text-secondary);
}

.header-stat strong {
  color: #ffffff;
  font-weight: 700;
  font-size: 1.05rem;
}

[data-theme="light"] .header-stat strong {
  color: #3A5CC5;
}

.header-stat-sep {
  color: rgba(255,255,255,0.4);
  font-size: 0.9rem;
}

[data-theme="light"] .header-stat-sep {
  color: var(--text-tertiary);
}

/* --- Header stats row (stats pill + live badge) --- */
.header-stats-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  justify-content: center;
}

.header-stats {
  margin-top: 0;
}

/* --- Header CTA row --- */
.header-cta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
}

/* --- Header CTA buttons --- */
.header-cta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.15s;
}
.header-cta:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}
/* Submit Results — accent blue (primary action) */
.header-cta-submit {
  background: rgba(108, 142, 255, 0.22);
  color: #c2d3ff;
  border: 1px solid rgba(108, 142, 255, 0.55);
}
.header-cta-submit:hover {
  background: rgba(108, 142, 255, 0.34);
  border-color: rgba(108, 142, 255, 0.8);
  color: #ffffff;
}
/* Join Discussions — same accent blue */
.header-cta-discuss {
  background: rgba(108, 142, 255, 0.22);
  color: #c2d3ff;
  border: 1px solid rgba(108, 142, 255, 0.55);
}
.header-cta-discuss:hover {
  background: rgba(108, 142, 255, 0.34);
  border-color: rgba(108, 142, 255, 0.8);
  color: #ffffff;
}
/* GitHub — same accent blue */
.header-cta-github {
  background: rgba(108, 142, 255, 0.22);
  color: #c2d3ff;
  border: 1px solid rgba(108, 142, 255, 0.55);
}
.header-cta-github:hover {
  background: rgba(108, 142, 255, 0.34);
  border-color: rgba(108, 142, 255, 0.8);
  color: #ffffff;
}

[data-theme="light"] .header-cta-submit,
[data-theme="light"] .header-cta-discuss,
[data-theme="light"] .header-cta-github {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
[data-theme="light"] .header-cta-submit:hover,
[data-theme="light"] .header-cta-discuss:hover,
[data-theme="light"] .header-cta-github:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
  background: transparent;
}

/* --- Custom chart legend --- */
.chart-custom-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 4px 8px;
  font-size: 0.82rem;
}
.legend-section {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.legend-section + .legend-section {
  padding-left: 0;
  border-left: none;
  padding-top: 5px;
  border-top: 1px solid var(--border);
}
.legend-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  min-width: 90px;
  margin-right: 2px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.legend-item svg {
  flex-shrink: 0;
}
.legend-item-text {
  line-height: 1;
}
.legend-item-italic {
  font-style: italic;
}

@media (max-width: 600px) {
  .chart-custom-legend {
    font-size: 0.76rem;
    gap: 5px;
  }
  .legend-section-label {
    min-width: 80px;
  }
}

/* --- Live inline stat (inside stats pill) --- */
.header-live-inline {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* --- Live Tracker Badge (standalone, now unused but kept) --- */
.header-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px 4px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  animation: live-pulse 2.4s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
  50% { opacity: 0.6; box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.2); }
}

/* --- Animated logo bars --- */
.hdr-bar {
  transform-box: fill-box;
  transform-origin: 50% 100%;
}

@keyframes hdr-bar-1 {
  0%, 100% { transform: scaleY(1); }
  45% { transform: scaleY(0.5); }
}

@keyframes hdr-bar-2 {
  0%, 100% { transform: scaleY(1); }
  35% { transform: scaleY(1.28); }
}

@keyframes hdr-bar-3 {
  0%, 100% { transform: scaleY(1); }
  60% { transform: scaleY(0.65); }
}

.hdr-bar-1 { animation: hdr-bar-1 3.4s ease-in-out infinite; }
.hdr-bar-2 { animation: hdr-bar-2 2.9s ease-in-out infinite 0.6s; }
.hdr-bar-3 { animation: hdr-bar-3 3.8s ease-in-out infinite 1.1s; }

/* --- Decorative header graphic (right side) --- */
.header-deco {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 260px;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  opacity: 0.07;
  color: var(--accent);
}

@media (max-width: 768px) {
  .header-deco { display: none; }
}

/* --- Section title toggle (Explanations of Metrics) --- */
.section-title-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: color 0.15s;
}

.section-title-toggle:hover {
  color: var(--accent);
}

.section-title-toggle .toggle-chevron {
  margin-left: auto;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--accent);
  opacity: 0.75;
  transition: transform 0.25s ease, opacity 0.15s;
}

.section-title-toggle:hover .toggle-chevron {
  opacity: 1;
}

.section-title-toggle.expanded .toggle-chevron {
  transform: rotate(180deg);
}

.explanations-body {
  overflow: hidden;
  transition: max-height 0.45s ease;
}

.explanations-body.collapsed {
  max-height: 0;
}

.explanations-body.expanded {
  max-height: 1800px;
}

.metric-list-body {
  overflow: hidden;
  transition: max-height 0.45s ease;
}

.metric-list-body.collapsed {
  max-height: 0;
}

.metric-list-body.expanded {
  max-height: 4000px;
}

/* --- Concern card header row (icon + title inline) --- */
.concern-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.concern-card-header .concern-card-icon {
  margin-bottom: 0;
}

/* --- Loading Skeleton --- */
.loading {
  padding: 32px 0;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

.skeleton-chart {
  height: 300px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- Charts --- */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
}

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

.chart-header .chart-title {
  margin-bottom: 0;
}

.chart-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.chart-title-row .chart-title {
  margin-bottom: 0;
}

.chart-title-row .info-btn {
  padding: 2px;
}

.chart-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

/* --- Section header icons --- */
.more-section-title {
  display: flex;
  align-items: center;
  gap: 7px;
}

.section-icon {
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0.85;
}

/* --- 2-Level Metric Selector --- */
.metric-selector {
  margin-bottom: 12px;
}

.metric-selector-l1 {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.concern-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.concern-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.concern-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.metric-selector-l1-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.concern-btn-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.concern-info-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: var(--text-tertiary);
  text-decoration: none;
  border-radius: 4px;
  opacity: 0.65;
  transition: color 0.15s, opacity 0.15s;
  flex-shrink: 0;
}

.concern-info-link:hover {
  color: var(--accent);
  opacity: 1;
  text-decoration: none;
}

.metric-selector-l2 {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.metric-btn {
  padding: 4px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.metric-btn:hover:not([disabled]) {
  color: var(--accent);
  border-color: var(--accent);
}

.metric-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.metric-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.metric-no-data {
  font-size: 0.75em;
  opacity: 0.7;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

.chart-wrap-trend {
  height: 380px;
}

/* Chart type toggle (Trend / Means) */
.chart-type-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.chart-type-btn {
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}

.chart-type-btn:last-child {
  border-right: none;
}

.chart-type-btn:hover:not(.active) {
  background: var(--bg-hover, rgba(128,128,128,0.08));
  color: var(--text-primary);
}

.chart-type-btn.active {
  background: var(--accent);
  color: #fff;
}

/* Means by Study scrollable chart */
.chart-wrap-means-outer {
  overflow-x: auto;
  overflow-y: hidden;
  height: 420px;
  position: relative;
  -webkit-overflow-scrolling: touch; /* smooth momentum scroll on iOS */
}

.chart-means-scroll {
  height: 100%;
  min-width: 100%;
  position: relative;
}


.chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-tertiary);
  font-style: italic;
}

/* --- External means-chart HTML tooltip --- */
.dqh-means-tt {
  position: absolute;
  z-index: 200;
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  max-width: 280px;
  font-family: Inter, sans-serif;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  box-shadow: 0 4px 20px rgba(0,0,0,0.16);
  pointer-events: auto;
}
.dqh-means-tt-title {
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
  margin-bottom: 7px;
  flex-wrap: wrap;
}
.dqh-means-tt-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dqh-means-tt-sep {
  color: var(--text-tertiary);
  font-weight: 400;
}
.dqh-means-tt a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}
.dqh-means-tt a:hover {
  text-decoration: underline;
}
.dqh-means-tt-passrate {
  font-weight: 600;
  color: var(--text-primary);
}
.dqh-means-tt-measure-lbl {
  color: var(--text-primary);
  font-weight: 500;
  margin-top: 5px;
}

/* --- Collapsible shared --- */
.toggle-chevron {
  transition: transform 0.3s ease;
  flex-shrink: 0;
  color: var(--text-tertiary);
}

.collapsed { max-height: 0; overflow: hidden; }
.expanded { max-height: 5000px; overflow: hidden; }

/* --- Filter Panel --- */
.filter-panel {
  margin-bottom: 12px;
}

.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.filter-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.filter-toggle.expanded .toggle-chevron {
  transform: rotate(180deg);
}

.filter-body {
  transition: max-height 0.3s ease;
}

.filter-body.expanded {
  max-height: 500px;
}

.filter-stage-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.info-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s;
}

.info-btn:hover {
  color: var(--accent);
}

.info-popup {
  transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
  background: var(--bg-elevated);
  border-radius: 6px;
}

.info-popup.collapsed {
  padding: 0 16px;
  margin: 0;
}

.info-popup.expanded {
  max-height: 300px;
  padding: 10px 16px;
  margin: 6px 0;
}

.info-popup p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 4px;
}

.info-popup p:last-child {
  margin-bottom: 0;
}

.filter-group {
  padding: 8px 0;
  border-top: 1px solid rgba(46, 51, 72, 0.4);
}

.filter-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.filter-radios {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.filter-radio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.filter-radio input[type="radio"] {
  accent-color: var(--accent);
}

.filter-checkboxes {
  display: flex;
  gap: 10px 14px;
  flex-wrap: wrap;
}

.filter-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  cursor: pointer;
}

.filter-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
}

/* --- Contribute Section (end of page) --- */
.contribute-section {
  padding: 24px 0 32px;
}

.contribute-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 28px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.contribute-card-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.contribute-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.contribute-card-icon {
  width: 34px;
  height: 34px;
  background: rgba(108, 142, 255, 0.14);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}

.contribute-card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.contribute-card-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.contribute-what {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.contribute-what-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-tertiary);
}

.contribute-chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0;
  padding: 0;
}

.contribute-chips li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 0.79rem;
  color: var(--text-secondary);
}

.contribute-chips li::before {
  content: '\2713';
  color: var(--accent);
  font-size: 0.72em;
  font-weight: 800;
}
.contribute-chips .chip-break {
  width: 100%;
  height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  background: none;
  border: none;
}
.contribute-chips .chip-break::before { content: none; }

.contribute-time {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.79rem;
  color: var(--text-tertiary);
}

.contribute-card-right {
  flex-shrink: 0;
}

.btn-contribute-card {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  background: var(--accent);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  transition: opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-contribute-card:hover {
  opacity: 0.85;
  text-decoration: none;
}

.btn-contribute-edit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-contribute-edit:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.contribute-desc-edit {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* --- More Section --- */
.section-more {
  padding: 20px 0 32px;
}

.section-more-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 6px 0 12px;
  letter-spacing: -0.01em;
}

.more-body {
  transition: max-height 0.4s ease;
}

.more-section {
  padding: 24px 28px;
  margin-bottom: 16px;
  background: var(--bg-card);
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
  border: 1px solid var(--border);
}

.more-section:last-child {
  margin-bottom: 0;
}

.more-section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* --- Studies Tree --- */

/* Column header row — must match .study-l2 grid exactly */
.study-col-header {
  display: grid;
  grid-template-columns: 20px 1.4fr 1fr 0.7fr 0.9fr 1fr 1fr 1.2fr;
  align-items: center;
  gap: 4px;
  padding: 8px 16px 8px 24px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.col-n, .col-country, .col-date, .col-rate, .col-attention, .col-recruitment {
  text-align: center;
}

.col-country {
  color: var(--text-tertiary);
  font-size: 0.7rem;
}

.table-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.btn-download:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.filter-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
}

.filter-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.studies-tree {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  overflow-x: auto;
}

.study-l1 {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.study-l1:last-child {
  border-bottom: none;
}

.study-l1:hover {
  background: var(--bg-hover);
}

.study-l1.expanded {
  background: var(--bg-elevated);
}

.study-l1 .toggle-chevron {
  transition: transform 0.3s ease;
}

.study-l1 .l1-chevron {
  color: var(--accent);
  flex-shrink: 0;
}

.study-l1.expanded > .toggle-chevron {
  transform: rotate(180deg);
}

.l1-paper {
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.l1-researcher {
  color: var(--text-secondary);
  font-size: 0.85rem;
  white-space: nowrap;
}

.l1-meta {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  white-space: nowrap;
}

.l1-n {
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.l1-info-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color 0.15s;
  flex-shrink: 0;
}

.l1-info-btn:hover {
  color: var(--accent);
}

.l1-info-popup {
  transition: max-height 0.3s ease, padding 0.3s ease;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.l1-info-popup.collapsed {
  max-height: 0;
  padding: 0 24px;
}

.l1-info-popup.expanded {
  max-height: 500px;
  padding: 12px 24px;
}

.study-info-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.study-info-row {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.study-info-row strong {
  color: var(--text-primary);
  font-weight: 600;
}

.study-info-header {
  margin-bottom: 8px;
}

.study-info-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.study-info-authors {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-top: 2px;
}

.study-info-bg {
  padding: 4px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.study-info-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
}

.study-info-bg strong {
  color: var(--text-primary);
  font-weight: 600;
}

.info-val {
  color: #3A5CC5;
  font-weight: 500;
}

[data-theme="dark"] .info-val {
  color: #6C8EFF;
}

.info-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  word-break: break-all;
}

.info-link:hover {
  text-decoration: underline;
}

.l2-recruitment {
  color: var(--text-secondary);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.l2-country {
  color: var(--text-secondary);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.l1-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  border-bottom: 1px solid var(--border);
}

.l1-children.expanded {
  max-height: 2000px;
}

.study-l2 {
  display: grid;
  grid-template-columns: 20px 1.4fr 1fr 0.7fr 0.9fr 1fr 1fr 1.2fr;
  align-items: center;
  gap: 4px;
  padding: 10px 16px 10px 24px;
  font-size: 0.875rem;
  border-bottom: 1px solid rgba(46, 51, 72, 0.4);
  transition: background 0.15s;
}

.study-l2:hover {
  background: var(--bg-hover);
}

.study-l2.has-child {
  cursor: pointer;
}

.study-l2 .l2-chevron {
  transition: transform 0.3s ease;
}

.study-l2.expanded .l2-chevron {
  transform: rotate(180deg);
}

.l2-spacer {
  display: inline-block;
  width: 14px;
}

.l2-n {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.l2-n, .l2-country, .l2-date, .l2-rate, .l2-attention, .l2-recruitment {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.l2-date { color: var(--text-secondary); }


.l2-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.l2-children.expanded {
  max-height: 500px;
}

.study-l3 {
  display: grid;
  grid-template-columns: 20px 1.4fr 1fr 0.7fr 0.9fr 1fr 1fr 1.2fr;
  align-items: center;
  gap: 4px;
  padding: 8px 16px 8px 48px;
  font-size: 0.85rem;
  background: rgba(108, 142, 255, 0.03);
  border-bottom: 1px solid rgba(46, 51, 72, 0.3);
}

.l3-label {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-style: italic;
}

.l3-n {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.l3-rate, .l3-attention, .l3-ai, .l3-fraud {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.l3-date { color: var(--text-secondary); }


.table-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-tertiary);
  font-style: italic;
}

/* --- Platform Tags --- */
.platform-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}

/* --- Rate Coloring --- */
.rate-green { color: var(--success); font-weight: 600; }
.rate-amber { color: var(--warning); font-weight: 600; }
.rate-red   { color: var(--danger); font-weight: 600; }
.rate-na    { color: var(--text-tertiary); }

/* --- Definitions Panel --- */
.definitions-panel {
  margin-top: 16px;
}

.definitions-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s;
}

.definitions-toggle:hover {
  background: var(--bg-hover);
}

.definitions-toggle.expanded .toggle-chevron {
  transform: rotate(180deg);
}

.definitions-body {
  transition: max-height 0.4s ease;
}

.definitions-body.expanded {
  max-height: 2000px;
}

.definitions-list {
  padding: 6px 0;
}

.definition-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}

.definition-item:last-child {
  border-bottom: none;
}

.definition-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  flex-wrap: wrap;
  gap: 8px;
}

.definition-paper {
  color: var(--accent);
  font-weight: 500;
  cursor: pointer;
}

.definition-paper:hover {
  text-decoration: underline;
}

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

.definition-text {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.6;
}

.definitions-empty {
  color: var(--text-tertiary);
  font-style: italic;
  padding: 10px 16px;
}

/* --- Metrics List --- */
.metrics-list-intro {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin: 4px 0 10px;
}

.metrics-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  overflow: hidden;
}

[data-theme="light"] .metrics-list {
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.metric-item {
  border-bottom: 1px solid var(--border);
}

.metric-item:last-child {
  border-bottom: none;
}

.metric-item[style*="display: none"] + .metric-item:not([style*="display: none"]) {
  border-top: none;
}

.metric-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

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

.metric-item-header[aria-expanded="true"] {
  background: var(--bg-elevated);
}

.metric-item-header .toggle-chevron {
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.25s ease;
  color: var(--text-tertiary);
}

.metric-item-header[aria-expanded="true"] .toggle-chevron {
  transform: rotate(180deg);
}

.metric-concern-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.concern-icon-inattention {
  background: rgba(52, 211, 153, 0.15);
  color: #34D399;
}

.concern-icon-ai {
  background: rgba(108, 142, 255, 0.15);
  color: #6C8EFF;
}

.concern-icon-fraud {
  background: rgba(251, 191, 36, 0.15);
  color: #FBBF24;
}

.metric-item-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}

.metric-concern-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px 2px 6px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.concern-tag-inattention {
  background: rgba(52, 211, 153, 0.1);
  color: #34D399;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.concern-tag-ai {
  background: rgba(108, 142, 255, 0.1);
  color: #6C8EFF;
  border: 1px solid rgba(108, 142, 255, 0.25);
}

.concern-tag-fraud {
  background: rgba(251, 191, 36, 0.1);
  color: #FBBF24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}

[data-theme="light"] .concern-tag-fraud {
  color: #B45309;
  border-color: rgba(180, 83, 9, 0.3);
  background: rgba(180, 83, 9, 0.08);
}

[data-theme="light"] .concern-icon-fraud {
  color: #B45309;
  background: rgba(180, 83, 9, 0.1);
}

.metric-item-body {
  padding: 0 16px;
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.3s ease;
  border-top: 0px solid var(--border);
}

.metric-item-body.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.metric-item-body.expanded {
  max-height: 400px;
  padding-top: 14px;
  padding-bottom: 16px;
  border-top-width: 1px;
}

.metric-item-body p {
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 10px;
}

.metric-item-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.79rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 6px;
}

.metric-note-good {
  background: rgba(52, 211, 153, 0.1);
  color: var(--success);
}

.metric-note-low {
  background: rgba(251, 191, 36, 0.1);
  color: var(--warning);
}

/* --- Footer --- */
.footer {
  padding: 36px 0 44px;
  border-top: 1px solid var(--border);
  background: var(--bg-card) url('../background/background_dark.png') center center / cover no-repeat;
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .footer {
  background-image: url('../background/background_light.png');
}

.footer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 60% 140% at center, rgba(15,17,23,0.72) 0%, rgba(15,17,23,0.08) 100%);
  pointer-events: none;
  z-index: 0;
}

[data-theme="light"] .footer::before {
  background: radial-gradient(ellipse 60% 140% at center, rgba(255,255,255,0.82) 0%, rgba(255,255,255,0.06) 100%);
}

.footer > .container {
  position: relative;
  z-index: 1;
}

.footer-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-name {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
}

[data-theme="light"] .footer-name {
  color: var(--text-primary);
}

.footer-tagline {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.6);
}

[data-theme="light"] .footer-tagline {
  color: var(--text-tertiary);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 8px;
  color: rgba(255,255,255,0.85);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  background: rgba(255,255,255,0.1);
}

.footer-link:hover {
  color: #ffffff;
  border-color: rgba(255,255,255,0.55);
  text-decoration: none;
  background: rgba(255,255,255,0.18);
}

[data-theme="light"] .footer-link {
  border-color: var(--border);
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

[data-theme="light"] .footer-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-hover);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
  .header { padding: 28px 0 20px; }
  .header-title { font-size: 1.6rem; }
  .header-icon { width: 38px; height: 38px; border-radius: 10px; }

  .concern-cards {
    grid-template-columns: 1fr;
  }

  .chart-wrap,
  .chart-wrap-trend,
  .chart-wrap-means-outer {
    height: 350px;
  }

  .contribute-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }

  /* Hide Country on tablet */
  .col-country, .l2-country, .l3-country {
    display: none;
  }

  .study-col-header,
  .study-l2,
  .study-l3 {
    grid-template-columns: 20px 1.4fr 0.7fr 0.9fr 1fr 1fr 1.2fr;
    gap: 4px;
    font-size: 0.8rem;
  }

  .footer-inner {
    flex-direction: column;
    gap: 16px;
  }

  .footer-links {
    gap: 6px;
  }

  .definition-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .header-title { font-size: 1.4rem; }
  .header-icon { width: 34px; height: 34px; border-radius: 8px; }

  .header-stats {
    gap: 4px;
  }

  .header-stat { font-size: 0.82rem; }
  .header-stat strong { font-size: 0.95rem; }

  .chart-wrap,
  .chart-wrap-trend,
  .chart-wrap-means-outer {
    height: 310px;
  }

  .study-l1 {
    gap: 8px;
    padding: 10px 12px;
    font-size: 0.85rem;
  }

  .l1-researcher,
  .l1-meta {
    display: none;
  }

  /* Also hide Attention and Recruitment on phone — keep Platform, N, Date, Pass Rate */
  .col-attention, .col-recruitment,
  .l2-attention, .l2-recruitment,
  .l3-attention, .l3-recruitment {
    display: none;
  }

  .study-col-header,
  .study-l2,
  .study-l3 {
    grid-template-columns: 16px 1.5fr 0.8fr 1.1fr 1.2fr;
    gap: 4px;
    padding-left: 12px;
    padding-right: 12px;
    font-size: 0.78rem;
  }

  .study-l3 {
    padding-left: 28px;
  }

  .study-l1 {
    padding-left: 12px;
    padding-right: 12px;
  }

  .l1-info-popup.expanded {
    padding: 10px 12px;
  }
}

/* --- Chart click-to-navigate highlight --- */
@keyframes study-highlight {
  0%, 100% { outline: 2px solid transparent; outline-offset: 2px; }
  20%, 80% { outline: 2px solid var(--accent); outline-offset: 2px; }
}

.study-l1.highlight-pulse {
  animation: study-highlight 1.5s ease;
}
