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

:root {
  --bg: #0a0e1a;
  --surface: #111827;
  --surface2: #1f2937;
  --border: rgba(255,255,255,0.08);
  --text: #f9fafb;
  --muted: #9ca3af;
  --accent: #6366f1;
  --accent-light: #818cf8;
  --gold: #f59e0b;
  --green: #10b981;
  --radius: 12px;
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* auth overlay */
#auth-loading {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; z-index: 100;
}
#auth-loading p { color: var(--muted); font-size: 13px; }
.loading-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* nav */
nav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10,14,26,.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 0 40px; height: 56px;
  display: flex; align-items: center; gap: 0;
}
.logo {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 700; letter-spacing: -.3px;
  text-decoration: none; color: var(--text);
  flex-shrink: 0; margin-right: 32px;
}
.logo-icon {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff;
}
.logo span { color: var(--accent-light); }

.nav-menu {
  display: flex; align-items: center; gap: 2px; flex: 1;
}
.nav-menu .nav-link {
  padding: 6px 12px; border-radius: 7px;
  font-size: 13px; font-weight: 500;
  color: var(--muted); text-decoration: none;
  transition: color .15s, background .15s; white-space: nowrap;
}
.nav-menu .nav-link:hover { color: var(--text); background: rgba(255,255,255,.06); }
.nav-menu .nav-link.active { color: var(--text); background: rgba(99,102,241,.14); }

.nav-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.nav-email { font-size: 12px; color: var(--muted); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  color: var(--muted); padding: 5px 13px; border-radius: 7px;
  cursor: pointer; font-size: 12px; font-family: inherit; font-weight: 500;
  transition: all .15s; white-space: nowrap;
}
.btn-logout:hover { border-color: rgba(255,255,255,.18); color: var(--text); background: rgba(255,255,255,.07); }

/* main */
main { max-width: 1080px; margin: 0 auto; padding: 36px 24px 80px; }

/* hero */
.report-hero {
  text-align: center;
  padding: 52px 24px 44px;
  margin-bottom: 48px;
  position: relative;
}
.report-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99,102,241,.14) 0%, transparent 70%);
  pointer-events: none;
}
.report-hero-badge {
  display: inline-block;
  background: rgba(99,102,241,.12);
  color: var(--accent-light);
  border: 1px solid rgba(99,102,241,.28);
  padding: 4px 14px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase;
  margin-bottom: 18px;
}
.report-hero-title {
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 700; letter-spacing: -1.5px;
  margin-bottom: 12px;
}
.report-hero-sub { color: var(--muted); font-size: 14px; margin-bottom: 36px; }
.report-hero-sub .highlight { color: var(--green); font-weight: 600; }

/* stat cards */
.stat-cards {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: center;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 28px;
  display: flex; flex-direction: column; gap: 5px; min-width: 148px;
  transition: border-color .15s, transform .15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.accent  { border-color: rgba(99,102,241,.35); background: rgba(99,102,241,.07); }
.stat-card.gold    { border-color: rgba(245,158,11,.35);  background: rgba(245,158,11,.06);  }
.stat-card.muted   { border-color: var(--border); }
.stat-num { font-size: 28px; font-weight: 700; letter-spacing: -1.5px; }
.stat-card.accent .stat-num { color: var(--accent-light); }
.stat-card.gold   .stat-num { color: var(--gold); }
.stat-lbl { font-size: 12px; color: var(--muted); }

/* section */
.section { margin-bottom: 52px; }
.section-title { font-size: 17px; font-weight: 600; letter-spacing: -.3px; margin-bottom: 18px; }
.section-note  { font-size: 12px; color: var(--muted); font-weight: 400; }

/* macro chart */
#macro-chart {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
}
.macro-sub-tabs { display: flex; gap: 8px; margin-bottom: 22px; }
.macro-sub-btn {
  background: none; border: 1px solid var(--border);
  color: var(--muted); padding: 5px 14px;
  border-radius: 7px; cursor: pointer; font-size: 12px; font-weight: 500; font-family: inherit;
  transition: all .15s;
}
.macro-sub-btn.active {
  background: rgba(99,102,241,.15); border-color: rgba(99,102,241,.45);
  color: var(--accent-light);
}
.macro-rows { display: flex; flex-direction: column; gap: 11px; }
.macro-row {
  display: grid;
  grid-template-columns: 148px 1fr 64px;
  align-items: center; gap: 14px;
}
.macro-row-label { font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 7px; color: var(--text); }
.macro-icon { font-size: 14px; }
.macro-bar-track {
  height: 18px; background: rgba(255,255,255,.04);
  border-radius: 4px; overflow: hidden;
}
.macro-bar {
  height: 100%; border-radius: 4px;
  transition: width .7s cubic-bezier(.4,0,.2,1); width: 0;
  opacity: .85;
}
.macro-count { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }

/* tab header */
.tab-header { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); padding: 8px 18px;
  border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; font-family: inherit;
  transition: all .15s;
}
.tab-btn:hover { border-color: rgba(255,255,255,.18); color: var(--text); }
.tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab-count { font-size: 11px; font-weight: 400; opacity: .8; margin-left: 4px; }

/* list controls */
.list-controls { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; pointer-events: none; }
#group-search {
  width: 100%; padding: 9px 14px 9px 34px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; font-family: inherit;
  outline: none; transition: border-color .15s;
}
#group-search:focus { border-color: rgba(99,102,241,.5); }
#group-search::placeholder { color: var(--muted); }

.cat-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.cat-chip {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--muted); padding: 5px 12px;
  border-radius: 20px; cursor: pointer; font-size: 12px; font-family: inherit;
  transition: all .15s; user-select: none; white-space: nowrap;
}
.cat-chip:hover { border-color: rgba(255,255,255,.2); color: var(--text); }
.cat-chip.active {
  border-color: rgba(99,102,241,.5);
  background: rgba(99,102,241,.13); color: var(--accent-light);
}

/* group list */
.group-list { display: flex; flex-direction: column; gap: 5px; }
.group-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 11px 16px;
  display: flex; flex-direction: column;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.group-card:hover { border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.02); }
.group-rank { font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; letter-spacing: .3px; flex-shrink: 0; }
.group-rank.top3 { color: var(--gold); }
.group-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.group-name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.group-name { font-size: 13px; font-weight: 500; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-cat-badge {
  font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: 500;
  white-space: nowrap; flex-shrink: 0; opacity: .8;
}
.group-bar-track {
  height: 4px; background: rgba(255,255,255,.05); border-radius: 2px; overflow: hidden;
}
.group-bar { height: 100%; border-radius: 2px; transition: width .9s cubic-bezier(.4,0,.2,1); width: 0; }
.group-meta { text-align: right; flex-shrink: 0; }
.group-count { font-size: 14px; font-weight: 600; color: var(--text); }
.group-pct { font-size: 11px; color: var(--muted); }

/* idea search input */
.idea-search-wrap {
  position: relative; display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
  background: rgba(245,158,11,.04);
  border: 1px solid rgba(245,158,11,.18);
  border-radius: 8px;
  padding: 0 14px 0 34px;
}
.idea-search-wrap .search-icon {
  position: absolute; left: 12px; font-size: 13px; pointer-events: none; top: 50%; transform: translateY(-50%);
}
#idea-search {
  flex: 1; padding: 9px 0;
  background: none; border: none;
  color: var(--text); font-size: 13px; font-family: inherit;
  outline: none;
}
#idea-search::placeholder { color: var(--muted); }
.idea-search-hint { font-size: 11px; color: var(--muted); white-space: nowrap; }
.idea-search-wrap.active { border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.07); }

/* group card expandable */
.group-card-header {
  display: grid;
  grid-template-columns: 34px 1fr 90px 18px;
  align-items: center; gap: 12px;
  width: 100%;
}
.expand-icon {
  font-size: 10px; color: var(--muted);
  transition: transform .2s; user-select: none; text-align: right;
  flex-shrink: 0;
}
.group-card.group-expanded .expand-icon { transform: rotate(90deg); }
.group-card.group-expanded { border-color: rgba(255,255,255,.18); }

/* idea list panel */
.idea-list-panel {
  width: 100%;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.idea-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 0; color: var(--muted); font-size: 13px;
}
.loading-spinner.small { width: 18px; height: 18px; border-width: 2px; }
.idea-list { display: flex; flex-direction: column; gap: 1px; }
.idea-item {
  display: grid; grid-template-columns: 28px 1fr auto;
  align-items: baseline; gap: 8px;
  padding: 6px 4px; border-radius: 6px;
  transition: background .12s;
}
.idea-item:hover { background: rgba(255,255,255,.04); }
.idea-num { font-size: 11px; color: var(--muted); text-align: right; flex-shrink: 0; }
.idea-text { font-size: 13px; color: var(--text); line-height: 1.5; }
.idea-author { font-size: 11px; color: var(--muted); white-space: nowrap; flex-shrink: 0; }
.idea-more-btn {
  display: block; width: 100%; margin-top: 10px;
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  color: var(--muted); padding: 8px 14px;
  border-radius: 7px; cursor: pointer; font-size: 12px; font-family: inherit;
  text-align: center; transition: all .15s;
}
.idea-more-btn:hover { border-color: rgba(255,255,255,.18); color: var(--text); background: rgba(255,255,255,.07); }
.idea-more-total { opacity: .65; margin-left: 6px; }
.idea-count-info { text-align: center; padding: 8px; font-size: 11px; color: var(--muted); }

/* idea search results */
.idea-search-header {
  padding: 10px 4px 14px;
  font-size: 13px; color: var(--muted);
  border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.idea-search-total strong { color: var(--text); }
.idea-search-results { display: flex; flex-direction: column; gap: 5px; }
.idea-result-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px;
  transition: border-color .15s;
}
.idea-result-card:hover { border-color: rgba(255,255,255,.16); }
.idea-result-body { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.idea-result-num { font-size: 11px; color: var(--muted); flex-shrink: 0; min-width: 28px; }
.idea-result-text { font-size: 13px; color: var(--text); line-height: 1.5; }
.idea-result-text mark {
  background: rgba(245,158,11,.25); color: var(--gold);
  border-radius: 2px; padding: 0 2px;
}
.idea-result-meta { display: flex; justify-content: space-between; align-items: center; padding-left: 36px; }
.idea-result-author { font-size: 11px; color: var(--muted); }
.idea-result-group { font-size: 11px; font-weight: 500; }
.idea-results-more {
  display: block; width: 100%; margin-top: 12px;
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  color: var(--muted); padding: 10px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-family: inherit;
  text-align: center; transition: all .15s;
}
.idea-results-more:hover { border-color: rgba(255,255,255,.18); color: var(--text); }
.idea-search-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 32px 0; justify-content: center; color: var(--muted); font-size: 13px;
}

.no-results { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 14px; }

/* responsive additions */
@media (max-width: 680px) {
  .group-card-header { grid-template-columns: 26px 1fr 76px 16px; gap: 8px; }
  .idea-item { grid-template-columns: 22px 1fr auto; gap: 6px; }
  .idea-result-meta { flex-direction: column; align-items: flex-start; gap: 2px; }
}

footer {
  border-top: 1px solid var(--border);
  text-align: center; padding: 22px;
  font-size: 12px; color: var(--muted);
}

/* responsive */
@media (max-width: 680px) {
  nav { padding: 0 16px; }
  .logo { margin-right: 12px; }
  .nav-menu .nav-link { padding: 5px 8px; font-size: 12px; }
  .nav-email { display: none; }
  main { padding: 24px 16px 60px; }
  .macro-row { grid-template-columns: 110px 1fr 52px; gap: 10px; }
  .macro-row-label { font-size: 11px; }
  .stat-card { min-width: 120px; padding: 14px 18px; }
  .stat-num { font-size: 22px; }
  .group-name { font-size: 12px; }
}
@media (max-width: 420px) {
  .logo span { display: none; }
  .nav-menu .nav-link { padding: 5px 7px; }
}
