:root {
  --ink: #1a1a1a; --muted: #6b6b6b; --faint: #9a9a9a; --line: #e4e4e4; --bg: #f2f2f2; --card: #fff; --soft: #f3f3f3; --head: #ececec;
  --neg: #c2412d;
  --map-base: #efefef; --map-sel: #d6d6d6; --map-nb: #e6e6e6; --map-sido: #8f8f8f;
  --radius: 10px;
  font-family: "Pretendard Variable", Pretendard, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px; -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.ph { font-size: 20px; line-height: 1; }

/* 틀: 왼쪽 메뉴 + 오른쪽 메인 */
.app { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100dvh; }
.side { background: var(--card); position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 24px 0 20px; }
.logo { display: flex; align-items: center; gap: 10px; padding: 0 22px 28px; font-size: 20px; font-weight: 600; letter-spacing: -0.02em; text-decoration: none; }
.logo .ph { font-size: 24px; }
#nav { display: grid; }
#nav a { display: flex; align-items: center; gap: 12px; padding: 13px 22px; text-decoration: none; color: #3a3a3a; border-left: 3px solid transparent; font-size: 15px; }
#nav a:hover { background: #f7f7f7; }
#nav a.on { background: var(--soft); border-left-color: var(--ink); color: var(--ink); font-weight: 600; }
.sidecard { margin: auto 16px 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; }
.sidecard b { font-size: 14px; font-weight: 600; }
.sidecard p { margin: 8px 0 0; font-size: 12px; color: var(--muted); line-height: 1.7; }

.app { background: var(--card); }
.body { border-left: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; background: var(--card); }
.topbar { height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 3; }
.crumb { font-size: 16px; font-weight: 500; }
.main { padding: 24px; display: grid; gap: 18px; align-content: start; min-width: 0; flex: 1; max-width: 1500px; width: 100%; }
.foot { padding: 8px 24px 24px; color: var(--faint); font-size: 12px; line-height: 1.6; max-width: 1500px; }

/* 공통 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 14px; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.head .muted { font-size: 13px; }
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.cardhead h2 { margin: 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 1px solid #cfcfcf; border-radius: 8px; background: #fff; font: inherit; font-size: 13px; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn .ph { font-size: 17px; }
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.icon { width: 36px; padding: 0; justify-content: center; }
.tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.pill { display: inline-block; padding: 3px 7px; border-radius: 6px; background: var(--soft); font-size: 12px; color: #3a3a3a; white-space: nowrap; }

/* 조건(가로 띠) */
.filters { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; padding: 14px 18px; }
.filters:empty { display: none; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); }
.field .row { display: flex; gap: 6px; flex-wrap: wrap; }
.field select, .field input[type=number], .field input[type=search] { height: 36px; padding: 0 10px; border: 1px solid #cfcfcf; border-radius: 8px; font: inherit; font-size: 13px; background: #fff; color: var(--ink); }
.field select { min-width: 120px; }
.field input[type=search] { width: 190px; }
#hsearch { width: min(560px, 100%); }
.field input[type=number] { width: 86px; }
.field select:focus, .field input:focus { outline: none; border-color: var(--ink); }
.checks { display: flex; gap: 14px; height: 36px; align-items: center; flex-wrap: wrap; }
.checks label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.checks input { accent-color: var(--ink); width: 15px; height: 15px; }
.range { display: flex; gap: 6px; align-items: center; }
.seg { display: inline-flex; border: 1px solid #cfcfcf; border-radius: 8px; overflow: hidden; height: 36px; }
.seg button { border: 0; background: #fff; padding: 0 14px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid #cfcfcf; }
.seg button.on { background: var(--ink); color: #fff; font-weight: 600; }
tr.hl td { background: #fff4cc !important; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 4px 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--soft); font-size: 12px; }
.chip.on { border-color: var(--ink); background: #fff; }
.chip button { border: 0; background: none; cursor: pointer; padding: 2px; display: grid; place-items: center; color: var(--muted); }
.chip button:hover { color: var(--ink); }
.chip .ph { font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: default; }
.hint { display: none; }

/* KPI 카드 */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 14px; position: relative; min-height: 104px; }
.kpi span { color: var(--muted); font-size: 13px; }
.kpi b { display: block; font-size: 22px; font-weight: 600; margin: 12px 0 8px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.kpi small { color: var(--faint); font-size: 12px; }
.kpi .ph { position: absolute; top: 14px; right: 14px; width: 36px; height: 36px; border-radius: 50%; background: #e3e3e3; display: grid; place-items: center; font-size: 19px; color: #2a2a2a; }

/* 탭 */
.tabs { display: flex; gap: 6px; }
.tabs a { height: 36px; display: inline-flex; align-items: center; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; color: var(--muted); }
.tabs a.on { border-color: var(--ink); color: var(--ink); font-weight: 600; }

/* 표 */
.tablewrap { overflow: auto; max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.eq { table-layout: fixed; }
table.eq col.mc { width: 20%; }
table.eq col.rc { width: 56px; }
table.eq th, table.eq td { padding-left: 12px; padding-right: 12px; }
table.eq td, table.eq th { overflow: hidden; text-overflow: ellipsis; }
table.eq th, table.eq td.mc, table.eq td.name { white-space: normal; word-break: keep-all; } /* 머리글·글자 열은 낱말 단위로 줄바꿈 */
table.eq thead th { vertical-align: bottom; line-height: 1.35; }
table.eq col.mc { min-width: 220px; }
th, td { padding: 12px 16px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child, .name { text-align: left; }
thead th { position: sticky; top: 0; background: var(--head); font-weight: 500; z-index: 1; }
tbody td { border-bottom: 1px solid #f1f1f1; }
tbody tr:hover td { background: #fafafa; }
th.sort { cursor: pointer; user-select: none; }
th.sort:hover { color: var(--muted); }
th.sort[aria-sort=ascending]::after { content: " ↑"; }
th.sort[aria-sort=descending]::after { content: " ↓"; }
td.rank { color: var(--faint); width: 1%; }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }
td .sub { color: var(--faint); font-size: 12px; margin-left: 8px; }
td.neg { color: var(--neg); }
tr.l1 td { font-weight: 600; background: #f7f7f7; }
tr.l2 td:first-child { padding-left: 28px; }
tr.l3 td:first-child { padding-left: 44px; color: var(--muted); }

/* 지도 */
.mapcard { padding: 0; overflow: hidden; }
.mapbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.hdmap { height: min(64vh, 660px); position: relative; touch-action: none; }
.hdmap svg { width: 100%; height: 100%; display: block; cursor: grab; background: #fbfbfb; }
.hdmap svg:active { cursor: grabbing; }
.hdmap .si path { fill: var(--map-base); stroke: #fff; stroke-width: .8; vector-effect: non-scaling-stroke; }
.hdmap .si path.nb { fill: var(--map-nb); }
.hdmap .si path.sel { fill: var(--map-sel); }
.hdmap .si path:hover { fill: #cacaca; }
.hdmap .sido path { fill: none; stroke: var(--map-sido); stroke-width: 1.1; vector-effect: non-scaling-stroke; pointer-events: none; }
.hdmap .lab { fill: var(--ink); stroke: #fff; paint-order: stroke; text-anchor: middle; dominant-baseline: middle; pointer-events: none; font-weight: 500; }
.hdmap .pts circle { stroke: #fff; stroke-width: .8; vector-effect: non-scaling-stroke; cursor: pointer; }
.mapnote { font-size: 12px; color: var(--faint); padding: 10px 18px; border-top: 1px solid var(--line); margin: 0; }
.legend { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.zoom { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 46px; text-align: center; font-size: 13px; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.linkbtn { margin-top: 16px; width: 100%; justify-content: center; }
.bars { display: grid; grid-template-columns: auto 1fr auto; gap: 8px 12px; align-items: center; font-variant-numeric: tabular-nums; }
.bars .bar { height: 10px; background: #3a3a3a; border-radius: 3px; }

@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .body { border-left: 0; }
  .field, .field .row, .field select, .field input[type=search] { width: 100%; }
  .field .row select { flex: 1; min-width: 0; }
  .bars { grid-template-columns: auto 1fr; } .bars span:nth-child(3n) { grid-column: 1 / -1; text-align: right; font-size: 12px; color: var(--muted); margin-top: -4px; }
  .side { z-index: 4; height: auto; padding: 0; flex-direction: row; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); }
  .logo, .sidecard { display: none; }
  #nav { display: flex; overflow-x: auto; }
  #nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 14px; white-space: nowrap; font-size: 14px; }
  #nav a.on { border-bottom-color: var(--ink); }
  .topbar { position: static; padding: 0 14px; }
  .topbar { display: none; }
    .main { padding: 14px; }
  .hdmap { height: 60vh; }
}
