:root {
  --bg: #f5efe4;
  --bg-strong: #f0e2c4;
  --panel: rgba(255, 252, 247, 0.78);
  --panel-strong: rgba(255, 248, 238, 0.92);
  --text: #1e2433;
  --muted: #5f6676;
  --line: rgba(30, 36, 51, 0.12);
  --accent: #af4f2b;
  --accent-soft: rgba(175, 79, 43, 0.15);
  --gray: #8f95a3;
  --blue: #2b6cb0;
  --teal: #0f8b8d;
  --amber: #d68c0b;
  --green: #32805d;
  --red: #bf3f49;
  --shadow: 0 24px 60px rgba(70, 53, 28, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Source Sans 3", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(175, 79, 43, 0.18), transparent 28%),
    radial-gradient(circle at right center, rgba(15, 139, 141, 0.14), transparent 22%),
    linear-gradient(180deg, #fbf5ec 0%, var(--bg) 60%, #efe4cf 100%);
}

a {
  color: inherit;
}

.page-shell {
  width: min(1400px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr);
  gap: 20px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.hero-meta,
.panel {
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 28px;
}

.hero-copy h1,
.panel h2 {
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin: 0;
}

.hero-copy h1 {
  font-size: clamp(2.4rem, 4vw, 4.8rem);
  max-width: 12ch;
}

.hero-text {
  margin: 18px 0 0;
  font-size: 1.1rem;
  line-height: 1.6;
  max-width: 64ch;
  color: var(--muted);
}

.eyebrow,
.section-label,
.meta-label {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--accent);
}

.hero-meta {
  padding: 20px;
  display: grid;
  gap: 12px;
  align-content: center;
}

.meta-chip {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(255, 243, 229, 0.72));
  border: 1px solid var(--line);
}

.meta-chip strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.1rem;
}

.dashboard {
  display: grid;
  gap: 20px;
}

.panel {
  padding: 22px;
}

.filters-panel {
  display: grid;
  gap: 18px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.filters-grid label {
  display: grid;
  gap: 8px;
  font-weight: 600;
  color: var(--muted);
}

.filters-grid input,
.filters-grid select,
.filters-grid button {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  font: inherit;
}

.filters-grid input,
.filters-grid select {
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.86);
}

.filter-actions {
  display: grid;
  gap: 10px;
  align-content: end;
}

.filters-grid button {
  cursor: pointer;
  background: linear-gradient(135deg, #1e2433, #3e4c63);
  color: white;
  border: 0;
  font-weight: 700;
}

.filters-grid button[type="reset"] {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--line);
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  padding: 20px;
  border-radius: 24px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.52);
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
}

.stat-card span:last-child {
  color: var(--muted);
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 18px;
}

.panel-heading.compact {
  margin-bottom: 12px;
}

.updated-at {
  margin: 0;
  color: var(--muted);
}

.chart-wrap {
  display: grid;
  gap: 16px;
}

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

.legend-item {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
}

.chart-frame {
  position: relative;
  width: 100%;
  overflow: auto;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(252, 246, 236, 0.9)),
    linear-gradient(90deg, transparent 0%, transparent 50%, rgba(175, 79, 43, 0.1) 50%, rgba(175, 79, 43, 0.1) 58%, transparent 58%);
}

#scatter-chart {
  display: block;
  width: 100%;
  min-width: 980px;
  height: auto;
}

.scatter-point {
  cursor: pointer;
}

.chart-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  max-width: 260px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(30, 36, 51, 0.94);
  color: white;
  pointer-events: none;
  box-shadow: 0 18px 50px rgba(18, 24, 38, 0.35);
  z-index: 10;
}

.chart-popup {
  position: absolute;
  top: 0;
  left: 0;
  max-width: 320px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.98);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(18, 24, 38, 0.18);
  z-index: 12;
}

.chart-popup p {
  margin: 0 0 10px;
  color: var(--muted);
}

.chart-popup a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  background: rgba(15, 139, 141, 0.12);
  color: var(--teal);
}

.chart-popup button {
  margin-left: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(30, 36, 51, 0.08);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.hidden {
  display: none;
}

.insights-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 20px;
}

.monthly-bars {
  display: grid;
  gap: 12px;
}

.month-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 44px;
  gap: 14px;
  align-items: center;
}

.month-row strong {
  font-family: "Space Grotesk", sans-serif;
}

.month-stack {
  display: flex;
  height: 20px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.month-stack span {
  display: block;
  height: 100%;
}

.detail-panel {
  min-height: 360px;
}

.detail-content {
  display: grid;
  gap: 14px;
}

.detail-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.detail-card {
  display: grid;
  gap: 14px;
}

.detail-kicker {
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.76rem;
}

.detail-card h3 {
  margin: 0;
  font-size: 1.5rem;
  font-family: "Space Grotesk", sans-serif;
}

.detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.detail-box,
.source-link,
.history-item {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
}

.detail-box span,
.history-item small,
.source-link small {
  display: block;
  color: var(--muted);
}

.source-link {
  text-decoration: none;
}

.source-link strong {
  display: block;
  margin-bottom: 4px;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.95rem;
}

.stage-badge,
.confidence-pill,
.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}

.source-list,
.history-list {
  display: grid;
  gap: 8px;
}

.source-pill {
  text-decoration: none;
  margin: 0 6px 6px 0;
  background: rgba(15, 139, 141, 0.11);
  color: var(--teal);
}

.muted {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .hero,
  .insights-grid {
    grid-template-columns: 1fr;
  }

  .filters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 1400px);
    padding-top: 18px;
  }

  .hero-copy,
  .hero-meta,
  .panel,
  .stat-card {
    border-radius: 22px;
  }

  .hero-copy h1 {
    font-size: 2.5rem;
  }

  .filters-grid,
  .stats-grid,
  .detail-meta {
    grid-template-columns: 1fr;
  }

  .month-row {
    grid-template-columns: 78px minmax(0, 1fr) 36px;
  }
}
