:root {
  --bg: #f3efe6;
  --bg-deep: #ebe3d3;
  --surface: rgba(255, 252, 246, 0.9);
  --surface-strong: #fffdf8;
  --surface-tint: rgba(255, 249, 239, 0.88);
  --ink: #1f2b24;
  --muted: #5c665f;
  --line: rgba(47, 61, 52, 0.14);
  --line-strong: rgba(32, 50, 40, 0.18);
  --accent: #1c6b51;
  --accent-strong: #134c3a;
  --accent-soft: #dff0e7;
  --sand: #f1e3cd;
  --sand-ink: #86542f;
  --shadow-soft: 0 18px 44px rgba(43, 48, 43, 0.08);
  --shadow-card: 0 12px 30px rgba(49, 56, 49, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-pill: 999px;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 40px;
  --text-xs: 0.8rem;
  --text-sm: 0.92rem;
  --text-base: 1rem;
  --text-lg: 1.08rem;
  --text-xl: 1.28rem;
  --text-2xl: 1.85rem;
  --font-body: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  --font-display: "Newsreader", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  font-family: var(--font-body);
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(194, 118, 63, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(28, 107, 81, 0.12), transparent 28%),
    linear-gradient(180deg, #fcfaf5 0%, var(--bg) 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
}

.page-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-6) 20px 56px;
}

.hero,
.controls-panel,
.table-shell,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: var(--space-6);
  margin-bottom: var(--space-5);
  background:
    linear-gradient(135deg, rgba(255, 252, 246, 0.92), rgba(251, 246, 237, 0.88)),
    var(--surface);
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -60px -70px auto;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(28, 107, 81, 0.12), transparent 68%);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--sand-ink);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero h1 {
  max-width: 12ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.3rem, 4vw, 4rem);
  line-height: 0.98;
  font-weight: 700;
}

.hero-copy {
  max-width: 760px;
  margin: var(--space-3) 0 var(--space-4);
  color: var(--muted);
  font-size: var(--text-lg);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  align-items: center;
  color: var(--muted);
  font-size: var(--text-sm);
}

.hero-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(28, 107, 81, 0.18);
  border-radius: var(--radius-pill);
  background: rgba(223, 240, 231, 0.6);
  color: var(--accent-strong);
  font-size: var(--text-sm);
  font-weight: 800;
  text-decoration: none;
}

.hero-link:hover {
  background: rgba(223, 240, 231, 0.95);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.stat-card {
  min-height: 132px;
  padding: var(--space-4);
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(250, 245, 236, 0.9)),
    var(--surface);
  box-shadow: var(--shadow-card);
}

.stat-label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 700;
}

.stat-value {
  display: block;
  font-size: clamp(1.9rem, 3vw, 2.45rem);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.controls-panel {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--space-3);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.95), rgba(248, 243, 234, 0.88)),
    var(--surface);
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.control-group-wide {
  grid-column: span 2;
}

.control-actions {
  justify-content: flex-end;
}

label {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--ink);
  font-size: var(--text-sm);
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

input::placeholder {
  color: #7f8982;
}

input:focus,
select:focus,
button:focus {
  outline: none;
  border-color: rgba(28, 107, 81, 0.5);
  box-shadow: 0 0 0 4px rgba(28, 107, 81, 0.12);
}

button {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #1f7558, var(--accent-strong));
  color: white;
  font-size: var(--text-sm);
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(20, 76, 58, 0.18);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.results-header h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 2vw, 1.8rem);
  font-weight: 700;
}

.results-header p {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.table-shell {
  overflow: hidden;
  background: rgba(255, 252, 246, 0.94);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(226, 241, 232, 0.95), rgba(246, 251, 247, 0.98));
  color: var(--muted);
  text-align: left;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

th,
td {
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}

thead th:nth-child(1),
tbody td:nth-child(1) {
  width: 114px;
}

thead th:nth-child(2),
tbody td:nth-child(2) {
  width: 168px;
}

thead th:nth-child(4),
tbody td:nth-child(4) {
  width: 210px;
}

thead th:nth-child(5),
tbody td:nth-child(5) {
  width: 340px;
}

thead th:nth-child(6),
tbody td:nth-child(6) {
  width: 116px;
}

tbody tr:nth-child(even) {
  background: rgba(255, 250, 241, 0.52);
}

tbody tr:hover {
  background: rgba(223, 240, 231, 0.38);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.cell-primary,
.cell-date {
  display: inline-block;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.45;
}

.cell-secondary {
  display: inline-block;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.45;
}

.cell-subtext {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  line-height: 1.4;
}

.cell-date {
  white-space: nowrap;
  font-weight: 800;
  color: var(--accent-strong);
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 0.79rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.snapshot-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.snapshot-label {
  display: inline-block;
  min-width: 88px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pill-bucket {
  background: var(--accent-soft);
  border-color: rgba(28, 107, 81, 0.1);
  color: var(--accent-strong);
}

.pill-auth {
  background: rgba(237, 229, 212, 0.92);
  border-color: rgba(134, 84, 47, 0.1);
  color: var(--sand-ink);
}

.pill-neutral {
  background: rgba(242, 239, 233, 0.95);
  border-color: rgba(92, 102, 95, 0.14);
  color: #465048;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: rgba(28, 107, 81, 0.08);
  color: var(--accent-strong);
  font-size: var(--text-sm);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.link-button:hover {
  background: rgba(28, 107, 81, 0.14);
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
}

.empty-state h3 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
}

.hidden {
  display: none;
}

@media (max-width: 1160px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .control-group-wide {
    grid-column: span 2;
  }

  .table-shell {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 1040px;
    table-layout: auto;
  }

  thead th:nth-child(1),
  tbody td:nth-child(1) {
    width: 114px;
    min-width: 114px;
  }

  thead th:nth-child(2),
  tbody td:nth-child(2) {
    width: 168px;
    min-width: 168px;
  }

  thead th:nth-child(3),
  tbody td:nth-child(3) {
    min-width: 220px;
  }

  thead th:nth-child(4),
  tbody td:nth-child(4) {
    width: 210px;
    min-width: 210px;
  }

  thead th:nth-child(5),
  tbody td:nth-child(5) {
    width: 340px;
    min-width: 340px;
  }

  thead th:nth-child(6),
  tbody td:nth-child(6) {
    width: 116px;
    min-width: 116px;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 18px 14px 40px;
  }

  .hero,
  .controls-panel,
  .stat-card {
    padding-left: 16px;
    padding-right: 16px;
  }

  .hero {
    padding-top: 22px;
    padding-bottom: 22px;
  }

  .hero h1 {
    max-width: none;
    font-size: 2.45rem;
  }

  .hero-copy {
    font-size: var(--text-base);
  }

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

  .control-group-wide {
    grid-column: span 1;
  }

  .results-header {
    align-items: start;
  }

  .table-shell {
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  table {
    min-width: 0;
    table-layout: auto;
    border-spacing: 0 14px;
  }

  thead {
    display: none;
  }

  tbody {
    display: block;
  }

  tbody tr {
    display: block;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: rgba(255, 252, 246, 0.94);
    box-shadow: var(--shadow-soft);
  }

  tbody tr:nth-child(even),
  tbody tr:hover {
    background: rgba(255, 252, 246, 0.94);
  }

  tbody td {
    display: grid;
    grid-template-columns: minmax(82px, 96px) minmax(0, 1fr);
    gap: 12px;
    width: auto;
    padding: 12px 16px;
    align-items: start;
  }

  tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  thead th:nth-child(1),
  thead th:nth-child(2),
  thead th:nth-child(3),
  thead th:nth-child(4),
  thead th:nth-child(5),
  thead th:nth-child(6),
  tbody td:nth-child(1),
  tbody td:nth-child(2),
  tbody td:nth-child(3),
  tbody td:nth-child(4),
  tbody td:nth-child(5),
  tbody td:nth-child(6) {
    width: auto;
  }

  tbody td:last-child {
    border-bottom: 0;
  }

  .snapshot-item {
    gap: 6px;
  }

  .snapshot-label {
    min-width: 76px;
  }

  .link-button {
    width: max-content;
  }
}
