/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  --bg:           hsl(210 40% 98%);
  --fg:           hsl(215 30% 12%);
  --card:         hsl(0 0% 100%);
  --primary:      hsl(198 90% 32%);
  --primary-fg:   hsl(0 0% 100%);
  --primary-glow: hsl(192 85% 48%);
  --secondary:    hsl(158 64% 38%);
  --secondary-fg: hsl(0 0% 100%);
  --muted:        hsl(210 40% 96%);
  --muted-fg:     hsl(215 16% 47%);
  --accent:       hsl(35 92% 55%);
  --border:       hsl(214 32% 91%);
  --radius:       0.5rem;
  --hero-grad:    linear-gradient(135deg, hsl(198 90% 32%), hsl(192 85% 48%));
  --shadow-sm:    0 2px 8px -2px hsl(215 30% 12% / 0.08);
  --shadow-lg:    0 20px 60px -10px hsl(215 30% 12% / 0.22);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.icon { width: 1rem; height: 1rem; flex-shrink: 0; }

/* ── Hero ────────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  background: var(--hero-grad);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.hero-dots {
  position: absolute;
  inset: 0;
  opacity: 0.1;
  background-image:
    radial-gradient(circle at 25% 30%, white 1px, transparent 1px),
    radial-gradient(circle at 75% 70%, white 1px, transparent 1px);
  background-size: 48px 48px;
}

.hero-body {
  position: relative;
  padding: 4rem 1.5rem;
}

.hero-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: rgba(255 255 255 / 0.8);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  color: white;
  max-width: 40rem;
  line-height: 1.15;
}

.hero-desc {
  margin-top: 1.25rem;
  font-size: 1.0625rem;
  color: rgba(255 255 255 / 0.85);
  max-width: 36rem;
  line-height: 1.6;
}

.hero-stats {
  margin-top: 2.5rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  max-width: 34rem;
}

.stat-card {
  border-radius: var(--radius);
  background: rgba(255 255 255 / 0.1);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255 255 255 / 0.15);
  padding: 0.75rem 1rem;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: rgba(255 255 255 / 0.7);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.stat-value {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
  color: white;
}

/* ── Main ────────────────────────────────────────────────────────────────── */
.main-section { padding: 2.5rem 1.5rem; flex: 1; }

/* ── Toolbar ─────────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

/* Tabs */
.tabs {
  display: flex;
  background: var(--muted);
  border-radius: var(--radius);
  padding: 0.25rem;
  gap: 2px;
}

.tab-btn {
  padding: 0.4rem 0.875rem;
  border: none;
  background: transparent;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-fg);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  line-height: 1.5;
}

.tab-btn.active {
  background: white;
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.tab-btn:not(.active):hover {
  color: var(--fg);
  background: rgba(255 255 255 / 0.5);
}

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.search-wrap { position: relative; }

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-fg);
  pointer-events: none;
}

.input {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--card);
  color: var(--fg);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px hsl(198 90% 32% / 0.15);
}

.search-input { padding-left: 2.25rem; width: 16rem; }

.select {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

.select:focus { border-color: var(--primary); }
.committee-select { max-width: 14rem; }

/* ── Result count ────────────────────────────────────────────────────────── */
.result-count {
  font-size: 0.875rem;
  color: var(--muted-fg);
  margin-bottom: 0.75rem;
}

.graph-hint { margin-bottom: 0.75rem; }

/* ── Catalog grid ────────────────────────────────────────────────────────── */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* ── Standard card ───────────────────────────────────────────────────────── */
.std-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.std-card:hover {
  border-color: hsl(198 90% 32% / 0.5);
  box-shadow: 0 4px 18px -4px hsl(198 90% 32% / 0.15);
}

.std-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.std-number {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
}

.std-title {
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color 0.15s;
  line-height: 1.45;
}

.std-card:hover .std-title { color: var(--primary); }

.std-scope {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted-fg);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  line-height: 1.5;
}

.std-footer {
  margin-top: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted-fg);
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.4;
}

.badge-primary   { background: var(--primary);   color: var(--primary-fg); }
.badge-secondary { background: var(--secondary); color: var(--secondary-fg); }
.badge-outline   { background: transparent; border: 1px solid var(--border); color: var(--muted-fg); }

/* ── Graph ───────────────────────────────────────────────────────────────── */
.graph-wrap {
  position: relative;
  width: 100%;
  height: 75vh;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.graph-container { width: 100%; height: 100%; }

.graph-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: var(--muted-fg);
  background: var(--card);
  z-index: 5;
  pointer-events: none;
}

/* Graph controls overlay */
.graph-controls {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 10;
}

.graph-ctrl-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255 255 255 / 0.92);
  backdrop-filter: blur(4px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  color: var(--fg);
  padding: 0;
}
.graph-ctrl-btn svg { width: 14px; height: 14px; }
.graph-ctrl-btn:hover:not(:disabled) { background: var(--muted); }
.graph-ctrl-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.graph-ctrl-btn:disabled { opacity: 0.35; cursor: default; }

.graph-ctrl-sep { height: 0.375rem; }

/* Graph legend */
.graph-legend {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  background: rgba(255 255 255 / 0.92);
  backdrop-filter: blur(4px);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted-fg);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.legend-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot-primary { background: hsl(198 90% 32%); }
.legend-dot-accent  { background: hsl(35 92% 55%); }

.legend-sep { width: 1px; height: 0.75rem; background: var(--border); }
.legend-hint { font-size: 0.6875rem; }

/* ── Dialog ──────────────────────────────────────────────────────────────── */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0 0 0 / 0.5);
  z-index: 200;
  padding: 2rem 1rem;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.dialog-overlay[hidden] { display: none; }

.dialog {
  position: relative;
  background: var(--card);
  border-radius: calc(var(--radius) * 2);
  box-shadow: var(--shadow-lg);
  max-width: 48rem;
  width: 100%;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin: auto;
  animation: dialog-in 0.18s ease;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.dialog-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 1;
}

.dialog-close:hover { background: var(--muted); }

.dialog-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.dialog-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.dialog-num {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
}

.dialog-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.35;
}

.dialog-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.dialog-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Fields ──────────────────────────────────────────────────────────────── */
.field-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-fg);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.field-value {
  font-size: 0.875rem;
  color: var(--fg);
  white-space: pre-wrap;
  line-height: 1.55;
}

.ext-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--primary);
  text-decoration: none;
}

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

/* ── Relationship chips ──────────────────────────────────────────────────── */
.rel-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-top: 0.375rem;
}

.rel-chip {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.4;
}

.rel-chip:hover {
  border-color: var(--primary);
  background: hsl(198 90% 32% / 0.05);
}

.rel-chip.no-detail {
  cursor: default;
  color: var(--muted-fg);
}

.rel-chip.no-detail:hover { border-color: var(--border); background: transparent; }

.empty-note {
  font-size: 0.875rem;
  color: var(--muted-fg);
}

/* ── Timeline chart ──────────────────────────────────────────────────────── */
.timeline-chart-wrap {
  overflow-x: auto;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem 0.75rem;
}
.timeline-chart-wrap:empty { display: none; }

.chart-bar-group rect  { transition: opacity 0.12s, fill 0.12s; }
.chart-bar-group:hover rect { fill: var(--primary-glow); opacity: 1 !important; }

.chart-drilldown-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.chart-back-btn {
  font-size: 0.8125rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--primary);
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.chart-back-btn:hover { background: var(--muted); }

.chart-drilldown-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
}

/* ── Timeline ────────────────────────────────────────────────────────────── */
.timeline { padding-bottom: 2rem; }

.timeline-group { margin-bottom: 2.5rem; }

.timeline-year-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.timeline-year-badge {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.timeline-year-divider {
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, var(--primary) 0%, var(--border) 100%);
  border-radius: 1px;
}

.timeline-year-count {
  font-size: 0.75rem;
  color: var(--muted-fg);
  white-space: nowrap;
  flex-shrink: 0;
}

.timeline-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--muted-fg);
  border-top: 1px solid var(--border);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .hero-stats          { grid-template-columns: 1fr 1fr; }
  .hero-body           { padding: 2.5rem 1.5rem; }
  .toolbar             { flex-direction: column; align-items: stretch; }
  .filters             { flex-direction: column; }
  .search-input        { width: 100%; }
  .catalog-grid        { grid-template-columns: 1fr; }
  .dialog-grid         { grid-template-columns: 1fr; }
  .committee-select    { max-width: 100%; }
}
