:root {
  --table-header-bg: #5b7596;
  --table-header-border: #d4af37;
  --table-header-text: #ffffff;
  --table-header-font: Georgia, "Times New Roman", Times, serif;
  --bg-deep: #0a0b0f;
  --bg-card: #12141c;
  --bg-elevated: #181b26;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaef;
  --muted: #8b92a8;
  --accent: #6ee7ff;
  --accent-dim: rgba(110, 231, 255, 0.15);
  --accent-2: #a78bfa;
  --danger: #f87171;
  --mark: rgba(255, 214, 102, 0.35);
  --radius: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, rgba(110, 231, 255, 0.08), transparent),
    radial-gradient(900px 500px at 90% 0%, rgba(167, 139, 250, 0.07), transparent), var(--bg-deep);
  line-height: 1.5;
}

.bg-grid {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 70%);
  opacity: 0.5;
  z-index: 0;
}

.header,
.main,
.footer {
  position: relative;
  z-index: 1;
}

.header {
  padding: 2rem 1.5rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
  animation: rise 0.7s ease both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 40px rgba(110, 231, 255, 0.25);
}

.header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
  animation: rise 0.65s ease both;
}

.card[data-animate] {
  animation: rise 0.65s ease both;
}

.results .card:nth-child(1) {
  animation-delay: 0.05s;
}
.results .card:nth-child(2) {
  animation-delay: 0.1s;
}
.results .card:nth-child(3) {
  animation-delay: 0.15s;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.stat:hover {
  border-color: rgba(110, 231, 255, 0.35);
  transform: translateY(-2px);
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 500;
  color: var(--accent);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.shimmer .stat-value {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

.search-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.search-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.search-row input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-row input:focus {
  border-color: rgba(110, 231, 255, 0.5);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn-primary {
  position: relative;
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1.5rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  color: #0a0b0f;
  background: linear-gradient(135deg, var(--accent), #9bdcff);
  box-shadow: 0 10px 30px rgba(110, 231, 255, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 120px;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.75;
  cursor: wait;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(10, 11, 15, 0.25);
  border-top-color: #0a0b0f;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.btn-primary.loading .btn-text {
  opacity: 0.7;
}

.btn-primary.loading .btn-spinner {
  display: block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-ghost {
  margin-top: 0.75rem;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: not-allowed;
}

.hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.hint code {
  font-family: var(--mono);
  font-size: 0.8em;
  color: var(--accent);
  background: var(--accent-dim);
  padding: 0.1em 0.35em;
  border-radius: 6px;
}

.error-msg {
  margin: 0.75rem 0 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.results {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.results-note {
  margin: 0;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
}

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
}

.table-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.badge {
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
}

.table-wrap {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table--wide {
  width: max-content;
  min-width: 100%;
}

.data-table--wide td:first-child {
  font-family: inherit;
  font-weight: 400;
  white-space: nowrap;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  box-sizing: border-box;
  background: var(--table-header-bg);
  color: var(--table-header-text);
  font-family: var(--table-header-font);
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: normal;
  text-align: center;
  vertical-align: middle;
  border: 1px solid var(--table-header-border);
  border-bottom: 1px solid var(--table-header-border);
  backdrop-filter: none;
}

.data-table thead tr:first-child th {
  border-top: 1px solid var(--table-header-border);
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.data-table td:first-child {
  font-family: var(--mono);
  font-weight: 500;
  white-space: nowrap;
}

mark.hl {
  background: var(--mark);
  color: inherit;
  padding: 0 0.05em;
  border-radius: 4px;
}

.empty {
  margin: 0;
  padding: 1.25rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.footer {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.footer code {
  font-family: var(--mono);
  color: var(--accent);
}

/* Author `display:grid` wins over the `hidden` attribute unless we reset it */
.global-loader[hidden] {
  display: none !important;
}

.global-loader {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(10, 11, 15, 0.55);
  backdrop-filter: blur(4px);
  animation: fade 0.25s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.loader-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@media (max-width: 640px) {
  .search-row {
    flex-direction: column;
  }

  .btn-primary {
    width: 100%;
  }
}
