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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #FDF0E8;
  color: #2D1B10;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#header {
  background: #2D1B10;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 16px;
}

#header-left { display: flex; align-items: center; gap: 12px; }

#logo {
  font-size: 17px;
  font-weight: 600;
  color: #FAEEDA;
}

#tagline {
  font-size: 12px;
  color: #FAC775;
  background: rgba(255,255,255,0.1);
  padding: 3px 10px;
  border-radius: 20px;
}

#search-wrap { position: relative; }

#search-box {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 7px 14px;
  color: #FAEEDA;
  font-size: 13px;
  width: 240px;
  outline: none;
}

#search-box::placeholder { color: rgba(250,238,218,0.5); }
#search-box:focus { border-color: rgba(255,255,255,0.4); }

#search-results {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 280px;
  background: white;
  border-radius: 10px;
  border: 1px solid #F5C4B3;
  box-shadow: 0 4px 16px rgba(45,27,16,0.15);
  z-index: 9999;
  display: none;
}

.search-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 0.5px solid #FDF0E8;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-item:last-child { border-bottom: none; }
.search-item:hover { background: #FDF0E8; }
.search-item-name { font-size: 13px; font-weight: 500; color: #2D1B10; }
.search-item-state { font-size: 11px; color: #993C1D; }
.search-item-score { font-size: 12px; font-weight: 600; color: #D85A30; }

#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#map-container {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: #FDF0E8;
}

#legend {
  position: absolute;
  bottom: 24px;
  left: 16px;
  background: white;
  border-radius: 10px;
  padding: 10px 14px;
  border: 1px solid #F5C4B3;
  z-index: 999;
  font-size: 12px;
}

.legend-title {
  font-weight: 600;
  color: #4A1B0C;
  margin-bottom: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 4px;
  color: #2D1B10;
  font-size: 12px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

#panel {
  width: 320px;
  background: #FFF8F2;
  border-left: 1px solid #F5C4B3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

#panel-tabs {
  display: flex;
  border-bottom: 1px solid #F5C4B3;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 11px 4px;
  font-size: 12px;
  background: transparent;
  color: #993C1D;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  transition: all 0.15s;
}

.tab-btn.active {
  background: #FAEEDA;
  color: #4A1B0C;
  border-bottom: 2px solid #D85A30;
}

.tab-btn:hover:not(.active) { background: #FDF0E8; }

.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.tab-content.active { display: block; }

.hint {
  font-size: 12px;
  color: #993C1D;
  margin-bottom: 12px;
  line-height: 1.5;
}

#summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.scard {
  background: #FAEEDA;
  border-radius: 8px;
  padding: 10px 12px;
}

.scard.danger { background: #FAECE7; }

.scard-label {
  font-size: 11px;
  color: #993C1D;
  margin-bottom: 2px;
}

.scard-value {
  font-size: 22px;
  font-weight: 600;
  color: #4A1B0C;
}

.scard.danger .scard-value { color: #7B0000; }

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: #4A1B0C;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 14px 0 8px;
}

.rank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: #FAECE7;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  border-left: 3px solid #D85A30;
  transition: background 0.15s;
}

.rank-item:hover { background: #F5C4B3; }
.rank-item:nth-child(1) { border-left-color: #7B0000; }
.rank-item:nth-child(2) { border-left-color: #993C1D; }

.rank-name { font-size: 12px; font-weight: 600; color: #2D1B10; }
.rank-state { font-size: 11px; color: #993C1D; }
.rank-score { font-size: 13px; font-weight: 700; color: #D85A30; }
.rank-item:nth-child(1) .rank-score { color: #7B0000; }

.state-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 0.5px solid #F5C4B3;
}

.state-name { font-size: 12px; font-weight: 500; color: #2D1B10; }
.state-count { font-size: 11px; color: #993C1D; }
.state-score { font-size: 13px; font-weight: 600; color: #D85A30; }

.state-bar-wrap {
  height: 4px;
  background: #FAEEDA;
  border-radius: 2px;
  margin-top: 4px;
}

.state-bar {
  height: 4px;
  background: #D85A30;
  border-radius: 2px;
}

#d-header {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #F5C4B3;
}

#d-name {
  font-size: 18px;
  font-weight: 700;
  color: #2D1B10;
}

#d-state {
  font-size: 12px;
  color: #993C1D;
  margin-top: 2px;
}

#d-tier-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

#d-score-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.score-box {
  background: #FAEEDA;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}

.score-label {
  font-size: 10px;
  color: #993C1D;
  margin-bottom: 2px;
}

.score-val {
  font-size: 18px;
  font-weight: 700;
  color: #4A1B0C;
}

.indicator-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 0.5px solid #FAEEDA;
  font-size: 12px;
}

.ind-label { color: #2D1B10; }
.ind-val { font-weight: 600; color: #D85A30; }

.leaflet-container { background: #FDF0E8 !important; }

.leaflet-popup-content-wrapper {
  border-radius: 10px !important;
  border: 1px solid #F5C4B3 !important;
  box-shadow: 0 4px 16px rgba(45,27,16,0.15) !important;
}