:root{
  --bg:#0b1220;
  --panel:#0e1730;
  --text:#eef2ff;
  --muted:#b7c2ff;
  --line:rgba(255,255,255,.10);

  --t-repeater:#22c55e;
  --t-room:#60a5fa;
  --t-sensor:#f59e0b;
  --t-client:#a78bfa;

  --shadow:0 18px 60px rgba(0,0,0,.55);
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial; background:var(--bg); color:var(--text); overflow:hidden; }
#map{ position:absolute; inset:0; }

.panel{
  position:absolute; z-index:5;
  left:14px; top:14px;
  width:392px; max-width:calc(100vw - 28px);
  background:linear-gradient(180deg, rgba(14,23,48,.96), rgba(11,18,32,.90));
  border:1px solid var(--line);
  border-radius:18px;
  padding:14px;
  box-shadow:var(--shadow);
  backdrop-filter: blur(10px);
}

.title{ font-weight:900; font-size:18px; letter-spacing:.2px; margin-bottom:12px; display:flex; align-items:center; gap:10px; }
.badge{
  font-size:12px; color:var(--muted);
  border:1px solid var(--line);
  padding:3px 10px; border-radius:999px;
  font-weight:800;
}

input,select,button{
  width:100%;
  max-width:100%;
  padding:11px 12px;
  border-radius:14px;
  border:1px solid var(--line);
  background:rgba(11,19,38,.92);
  color:var(--text);
  outline:none;
}
input::placeholder{ color:rgba(238,242,255,.55); }

.row{ display:flex; gap:10px; margin-top:10px; }
.row button{ flex:1; width:auto; }

button{
  cursor:pointer;
  background:linear-gradient(180deg, rgba(37,99,235,.28), rgba(30,64,175,.22));
  font-weight:900;
}
button:hover{ filter:brightness(1.08); }

.hint{ font-size:12px; color:rgba(183,194,255,.85); margin-top:10px; }
.stats{ font-size:12px; color:rgba(183,194,255,.9); margin-top:10px; line-height:1.55; }

.legend{
  margin-top:12px;
  padding-top:10px;
  border-top:1px solid rgba(255,255,255,.08);
  font-size:12px;
  color:rgba(183,194,255,.92);
  display:grid;
  gap:8px;
}
.legend .r{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.dot{
  width:12px; height:12px; border-radius:50%;
  display:inline-block;
  box-shadow:0 0 0 2px rgba(11,18,32,.95);
}
.dot.r5{ background:#22c55e; }
.dot.r30{ background:#f59e0b; }
.dot.r180{ background:#fb7185; }
.dot.rold{ background:#94a3b8; }

.key{
  display:flex; align-items:center; gap:8px;
  padding:3px 8px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.04);
  color:rgba(238,242,255,.92);
}

.node-list{
  margin-top:10px;
  max-height:40vh;
  overflow:auto;
  border-top:1px solid rgba(255,255,255,.08);
  padding-top:10px;
}
.node-item{
  display:flex; align-items:center; gap:10px;
  padding:10px 10px;
  border-radius:14px;
  cursor:pointer;
  border:1px solid rgba(255,255,255,.06);
  background:rgba(255,255,255,.03);
  margin-bottom:8px;
}
.node-item:hover{ background:rgba(255,255,255,.06); }
.node-name{ font-weight:900; font-size:13px; }
.node-sub{ font-size:12px; color:rgba(183,194,255,.9); margin-top:2px; }
.node-left{ display:flex; flex-direction:column; min-width:0; }
.node-left > div{ white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.node-badge{
  margin-left:auto;
  font-size:12px;
  color:rgba(183,194,255,.9);
}

.maplibregl-ctrl-top-right{ top:14px; right:14px; z-index:6; }
.maplibregl-ctrl-group{
  background:rgba(14,23,48,.92);
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow:var(--shadow);
  overflow:hidden;
}
.maplibregl-ctrl-group button{
  width:44px; height:44px;
  background:transparent;
  border:none;
}
.maplibregl-ctrl-group button:hover{ background:rgba(255,255,255,.06); }
.maplibregl-ctrl-group button + button{ border-top:1px solid rgba(255,255,255,.08); }
.maplibregl-ctrl-icon{ filter:invert(1) saturate(0) brightness(1.2); }

.maplibregl-popup-content{
  background:linear-gradient(180deg, rgba(14,23,48,.98), rgba(11,19,38,.96));
  color:var(--text);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
  padding:14px;
  min-width:320px;
}
.maplibregl-popup-close-button{
  position:absolute;
  right:10px;
  top:10px;
  width:34px;
  height:34px;
  border-radius:10px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
  color:rgba(255,255,255,.95);
  font-size:22px;
  line-height:30px;
  padding:0;
}
.maplibregl-popup-close-button:hover{ background:rgba(255,255,255,.12); }
.maplibregl-popup-tip{
  border-top-color:rgba(11,19,38,.96)!important;
  border-bottom-color:rgba(11,19,38,.96)!important;
  border-left-color:rgba(11,19,38,.96)!important;
  border-right-color:rgba(11,19,38,.96)!important;
}

.pill{
  display:inline-block;
  padding:3px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:900;
  border:1px solid rgba(255,255,255,.12);
  color:rgba(183,194,255,.95);
  background:rgba(255,255,255,.04);
}

/* --- Collapsible panel --- */
.toggle{
  position:absolute;
  top:12px;
  right:12px;
  width:40px;
  height:40px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.14);
  background:rgba(255,255,255,.06);
  color:rgba(255,255,255,.95);
  font-size:18px;
  font-weight:900;
  cursor:pointer;
}
.toggle:hover{ background:rgba(255,255,255,.12); }

.panel.collapsed{
  width:64px !important;
  padding:12px !important;
}
.panel.collapsed .title,
.panel.collapsed .row,
.panel.collapsed .hint,
.panel.collapsed .stats,
.panel.collapsed .legend,
.panel.collapsed .node-list{
  display:none !important;
}
.panel.collapsed .toggle{
  position:static;
  width:44px; height:44px;
  display:block;
  margin:0 auto;
}
