:root {
  --bg: #12161c; --panel: #1a2029; --panel2: #222a35; --line: #2f3a48; --text: #e6ebf1;
  --muted: #8d9aab; --accent: #3d8bfd; --danger: #e5484d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 "Segoe UI", system-ui, sans-serif; }
#app { display: flex; height: 100vh; }
#side { width: 360px; min-width: 300px; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); }
main { flex: 1; position: relative; }
#map { position: absolute; inset: 0; background: #0d1015; }
header { padding: 12px 14px 8px; border-bottom: 1px solid var(--line); }
h1 { font-size: 16px; margin: 0; }
h2 { font-size: 13px; margin: 0 0 8px; color: #c9d3df; text-transform: uppercase; letter-spacing: .04em; }
h2.inline { display: inline; }
.sub { color: var(--muted); font-size: 12px; }
section { padding: 10px 14px; border-bottom: 1px solid var(--line); }
footer { padding: 10px 14px 16px; }
.row { display: flex; align-items: center; gap: 6px; }
.row.between { justify-content: space-between; }
.gap { gap: 8px; margin-top: 6px; }
.grow { flex: 1; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; margin-top: 8px; }
label { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--muted); }
label.row { flex-direction: row; color: var(--text); font-size: 12.5px; }
input, select { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 5px;
  padding: 5px 6px; font: inherit; font-size: 13px; min-width: 0; }
input[type=checkbox], input[type=range] { padding: 0; }
input:focus, select:focus { outline: 1px solid var(--accent); }
button { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 5px;
  padding: 5px 10px; font: inherit; cursor: pointer; }
button:hover { border-color: #4a596c; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary.on { background: #f0a020; border-color: #f0a020; }
button.danger { color: #ff9a9d; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; margin-bottom: 6px; }
.seg button { flex: 1; border: 0; border-radius: 0; padding: 6px 4px; font-size: 12px; }
.seg button.on { background: var(--accent); color: #fff; }
#repList .rep { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line);
  border-radius: 6px; margin-bottom: 5px; cursor: pointer; }
#repList .rep.sel { border-color: var(--accent); background: #1d2a3d; }
#repList .rep .nm { flex: 1; }
#repList .rep .st { font-size: 11px; color: var(--muted); }
#repList .empty { color: var(--muted); font-size: 12px; }
#repEdit { margin-top: 6px; }
#legend { margin-top: 8px; }
#legend .li { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 12px; }
#legend .sw { width: 18px; height: 12px; border-radius: 2px; flex: none; }
#legend .db { color: var(--muted); margin-left: auto; white-space: nowrap; }
#stats { margin-top: 6px; color: var(--muted); }
table.clutter { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.clutter td, table.clutter th { padding: 2px 4px; text-align: left; font-weight: normal; color: var(--muted); }
table.clutter input { width: 70px; }
details summary { cursor: pointer; list-style: none; }
details summary::before { content: "▸ "; color: var(--muted); }
details[open] summary::before { content: "▾ "; }
#hover { position: absolute; left: 10px; bottom: 10px; z-index: 500; background: rgba(18, 22, 28, .9);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; pointer-events: none; max-width: 520px; }
#hover:empty { display: none; }
#busy { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 600; background: #f0a020;
  color: #111; padding: 6px 14px; border-radius: 16px; font-weight: 600; }
#profile { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 700; background: rgba(22, 27, 35, .97);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
#profile .pfbody { display: flex; gap: 12px; margin-top: 4px; }
#pfCanvas { flex: 1; height: 220px; min-width: 0; background: #0f1318; border-radius: 4px; }
#pfInfo { width: 300px; flex: none; }
#pfInfo .big { font-size: 15px; font-weight: 600; }
#pfInfo td { padding: 1px 6px 1px 0; }
#pfClose { padding: 2px 8px; }
.leaflet-container { font: inherit; }
.tower-icon { font-size: 22px; line-height: 22px; text-align: center; filter: drop-shadow(0 0 2px #000); }
.tower-icon.sel { font-size: 28px; line-height: 28px; filter: drop-shadow(0 0 4px #3d8bfd); }
.placing .leaflet-container { cursor: crosshair !important; }
@media (max-width: 800px) {
  #app { flex-direction: column-reverse; }
  #side { width: 100%; height: 45vh; }
  #pfInfo { display: none; }
}

/* ---- дерево мереж ---- */
h3 { font-size: 12px; margin: 12px 0 4px; color: #c9d3df; font-weight: 600; }
.span2 { grid-column: span 2; }
button.ic { padding: 1px 7px; border-color: transparent; background: transparent; color: var(--muted); }
button.ic:hover { color: var(--text); border-color: var(--line); }
#tree { margin-top: 8px; }
.trow { display: flex; align-items: center; gap: 6px; padding: 5px 6px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.trow:hover { background: #1f2732; }
.trow.shown { border-color: var(--accent); background: #1b2738; }
.trow .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .st { font-size: 11px; color: var(--muted); white-space: nowrap; }
.eye { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #5b6878; flex: none; padding: 0; background: transparent; }
.trow.shown > .eye { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 40%, transparent 45%); }
.net { margin-bottom: 4px; }
.nethead .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.nethead .nm { font-weight: 600; }
.nethead .arr { width: 12px; color: var(--muted); flex: none; text-align: center; }
.nethead input.nmEdit { flex: 1; padding: 2px 5px; font-weight: 600; }
.reps { margin-left: 18px; border-left: 1px solid var(--line); padding-left: 6px; }
.reps .trow.sel .nm { color: #9cc3ff; }
.reps .add { color: var(--muted); font-size: 12px; padding: 4px 6px; }
.reps .add:hover { color: var(--text); }
.reps .empty { color: var(--muted); font-size: 12px; padding: 3px 6px; }
.hint { margin-top: 6px; padding: 6px 8px; border-radius: 6px; background: #3a2c10; color: #ffd27a; font-size: 12px; }
.viewline { font-size: 12.5px; margin-bottom: 8px; }
.viewline b { color: #9cc3ff; }
details.sub-d { margin-top: 8px; }
details.sub-d summary { font-size: 12px; color: var(--muted); }
.tower { position: relative; width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--c); background: rgba(18,22,28,.85);
  display: flex; align-items: center; justify-content: center; font-size: 14px; box-shadow: 0 0 4px #000; }
.tower.dim { opacity: .45; }
.tower.sel { box-shadow: 0 0 0 3px rgba(61,139,253,.7), 0 0 6px #000; }

#repEdit { background: #1c2430; border-left: 3px solid var(--accent); }
.edbtns { margin-top: 10px; }
button:disabled { opacity: .45; cursor: default; }
.trow .pen { padding: 0 5px; font-size: 13px; }
.trow .pen.on { color: var(--accent); }

/* ---- бокова панель: верх прокручується, «Покриття» внизу з регульованою межею ---- */
#side { display: flex; flex-direction: column; overflow: hidden; }
#side > header { flex: none; }
#sideTop { flex: 1 1 auto; min-height: 60px; overflow-y: auto; }
#splitter { flex: none; height: 9px; cursor: row-resize; display: flex; align-items: center; justify-content: center;
  background: var(--bg); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); touch-action: none; }
#splitter span { width: 42px; height: 3px; border-radius: 2px; background: #3c4859; }
#splitter:hover span, #splitter.drag span { background: var(--accent); }
#covPane { flex: none; height: var(--cov-h, 330px); min-height: 70px; overflow-y: auto; border-bottom: 0;
  background: #161c24; padding-top: 12px; }
body.resizing { cursor: row-resize; user-select: none; }
@media (max-width: 800px) { #side { height: 55vh; } }

/* ---- підписи населених пунктів ---- */
.place { position: relative; }
.place i { position: absolute; left: -3px; top: -3px; width: 6px; height: 6px; border-radius: 50%; background: #fff; border: 1px solid #222; }
.place span { position: absolute; left: 6px; top: -9px; white-space: nowrap; color: #fff; font-size: 11.5px; font-weight: 600;
  text-shadow: 0 0 3px #000, 0 0 2px #000, 0 0 1px #000; }
.place.r0 span { font-size: 14px; font-weight: 700; top: -11px; }
.place.r0 i { width: 9px; height: 9px; left: -4.5px; top: -4.5px; }
.place.r1 span { font-size: 12.5px; font-weight: 700; top: -10px; }
.place.r3 span { font-weight: 500; color: #e8e8e8; }

/* ---- режим мережі і роумінг ---- */
.chip { font-size: 10.5px; padding: 1px 6px; border-radius: 9px; background: #17324f; color: #9cc3ff; border: 1px solid #2b5687;
  white-space: nowrap; cursor: pointer; flex: none; }
.chip.sep { background: #2a2f37; color: #b9c2cd; border-color: #444d59; }
.chip:hover { filter: brightness(1.25); }
.sw.hatch { background: repeating-linear-gradient(45deg, #3fbf3f 0 4px, #6fcf6f 4px 5px); }

/* ---- абоненти на точках ---- */
#ptSec .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
#ptList .empty { padding: 4px 2px; }
#ptEdit { margin-top: 6px; padding: 8px; border-radius: 6px; background: #1c2430; border-left: 3px solid var(--accent); }
table.links { width: 100%; border-collapse: collapse; margin-bottom: 3px; }
table.links td { padding: 2px 4px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.links tr.lnk { cursor: pointer; }
table.links tr.lnk:hover td { background: #243042; }
#chain h3 { margin: 10px 0 4px; }
.chainrow { display: flex; gap: 7px; align-items: flex-start; padding: 4px 0; border-bottom: 1px solid var(--line); }
.chainrow .lamp { width: 10px; height: 10px; border-radius: 50%; margin-top: 3px; flex: none; box-shadow: 0 0 4px rgba(0,0,0,.6); }
.tower.pt { border-radius: 6px; font-size: 13px; }

/* ---- перемикач абонента вгорі карти ---- */
#subBar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 620; display: flex; flex-direction: column;
  align-items: center; gap: 6px; max-width: calc(100% - 140px); }
#subSeg { display: flex; margin: 0; background: rgba(18, 22, 28, .92); border: 1px solid var(--line); border-radius: 9px; padding: 3px;
  box-shadow: 0 2px 10px rgba(0,0,0,.5); }
#subSeg button { border: 0; background: transparent; white-space: nowrap; padding: 6px 10px; border-radius: 6px 0 0 6px; }
#subSeg button.pen { padding: 6px 8px; border-radius: 0 6px 6px 0; color: var(--muted); margin-right: 3px; }
#subSeg button.pen:last-child { margin-right: 0; }
#subSeg button.on { background: var(--accent); color: #fff; }
#subSeg button.pen.on { background: #2b5fb0; color: #fff; }
#subSeg button:not(.on):hover { background: #243042; }
#subPop { width: 380px; max-width: 100%; background: rgba(22, 28, 36, .97); border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 12px; box-shadow: 0 4px 18px rgba(0,0,0,.6); }
#subPop #subSum { margin: 2px 0 8px; }
#busy { top: 58px; }
@media (max-width: 800px) { #subSeg button { padding: 5px 6px; font-size: 12px; } #subBar { max-width: calc(100% - 20px); } }
/* модальні вікна: налаштування, вітання */
button.icon { padding: 3px 7px; font-size: 15px; line-height: 1; }
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(5, 8, 12, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modalBox { width: 420px; max-width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5); }
.modalBox h3 { font-size: 12.5px; margin: 14px 0 4px; color: #c9d3df; }
.modalBox ul { margin: 6px 0; padding-left: 18px; }
.modalBox li { margin: 4px 0; }
