:root { --bg: #eef1f4; --panel: #fff; --ink: #1a1d21; --muted: #6b7280; --line: #d8dde3; --accent: #1f6feb; --danger: #c62828; }
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
.login { min-height: 100vh; display: grid; place-items: center; }
.login form { background: var(--panel); padding: 28px; border-radius: 12px; width: min(360px, 92vw); box-shadow: 0 8px 30px rgba(0,0,0,.08); display: grid; gap: 12px; }
.login h1 { margin: 0; font-size: 22px; }
.login input { padding: 10px 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; }
.login button, header button, #props button, #poiProps button { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; }
.login button, header button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
header button.active { background: #dbe7ff; border-color: var(--accent); }
header button.danger, #props .danger { background: #fff5f5; color: var(--danger); border-color: #f3c0c0; }
.err { color: var(--danger); margin: 0; }
.muted { color: var(--muted); font-size: 12px; }
header { display: flex; gap: 10px; align-items: center; padding: 8px 20px 8px 12px; background: #e4e9ef; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.nav { color: var(--ink); text-decoration: none; font-size: 14px; }
.nav:hover { text-decoration: underline; }
#resort { font-size: 15px; padding: 6px 8px; min-width: 200px; border-radius: 8px; border: 1px solid #ccc; }
.ski-patrol {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.ski-patrol input {
  width: 8.5rem;
  padding: 6px 8px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
}
.ski-patrol input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(31, 111, 235, .18);
}
.name-search {
  position: relative;
  flex: 0 1 11rem;
  min-width: 7.5rem;
  max-width: 14rem;
}
#nameSearchInput {
  width: 100%;
  padding: 6px 10px;
  font: inherit;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: #fff;
  min-width: 0;
}
#nameSearchInput:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(31, 111, 235, .18);
}
.name-search-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 1200;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  max-height: min(280px, 50vh);
  overflow-y: auto;
}
.name-search-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.3;
}
.name-search-list li:hover,
.name-search-list li.is-active { background: #e8f0fe; }
.name-search-list .ns-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.name-search-list .ns-kind {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 11px;
}
.name-search-list .ns-empty {
  cursor: default;
  color: var(--muted);
  font-weight: 400;
}
.name-search-list .ns-empty:hover { background: transparent; }
.poi-type-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  max-width: min(42rem, 100%);
  flex: 1 1 12rem;
  min-width: 0;
}
.poi-type-filters:empty { display: none; }
.poi-type-filters label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  line-height: 1.2;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.poi-type-filters label:hover { border-color: #b6c2d1; }
.poi-type-filters label.is-off {
  opacity: .45;
  background: #f3f5f7;
}
.poi-type-filters input {
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.poi-type-filters .ptf-icon {
  font-size: 13px;
  line-height: 1;
}
.poi-type-filters .ptf-icon img {
  width: 14px;
  height: 14px;
  display: block;
  vertical-align: middle;
}
.poi-type-filters .ptf-count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.tools { display: flex; gap: 6px; flex-shrink: 0; }
/* Fixed slot left of Undo — long messages wrap to ~2 lines, don’t shove Save onto a new row */
#status {
  margin-left: auto;
  flex: 0 0 11.5rem;
  width: 11.5rem;
  max-width: 11.5rem;
  min-width: 0;
  min-height: 0;
  max-height: 2.6em;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  word-break: break-word;
  text-align: right;
}
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}
#btnSave:disabled, #btnAddWay:disabled, #btnExtendDown:disabled, #btnExtendUp:disabled, #btnUndo:disabled { opacity: .45; cursor: default; }
#btnPublish:disabled:not(.ok):not(.busy) { opacity: .45; cursor: default; }
#btnPublish.busy { background: #fff8e1; border-color: #f0c36d; color: #7a5a00; opacity: 1; cursor: wait; }
#btnPublish.ok { background: #1b7f3a; color: #fff; border-color: #1b7f3a; opacity: 1; font-weight: 600; }
#status.ok { color: #1b7f3a; font-weight: 600; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: #1b7f3a; color: #fff; padding: 12px 18px; border-radius: 10px;
  font: 600 15px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 8px 28px rgba(0,0,0,.25); z-index: 10001; max-width: min(420px, 92vw);
  text-align: center;
}
.workspace { display: grid; grid-template-columns: 1fr 300px; height: calc(100vh - 52px); padding-right: 8px; }
.map-wrap { position: relative; height: 100%; min-width: 0; }
#map { height: 100%; min-width: 0; }
.load-overlay {
  position: absolute; inset: 0; z-index: 2000;
  display: grid; place-items: center;
  background: rgba(238, 241, 244, .72);
}
.load-card {
  background: var(--panel); padding: 18px 20px; border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.12); width: min(320px, 88%);
}
.load-title { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.load-bar {
  height: 8px; border-radius: 999px; background: #d8dde3; overflow: hidden;
}
.load-bar-fill {
  height: 100%; width: 0%; background: var(--accent); border-radius: 999px;
  transition: width .15s linear;
}
#loadStatus { margin: 8px 0 0; }
aside {
  background: var(--panel); border-left: 1px solid var(--line);
  padding: 14px 12px; overflow-x: hidden; overflow-y: auto;
  border-radius: 0 8px 0 0; min-width: 0;
}
#props, #poiProps { display: grid; gap: 10px; min-width: 0; }
#props label, #poiProps label { display: grid; gap: 4px; font-size: 13px; min-width: 0; }
#props input:not([type="checkbox"]), #props select,
#poiProps input:not([type="checkbox"]), #poiProps select {
  padding: 7px 8px; border: 1px solid var(--line); border-radius: 6px; font: inherit;
  width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box;
}
#props .row, #poiProps .row { display: flex; align-items: center; gap: 8px; min-width: 0; }
#props .ends-row, #poiProps .ends-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; min-width: 0;
}
#props .ends-row label, #poiProps .ends-row label { margin: 0; min-width: 0; }
#poiProps input[readonly], #poiProps input:disabled { background: #f4f6f8; color: #1a1d21; }
.poi-symbol-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.poi-symbol-row input, .poi-symbol-row select { flex: 1; min-width: 0; max-width: 100%; }
.poi-symbol-icon { font-size: 22px; line-height: 1; flex-shrink: 0; }
#pEntry { background: #f3f5f7; color: var(--muted); }
#liftieBlock { display: grid; gap: 10px; min-width: 0; }
#liftieBlock[hidden] { display: none !important; }
#pLiftieName:disabled { background: #f4f6f8; color: var(--muted); }
.wp-head { font-size: 12px; margin: 2px 0 4px; }
.wp-table {
  width: 100%; border-collapse: collapse; font-size: 11px; line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.wp-table th, .wp-table td {
  padding: 3px 4px; text-align: left; border-bottom: 1px solid var(--line);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 72px;
}
.wp-table th { color: var(--muted); font-weight: 600; border-bottom-color: #c5ccd4; }
.wp-table td.wp-i { width: 1.6em; max-width: 2em; color: var(--muted); }
.wp-table tr.is-noentry { background: #fff3e0; }
.wp-table tr.is-noentry td { font-weight: 600; }
.wp-table .wp-ne { color: #e65100; font-size: 10px; margin-left: 2px; }
.alt-fetch-row { margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.rdp-row {
  margin: 0 0 8px; display: flex; flex-wrap: wrap; align-items: end; gap: 6px;
}
.rdp-row .rdp-eps {
  margin: 0; display: flex; flex-direction: column; gap: 2px;
  font-size: 11px; color: var(--muted); font-weight: 600;
}
.rdp-row .rdp-eps input {
  width: 4.5rem; padding: 5px 6px; border-radius: 7px; border: 1px solid var(--line);
  font: inherit; font-size: 12px; font-weight: 400; color: var(--text, #1a1d21);
}
#btnGetAlts, #btnFixDir, #btnRdp, #btnRdpRedo {
  padding: 6px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font: inherit; font-size: 12px;
}
#btnGetAlts:disabled, #btnFixDir:disabled, #btnRdp:disabled, #btnRdpRedo:disabled {
  opacity: .45; cursor: default;
}
#btnGetAlts:not(:disabled):hover, #btnFixDir:not(:disabled):hover,
#btnRdp:not(:disabled):hover, #btnRdpRedo:not(:disabled):hover {
  border-color: var(--accent); background: #eef4ff;
}
.alt-progress { margin: 0 0 10px; }
.alt-bar {
  height: 8px; border-radius: 999px; background: #d8dde3; overflow: hidden;
}
.alt-bar-fill {
  height: 100%; width: 0%; background: var(--accent); border-radius: 999px;
  transition: width .12s linear;
}
.alt-bar-fill.ok { background: #1b7f3a; }
.alt-bar-fill.fail { background: var(--danger); }
.alt-progress-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-top: 6px;
}
.alt-progress-row .muted { margin: 0; flex: 1; min-width: 0; }
#btnAltStop { padding: 5px 10px; font-size: 12px; flex-shrink: 0; }
#btnAltStop:disabled { opacity: .45; cursor: default; }
.hint { font-size: 12px; color: var(--muted); margin: 0 0 12px; }
.conn-test {
  margin: 0 0 14px; padding: 10px 10px 8px; border: 1px solid var(--line);
  border-radius: 8px; background: #f7f9fb;
}
.conn-head { font-weight: 700; font-size: 13px; margin: 0 0 2px; }
.conn-desc { margin: 0 0 8px; }
.conn-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.conn-btns button {
  padding: 6px 10px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font: inherit; font-size: 12px;
}
.conn-btns button:disabled, #btnConnStop:disabled { opacity: .45; cursor: default; }
.conn-btns button:not(:disabled):hover { border-color: var(--accent); background: #eef4ff; }
.conn-btns button.active {
  border-color: var(--accent); background: #eef4ff; color: var(--accent); font-weight: 600;
}
.conn-pick-status { margin: 8px 0 0; font-size: 12px; }
.conn-pick-marker { background: transparent !important; border: none !important; }
.conn-pick-dot {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid #1f6feb; background: #fff;
  box-sizing: border-box;
}
.conn-pick-dot.a { border-color: #1b7f3a; background: #c8e6c9; box-shadow: 0 0 0 3px rgba(27,127,58,.35); }
.conn-pick-dot.b { border-color: #c62828; background: #ffcdd2; box-shadow: 0 0 0 3px rgba(198,40,40,.35); }
.conn-progress { margin-top: 10px; }
.conn-bar {
  height: 8px; border-radius: 999px; background: #d8dde3; overflow: hidden;
}
.conn-bar-fill {
  height: 100%; width: 0%; background: var(--accent); border-radius: 999px;
  transition: width .12s linear;
}
.conn-bar-fill.fail { background: var(--danger); }
.conn-bar-fill.ok { background: #1b7f3a; }
.conn-progress-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-top: 6px;
}
.conn-progress-row .muted { margin: 0; flex: 1; min-width: 0; }
#btnConnStop { padding: 5px 10px; font-size: 12px; flex-shrink: 0; }
.conn-result { margin: 8px 0 0; font-size: 12px; line-height: 1.35; white-space: pre-wrap; }
.conn-result.ok { color: #1b7f3a; font-weight: 600; }
.conn-result.fail { color: var(--danger); font-weight: 600; }
.conn-result.info { color: var(--muted); font-weight: 500; }
.conn-path-list {
  margin: 8px 0 0; padding: 8px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; font-size: 11px; line-height: 1.35; max-height: 42vh; overflow: auto;
}
.conn-path-dir { margin: 0 0 8px; }
.conn-path-dir:last-child { margin-bottom: 0; }
.conn-path-dir h4 {
  margin: 0 0 4px; font-size: 11px; font-weight: 700; letter-spacing: .01em;
}
.conn-path-dir h4.ok { color: #0f766e; }
.conn-path-dir h4.fail { color: var(--danger); }
.conn-path-dir.ab h4.ok { color: #0f766e; }
.conn-path-dir.ba h4.ok { color: #a21caf; }
.conn-path-hops {
  margin: 0; padding: 0; list-style: none; font-variant-numeric: tabular-nums;
}
.conn-path-hops li {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 6px;
  padding: 2px 0; border-bottom: 1px solid #eef1f4;
}
.conn-path-hops li:last-child { border-bottom: none; }
.conn-path-hops .hop-edge { color: var(--muted); white-space: nowrap; }
.conn-path-hops .hop-via { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn-path-miss { margin: 0; color: var(--danger); }
.conn-path-arrow { pointer-events: none; }
.conn-path-arrow span {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%) rotate(var(--a));
  color: var(--c); font-size: 12px; line-height: 1; text-shadow: 0 0 2px #fff, 0 0 3px #fff;
}
.vertex-marker { background: transparent !important; border: none !important; }
.vertex-wrap {
  display: flex; align-items: center; gap: 4px;
  width: 100%; height: 100%; pointer-events: none;
}
.vertex-icon {
  background: #fff; border: 2px solid #1f6feb; border-radius: 50%;
  width: var(--vh, 14px); height: var(--vh, 14px); flex: 0 0 auto;
  box-sizing: border-box; pointer-events: auto;
}
.vertex-icon.shared { border-color: #e65100; background: #ffe0b2; }
.vertex-icon.fresh { border-color: #00c853; background: #b9f6ca; box-shadow: 0 0 0 4px rgba(0,200,83,.45); animation: pulse 1.2s ease-in-out 3; }
.vertex-icon.noentry { border-color: #c62828; background: #ffcdd2; }
.vertex-pid {
  font: 700 11px/1.1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a1d21; white-space: nowrap;
  text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff, 1px 1px 0 #fff;
  pointer-events: none;
}
.vertex-pid.noentry { color: #c62828; }
.poi-marker { background: transparent !important; border: none !important; cursor: grab; }
.poi-marker.leaflet-marker-dragging { cursor: grabbing; }
.poi-wrap {
  display: flex; align-items: center; gap: 3px;
  pointer-events: none; white-space: nowrap;
}
.poi-icon { font-size: 16px; line-height: 1; filter: drop-shadow(0 0 1px #fff) drop-shadow(0 1px 1px rgba(0,0,0,.35)); }
.poi-resto {
  display: block; flex-shrink: 0; width: 21px; height: 21px;
  object-fit: contain;
  filter: drop-shadow(0 0 1.5px #fff) drop-shadow(0 0 1px #fff)
          drop-shadow(0 1px 2px rgba(0,0,0,.45));
  pointer-events: none; user-select: none;
}
.poi-pid {
  font: 700 11px/1.1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1a1d21;
  text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff, 1px 1px 0 #fff;
}
.poi-orphan {
  font: 800 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #c62828;
  margin-left: 2px;
  text-shadow: 0 0 2px #fff, 0 0 3px #fff, 1px 1px 0 #fff;
}
.poi-wrap.is-orphan .poi-pid { color: #b71c1c; }
.poi-wrap.is-orphan.is-selected .orphan-dot {
  box-shadow: 0 0 0 1px #fff, 0 0 0 4px rgba(31, 95, 214, .45);
}
.poi-wrap.is-orphan.is-selected .poi-pid { color: #1f5fd6; }
.orphan-dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: #ffcdd2; border: 2px solid #c62828; flex-shrink: 0;
  box-shadow: 0 0 0 1px #fff;
}
#orphanProps .conn-head { margin: 0 0 6px; font-weight: 700; }
.vertex-icon.orphan { border-color: #c62828; background: #ffcdd2; }
.poi-wrap.is-selected .poi-icon {
  font-size: 20px;
  filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 4px #1f5fd6) drop-shadow(0 1px 1px rgba(0,0,0,.35));
}
.poi-wrap.is-selected .poi-resto {
  transform: scale(1.15);
  filter: drop-shadow(0 0 1px #fff) drop-shadow(0 0 4px #1f5fd6) drop-shadow(0 1px 1px rgba(0,0,0,.35));
}
.poi-wrap.is-selected .poi-pid { color: #1f5fd6; }
.poi-symbol-icon .poi-resto { transform: scale(1.15); }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(0,200,83,.15); } }
.draw-temp { stroke-dasharray: 6 4; }
.feat-lbl { pointer-events: none; }
.feat-lbl span { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%) rotate(var(--a));
  white-space: nowrap; font: 600 11px/1.1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--c, #222); text-shadow: 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff; }
.feat-lbl.lift span { font-style: italic; color: #b01818; }
.feat-arrow { pointer-events: none; }
.feat-arrow span { position: absolute; left: 0; top: 0; transform: translate(-50%, -50%) rotate(var(--a));
  font: 700 13px/1 sans-serif; color: var(--c, #333); text-shadow: 0 0 2px #fff, 0 0 3px #fff; opacity: .95;
  display: block; width: 16px; height: 16px; text-align: center; }
.feat-arrow.both span { font-size: 11px; letter-spacing: -1px; width: auto; }
.feat-stack { pointer-events: auto; cursor: help; }
.feat-stack span { position: absolute; left: 0; top: 0; transform: translate(-50%, -120%);
  background: #111; color: #fff; font: 700 11px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 3px 7px; border-radius: 10px; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.35); }
.feat-stack span::after { content: ""; position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: #111; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 10000; }
.modal-card { background: #fff; border-radius: 12px; padding: 18px 18px 14px; width: min(360px, 92vw); box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal-card p { margin: 0 0 14px; font-size: 15px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal-actions button { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font: inherit; }
.modal-actions .danger { background: #fff5f5; color: var(--danger); border-color: #f3c0c0; }
@media (max-width: 800px) {
  .workspace { grid-template-columns: 1fr; grid-template-rows: 1fr 40vh; }
  aside { border-left: 0; border-top: 1px solid var(--line); }
}
