@font-face {
  font-family: 'GmarketSans';
  font-weight: 700;
  font-style: normal;
  src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_2001@1.1/GmarketSansBold.woff') format('woff');
}

/* 라이트 모드 (기본) */
:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --surface2: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-dim: #64748b;
  --accent: #3b82f6;
  --accent-glow: rgba(59, 130, 246, 0.2);
  --seoul: #3b82f6;
  --gyeonggi: #10b981;
  --chungcheong: #f59e0b;
  --jeolla: #ef4444;
  --gyeongsang: #8b5cf6;
  --gangwon: #06b6d4;
  --jeju: #ec4899;
  --card-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --map-bg: #e5e7eb;
}



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

body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  transition: background 0.3s, color 0.3s;
}

/* 헤더 */
.header {
  min-height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 10px 24px;
  gap: 10px 12px;
  z-index: 1000;
  position: relative;
  flex-wrap: wrap;
  /* Allow wrapping on small screens */
  transition: background 0.3s, border-color 0.3s;
}

/* 콘도 도우미 바로가기 */
.condo-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  text-decoration: none;
  flex-shrink: 0;
}

.condo-desc {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.3;
  word-break: keep-all;
}

.condo-btn {
  font-size: 12px;
  font-weight: 700;
  background: var(--surface);
  padding: 6px 14px;
  border-radius: 20px;
  white-space: nowrap;
  transition: all 0.2s;
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.condo-sh {
  color: #242a38;
}

.condo-name {
  color: #6a9d20;
}

.condo-link:hover .condo-btn {
  background: var(--surface2);
  border-color: #6a9d20;
  box-shadow: 0 3px 10px rgba(106, 157, 32, 0.2);
  transform: translateY(-1px);
}

.header>* {
  flex-shrink: 0;
}

.mobile-menu-btn {
  display: none;
}

.header .logo {
  font-family: 'GmarketSans', 'Noto Sans KR', sans-serif;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-sh {
  color: #242a38;
}

.logo-health {
  color: #6a9d20;
}

.header .badge {
  background: var(--accent);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.header .subtitle {
  font-size: 12px;
  color: var(--text-dim);
}




.main {
  display: flex;
  height: calc(100vh - 56px);
  position: relative;
}

/* 사이드바 */
.sidebar {
  width: 380px;
  min-width: 380px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 2000;
  transition: transform 0.3s ease, background 0.3s, border-color 0.3s;
}

.sidebar-header-mobile {
  display: none;
}

.search-box {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.search-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px 10px 38px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-wrap {
  position: relative;
}

.search-wrap::before {
  content: "🔍";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

/* 필터 */
.filter-row {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.filter-btn {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* 리스트 */
.list-header {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.list-container {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.list-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.list-item:hover {
  background: var(--surface2);
}

.list-item.active {
  background: rgba(59, 130, 246, 0.08);
  border-left: 3px solid var(--accent);
}

.list-item-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-item-name .region-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.list-item-addr {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.list-item-tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.empty-state {
  padding: 30px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}

/* 지도 */
.map-wrap {
  flex: 1;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  background: var(--map-bg);
  transition: background 0.3s;
  z-index: 10;
}

/* 클러스터 마커 디자인 */
.marker-cluster {
  background-clip: padding-box;
  border-radius: 20px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.marker-cluster div {
  width: 30px;
  height: 30px;
  margin-left: 5px;
  margin-top: 5px;
  text-align: center;
  border-radius: 15px;
  font-size: 13px;
  font-weight: 800;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-cluster-small {
  background-color: rgba(59, 130, 246, 0.4);
}

.marker-cluster-small div {
  background-color: rgba(59, 130, 246, 0.95);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.marker-cluster-medium {
  background-color: rgba(16, 185, 129, 0.4);
}

.marker-cluster-medium div {
  background-color: rgba(16, 185, 129, 0.95);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.marker-cluster-large {
  background-color: rgba(245, 158, 11, 0.4);
}

.marker-cluster-large div {
  background-color: rgba(245, 158, 11, 0.95);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* 핀 마커 */
.custom-marker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-pin {
  width: 28px;
  height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  position: absolute;
  top: -30px;
  left: -14px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  border: 2.5px solid #ffeb3b;
  /* Yellow border */
  animation: markerDrop 0.4s ease-out;
}

.marker-pin::after {
  content: '';
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.marker-pulse {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  position: absolute;
  top: -34px;
  left: -18px;
  animation: pulse 2.5s ease-out infinite;
  opacity: 0;
}

@keyframes markerDrop {
  0% {
    top: -70px;
    opacity: 0;
  }

  60% {
    top: -24px;
  }

  100% {
    top: -30px;
    opacity: 1;
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.7);
    opacity: 0.6;
  }

  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

/* 팝업 커스텀 */
.leaflet-popup-content-wrapper {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  box-shadow: var(--card-shadow) !important;
  color: var(--text) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-tip {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
}

.leaflet-popup-close-button {
  color: var(--text-dim) !important;
  font-size: 20px !important;
  top: 8px !important;
  right: 10px !important;
}

.popup-content {
  padding: 18px;
  min-width: 300px;
  max-width: 320px;
}

.popup-name {
  font-size: 17px;
  font-weight: 800;
  margin-bottom: 4px;
}

.popup-addr {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.popup-scroll-area {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
  padding-right: 4px;
  scrollbar-width: thin;
}

.popup-scroll-area::-webkit-scrollbar {
  width: 4px;
}

.popup-scroll-area::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.stat-group {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

.stat-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.stat-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.stat-row:last-child {
  margin-bottom: 0;
}

.stat-badge {
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}

.stat-badge.highlight {
  color: var(--accent);
  border-color: rgba(59, 130, 246, 0.3);
  background: rgba(59, 130, 246, 0.05);
}

.stat-badge.doc {
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.05);
}

.stat-badge.promo {
  color: var(--province);
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.05);
  font-weight: 700;
}

.stat-badge.note {
  color: var(--jeju);
  border-color: rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.05);
}

/* 팝업 내 버튼들 */
.detail-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 6px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 700;
  padding: 10px;
  border-radius: 8px;
  transition: all 0.2s;
  margin-bottom: 8px;
  cursor: pointer;
}

.detail-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.popup-naver {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 8px;
  background: #03c75a;
  color: #fff !important;
  text-decoration: none !important;
  font-size: 14px;
  font-weight: 700;
  padding: 12px;
  border-radius: 8px;
  transition: background 0.2s;
  letter-spacing: 0.3px;
}

.popup-naver:hover {
  background: #02b350;
}

/* ✨ 상세 검사항목 모달창 CSS */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-content {
  background: var(--surface);
  color: var(--text);
  width: 90%;
  max-width: 540px;
  max-height: 85vh;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transform: translateY(20px);
  transition: transform 0.2s;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 16px;
  background: var(--surface2);
  border-radius: 16px 16px 0 0;
}

.modal-close {
  cursor: pointer;
  font-size: 22px;
  color: var(--text-dim);
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.6;
  scrollbar-width: thin;
}

.modal-detail-section {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface2);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.modal-detail-title {
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 10px;
  font-size: 14.5px;
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-detail-text {
  margin: 0;
  color: var(--text);
  word-break: keep-all;
}

/* 범례 & 통계 */
.stats-bar {
  position: absolute;
  top: 16px;
  right: 24px;
  display: flex;
  gap: 8px;
  z-index: 500;
}

.stat-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--card-shadow);
}

.stat-chip .num {
  font-weight: 800;
  color: var(--accent);
}

.legend {
  position: absolute;
  bottom: 30px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  z-index: 500;
  box-shadow: var(--card-shadow);
}

.legend-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 4px;
  font-weight: 500;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.1);
}

/* 모바일 반응형 처리 */
@media (max-width: 768px) {
  .header {
    padding: 0 16px;
  }

  .subtitle {
    display: none;
  }

  .condo-link {
    display: none;
  }

  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
  }

  .mobile-menu-btn:active {
    background: var(--border);
  }

  .sidebar {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    max-width: 100%;
    transform: translateX(-100%);
    border-right: none;
    box-shadow: var(--card-shadow);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-header-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 16px;
  }

  .close-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 6px;
    color: var(--text);
    font-size: 12px;
    cursor: pointer;
  }

  .stats-bar {
    top: 12px;
    right: 12px;
  }

  .legend {
    bottom: 20px;
    right: 12px;
    padding: 10px 14px;
  }

  .leaflet-control-zoom {
    display: none;
  }
}

/* ===== Mode Toggle ===== */
.mode-toggle {
  display: flex;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  margin-left: 12px;
  flex-shrink: 0;
}

.mode-btn {
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text-dim);
  transition: all 0.15s;
  white-space: nowrap;
}

.mode-btn.active {
  background: var(--accent);
  color: white;
}

.mode-btn:hover:not(.active) {
  color: var(--text);
}

/* ===== List View ===== */
.lv-tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.lv-tab {
  flex: none;
  padding: 11px 20px;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
}

.lv-tab:hover {
  background: var(--surface2);
  color: var(--text);
}

.lv-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

.lv-sub-wrapper {
  flex-shrink: 0;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  display: none;
}

.lv-sub-wrapper.visible {
  display: block;
}

.lv-search {
  width: 100%;
  max-width: 400px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  background: var(--surface);
  color: var(--text);
}

.lv-search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.lv-sub-tabs {
  display: flex;
  flex-wrap: wrap;
  padding: 4px 14px 8px;
  gap: 5px;
}

.lv-sub-tab {
  padding: 5px 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 16px;
  font-size: 11px;
  font-family: inherit;
  color: var(--text-dim);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.lv-sub-tab:hover {
  border-color: var(--accent);
  color: var(--text);
}

.lv-sub-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.lv-content {
  flex: 1;
  overflow: auto;
  padding: 16px;
  background: var(--bg);
}

.lv-panel {
  display: none;
}

/* List View Tables */
#listView .table-wrapper {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  overflow-x: auto;
}

#listView table {
  border-collapse: collapse;
  font-size: 11.5px;
}

#listView th,
#listView td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: center;
  vertical-align: middle;
  color: var(--text);
  line-height: 1.45;
  word-break: keep-all;
}

#listView th {
  white-space: nowrap;
}

#listView .header-row th {
  background: #1a365d;
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

#listView .title-row td,
#listView .title-cell {
  background: var(--surface2);
  color: var(--text);
  font-weight: 600;
  text-align: left !important;
}

#listView tr:nth-child(even):not(.header-row):not(.title-row) {
  background: var(--surface2);
}

#listView tr:hover:not(.header-row):not(.title-row) {
  background: rgba(59, 130, 246, 0.06);
}

#listView td:first-child {
  text-align: left;
}

#listView .info-header-row td {
  background: var(--surface2);
  font-weight: 600;
  border-bottom: 2px solid var(--accent);
}

#listView .info-header-row td:first-child,
#listView .info-header-row td:nth-child(2),
#listView .info-header-row td:nth-child(3) {
  background: #1a365d;
  color: #fff;
}

/* Wide table (종합/가족) frozen columns */
.lv-wide .table-wrapper {
  max-height: calc(100vh - 190px);
  overflow: auto;
}

.lv-wide table th,
.lv-wide table td {
  white-space: pre-wrap;
  word-break: keep-all;
  min-width: 110px;
}

.lv-wide table th {
  white-space: nowrap;
}

.lv-wide table th:nth-child(-n+3),
.lv-wide table td:nth-child(-n+3) {
  min-width: auto;
  white-space: nowrap;
  position: sticky;
  z-index: 4;
  background: var(--surface);
}

.lv-wide table th:nth-child(1),
.lv-wide table td:nth-child(1) {
  left: 0;
  min-width: 65px;
}

.lv-wide table th:nth-child(2),
.lv-wide table td:nth-child(2) {
  left: 65px;
  min-width: 75px;
}

.lv-wide table th:nth-child(3),
.lv-wide table td:nth-child(3) {
  left: 140px;
  min-width: 120px;
  border-right: 2px solid var(--accent);
}

.lv-wide .header-row th:nth-child(-n+3) {
  background: #1a365d !important;
  z-index: 10;
}

.lv-wide .title-row td:nth-child(-n+3) {
  background: var(--surface2);
}

.lv-wide tr:nth-child(even):not(.header-row):not(.title-row) td:nth-child(-n+3) {
  background: var(--surface2);
}

.lv-hosp table {
  width: auto;
}

/* Dark mode table fix */





@media (max-width: 768px) {
  .mode-toggle {
    margin-left: 8px;
    margin-right: 8px;
    transform: scale(0.9);
    transform-origin: left center;
  }

  .lv-tab {
    padding: 9px 12px;
    font-size: 11px;
  }

  .lv-content {
    padding: 8px;
  }
}