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

:root {
  --bg: #f8f9fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --header-bg: #1e293b;
  --header-text: #f1f5f9;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
header {
  background: var(--header-bg);
  color: var(--header-text);
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
}
.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--header-text);
  text-decoration: none;
  white-space: nowrap;
}
.logo:hover { opacity: 0.85; }
.meta {
  font-size: 0.8rem;
  color: #94a3b8;
  white-space: nowrap;
  margin-left: auto;
}

/* Search */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 400px;
}
#search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #475569;
  border-radius: var(--radius);
  background: #334155;
  color: #f1f5f9;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s;
}
#search:focus { border-color: var(--primary); }
#search::placeholder { color: #94a3b8; }

.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  margin-top: 4px;
}
.search-results.active { display: block; }
.search-item {
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover, .search-item.active { background: #eef2ff; }
.search-item .count { color: var(--text-muted); font-size: 0.8rem; }

/* Main */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Home */
.home-hero--big {
  text-align: center;
  padding: 4rem 1rem 2rem;
}
.home-hero--big h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.home-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

/* Home search (centered, bigger) */
.home-search-wrap {
  position: relative;
  max-width: 560px;
  margin: 0 auto;
}
.home-search-input {
  width: 100%;
  padding: 0.85rem 1.25rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font-size: 1.1rem;
  outline: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.home-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.12);
}
.home-search-input::placeholder { color: #94a3b8; }

.home-search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  margin-top: 4px;
}
.home-search-results.active { display: block; }

/* Inline stats */
.home-stats-inline {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  flex-wrap: wrap;
}
.home-stats-inline strong {
  color: var(--text);
  font-weight: 700;
}
.home-stats-inline .dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #cbd5e1;
  display: inline-block;
}

/* Vintage chart on home */
.home-chart-section {
  margin-top: 2rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.home-chart-header {
  padding: 1.25rem 1.5rem 0;
}
.home-chart-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}
.home-chart-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.home-chart-container {
  position: relative;
  height: 480px;
  padding: 0.5rem 1rem 1rem;
}

/* Legacy stat cards (unused on home now but kept for reference) */
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  min-width: 140px;
}
.stat-card .value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary);
}
.stat-card .label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Breadcrumb */
.breadcrumb {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { margin: 0 0.4rem; }

/* Fund table */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.card-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
}
.card-header .subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead th {
  background: #f1f5f9;
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--text); }
thead th::after {
  content: "";
  display: inline-block;
  margin-left: 4px;
  opacity: 0.3;
  font-size: 0.7rem;
}
thead th:hover::after { content: "\25B2"; opacity: 0.5; }
thead th[data-sort="asc"]::after { content: "\25B2"; opacity: 1; }
thead th[data-sort="desc"]::after { content: "\25BC"; opacity: 1; }
thead th.num { text-align: right; }
tbody td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f8fafc; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #eef2ff; }

.fund-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.fund-link:hover { text-decoration: underline; }

/* Metrics cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.metric-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.metric-card .metric-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}
.metric-card .metric-value {
  font-size: 1.5rem;
  font-weight: 700;
}
.metric-card .metric-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}
.metric-card .metric-sub.stale {
  color: #d97706;
  font-style: italic;
}
.metric-card .metric-sub.stale::after {
  content: " (stale)";
}

/* Chart section */
.chart-section { margin-top: 1.5rem; }
.chart-tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1rem;
}
.chart-tab {
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.15s;
}
.chart-tab:hover { color: var(--text); border-color: #cbd5e1; }
.chart-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.chart-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  position: relative;
  height: 400px;
}

/* Sources table */
.sources-section { margin-top: 1.5rem; }
.source-link { color: var(--primary); text-decoration: none; font-size: 0.85rem; }
.source-link:hover { text-decoration: underline; }

/* Fund detail header */
.fund-header {
  margin-bottom: 1.5rem;
}
.fund-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}
.fund-header .fund-meta {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.fund-header .fund-meta span { display: flex; align-items: center; gap: 0.3rem; }

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 0.5rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Badge */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: #e2e8f0;
  color: var(--text-muted);
}
.badge-strategy { background: #dbeafe; color: #1e40af; }

/* Responsive */
@media (max-width: 768px) {
  .header-inner { gap: 0.75rem; }
  .meta { display: none; }
  .search-wrap { max-width: none; }
  .home-hero--big { padding: 2.5rem 1rem 1.5rem; }
  .home-hero--big h1 { font-size: 1.75rem; }
  .home-search-input { font-size: 1rem; padding: 0.75rem 1rem; }
  .home-chart-container { height: 340px; }
  .chart-container { height: 300px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
