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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", sans-serif;
  background-color: #f8fafc;
  color: #333333;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 15px;
}

.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 1170px;
  margin: 0 auto;
}

/* Header */
.header {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, #80c85d 0%, #0aa4b4 100%);
  border-bottom: 3px solid #80c85d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  box-shadow: 0 4px 12px rgba(128, 200, 93, 0.25);
}

.header-title {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  margin-right: 16px;
}

.header-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.select-wrapper {
  position: relative;
}

select {
  background-color: #ffffff;
  color: #334155;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  padding: 10px 36px 10px 14px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  min-width: 160px;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

select:hover {
  border-color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

select:focus {
  outline: none;
  border-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.select-wrapper::after {
  content: "▼";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 10px;
  color: #80c85d;
  font-weight: 700;
}

/* Map Section */
.map-section {
  width: 100%;
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 16px;
  background-color: #f8fafc;
}


#map {
  width: 100%;
  height: 500px;
  background-color: #171717;
  border-radius: 12px;
  overflow: hidden;
}

.map-boxplot {
  display: flex;
  flex-direction: column;
}

/* Data Section */
.data-section {
  width: 100%;
  padding: 16px;
  background-color: #f8fafc;
}


/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-grid-5 {
  display: flex;
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-grid-5 .kpi-card {
  flex: 1;
  min-width: 0;
}

@media (max-width: 1170px) {
  .kpi-grid-5 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }
}

.kpi-card {
  background-color: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 12px;
  box-shadow: 0 2px 8px rgba(128, 200, 93, 0.08);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.kpi-card:hover {
  border-color: #80c85d;
  box-shadow: 0 4px 12px rgba(128, 200, 93, 0.2);
  transform: translateY(-2px);
}

.kpi-label {
  font-size: 13px;
  color: #64748b;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: #09408a;
  margin-bottom: 4px;
  line-height: 1.2;
  word-break: break-word;
}

.kpi-change {
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.3;
}

.kpi-change.positive {
  color: #80c85d;
}

.kpi-change.negative {
  color: #ef4444;
}

/* Chart Cards */
.chart-card {
  background-color: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(128, 200, 93, 0.08);
}

/* 지도 아래 박스플롯 카드는 margin 제거 (지도와 하단 라인 맞추기) */
.chart-card.map-boxplot {
  margin-bottom: 0;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.chart-title {
  font-size: 17px;
  font-weight: 600;
  color: #09408a;
}

.chart-subtitle {
  font-size: 14px;
  color: #64748b;
  margin-top: 4px;
}

/* 기간 선택 버튼 */
.chart-period-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
}

.period-btn {
  background-color: #f1f5f9;
  color: #64748b;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.period-btn:hover {
  background-color: #e2e8f0;
  border-color: #cbd5e1;
}

.period-btn.active {
  background-color: #80c85d;
  color: #ffffff;
  border-color: #80c85d;
  box-shadow: 0 2px 8px rgba(128, 200, 93, 0.3);
}

.period-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(128, 200, 93, 0.2);
}

.chart-container {
  width: 100%;
  height: 260px;
}

.chart-container.large {
  height: 380px;
}

.chart-container.sparkline {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px 8px;
  /* 스크롤바 스타일 */
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f1f5f9;
}

.chart-container.sparkline::-webkit-scrollbar {
  height: 8px;
}

.chart-container.sparkline::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.chart-container.sparkline::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.chart-container.sparkline::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Trend Card Styles */
.trend-card {
  background-color: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  transition: all 0.3s ease;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  /* 고정 너비로 가로 스크롤 지원 */
  min-width: 180px;
  flex-shrink: 0;
}

.trend-card:hover {
  border-color: #80c85d;
  box-shadow: 0 4px 12px rgba(128, 200, 93, 0.2);
  transform: translateY(-2px);
}

.trend-card-selected {
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
  border: 2px solid #80c85d;
  box-shadow: 0 4px 16px rgba(128, 200, 93, 0.3);
}

.trend-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.trend-card-rank {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  background-color: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
}

.trend-card-selected .trend-card-rank {
  color: #09408a;
  background-color: #bbf7d0;
}

.trend-card-name {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
  flex: 1;
  text-align: right;
}

.trend-card-selected .trend-card-name {
  color: #09408a;
}

.trend-card-value {
  font-size: 22px;
  font-weight: 700;
  color: #09408a;
  margin-bottom: 4px;
  line-height: 1;
}

.trend-card-unit {
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  margin-left: 2px;
}

.trend-card-change {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 10px;
}

/* SVG 차트 (고정 픽셀 크기) */
.trend-card-chart {
  width: 140px;
  height: 50px;
  margin: 0 auto 8px;
  display: block;
}

.trend-card-years {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #94a3b8;
  padding: 0 10px;  /* SVG paddingX(10px)와 동일 */
}

.trend-card-years span {
  font-weight: 500;
}

@media (max-width: 900px) {
  .trend-card-value {
    font-size: 20px;
  }
}

@media (max-width: 700px) {
  .trend-card {
    padding: 10px;
    min-width: 140px; /* 모바일에서 카드 크기 축소 */
  }

  .trend-card-name {
    font-size: 12px;
  }

  .trend-card-value {
    font-size: 18px;
  }

  .trend-card-chart {
    width: 100px; /* 모바일에서 차트 너비 축소 */
    height: 40px;
  }

  .trend-card-years {
    font-size: 8px;
    padding: 0 5px;
  }
}

/* 더 작은 모바일 화면 대응 */
@media (max-width: 500px) {
  .trend-card {
    min-width: 120px;
    padding: 8px;
  }

  .trend-card-rank {
    font-size: 10px;
    padding: 2px 6px;
  }

  .trend-card-name {
    font-size: 11px;
  }

  .trend-card-value {
    font-size: 16px;
  }

  .trend-card-unit {
    font-size: 12px;
  }

  .trend-card-change {
    font-size: 11px;
  }

  .trend-card-chart {
    width: 90px;
    height: 35px;
  }

  .trend-card-years {
    font-size: 7px;
    padding: 0 5px;
  }
}

/* Data Table */
.table-wrapper {
  background-color: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(128, 200, 93, 0.08);
}

.table-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.export-btn {
  background: linear-gradient(135deg, #80c85d 0%, #0aa4b4 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(128, 200, 93, 0.2);
}

.export-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(128, 200, 93, 0.3);
}

.table-container {
  overflow-x: auto;
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background-color: #f8fafc;
}

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #09408a;
  border-bottom: 2px solid #80c85d;
  white-space: nowrap;
}

/* Sticky columns for 순번 and 지역 */
th:nth-child(1),
th:nth-child(2) {
  position: sticky;
  background-color: #f8fafc;
  z-index: 10;
}

th:nth-child(1) {
  left: 0;
  min-width: 60px;
}

th:nth-child(2) {
  left: 60px;
  min-width: 120px;
  padding-left: 20px;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.08);
}

/* 지역 열 오른쪽에 고정 세로선 (가상 요소 사용) */
th:nth-child(2)::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  height: 100%;
  background-color: #cbd5e1;
  z-index: 1;
}

td {
  padding: 12px 16px;
  font-size: 14px;
  color: #334155;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

/* Sticky columns for data rows */
td:nth-child(1),
td:nth-child(2) {
  position: sticky;
  background-color: #ffffff;
  z-index: 5;
}

td:nth-child(1) {
  left: 0;
  min-width: 60px;
}

td:nth-child(2) {
  left: 60px;
  min-width: 120px;
  padding-left: 20px;
  font-weight: 500;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.08);
}

/* 지역 열 오른쪽에 고정 세로선 (가상 요소 사용) */
td:nth-child(2)::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 2px;
  height: 100%;
  background-color: #e2e8f0;
  z-index: 1;
}

/* Hover effect for sticky columns */
tbody tr:hover td:nth-child(1),
tbody tr:hover td:nth-child(2) {
  background-color: #f8fafc;
}

tbody tr:hover {
  background-color: #f8fafc;
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: #737373;
  font-size: 14px;
}


/* Responsive */
@media (max-width: 900px) {
  .map-section {
    grid-template-columns: 1fr;
  }

  #map {
    height: 400px;
  }

  .kpi-grid-5 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

}

@media (max-width: 900px) {
  .header {
    padding: 16px 20px;
  }

  .header-title {
    font-size: 18px;
  }

  select {
    min-width: 140px;
    font-size: 14px;
    padding: 9px 32px 9px 12px;
  }
}

@media (max-width: 700px) {
  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 16px;
  }

  .header-title {
    font-size: 17px;
    text-align: center;
    margin-right: 0;
    margin-bottom: 4px;
  }

  .header-controls {
    width: 100%;
    justify-content: center;
    gap: 8px;
  }

  .select-wrapper {
    flex: 1;
    min-width: 0;
  }

  select {
    width: 100%;
    min-width: 0;
    font-size: 14px;
    padding: 10px 32px 10px 12px;
  }

  .kpi-grid-5 {
    grid-template-columns: 1fr;
  }

  .kpi-card {
    padding: 16px;
  }

  .kpi-label {
    font-size: 14px;
    white-space: normal;
  }

  .kpi-value {
    font-size: 26px;
  }

  .kpi-change {
    font-size: 13px;
    flex-direction: row;
    gap: 4px;
  }
  
  #map {
    height: 350px;
  }
}

@media (max-width: 500px) {

  .header {
    padding: 14px 12px;
  }

  .header-title {
    font-size: 16px;
  }

  .header-controls {
    flex-direction: column;
    gap: 8px;
  }

  .select-wrapper {
    width: 100%;
  }

  select {
    font-size: 13px;
    padding: 9px 28px 9px 10px;
  }

  .chart-card {
    padding: 12px;
  }

  .chart-container {
    height: 220px;
  }

  .chart-container.large {
    height: 280px;
  }

  th, td {
    padding: 6px 8px;
    font-size: 11px;
  }
}
