:root {
  --navy: #0f2d5c;
  --navy-2: #1d4383;
  --accent: #2b6cd4;
  --ink: #1b2433;
  --muted: #6b7686;
  --line: #e2e7ef;
  --bg: #f4f6fa;
  --card: #fff;
  --radius: 12px;
  --head-h: 64px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; word-break: keep-all;
}
button, input, select { font: inherit; color: inherit; }
.wrap { max-width: 1320px; margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-head { background: #fff; border-bottom: 1px solid var(--line); }
.head-inner { height: var(--head-h); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); }
.brand-mark { background: var(--navy); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .04em; padding: 7px 9px; border-radius: 7px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text b { font-size: 17px; font-weight: 700; }
.brand-text small { font-size: 11px; color: var(--muted); letter-spacing: .01em; }
.demo-flag { font-size: 12px; font-weight: 600; color: #8a5a00; background: #fff6df; border: 1px solid #f1d58f; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }

.page-title { background: linear-gradient(120deg, var(--navy) 0%, var(--navy-2) 100%); color: #fff; }
.page-title .wrap { padding-top: 26px; padding-bottom: 26px; }
.page-title h1 { margin: 2px 0 0; font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.crumb { margin: 0; font-size: 13px; opacity: .75; }

/* ---------- search ---------- */
.search {
  display: grid; grid-template-columns: 1fr 1.2fr 180px auto; gap: 12px; align-items: end;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: -22px 0 18px; position: relative; box-shadow: 0 6px 20px rgba(15, 45, 92, .07);
}
.search label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.search input, .search select {
  height: 42px; border: 1px solid #cfd7e3; border-radius: 8px; padding: 0 12px; background: #fff; font-size: 15px; color: var(--ink);
}
.search input:focus, .search select:focus { outline: 2px solid rgba(43, 108, 212, .25); border-color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 42px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 14px; }
.btn.line { background: #fff; border-color: #cfd7e3; color: var(--navy); }
.btn.line:hover { border-color: var(--navy); }
.btn.kakao { background: #fee500; color: #191919; }
.btn.naver { background: #03c75a; color: #fff; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: minmax(360px, 440px) 1fr; gap: 18px; height: calc(100vh - 120px); min-height: 560px; margin-bottom: 28px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px 0; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; }
.tab { border: 0; background: none; padding: 10px 12px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--navy); }
.summary { margin: 0; font-size: 13px; color: var(--muted); padding-bottom: 8px; }
.summary b { color: var(--navy); }

.results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.card { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; transition: background .12s, border-color .12s; }
.card + .card { margin-top: 2px; }
.card:hover { background: #f3f6fb; }
.card.is-active { background: #eaf1fd; border-color: #b9cff3; }
.card:focus-visible { outline: 2px solid var(--accent); }
.card-body { flex: 1; min-width: 0; }
.card-top { display: flex; align-items: baseline; gap: 6px; }
.name { font-size: 16px; color: var(--ink); }
.pos { font-size: 13px; color: var(--muted); }
.aff { font-size: 13.5px; color: #3c4757; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag { font-size: 11.5px; color: var(--navy-2); background: #edf2fb; border-radius: 4px; padding: 2px 7px; }
.card-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.sido { font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.more { font-size: 12px; font-weight: 600; color: var(--navy); background: #fff; border: 1px solid #cfd7e3; border-radius: 6px; padding: 3px 9px; cursor: pointer; }
.more:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.empty { text-align: center; color: var(--muted); padding: 48px 12px; }

.avatar { flex: none; width: 46px; height: 46px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 600; font-size: 14px; letter-spacing: -.02em; object-fit: cover; }
.avatar.sm { width: 30px; height: 30px; font-size: 11px; }
.avatar.xl { width: 104px; height: 104px; font-size: 30px; }

/* ---------- stats ---------- */
.stats { padding: 14px 16px; overflow-y: auto; flex: 1; }
.stats-note { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.bar-row { display: grid; grid-template-columns: 44px 1fr 32px; align-items: center; gap: 10px; width: 100%; padding: 6px 8px; background: none; border: 0; border-radius: 6px; cursor: pointer; text-align: left; }
.bar-row:hover:not(:disabled) { background: #f3f6fb; }
.bar-row:disabled { opacity: .4; cursor: default; }
.bar-row.is-active { background: #eaf1fd; }
.bar-label { font-weight: 600; font-size: 14px; }
.bar-track { height: 12px; background: #eef1f6; border-radius: 6px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--navy-2), var(--accent)); border-radius: 6px; transition: width .3s; }
.bar-val { font-variant-numeric: tabular-nums; text-align: right; font-weight: 600; color: var(--navy); }

/* ---------- map ---------- */
.map-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #dfe6ee; min-height: 0; }
#map { position: absolute; inset: 0; }
.map-legend { position: absolute; left: 10px; bottom: 10px; z-index: 500; margin: 0; background: rgba(255, 255, 255, .94); font-size: 12px; color: #3c4757; padding: 5px 10px; border-radius: 6px; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); display: flex; align-items: center; gap: 6px; }
.pin-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--navy); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--navy); }

.pin { width: 100%; height: 100%; border-radius: 50%; background: var(--navy); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .35); color: #fff; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; transition: transform .15s, background .15s; }
.pin.is-multi { background: var(--navy-2); }
.pin.is-active { background: #e8483b; transform: scale(1.3); }
.leaflet-tooltip { font-family: inherit; font-size: 12.5px; }

.hosp-popup .leaflet-popup-content { margin: 12px 14px; font-family: Pretendard, sans-serif; }
.hosp-popup .leaflet-popup-content-wrapper { border-radius: 10px; }
.pop-head strong { display: block; font-size: 15px; color: var(--navy); }
.pop-head span { font-size: 12px; color: var(--muted); }
.pop-list { list-style: none; margin: 8px 0; padding: 0; max-height: 200px; overflow-y: auto; border-top: 1px solid var(--line); }
.pop-list button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 2px; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; font-size: 13.5px; }
.pop-list button:hover { background: #f3f6fb; }
.pop-foot { font-size: 12px; color: var(--muted); }
.pop-foot a { color: var(--accent); }

/* ---------- modal ---------- */
dialog { border: 0; border-radius: 16px; padding: 28px; width: min(520px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(15, 45, 92, .3); color: var(--ink); }
dialog::backdrop { background: rgba(10, 22, 44, .55); }
.modal-close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; background: none; font-size: 26px; color: var(--muted); cursor: pointer; border-radius: 50%; }
.modal-close:hover { background: #f0f2f6; }
.detail-head { display: flex; gap: 18px; align-items: center; }
.detail-head h2 { margin: 0; font-size: 24px; }
.detail-head h2 small { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.detail-aff { margin: 2px 0 8px; color: #3c4757; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; background: var(--navy); color: #fff; border-radius: 4px; padding: 2px 8px; }
.badge.ghost { background: #edf2fb; color: var(--navy); }
.detail-dl { display: grid; grid-template-columns: 80px 1fr; gap: 10px 12px; margin: 22px 0; padding: 18px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-dl dt { color: var(--muted); font-size: 13.5px; font-weight: 600; }
.detail-dl dd { margin: 0; }
.detail-dl .tags { margin-top: 0; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-actions .btn { flex: 1 1 140px; }

.site-foot { border-top: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 12.5px; }
.site-foot .wrap { padding-top: 18px; padding-bottom: 24px; }

/* ---------- responsive: 모바일은 지도 상단 ---------- */
@media (max-width: 900px) {
  :root { --head-h: 56px; }
  .wrap { padding: 0 14px; }
  .brand-text small { display: none; }
  .brand-text b { font-size: 15px; }
  .demo-flag { font-size: 11px; padding: 3px 8px; }
  .page-title .wrap { padding-top: 16px; padding-bottom: 30px; }
  .page-title h1 { font-size: 21px; }
  .search { grid-template-columns: 1fr 1fr; padding: 12px; gap: 10px; }
  .search label:nth-child(3) { grid-column: 1 / 2; }
  .search .btn { align-self: end; }
  .layout { display: flex; flex-direction: column; height: auto; min-height: 0; gap: 12px; }
  .map-wrap { order: -1; height: 42vh; min-height: 260px; position: sticky; top: 0; z-index: 5; flex: none; }
  .panel { overflow: visible; }
  .results { overflow: visible; }
  .map-legend { font-size: 11px; }
  .detail-head .avatar.xl { width: 80px; height: 80px; font-size: 24px; }
  dialog { padding: 22px 18px; }
}

/* grid 자식 입력창이 최소폭 때문에 넘치지 않도록 */
.search > * { min-width: 0; }
.search input, .search select { width: 100%; min-width: 0; }

/* 고정 지도 + 자체 팝업 */
.map-main { position: absolute; inset: 0; background: #aad3df; }
.map-main.leaflet-container { cursor: default; }
.map-pop { position: absolute; z-index: 800; width: 260px; background: #fff; border-radius: 10px; box-shadow: 0 6px 24px rgba(15, 45, 92, .25); padding: 12px 14px; }
.map-pop-close { position: absolute; top: 4px; right: 6px; border: 0; background: none; font-size: 20px; color: var(--muted); cursor: pointer; width: 28px; height: 28px; border-radius: 50%; }
.map-pop-close:hover { background: #f0f2f6; }
.map-pop .pop-head { padding-right: 22px; }
.pin { border-width: 2px; font-size: 12px; }
@media (max-width: 900px) {
  .map-legend .legend-more { display: none; }
  .map-legend { left: auto; right: 8px; bottom: 26px; }
}
/* 타일 1px 겹침(어댑터) + 기본 plus-lighter 해제 → 이음선 없음 */
.leaflet-container img.leaflet-tile { mix-blend-mode: normal; }
