/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f4f8;
  color: #1a202c;
  min-height: 100vh;
}

/* ── Header ── */
header {
  background: #1a4f8a;
  color: white;
  padding: 1.5rem 2rem;
}
header h1 { font-size: 1.6rem; font-weight: 700; }
header .subtitle { margin-top: 0.25rem; opacity: 0.8; font-size: 0.9rem; }

/* ── Filters ── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  background: white;
  padding: 1rem 2rem;
  border-bottom: 1px solid #e2e8f0;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4a5568;
}
.filter-group select,
.filter-group input {
  padding: 0.45rem 0.75rem;
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  font-size: 0.95rem;
  background: white;
  min-width: 200px;
}
.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: #1a4f8a;
  box-shadow: 0 0 0 3px rgba(26,79,138,0.15);
}

.results-count {
  font-size: 0.85rem;
  color: #718096;
  align-self: flex-end;
  padding-bottom: 0.5rem;
}

/* ── Content layout ── */
.content {
  display: flex;
  height: calc(100vh - 160px);
  overflow: hidden;
}

/* ── Lake list panel ── */
.lake-list-panel {
  width: 320px;
  min-width: 240px;
  overflow-y: auto;
  background: white;
  border-right: 1px solid #e2e8f0;
}

#lake-list { list-style: none; }

#lake-list li {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #edf2f7;
  cursor: pointer;
  transition: background 0.1s;
}
#lake-list li:hover { background: #ebf4ff; }
#lake-list li.active { background: #1a4f8a; color: white; }
#lake-list li.active .lake-county { color: rgba(255,255,255,0.7); }

.lake-name { font-weight: 600; font-size: 0.95rem; }
.lake-county { font-size: 0.78rem; color: #718096; }
.survey-date { font-size: 0.75rem; color: #a0aec0; margin-left: auto; }

/* Ranked list rows */
.lake-row-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.lake-row-bottom {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 3px;
}

.rank-badge {
  font-size: 0.7rem;
  font-weight: 700;
  color: #718096;
  min-width: 2rem;
  flex-shrink: 0;
}
#lake-list li.active .rank-badge { color: rgba(255,255,255,0.6); }

.metric-badge {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 700;
  color: #1a4f8a;
  background: #ebf4ff;
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
}
#lake-list li.active .metric-badge {
  background: rgba(255,255,255,0.2);
  color: white;
}
#lake-list li.active .survey-date { color: rgba(255,255,255,0.55); }

.lake-row-trend {
  margin-top: 4px;
}
.trend-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  white-space: nowrap;
}
.trend-up   { background: #c6f6d5; color: #276749; }
.trend-down { background: #fed7d7; color: #9b2c2c; }
.trend-same { background: #e2e8f0; color: #4a5568; }
#lake-list li.active .trend-badge { opacity: 0.85; }

#no-results {
  padding: 2rem 1rem;
  text-align: center;
  color: #718096;
  font-size: 0.9rem;
}
.hidden { display: none; }

/* ── Detail panel ── */
.detail-panel {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
}

.detail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #a0aec0;
  font-size: 1rem;
}

/* ── Lake detail content ── */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.detail-header h2 { font-size: 1.4rem; color: #1a202c; }
.detail-header .meta { font-size: 0.85rem; color: #718096; margin-top: 0.25rem; }

.detail-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-start;
}

.maps-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #1a4f8a;
  color: white;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s;
}
.maps-link:hover { background: #154278; }
.maps-link svg { flex-shrink: 0; }

/* ── Survey loading ── */
.loading {
  color: #718096;
  font-size: 0.9rem;
  padding: 1rem 0;
}

/* ── Species tabs ── */
.species-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.species-tab {
  padding: 0.3rem 0.8rem;
  border: 1px solid #cbd5e0;
  border-radius: 20px;
  background: white;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.1s;
}
.species-tab:hover { border-color: #1a4f8a; color: #1a4f8a; }
.species-tab.active { background: #1a4f8a; color: white; border-color: #1a4f8a; }

/* ── Survey table ── */
.section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4a5568;
  margin-bottom: 0.6rem;
}

.survey-table-wrap { overflow-x: auto; margin-bottom: 2rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}
thead th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: #edf2f7;
  font-weight: 600;
  color: #4a5568;
  border-bottom: 2px solid #cbd5e0;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid #edf2f7; }
tbody tr:last-child { border-bottom: none; }
tbody td {
  padding: 0.5rem 0.75rem;
  vertical-align: top;
}
tbody tr:hover td { background: #f7fafc; }

.no-surveys {
  color: #a0aec0;
  font-size: 0.9rem;
  padding: 1rem 0;
}

/* ── Loading bar ── */
.loading-bar {
  position: relative;
  height: 32px;
  background: #ebf4ff;
  border-bottom: 1px solid #bee3f8;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  font-size: 0.8rem;
  color: #2b6cb0;
  font-weight: 600;
  overflow: hidden;
}
.loading-bar-inner {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: rgba(26,79,138,0.12);
  transition: width 0.2s ease;
  width: 0%;
}
#loading-label { position: relative; z-index: 1; }

/* ── Info bar ── */
.info-bar {
  background: white;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 2rem;
}
.info-bar details { padding: 0.6rem 0; }
.info-bar summary {
  font-size: 0.82rem;
  font-weight: 600;
  color: #4a5568;
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.info-bar summary::before {
  content: "▶";
  font-size: 0.6rem;
  color: #a0aec0;
  transition: transform 0.15s;
}
.info-bar details[open] summary::before { transform: rotate(90deg); }
.info-bar summary span { color: #4a5568; }

.info-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1rem 0 1.25rem;
}

.info-about {
  background: #f7fafc;
  border-left: 3px solid #1a4f8a;
  border-radius: 0 6px 6px 0;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #4a5568;
  line-height: 1.65;
}
.info-about a { color: #1a4f8a; text-decoration: none; }
.info-about a:hover { text-decoration: underline; }

.info-divider {
  height: 1px;
  background: #e2e8f0;
}

.info-terms {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}
.info-term {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.info-term p {
  font-size: 0.82rem;
  color: #718096;
  line-height: 1.55;
}
.info-label {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  background: #ebf4ff;
  color: #1a4f8a;
  width: fit-content;
  margin-bottom: 0.1rem;
}
.info-label.trend-up  { background: #c6f6d5; color: #276749; }
.info-label.trend-down { background: #fed7d7; color: #9b2c2c; }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 1.25rem 2rem;
  font-size: 0.82rem;
  color: #718096;
  border-top: 1px solid #e2e8f0;
  background: white;
  margin-top: 1rem;
}
footer a { color: #1a4f8a; text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .content { flex-direction: column; height: auto; }
  .lake-list-panel { width: 100%; height: 40vh; border-right: none; border-bottom: 1px solid #e2e8f0; }
  .detail-panel { padding: 1rem; }
  .info-bar { padding: 0 1rem; }
  .info-content { flex-direction: column; gap: 1rem; }
}
