:root {
  color-scheme: light;
  --bg: #f5efe4;
  --surface: #fffaf2;
  --surface-strong: #f1e6d6;
  --ink: #191614;
  --muted: #6f665d;
  --accent: #f2a23a;
  --accent-strong: #e0674c;
  --teal: #1c746e;
  --teal-strong: #0f5853;
  --stroke: rgba(28, 26, 23, 0.1);
  --shadow: 0 20px 50px rgba(28, 26, 23, 0.12);
  --shadow-soft: 0 8px 18px rgba(28, 26, 23, 0.08);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Rubik", "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

.backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 10% 10%, rgba(242, 162, 58, 0.18), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(29, 127, 120, 0.2), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(224, 108, 74, 0.18), transparent 50%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent 60%);
  z-index: -2;
}

.backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
      rgba(28, 26, 23, 0.06) 1px,
      transparent 1px
    ),
    linear-gradient(90deg, rgba(28, 26, 23, 0.04) 1px, transparent 1px);
  background-size: 80px 80px;
  opacity: 0.5;
  z-index: -1;
}

.page {
  max-width: 1250px;
  margin: 0 auto;
  padding: 28px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

h1 {
  font-family: "Spectral", "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 3.2rem);
  margin: 0;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.hero {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
}

.hero::after {
  content: "";
  position: absolute;
  inset: -40% 40% auto auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 162, 58, 0.35), transparent 70%);
  opacity: 0.6;
  pointer-events: none;
}

.hero__badge {
  width: fit-content;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(29, 127, 120, 0.12);
  color: var(--teal-strong);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.source {
  font-size: 0.95rem;
  color: var(--muted);
}

.meta-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

a.source {
  text-decoration: none;
  border-bottom: 1px dashed rgba(28, 26, 23, 0.2);
  padding-bottom: 2px;
}

a.source:hover {
  color: var(--ink);
  border-bottom-color: rgba(28, 26, 23, 0.45);
}

.source a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed rgba(28, 26, 23, 0.25);
  padding-bottom: 2px;
}

.source a:hover {
  color: var(--ink);
  border-bottom-color: rgba(28, 26, 23, 0.45);
}

.last-update {
  font-size: 0.85rem;
  color: var(--muted);
}

.btn {
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:focus-visible {
  outline: 3px solid rgba(29, 127, 120, 0.25);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #1c1306;
  box-shadow: 0 12px 25px rgba(224, 103, 76, 0.25);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(224, 103, 76, 0.3);
}

.btn-primary:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  box-shadow: none;
  transform: none;
}

.btn-ghost {
  background: transparent;
  border-color: rgba(28, 26, 23, 0.2);
  color: var(--ink);
}

.btn-ghost:hover {
  border-color: rgba(28, 26, 23, 0.35);
  transform: translateY(-1px);
}

.cutoff-note {
  font-size: 0.9rem;
  color: var(--muted);
}

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

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 18px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 6px;
}

.stat-card.accent {
  background: linear-gradient(135deg, rgba(242, 162, 58, 0.22), rgba(224, 108, 74, 0.18));
  border-color: rgba(224, 108, 74, 0.2);
}

.stat-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat-value {
  font-family: "Spectral", "Times New Roman", serif;
  font-size: 1.6rem;
  font-weight: 700;
}

.stat-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.filters {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--stroke);
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas:
    "search"
    "region"
    "grade"
    "score"
    "toggle"
    "actions";
  gap: 14px 16px;
  align-items: start;
}

.control {
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
}

.control label {
  color: var(--muted);
  font-size: 0.85rem;
}

.control input:not([type="range"]),
.control select {
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fffdf7;
  box-shadow: inset 0 0 0 1px transparent;
  height: 42px;
}

.control input:focus,
.control select:focus {
  outline: none;
  border-color: rgba(29, 127, 120, 0.4);
  box-shadow: 0 0 0 3px rgba(29, 127, 120, 0.15);
}

.control select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='10' viewBox='0 0 16 10'%3E%3Cpath fill='%236f665d' d='M1.6 1.5 8 7.9l6.4-6.4 1.4 1.4L8 10 0 2.9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.control input[type="number"] {
  width: 84px;
  text-align: center;
  -moz-appearance: textfield;
}

.control input[type="number"]::-webkit-outer-spin-button,
.control input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.control input[type="search"] {
  width: 100%;
}

.control input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(242, 162, 58, 0.8), rgba(29, 127, 120, 0.6));
  outline: none;
}

.control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fffdf7;
  border: 2px solid rgba(29, 127, 120, 0.6);
  box-shadow: 0 4px 8px rgba(28, 26, 23, 0.2);
}

.control input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fffdf7;
  border: 2px solid rgba(29, 127, 120, 0.6);
  box-shadow: 0 4px 8px rgba(28, 26, 23, 0.2);
}

.control input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(242, 162, 58, 0.8), rgba(29, 127, 120, 0.6));
}

.control.search {
  grid-area: search;
}

.control.region {
  grid-area: region;
}

.control.grade {
  grid-area: grade;
}

.control.score {
  grid-area: score;
}

.control.toggle {
  grid-area: toggle;
}

.control.actions {
  grid-area: actions;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 96px;
  gap: 8px;
  align-items: center;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.toggle span {
  white-space: nowrap;
}

.toggle input {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: rgba(28, 26, 23, 0.15);
  position: relative;
  transition: background 0.2s ease;
  cursor: pointer;
}

.toggle input::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fffdf7;
  top: 3px;
  left: 4px;
  transition: transform 0.2s ease;
  box-shadow: 0 4px 8px rgba(28, 26, 23, 0.2);
}

.toggle input:checked {
  background: linear-gradient(135deg, rgba(29, 127, 120, 0.8), rgba(29, 127, 120, 0.5));
}

.toggle input:checked::after {
  transform: translateX(18px);
}

.control.toggles {
  align-self: end;
  padding-bottom: 6px;
  gap: 10px;
  align-content: end;
}

.control.actions {
  align-self: end;
}

.control.actions .btn {
  width: 100%;
}

.delta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.delta-up {
  background: rgba(29, 127, 120, 0.18);
  color: var(--teal-strong);
}

.delta-down {
  background: rgba(224, 103, 76, 0.18);
  color: #8b2c16;
}

.delta-same {
  background: rgba(108, 101, 92, 0.15);
  color: var(--muted);
}

.delta-new {
  background: rgba(242, 162, 58, 0.2);
  color: #824b00;
}

table th.task-column,
table td.task-column {
  display: none;
}

body.show-tasks table th.task-column,
body.show-tasks table td.task-column {
  display: table-cell;
}

body.show-tasks table {
  min-width: 2000px;
}

.table-section {
  display: grid;
  gap: 12px;
}

.table-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.results {
  font-weight: 600;
  color: var(--ink);
}

.status {
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(29, 127, 120, 0.1);
  color: var(--teal-strong);
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--stroke);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  font-size: 0.92rem;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-strong);
  text-align: left;
  padding: 14px 12px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--stroke);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease;
}

thead th:hover {
  background: rgba(242, 162, 58, 0.12);
}

thead th span {
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 4px;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid rgba(28, 26, 23, 0.06);
  white-space: nowrap;
}

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

tbody tr:hover {
  background: rgba(242, 162, 58, 0.08);
}

tbody tr.qualified {
  background: rgba(242, 162, 58, 0.12);
}

tbody tr.top-1 {
  background: rgba(29, 127, 120, 0.15);
}

tbody tr.top-2 {
  background: rgba(29, 127, 120, 0.1);
}

tbody tr.top-3 {
  background: rgba(29, 127, 120, 0.08);
}

.center {
  text-align: center;
}

.right {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.region-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.region-code {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(29, 127, 120, 0.12);
  color: var(--teal-strong);
  font-size: 0.75rem;
  font-weight: 600;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid transparent;
}

.pill.pass {
  background: rgba(242, 162, 58, 0.2);
  color: #824b00;
  border-color: rgba(242, 162, 58, 0.35);
}

.pill.out {
  background: rgba(108, 101, 92, 0.15);
  color: var(--muted);
}

.empty {
  text-align: center;
  padding: 30px;
  color: var(--muted);
}

[data-animate] {
  opacity: 0;
  transform: translateY(16px);
}

body.loaded [data-animate] {
  animation: fadeUp 0.6s ease forwards;
  animation-delay: var(--delay, 0s);
}

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

@media (max-width: 900px) {
  .page {
    padding: 20px 16px 60px;
  }

  .hero {
    padding: 22px;
  }

  table {
    min-width: 760px;
  }
}

@media (min-width: 720px) {
  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "search search"
      "region grade"
      "score score"
      "toggle actions";
    align-items: end;
  }
}

@media (min-width: 1100px) {
  .filters {
    grid-template-columns:
      minmax(240px, 1.4fr)
      minmax(180px, 0.9fr)
      minmax(260px, 1.4fr)
      auto
      auto;
    grid-template-areas:
      "search search search search search"
      "region grade score toggle actions";
    align-items: end;
  }

  .control.actions .btn {
    width: auto;
  }
}

@media (max-width: 720px) {
  .range-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-animate] {
    opacity: 1;
    transform: none;
  }

  body.loaded [data-animate] {
    animation: none;
  }
}
