/* ============================================================
   配网标绘 · Power Grid Mapper
   ============================================================ */
:root {
  --ink: #0f1e2e;
  --ink-2: #1b3049;
  --ink-3: #2a405a;
  --paper: #f2f6fa;
  --surface: #ffffff;
  --line: #e3eaf2;
  --line-strong: #d3dfea;
  --muted: #6d8095;
  --muted-2: #93a3b3;
  --accent: #f5a524;
  --accent-strong: #e08e0b;
  --accent-soft: #fff4de;
  --blue: #2f6fed;
  --green: #129a72;
  --red: #e2544a;
  --violet: #7c5cf0;
  --shadow-sm: 0 2px 8px rgba(12, 28, 46, 0.08);
  --shadow-md: 0 10px 30px rgba(12, 28, 46, 0.14);
  --shadow-lg: 0 24px 60px rgba(12, 28, 46, 0.22);
  --radius: 18px;
  --panel-w: 344px;
  --font-body: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Heiti SC", sans-serif;
  --font-num: "Bahnschrift", "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-body);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.mono { font-family: var(--font-num); letter-spacing: 0.3px; }
.ic {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.ic-sm { width: 15px; height: 15px; }

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---------------- top bar ---------------- */
.topbar {
  position: relative; z-index: 1000;
  flex: none; height: 62px;
  display: flex; align-items: center; gap: 18px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  background: linear-gradient(150deg, var(--ink) 0%, var(--ink-2) 100%);
  display: grid; place-items: center; color: var(--accent);
  box-shadow: 0 4px 12px rgba(15, 30, 46, 0.26);
}
.brand-mark .ic { width: 21px; height: 21px; fill: currentColor; stroke: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; white-space: nowrap; }
.brand-text strong { font-size: 16px; letter-spacing: 0.6px; font-weight: 700; }
.brand-text span {
  margin-top: 4px; font-family: var(--font-num); font-size: 8.5px;
  letter-spacing: 2.1px; color: var(--muted-2);
}
.topbar-center { position: absolute; left: 50%; transform: translateX(-50%); }
.segmented {
  display: flex; gap: 2px; padding: 3px;
  background: #eef3f8; border: 1px solid #e6edf4; border-radius: 11px;
}
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  height: 28px; padding: 0 14px; border-radius: 8px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px;
  transition: background .18s, color .18s, box-shadow .18s;
}
.segmented button:hover { color: var(--ink); }
.segmented button.active {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
  display: grid; place-items: center;
  transition: background .16s, color .16s;
}
.icon-btn:hover { background: #f0f5fa; color: var(--ink); }
.icon-btn .ic { width: 18px; height: 18px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 10px;
  border: 1px solid transparent; background: var(--ink); color: #fff;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0.2px;
  transition: background .16s, box-shadow .16s, border-color .16s;
}
.btn:hover { background: var(--ink-2); }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn.ghost:hover { background: #f5f8fb; border-color: var(--line-strong); }
.btn.primary { background: var(--ink); }
.btn.primary:hover { background: var(--ink-2); box-shadow: 0 6px 16px rgba(15, 30, 46, 0.22); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #cf453b; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn .ic { width: 16px; height: 16px; }

.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 1200;
  width: 208px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-md);
  animation: menuIn .16s ease-out;
}
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 10px; border: 0; border-radius: 9px;
  background: transparent; font-size: 12.5px; text-align: left; color: var(--ink-2);
}
.menu-item:hover { background: #f2f6fa; }
.menu-item .ic { width: 17px; height: 17px; color: var(--muted); }
.menu-item.danger { color: var(--red); }
.menu-item.danger .ic { color: var(--red); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 8px; }

/* ---------------- stage / map ---------------- */
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #dde6ee; }
#map { position: absolute; inset: 0; background: #dde6ee; z-index: 0; }
.leaflet-container { font-family: var(--font-body); background: #dde6ee; }
.leaflet-container.mode-crosshair, .leaflet-container.mode-crosshair .leaflet-interactive { cursor: crosshair; }
.leaflet-container.mode-draw .asset-marker,
.leaflet-container.mode-draw .asset-line,
.leaflet-container.mode-draw .asset-line-hit { pointer-events: none !important; }

.leaflet-control-attribution {
  background: rgba(255, 255, 255, 0.82) !important;
  color: var(--muted) !important; font-size: 9px !important;
  padding: 1px 6px !important; border-radius: 5px;
  backdrop-filter: blur(6px);
}
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-bottom.leaflet-right { right: calc(var(--panel-w) + 36px); bottom: 8px; }
.leaflet-control-scale-line {
  background: rgba(255, 255, 255, 0.82) !important;
  border-color: rgba(15, 30, 46, 0.5) !important;
  color: var(--ink-2) !important; font-family: var(--font-num);
  font-size: 9.5px !important; border-radius: 4px;
  text-shadow: none !important; padding: 1px 5px !important;
}

/* ---------------- tool rail ---------------- */
.tool-rail {
  position: absolute; left: 18px; top: 18px; z-index: 900;
  width: 78px; padding: 12px 8px 10px;
  display: flex; flex-direction: column; align-items: stretch;
  background: linear-gradient(180deg, rgba(16, 32, 51, 0.97) 0%, rgba(12, 25, 40, 0.97) 100%);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 22px; box-shadow: var(--shadow-lg);
  backdrop-filter: blur(10px);
  animation: railIn .5s cubic-bezier(.22,.9,.3,1) both;
}
.rail-group { display: flex; flex-direction: column; gap: 3px; }
.rail-label {
  font-family: var(--font-num); font-size: 8.5px; letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.32); padding: 4px 0 6px 10px;
}
.rail-sep { height: 1px; background: rgba(255, 255, 255, 0.09); margin: 8px 6px; }
.tool {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: 50px; padding: 0; border: 0; border-radius: 13px;
  background: transparent; color: rgba(255, 255, 255, 0.7);
  font-size: 10.5px; letter-spacing: 0.3px;
  transition: background .18s, color .18s, transform .18s;
}
.tool .ic { width: 19px; height: 19px; transition: transform .18s; }
.tool:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.tool:hover .ic { transform: translateY(-1px); }
.tool.active {
  background: var(--accent); color: var(--ink); font-weight: 700;
  box-shadow: 0 6px 16px rgba(245, 165, 36, 0.36);
}
.tool.active .ic { stroke-width: 2; }
.rail-zoom { display: flex; gap: 4px; padding: 0 2px; }
.rail-zoom button {
  flex: 1; height: 30px; border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 9px; background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.75); font-family: var(--font-num);
  font-size: 16px; line-height: 1; padding: 0 0 2px;
  transition: background .16s, color .16s;
}
.rail-zoom button:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }

/* ---------------- hint / status ---------------- */
.tool-hint {
  position: absolute; top: 20px; left: 50%; transform: translate(-50%, -8px);
  z-index: 850; max-width: min(560px, calc(100% - 520px));
  padding: 8px 14px; border-radius: 999px;
  background: rgba(15, 30, 46, 0.9); color: rgba(255, 255, 255, 0.92);
  font-size: 11.5px; letter-spacing: 0.2px; white-space: nowrap;
  box-shadow: var(--shadow-md); backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s;
}
.tool-hint.show { opacity: 1; transform: translate(-50%, 0); }

.statusbar {
  position: absolute; left: 18px; bottom: 18px; z-index: 700;
  display: flex; align-items: center; gap: 9px;
  height: 32px; padding: 0 12px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line); border-radius: 999px;
  box-shadow: var(--shadow-sm); backdrop-filter: blur(10px);
  font-family: var(--font-num); font-size: 10.5px; color: var(--muted);
  letter-spacing: 0.4px; pointer-events: none;
}
.statusbar .ic { width: 13px; height: 13px; color: var(--muted-2); }
.statusbar .coord { min-width: 168px; color: var(--ink-2); }
.statusbar .sep { width: 1px; height: 12px; background: var(--line-strong); }
.statusbar .crs {
  padding: 2px 7px; border-radius: 999px;
  background: #eef3f8; color: var(--muted); font-size: 9px; letter-spacing: 0.8px;
}

/* ---------------- side panel ---------------- */
.side-panel {
  position: absolute; top: 18px; right: 18px; bottom: 18px; z-index: 950;
  width: var(--panel-w);
  background: var(--surface); border: 1px solid rgba(15, 30, 46, 0.06);
  border-radius: 22px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
  transition: transform .32s cubic-bezier(.4,0,.2,1), opacity .28s;
}
.side-panel:not(.is-closed) {
  animation: panelIn .55s cubic-bezier(.22,.9,.3,1) both;
}
.side-panel.is-closed {
  transform: translateX(calc(100% + 30px)); opacity: 0; pointer-events: none;
}
.panel-view { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.panel-detail { overflow-y: auto; }

.panel-head {
  position: relative; flex: none;
  display: flex; align-items: flex-start; gap: 8px;
  padding: 18px 14px 12px 20px;
}
.panel-title h2 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0.4px; }
.panel-title p { margin: 5px 0 0; font-size: 10.5px; color: var(--muted); letter-spacing: 0.3px; }
.panel-title p b { color: var(--ink-2); font-family: var(--font-num); font-weight: 600; font-size: 11.5px; }
.panel-head-actions { margin-left: auto; display: flex; gap: 2px; }
.panel-close { display: none; }

.layer-pop {
  position: absolute; top: 56px; right: 14px; z-index: 20;
  width: 214px; padding: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-md);
  animation: menuIn .15s ease-out;
}
.pop-title {
  margin: 2px 0 7px; padding-left: 4px;
  font-family: var(--font-num); font-size: 9px; letter-spacing: 1.6px;
  color: var(--muted-2); text-transform: uppercase;
}
.pop-row {
  display: flex; align-items: center; gap: 9px;
  height: 33px; padding: 0 4px; border-radius: 8px;
  font-size: 12px; color: var(--ink-2); cursor: pointer;
}
.pop-row:hover { background: #f4f8fb; }
.pop-row input { width: 14px; height: 14px; accent-color: var(--ink); cursor: pointer; }
.pop-row b {
  margin-left: auto; font-family: var(--font-num); font-size: 10.5px;
  color: var(--muted); font-weight: 500;
}
.pop-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.swatch { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--blue)); flex: none; }
.swatch.line { width: 12px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--blue), var(--green)); }
.swatch.outline { border-radius: 3px; background: transparent; border: 1.5px dashed var(--muted-2); }

.search-box {
  flex: none; margin: 0 16px 10px;
  display: flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 10px 0 12px;
  background: #f3f7fa; border: 1px solid transparent; border-radius: 12px;
  transition: border-color .18s, background .18s, box-shadow .18s;
}
.search-box:focus-within {
  background: #fff; border-color: var(--ink-3);
  box-shadow: 0 0 0 3px rgba(15, 30, 46, 0.06);
}
.search-box .ic { width: 16px; height: 16px; color: var(--muted-2); }
.search-box input {
  flex: 1; min-width: 0; border: 0; background: transparent;
  font-size: 12px; outline: none; letter-spacing: 0.2px;
}
.search-box input::placeholder { color: var(--muted-2); }
.search-clear {
  width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: #e8eef4; color: var(--muted); display: grid; place-items: center;
}
.search-clear .ic { width: 11px; height: 11px; }

.chips {
  flex: none; display: flex; flex-wrap: wrap; gap: 5px;
  padding: 0 16px 13px;
}
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: 10.5px; font-weight: 500;
  transition: background .16s, color .16s, border-color .16s;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink-2); }
.chip[data-filter="pole"] { box-shadow: inset 2.5px 0 0 #2f6fed; }
.chip[data-filter="transformer"] { box-shadow: inset 2.5px 0 0 #e08e0b; }
.chip[data-filter="switch"] { box-shadow: inset 2.5px 0 0 #e2544a; }
.chip[data-filter="line"] { box-shadow: inset 2.5px 0 0 #129a72; }
.chip b { font-family: var(--font-num); font-weight: 600; font-size: 9.5px; opacity: .7; }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip.active b { opacity: .9; }

.asset-list {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 0 10px 12px;
  scrollbar-width: thin; scrollbar-color: #d8e2ec transparent;
}
.asset-list::-webkit-scrollbar { width: 6px; }
.asset-list::-webkit-scrollbar-thumb { background: #d8e2ec; border-radius: 3px; }
.asset-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 8px 9px; margin-bottom: 2px;
  border: 1px solid transparent; border-radius: 13px;
  background: transparent; text-align: left;
  transition: background .15s, border-color .15s;
  animation: itemIn .3s ease-out both;
}
.asset-item:hover { background: #f4f8fb; }
.asset-item.is-active { background: #f1f6ff; border-color: #cfe0ff; }
.asset-icon {
  flex: none; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--tint, #eaf1ff); color: var(--c, var(--blue));
}
.asset-icon .ic { width: 17px; height: 17px; }
.asset-icon.line { --c: var(--green); --tint: #e7f7f1; }
.asset-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.asset-name {
  font-size: 12.5px; font-weight: 600; color: var(--ink); letter-spacing: 0.2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.asset-sub {
  font-size: 10px; color: var(--muted); letter-spacing: 0.2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-num);
}
.asset-go { color: var(--muted-2); font-size: 15px; line-height: 1; padding-left: 2px; }

.empty {
  margin: 16px 10px; padding: 26px 20px;
  border: 1px dashed var(--line-strong); border-radius: 16px;
  background: linear-gradient(180deg, #fbfdff 0%, #f6fafd 100%);
  text-align: center;
}
.empty-art { width: 132px; height: 86px; margin: 0 auto 12px; display: block; opacity: .9; }
.empty h4 { margin: 0 0 6px; font-size: 13px; font-weight: 700; }
.empty p { margin: 0 auto 14px; max-width: 240px; font-size: 11px; line-height: 1.7; color: var(--muted); }
.empty .btn { height: 34px; font-size: 11.5px; padding: 0 14px; }

.panel-foot {
  flex: none; display: flex; gap: 10px;
  padding: 12px 18px 14px; border-top: 1px solid var(--line);
  background: #fbfdff;
}
.stat { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.stat + .stat { padding-left: 14px; border-left: 1px solid var(--line); }
.stat span {
  font-size: 9px; letter-spacing: 1px; color: var(--muted-2);
  font-family: var(--font-num); text-transform: uppercase;
}
.stat strong {
  font-family: var(--font-num); font-size: 16px; font-weight: 600;
  color: var(--ink); letter-spacing: 0.3px;
}
.stat:first-child strong { color: var(--accent-strong); }

/* ---------------- detail ---------------- */
.detail-head {
  flex: none; display: flex; align-items: center; gap: 8px;
  padding: 14px 16px 6px;
}
.detail-head .icon-btn:first-child { margin-left: -4px; }
.detail-kicker {
  font-family: var(--font-num); font-size: 9px; letter-spacing: 2px;
  color: var(--muted-2); text-transform: uppercase;
}
.detail-head .icon-btn.danger { margin-left: auto; color: var(--red); }
.detail-head .icon-btn.danger:hover { background: #fdeeec; }
.detail-hero {
  display: flex; align-items: center; gap: 13px;
  padding: 4px 20px 18px;
}
.detail-hero .asset-icon { width: 50px; height: 50px; border-radius: 14px; }
.detail-hero .asset-icon .ic { width: 24px; height: 24px; }
.detail-hero h3 {
  margin: 0 0 4px; font-size: 18px; font-weight: 700; letter-spacing: 0.3px;
  word-break: break-all;
}
.detail-hero p {
  margin: 0; font-size: 10.5px; color: var(--muted);
  font-family: var(--font-num); letter-spacing: 0.6px;
}
.detail-hero p .badge {
  display: inline-block; padding: 2px 7px; border-radius: 999px;
  background: #eef7f2; color: var(--green); font-family: var(--font-body);
  font-size: 10px; margin-left: 2px; letter-spacing: 0.2px;
}
.detail-hero p .badge.off { background: #f1f4f7; color: var(--muted); }
.detail-hero p .badge.plan { background: var(--accent-soft); color: var(--accent-strong); }

.detail-block {
  margin: 0 16px 14px; padding: 4px 0;
  border: 1px solid var(--line); border-radius: 14px;
  background: #fcfdff;
}
.detail-row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 9px 14px; font-size: 11.5px;
}
.detail-row + .detail-row { border-top: 1px solid #eff4f8; }
.detail-row > span { flex: none; width: 62px; color: var(--muted); }
.detail-row > div { flex: 1; min-width: 0; color: var(--ink-2); line-height: 1.6; word-break: break-all; }
.detail-row .mono { font-size: 12px; }
.detail-row .copy-btn {
  margin-left: 6px; border: 0; background: transparent; color: var(--muted-2);
  padding: 2px; border-radius: 5px; vertical-align: -2px;
}
.detail-row .copy-btn:hover { color: var(--ink); background: #eef4f9; }
.detail-row .copy-btn .ic { width: 12px; height: 12px; }
.detail-note { white-space: pre-wrap; }

.detail-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 2px 16px 16px;
}
.detail-actions .btn { height: 40px; font-size: 12px; }
.detail-actions .span-2 { grid-column: span 2; }
.detail-tip {
  margin: 0 16px 16px; padding: 10px 12px;
  border-radius: 10px; background: var(--accent-soft);
  color: #8a6113; font-size: 10.5px; line-height: 1.6;
}
.detail-tip b { color: var(--accent-strong); }

/* ---------------- draw bar ---------------- */
.draw-bar {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 960; display: flex; align-items: center; gap: 14px;
  padding: 8px 10px 8px 18px;
  background: rgba(13, 27, 43, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px; box-shadow: var(--shadow-lg);
  backdrop-filter: blur(12px); color: #fff;
  animation: barIn .25s cubic-bezier(.2,.9,.3,1);
}
.draw-info { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.draw-info span { font-size: 11.5px; letter-spacing: 0.3px; }
.pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 rgba(245, 165, 36, 0.65);
  animation: pulse 1.6s infinite;
}
.draw-actions { display: flex; gap: 5px; }
.mini {
  height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid transparent; background: rgba(255, 255, 255, 0.1);
  color: #fff; font-size: 11px; font-weight: 500;
  transition: background .15s;
}
.mini:hover { background: rgba(255, 255, 255, 0.2); }
.mini.solid { background: var(--accent); color: var(--ink); font-weight: 700; }
.mini.solid:hover { background: #ffb63a; }
.mini.danger { background: transparent; color: #ff9b93; border-color: rgba(255, 155, 147, 0.3); }
.mini.danger:hover { background: rgba(226, 84, 74, 0.22); }

/* ---------------- map markers ---------------- */
.asset-marker { background: none; border: none; }
.pin {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--pin-c, var(--blue));
  border: 2.5px solid #fff;
  box-shadow: 0 4px 10px rgba(9, 20, 32, 0.35), 0 0 0 1px rgba(9, 20, 32, 0.08);
  display: grid; place-items: center; color: #fff;
  transition: transform .16s cubic-bezier(.2,.9,.3,1.4), box-shadow .16s;
}
.asset-marker[class*="pin-transformer"] .pin { border-radius: 9px; }
.asset-marker[class*="pin-switch"] .pin { border-radius: 5px; }
.pin .ic, .pin svg {
  width: 16px; height: 16px; color: #fff;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.asset-marker:hover .pin { transform: scale(1.14); }
.pin.is-selected {
  transform: scale(1.16);
  box-shadow: 0 0 0 4px rgba(245, 165, 36, 0.5), 0 6px 16px rgba(9, 20, 32, 0.35);
}
.pin.is-flash { animation: flash .8s ease-out 2; }

.asset-tip, .line-tip {
  padding: 3px 8px !important;
  background: rgba(255, 255, 255, 0.96) !important;
  border: 1px solid var(--line-strong) !important;
  border-radius: 7px !important;
  box-shadow: 0 3px 10px rgba(12, 28, 46, 0.14) !important;
  color: var(--ink-2) !important;
  font-size: 10.5px !important; font-weight: 600; letter-spacing: 0.2px;
}
.asset-tip::before, .line-tip::before { border-top-color: #fff !important; }

.draw-node {
  display: block; width: 11px; height: 11px; border-radius: 50%;
  background: var(--accent); border: 2.5px solid #fff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.3);
}
.snap-ring {
  display: block; width: 44px; height: 44px; border-radius: 50%;
  border: 2px dashed var(--accent);
  background: rgba(245, 165, 36, 0.16);
  animation: snapPulse 1.5s ease-out infinite;
}
.measure-chip {
  display: inline-block; transform: translate(-50%, -100%);
  padding: 4px 9px; border-radius: 999px;
  background: var(--ink); color: #fff;
  font-family: var(--font-num); font-size: 11px; letter-spacing: 0.4px;
  white-space: nowrap; box-shadow: 0 4px 12px rgba(9, 20, 32, 0.3);
}
.v-handle {
  display: block; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3); cursor: grab;
}
.locate-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--blue); border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(47, 111, 237, 0.2), 0 3px 8px rgba(0,0,0,.3);
}
.vertex-marker { background: none; border: none; }
.leaflet-container.mode-vertex .asset-marker { pointer-events: none; }

/* ---------------- modal ---------------- */
.modal-layer {
  position: fixed; inset: 0; z-index: 2000;
  display: grid; place-items: center; padding: 20px;
  background: rgba(9, 18, 30, 0.46);
  backdrop-filter: blur(4px);
  animation: fadeIn .18s ease-out;
}
.modal {
  width: min(452px, 100%); max-height: 88vh; display: flex; flex-direction: column;
  background: var(--surface); border-radius: 20px;
  box-shadow: 0 30px 90px rgba(5, 14, 24, 0.4);
  animation: modalIn .24s cubic-bezier(.2,.9,.3,1);
  overflow: hidden;
}
.modal-head {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 0 22px;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: 0.4px; }
.modal-head .icon-btn { margin-left: auto; width: 32px; height: 32px; }
.modal-body { padding: 16px 22px 4px; overflow-y: auto; }
.modal-foot {
  flex: none; display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 22px 20px;
}
.modal-foot .btn { min-width: 84px; }
.modal-foot .btn.ghost { background: #f4f8fb; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 13px; }
.field > label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: 0.5px;
}
.field .input {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fbfdff; font-size: 13px; outline: none;
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.field textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.field .input:focus {
  background: #fff; border-color: var(--ink-3);
  box-shadow: 0 0 0 3px rgba(15, 30, 46, 0.07);
}
.field select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 19px, calc(100% - 11px) 19px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid .field { margin-bottom: 13px; }
.coord-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.coord-inputs .input { font-family: var(--font-num); font-size: 12.5px; letter-spacing: 0.4px; }
.form-hint {
  margin: 2px 0 10px; padding: 9px 11px; border-radius: 9px;
  background: #f4f8fb; color: var(--muted);
  font-size: 10.5px; line-height: 1.65;
}
.confirm-text { margin: 4px 0 12px; font-size: 12.5px; line-height: 1.75; color: var(--ink-2); }
.confirm-text b { color: var(--ink); }
.import-summary {
  display: flex; gap: 10px; margin: 6px 0 14px;
}
.import-summary div {
  flex: 1; padding: 12px 14px; border-radius: 12px; background: #f5f9fc;
  display: flex; flex-direction: column; gap: 4px;
}
.import-summary span { font-size: 10px; color: var(--muted); }
.import-summary strong { font-family: var(--font-num); font-size: 20px; font-weight: 600; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.help-grid div {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px; border-radius: 10px; background: #f5f9fc;
  font-size: 11px; color: var(--ink-2);
}
.help-grid kbd {
  display: inline-grid; place-items: center; min-width: 22px; height: 20px;
  padding: 0 5px; border-radius: 5px; background: #fff;
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  font-family: var(--font-num); font-size: 10px; color: var(--ink-2);
}
.help-list { margin: 0 0 12px; padding: 0; list-style: none; }
.help-list li {
  position: relative; padding: 5px 0 5px 16px;
  font-size: 11.5px; line-height: 1.65; color: var(--ink-2);
}
.help-list li::before {
  content: ""; position: absolute; left: 2px; top: 12px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
}

/* ---------------- toast ---------------- */
.toast-wrap {
  position: absolute; top: 74px; left: 50%; transform: translateX(-50%);
  z-index: 3000; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: min(92vw, 420px);
}
.toast {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px 9px 13px; border-radius: 999px;
  background: rgba(15, 30, 46, 0.94); color: #fff;
  font-size: 11.5px; letter-spacing: 0.2px;
  box-shadow: var(--shadow-md); backdrop-filter: blur(8px);
  animation: toastIn .28s cubic-bezier(.2,.9,.3,1);
  max-width: 100%;
}
.toast .ic { width: 15px; height: 15px; flex: none; }
.toast.ok .ic { color: #54d6a4; }
.toast.warn .ic { color: var(--accent); }
.toast.info .ic { color: #8ec0ff; }
.toast.out { animation: toastOut .25s ease-in forwards; }

/* ---------------- keyframes ---------------- */
@keyframes panelIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes railIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes itemIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes menuIn { from { opacity: 0; transform: translateY(-5px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes barIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 165, 36, 0.55); }
  70% { box-shadow: 0 0 0 9px rgba(245, 165, 36, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 165, 36, 0); }
}
@keyframes snapPulse {
  0% { transform: scale(.85); opacity: 1; }
  70% { transform: scale(1.08); opacity: .55; }
  100% { transform: scale(.85); opacity: 1; }
}
@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(245, 165, 36, 0.7); }
  100% { box-shadow: 0 0 0 16px rgba(245, 165, 36, 0); }
}

/* ---------------- responsive ---------------- */
@media (max-width: 1180px) {
  :root { --panel-w: 320px; }
  .brand-text span { display: none; }
}
@media (max-width: 900px) {
  :root { --panel-w: 352px; }
  .topbar { height: 56px; padding: 0 12px; gap: 8px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .brand-text strong { font-size: 14.5px; }
  .topbar-center { position: static; transform: none; margin-left: auto; }
  .topbar-actions { margin-left: 0; }
  .segmented button { padding: 0 10px; height: 26px; font-size: 11px; }
  .topbar .btn.ghost { height: 34px; padding: 0 10px; font-size: 11.5px; }
  .topbar .btn.ghost .ic-sm { display: none; }
  #btn-help { display: none; }
  .panel-close { display: grid; }
  .tool-rail {
    left: 50%; top: auto; bottom: 14px; transform: translateX(-50%);
    width: auto; max-width: calc(100vw - 16px);
    flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 6px;
    padding: 7px 8px; border-radius: 18px;
    overflow-x: auto; scrollbar-width: none;
    animation: railMobileIn .45s cubic-bezier(.22,.9,.3,1) both;
  }
  .tool-rail::-webkit-scrollbar { display: none; }
  .rail-group { flex-direction: row; gap: 3px; }
  .rail-group + .rail-group { border-left: 1px solid rgba(255,255,255,.1); padding-left: 5px; }
  .rail-label { display: none; }
  .rail-sep { display: none; }
  .tool { width: 46px; height: 48px; font-size: 9.5px; border-radius: 11px; }
  .tool .ic { width: 18px; height: 18px; }
  .rail-zoom { display: none; }
  .side-panel {
    top: 68px; right: 10px; bottom: 82px; width: min(var(--panel-w), calc(100vw - 20px));
    border-radius: 20px;
  }
  .side-panel.is-closed { transform: translateX(calc(100% + 20px)); }
  .draw-bar { bottom: 86px; max-width: calc(100vw - 20px); gap: 8px; padding-left: 14px; }
  .draw-info span { font-size: 10.5px; max-width: 190px; overflow: hidden; text-overflow: ellipsis; display: inline-block; }
  .statusbar { display: none; }
  .tool-hint {
    top: 12px; max-width: calc(100vw - 24px);
    white-space: normal; text-align: center; border-radius: 12px;
    line-height: 1.5;
  }
  .leaflet-bottom.leaflet-right { right: 10px; bottom: 78px; }
  .toast-wrap { top: 66px; }
  .topbar-center .segmented { background: #f1f5f9; }
  .field-grid { grid-template-columns: 1fr; gap: 0; }
  .help-grid { grid-template-columns: 1fr; }
  .leaflet-control-scale { display: none; }
}
@media (max-width: 560px) {
  .brand-text { display: none; }
  .topbar { gap: 6px; }
  .topbar-center { margin-left: 6px; }
  .topbar-actions { margin-left: auto; }
  .segmented { padding: 2px; }
  .segmented button { padding: 0 9px; }
  .modal { width: 100%; max-height: 92vh; }
}
@keyframes railMobileIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
