:root {
  --bg: #12151a;
  --panel: #1a1e25;
  --panel-2: #222731;
  --line: #2e3440;
  --text: #e4e7ec;
  --muted: #8b93a1;
  --accent: #e0a64a;
  --ok: #4cc38a;
  --warn: #e0a64a;
  --bad: #e5534b;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
h1 { font-size: 16px; margin: 0; }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.muted { color: var(--muted); }
h2.spaced { margin-top: 12px; }
.small { font-size: 12px; }
button, select, input { font: inherit; color: var(--text); }
select, input[type=search], input:not([type]), input[type=password] {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
input[type=range] { flex: 1; accent-color: var(--accent); }
button.link { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; }
button.link:hover { color: var(--text); }

#app { display: flex; height: 100vh; position: relative; }
#side {
  width: 340px; flex: none; background: var(--panel); border-right: 1px solid var(--line);
  overflow-y: auto; display: flex; flex-direction: column;
}
#side section { padding: 12px 14px; border-bottom: 1px solid var(--line); }
#side.collapsed { width: 44px; overflow: hidden; }
#side.collapsed section, #side.collapsed .side-head > div, #side.collapsed .side-head form { display: none; }
.side-head { display: flex; align-items: flex-start; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.side-head > div { flex: 1; }
#map { flex: 1; background: #0d1014; }
.leaflet-container { background: #0d1014; font: inherit; }

.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; margin-bottom: 8px; }
.checks label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.checks .n { color: var(--muted); font-size: 12px; margin-left: auto; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; white-space: nowrap; }
.row select { flex: 1; width: auto; }

.btn { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; cursor: pointer; margin-top: 6px; }
.btn:hover { border-color: var(--accent); }
textarea { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 6px; font: 12px ui-monospace, monospace; padding: 6px; }
#map.calibrating { cursor: crosshair; }
.calib-pop { display: grid; gap: 6px; }
.calib-pop input, .calib-pop select { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

.tabs { display: flex; gap: 2px; margin: 8px 0 6px; }
.tabs button { flex: 1; background: var(--panel-2); border: 1px solid var(--line); padding: 4px; cursor: pointer; font-size: 12px; border-radius: 4px; }
.tabs button.on { border-color: var(--accent); color: var(--accent); }

.list { max-height: 240px; overflow-y: auto; }
.item { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 4px; cursor: pointer; }
.item:hover { background: var(--panel-2); }
.item .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.sw-attack { background: #c792ea; box-shadow: 0 0 0 2px #e5534b; }
.sw-kill { border: 2px solid #c792ea; width: 8px; height: 8px; }
.item .count { font-size: 12px; padding: 0 2px; white-space: nowrap; }
.item .count.attack { color: #e5534b; }
.item .count.kill { color: var(--muted); }
.bar { width: 60px; height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; flex: none; }
.bar i { display: block; height: 100%; background: var(--bad); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }

table.attrs { width: 100%; border-collapse: collapse; font-size: 12px; }
table.attrs td { padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: top; word-break: break-word; }
table.attrs td:first-child { color: var(--muted); width: 40%; }
.warnings { color: var(--warn); font-size: 12px; }
.warnings p { margin: 4px 0; }
.pill { font-size: 11px; padding: 1px 6px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.bad { color: var(--bad); border-color: var(--bad); }

.map-btn {
  position: absolute; top: 10px; right: 10px; z-index: 600; background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; font-weight: 700; cursor: pointer;
}
.map-btn:hover { border-color: var(--accent); color: var(--accent); }
#view3d { position: absolute; top: 0; right: 0; bottom: 0; left: 340px; z-index: 1100; background: #0d1014; }
#side.collapsed ~ #view3d { left: 44px; }
.v3d-canvas, .v3d-canvas canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.v3d-bar {
  position: absolute; left: 10px; right: 10px; top: 10px; display: flex; gap: 10px; align-items: center;
  justify-content: space-between; pointer-events: none;
}
.v3d-bar > * { pointer-events: auto; }
.v3d-info { background: rgba(18,21,26,.85); padding: 6px 10px; border-radius: 6px; }
.v3d-bar .btn { margin: 0; }
.coords {
  position: absolute; right: 10px; bottom: 10px; z-index: 500; background: rgba(18,21,26,.85);
  padding: 4px 8px; border-radius: 4px; font: 12px ui-monospace, monospace; pointer-events: none;
}
.leaflet-tooltip.lbl {
  background: rgba(18,21,26,.8); color: var(--text); border: none; box-shadow: none;
  padding: 1px 5px; font-size: 11px;
}
.leaflet-tooltip.lbl::before { display: none; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-bar a { background: var(--panel); color: var(--text); border-color: var(--line); }

.login-body { display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.login-card label { display: block; margin: 12px 0; color: var(--muted); }
.login-card input { margin-top: 4px; }
.login-card button { width: 100%; padding: 8px; background: var(--accent); color: #1a1205; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; margin-top: 8px; }
.error { color: var(--bad); }

@media (max-width: 720px) {
  #app { flex-direction: column-reverse; }
  #side { width: 100%; height: 45vh; border-right: none; border-top: 1px solid var(--line); }
  #side.collapsed { height: 48px; width: 100%; overflow: hidden; }
  #map { min-height: 55vh; }
  #view3d, #side.collapsed ~ #view3d { left: 0; bottom: 45vh; }
}
