:root {
  --bg: #f4f6f9; --panel: #ffffff; --panel-2: #f1f4f8; --text: #1b2330; --muted: #6b7786; --border: #e2e7ee;
  --accent: #4e9a4e; --accent-2: #3d7d3d; --accent-soft: #e6f1e6; --border-line: #3a4a48; --cluster: #559255; --danger: #c0392b; --danger-soft: #fdeceb; --ok: #1e8e5a; --ok-soft: #e6f6ee;
  --shadow: 0 6px 24px rgba(16, 24, 40, .08); --radius: 14px; --side-w: 380px;
  --k-ba: #c0392b; --k-tt: #e67e22; --k-nr: #27ae60; --k-tn: #2980b9; --k-za: #8e44ad; --k-bb: #d4a017; --k-po: #16a085; --k-ke: #e84393;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0f141b; --panel: #171e27; --panel-2: #1f2834; --text: #e8edf3; --muted: #94a0b0; --border: #2a3441;
  --accent: #6fbf6f; --accent-2: #8fd48f; --accent-soft: #1d3320; --border-line: #8aa39f; --cluster: #6fbf6f; --danger: #ff6b5b; --danger-soft: #3a1f1c; --ok: #4ccf8a; --ok-soft: #173126;
  --shadow: 0 6px 24px rgba(0,0,0,.4);
} }
:root[data-theme="dark"] {
  --bg: #0f141b; --panel: #171e27; --panel-2: #1f2834; --text: #e8edf3; --muted: #94a0b0; --border: #2a3441;
  --accent: #6fbf6f; --accent-2: #8fd48f; --accent-soft: #1d3320; --border-line: #8aa39f; --cluster: #6fbf6f; --danger: #ff6b5b; --danger-soft: #3a1f1c; --ok: #4ccf8a; --ok-soft: #173126;
  --shadow: 0 6px 24px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; } a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.app { display: grid; grid-template-columns: var(--side-w) 1fr; height: 100dvh; }
.side { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; z-index: 2; }
.side-scroll { overflow: auto; flex: 1; min-height: 0; padding: 0 20px 20px; }
.side header { padding: 22px 20px 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.side h1 { font-size: 24px; font-weight: 700; margin-top: 10px; letter-spacing: -.01em; }
.side header p { color: var(--muted); margin: 6px 0 0; font-size: 14px; }
#map { height: 100%; width: 100%; background: var(--bg); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 16px; }
.stat { background: var(--panel-2); border-radius: 12px; padding: 12px 12px 10px; }
.stat b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field { position: relative; margin-bottom: 10px; }
.field input, .field select, .field textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; outline: none; transition: border-color .15s, box-shadow .15s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--panel); }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.field input[readonly] { color: var(--muted); }
.field .clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; display: none; }
.field.has-value .clear { display: block; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel); cursor: pointer; font-size: 13px; transition: all .15s; user-select: none; }
.chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); display: inline-block; }
.chip small { color: var(--muted); font-weight: 600; }
.chip.off { opacity: .4; } .chip:hover { border-color: var(--accent); }
.section-title { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; margin: 14px 0 8px; }
.section-title button { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 12px; text-transform: none; letter-spacing: 0; padding: 0; font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; cursor: pointer; transition: background .12s; }
.list li:hover, .list li.active { background: var(--panel-2); }
.list li i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.list li .t { flex: 1; min-width: 0; }
.list li .t b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list li .t span { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list li .actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.list li:hover .actions, .list li.active .actions { opacity: 1; }
.list .empty { color: var(--muted); padding: 16px 10px; text-align: center; cursor: default; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--panel); color: var(--accent); box-shadow: inset 0 0 0 1px var(--border); }
.icon-btn.danger:hover { color: var(--danger); }
.icon-btn svg { width: 16px; height: 16px; }
.side footer { padding: 12px 20px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn:hover { background: var(--accent-2); text-decoration: none; } .btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--panel-2); color: var(--text); border-color: var(--border); } .btn.secondary:hover { border-color: var(--accent); background: var(--panel-2); }
.btn.danger { background: var(--danger-soft); color: var(--danger); } .btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.card { background: var(--panel-2); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.card h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.card .field input, .card .field select, .card .field textarea { background: var(--panel); }
.hint { color: var(--muted); font-size: 12.5px; margin: 6px 0 0; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); z-index: 30; max-height: 300px; overflow: auto; display: none; }
.suggest.open { display: block; }
.suggest div { padding: 9px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.suggest div:hover, .suggest div.sel { background: var(--accent-soft); }
.suggest div b { font-weight: 600; } .suggest div span { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.suggest div .tag { font-size: 11px; background: var(--ok-soft); color: var(--ok); padding: 2px 7px; border-radius: 999px; font-weight: 700; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-weight: 600; opacity: 0; transition: all .25s; z-index: 1000; pointer-events: none; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); color: #fff; }
.overlay { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 500; padding: 16px; }
.overlay.modal { background: rgba(10, 14, 20, .55); backdrop-filter: blur(3px); z-index: 900; }
.login { background: var(--panel); border-radius: 18px; padding: 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.login h1 { font-size: 22px; margin: 12px 0 4px; } .login p { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
.login .err { color: var(--danger); font-size: 13.5px; min-height: 18px; margin: 6px 0 0; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); min-width: 230px; padding: 6px; display: none; z-index: 40; }
.menu.open .menu-list { display: block; }
.menu-list a, .menu-list button { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.menu-list a:hover, .menu-list button:hover { background: var(--panel-2); text-decoration: none; }
.menu-list small { display: block; color: var(--muted); font-size: 12px; }
.log { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.log li { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.log li time { color: var(--muted); flex: none; font-variant-numeric: tabular-nums; }
.log li .a { font-weight: 700; flex: none; width: 80px; }
details { margin-bottom: 10px; } details summary { cursor: pointer; font-weight: 600; padding: 10px 0; color: var(--text); list-style: none; display: flex; justify-content: space-between; }
details summary::after { content: "+"; color: var(--muted); } details[open] summary::after { content: "–"; }
.side-toggle { display: none; }
.leaflet-container { font: inherit; }
.basemap { filter: saturate(.75) contrast(.95); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .basemap { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.5); } }
:root[data-theme="dark"] .basemap { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9) saturate(.5); }
.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border-radius: 12px; box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--panel); }
.leaflet-popup-content { margin: 14px 16px; font-size: 14px; line-height: 1.4; }
.popup h3 { font-size: 16px; margin-bottom: 4px; } .popup .k { color: var(--muted); font-size: 13px; } .popup .note { margin-top: 6px; font-style: italic; }
.popup .pin { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-control-attribution { background: color-mix(in srgb, var(--panel) 80%, transparent) !important; color: var(--muted) !important; font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--accent) !important; }
.logo-marker img { display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.45)); transition: transform .12s; }
.logo-marker:hover img { transform: scale(1.18); }
.leaflet-tooltip { background: var(--text); color: var(--bg); border: 0; border-radius: 6px; font-weight: 600; font-size: 12px; padding: 4px 8px; box-shadow: var(--shadow); }
.leaflet-tooltip-top:before { border-top-color: var(--text); }
.draft-marker { width: 22px; height: 22px; border-radius: 50% 50% 50% 0; background: var(--accent); transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.35); }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side { order: 2; border-right: 0; border-top: 1px solid var(--border); max-height: 55dvh; transition: max-height .25s; border-radius: 18px 18px 0 0; box-shadow: 0 -8px 30px rgba(0,0,0,.12); }
  .side.collapsed { max-height: 64px; overflow: hidden; }
  .side header { padding: 12px 16px 8px; } .side-scroll { padding: 0 16px 16px; }
  .side h1 { font-size: 19px; }
  #map { order: 1; min-height: 45dvh; }
  .side-toggle { display: block; position: absolute; left: 50%; top: 8px; transform: translateX(-50%); width: 44px; height: 5px; border-radius: 999px; background: var(--border); border: 0; padding: 0; cursor: pointer; }
  .side { position: relative; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}
