*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --surface: #f8f9fa;
  --border: #dee2e6;
  --text: #212529;
  --text-secondary: #6c757d;
  --primary: #1a73e8;
  --primary-light: #e8f0fe;
  --green: #28a745;
  --yellow: #ffc107;
  --red: #dc3545;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}

header {
  background: var(--primary);
  color: #fff;
  padding: 1.5rem 2rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

header h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
header p { font-size: 0.9rem; opacity: 0.9; }
header a { color: #fff; text-decoration: underline; }

nav {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
}

nav a {
  color: #fff;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  transition: background 0.2s;
}

nav a:hover { background: rgba(255,255,255,0.3); }

.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem 2rem; }

/* Stats bar */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  flex: 1;
  min-width: 140px;
  text-align: center;
}
.stat-card .value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-card .label { font-size: 0.8rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; }

/* Dataset card grid */
.dataset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}
.dataset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: box-shadow 0.2s;
}
.dataset-card:hover { box-shadow: var(--shadow); }
.dataset-card h3 { font-size: 0.95rem; margin-bottom: 0.5rem; }
.dataset-card h3 a { color: var(--primary); text-decoration: none; }
.dataset-card h3 a:hover { text-decoration: underline; }
.dataset-card .thumb {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  border: 1px solid var(--border);
}
.dataset-card .meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.dataset-card .meta span { white-space: nowrap; }
.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-complete { background: #d4edda; color: #155724; }
.badge-partial { background: #fff3cd; color: #856404; }
.badge-missing { background: #f8d7da; color: #721c24; }

/* Table */
.table-container { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
th, td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th {
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  position: relative;
}
th:hover { background: #e9ecef; }
th .sort-arrow { margin-left: 0.25rem; font-size: 0.7rem; }
tr:hover { background: #f1f3f5; }
tr.row-ok { border-left: 3px solid var(--green); }
tr.row-partial { border-left: 3px solid var(--yellow); }
tr.row-missing { border-left: 3px solid var(--red); }

/* Filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  align-items: center;
}
.filters label { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.filters select, .filters input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: inherit;
}
.filters input[type="search"] { min-width: 180px; }
.filters .filter-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.filters .filter-group label { font-weight: 400; }

/* Detail page */
.detail-header { margin-bottom: 1.5rem; }
.detail-header h2 { font-size: 1.25rem; margin-bottom: 0.25rem; }
.detail-header .subtitle { font-size: 0.85rem; color: var(--text-secondary); }
.detail-heatmap {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.variable-table { margin-bottom: 2rem; }

/* Validation gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.gallery-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.gallery-item:hover { box-shadow: var(--shadow); }
.gallery-item img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}
.gallery-item .caption {
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}
.lightbox .close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  background: none;
  border: none;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

@media (max-width: 600px) {
  header { padding: 1rem; }
  .container { padding: 1rem; }
  .dataset-grid { grid-template-columns: 1fr; }
  .stats-bar { flex-direction: column; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters input[type="search"] { min-width: auto; }
}
