/* 仅展示与图例相关的新增/改动，其它保持不变 */
:root { --bg:#fff; --text:#0f172a; --muted:#475569; --line:#e5e7eb; }
* { box-sizing:border-box; }
body{ margin:0; font-family: ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Arial; color:var(--text); }
.app{ display:grid; grid-template-columns:360px 1fr; height:100vh; }
.panel{ padding:16px; border-right:1px solid var(--line); overflow:auto; background:var(--bg); }
.panel h2{ margin:0 0 12px; font-size:18px; }
.panel label{ display:block; font-size:12px; color:var(--muted); margin:12px 0 6px; }
.panel input,.panel select,.panel button{ width:100%; padding:10px; border:1px solid var(--line); border-radius:10px; font-size:14px; }
.row{ display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.btn{ background:#111; color:#fff; border:0; cursor:pointer; border-radius:12px; }
.ghost{ background:#fff; border:1px solid var(--line); border-radius:12px; }
#map{ position:relative; height:100%; width:100%; }

/* 图例：加了高度限制与滚动 */
.legend{
  position:absolute; right:12px; top:12px; background:#fff;
  border-radius:12px; padding:8px 10px; box-shadow:0 6px 16px rgba(0,0,0,.08);
  font-size:12px; max-width:280px; border:1px solid var(--line);
  z-index:10000 !important; pointer-events:auto;
  max-height: 72vh;           /* 新增：防止超出屏幕 */
  overflow: auto;             /* 新增：可滚动 */
}
.legend h4{ margin:0 0 6px; font-size:12px; }

/* 每一行：复选框 + 色点 + 标签名 + 计数 + 颜色选择器 */
.legend .item{
  display:flex; align-items:center; gap:8px; margin:6px 0;
}
.legend .dot{
  width:12px; height:12px; border-radius:50%;
  border:1px solid rgba(0,0,0,.2); flex:0 0 12px;
}
.legend .tag{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width: 140px; }
.legend .count{ color:var(--muted); }
