:root {
  --ink: #1f2937;
  --ink-2: #4b5563;
  --ink-3: #9ca3af;
  --line: #e5e7eb;
  --bg: #ffffff;
  --bg-2: #f3f4f6;
  --accent: #2563eb;
  --s-confirmed: #2563eb;
  --s-unconfirmed: #f97316;
  --s-planned: #9333ea;
  --s-failed: #6b7280;
  --s-done: #10b981;
  --top-h: 56px;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.14);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- top bar (한 줄) ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--top-h); z-index: 1001;
  display: flex; align-items: center; gap: 12px; padding: 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); flex: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M8 23V13l5-4 5 4v10M18 23v-7l3-2 3 2v7' stroke='white' stroke-width='2.4' fill='none' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: cover;
}
.brand-text { font-weight: 800; font-size: 17px; letter-spacing: -0.3px; white-space: nowrap; }
.filters {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px;
  overflow-x: auto; scrollbar-width: none; padding: 2px 0;
}
.filters::-webkit-scrollbar { display: none; }
.search { position: relative; flex: 0 1 260px; min-width: 150px; }
.search input {
  width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 18px;
  padding: 0 14px 0 36px; font-size: 14px; background: var(--bg-2) no-repeat 13px center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E");
  outline: none; color: var(--ink);
}
.search input:focus { border-color: var(--accent); background-color: #fff; }
.search-toggle {
  display: none; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%;
  background: var(--bg-2) no-repeat center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234b5563' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E");
}
.search-results {
  position: absolute; top: 42px; right: 0; width: max(100%, 320px); max-height: 60vh; overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px;
}
.search-results .sr-head { font-size: 12px; color: var(--ink-3); padding: 6px 10px 4px; }
.search-results .quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 8px 8px; }
.search-results .quick button { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 5px 11px; font-size: 13px; }
.search-results .quick button:hover { border-color: var(--accent); color: var(--accent); }
.sr-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 0; background: none; padding: 8px 10px; border-radius: 8px; font-size: 14px;
}
.sr-item:hover, .sr-item.is-active { background: var(--bg-2); }
.sr-item .sr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-item .sr-sub { color: var(--ink-3); font-size: 12px; flex: none; }
.sr-empty { padding: 12px; color: var(--ink-3); font-size: 13px; }

.fchip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 16px; background: #fff; font-size: 13px; white-space: nowrap;
}
.fchip--dd b { font-weight: 700; color: var(--accent); }
.caret { width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid var(--ink-2); }
.fsep { flex: none; width: 1px; height: 20px; background: var(--line); }
.status-chips { display: flex; gap: 6px; flex: none; }
.schip { color: var(--ink-3); }
.schip .ls { width: 20px; height: 12px; }
.schip.is-on { border-color: #374151; color: var(--ink); font-weight: 700; background: #f3f4f6; }
.schip:not(.is-on) .ls { opacity: 0.35; }
.schip small { color: var(--ink-3); font-weight: 500; font-size: 12px; }
.fcount { flex: none; font-size: 12px; color: var(--ink-2); white-space: nowrap; }

.dropdown { position: relative; flex: none; }
.dropdown-panel {
  position: fixed; z-index: 1100; width: 300px; max-height: calc(100vh - 140px); overflow-y: auto;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 12px;
}
.dropdown-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 12px; padding: 2px 4px; }
.type-list { display: grid; gap: 2px; }
.type-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 8px; font-size: 14px; cursor: pointer; user-select: none; }
.type-row:hover { background: var(--bg-2); }
.type-row input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.type-row .tsw {
  flex: none; width: 18px; height: 18px; border-radius: 5px; background: var(--c); border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line); padding: 0; cursor: pointer;
}
.type-row .tsw:hover { box-shadow: 0 0 0 2px var(--ink-2); }
.dd-hint { font-weight: 400; color: var(--ink-3); font-size: 11px; margin-left: 4px; }
.dropdown-foot { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; text-align: right; }
.palette {
  position: fixed; z-index: 1200; width: 212px; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 10px;
}
.palette-head { font-size: 12px; margin-bottom: 8px; }
.palette-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.palette-grid button {
  width: 26px; height: 26px; border-radius: 6px; border: 2px solid #fff; background: var(--c);
  box-shadow: 0 0 0 1px var(--line); padding: 0;
}
.palette-grid button:hover { transform: scale(1.1); }
.palette-grid button.is-on { box-shadow: 0 0 0 2px var(--ink); }
.palette-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; }
.palette-custom { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); cursor: pointer; }
.palette-custom input { width: 30px; height: 24px; padding: 0; border: 1px solid var(--line); border-radius: 4px; background: none; cursor: pointer; }
.lg-types span { cursor: pointer; }
.lg-types span:hover { text-decoration: underline; }
.type-row .tname { flex: 1; }
.type-row .tcount { color: var(--ink-3); font-size: 12px; }

/* ---------- map ---------- */
#map { position: fixed; top: var(--top-h); left: 0; right: 0; bottom: 0; background: #eef0f3; }
.leaflet-control-attribution { font-size: 10px; }
.leaflet-top.leaflet-right { top: 8px; }

.zlabel {
  display: inline-flex; align-items: center; gap: 4px; transform: translate(-50%, -50%);
  padding: 3px 8px 3px 3px; border-radius: 14px; background: #fff; white-space: nowrap;
  font-size: 12px; font-weight: 700; color: var(--ink); line-height: 18px;
  border: 1.5px solid var(--c); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18); cursor: pointer; width: max-content;
}
.zlabel .tb { background: var(--c); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; line-height: 18px; }
.zlabel.is-failed { color: var(--ink-2); text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, 0.35); }
.zlabel.is-done { opacity: 0.8; }
.zlabel:hover { z-index: 10000 !important; transform: translate(-50%, -50%) scale(1.06); }
.zlabel-icon { background: none !important; border: 0 !important; }

/* ---------- popover ---------- */
.leaflet-popup.pop .leaflet-popup-content-wrapper { border-radius: 14px; box-shadow: var(--shadow); padding: 0; }
.leaflet-popup.pop .leaflet-popup-content { margin: 0; width: 340px !important; max-width: calc(100vw - 48px); }
.leaflet-popup.pop a.leaflet-popup-close-button { top: 8px; right: 8px; width: 26px; height: 26px; font-size: 20px; color: var(--ink-3); }
.pv { padding: 16px 16px 14px; font-size: 13px; color: var(--ink); }
.pv-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; padding-right: 22px; }
.badge { display: inline-block; border-radius: 6px; padding: 2px 7px; font-size: 11px; font-weight: 700; line-height: 16px; }
.badge--status { color: #fff; background: var(--c); border: 1.5px solid var(--c); }
.badge--status.st-미확정, .badge--status.st-계획 { background: #fff; color: var(--c); }
.badge--status.st-무산 { background: #fff; color: var(--ink-3); border: 1.5px dotted var(--ink-3); text-decoration: line-through; }
.badge--status.st-완료 { background: color-mix(in srgb, var(--c) 45%, white); border-color: transparent; }
.badge--type { background: var(--bg-2); color: var(--ink); }
.badge--tag { background: #fff; color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); font-weight: 600; }
.badge--type i, .badge--tag i { display: inline-block; width: 7px; height: 7px; border-radius: 2px; background: var(--c); margin-right: 4px; vertical-align: 1px; }
.pv h3 { margin: 2px 0 2px; font-size: 16px; line-height: 1.35; letter-spacing: -0.3px; padding-right: 20px; }
.pv-addr { color: var(--ink-2); font-size: 12px; margin-bottom: 12px; }
.pv-stage-now { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.pv-stage-now strong { font-size: 14px; color: var(--c); }
.pv-stage-now span { font-size: 11px; color: var(--ink-3); }
.steps { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; margin-bottom: 4px; }
.step { height: 10px; background: var(--bg-2); }
.step:first-child { border-radius: 5px 0 0 5px; }
.step:last-child { border-radius: 0 5px 5px 0; }
.step.is-done { background: color-mix(in srgb, var(--c) 45%, white); }
.step.is-now { background: var(--c); position: relative; }
.step.is-now::after {
  content: ""; position: absolute; left: 50%; top: -6px; transform: translateX(-50%);
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 5px solid var(--c);
}
.steps--failed .step.is-now { background: repeating-linear-gradient(45deg, #9ca3af 0 3px, #d1d5db 3px 6px); }
.step-labels { display: grid; grid-template-columns: repeat(9, 1fr); gap: 2px; margin-bottom: 12px; }
.step-labels span { font-size: 9.5px; color: var(--ink-3); text-align: center; letter-spacing: -0.5px; line-height: 1.2; word-break: keep-all; }
.step-labels span.is-now { color: var(--c); font-weight: 800; }
.pv-rows { display: grid; grid-template-columns: 64px 1fr; gap: 5px 8px; margin: 0 0 10px; font-size: 12.5px; }
.pv-rows dt { color: var(--ink-3); }
.pv-rows dd { margin: 0; color: var(--ink); word-break: keep-all; overflow-wrap: anywhere; }
.pv-note { background: var(--bg-2); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--ink-2); line-height: 1.5; margin-bottom: 10px; }
.pv-warn { font-size: 11px; color: #b45309; margin-bottom: 8px; }
.pv-links { display: flex; flex-wrap: wrap; gap: 6px; }
.pv-links a, .pv-links button {
  display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 14px;
  border: 1px solid var(--line); background: #fff; font-size: 12px; color: var(--ink); text-decoration: none;
}
.pv-links a:hover, .pv-links button:hover { border-color: var(--accent); color: var(--accent); }
.pv-others { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.pv-others p { margin: 0 0 6px; font-size: 11px; color: var(--ink-3); }
.pv-others button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 5px 4px; font-size: 12.5px; border-radius: 6px; }
.pv-others button:hover { background: var(--bg-2); }
.pv-others i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c); margin-right: 6px; }

/* ---------- legend (간결형) ---------- */
.legend {
  position: fixed; left: 12px; bottom: 24px; z-index: 900; background: rgba(255, 255, 255, 0.96); border-radius: 12px;
  box-shadow: var(--shadow); font-size: 12px; width: 232px;
}
.legend-toggle { border: 0; background: none; font-weight: 800; padding: 8px 12px; width: 100%; text-align: left; font-size: 12px; }
.legend-toggle::after { content: "–"; float: right; color: var(--ink-3); }
.legend.is-collapsed { width: auto; }
.legend.is-collapsed .legend-toggle::after { content: "+"; margin-left: 10px; }
.legend.is-collapsed .legend-body { display: none; }
.legend-body { padding: 0 12px 10px; display: grid; gap: 6px; }
.lg-types, .lg-lines { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px 6px; }
.lg-lines { grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line); padding-top: 7px; }
.lg-types span, .lg-lines span { display: flex; align-items: center; gap: 5px; font-size: 11.5px; white-space: nowrap; }
.lg-types i { flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.lg-lines .ls { flex: none; width: 20px; height: 12px; }

/* 상태별 경계선 견본 (중립색) */
.ls { display: inline-block; box-sizing: border-box; border-radius: 3px; --n: #374151; }
.ls-확정 { border: 2px solid var(--n); background: rgba(55, 65, 81, 0.3); }
.ls-미확정 { border: 2px dashed var(--n); background: rgba(55, 65, 81, 0.12); }
.ls-계획 { border: 2px dotted var(--n); background: rgba(55, 65, 81, 0.05); }
.ls-무산 { border: 1.5px dotted rgba(55, 65, 81, 0.7); background: none; }
.ls-완료 { border: 1px solid rgba(55, 65, 81, 0.55); background: rgba(55, 65, 81, 0.1); }
.ls-원형 { border: 2px dashed var(--n); border-radius: 50%; background: rgba(55, 65, 81, 0.05); width: 14px !important; height: 14px !important; margin: 0 3px; }

.toast {
  position: fixed; left: 50%; top: calc(var(--top-h) + 12px); transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.88); color: #fff; padding: 8px 14px; border-radius: 18px; font-size: 13px; z-index: 1200;
}

@media (max-width: 1240px) {
  .fcount { display: none; }
  .schip small { display: none; }
  .fchip { padding: 0 10px; }
}
@media (max-width: 1080px) {
  .brand-text { display: none; }
  .search { flex-basis: 220px; }
}
@media (max-width: 640px) {
  :root { --top-h: 52px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .search { flex: none; min-width: 0; position: static; }
  .search input { display: none; }
  .search-toggle { display: block; }
  .topbar.is-searching .filters, .topbar.is-searching .brand { display: none; }
  .topbar.is-searching .search { flex: 1; }
  .topbar.is-searching .search input { display: block; }
  .topbar.is-searching .search-toggle { display: none; }
  .search-results { left: 8px; right: 8px; top: calc(var(--top-h) - 4px); width: auto; position: fixed; }
  .legend { left: 8px; bottom: 16px; }
  .dropdown-panel { left: 8px !important; right: 8px; width: auto; }
}

/* 범례 안내 · 상태 표현 편집 */
.lg-hint { font-weight: 500; color: var(--accent); font-size: 10.5px; margin-left: 4px; }
.legend.is-collapsed .lg-hint { display: none; }
.lg-lines span { cursor: pointer; border-radius: 4px; }
.lg-lines span:hover { background: var(--bg-2); }
.style-pop { width: 286px; }
.sp-row { margin-bottom: 8px; }
.sp-label { display: block; font-size: 11px; color: var(--ink-3); margin-bottom: 4px; }
.sp-opts { display: flex; gap: 4px; flex-wrap: wrap; }
.sp-opt {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 50px; padding: 6px 4px 4px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 10.5px; color: var(--ink-2);
}
.sp-opt small { font-size: 10.5px; }
.sp-opt:hover { border-color: var(--ink-3); }
.sp-opt.is-on { border-color: var(--accent); color: var(--accent); font-weight: 700; box-shadow: 0 0 0 1px var(--accent); }
.sp-line { display: block; width: 32px; height: 0; margin: 5px 0; }
.sp-fill { display: block; width: 28px; height: 14px; border: 1.5px solid #374151; border-radius: 3px; }
