:root {
  --base-font-size: 16px;
  --bg: #f6f1e8;
  --bg-panel: rgba(255, 251, 245, 0.92);
  --surface: #fffdf8;
  --surface-strong: #f4ecdf;
  --border: rgba(67, 53, 37, 0.14);
  --border-strong: rgba(67, 53, 37, 0.24);
  --text: #2f2419;
  --muted: #7a6650;
  --primary: #0f6a56;
  --primary-soft: rgba(15, 106, 86, 0.12);
  --shadow: 0 18px 50px rgba(72, 53, 28, 0.1);
}

[data-theme="dark"] {
  --bg: #11161b;
  --bg-panel: rgba(21, 29, 36, 0.92);
  --surface: #182028;
  --surface-strong: #202b35;
  --border: rgba(210, 223, 233, 0.12);
  --border-strong: rgba(210, 223, 233, 0.24);
  --text: #edf3f7;
  --muted: #9fb2bf;
  --primary: #8fe3c0;
  --primary-soft: rgba(143, 227, 192, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  font-size: var(--base-font-size);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(215, 177, 114, 0.22), transparent 28%),
    radial-gradient(circle at top right, rgba(15, 106, 86, 0.16), transparent 28%),
    linear-gradient(180deg, #f4eee4 0%, var(--bg) 100%);
}

button,
input {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 24px));
  margin: 0 auto;
  padding: 14px 0 26px;
}

.hero,
.filters-panel,
.results-panel {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  align-items: center;
}

.hero-copy,
.hero-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

h1,
h2 {
  margin: 0;
  font-family: "Source Serif 4", serif;
  line-height: 1;
}

h1 {
  font-size: clamp(1.6rem, 3.6vw, 2.35rem);
  letter-spacing: -0.05em;
}

h2 {
  font-size: clamp(1.15rem, 2.4vw, 1.5rem);
  letter-spacing: -0.04em;
}

.font-controls,
.hero-tools {
  display: inline-flex;
  gap: 6px;
}

.font-button,
.theme-toggle,
.ghost-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  min-height: 36px;
  padding: 7px 11px;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.font-button:hover,
.theme-toggle:hover,
.ghost-button:hover,
.sort-button:hover {
  transform: translateY(-1px);
  border-color: var(--border-strong);
  background: var(--surface-strong);
}

.font-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.app-layout {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.filters-panel,
.results-panel {
  padding: 14px;
}

.filters-header,
.results-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.filters-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.filters-grid-compact {
  grid-template-columns: 1.3fr 1fr 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 0.82rem;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

input:focus {
  border-color: rgba(15, 106, 86, 0.45);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.range-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.range-group label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.range-group span,
.results-hint,
.field-hint,
.site-footer,
.empty-state {
  color: var(--muted);
}

.range-group span,
.results-hint,
.field-hint,
.site-footer {
  font-size: 0.78rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: min(100%, 250px);
}

.stat-card {
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
}

.stat-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-card strong {
  font-size: 1rem;
}

.table-shell {
  margin-top: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2e9da;
  padding: 0;
  text-align: left;
}

[data-theme="dark"] thead th {
  background: #22303a;
}

.sort-button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.sort-button.is-active {
  color: var(--primary);
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 0.88rem;
}

tbody tr:hover {
  background: rgba(239, 227, 207, 0.32);
}

.empty-state {
  padding: 22px 12px;
  text-align: center;
}

.site-footer {
  display: flex;
  justify-content: center;
  margin-top: 12px;
  padding-bottom: 2px;
}

.footer-visitors {
  opacity: 0.72;
}

.footer-visitors strong {
  font-weight: 600;
}

@media (max-width: 900px) {
  .filters-grid-compact {
    grid-template-columns: 1fr;
  }

  .results-toolbar {
    align-items: start;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 14px, 1180px);
    padding-top: 8px;
  }

  .hero,
  .filters-header {
    align-items: start;
    flex-direction: column;
  }

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

  .hero-copy,
  .hero-tools {
    width: 100%;
    justify-content: space-between;
  }

  .filters-panel,
  .results-panel {
    padding: 12px;
  }

  .stats-grid,
  .range-group {
    grid-template-columns: 1fr;
    width: 100%;
  }

  table {
    min-width: 560px;
  }
}
