/* ── 토큰 ─────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --surface-2: #f4f4f1;
  --page: #eeeeea;
  --text-1: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.18);
  --exp: #2a78d6;
  --imp: #eb6834;
  --pos: #2a78d6;
  --neg: #d03b3b;
  --neutral: #f0efec;
  --good: #006300;
  --bad: #d03b3b;
  --ring: #fcfcfb;
  --shadow: 0 1px 2px rgba(11,11,11,.06), 0 8px 24px rgba(11,11,11,.08);
  --sb-thumb: rgba(11, 11, 11, 0.22);
  --sb-thumb-hover: rgba(11, 11, 11, 0.34);
  --sb-thumb-active: rgba(42, 120, 214, 0.60);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --surface-2: #131312;
  --page: #0d0d0d;
  --text-1: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --exp: #3987e5;
  --imp: #d95926;
  --pos: #3987e5;
  --neg: #e66767;
  --neutral: #383835;
  --good: #0ca30c;
  --bad: #e66767;
  --ring: #1a1a19;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 10px 30px rgba(0,0,0,.55);
  --sb-thumb: rgba(255, 255, 255, 0.22);
  --sb-thumb-hover: rgba(255, 255, 255, 0.32);
  --sb-thumb-active: rgba(57, 135, 229, 0.65);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

/* 스크롤바 — OS 오버레이 스크롤바는 CSS 로 제어가 안 되므로(맥 기본값)
   네이티브를 완전히 끄고 app.js 가 그리는 자체 막대(.xsb)를 쓴다. */
.scroll-host { scrollbar-width: none; -ms-overflow-style: none; }
.scroll-host::-webkit-scrollbar { width: 0; height: 0; display: none; }
.xsb {
  position: absolute; top: 0; left: 0; z-index: 40;
  border-radius: 999px; background: var(--sb-thumb);
  opacity: 0; pointer-events: none; touch-action: none;
  transition: opacity .18s ease, background .12s ease;
}
.xsb-y { width: 6px; }
.xsb-x { height: 6px; }
.xsb.is-off { display: none; }
*:hover > .xsb, .xsb.is-live, .xsb.is-drag { opacity: 1; pointer-events: auto; }
.xsb:hover { background: var(--sb-thumb-hover); }
.xsb.is-drag { background: var(--sb-thumb-active); }

/* 네이티브 위젯 톤 맞추기 */
input[type="month"]::-webkit-calendar-picker-indicator { opacity: .45; cursor: pointer; }
input[type="month"]:hover::-webkit-calendar-picker-indicator { opacity: .8; }
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none;
  width: 12px; height: 12px; cursor: pointer; opacity: .45;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M3 3l6 6M9 3l-6 6' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") center/contain no-repeat;
}
input[type="search"]:hover::-webkit-search-cancel-button { opacity: .85; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-1);
  font-family: system-ui, -apple-system, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
}
h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--exp); outline-offset: 2px; }

/* ── 상단바 ───────────────────────────────────────────────────── */
.topbar {
  height: 54px;
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 900;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 26px; height: 26px; flex: none; display: block; }
.brand-text h1 { font-size: 14px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.brand-text p { font-size: 11px; color: var(--muted); white-space: nowrap; }
/* 분석 축 전환 */
.viewtabs { display: flex; gap: 3px; padding: 3px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.vtab {
  padding: 5px 13px; border-radius: 7px; border: 1px solid transparent; background: transparent;
  cursor: pointer; font-size: 12px; font-weight: 550; white-space: nowrap;
}
.vtab:hover { background: var(--surface-1); }
.vtab.is-on { background: var(--exp); border-color: var(--exp); color: #fff; }

/* 품목 축 화면 (지도 대체) */
.itemview { position: absolute; inset: 0; z-index: 500; background: var(--surface-2); display: flex; flex-direction: column; }
/* 품목 화면일 때는 지도를 아예 감춘다 — 안 그러면 leaflet 줌 컨트롤이 위로 뚫고 나온다 */
.mapwrap.hide-map #map { display: none; }
.iv-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-1); }
.iv-head .panel-note { margin-left: auto; }
.crumbs { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.crumb { padding: 3px 9px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface-1); cursor: pointer; font-size: 11.5px; font-weight: 520; }
.crumb:hover { background: var(--surface-2); }
.crumb.is-on { background: var(--exp); border-color: var(--exp); color: #fff; cursor: default; }
.crumb-sep { color: var(--muted); font-size: 11px; }
.iv-body { flex: 1; overflow: auto; padding: 10px 14px 18px; }
.iv-body.is-tree { padding: 10px; overflow: hidden; }
.modeswitch { display: flex; gap: 3px; padding: 3px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.mbtn { padding: 3px 10px; border-radius: 6px; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 11.5px; font-weight: 550; }
.mbtn:hover { background: var(--surface-1); }
.mbtn.is-on { background: var(--exp); border-color: var(--exp); color: #fff; }

/* 트리맵 — 넓이가 무역액, 색이 무역수지 */
.treemap { width: 100%; height: 100%; display: block; }
.tm-tile { cursor: pointer; transition: opacity .1s ease; }
.tm-tile:hover { opacity: .82; }
.tm-tile.is-on rect { stroke: var(--text-1); stroke-width: 2.5; }
.tm-code { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; pointer-events: none; }
.tm-name { font-size: 10.5px; pointer-events: none; }
.tm-val { font-size: 10.5px; font-variant-numeric: tabular-nums; pointer-events: none; opacity: .82; }
.tree-tip {
  position: absolute; z-index: 40; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: var(--shadow); padding: 9px 11px; min-width: 200px; max-width: 320px;
}

/* 목록 모드 — 표 형태 */
.ilist { display: grid; grid-template-columns: 46px minmax(160px, 1fr) 190px repeat(3, 92px) 62px; gap: 0 10px; align-items: center; }
.ilist > div { padding: 5px 0; }
.ihead > div { font-size: 10.5px; color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 6px; position: sticky; top: 0; background: var(--surface-2); }
.ihead .r, .irow .r { text-align: right; }
.irow { display: contents; cursor: pointer; }
.irow > div { border-bottom: 1px solid var(--border); font-size: 12px; font-variant-numeric: tabular-nums; }
.irow:hover > div { background: var(--surface-1); }
.irow.is-on > div { background: var(--surface-1); box-shadow: inset 0 1px 0 var(--exp), inset 0 -1px 0 var(--exp); }
.i-code { font-weight: 650; color: var(--text-2); }
.i-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 크기는 비중 열이 말해주므로, 막대는 수출/수입 구성비를 꽉 채워 보여준다 */
.i-track { height: 9px; width: 100%; border-radius: 3px; background: var(--grid); display: flex; overflow: hidden; }
.i-track i { height: 100%; display: block; }
.i-track .b-exp { background: var(--exp); }
.i-track .b-imp { background: var(--imp); }

.topbar-meta { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.chip-live {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12px; font-weight: 550; white-space: nowrap;
}
.chip-live .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent);
}
.meta-sub { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.topbar-actions { display: flex; gap: 6px; }
.btn {
  height: 30px; padding: 0 11px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--surface-1);
  font-size: 12px; font-weight: 550; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-icon { width: 30px; padding: 0; justify-content: center; }

/* ── 레이아웃 ─────────────────────────────────────────────────── */
.layout {
  height: calc(100vh - 54px);
  display: grid;
  grid-template-columns: 344px minmax(0, 1fr) 0px;
  transition: grid-template-columns .18s ease;
}
.layout.has-detail { grid-template-columns: 344px minmax(0, 1fr) 396px; }

.sidebar {
  background: var(--surface-2);
  border-right: 1px solid var(--border);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
}
.panel { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.sidebar .panel:last-child { border-bottom: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel-title {
  font-size: 11px; font-weight: 650; letter-spacing: .06em;
  text-transform: none; color: var(--text-2); margin-bottom: 9px;
}
.panel-head .panel-title { margin-bottom: 9px; }
.panel-note { font-size: 11px; color: var(--muted); font-weight: 450; letter-spacing: 0; }

/* 칩 · 폼 */
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.chip {
  padding: 4px 9px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-1);
  font-size: 11.5px; font-weight: 520;
}
.chip:hover { background: var(--surface-2); }
.chip.is-on { background: var(--exp); border-color: var(--exp); color: #fff; }
.range-row { display: flex; align-items: flex-end; gap: 7px; }
.range-dash { color: var(--muted); padding-bottom: 6px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.field > span { font-size: 11px; color: var(--muted); }
.field-full { margin-bottom: 9px; }
.field input, .field select {
  height: 30px; width: 100%; padding: 0 8px;
  border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--surface-1); color: var(--text-1);
  font: inherit; font-size: 12px;
}
/* 커스텀 드롭다운 — 네이티브 select 는 숨기고 값만 보관한다 */
.sel { position: relative; }
.sel-native { display: none; }
.sel-btn {
  width: 100%; height: 30px; padding: 0 9px 0 10px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--surface-1); cursor: pointer;
  font-size: 12px; font-weight: 500; text-align: left;
}
.sel-btn:hover { background: var(--surface-2); }
.sel-chev { color: var(--muted); flex: none; transition: transform .14s ease; }
.sel.is-open .sel-btn { border-color: var(--exp); }
.sel.is-open .sel-chev { transform: rotate(180deg); color: var(--exp); }
.sel-list {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 258px; overflow-y: auto; padding: 4px;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 9px; box-shadow: var(--shadow);
}
.sel-opt {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12px;
}
.sel-opt:hover { background: var(--surface-2); }
.sel-check { width: 12px; flex: none; color: var(--exp); }
.sel-opt.is-on { font-weight: 600; }
.sel-opt.is-on .sel-check::before { content: '✓'; font-size: 11px; }

.typefilter { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 9px; }
.typefilter label {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 8px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-1);
  font-size: 11.5px;
}
.typefilter input { accent-color: var(--exp); margin: 0; }

/* KPI */
.scope-note {
  display: flex; align-items: center; gap: 8px;
  margin: -2px 0 8px; padding: 5px 9px;
  border-radius: 7px; border: 1px solid color-mix(in srgb, var(--exp) 35%, transparent);
  background: color-mix(in srgb, var(--exp) 8%, transparent);
  font-size: 11px; color: var(--text-2);
}
.link-btn {
  margin-left: auto; padding: 0; border: 0; background: none; cursor: pointer;
  font-size: 11px; font-weight: 600; color: var(--exp); white-space: nowrap;
}
.link-btn:hover { text-decoration: underline; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.kpi {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 10px;
}
.kpi-label { font-size: 11px; color: var(--muted); }
.kpi-value { font-size: 19px; font-weight: 620; letter-spacing: -.02em; margin-top: 1px; }
.kpi-value .unit { font-size: 11.5px; font-weight: 500; color: var(--text-2); margin-left: 2px; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.delta { font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* 차트 */
.chart { width: 100%; height: 132px; position: relative; }
.chart-tip {
  position: absolute; z-index: 20; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); padding: 6px 9px; min-width: 118px;
}
.ct-h { font-size: 10.5px; color: var(--muted); margin-bottom: 3px; font-variant-numeric: tabular-nums; }
.ct-r { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.ct-r span { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); }
.ct-r i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.ct-r b { font-weight: 600; }
.chart-sm { height: 66px; margin-top: 2px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: hidden; }
.chart-cap { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.legend-inline { display: flex; gap: 10px; }
.lg { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--text-2); }
.sw { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.sw-exp { background: var(--exp); }
.sw-imp { background: var(--imp); }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: var(--axis); stroke-width: 1; }
.tick-text { fill: var(--muted); font-size: 9.5px; font-variant-numeric: tabular-nums; }
.series-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
.hit { fill: transparent; }

/* 순위 — 지도 우측 상단 플로팅 카드 */
.map-rank {
  position: absolute; top: 12px; right: 12px; z-index: 700;
  width: 266px; max-height: min(calc(100% - 44px), 520px);
  display: flex; flex-direction: column; overflow: hidden;
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow);
}
.rank-head {
  display: flex; align-items: center; gap: 8px; flex: none;
  width: 100%; padding: 9px 10px 9px 12px;
  background: transparent; border: 0; border-bottom: 1px solid var(--border);
  cursor: pointer; text-align: left;
}
.rank-head:hover { background: var(--surface-2); }
.rank-title { font-size: 11px; font-weight: 650; color: var(--text-2); white-space: nowrap; }
.rank-head .panel-note { margin-left: auto; white-space: nowrap; }
.rank-chev { color: var(--muted); flex: none; transition: transform .16s ease; }
.map-rank.is-collapsed { max-height: none; }
.map-rank.is-collapsed .rank-head { border-bottom: 0; }
.map-rank.is-collapsed .rank-chev { transform: rotate(-90deg); }
.map-rank.is-collapsed .ranklist { display: none; }
.ranklist { overflow-y: auto; padding: 5px; margin: 0; }
.rank-item {
  display: grid; grid-template-columns: 20px 1fr auto; gap: 8px; align-items: center;
  padding: 6px 8px; border-radius: 8px; cursor: pointer;
}
.rank-item:hover { background: var(--surface-2); }
.rank-item.is-on { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--exp); }
.rank-no { font-size: 11px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.rank-main { min-width: 0; }
.rank-name { font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar { height: 4px; border-radius: 2px; background: var(--grid); margin-top: 4px; overflow: hidden; display: flex; }
.rank-bar i { height: 100%; display: block; }
.rank-bar .b-exp { background: var(--exp); }
.rank-bar .b-imp { background: var(--imp); }
.rank-val { font-size: 12px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-val small { display: block; font-size: 10px; font-weight: 450; color: var(--muted); }

/* ── 지도 ─────────────────────────────────────────────────────── */
.mapwrap { position: relative; background: var(--surface-2); }
#map { position: absolute; inset: 0; background: var(--surface-2); }
.leaflet-container { font-family: inherit; background: var(--surface-2); }
:root[data-theme="dark"] .leaflet-control-attribution { background: rgba(0,0,0,.6); color: #999; }
:root[data-theme="dark"] .leaflet-control-attribution a { color: #bbb; }
.leaflet-control-attribution { font-size: 10px; }

/* 마커 */
.mk-wrap { display: grid; place-items: center; }
.mk-shape {
  position: relative;
  border: 1.5px solid color-mix(in srgb, var(--ring) 50%, transparent);
  box-shadow: 0 1px 2px rgba(0,0,0,.16);
  transition: transform .12s ease, border-color .12s ease;
}
.mk-wrap:hover .mk-shape, .mk-wrap.is-on .mk-shape { transform: scale(1.12); }
.mk-wrap:hover .mk-shape { border-color: var(--ring); }

/* 숨쉬듯 번쩍이는 맥박 — 주기와 위상을 관문마다 다르게 줘서 서로 어긋나게 한다.
   --bt(주기) / --bd(음수 지연=시작 위상)는 app.js 가 코드 해시로 넣는다. */
@keyframes mk-glow {
  0%, 100% { filter: brightness(1) saturate(1); }
  50% { filter: brightness(1.42) saturate(1.15); }
}
@keyframes mk-ping {
  0% { opacity: 0; transform: scale(1); }
  35% { opacity: .42; }
  100% { opacity: 0; transform: scale(1.45); }
}
.mk-shape {
  animation: mk-glow var(--bt, 4s) ease-in-out var(--bd, 0s) infinite;
}
.mk-shape::before {
  content: '';
  position: absolute; inset: -1.5px;
  border-radius: inherit;
  background: inherit;
  opacity: 0; pointer-events: none;
  animation: mk-ping var(--bt, 4s) ease-out var(--bd, 0s) infinite;
}
.mk-wrap:hover .mk-shape, .mk-wrap:hover .mk-shape::before { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .mk-shape, .mk-shape::before { animation: none; }
}
.mk-wrap.is-on .mk-shape { border-color: var(--text-1); }
.s-sea, .s-sido, .s-nation { border-radius: 50%; }   /* 시도·국가 축은 모양 구분이 없다 */
.s-air { border-radius: 4px; transform: rotate(45deg); }
.mk-wrap:hover .s-air, .mk-wrap.is-on .s-air { transform: rotate(45deg) scale(1.12); }
.s-land { border-radius: 3px; }
.s-customs { border-radius: 4px; }
.s-customs::after {
  content: ''; position: absolute; inset: 2px; border-radius: 2px;
  border: 1px dashed var(--ring);
}
.mk-label {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: 100%; margin-top: 2px; white-space: nowrap;
  font-size: 10px; font-weight: 600; color: var(--text-1);
  text-shadow: 0 0 3px var(--ring), 0 0 3px var(--ring), 0 0 3px var(--ring);
  pointer-events: none;
}

/* 범례 · 툴팁 */
.map-legend {
  position: absolute; left: 12px; bottom: 20px; z-index: 700;
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; max-width: 230px;
}
.lg-head { font-size: 10.5px; color: var(--muted); margin-bottom: 5px; }
.lg-ramp { display: flex; height: 8px; border-radius: 4px; overflow: hidden; }
.lg-ramp span { flex: 1; }
.lg-neg { background: linear-gradient(90deg, var(--neg), color-mix(in srgb, var(--neg) 25%, var(--neutral))); }
.lg-mid { background: var(--neutral); flex: 0 0 14px !important; }
.lg-pos { background: linear-gradient(90deg, color-mix(in srgb, var(--pos) 25%, var(--neutral)), var(--pos)); }
.lg-scale { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 3px; }
.lg-sizes { display: flex; align-items: flex-end; gap: 10px; }
.lg-sizes .s { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.lg-sizes .s i { display: block; border-radius: 50%; border: 1.5px solid var(--axis); background: transparent; }
.lg-sizes .s span { font-size: 9.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lg-shapes { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.lg-shape { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--text-2); }
.mk { width: 9px; height: 9px; background: var(--muted); display: inline-block; }
.mk-sea { border-radius: 50%; }
.mk-air { border-radius: 2px; transform: rotate(45deg); }
.mk-land { border-radius: 1px; }
.mk-customs { border-radius: 2px; box-shadow: inset 0 0 0 1px var(--surface-1); }

.map-tip {
  position: absolute; z-index: 800; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: var(--shadow);
  padding: 9px 11px; min-width: 190px; max-width: 260px;
}
.tip-name { font-size: 12.5px; font-weight: 620; }
.tip-sub { font-size: 10.5px; color: var(--muted); margin-bottom: 6px; }
.tip-row { display: flex; justify-content: space-between; gap: 12px; font-size: 11.5px; padding: 1px 0; font-variant-numeric: tabular-nums; }
.tip-row span:first-child { color: var(--text-2); display: inline-flex; align-items: center; gap: 5px; }
.tip-row b { font-weight: 600; }
.map-loading {
  position: absolute; inset: 0; z-index: 750; display: none;
  align-items: center; justify-content: center; gap: 9px;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  font-size: 12px; color: var(--text-2);
}
.map-loading.is-on { display: flex; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--axis); border-top-color: var(--exp);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 상세 패널 ────────────────────────────────────────────────── */
.detail { background: var(--surface-2); border-left: 1px solid var(--border); overflow: hidden; }
.detail-inner { height: 100%; overflow-y: auto; padding: 0 0 20px; }
.d-head { padding: 14px; border-bottom: 1px solid var(--border); background: var(--surface-1); position: sticky; top: 0; z-index: 5; }
.d-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.d-name { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.d-tags { display: flex; gap: 5px; margin-top: 5px; flex-wrap: wrap; }
.tag {
  font-size: 10.5px; padding: 2px 7px; border-radius: 5px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.tag-pos { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 35%, transparent); }
.tag-neg { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 35%, transparent); }
.d-sec { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.d-sec:last-child { border-bottom: 0; }
.d-title { font-size: 11px; font-weight: 650; color: var(--text-2); margin-bottom: 9px; display: flex; align-items: center; gap: 10px; }
.d-title .legend-inline { font-weight: 450; }
.dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; font-size: 12px; }
.dl dt { color: var(--text-2); }
.dl dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.share-bar { height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; margin-top: 6px; }
.share-bar i { display: block; height: 100%; background: var(--exp); }

/* 표 */
.tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.tbl th, .tbl td { padding: 5px 7px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th {
  position: sticky; top: 0; background: var(--surface-1); z-index: 2;
  font-weight: 600; color: var(--text-2); font-size: 10.5px; cursor: pointer; user-select: none;
}
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th.sortable::after { content: ''; }
.tbl th.is-sorted::after { content: ' ▾'; color: var(--exp); }
.tbl th.is-sorted.asc::after { content: ' ▴'; }
.tbl td { font-variant-numeric: tabular-nums; }
.tbl tbody tr:hover { background: var(--surface-1); }
.tbl .minibar { display: inline-block; height: 4px; border-radius: 2px; background: var(--exp); vertical-align: middle; margin-left: 6px; }
.num-pos { color: var(--pos); }
.num-neg { color: var(--neg); }
.tbl-wrap { overflow: auto; max-height: 260px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-1); }

/* ── 모달 ─────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.42); display: grid; place-items: center; padding: 24px; }
.modal-box {
  width: min(1100px, 100%); height: min(760px, 100%);
  background: var(--surface-1); border-radius: 14px; border: 1px solid var(--border);
  box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.modal-actions { display: flex; gap: 6px; }
.tabs { display: flex; gap: 4px; }
.tab { padding: 5px 11px; border-radius: 7px; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 12px; font-weight: 550; }
.tab:hover { background: var(--surface-2); }
.tab.is-on { background: var(--surface-2); border-color: var(--border-strong); }
.modal-body { flex: 1; overflow: auto; padding: 0; }
.modal-body .tbl th { background: var(--surface-1); }

/* 토스트 */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 1200; padding: 9px 15px; border-radius: 9px;
  background: var(--text-1); color: var(--surface-1);
  font-size: 12px; font-weight: 550; box-shadow: var(--shadow);
}

/* 빈 상태 */
.empty { padding: 24px 14px; text-align: center; color: var(--muted); font-size: 12px; }

@media (max-width: 1180px) {
  .layout { grid-template-columns: 300px minmax(0,1fr) 0; }
  .layout.has-detail { grid-template-columns: 300px minmax(0,1fr) 340px; }
}
