@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,700&family=Space+Grotesk:wght@400;500;700&display=swap");

:root {
  --ink: #102a43;
  --paper: #f9f8f3;
  --card: rgba(255, 255, 255, 0.88);
  --line: #d7dde5;
  --accent: #f97316;
  --accent-2: #0f766e;
  --accent-3: #0ea5e9;
  --accent-4: #f59e0b;
  --accent-5: #334155;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Space Grotesk", "Avenir Next", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #fdf7ed 0%, #e0f2fe 50%, #ecfeff 100%);
  min-height: 100vh;
}

.background-layer {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(249, 115, 22, 0.16) 0, transparent 35%),
    radial-gradient(circle at 80% 10%, rgba(14, 165, 233, 0.18) 0, transparent 40%),
    radial-gradient(circle at 75% 75%, rgba(15, 118, 110, 0.14) 0, transparent 38%);
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1140px;
  margin: 0 auto;
  padding: 2rem 1rem 3rem;
  display: grid;
  gap: 1rem;
}

.hero {
  display: grid;
  gap: 0.75rem;
  animation: reveal 500ms ease-out;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.75rem;
  font-weight: 700;
  color: #0369a1;
}

h1,
h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.1;
}

h2 {
  font-size: 1.3rem;
}

.subtitle {
  margin: 0;
  max-width: 72ch;
}

.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

button,
select {
  font: inherit;
}

.actions button {
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  background: linear-gradient(130deg, #0f766e 0%, #0369a1 100%);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.actions button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(3, 105, 161, 0.22);
}

.card {
  background: var(--card);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  padding: 1rem;
  backdrop-filter: blur(8px);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
  animation: reveal 650ms ease-out;
}

.controls {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.period-controls {
  display: grid;
  gap: 0.6rem;
}

.period-label {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.period-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.period-button {
  border: 1px solid #bfd0e2;
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  background: #edf2f7;
  color: #1e293b;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
}

.period-button:hover {
  background: #dbe5f1;
}

.period-button.is-active {
  border-color: transparent;
  background: linear-gradient(130deg, #0f766e 0%, #0369a1 100%);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(3, 105, 161, 0.2);
}

.tabs {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.tab-button {
  border: 1px solid #bfd0e2;
  border-radius: 999px;
  padding: 0.52rem 0.95rem;
  background: #edf2f7;
  color: #1e293b;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
}

.tab-button:hover {
  background: #dbe5f1;
}

.tab-button.is-active {
  border-color: transparent;
  background: linear-gradient(130deg, #0f766e 0%, #0369a1 100%);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(3, 105, 161, 0.2);
}

.controls label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
}

select {
  width: 100%;
  padding: 0.58rem 0.7rem;
  border-radius: 10px;
  border: 1px solid #9fb2c8;
  background: #fcfcfd;
}

.grid-layout {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

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

.about-placeholder {
  margin-top: 0.85rem;
  min-height: 220px;
  border: 1px dashed #9fb2c8;
  border-radius: 12px;
  padding: 0.9rem;
  color: #475569;
  background: #f8fafc;
}

.chart-caption {
  margin: 0.4rem 0 1rem;
  color: #334155;
}

.bar-chart {
  display: grid;
  gap: 0.7rem;
}

.bar-row {
  display: grid;
  gap: 0.4rem;
}

.bar-header {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.94rem;
}

.bar-label {
  font-weight: 600;
}

.bar-track {
  position: relative;
  width: 100%;
  height: 0.85rem;
  background: #e5eaf1;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  transform-origin: left center;
  animation: stretch 700ms ease forwards;
}

.bar-track-diverging {
  background: #edf2f7;
}

.bar-zero-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-1px);
  background: #94a3b8;
  z-index: 1;
}

.bar-fill-diverging {
  position: absolute;
  top: 0;
  height: 100%;
  animation: none;
  z-index: 2;
}

.bar-fill-diverging.is-positive {
  border-radius: 0 999px 999px 0;
}

.bar-fill-diverging.is-negative {
  border-radius: 999px 0 0 999px;
}

.table-card {
  overflow: hidden;
}

.table-wrapper {
  overflow-x: auto;
}

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

th,
td {
  padding: 0.58rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  background: #f1f5f9;
  font-size: 0.9rem;
}

tbody tr:hover {
  background: #f8fafc;
}

.footnote p {
  margin: 0.45rem 0 0;
  line-height: 1.45;
}

@keyframes stretch {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 700px) {
  .app-shell {
    padding-top: 1.2rem;
  }

  h2 {
    font-size: 1.1rem;
  }

  .card {
    border-radius: 14px;
    padding: 0.9rem;
  }
}
