:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1a2230;
  --muted: #6b7684;
  --accent: #0077bb;
  --visited: #2ea043;
  --closed: #b0b7c0;
  --shadow: 0 2px 12px rgba(20, 30, 50, 0.12);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); }
#map { position: absolute; inset: 0; }

/* ---------- Onboarding overlay ---------- */
#onboard {
  position: absolute; inset: 0; z-index: 30;
  background: linear-gradient(135deg, #0077bb 0%, #00527f 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.onboard-card {
  background: var(--panel); border-radius: 18px; box-shadow: var(--shadow);
  max-width: 460px; width: 100%; padding: 32px;
}
.onboard-card h1 { margin: 0 0 4px; font-size: 26px; }
.onboard-card .sub { color: var(--muted); margin: 0 0 24px; font-size: 15px; line-height: 1.4; }
.field { margin-bottom: 18px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.4; }
.field input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; outline: none;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,119,187,0.12); }
.seg { display: flex; gap: 8px; margin-bottom: 18px; }
.seg button {
  flex: 1; padding: 10px; border: 1px solid var(--border); background: #fff;
  border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--muted);
}
.seg button.active { border-color: var(--accent); color: var(--accent); background: rgba(0,119,187,0.06); }
.btn-primary {
  width: 100%; padding: 13px; background: var(--accent); color: #fff; border: none;
  border-radius: 10px; font-size: 16px; font-weight: 700; cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: #0069a8; }
.btn-primary:disabled { opacity: .6; cursor: default; }
.examples { margin-top: 20px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.examples code {
  background: #eef1f5; padding: 2px 6px; border-radius: 5px; cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.examples code:hover { background: #dfe4ea; }
.err { color: #c0392b; font-size: 13px; margin-top: 12px; min-height: 18px; }

/* Autocomplete combo box */
.combo { position: relative; }
.suggest {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 5;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
  max-height: 280px; overflow-y: auto; display: none;
}
.suggest.show { display: block; }
.suggest-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; cursor: pointer; border-bottom: 1px solid #f0f2f5;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover, .suggest-item.active { background: rgba(0,119,187,0.08); }
.suggest-item .si-name { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-item .si-meta { font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* Manual-entry fallback */
.manual { margin-bottom: 18px; }
.manual > summary {
  cursor: pointer; font-size: 13px; color: var(--accent); font-weight: 600;
  list-style: none; padding: 4px 0; user-select: none;
}
.manual > summary::-webkit-details-marker { display: none; }
.manual > summary::before { content: '▸ '; }
.manual[open] > summary::before { content: '▾ '; }
.manual[open] { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-top: 8px; }
.manual .field { margin-bottom: 10px; }
.manual .field:last-child { margin-bottom: 0; }

/* ---------- Sidebar ---------- */
#sidebar {
  position: absolute; top: 12px; left: 12px; z-index: 10;
  width: 340px; max-width: calc(100vw - 24px);
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; max-height: calc(100vh - 24px);
}
.sb-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.sb-head .title { display: flex; align-items: center; gap: 8px; }
.sb-head .title h2 { margin: 0; font-size: 17px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-head .title .gear {
  background: none; border: none; cursor: pointer; font-size: 16px; color: var(--muted); padding: 4px;
}
.search-wrap { position: relative; margin-top: 10px; }
.search-wrap input {
  width: 100%; padding: 9px 12px 9px 34px; border: 1px solid var(--border);
  border-radius: 9px; font-size: 14px; outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }
.search-wrap .mag { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.toggles { display: flex; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px;
  border: 1px solid var(--border); border-radius: 20px; font-size: 13px; cursor: pointer; user-select: none;
  background: #fff; color: var(--muted); font-weight: 600;
}
.chip.active { background: rgba(0,119,187,0.08); border-color: var(--accent); color: var(--accent); }

/* ---------- Stats ---------- */
.stats { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.stats .bar { height: 10px; background: #edf0f4; border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.stats .bar > div { height: 100%; background: linear-gradient(90deg, var(--visited), #46c265); width: 0%; transition: width .4s; }
.stats .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.stats .row b { color: var(--text); }
.stats .big { font-size: 22px; font-weight: 800; color: var(--visited); }

/* ---------- List ---------- */
.list { overflow-y: auto; flex: 1; }
.lib-item {
  padding: 11px 16px; border-bottom: 1px solid #f0f2f5; cursor: pointer; display: flex; gap: 10px; align-items: flex-start;
}
.lib-item:hover { background: #f6f8fb; }
.lib-item .emoji { font-size: 20px; line-height: 1.2; }
.lib-item .info { flex: 1; min-width: 0; }
.lib-item .nm { font-weight: 600; font-size: 14px; }
.lib-item.visited .nm { color: var(--visited); }
.lib-item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-item.dim { opacity: 0.42; }
.lib-item .status-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.dot-open { background: var(--visited); }
.dot-closed { background: var(--closed); }
.dot-unknown { background: #d9b310; }
.lib-item .miss-badge {
  flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: #fdeaea; color: #c0392b; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; margin-top: 1px;
}
.list-empty { padding: 24px 16px; text-align: center; color: var(--muted); font-size: 14px; }

.sb-foot { padding: 8px 16px; border-top: 1px solid var(--border); text-align: center; }
.sb-foot a { color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none; }
.sb-foot a:hover { color: var(--accent); }

/* ---------- Popup ---------- */
.maplibregl-popup-content { border-radius: 12px; padding: 0; overflow: hidden; box-shadow: var(--shadow); }
.pop { width: 260px; }
.pop-head { padding: 14px 16px 10px; }
.pop-head .nm { font-weight: 700; font-size: 16px; margin: 0; }
.pop-head .op { color: var(--muted); font-size: 12px; margin-top: 3px; }
.pop-body { padding: 0 16px 12px; font-size: 13px; }
.pop-body .r { display: flex; gap: 8px; margin-top: 8px; color: var(--text); }
.pop-body .r .k { color: var(--muted); flex-shrink: 0; }
.pop-body a { color: var(--accent); text-decoration: none; word-break: break-all; }
.status-badge { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 12px; font-weight: 700; }
.badge-open { background: rgba(46,160,67,0.14); color: var(--visited); }
.badge-closed { background: rgba(176,183,192,0.22); color: #6b7684; }
.badge-unknown { background: rgba(217,179,16,0.16); color: #9a7d00; }
/* Visited toggle switch */
.visit-toggle {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 14px; padding: 9px 12px; background: #f6f8fb; border-radius: 9px; cursor: pointer;
}
.visit-toggle .vt-label { font-size: 14px; font-weight: 700; }
.switch {
  position: relative; width: 46px; height: 26px; border-radius: 14px; background: #cfd6df;
  transition: background .18s; flex-shrink: 0; outline: none;
}
.switch:focus-visible { box-shadow: 0 0 0 3px rgba(0,119,187,0.3); }
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25); transition: transform .18s;
}
.switch.on { background: var(--visited); }
.switch.on .knob { transform: translateX(20px); }

/* OSM tag breakdown (Missing OSM data mode) */
.tags-block { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.tags-title { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.tags-count { color: #c0392b; }
.tags-complete { color: var(--visited); }
.tag-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 2px 0; }
.tag-row .tag-k { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.tag-row .tag-v { text-align: right; word-break: break-all; }
.tag-present .tag-v { color: var(--text); }
.tag-missing .tag-k { color: #c0392b; }
.tag-missing .tag-v { color: #c0392b; font-style: italic; }

/* ---------- Loading ---------- */
#loading {
  position: absolute; inset: 0; z-index: 25; background: rgba(247,248,250,0.94);
  display: none; align-items: center; justify-content: center; flex-direction: column; gap: 16px;
}
#loading.show { display: flex; }
.spinner { width: 44px; height: 44px; border: 4px solid #d7dde5; border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading .msg { color: var(--muted); font-size: 15px; }

.toast {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 40;
  background: #1a2230; color: #fff; padding: 10px 18px; border-radius: 22px; font-size: 14px;
  box-shadow: var(--shadow); opacity: 0; transition: opacity .25s; pointer-events: none;
}
.toast.show { opacity: 1; }

@media (max-width: 560px) {
  #sidebar { width: calc(100vw - 24px); max-height: 45vh; }
}

/* ==================== Data QA page ==================== */
body.qa-page { height: auto; background: var(--bg); }

.qa-head { background: linear-gradient(135deg, #0077bb 0%, #00527f 100%); color: #fff; padding: 28px 20px 0; }
.qa-head-inner { max-width: 1060px; margin: 0 auto; }
.qa-title { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.qa-title h1 { margin: 0; font-size: 26px; }
.qa-back { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 14px; font-weight: 600; }
.qa-back:hover { color: #fff; }
.qa-country { display: inline-flex; gap: 6px; }
.qa-country a {
  padding: 2px 10px; border: 1px solid rgba(255,255,255,0.4); border-radius: 999px;
  font-size: 13px; font-weight: 600; text-decoration: none; color: rgba(255,255,255,0.85);
}
.qa-country a:hover { color: #fff; border-color: rgba(255,255,255,0.7); }
.qa-country a.active { background: rgba(255,255,255,0.18); color: #fff; border-color: #fff; }
/* Same toggle on the QA map's light floating panel. */
.qm-country { display: inline-flex; gap: 6px; margin-top: 6px; }
.qm-country a {
  padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px;
  font-size: 12px; font-weight: 600; text-decoration: none; color: var(--muted);
}
.qm-country a:hover { color: var(--accent); border-color: var(--accent); }
.qm-country a.active { color: var(--accent); border-color: var(--accent); background: rgba(0,119,187,0.06); }
.qa-sub { margin: 8px 0 4px; max-width: 640px; font-size: 15px; line-height: 1.45; color: rgba(255,255,255,0.92); }
.qa-sub a { color: #fff; }
.qa-editor-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0 6px; font-size: 13px; color: rgba(255,255,255,0.9); }
.qa-editor-pick select {
  padding: 4px 8px; border-radius: 7px; border: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.12); color: #fff; font-size: 13px; cursor: pointer;
}
.qa-editor-pick select option { color: #1a2230; }
.qa-editor-hint { color: rgba(255,255,255,0.7); font-size: 12px; }

/* Overpass server picker — same row treatment as the editor picker. */
.qa-endpoint-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; font-size: 13px; color: rgba(255,255,255,0.9); }
.qa-endpoint-pick input {
  flex: 1 1 340px; max-width: 460px; padding: 4px 8px; border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.12);
  color: #fff; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.qa-endpoint-pick input::placeholder { color: rgba(255,255,255,0.5); }
.qa-endpoint-hint { color: rgba(255,255,255,0.7); font-size: 12px; flex-basis: 100%; }
.qa-endpoint-hint.qa-endpoint-custom { color: rgba(163,230,180,0.95); }

/* Pending state for a button that's waiting on the network. */
.qa-spinner {
  display: inline-block; width: 11px; height: 11px; margin-right: 6px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: qa-spin 0.7s linear infinite;
}
@keyframes qa-spin { to { transform: rotate(360deg); } }
.qa-link-btn.is-busy, .qa-more.is-busy { opacity: 0.75; cursor: progress; }
@media (prefers-reduced-motion: reduce) { .qa-spinner { animation-duration: 2.4s; } }

.qa-meta { margin: 0 0 14px; font-size: 13px; color: rgba(255,255,255,0.75); }
.qa-nav { display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: 14px; }
.qa-nav a {
  color: #fff; text-decoration: none; font-size: 14px; font-weight: 600;
  padding: 7px 14px; border-radius: 18px; background: rgba(255,255,255,0.14);
}
.qa-nav a:hover { background: rgba(255,255,255,0.26); }

.qa-main { max-width: 1060px; margin: 0 auto; padding: 20px; }
.qa-section {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 24px; margin-bottom: 20px; scroll-margin-top: 12px;
}
.qa-section h2 { margin: 0 0 12px; font-size: 20px; }

/* Collapsible sections (<details class="qa-section">) */
.qa-section > summary { cursor: pointer; list-style: none; user-select: none; }
.qa-section > summary::-webkit-details-marker { display: none; }
.qa-section > summary h2 { display: inline; }
.qa-section > summary::before {
  content: '▸'; display: inline-block; margin-right: 8px; color: var(--muted);
  font-size: 15px; transition: transform .15s;
}
.qa-section[open] > summary::before { transform: rotate(90deg); }
.qa-section[open] > summary { margin-bottom: 12px; }

/* Small filter input (wikidata-gaps table) */
.qa-filter {
  width: 100%; max-width: 320px; margin-bottom: 12px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 9px; font-size: 14px; outline: none;
}
.qa-filter:focus { border-color: var(--accent); }
.qa-filter-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.qa-filter-row .qa-filter { margin-bottom: 0; }
.qa-state-select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px;
  font-size: 14px; background: #fff; cursor: pointer; outline: none;
}
.qa-state-select:focus { border-color: var(--accent); }
.qa-section h3 { margin: 22px 0 10px; font-size: 15px; }
.qa-note { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 4px 0 12px; }
.qa-note code, .qa-section code {
  background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Stat tiles */
.qa-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 8px; }
.qa-tile { background: #f6f8fb; border-radius: 10px; padding: 14px 16px; }
.qa-tile-link { display: block; text-decoration: none; color: inherit; transition: background .12s; }
.qa-tile-link:hover { background: #eaeff6; }
.qa-tile-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.qa-tile-value { font-size: 26px; font-weight: 700; margin-top: 2px; }

/* Completion meters — track is a lighter step of the accent hue */
.qa-meters { display: flex; flex-direction: column; gap: 7px; max-width: 560px; }
.qa-meter-row { display: flex; align-items: center; gap: 10px; }
.qa-meter-label { width: 150px; flex-shrink: 0; text-align: right; font-size: 13px; }
.qa-meter { flex: 1; height: 10px; border-radius: 6px; background: rgba(0,119,187,0.14); overflow: hidden; }
.qa-meter > div { height: 100%; background: var(--accent); border-radius: 6px; }
.qa-meter-val { width: 42px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Tables */
.qa-table-wrap { overflow-x: auto; }
.qa-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.qa-table th {
  text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border);
  font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; white-space: nowrap;
}
.qa-table th.num, .qa-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.qa-table td { padding: 7px 10px; border-bottom: 1px solid #f0f2f5; }
.qa-table tbody tr:hover { background: #f6f8fb; }
.qa-table a { color: var(--accent); text-decoration: none; }
.qa-yes { color: var(--visited); font-weight: 700; }
.qa-no { color: #c0392b; font-weight: 700; }
.qa-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.qa-link-btn {
  background: none; border: none; padding: 0; color: var(--accent); font-size: 13px;
  font-weight: 600; cursor: pointer;
}
.qa-icon-link { text-decoration: none; color: var(--accent); line-height: 1; }
.qa-icon-link:hover { opacity: 0.75; }
.qa-icon { height: 15px; width: 15px; display: inline-block; vertical-align: -3px; }
.qa-icon-wd { width: 22px; }  /* wider aspect (barcode logo) */
.qa-link-btn:hover { text-decoration: underline; }
.qa-more {
  margin-top: 12px; padding: 9px 16px; border: 1px solid var(--border); border-radius: 9px;
  background: #fff; color: var(--accent); font-weight: 600; font-size: 13px; cursor: pointer;
}
.qa-more:hover { background: #f6f8fb; }

/* Collision cards */
.qa-coll {
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px 14px; align-items: center;
}
.qa-coll-side { min-width: 0; }
.qa-coll-name { display: block; font-weight: 600; font-size: 14px; }
.qa-coll-meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; margin-top: 2px; }
.qa-coll-vs { color: var(--muted); font-size: 12px; font-weight: 700; }
.qa-coll-hint { grid-column: 1 / -1; font-size: 12px; color: #9a7d00; background: rgba(217,179,16,0.1); border-radius: 6px; padding: 5px 10px; }
.qa-badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.qa-badge-wd { background: rgba(46,160,67,0.14); color: var(--visited); }
.qa-badge-wd a { color: var(--visited); text-decoration: none; }
.qa-badge-miss { background: rgba(192,57,43,0.1); color: #c0392b; }
.qa-badge-mixed { background: rgba(217,179,16,0.16); color: #9a7d00; }
.qa-badge-mixed a { color: #9a7d00; text-decoration: none; }
.qa-badge-not { background: #eef1f5; color: var(--muted); }
/* Where a suggestion came from, subordinate to the item it labels. */
.qa-badge-src { font-weight: 600; opacity: 0.72; font-size: 10px; text-transform: uppercase; letter-spacing: 0.03em; }
.qa-badge-not a { color: var(--muted); text-decoration: line-through; }
.qa-delta-miss { color: #9a7d00; font-weight: 700; }   /* fewer in OSM than Wikidata */
.qa-delta-extra { color: var(--accent); font-weight: 700; } /* more in OSM than Wikidata */

/* Ambiguous-name cards (shared names, different places) */
.qa-amb { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.qa-amb-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.qa-amb-cluster {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 6px 0 6px 12px; border-top: 1px solid #f0f2f5; font-size: 13px;
}
.qa-amb-where { font-weight: 600; }
.qa-amb-count { color: var(--muted); }
.qa-amb-cluster .qa-actions a { font-size: 12px; }

/* Missing/untagged branches (IMLS PLS) */
.pls-sys { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.pls-sys-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.pls-untagged-n { color: var(--accent); }
.pls-qid-row { margin: 0 0 8px 2px; }
.pls-qid {
  display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 6px;
  background: rgba(46,160,67,0.12); color: var(--visited);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.pls-qid a { color: inherit; font-weight: 700; text-decoration: none; }
.pls-qid-suggested { background: rgba(217,179,16,0.16); color: #9a7d00; }

/* The "here's the fix, take it to an editor" bar on an operator mismatch. */
.wd-fix {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin: 0 0 8px 2px; padding: 7px 10px;
  border: 1px dashed var(--border); border-radius: 8px; background: #f8fafc;
}
.wd-fix-tags code {
  font-size: 12px; padding: 2px 6px; border-radius: 5px;
  background: rgba(46,160,67,0.12); color: var(--visited);
}
.wd-fix-tags code.wd-fix-guess { background: rgba(217,179,16,0.16); color: #9a7d00; }
.wd-fix-actions { display: flex; gap: 14px; align-items: center; white-space: nowrap; }
.pls-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) minmax(0, 2fr) 120px 20px;
  gap: 10px; align-items: center;
  padding: 5px 0 5px 12px; border-top: 1px solid #f0f2f5; font-size: 13px;
}
.pls-row .pls-name { font-weight: 600; }
.pls-row .pls-detail { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pls-row .pls-meta { text-align: right; }
.pls-row .pls-geo { font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.pls-row .qa-icon-link { justify-self: end; }
.pls-missing .pls-name::before { content: '＋ '; color: var(--visited); font-weight: 700; }
.pls-untagged .pls-name::before { content: '🏷️ '; }
.pls-disc .pls-name::before { content: '⚑ '; color: #9a7d00; }

/* Explorer */
.qa-explorer-search { position: relative; max-width: 460px; margin-bottom: 16px; }
.qa-explorer-search input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 15px; outline: none;
}
.qa-explorer-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,119,187,0.12); }
.qa-sys-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.qa-sys-head h3 { margin: 0; font-size: 18px; }
.qa-sys-meta { font-size: 13px; color: var(--muted); }
.qa-sys-meta a { color: var(--accent); text-decoration: none; }
.qa-live-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.qa-live-btn {
  padding: 9px 16px; border: none; border-radius: 9px; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 13px; cursor: pointer;
}
.qa-live-btn:hover { background: #0069a8; }
.qa-live-btn:disabled { opacity: 0.6; cursor: default; }
.qa-live-note { font-size: 13px; color: var(--muted); }

.qa-foot { max-width: 1060px; margin: 0 auto; padding: 6px 20px 28px; font-size: 12px; color: var(--muted); }
.qa-foot a { color: var(--accent); text-decoration: none; }

@media (max-width: 700px) {
  .qa-meter-label { width: 110px; }
  .qa-coll { grid-template-columns: 1fr; }
  .qa-coll-vs { display: none; }
}

/* ---- Augment page ---- */
.aug-josm-callout {
  background: rgba(255,255,255,0.14); border: 1px solid rgba(255,255,255,0.28);
  border-radius: 10px; padding: 12px 14px; margin: 4px 0 14px; font-size: 13px; line-height: 1.5;
}
.aug-josm-callout code { background: rgba(255,255,255,0.22); padding: 1px 5px; border-radius: 4px; }
.aug-josm-status { display: inline-block; margin-top: 6px; font-weight: 700; }
.aug-josm-status.ok { color: #baf7c8; }
.aug-josm-status.warn { color: #ffd7a1; }

.aug-sys-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.aug-sys-head h3 { margin: 0; font-size: 18px; }
.aug-sys-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.aug-send-all {
  padding: 8px 15px; border: none; border-radius: 9px; background: var(--visited); color: #fff;
  font-weight: 700; font-size: 13px; cursor: pointer;
}
.aug-send-all:hover { filter: brightness(0.94); }

.aug-rows { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.aug-row { border: 1px solid var(--border); border-radius: 9px; padding: 9px 12px; }
.aug-row.aug-row-conflict-only { border-left: 3px solid #d9b310; background: rgba(217,179,16,0.04); }
.aug-row-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.aug-kind {
  font-size: 11px; font-weight: 700; color: var(--muted); text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; flex-shrink: 0;
}
.aug-kind:hover { color: var(--accent); text-decoration: underline; }
.aug-name { font-weight: 600; }
.aug-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 7px 0; }
.aug-chip {
  font-size: 12px; background: #eef4fb; border: 1px solid #d8e6f4; color: #244; border-radius: 6px;
  padding: 2px 7px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.aug-chip code { background: none; padding: 0; color: var(--accent); font-weight: 700; }
/* Copy-as-lines button rendered inside a chip block (QA map popups). */
.qm-copy-tags {
  border: none; background: none; color: var(--accent); cursor: pointer;
  font-size: 11px; font-weight: 600; padding: 2px 4px; align-self: center;
}
.qm-copy-tags:hover { text-decoration: underline; }
.aug-row-actions { display: flex; align-items: center; gap: 12px; }
.aug-send {
  padding: 6px 13px; border: none; border-radius: 8px; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 12px; cursor: pointer;
}
.aug-send:hover { background: #0069a8; }
.aug-fallback { font-size: 12px; color: var(--muted); text-decoration: none; }
.aug-fallback:hover { color: var(--accent); }
.aug-row .pls-geo { font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin-left: auto; }

/* Conflicts — PLS value differs from OSM; display-only, never sent. */
.aug-conflicts { margin: 7px 0; padding: 7px 9px; border-radius: 7px; background: rgba(217,179,16,0.1); border: 1px solid rgba(217,179,16,0.35); }
.aug-conflict-label { display: block; font-size: 12px; font-weight: 700; color: #9a7d00; margin-bottom: 4px; }
.aug-conflict-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-size: 12px; padding: 2px 0; }
.aug-conflict-row code { background: none; padding: 0; color: #7a6400; font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; min-width: 120px; }
.aug-cf-osm { color: var(--muted); }
.aug-cf-pls { color: #244; }
.aug-cf-osm::before, .aug-cf-pls::before { content: ''; }

/* ==================== QA map page ==================== */
#qm-panel {
  position: absolute; top: 12px; left: 12px; z-index: 10;
  width: 360px; max-width: calc(100vw - 24px);
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; max-height: calc(100vh - 24px);
}
.qm-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--border); }
.qm-title { display: flex; align-items: center; gap: 10px; }
.qm-title h1 { margin: 0; font-size: 18px; flex: 1; }
.qm-gear {
  background: none; border: none; cursor: pointer; font-size: 15px;
  color: var(--muted); padding: 2px 4px;
}
.qm-collapse {
  background: none; border: 1px solid var(--border); border-radius: 7px;
  cursor: pointer; font-size: 12px; color: var(--muted); padding: 2px 8px;
}
.qm-sub { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.qm-prefs { margin-top: 8px; padding: 9px 11px; background: #f6f8fb; border-radius: 9px; }
.qm-prefs[hidden] { display: none; }
.qm-editor { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.qm-editor select {
  padding: 3px 7px; border-radius: 7px; border: 1px solid var(--border);
  background: #fff; font-size: 12px; cursor: pointer;
}
.qm-editor-hint { font-size: 11px; }

.qm-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
#qm-panel.collapsed .qm-body, #qm-panel.collapsed .qm-foot,
#qm-panel.collapsed .qm-sub, #qm-panel.collapsed .qm-prefs { display: none; }

.qm-chips { display: flex; gap: 6px; padding: 10px 16px 4px; flex-wrap: wrap; }
.qm-chip { padding: 5px 10px; font-size: 12px; gap: 5px; }
.qm-chip.active { background: rgba(0,119,187,0.07); }
.qm-chip-n { font-weight: 700; font-size: 11px; opacity: 0.75; }
.qm-chip-sm { padding: 3px 9px; font-size: 11px; }
.qm-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  background: var(--c); border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.12);
}
.qm-dot-lg { width: 12px; height: 12px; margin-top: 3px; }
.qm-gaptags { display: flex; gap: 6px; padding: 6px 16px 2px; flex-wrap: wrap; align-items: center; }
.qm-gaptags[hidden] { display: none; }
.qm-gaptags-label { font-size: 11px; color: var(--muted); font-weight: 600; }

.qm-viewbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 16px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  margin-top: 8px; font-size: 13px; color: var(--muted);
}
.qm-viewbar b { color: var(--text); }
.qm-locate {
  border: 1px solid var(--border); background: #fff; border-radius: 16px;
  padding: 4px 12px; font-size: 12px; font-weight: 600; color: var(--accent); cursor: pointer;
}
.qm-locate:hover { background: rgba(0,119,187,0.06); }

.qm-list { overflow-y: auto; flex: 1; min-height: 80px; }
.qm-item { align-items: flex-start; }

.qm-foot { padding: 8px 16px; border-top: 1px solid var(--border); display: flex; gap: 16px; justify-content: center; }
.qm-foot a { color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none; }
.qm-foot a:hover { color: var(--accent); }

/* Issue popups */
.qm-pop { width: 280px; }
.qm-badge {
  display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 11px; font-weight: 700;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff);
}
.qm-pop .pop-body { padding-bottom: 14px; }
.qm-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.qm-act { font-size: 12px; font-weight: 600; }
.qm-act-btn {
  padding: 6px 12px; border: none; border-radius: 8px; background: var(--accent); color: #fff;
  font-weight: 700; font-size: 12px; cursor: pointer;
}
.qm-act-btn:hover { background: #0069a8; }
.qm-act-btn:disabled { opacity: 0.6; cursor: default; }
.qm-tagcard-note { color: var(--muted); font-weight: 400; }

/* Per-outlet list in the unmatched-system popup */
.qm-outlet-list {
  margin-top: 10px; max-height: 180px; overflow-y: auto;
  border-top: 1px solid var(--border); padding-top: 6px;
}
.qm-outlet {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 2px; font-size: 12px; cursor: pointer; border-radius: 6px;
}
.qm-outlet:hover { background: #f6f8fb; }
.qm-outlet-n { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qm-outlet-m { flex-shrink: 0; font-size: 11px; color: var(--muted); }
/* Lazy-loaded operator tags under each matched outlet */
.qm-outlet-tags { margin: -2px 0 5px 20px; font-size: 11px; color: var(--muted); line-height: 1.5; word-break: break-word; }
.qm-outlet-tags code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px;
  background: #eef1f5; padding: 0 3px; border-radius: 3px;
}
.qm-otag { margin-right: 6px; }
.qm-outlet-tags-none { font-style: italic; }

@media (max-width: 560px) {
  #qm-panel { width: calc(100vw - 24px); max-height: 52vh; }
}

/* Background-action toast (e.g. JOSM remote-control feedback) */
.qa-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(12px);
  background: #1a2230; color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 14px;
  box-shadow: 0 4px 16px rgba(20,30,50,0.25); opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; z-index: 100; max-width: 90vw; text-align: center;
}
.qa-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.qa-toast-error { background: #c0392b; }
