:root {
  color-scheme: light;
  --ink: #0b0b0d;
  --ink-soft: #505057;
  --bg: #f7f7f8;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-solid: #ffffff;
  --shadow: 0 20px 45px rgba(12, 12, 16, 0.12);
  --border: rgba(12, 12, 16, 0.14);
  --border-soft: rgba(12, 12, 16, 0.08);
  --accent: #b6ff3a;
  --accent-strong: #5a8f00;
  --accent-soft: rgba(182, 255, 58, 0.18);
  --accent-faint: rgba(182, 255, 58, 0.08);
  --table-head: #f0f0f2;
  --row-border: rgba(12, 12, 16, 0.08);
  --row-adjusted: var(--accent-soft);
  --row-capped: var(--accent-faint);
  --pill-bg: rgba(12, 12, 16, 0.06);
  --note-bg: var(--accent-faint);
  --note-ink: var(--accent-strong);
  --toggle-shadow: 0 12px 24px rgba(12, 12, 16, 0.16);
  --backdrop:
    radial-gradient(
      circle at 12% 16%,
      rgba(182, 255, 58, 0.2),
      transparent 60%
    ),
    radial-gradient(
      circle at 86% 12%,
      rgba(182, 255, 58, 0.1),
      transparent 55%
    ),
    linear-gradient(140deg, #f7f7f8 0%, #fdfdfe 55%, #f0f0f2 100%);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3f3f5;
  --ink-soft: #b4b4bb;
  --bg: #15161b;
  --surface: rgba(22, 22, 28, 0.92);
  --surface-solid: #16161c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  --border: rgba(243, 243, 245, 0.16);
  --border-soft: rgba(243, 243, 245, 0.08);
  --accent: #b6ff3a;
  --accent-strong: #d6ff86;
  --accent-soft: rgba(182, 255, 58, 0.26);
  --accent-faint: rgba(182, 255, 58, 0.14);
  --table-head: #131316;
  --row-border: rgba(243, 243, 245, 0.06);
  --row-adjusted: var(--accent-soft);
  --row-capped: var(--accent-faint);
  --pill-bg: rgba(243, 243, 245, 0.1);
  --note-bg: rgba(182, 255, 58, 0.18);
  --note-ink: #e5ffb0;
  --toggle-shadow: 0 16px 34px rgba(0, 0, 0, 0.6);
  --backdrop:
    radial-gradient(
      circle at 18% 20%,
      rgba(182, 255, 58, 0.22),
      transparent 58%
    ),
    radial-gradient(
      circle at 82% 12%,
      rgba(182, 255, 58, 0.12),
      transparent 60%
    ),
    linear-gradient(140deg, #14151a 0%, #1a1c24 60%, #121319 100%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

code {
  font-family: "SF Mono", "Consolas", monospace;
}

a {
  color: var(--accent-strong);
  text-decoration-color: rgba(182, 255, 58, 0.4);
}

a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.backdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  z-index: -1;
}

.hero {
  padding: 56px 8vw 24px;
  display: flex;
  justify-content: center;
}

.hero__content {
  background: var(--surface);
  padding: 36px;
  border-radius: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-soft);
  max-width: 900px;
  width: 100%;
  animation: rise-in 0.65s ease-out both;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin: 0 0 12px;
  font-weight: 600;
}

.hero-title {
  font-family: "Fraunces", serif;
  font-size: clamp(2.2rem, 2.8vw, 3.2rem);
  margin: 0 0 12px;
}

.lede {
  margin: 0 0 24px;
  font-size: 1.05rem;
  color: var(--ink-soft);
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 500;
}

.field span {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

input,
select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-solid);
  font-size: 0.95rem;
  color: var(--ink);
}

input:focus-visible,
select:focus-visible,
.ghost:focus-visible,
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--accent-faint);
}

.theme-toggle {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--toggle-shadow);
  z-index: 2;
}

.theme-toggle .icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
}

.theme-toggle .icon-moon {
  display: none;
  fill: currentColor;
  stroke: none;
}

html[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

.search {
  display: grid;
  gap: 4px;
  font-weight: 500;
  min-width: 220px;
}

.search input {
  height: 38px;
}

.search span {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.table-toolbar .field {
  min-width: 160px;
}

.note {
  background: var(--note-bg);
  color: var(--note-ink);
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  animation: fade-in 0.5s ease-out 0.2s both;
}

.content {
  padding: 0 6vw 60px;
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 16px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  animation: rise-in 0.65s ease-out 0.08s both;
}

.toolbar-left {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-top: 18px;
}

.export {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.snapshot-inline {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.stat-pill {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-weight: 600;
}

.stat-pill strong {
  font-weight: 600;
  color: var(--accent-strong);
}

.ghost {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
}

.ghost:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-faint);
}

.table-wrap {
  background: var(--surface);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  animation: rise-in 0.65s ease-out 0.16s both;
}

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

thead th {
  position: sticky;
  top: 0;
  background: var(--table-head);
  text-align: left;
  padding: 12px 16px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable:hover {
  color: var(--accent-strong);
}

thead th.is-sorted {
  color: var(--accent-strong);
}

.sort-indicator {
  margin-left: 6px;
  font-size: 0.75rem;
}

tbody td {
  padding: 12px 16px;
  border-top: 1px solid var(--row-border);
  font-size: 0.95rem;
}

tbody tr.is-capped {
  background: var(--row-capped);
}

tbody tr.is-missing {
  opacity: 0.55;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--pill-bg);
  font-size: 0.75rem;
}

.is-adjusted-value {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--accent-faint);
  color: var(--accent-strong);
  font-weight: 600;
}

.is-muted {
  opacity: 0.55;
}

.footer {
  padding: 24px 6vw 40px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  display: grid;
  gap: 8px;
  animation: fade-in 0.5s ease-out 0.24s both;
}

.footer__links {
  font-weight: 600;
}

.footer__meta {
  color: var(--ink-soft);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 980px) {
  .hero {
    padding: 40px 6vw 20px;
  }
  .hero__content,
  .table-wrap,
  .table-toolbar {
    border-radius: 20px;
  }
  .theme-toggle {
    top: 14px;
    left: 14px;
  }
}

@media (max-width: 720px) {
  .hero__content {
    padding: 28px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
  }

  .toolbar-right {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .snapshot-inline {
    width: 100%;
  }

  .export {
    width: 100%;
    justify-content: flex-start;
  }
}
