:root {
  color-scheme: light;
  --bg: #f4efe6;
  --bg-2: #f9f5ee;
  --ink: #1b1b1b;
  --muted: #6e6459;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-border: rgba(26, 20, 12, 0.08);
  --accent: #e4572e;
  --accent-2: #1b998b;
  --shadow: 0 20px 50px rgba(18, 13, 7, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 800px at 15% -10%, #fff4df 0%, transparent 60%),
    radial-gradient(900px 700px at 100% 0%, #d9f1eb 0%, transparent 60%), var(--bg);
  min-height: 100vh;
}

.bg-accent {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(228, 87, 46, 0.12), rgba(27, 153, 139, 0.12));
  mix-blend-mode: multiply;
  opacity: 0.6;
}

h1,
h2,
h3 {
  font-family: "Fraunces", "Georgia", serif;
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 3vw, 3.4rem);
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.5rem;
}

p {
  margin: 0;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  font-weight: 600;
  color: var(--muted);
}

.lede {
  margin-top: 0.7rem;
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 38rem;
}

.hero {
  padding: 3rem clamp(1.5rem, 4vw, 4rem) 1.5rem;
  display: flex;
  gap: 2rem;
  align-items: flex-end;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  min-width: 280px;
}

.stat {
  background: var(--panel);
  padding: 1rem 1.25rem;
  border-radius: 16px;
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--muted);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.85fr) minmax(320px, 1.2fr) minmax(320px, 1.6fr);
  grid-template-areas:
    "filters list detail"
    "map map detail";
  gap: 1.5rem;
  padding: 1.5rem clamp(1.5rem, 4vw, 4rem) 3rem;
  position: relative;
  z-index: 1;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  backdrop-filter: blur(10px);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.filters {
  grid-area: filters;
}

.list {
  grid-area: list;
}

.detail {
  grid-area: detail;
}

.map-overview {
  grid-area: map;
}

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

.filter-grid {
  display: grid;
  gap: 0.9rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

input,
select {
  border-radius: 12px;
  border: 1px solid rgba(22, 16, 6, 0.15);
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid rgba(228, 87, 46, 0.25);
  border-color: rgba(228, 87, 46, 0.5);
}

.ghost {
  border: 1px solid rgba(27, 20, 10, 0.2);
  background: transparent;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.ghost:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dataset-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-height: 70vh;
  overflow: auto;
  padding-right: 0.4rem;
}

.dataset-card {
  border-radius: 16px;
  border: 1px solid rgba(22, 16, 6, 0.12);
  background: #fff;
  padding: 1rem;
  cursor: pointer;
  display: grid;
  gap: 0.6rem;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  opacity: 0;
  transform: translateY(8px);
  animation: rise 0.6s ease forwards;
  animation-delay: calc(var(--i) * 40ms);
  appearance: none;
}

.dataset-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 30px rgba(18, 13, 7, 0.12);
}

.dataset-card[data-selected="true"] {
  border-color: var(--accent);
  box-shadow: 0 20px 40px rgba(228, 87, 46, 0.18);
}

.dataset-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.dataset-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.badge {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(27, 153, 139, 0.12);
  color: #0f5e55;
}

.badge.orange {
  background: rgba(228, 87, 46, 0.12);
  color: #9c2e0f;
}

.badge.green {
  background: rgba(27, 153, 139, 0.15);
  color: #0a6b5f;
}

.badge.red {
  background: rgba(220, 38, 38, 0.12);
  color: #991b1b;
}

.timeline-bar {
  background: rgba(27, 153, 139, 0.06);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
}

.timeline-bar input[type="range"] {
  flex: 1 1 200px;
  cursor: pointer;
}

.timeline-bar button {
  min-width: 2.4rem;
  text-align: center;
}

.timeline-bar label {
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.kv-full {
  grid-column: 1 / -1;
}

.kv-full span:last-child {
  font-size: 0.82rem;
  line-height: 1.5;
}

.detail-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.map {
  height: 320px;
  border-radius: 14px;
  overflow: hidden;
}

.map-note {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.map-toolbar input,
.map-toolbar select {
  flex: 1 1 160px;
}

.map-toolbar button {
  border: 1px solid rgba(22, 16, 6, 0.2);
  background: #fff;
  border-radius: 10px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-weight: 600;
}

.map-status {
  font-size: 0.8rem;
  color: var(--muted);
}

.detail-summary {
  display: grid;
  gap: 0.6rem;
}

.detail-map {
  display: grid;
  gap: 0.6rem;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.kv span:first-child {
  font-weight: 600;
  color: var(--muted);
}

.files-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.files-toolbar input,
.files-toolbar select {
  flex: 1 1 150px;
}

.table-wrap {
  border-radius: 12px;
  border: 1px solid rgba(22, 16, 6, 0.1);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: rgba(27, 153, 139, 0.08);
}

th,
td {
  text-align: left;
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid rgba(22, 16, 6, 0.08);
}

tr:hover td {
  background: rgba(228, 87, 46, 0.05);
}

.file-actions button {
  border: none;
  background: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.file-meta {
  padding: 0.8rem 1rem;
  background: #fef9f2;
  border-left: 3px solid var(--accent);
  font-size: 0.8rem;
  white-space: pre-wrap;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.pagination button {
  border: 1px solid rgba(22, 16, 6, 0.2);
  background: #fff;
  border-radius: 10px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  border-radius: 16px;
  border: 1px dashed rgba(22, 16, 6, 0.2);
  background: rgba(255, 255, 255, 0.6);
}

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

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "filters"
      "list"
      "map"
      "detail";
  }

  .dataset-list,
  .detail-content {
    max-height: none;
  }

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

@media (max-width: 700px) {
  .hero-stats {
    width: 100%;
    grid-template-columns: 1fr;
  }

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