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

body {
  font-family: -apple-system, 'Segoe UI', 'Malgun Gothic', sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  font-size: 13px;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* ============ 사이드바 ============ */
#sidebar {
  width: 360px;
  background: #ffffff;
  border-right: 1px solid #e5e5ea;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 20px;
  border-bottom: 1px solid #e5e5ea;
  background: #ffffff;
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  color: #1d1d1f;
}

.section {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e5ea;
}

.section h3 {
  font-size: 12px;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.section label {
  display: block;
  font-size: 12px;
  color: #424245;
  margin-bottom: 6px;
  margin-top: 10px;
}

.section label:first-of-type {
  margin-top: 0;
}

.section label span {
  float: right;
  color: #007aff;
  font-weight: 600;
}

.section select,
.section input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  color: #1d1d1f;
}

.section input[type="range"] {
  width: 100%;
  margin: 4px 0 8px;
  accent-color: #007aff;
}

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  cursor: pointer;
  font-size: 13px;
  color: #1d1d1f;
}

label.check input {
  accent-color: #007aff;
}

/* ============ 결과 탭 ============ */
.results-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0;
  min-height: 0;
}

.tabs {
  display: flex;
  border-bottom: 1px solid #e5e5ea;
  background: #fafafa;
}

.tab {
  flex: 1;
  padding: 12px 8px;
  border: none;
  background: transparent;
  font-size: 12px;
  color: #86868b;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.tab.active {
  color: #007aff;
  border-bottom-color: #007aff;
  background: #fff;
  font-weight: 600;
}

.tab:hover {
  background: #f5f5f7;
}

.sort-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid #e5e5ea;
  background: #fff;
}

.sort-bar button {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #d2d2d7;
  border-radius: 4px;
  background: #fff;
  font-size: 11px;
  color: #424245;
  cursor: pointer;
}

.sort-bar button:hover {
  background: #f5f5f7;
}

#resultsList {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.result-item {
  padding: 12px;
  border: 1px solid #e5e5ea;
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s;
}

.result-item:hover {
  background: #f5f5f7;
  border-color: #007aff;
}

.result-item.active {
  background: #e8f2ff;
  border-color: #007aff;
}

.result-name {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.result-name input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: #1d1d1f;
  padding: 2px 4px;
  border-radius: 4px;
}

.result-name input:focus {
  outline: none;
  background: #fff;
  border: 1px solid #007aff;
}

.result-name .star {
  cursor: pointer;
  color: #d2d2d7;
  font-size: 16px;
}

.result-name .star.active {
  color: #ffd60a;
}

.result-name .addr-btn {
  padding: 2px 8px;
  border: 1px solid #d2d2d7;
  border-radius: 4px;
  background: #fff;
  font-size: 10px;
  cursor: pointer;
  color: #424245;
}

.result-row1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.result-capacity {
  font-size: 14px;
  font-weight: 600;
  color: #007aff;
}

.result-kind {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e8f2ff;
  color: #007aff;
}

.result-kind.bdk005 {
  background: #e8f9ee;
  color: #34c759;
}

.result-kind.installed {
  background: #ffe8e8;
  color: #ff3b30;
}

.result-kind.parking {
  background: #fff4d6;
  color: #b25e00;
}

.result-area,
.result-sido {
  font-size: 11px;
  color: #86868b;
}

/* ============ 지도 ============ */
#map-container {
  flex: 1;
  position: relative;
}

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

.map-controls {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.map-type {
  display: flex;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  overflow: hidden;
}

.map-type-btn {
  padding: 8px 16px;
  border: none;
  background: #fff;
  color: #424245;
  cursor: pointer;
  font-size: 13px;
}

.map-type-btn.active {
  background: #007aff;
  color: #fff;
}

.legend {
  background: #fff;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  font-size: 11px;
}

.legend div {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0;
  color: #424245;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.blue { background: #007aff; }
.dot.green { background: #34c759; }
.dot.red { background: #ff3b30; }
.dot.yellow { background: #ffcc00; }

/* ============ 팝업 ============ */
.maplibregl-popup-content {
  background: #fff !important;
  color: #1d1d1f !important;
  border-radius: 10px !important;
  padding: 16px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12) !important;
  min-width: 260px;
}

.popup-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: #1d1d1f;
}

.popup-name-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.popup-name-row input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  font-size: 12px;
}

.popup-name-row button {
  padding: 6px 10px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  background: #fff;
  font-size: 11px;
  cursor: pointer;
}

.popup-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 12px;
  border-bottom: 1px solid #f5f5f7;
}

.popup-row span {
  color: #86868b;
}

.popup-row strong {
  color: #007aff;
  font-weight: 600;
}

.popup-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
}

.popup-actions button {
  flex: 1;
  padding: 8px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}

.popup-actions button.active {
  background: #ffd60a;
  border-color: #ffd60a;
  color: #1d1d1f;
}

.popup-memo {
  width: 100%;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  font-size: 12px;
  font-family: inherit;
  resize: vertical;
  min-height: 50px;
}

/* ============ 모달 ============ */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 480px;
  max-width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.modal-header button {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: #86868b;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
}

.modal-body input {
  width: calc(100% - 80px);
  padding: 10px;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  font-size: 13px;
}

.modal-body > button {
  width: 70px;
  margin-left: 6px;
  padding: 10px;
  border: none;
  background: #007aff;
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

#addrResults {
  margin-top: 16px;
}

.addr-result {
  padding: 10px;
  border: 1px solid #e5e5ea;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: pointer;
  font-size: 12px;
}

.addr-result:hover {
  background: #f5f5f7;
  border-color: #007aff;
}

.addr-result-title {
  font-weight: 600;
  margin-bottom: 4px;
}

.addr-result-addr {
  color: #86868b;
  font-size: 11px;
}

/* ============ 로딩 ============ */
#loading {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#loading.hidden {
  display: none;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #e5e5ea;
  border-top-color: #007aff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loadingText {
  font-size: 13px;
  color: #424245;
}

/* ============ 토스트 ============ */
#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #1d1d1f;
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 9999;
}

#toast.show {
  opacity: 0.95;
}
