:root {
  --bg: #05070A; --panel: #0c1118; --panel2: #121923; --line: #1f2936; --text: #e8edf3; --muted: #8a9bb0;
  --accent: #00b0aa; --accent-ink: #00110f; --good: #2ecc71; --bad: #ff5a5f; --warn: #f5b942; --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .right { margin-left: auto; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { font-weight: 700; letter-spacing: .06em; padding: 4px 10px 16px; }
.brand span { color: var(--accent); }
.nav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--muted); margin-bottom: 2px; }
.nav a:hover { background: var(--panel2); color: var(--text); }
.nav a.on { background: var(--panel2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.main { padding: 22px 26px 80px; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.menu-btn { display: none; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, 1fr); } .g3 { grid-template-columns: repeat(3, 1fr); } .g2 { grid-template-columns: repeat(2, 1fr); }
.stat .n { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat .l { color: var(--muted); font-size: 13px; }

.btn { background: var(--panel2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 9px; cursor: pointer; }
.btn:hover { border-color: #33455b; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #33455b; }
input[type=checkbox], input[type=radio] { width: auto; }
label.f { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--panel2); border: 1px solid var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #55657a; display: inline-block; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(46,204,113,.18); }
.badge.ok { color: var(--good); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--bad); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
.tablewrap { overflow-x: auto; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.mcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mcard .img { aspect-ratio: 16/10; background: #000 center/cover no-repeat; position: relative; }
.mcard .img .k { position: absolute; left: 8px; top: 8px; }
.mcard .body { padding: 10px; }
.mcard .name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcard.pick { cursor: pointer; } .mcard.pick:hover, .mcard.sel { border-color: var(--accent); }

.drop { border: 2px dashed #2a3748; border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); cursor: pointer; }
.drop.over { border-color: var(--accent); color: var(--text); }
.bar { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 6px; } .bar i { display: block; height: 100%; background: var(--accent); width: 0; }

.pl { display: flex; flex-direction: column; gap: 8px; }
.pli { display: grid; grid-template-columns: 22px 64px 1fr; gap: 8px 10px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.pli.drag { opacity: .5; }
.pli > :last-child { grid-column: 2 / -1; }
.pli .handle { cursor: grab; color: var(--muted); text-align: center; user-select: none; }
.pli .t { width: 64px; height: 40px; background: #000 center/cover; border-radius: 6px; }
.pli input[type=number] { width: 70px; padding: 6px 8px; }
.pli select { width: auto; padding: 6px 8px; }
.pli .row { flex-wrap: wrap; }
.savebar { position: sticky; bottom: 0; background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; margin-top: 12px; }

.split { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
#map, .mapbox { height: 520px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 0; }
.mapbox.small { height: 240px; }
.leaflet-container { background: #0c1118; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 14px; z-index: 1000; overflow: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 620px; padding: 20px; }
.modal.wide { max-width: 860px; }
.modal .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; max-height: 220px; overflow: auto; }
.checks label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 14px; }

#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 2000; align-items: center; }
.toast { background: #1b2635; border: 1px solid #33455b; padding: 10px 16px; border-radius: 10px; display: flex; gap: 14px; align-items: center; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
.toast.err { border-color: var(--bad); }

.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 380px; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.chart div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.err { color: var(--bad); font-size: 13px; margin: 8px 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: -240px; width: 230px; z-index: 900; transition: left .2s; }
  .side.open { left: 0; }
  .menu-btn { display: inline-block; }
  .main { padding: 16px 14px 80px; }
  .g4, .g3 { grid-template-columns: repeat(2, 1fr); } .split { grid-template-columns: 1fr; }
  .pli { grid-template-columns: 18px 52px 1fr; }
  #map { height: 380px; }
}
