/* дизайн-язык «Tailscale» (DECISIONS §33): светлый фон, плотные таблицы,
   моноширинные технические значения, цвет — только у статуса */
:root {
  --bg: #fafafa; --card: #fff; --text: #1f2328; --muted: #6e7781;
  --line: #e6e8eb; --accent: #2456bf; --green: #1ea672; --red: #d3372c;
  --gray: #9aa4af; --warn-bg: #fff7e0;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 980px; margin: 0 auto; padding: 16px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 10px 0; }
h3 { margin: 0 0 8px; font-size: 17px; }
code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.prewrap { white-space: pre-wrap; margin: 0; }

.topbar {
  display: flex; align-items: center; gap: 20px; padding: 11px 20px;
  background: var(--card); color: var(--text);
  border-bottom: 1px solid var(--line);
}
.topbar a { color: var(--muted); }
.topbar a:hover { color: var(--text); text-decoration: none; }
.topbar nav a.active { color: var(--text); font-weight: 600; }
.topbar .brand { font-weight: 700; color: var(--text); font-size: 16px; }
.topbar nav { display: flex; gap: 18px; flex: 1; font-size: 14px; }
.userbox { font-size: 13px; color: var(--muted); }
.navbadge { background: var(--red); color: #fff; border-radius: 10px;
  padding: 0 7px; font-size: 12px; font-weight: 700; }
#map { height: calc(100vh - 160px); min-height: 420px; border-radius: 10px;
  border: 1px solid var(--line); }

footer { max-width: 980px; margin: 24px auto; padding: 0 16px; font-size: 13px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; margin: 12px 0;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
.card.emergency { border-left: 4px solid var(--red); background: #fff8f7; }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.space-between { justify-content: space-between; }
.inline { display: inline; }

.btn {
  display: inline-block; border: 1px solid var(--line); background: #fff;
  border-radius: 8px; padding: 6px 14px; cursor: pointer; font-size: 15px;
  color: var(--text);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.small { padding: 3px 10px; font-size: 13px; }
.linklike { border: 0; background: none; color: var(--red); cursor: pointer; }

.searchbar { display: flex; gap: 8px; margin: 12px 0; }
.searchbar input { flex: 1; }
.listmeta { font-size: 13px; margin: 2px 0 8px; }
input, select, textarea {
  font: inherit; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: #a8bfe8;
  box-shadow: 0 0 0 3px rgba(36, 86, 191, .10);
}
input[type="checkbox"] { width: auto; }
.form-grid { display: grid; gap: 10px; max-width: 520px; }
.form-grid label { font-size: 14px; color: var(--muted); }
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.form-cols label { font-size: 14px; color: var(--muted); }
@media (max-width: 720px) { .form-cols { grid-template-columns: 1fr; } }

table.list { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  font-size: 14px; }
table.list th, table.list td { padding: 9px 12px; text-align: left;
  border-bottom: 1px solid var(--line); }
table.list th { font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted); font-weight: 600;
  background: #fbfbfc; }
table.list th a { color: var(--muted); }
table.list th a:hover { color: var(--text); text-decoration: none; }
table.list td > a:not(.tag) { color: var(--text); font-weight: 600; }
table.list .num { font-family: var(--mono); font-size: 13px; }
table.list tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: #f6f8fa; }
.dotcell { width: 28px; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px rgba(211, 55, 44, .16); }
.dot.gray { background: var(--gray); }

.tag { font-size: 12px; border-radius: 999px; padding: 1px 8px; margin-left: 6px;
  border: 1px solid transparent; white-space: nowrap; }
.tag.red { background: #fdf0ef; color: #b3261e; border-color: #f3c6c2; }
.tag.green { background: #e9f7ef; color: #157347; border-color: #c5e8d3; }
.tag.blue { background: #eef4fd; color: var(--accent); border-color: #cfdff7; }
.tag.gray { background: #f4f5f7; color: var(--muted); border-color: #e3e6ea; }

.confirm-line { padding: 8px 12px; border-radius: 8px; background: #e2f3e6;
  margin: 10px 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.confirm-line.warn { background: var(--warn-bg); }

.devtree { display: flex; flex-direction: column; }
.tchildren { margin-left: 14px; border-left: 2px solid var(--line);
  padding-left: 14px; }
.tgroup > summary { cursor: pointer; padding: 8px 4px; list-style: none; }
.tgroup > summary::-webkit-details-marker { display: none; }
.tgroup > summary::before { content: "▸ "; color: var(--muted); }
.tgroup[open] > summary::before { content: "▾ "; }
.tgroup > summary .dot { margin-right: 6px; }
.dot.mute { background: #fff; border: 2px solid var(--gray);
  width: 8px; height: 8px; }
.devrow.isdown { background: #fff4f3; border-radius: 8px; }

.devchain { display: flex; flex-direction: column; }
.devrow { display: flex; gap: 10px; padding: 10px 4px;
  border-bottom: 1px dashed var(--line); align-items: flex-start; }
.devrow:last-child { border-bottom: 0; }
.devrow .dot { margin-top: 6px; flex-shrink: 0; }
.devrow.missing { background: #fff4f3; }
.devmain { flex: 1; }
.note { background: var(--warn-bg); border-radius: 6px; padding: 4px 8px;
  font-size: 14px; margin-top: 4px; }
.port { margin-left: 8px; }

.editpencil summary { cursor: pointer; list-style: none; }
.editpencil summary::-webkit-details-marker { display: none; }
.editpencil form { margin: 8px 0; }
details.inline-form { position: relative; }
details.inline-form summary { list-style: none; cursor: pointer; }
details.inline-form summary::-webkit-details-marker { display: none; }
details.inline-form > .card { position: absolute; right: 0; z-index: 20;
  min-width: 400px; box-shadow: 0 8px 30px rgba(0,0,0,.15); }
@media (max-width: 720px) { details.inline-form > .card { position: static; min-width: 0; } }

.constructor { margin-top: 12px; display: flex; gap: 10px; flex-direction: column; }
.constructor > details > summary { width: fit-content; }

.contacts { list-style: none; padding: 0; margin: 0 0 8px; }
.contacts li { padding: 3px 0; }

.photos { display: flex; gap: 12px; flex-wrap: wrap; }
.photos img { max-width: 180px; max-height: 140px; border-radius: 8px;
  border: 1px solid var(--line); }

.journal { list-style: none; padding: 0; margin: 0; }
.journal li { padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }

.sticky-actions { position: sticky; bottom: 8px; box-shadow: 0 4px 20px rgba(0,0,0,.12); }

.login-page { display: grid; place-items: center; min-height: 100vh; background: #17324d; }
.login-card { background: #fff; padding: 40px 48px; border-radius: 14px; text-align: center; }
.login-card h1 { margin-top: 0; }
.error-card { border-left: 4px solid var(--red); }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; font-size: 13px; }
  .card { border: 1px solid #bbb; break-inside: avoid; margin: 6px 0; }
  .topbar, footer { display: none; }
  a { color: inherit; }
  .dot.green::after { content: " ✓"; }
}

/* ---------- паспорт узла (чек-лист документации) ---------- */
.passport { padding: 10px 14px; border-radius: 10px; margin: 10px 0;
  background: var(--warn-bg, #fdf3d7); border: 1px solid #ecd9a0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.passport.full { background: #e2f3e6; border-color: #bfe3c8; }
.passport b { margin-right: 4px; }
.chip { font-size: 13px; border-radius: 14px; padding: 2px 10px;
  text-decoration: none; white-space: nowrap; }
.chip.ok { background: #e2f3e6; color: #1f7a33; }
.chip.todo { background: #fff; color: var(--red, #b3261e);
  border: 1px dashed var(--red, #b3261e); }
a.chip.todo:hover { background: #fbe3e1; }
.pbadge { font-size: 12px; font-family: var(--mono); border-radius: 999px;
  padding: 2px 9px; cursor: help; border: 1px solid transparent; }
.pbadge.ok { background: #e9f7ef; color: #157347; border-color: #c5e8d3; }
.pbadge.mid { background: #fdf6e3; color: #8a6d1a; border-color: #eeddad; }
.pbadge.low { background: #fdf0ef; color: #b3261e; border-color: #f3c6c2; }

/* ---------- схема сети ---------- */
.scheme-wrap { display: flex; gap: 16px; align-items: flex-start; }
.scheme-svg { flex: 1; overflow: auto; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; }
.scheme-panel { width: 340px; flex-shrink: 0; position: sticky; top: 12px; }
.scheme-panel h4 { margin: 10px 0 2px; }
.know { white-space: pre-line; margin: 2px 0; }
.schemedev .dot { display: inline-block; margin-right: 4px; }
.schemedev { margin-top: 6px; }
.devlive { margin-left: 14px; font-size: 12px; }
#lightbox { position: fixed; inset: 0; background: rgba(10,14,20,.88);
  display: none; z-index: 100; align-items: center; justify-content: center;
  flex-direction: column; cursor: zoom-out; }
#lightbox.open { display: flex; }
#lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 8px;
  cursor: default; }
#lightbox .lbcap { color: #e8ecf1; margin-top: 12px; font-size: .95em; }
#lightbox .lbnav { position: absolute; top: 0; bottom: 0; display: flex;
  align-items: center; padding: 0 22px; font-size: 3em; color: #fff;
  cursor: pointer; user-select: none; }
#lightbox .lbprev { left: 0; }
#lightbox .lbnext { right: 0; }
.wizsteps { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.wizstep { padding: 4px 10px; border-radius: 14px; border: 1px solid var(--line);
  font-size: .9em; color: inherit; text-decoration: none; background: var(--card); }
.wizstep.done { background: #e2f3e6; border-color: #bfe3c8; }
.wizstep.cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.draftbanner { border-left: 4px solid #b58900; background: #fdf6e3;
  padding: 10px 14px; border-radius: 6px; margin: 10px 0; }
.knowalarm { border-left: 4px solid var(--red); background: #fff8f7;
  padding: 8px 12px; border-radius: 6px; margin: 10px 0; }
.knowalarm h4 { margin: 0 0 4px; }
.knowalarm .know { margin: 0; }
.cardphotos { display: flex; gap: 6px; flex-wrap: wrap; }
.cardphotos img { width: 72px; height: 72px; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--line); }
#notes textarea { width: 100%; }
.snode { cursor: pointer; }
.snode.dim { opacity: .18; }
.sbox { fill: #f6f8fa; stroke: var(--line); stroke-width: 1.2; }
.sbox.red { fill: #fbe3e1; stroke: #f2b8b3; }
.sbox.green { fill: #e2f3e6; stroke: #bfe3c8; }
.snode:hover .sbox { stroke: var(--accent); stroke-width: 1.6; }
.sdot.green { fill: #1f7a33; } .sdot.red { fill: #b3261e; }
.sdot.gray { fill: #9aa4ae; }
.sname { font-size: 13px; fill: #1d2733; }
.sedge { stroke: #9db8d2; stroke-width: 1.6; }
.sedge-label { font-size: 11px; fill: #64798e; }
@media (max-width: 900px) {
  .scheme-wrap { flex-direction: column; }
  .scheme-panel { width: auto; position: static; }
}

/* ---------- связи с другими узлами ---------- */
.nodelinks { padding: 10px 14px; border-radius: 10px; margin: 10px 0;
  background: #e1eefb; border: 1px solid #b9d5f2; font-size: 14px; }
.nodelinks div { margin-top: 2px; }

/* ---------- помощник IP, привязка, конфиг ---------- */
.iprow { display: flex; gap: 6px; }
.iprow input { flex: 1; }
.attach-offer { margin: 12px 0; padding: 12px; border-radius: 8px;
  background: #e1eefb; border: 1px solid #b9d5f2; }
.configpre { background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 14px; overflow-x: auto; font-size: 13px; line-height: 1.45; }

/* ---------- физическая сеть: карта (§46, дизайн по §33) ---------- */
.pn-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 10px; }
.pn-head h1 { margin: 0; }
.pn-stats { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.pn-stat { font-size: 13px; border-radius: 14px; padding: 2px 10px; background: #f4f5f7;
  color: var(--muted); border: 1px solid #e3e6ea; white-space: nowrap; }
.pn-stat b { font-family: var(--mono); font-weight: 600; color: var(--text); }
.pn-stat.plan { border-style: dashed; }
.pn-stat.err { background: #fdf0ef; color: #b3261e; border-color: #f3c6c2; }
@media (prefers-reduced-motion: no-preference) {
  .pn-stat { transition: background-color .15s ease, color .15s ease; }
}

/* мобильная шапка: меню прокручивается, не распирает страницу */
@media (max-width: 720px) {
  .topbar { gap: 12px; padding: 8px 12px; }
  .topbar .brand { white-space: nowrap; }
  .topbar nav { overflow-x: auto; white-space: nowrap; gap: 14px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .userbox { display: none; }
  main { padding: 10px 12px; }
  .pn-head h1 { flex-basis: 100%; }
  .pn-head .btn { min-height: 40px; display: inline-flex; align-items: center; }
}

/* карточка: состояние, вложения; неполадки данных */
.pn-h2 { font-size: 13px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 22px 0 6px; }
.pn-issue h3 { margin: 0; font-size: 15px; }
.pn-issue-red { border-left: 4px solid var(--red); }
.pn-issue-list { margin: 8px 0 0; padding-left: 18px; font-size: 14px; }
.pn-issue-list li { margin: 2px 0; }

.pn-issue-list { max-height: 320px; overflow: auto; }
.linklike.blue { color: var(--accent); }

/* страница групп: таблица-дерево */
@media (max-width: 720px) {
  .pn-grp-list .pn-grp-row { grid-template-columns: 1fr 60px 60px; }
  .pn-grp-list .pn-grp-row > :nth-child(4), .pn-grp-list .pn-grp-row > :nth-child(5) { grid-column: 1 / -1; }
}
/* страница групп: таблица-дерево */
.pn-grp-list .pn-grp-row { display: grid; grid-template-columns: minmax(200px, 1fr) 90px 80px minmax(200px, auto) minmax(120px, auto); gap: 8px 12px; align-items: start; padding: 8px 6px; border-top: 1px solid var(--line); }
.pn-grp-list .pn-grp-head { border-top: 0; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pn-grp-list .pn-grp-name { display: flex; align-items: center; gap: 6px; padding-left: calc(var(--lvl, 0) * 18px); }
.pn-grp-list .num { text-align: right; font-variant-numeric: tabular-nums; }
.pn-grp-list .pn-grp-x a { margin-right: 10px; }
.pn-grp-list .pn-grp-loose { color: var(--muted); }
.pn-grp-edit summary { cursor: pointer; }
.pn-grp-edit .form-grid { margin-top: 8px; }
.pn-grp-list .pn-grp-name { flex-wrap: wrap; row-gap: 2px; }
.pn-grp-list .pn-grp-name > b { flex: 1 1 100%; }
.pn-grp-list .pn-grp-name > .small { flex: 1 1 100%; padding-left: 20px; }
.pn-grp-list .pn-grp-x { white-space: nowrap; }
@media (max-width: 720px) {
  .pn-grp-list .pn-grp-row { grid-template-columns: 1fr 60px 60px; }
  .pn-grp-list .pn-grp-row > :nth-child(4), .pn-grp-list .pn-grp-row > :nth-child(5) { grid-column: 1 / -1; }
