/* Base styles for the main SkyMod interface. */
:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --success: #3fb950;
  --danger: #f85149;
  --border: #30363d;
  --radius: 8px;
  --font-size-regular: 1rem;
  --font-bold: 600;
}

* {
  box-sizing: border-box;
}

.sidebar-toggle {
  display: none;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.demo-mode-page {
  overflow-x: hidden;
}

.demo-mode-page > .app {
  min-height: calc(100vh - 40px);
}

.demo-mode-header {
  padding: 6px 16px;
  text-align: center;
  color: var(--danger);
  background: rgba(248, 81, 73, 0.1);
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 1.05rem;
  border-bottom: 1px solid rgba(248, 81, 73, 0.45);
  text-transform: uppercase;
}

.header {
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  align-items: center;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-left {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
}

.header-search-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-search-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.header-search-input {
  width: 72px;
  padding: 6px 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  -moz-appearance: textfield;
  appearance: textfield;
}

.header-search-input::-webkit-outer-spin-button,
.header-search-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.header-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.header-search-input-client {
  width: 110px;
}

#searchSplitterById {
  width: 112px;
}

/* Статистика: активные/неактивные абоненты, количество домов — слева от бренда, в 3 строки */
.header-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  margin-left: 24px;
  margin-right: auto;
  order: 2;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.header-stats-item {
  line-height: 1.3;
}

.header-stats-item strong {
  font-weight: 600;
  color: var(--text);
}

.header-stats-item strong.header-stats-active {
  color: var(--success);
}

.header-stats-item strong.header-stats-inactive {
  color: var(--danger);
}

/* В потоке шапки справа — не перекрывает OLT при любом разрешении и F12 */
.header-brand-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 0 0 0 20px;
  font-size: 1.25rem;
  order: 3;
}

.header-brand-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.header-brand-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-brand {
  margin: 0;
  padding: 0;
  font-size: inherit;
  font-weight: 600;
  white-space: nowrap;
  color: var(--success);
  letter-spacing: 0.02em;
}

.header-brand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  box-sizing: border-box;
  font-size: 1.15rem;
  line-height: 1.2;
  padding: 8px 18px;
  white-space: nowrap;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.header-brand-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
}

.header-brand-btn--update {
  position: relative;
  border-color: rgba(63, 185, 80, 0.95);
  color: #dcffe4;
  background: rgba(63, 185, 80, 0.16);
  animation: header-update-pulse 1.1s ease-in-out infinite;
}

.header-brand-btn--update::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3fb950;
  box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.75);
  animation: header-update-dot 1.1s ease-in-out infinite;
}

.header-brand-btn--update:hover {
  border-color: #56d364;
  color: #f0fff4;
  background: rgba(63, 185, 80, 0.24);
}

.header-brand-btn--update-read::after {
  display: none;
}

.header-brand-btn-sm {
  font-size: 0.85rem;
  padding: 5px 10px;
}

.header-brand-btn-xs {
  min-height: 1.25rem;
  font-size: 0.6rem;
  line-height: 1.1;
  padding: 2px 8px;
}

.header-brand-link {
  pointer-events: auto;
  color: #a371f7;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: color 0.2s ease, text-shadow 0.2s ease, transform 0.2s ease;
  border-bottom: 1px solid rgba(163, 113, 247, 0.6);
}

.header-brand-link:hover {
  color: #c297ff;
  text-shadow: 0 0 12px rgba(163, 113, 247, 0.5);
  border-bottom-color: #a371f7;
  transform: scale(1.02);
}

.header-brand-link:focus {
  outline: none;
  border-bottom-color: #a371f7;
}

/* Модальное окно «Краткое описание» */
.modal-short-description {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13, 17, 23, 0.95);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-short-description.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-short-description-box {
  max-width: 520px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface1);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border);
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-short-description.is-open .modal-short-description-box {
  transform: scale(1);
}

.modal-short-description-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(63, 185, 80, 0.12) 0%, rgba(88, 166, 255, 0.08) 100%);
}

.modal-short-description-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

.modal-short-description-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.modal-short-description-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.modal-short-description-body {
  overflow-y: auto;
  padding: 20px;
  background: rgba(14, 24, 42, 0.9);
}

.modal-short-description-body .desc-intro {
  margin: 0 0 1rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}

.modal-short-description-body .desc-section {
  margin-bottom: 1.25rem;
}
.modal-short-description-body .desc-section-new {
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--surface2);
  border-left: 3px solid var(--accent, #3b82f6);
}

.modal-short-description-body .desc-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.modal-short-description-body .desc-section ul {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text);
}

.modal-short-description-body .desc-section ul li {
  margin-bottom: 0.35rem;
}

.modal-short-description-body .desc-section p {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text);
}

.modal-short-description-body .desc-subtitle {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.modal-short-description-body .desc-footer {
  margin: 1rem 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.changelog-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

#modalChangeLog .modal-short-description-box {
  width: min(760px, calc(100vw - 40px));
  height: min(85vh, 760px);
}

#modalChangeLog .modal-short-description-body {
  flex: 1 1 auto;
  min-height: 0;
}

#changelogContent {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.changelog-empty,
.changelog-empty-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.changelog-loading-state {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.changelog-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(88, 166, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: building-refresh-spin 0.8s linear infinite;
  flex: 0 0 auto;
}

@keyframes header-update-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.12);
    filter: brightness(1);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.22);
    filter: brightness(1.12);
  }
}

@keyframes header-update-dot {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(63, 185, 80, 0.7);
    transform: scale(1);
  }
  50% {
    opacity: 0.35;
    box-shadow: 0 0 0 6px rgba(63, 185, 80, 0);
    transform: scale(0.85);
  }
}

.changelog-entry-title {
  margin: 0 0 0.55rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--success);
}

.changelog-entry-subtitle {
  margin: 0.2rem 0 0.55rem;
  font-size: 0.87rem;
  font-weight: 700;
  color: var(--accent);
}

.changelog-entry-content {
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.55;
}

.changelog-entry-content p {
  margin: 0 0 0.5rem;
}

.changelog-entry-content ul {
  margin: 0;
  padding-left: 1.2rem;
}

.changelog-entry-content ul li {
  margin-bottom: 0.35rem;
}

.changelog-entry-content pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.84rem;
  color: var(--text);
}

.architecture-modal-body {
  display: flex;
  gap: 0;
  padding: 0;
  min-height: 0;
}

.architecture-content-wrap {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

#modalArchitecture .modal-short-description-box {
  max-width: min(960px, calc(100vw - 40px));
}

#modalArchitecture .modal-short-description-box .architecture-content {
  width: 100%;
  max-width: 100%;
}

#modalArchitecture .modal-short-description-box .architecture-content-wrap {
  width: 100%;
  max-width: 100%;
}

.architecture-content {
  margin: 0;
  padding: 20px;
  overflow: auto;
  max-height: calc(85vh - 96px);
  color: var(--text);
  white-space: normal;
  word-break: break-word;
  font-size: 0.84rem;
  line-height: 1.5;
}

.architecture-content p {
  margin: 0 0 0.65rem;
}

.architecture-content .architecture-heading {
  margin: 0 0 0.65rem;
  color: var(--text);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.architecture-heading-1 {
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 0.9rem;
  color: var(--success);
}

.architecture-heading-2 {
  margin-top: 0.7rem;
  font-size: 1.02rem;
  color: var(--accent);
}

.architecture-heading-3 {
  margin-top: 0.6rem;
  font-size: 0.96rem;
  color: var(--success);
}

.architecture-content .architecture-list {
  margin: 0 0 0.8rem;
  padding-left: 1.2rem;
}

.architecture-content .architecture-list li {
  margin-bottom: 0.34rem;
}

.architecture-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  background: rgba(15, 23, 42, 0.7);
  color: #e2e8f0;
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
}

.architecture-divider {
  margin: 0.9rem 0;
  border: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
}

.architecture-content .architecture-quote {
  margin: 0 0 0.85rem;
  padding: 0.5rem 0.8rem;
  border-left: 3px solid var(--accent);
  background: rgba(88, 166, 255, 0.08);
  border-radius: 6px;
  color: var(--text-muted);
  font-style: italic;
}

.architecture-toc {
  width: min(34%, 280px);
  min-width: 170px;
  max-height: calc(85vh - 96px);
  overflow: auto;
  border-right: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.6);
  padding: 12px;
  box-sizing: border-box;
}

.architecture-toc-title {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: var(--success);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.architecture-toc-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.architecture-toc-link {
  color: var(--text);
  text-decoration: none;
  font-size: 0.78rem;
  line-height: 1.35;
  display: block;
  padding: 4px 6px;
  border-radius: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.architecture-toc-link:hover {
  background: rgba(88, 166, 255, 0.1);
}

.changelog-archive {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(14, 24, 42, 0.7);
  margin-top: 0.6rem;
  overflow: hidden;
}

.changelog-archive summary {
  cursor: pointer;
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
  list-style: none;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.changelog-archive summary::-webkit-details-marker {
  display: none;
}

.changelog-entry-summary-date {
  font-weight: 700;
}

.changelog-entry-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.changelog-archive[open] summary {
  background: rgba(88, 166, 255, 0.09);
  color: var(--success);
}

.changelog-archive-content {
  padding: 0 0.9rem 0.75rem;
}

/* Модальное окно «Абоненты с низким dBm» */
.modal-low-dbm {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13, 17, 23, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-low-dbm.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-low-dbm-box {
  max-width: 720px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface1);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border);
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-low-dbm.is-open .modal-low-dbm-box {
  transform: scale(1);
}

.modal-low-dbm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 24, 42, 0.9);
}

.modal-low-dbm-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-low-dbm-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.modal-low-dbm-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.modal-low-dbm-body {
  overflow-y: auto;
  padding: 20px;
  background: #0e182a;
}

.modal-low-dbm-loading,
.modal-low-dbm-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.modal-low-dbm-empty-message {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--success);
  text-align: center;
  padding: 24px 16px;
}

.modal-low-dbm-list {
  min-height: 40px;
}

.modal-low-dbm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.modal-low-dbm-table th,
.modal-low-dbm-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.modal-low-dbm-table th {
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface2);
}

.modal-low-dbm-table tbody td {
  color: var(--text);
  background: rgba(14, 24, 42, 0.9);
}

.modal-low-dbm-table tbody tr:hover td {
  background: var(--surface2);
}

.modal-low-dbm-table td.loss-warn {
  color: #d4a012;
  font-weight: 600;
}

.modal-low-dbm-table td.loss-critical {
  color: var(--danger);
  font-weight: 600;
}

.modal-low-dbm-copy-cell {
  width: 1%;
  white-space: nowrap;
  padding-right: 4px;
}

.modal-low-dbm-table th:last-child,
.modal-low-dbm-table td:last-child {
  white-space: nowrap;
  width: 1%;
}

@media (max-width: 768px) {
  .modal-low-dbm {
    padding: 8px;
  }

  .modal-low-dbm-box {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
  }

  .modal-low-dbm-header {
    padding: 10px 12px;
  }

  .modal-low-dbm-title {
    font-size: 0.95rem;
    line-height: 1.2;
  }

  .modal-low-dbm-body {
    padding: 10px;
  }

  #modalLowDbmList > table.modal-low-dbm-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0 8px;
    font-size: 0.78rem;
  }

  #modalLowDbmList > table.modal-low-dbm-table thead {
    display: none;
  }

  #modalLowDbmList > table.modal-low-dbm-table tbody tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(14, 24, 42, 0.9);
    padding: 8px;
  }

  #modalLowDbmList > table.modal-low-dbm-table tbody td {
    display: grid;
    grid-template-columns: 78px 1fr;
    align-items: start;
    gap: 6px;
    padding: 3px 0;
    border: 0;
    background: transparent;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  #modalLowDbmList > table.modal-low-dbm-table tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.7rem;
    line-height: 1.2;
    white-space: nowrap;
  }

  #modalLowDbmList > table.modal-low-dbm-table td.modal-low-dbm-copy-cell {
    grid-template-columns: 1fr;
    justify-items: start;
  }

  #modalLowDbmList > table.modal-low-dbm-table td.modal-low-dbm-copy-cell::before {
    display: none;
  }

  #modalLowDbmList > table.modal-low-dbm-table td:last-child {
    white-space: normal;
    width: auto;
  }

  #modalLowDbmList > table.modal-low-dbm-table .btn-goto-port,
  #modalLowDbmList > table.modal-low-dbm-table .btn-copy-line {
    min-height: 34px;
    padding: 6px 10px;
    font-size: 0.75rem;
  }
}

/* Карточка абонента */
.modal-subscriber-card {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13, 17, 23, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-subscriber-card.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-subscriber-card-box {
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border);
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-subscriber-card.is-open .modal-subscriber-card-box {
  transform: scale(1);
}

.modal-subscriber-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(63, 185, 80, 0.12) 0%, rgba(88, 166, 255, 0.08) 100%);
}

.modal-subscriber-card-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.modal-subscriber-card-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.modal-subscriber-card-close:hover {
  background: var(--surface2);
  color: var(--text);
}

.modal-subscriber-card-body {
  overflow-y: auto;
  padding: 20px;
  background: rgba(14, 24, 42, 0.9);
}

.subscriber-card-section {
  margin-bottom: 20px;
}

.subscriber-card-section:last-of-type {
  margin-bottom: 24px;
}

.subscriber-card-section-title {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.subscriber-card-grid {
  display: grid;
  gap: 6px 10px;
  grid-template-columns: auto 1fr;
}

.subscriber-card-row {
  display: contents;
}

.subscriber-card-label {
  font-size: 1rem;
  color: var(--text-muted);
  text-align: left;
}

.subscriber-card-label-with-copy {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  color: var(--text-muted);
  text-align: left;
}

.subscriber-card-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.2s, color 0.2s;
}

.subscriber-card-copy-btn:hover {
  background: var(--surface2);
  color: var(--accent);
}

.subscriber-card-value {
  font-size: 1.05rem;
  color: var(--text);
  font-weight: 500;
  text-align: right;
  direction: ltr;
}

.subscriber-card-grid .subscriber-card-label,
.subscriber-card-grid .subscriber-card-label-with-copy {
  justify-self: start;
}

.subscriber-card-grid .subscriber-card-value {
  justify-self: end;
}

.subscriber-card-row-full .subscriber-card-value {
  grid-column: 2 / -1;
  min-width: 0;
}

/* ФИО в одну строку, длинное обрезается с многоточием */
.subscriber-card-value-fio {
  font-size: 1.15rem;
  font-weight: var(--font-bold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.subscriber-card-status.status-active {
  color: var(--success);
  font-weight: 600;
}

.subscriber-card-status.status-inactive {
  color: var(--danger);
  font-weight: 600;
}

.subscriber-card-loss-level.loss-ok,
.subscriber-card-value.loss-ok {
  color: var(--success);
}

.subscriber-card-loss-level.loss-warn,
.subscriber-card-value.loss-warn {
  color: #d4a012;
  font-weight: 600;
}

.subscriber-card-loss-level.loss-critical,
.subscriber-card-value.loss-critical {
  color: var(--danger);
  font-weight: 600;
}

.subscriber-card-value.loss-inactive {
  color: var(--danger);
}

.subscriber-card-value.subscriber-card-balance-negative {
  color: var(--danger);
  font-weight: 600;
}

.subscriber-card-value-copy {
  cursor: pointer;
}
.subscriber-card-value-copy:hover {
  text-decoration: underline;
  color: var(--accent);
}

.subscriber-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.subscriber-card-actions-buttons {
  border-top: none;
  padding-top: 0;
}

.subscriber-card-actions-buttons .btn-primary {
  flex: 1;
  min-width: 140px;
}

.subscriber-card-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--danger);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}

.subscriber-card-link:hover {
  color: #da3633;
}

/* Модалки: Обновить данные / Телефоны */
.modal-subscriber-edit {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(13, 17, 23, 0.6);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-subscriber-edit.is-open {
  opacity: 1;
  visibility: visible;
}

.modal-subscriber-edit-box {
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--border);
}

.modal-subscriber-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(14, 24, 42, 0.9);
}

.modal-subscriber-edit-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-subscriber-edit-body {
  overflow-y: auto;
  padding: 20px;
}

.subscriber-edit-section {
  margin-bottom: 12px;
}

.subscriber-edit-row {
  margin-bottom: 14px;
}

.subscriber-edit-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subscriber-edit-label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.subscriber-edit-toggle-row .subscriber-edit-label {
  margin-bottom: 0;
}

.subscriber-edit-input {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
}

.subscriber-edit-input:focus {
  outline: none;
  border-color: var(--accent);
}

.subscriber-edit-input.has-error {
  border-color: var(--danger);
}

.subscriber-edit-error {
  display: block;
  font-size: 0.8rem;
  color: var(--danger);
  margin-top: 4px;
}

.subscriber-edit-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.subscriber-edit-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.subscriber-edit-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface2);
  border-radius: 24px;
  transition: 0.2s;
}

.subscriber-edit-slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: 0.2s;
}

.subscriber-edit-switch input:checked + .subscriber-edit-slider {
  background: var(--success);
}

.subscriber-edit-switch input:checked + .subscriber-edit-slider::before {
  transform: translateX(20px);
  background: #fff;
}

.subscriber-edit-warning {
  margin: 12px 0 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.subscriber-edit-actions {
  margin-top: 8px;
}

.subscriber-edit-actions .btn {
  width: 100%;
}

.subscriber-phones-list {
  margin-bottom: 12px;
}

.subscriber-phone-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.subscriber-phone-item .subscriber-edit-input {
  flex: 1;
  min-width: 0;
}

.subscriber-phone-btn-primary {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: var(--text-muted);
  color: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.subscriber-phone-btn-primary:hover {
  background: #6e7681;
  color: #fff;
}

.subscriber-phone-btn-primary.is-primary {
  background: var(--success);
  color: #fff;
}

.subscriber-phone-btn-delete {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: var(--danger);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  flex-shrink: 0;
}

.subscriber-phone-btn-delete:hover {
  background: #da3633;
}

.subscriber-phones-add {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.subscriber-phones-add .subscriber-edit-input {
  flex: 1;
  min-width: 0;
}

.header h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sidebar {
  padding: 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn {
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
}

.btn-secondary:hover {
  background: #2d3a4d;
}

.btn-splitter {
  background: var(--surface2);
  color: var(--text);
  margin-right: 8px;
}

.btn-splitter:hover, .btn-splitter.active {
  background: var(--accent);
  color: #fff;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #da3633;
  color: #fff;
}

.building-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
}

.building-search-input::placeholder {
  color: var(--text-muted);
}

.building-search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.sidebar-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 12px;
  line-height: 1.3;
}

.zone-list-scroll {
  margin-top: 12px;
  max-height: min(65vh, 600px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* Скрываем полосы прокрутки (прокрутка остаётся рабочей) */
.zone-list-scroll,
.zone-buildings.is-open {
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* IE/Edge legacy */
}

.zone-list-scroll::-webkit-scrollbar,
.zone-buildings.is-open::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.zone-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.zone-item {
  margin-bottom: 4px;
}

.zone-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.zone-header:hover {
  background: #2d3a4d;
}

.zone-header .zone-toggle {
  flex-shrink: 0;
  width: 1em;
  color: var(--text-muted);
}

.zone-header .zone-name {
  flex: 1;
  min-width: 0;
}

.zone-header .zone-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.zone-header .btn-delete-zone {
  flex-shrink: 0;
  margin-left: 6px;
  padding: 2px 6px;
  font-size: 1rem;
  line-height: 1;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.zone-header .btn-delete-zone:hover {
  background: var(--danger);
  color: #fff;
}

.zone-buildings {
  list-style: none;
  padding: 0 0 0 1.2rem;
  margin: 4px 0 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease-out;
}

.zone-buildings.is-open {
  max-height: min(600px, 40vh);
  overflow-y: auto;
  overflow-x: hidden;
}

.building-actions-menu {
  position: fixed;
  z-index: 200;
  min-width: 180px;
  padding: 6px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.building-menu-item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.building-menu-item:hover {
  background: var(--surface2);
}

.building-menu-delete:hover {
  color: var(--danger);
}

.building-menu-title {
  padding: 6px 14px 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.building-menu-back {
  color: var(--accent);
}

.building-menu-zones {
  display: flex;
  flex-direction: column;
  max-height: 220px;
  overflow-y: auto;
}

.building-menu-zone-opt.is-current {
  color: var(--success);
  font-weight: 500;
}

.building-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
}

.building-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 4px;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid transparent;
}

.building-list .building-name {
  flex: 1;
  cursor: pointer;
  min-width: 0;
}

.building-list .building-name-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.building-refresh-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  pointer-events: none;
}

.building-refresh-indicator--loading {
  border: 2px solid rgba(88, 166, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: building-refresh-spin 0.8s linear infinite;
}

.building-refresh-indicator--success {
  color: var(--success);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  border-radius: 50%;
  background: rgba(63, 185, 80, 0.15);
}

.building-refresh-indicator--success::before {
  content: "✓";
}

.building-refresh-indicator--error {
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  border-radius: 50%;
  background: rgba(248, 81, 73, 0.15);
}

.building-refresh-indicator--error::before {
  content: "✕";
}

.building-list .btn-delete-building {
  flex-shrink: 0;
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.building-list .btn-delete-building:hover {
  background: var(--danger);
  color: #fff;
}

.building-list li:hover .building-name {
  color: var(--text);
}

.building-list li:hover {
  background: #2d3a4d;
}

@keyframes building-refresh-spin {
  to {
    transform: rotate(360deg);
  }
}

.building-list li.active {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.15);
}

.building-list-show-more {
  margin-top: 4px;
  padding: 8px 12px !important;
  background: transparent !important;
  border: 1px dashed var(--text-muted);
}

.building-list-show-more .btn-show-more-buildings {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
}

.building-list-show-more .btn-show-more-buildings:hover {
  background: rgba(88, 166, 255, 0.15);
}

.main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px;
}

.main-content {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 12px;
}

.workspace {
  flex: 1;
  min-width: 0;
  position: relative;
  min-height: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.olt-box {
  display: inline-flex;
  flex-direction: column;
  width: fit-content;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.olt-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.olt-box .olt-title {
  margin-bottom: 0;
}

.olt-uid {
  font-weight: 400;
  color: var(--text);
  font-size: 0.85em;
}

.olt-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-low-dbm {
  cursor: pointer;
  border: 1px solid var(--accent);
  font-size: 1rem;
  font-weight: 400;
  color: var(--text);
}

.btn-low-dbm:disabled {
  border-color: var(--border);
  opacity: 0.8;
}

.btn-low-dbm:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.btn-low-dbm .btn-low-dbm-count {
  color: var(--danger);
  font-weight: 700;
  margin-left: 2px;
}

.btn-low-dbm.btn-low-dbm-zero,
.btn-low-dbm.btn-low-dbm-zero .btn-low-dbm-count {
  color: #fff;
}

.olt-low-dbm-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.refresh-all-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.btn-low-dbm-refresh {
  flex-shrink: 0;
  min-width: 2em;
  padding: 4px 8px;
  font-size: 1.1rem;
  line-height: 1;
}

.btn-low-dbm-refresh:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.olt-ports {
  display: grid;
  grid-template-columns: repeat(16, 28px);
  gap: 4px;
}

.olt-port {
  width: 28px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
}

.olt-port-num {
  font-size: 0.85rem;
  line-height: 1.1;
  color: var(--text-muted);
}

.olt-port-box {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: border-color 0.15s, background 0.15s;
}

.olt-port-count {
  font-size: 0.75rem;
  line-height: 1.1;
  color: var(--text-muted);
}

/* 120–127 клиентов — жёлтый текст счётчика */
.olt-port.olt-port-warn .olt-port-count {
  color: #d4a012;
}

/* 128 клиентов — красный порт и красный текст */
.olt-port.olt-port-full .olt-port-box {
  border-color: var(--danger);
  background: rgba(248, 81, 73, 0.25);
}

.olt-port.olt-port-full .olt-port-count {
  color: var(--danger);
}

.olt-port:hover .olt-port-box {
  border-color: var(--accent);
}

.olt-port:hover .olt-port-count {
  color: var(--accent);
}

.olt-port.highlight .olt-port-box {
  border-color: var(--success);
  background: rgba(63, 185, 80, 0.2);
}

.olt-port.highlight .olt-port-count {
  color: var(--success);
}

.olt-port.selected-for-add .olt-port-box {
  border-color: var(--success);
  background: rgba(63, 185, 80, 0.2);
}

.olt-port.selected-for-add .olt-port-count {
  color: var(--success);
}

.btn-olt-topology {
  border-color: rgba(31, 111, 235, 0.4);
  background: linear-gradient(135deg, rgba(31, 111, 235, 0.16), rgba(47, 191, 188, 0.16));
}

.btn-olt-topology:hover {
  border-color: rgba(31, 111, 235, 0.8);
}

.olt-topology-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: none;
  padding: 18px;
  background: rgba(12, 18, 28, 0.68);
  backdrop-filter: blur(4px);
}

.olt-topology-overlay.is-open {
  display: block;
}

.olt-topology-shell {
  display: flex;
  flex-direction: column;
  width: min(1400px, 100%);
  height: calc(100vh - 36px);
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(16, 24, 38, 0.98), rgba(12, 18, 28, 0.98));
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.olt-topology-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(90deg, rgba(31, 111, 235, 0.08), rgba(47, 191, 188, 0.06));
}

.olt-topology-title {
  margin: 0;
  font-size: 1.25rem;
  color: #f8fafc;
}

.olt-topology-subtitle {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: rgba(226, 232, 240, 0.75);
}

.olt-topology-header-actions {
  display: flex;
  gap: 8px;
}

.olt-topology-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  min-height: 0;
  flex: 1;
}

.olt-topology-canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(circle at top left, rgba(31, 111, 235, 0.1), transparent 32%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.55), rgba(15, 23, 42, 0.2));
}

.olt-topology-status {
  padding: 24px;
  color: rgba(226, 232, 240, 0.86);
  font-size: 0.96rem;
}

.olt-topology-graph-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: auto;
}

.olt-topology-graph-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.olt-topology-graph-nodes {
  position: relative;
  z-index: 1;
  min-width: 100%;
  min-height: 100%;
  padding: 28px;
}

.olt-topology-olt-card {
  position: sticky;
  top: 0;
  z-index: 2;
  margin-bottom: 24px;
  padding: 18px 20px;
  border: 1px solid rgba(59, 130, 246, 0.28);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.92), rgba(15, 23, 42, 0.92));
  box-shadow: 0 18px 38px rgba(2, 6, 23, 0.28);
}

.olt-topology-olt-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.olt-topology-olt-name {
  font-size: 1.02rem;
  font-weight: 700;
  color: #f8fafc;
}

.olt-topology-olt-note {
  font-size: 0.82rem;
  color: rgba(148, 163, 184, 0.88);
}

.olt-topology-port-row {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 6px;
}

.olt-topology-port {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  min-width: 0;
  padding: 7px 4px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.72);
  color: #e2e8f0;
}

.olt-topology-port.is-active {
  border-color: rgba(59, 130, 246, 0.6);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.2) inset;
}

.olt-topology-port.is-selected {
  border-color: rgba(45, 212, 191, 0.9);
  background: rgba(20, 184, 166, 0.16);
}

.olt-topology-port-num {
  font-size: 0.68rem;
  color: rgba(226, 232, 240, 0.72);
}

.olt-topology-port-count {
  font-size: 0.9rem;
  font-weight: 700;
}

.olt-topology-columns {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  min-width: max-content;
  padding-bottom: 24px;
}

.olt-topology-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 250px;
}

.olt-topology-column-badge {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(148, 163, 184, 0.82);
  padding-left: 4px;
}

.olt-topology-building-card {
  position: relative;
  padding: 14px 14px 12px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.78);
  box-shadow: 0 14px 30px rgba(2, 6, 23, 0.18);
}

.olt-topology-building-card.is-selected {
  border-color: rgba(45, 212, 191, 0.65);
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.15), 0 16px 36px rgba(2, 6, 23, 0.28);
}

.olt-topology-building-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.olt-topology-building-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #f8fafc;
}

.olt-topology-building-meta {
  margin: 4px 0 0;
  font-size: 0.76rem;
  color: rgba(148, 163, 184, 0.86);
}

.olt-topology-open-building {
  white-space: nowrap;
}

.olt-topology-box-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.olt-topology-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(30, 41, 59, 0.78);
  color: #e2e8f0;
  text-align: left;
  cursor: pointer;
}

.olt-topology-box:hover {
  border-color: rgba(59, 130, 246, 0.56);
}

.olt-topology-box.is-selected {
  border-color: rgba(45, 212, 191, 0.88);
  background: rgba(20, 184, 166, 0.15);
}

.olt-topology-box.is-routed::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #34d399;
}

.olt-topology-box-name {
  font-weight: 700;
}

.olt-topology-box-meta {
  font-size: 0.76rem;
  color: rgba(226, 232, 240, 0.74);
}

.olt-topology-segment-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 0.72rem;
  color: rgba(45, 212, 191, 0.95);
}

.olt-topology-segment-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.35);
}

.olt-topology-line {
  fill: none;
  stroke: rgba(96, 165, 250, 0.34);
  stroke-width: 2;
  pointer-events: auto;
  cursor: pointer;
}

.olt-topology-line.is-highlight {
  stroke: rgba(45, 212, 191, 0.92);
  stroke-width: 3;
}

.olt-topology-line.is-selected {
  stroke: rgba(251, 191, 36, 0.92);
  stroke-width: 3.2;
}

.olt-topology-line-label {
  fill: rgba(226, 232, 240, 0.88);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

.olt-topology-side-panel {
  overflow: auto;
  padding: 18px 18px 20px;
  border-left: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(9, 14, 23, 0.92);
}

.olt-topology-side-empty,
.olt-topology-empty-note {
  color: rgba(226, 232, 240, 0.78);
  font-size: 0.92rem;
}

.olt-topology-panel-section {
  padding: 14px;
  margin-bottom: 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.82);
}

.olt-topology-panel-title {
  margin: 0 0 10px;
  font-size: 0.94rem;
  color: #f8fafc;
}

.olt-topology-panel-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.84rem;
  color: rgba(226, 232, 240, 0.86);
}

.olt-topology-panel-row strong {
  color: #f8fafc;
}

.olt-topology-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: rgba(226, 232, 240, 0.88);
}

.olt-topology-field input,
.olt-topology-field select,
.olt-topology-field textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.72);
  color: #f8fafc;
  padding: 8px 10px;
  box-sizing: border-box;
}

.olt-topology-field textarea {
  min-height: 72px;
  resize: vertical;
}

.olt-topology-inline-choices {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.olt-topology-inline-choices label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
}

.olt-topology-action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.olt-topology-step-list,
.olt-topology-candidate-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.olt-topology-step-item,
.olt-topology-candidate-item {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(30, 41, 59, 0.68);
}

.olt-topology-step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.olt-topology-step-label,
.olt-topology-candidate-title {
  font-size: 0.82rem;
  color: #f8fafc;
}

.olt-topology-step-meta,
.olt-topology-candidate-meta {
  margin-top: 4px;
  font-size: 0.74rem;
  color: rgba(148, 163, 184, 0.88);
}

.olt-topology-help {
  margin-top: 10px;
  font-size: 0.76rem;
  line-height: 1.45;
  color: rgba(148, 163, 184, 0.88);
}

#lineCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* Обёртка схемы: на десктопе заполняет workspace, на мобильной растёт по контенту для скролла канваса линий */
.scheme-scroll-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.scheme-area {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 20px 20px 20px 20px;
  overflow: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  z-index: 6;
}

/* Схема муфт: скрыть видимые полосы прокрутки, но оставить скролл жестами/колесом */
.workspace,
.scheme-area,
.olt-ports {
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* IE/Edge legacy */
}

.workspace::-webkit-scrollbar,
.scheme-area::-webkit-scrollbar,
.olt-ports::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

.empty-state {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Панель режимов Строительство / Просмотр */
.mode-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.mode-bar-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.mode-bar-splitter-choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}

.btn-mode {
  padding: 8px 18px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 500;
}

.btn-mode:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(88, 166, 255, 0.08);
}

.btn-mode.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--surface2);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.toolbar-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.toolbar select {
  padding: 6px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.hint {
  font-size: 0.85rem;
  color: var(--accent);
}

.toolbar-port-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.toolbar-port-field label {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

#addSplitterPortInput {
  width: 56px;
  padding: 4px 8px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  color: var(--text);
  -moz-appearance: textfield;
  appearance: textfield;
}

#addSplitterPortInput::-webkit-outer-spin-button,
#addSplitterPortInput::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Парадные в строку (колонки), у каждого этажа — зарезервированное место под две муфты */
.scheme-titles-row {
  display: flex;
  flex-direction: row;
  gap: 24px;
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  padding-bottom: 10px;
  margin-bottom: 4px;
  border-bottom: 2px solid var(--border);
  min-width: min-content;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.scheme-title-cell {
  flex: 0 0 auto;
  min-width: 140px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  line-height: 1.3;
}

.scheme-entrances-row {
  display: flex;
  flex-direction: row;
  gap: 24px;
  align-items: flex-start;
  min-width: min-content;
}

.scheme-entrance {
  flex: 0 0 auto;
  min-width: 140px;
  margin-bottom: 20px;
}

.scheme-floor {
  display: flex;
  flex-direction: column;
  min-height: 44px;
  padding: 2px 0;
  border-bottom: 1px solid var(--border);
}

.scheme-floor-distribution {
  border-bottom-color: var(--accent);
}

.scheme-floor-distribution .scheme-floor-title {
  color: var(--accent);
}

.scheme-floor-title {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 2px;
  flex-shrink: 0;
}

.splitters-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-height: 52px;
}

/* Фиксированный размер слота: муфта или заготовка под установку */
.slot-cell {
  position: relative;
  flex-shrink: 0;
  width: 52px;
  min-width: 52px;
  height: 48px;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.slot-cell.filled {
  border: none;
  background: transparent;
}

.slot-cell.filled .splitter-node {
  flex-shrink: 0;
}

/* Зарезервированное место под муфту (пустое, без подписи) */
.slot-cell.slot-placeholder {
  border: 1px dashed var(--border);
  background: rgba(48, 54, 61, 0.2);
  color: transparent;
}

.slot-cell.slot-placeholder.placeable {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
  cursor: pointer;
}

.slot-cell.slot-placeholder.placeable:hover {
  background: rgba(88, 166, 255, 0.2);
  border-style: solid;
}

.slot-placeholder-plus {
  color: var(--accent);
  font-size: 1rem;
  font-weight: 600;
  pointer-events: none;
}


/* Подвал: общий ящик на дом */
.scheme-basement-box-row,
.scheme-basement-placeholder-row {
  width: 100%;
}

.splitters-row-basement-box {
  width: 100%;
  flex-wrap: wrap;
}

.basement-box-node {
  min-width: 64px;
  font-weight: 700;
  font-size: 0.85rem;
  background: rgba(136, 100, 200, 0.25);
  border: 2px solid rgba(136, 100, 200, 0.6);
  color: var(--text);
  cursor: pointer;
}

.basement-box-node:hover {
  background: rgba(136, 100, 200, 0.4);
  border-color: var(--accent);
}

.basement-box-node.box-selected {
  border-color: #22c55e;
  box-shadow: 0 0 0 2px #22c55e;
}

.basement-box-placeholder {
  min-width: 80px;
  font-size: 0.8rem;
  color: var(--accent);
  border: 1px dashed var(--accent);
  background: rgba(88, 166, 255, 0.08);
  cursor: pointer;
}

.basement-box-placeholder:hover {
  background: rgba(88, 166, 255, 0.2);
  border-style: solid;
}

/* Панель ящика — ширина под 16 портов в ряд (колонки 44px + отступы) */
#basementBoxPanel.basement-box-panel {
  flex: 0 0 auto;
  width: auto;
  min-width: 300px;
  max-width: 95vw;
  --basement-box-col-width: 56px;
}

.basement-box-panel.splitter-panel {
  flex: 0 0 auto;
  width: auto;
  min-width: 300px;
}

#basementBoxPanel.basement-box-panel.is-compact {
  align-self: flex-start;
  width: 300px;
  min-width: 300px;
  max-width: 300px;
}

#basementBoxPanel.basement-box-panel.is-compact .basement-box-panel-content {
  max-height: none;
  overflow: visible;
}

#basementBoxPanel.basement-box-panel.is-optical-box {
  flex: 0 0 auto;
  width: fit-content;
  min-width: 320px;
  max-width: min(95vw, 1100px);
}

.basement-box-panel .basement-box-panel-content {
  padding: 12px 16px;
}

#basementBoxPanel .basement-box-panel-content {
  overflow: visible;
  max-height: none;
}

#basementBoxPanel.is-optical-box .basement-box-panel-content {
  width: fit-content;
  min-width: 320px;
  min-height: 320px;
}

.basement-box-panel .basement-box-port-btn {
  display: block;
  width: 100%;
  margin-bottom: 6px;
  text-align: left;
}

.basement-box-olt-block {
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.basement-box-olt-title {
  margin-bottom: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.basement-box-olt-none {
  margin: 0 0 8px;
}

.basement-box-olt-ports {
  display: grid;
  grid-template-columns: repeat(8, minmax(var(--basement-box-col-width), 1fr));
  gap: 6px;
  max-width: 100%;
  margin-bottom: 6px;
  justify-items: stretch;
}

.basement-box-olt-ports.basement-box-cols-16 {
  grid-template-columns: repeat(16, minmax(var(--basement-box-col-width), 1fr));
}

.basement-box-olt-ports:last-of-type {
  margin-bottom: 0;
}

.basement-box-olt-port {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.8rem;
  min-width: 0;
  width: 100%;
  cursor: pointer;
}

.basement-box-olt-port:hover .basement-box-olt-port-box {
  border-color: var(--accent);
}

.basement-box-olt-port:hover .basement-box-olt-port-count,
.basement-box-olt-port:hover .basement-box-olt-port-num {
  color: var(--accent);
}

.basement-box-olt-ports-left .basement-box-olt-port,
.basement-box-olt-ports-right .basement-box-olt-port {
  align-items: center;
}

.basement-box-olt-port-num {
  color: var(--text-muted);
  line-height: 1.1;
}

.basement-box-olt-port-box {
  width: 100%;
  min-width: 24px;
  max-width: 40px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.basement-box-olt-port-count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.basement-box-olt-port-placeable,
.basement-box-olt-port-reconnect {
  cursor: pointer;
  border-radius: 4px;
}

.basement-box-olt-port-placeable:hover,
.basement-box-olt-port-reconnect:hover {
  background: rgba(88, 166, 255, 0.12);
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.basement-box-olt-port.highlight .basement-box-olt-port-box {
  border-color: var(--success);
  background: rgba(63, 185, 80, 0.2);
  box-shadow: 0 0 0 1px rgba(63, 185, 80, 0.35);
}

.basement-box-olt-port.highlight .basement-box-olt-port-count,
.basement-box-olt-port.highlight .basement-box-olt-port-num {
  color: var(--success);
}

.basement-box-connectors-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(var(--basement-box-col-width), 1fr));
  gap: 6px;
  margin-bottom: 6px;
  max-width: 100%;
  align-items: stretch;
  justify-items: stretch;
}

.basement-box-connectors-row.basement-box-cols-16 {
  grid-template-columns: repeat(16, minmax(var(--basement-box-col-width), 1fr));
}

.basement-box-connector-cell {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 24px;
  min-width: 0;
}

.basement-box-connectors-row-left .basement-box-connector-cell {
  justify-content: center;
}

.basement-box-connectors-row-right .basement-box-connector-cell {
  justify-content: center;
}

.basement-box-olt-connector-line {
  width: 2px;
  min-height: 20px;
  height: 20px;
  background: rgba(88, 166, 255, 0.9);
  flex-shrink: 0;
  border-radius: 1px;
}

.basement-box-splitters-row {
  display: grid;
  grid-template-columns: repeat(8, minmax(var(--basement-box-col-width), 1fr));
  gap: 6px;
  margin-bottom: 6px;
  max-width: 100%;
  align-items: start;
  justify-items: stretch;
}

.basement-box-splitters-row.basement-box-cols-16 {
  grid-template-columns: repeat(16, minmax(var(--basement-box-col-width), 1fr));
}

.basement-box-olt-block > .basement-box-splitters-row:last-of-type {
  margin-bottom: 10px;
}

.basement-box-splitter-cell {
  position: relative;
  min-width: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
}

.basement-box-splitters-row-left .basement-box-splitter-cell {
  align-items: center;
}

.basement-box-splitters-row-right .basement-box-splitter-cell {
  align-items: center;
}

.basement-box-splitter-cell .basement-box-olt-connector-line {
  width: 2px;
  height: 10px;
  min-height: 10px;
  background: rgba(88, 166, 255, 0.9);
}

.basement-box-splitter-top-connector {
  height: 18px;
  min-height: 18px;
  margin-bottom: 2px;
}

.basement-box-splitter-top-connector-compact {
  height: 10px;
  min-height: 10px;
  margin-bottom: 0;
}

.basement-box-node-ports {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin-top: 1px;
}

.basement-box-node-ports-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 1px;
  justify-content: center;
}

.basement-box-port-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  cursor: default;
  box-sizing: border-box;
  flex-shrink: 0;
}

.basement-box-port-dot.dot-empty {
  background: var(--text-muted);
}

.basement-box-port-dot.dot-inactive {
  background: rgba(248, 81, 73, 0.9);
}

.basement-box-port-dot.dot-active {
  background: rgba(63, 185, 80, 0.9);
}

/* В ящике: кружок порта — жёлтый при активном абоненте и потери -28…-30 dBm */
.basement-box-splitter-node .basement-box-port-dot.dot-active-yellow,
.basement-box-port-dot.dot-active-yellow {
  background: rgba(212, 160, 18, 0.95) !important;
}

/* В ящике: кружок порта по позиции — мигает красным если на этом порту абонент с красной рамкой */
.basement-box-port-dot.dot-inactive-blink {
  animation: dot-blink-red 1.2s ease-in-out infinite;
}

.basement-box-port-dot.dot-empty {
  cursor: pointer;
}

.basement-box-cell-placeable {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: rgba(88, 166, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  align-self: center;
}
.basement-box-cell-placeable:hover {
  background: rgba(88, 166, 255, 0.12);
  border-color: var(--accent);
  border-style: solid;
}

.basement-box-child-placeable {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  border: 1px dashed var(--border);
  border-radius: 50%;
  cursor: pointer;
  background: rgba(88, 166, 255, 0.06);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  line-height: 1;
}

.basement-box-child-placeable-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.basement-box-child-siblings-row {
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  margin-top: 1px;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.basement-box-child-siblings-row-compact {
  margin-top: 0;
}

.basement-box-child-group {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: fit-content;
  max-width: 100%;
}

.basement-box-child-branch {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
}

.basement-box-child-siblings-svg {
  display: block;
  margin: 1px auto 1px auto;
  overflow: visible;
}

.basement-box-child-placeable:hover {
  background: rgba(88, 166, 255, 0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.basement-box-child-branch-right {
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 1px solid rgba(88, 166, 255, 0.6);
  border-radius: 999px;
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  font-size: 11px;
  line-height: 1;
}

.basement-box-child-branch-right:hover {
  background: rgba(88, 166, 255, 0.26);
  border-color: var(--accent);
}

.basement-box-tail-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.basement-box-tail-controls {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.basement-box-tail-down-row {
  margin-top: 0;
}

.basement-box-child-branch-inline {
  position: static;
  transform: none;
  right: auto;
  top: auto;
}


.basement-box-olt-port-select-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.basement-box-olt-port-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.basement-box-olt-port-select {
  font-size: 0.65rem;
  padding: 2px 4px;
  min-width: 2em;
  max-width: 3em;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.basement-box-splitter-node .basement-box-olt-port-select-wrap {
  margin-top: 2px;
}

.basement-box-place-hint {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.basement-box-add-fallback {
  margin-bottom: 10px;
}

.basement-box-splitter-node {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  border-radius: 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.45rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #1e3a5f;
  color: var(--text);
  padding: 0;
  flex-shrink: 0;
}

.basement-box-splitter-node .splitter-type {
  display: none;
}

.basement-box-splitter-node .splitter-uid {
  font-size: 0.45rem;
  line-height: 1;
  color: #fff;
}

.basement-box-splitter-node:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 2px var(--accent);
}

.basement-box-entrance-select {
  padding: 4px 8px;
  min-width: 4em;
}

.modal-basement-box-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.basement-box-delete-block {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.basement-box-splitter-link {
  display: block;
  margin-bottom: 4px;
  color: var(--primary);
}

.basement-box-splitter-link:hover {
  text-decoration: underline;
}

.basement-box-feeds-block {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.basement-box-feeds-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 8px;
}

.basement-box-feed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.85rem;
}

.basement-box-feed-del {
  flex-shrink: 0;
  padding: 2px 8px;
}

.optical-box-list {
  display: inline-flex;
  flex-direction: column;
  gap: 10px;
  width: max-content;
  min-width: 100%;
  align-self: flex-start;
}

.optical-box-row {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  width: max-content;
}

.optical-box-empty {
  margin: 8px 0 0;
  color: var(--text-muted);
}

.splitter-node {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  border: 2px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  z-index: 4;
  padding: 1px 0;
}

.splitter-node .splitter-type {
  display: none;
}

.splitter-node .splitter-uid {
  font-size: 0.68rem;
  font-weight: 500;
  color: #fff;
  line-height: 1.1;
  margin-top: 0;
}

.splitter-node .splitter-node-ports {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  max-width: 100%;
}

.splitter-node .splitter-node-ports-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  justify-content: center;
}

.splitter-node .splitter-port-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
}

.splitter-node .splitter-port-dot.dot-empty {
  background: var(--text-muted);
}

.splitter-node .splitter-port-dot.dot-inactive {
  background: rgba(248, 81, 73, 0.9);
}

.splitter-node .splitter-port-dot.dot-active {
  background: rgba(63, 185, 80, 0.9);
}

/* Кружок порта: активный абонент и потери -28…-30 dBm — жёлтый (специфичность не ниже .dot-active) */
.splitter-node .splitter-port-dot.dot-active-yellow,
.splitter-port-dot.dot-active-yellow {
  background: rgba(212, 160, 18, 0.95) !important;
}

/* Кружок порта: абонент неактивен и муфта с красной рамкой — мигает красным (по позиции порта) */
@keyframes dot-blink-red {
  0%, 100% {
    background: rgba(248, 81, 73, 0.95);
  }
  50% {
    background: rgba(248, 81, 73, 0.4);
  }
}

.splitter-port-dot.dot-inactive-blink {
  animation: dot-blink-red 1.2s ease-in-out infinite;
}

.splitter-node:hover {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px var(--accent);
}

.splitter-node.type-1-4 {
  background: #1e3a5f;
  border-color: #2d5a8a;
}

.splitter-node.type-1-8 {
  background: #2C3E50;
  border-color: #455A64;
}

.splitter-node.selected {
  box-shadow: 0 0 0 3px var(--accent);
}

/* Только выбранная муфта (открытая панель) мигает зелёным; путь до OLT — статичная зелёная подсветка */
@keyframes blink-green {
  0%, 100% {
    border-color: var(--success);
    background: rgba(63, 185, 80, 0.35);
    box-shadow: 0 0 0 3px var(--success);
  }
  50% {
    border-color: rgba(63, 185, 80, 0.6);
    background: rgba(63, 185, 80, 0.15);
    box-shadow: 0 0 0 1px rgba(63, 185, 80, 0.5);
  }
}

.splitter-node.panel-selected {
  animation: blink-green 1.2s ease-in-out infinite;
  border-color: var(--success);
  box-shadow: 0 0 0 3px var(--success);
}

.splitter-node.feeding {
  box-shadow: 0 0 0 3px var(--success);
  border-color: var(--success);
}

/* Муфты, полностью заполненные активными клиентами — статичная жёлтая заливка */
.splitter-node.all-ports-used {
  border-color: #d4a012;
  background: rgba(212, 160, 18, 0.45);
}

/* Муфты, где все клиенты неактивны — моргают красным */
@keyframes blink-red {
  0%, 100% {
    border-color: var(--danger);
    background: rgba(248, 81, 73, 0.5);
    box-shadow: 0 0 0 2px rgba(248, 81, 73, 0.6);
  }
  50% {
    border-color: rgba(248, 81, 73, 0.5);
    background: rgba(248, 81, 73, 0.15);
    box-shadow: 0 0 0 1px rgba(248, 81, 73, 0.3);
  }
}

.splitter-node.all-clients-inactive {
  animation: blink-red 1.2s ease-in-out infinite;
}

.splitter-node.all-clients-inactive.panel-selected {
  animation: blink-green 1.2s ease-in-out infinite;
  border-color: var(--success);
  background: rgba(63, 185, 80, 0.25);
  box-shadow: 0 0 0 3px var(--success);
}

.splitter-node.all-clients-inactive.feeding {
  animation: none;
  border-color: var(--success);
  background: rgba(63, 185, 80, 0.25);
  box-shadow: 0 0 0 3px var(--success);
}

/* При выборе муфты (жёлтой или красной): выбранная мигает, путь до OLT — статично зелёный */
.splitter-node.all-ports-used.panel-selected {
  animation: blink-green 1.2s ease-in-out infinite;
  border-color: var(--success);
  background: rgba(63, 185, 80, 0.25);
  box-shadow: 0 0 0 3px var(--success);
}

.splitter-node.all-ports-used.feeding {
  animation: none;
  border-color: var(--success);
  background: rgba(63, 185, 80, 0.25);
  box-shadow: 0 0 0 3px var(--success);
}

/* Боковая панель муфты: не перекрывает схему, можно прокручивать этажи и смотреть линию до OLT */
.splitter-panel {
  flex: 0 0 300px;
  width: 300px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.splitter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.splitter-panel-type {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.splitter-panel-header .btn {
  padding: 4px 10px;
  font-size: 1.2rem;
  line-height: 1;
}

.splitter-panel-attenuation {
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.splitter-panel-connection {
  padding: 8px 12px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

#splitterPanelGotoConnectionSplitter {
  width: 80px;
}

.splitter-panel-connection-metrics {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  margin-top: 2px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.splitter-panel-connection-metrics-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.splitter-panel-connection-metrics-edit input {
  width: 88px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.splitter-panel-connection-label {
  font-weight: 600;
  color: var(--text-muted);
}

.splitter-panel-reconnect-hint {
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--primary);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.splitter-panel-reconnect-ports {
  padding: 8px 12px;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.splitter-panel-reconnect-ports .btn {
  margin-right: 4px;
}

.splitter-panel-connect-to-port {
  padding: 10px 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.splitter-panel-connect-to-port > #splitterPanelConnectToPortLabel {
  flex: 0 0 100%;
}

.splitter-panel-connect-to-port .splitter-panel-connect-btns {
  display: inline-flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
  white-space: nowrap;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.splitter-panel-connect-existing-hint {
  width: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.splitter-panel-connect-existing-hint .splitter-panel-connect-existing-label {
  margin-bottom: 8px;
}

.splitter-panel-connect-existing-list {
  width: 100%;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.splitter-panel-connect-existing-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.splitter-panel-connect-existing-inner {
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.splitter-panel-connect-existing-inner .btn {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.splitter-panel-ports {
  padding: 12px 18px 16px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.splitter-panel,
.splitter-panel-ports,
.splitter-panel-connect-existing-inner {
  scrollbar-width: none;      /* Firefox */
  -ms-overflow-style: none;   /* IE/Edge legacy */
}

.splitter-panel::-webkit-scrollbar,
.splitter-panel-ports::-webkit-scrollbar,
.splitter-panel-connect-existing-inner::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.splitter-panel-distribution-info {
  padding: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.splitter-panel-distribution-info p {
  margin: 0;
}

.splitter-panel-ports .ports-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  width: 100%;
  margin: 0;
  box-sizing: border-box;
  padding-inline: 8px;
}

.splitter-panel-ports .port-card {
  padding: 8px;
  font-size: 0.75rem;
}

.splitter-panel-ports .port-num-square {
  width: 26px;
  height: 26px;
  font-size: 0.8rem;
}

.splitter-panel-edit {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.splitter-panel-edit-title {
  margin: 0 0 8px;
  font-size: 0.9rem;
}

.splitter-panel-edit label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.splitter-panel-edit input,
.splitter-panel-edit select {
  width: 100%;
  padding: 6px 8px;
  margin-top: 2px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.splitter-panel-edit-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.splitter-panel-actions {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Модальные окна */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.is-open {
  display: flex;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 420px;
  width: 100%;
}

.modal-content h3 {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.modal-content label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.modal-content input,
.modal-content select {
  width: 100%;
  padding: 8px 10px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.modal-olt-hint {
  display: block;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--text-muted, #666);
}

.modal-olt-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.modal-olt-list .modal-olt-opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
}

.modal-olt-empty {
  margin: 12px 0;
  color: var(--text-muted, #666);
}

.olt-title-row .btn-add-olt {
  margin-left: 8px;
}

.modal-ports .modal-content {
  max-width: 560px;
  padding: 16px;
}

.modal-ports-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-ports-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.modal-ports-type {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.port-choice-btn.selected,
.dist-port-choice-btn.selected {
  background: var(--accent);
  color: var(--bg);
}

.ports-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

/* Карточка порта как на скриншоте: квадрат с номером, ID, статус, Rx */
.port-card {
  padding: 10px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  box-sizing: border-box;
  cursor: pointer;
  font-size: 0.8rem;
  background: var(--surface2);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.port-card:hover {
  box-shadow: 0 0 0 1px var(--accent);
}

.port-card.free {
  border-color: #6e7681;
  color: var(--text-muted);
}

.port-card.active {
  border-color: var(--success);
  color: var(--text);
}

.port-card.active .port-line,
.port-card.inactive .port-line {
  margin-left: -4px;
}

.port-card.inactive {
  border-color: var(--danger);
  color: var(--text);
}

/* Порт 1/4, питающий мигающую муфту 1/8 — красная рамка и мигание */
.port-card.port-blink {
  animation: blink-red 1.2s ease-in-out infinite;
}

/* Потери -28 … -30: жёлтая подсветка порта */
.port-card.port-loss-warn {
  border-color: #d4a012;
  background: rgba(212, 160, 18, 0.25);
  box-shadow: 0 0 0 2px rgba(212, 160, 18, 0.5);
}

.port-card.port-loss-warn .port-num-square {
  background: #d4a012;
  color: #fff;
}

/* Потери менее -30: красное моргание */
.port-card.port-loss-critical {
  animation: blink-red 1.2s ease-in-out infinite;
}

.port-card.port-client-highlight {
  border-color: #a371f7;
  box-shadow: 0 0 0 2px rgba(163, 113, 247, 0.4);
  background: rgba(163, 113, 247, 0.15);
}

.port-card .port-num-square {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 4px;
  margin-bottom: 6px;
}

.port-card.free .port-num-square {
  background: #6e7681;
  color: #fff;
}

.port-card.active .port-num-square {
  background: var(--success);
  color: #fff;
}

.port-card.inactive .port-num-square {
  background: var(--danger);
  color: #fff;
}

.port-card .port-line {
  font-size: 0.8rem;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.3;
}

.port-card .port-line:last-child {
  margin-bottom: 0;
}

.port-card .port-loss {
  white-space: nowrap;
}

.port-card .port-loss .port-loss-unit {
  font-size: 0.6em;
}

.port-card.free .port-line {
  color: var(--text-muted);
}

.ports-grid.modal-8 .port-card {
  min-width: 0;
}

.ports-grid.modal-4 {
  grid-template-columns: repeat(2, 1fr);
}

/* ---------- Мобильная адаптация ---------- */
@media (max-width: 768px) {
  html,
  body {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    width: 100vw;
    max-width: 100vw;
    min-width: 100vw;
    overflow-x: hidden;
    justify-items: stretch;
  }

  .header {
    flex-wrap: wrap;
    padding: 10px 12px;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .header-left {
    flex: 1 1 100%;
    order: 2;
    gap: 8px;
    min-width: 0;
  }

  .header-search-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .header-search {
    flex: 1 1 100%;
    min-width: 0;
    flex-wrap: wrap;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .header-search .header-search-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }

  .header-search .btn {
    flex: 0 0 auto;
    min-width: 0;
  }

  .header-search-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .header-search-input {
    width: 56px;
  }

  .header-search-input-client {
    width: 72px;
  }

  #searchSplitterById {
    width: 112px;
    min-width: 112px;
    flex: 0 0 112px;
  }

  .header h1 {
    font-size: 1.1rem;
  }

  .subtitle {
    font-size: 0.8rem;
  }

  .header-stats {
    order: 3;
    width: 100%;
    margin: 0;
    gap: 4px;
  }

  .header-brand-wrap {
    order: 4;
    width: 100%;
    margin: 0;
    padding: 0;
    align-items: flex-start;
  }

  .header-brand-actions {
    flex-wrap: wrap;
    width: 100%;
    gap: 6px;
  }

  .header-brand-btn {
    font-size: 0.95rem;
    padding: 8px 12px;
  }

  .header-brand-btn-xs {
    min-height: 1.15rem;
    font-size: 0.58rem;
    padding: 2px 6px;
  }

  .sidebar {
    order: 1;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px;
  }

  .sidebar.is-hidden-mobile {
    display: none !important;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    min-width: 0;
    min-height: 44px;
    padding: 8px 12px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
  }

  .sidebar-toggle:hover {
    background: #2d3a4d;
  }

  .main {
    padding: 12px;
    order: 2;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .main-content {
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
  }

  .workspace {
    min-height: 280px;
    max-width: 100%;
    min-width: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* На мобильной схема в области с прокруткой как на desktop (не на всю развёртку) */
  .scheme-scroll-wrap .scheme-area {
    padding: 12px;
  }

  .olt-box {
    padding: 8px 10px;
    width: 100%;
    min-width: 0;
  }

  .olt-title-row {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 6px;
  }

  .olt-low-dbm-wrap {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    gap: 6px;
  }

  .olt-low-dbm-wrap .btn {
    flex: 1 1 auto;
    min-width: 0;
  }

  .btn-low-dbm {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 0.9rem;
    line-height: 1.15;
  }

  .olt-ports {
    grid-template-columns: repeat(16, 28px);
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .olt-port {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    font-size: 0.85rem;
  }

  .toolbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
    margin-top: 10px;
  }

  .toolbar-label {
    width: 100%;
  }

  .btn,
  .btn-splitter,
  .btn-sm {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .btn-splitter {
    margin-right: 0;
  }

  .splitter-panel {
    flex: 0 0 auto;
    width: 100%;
    max-height: 50vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .basement-box-panel.splitter-panel {
    width: 100%;
    min-width: 0;
    flex: 0 0 auto;
    max-height: 70vh;
  }

  .splitter-panel-ports {
    padding: 8px 14px 12px;
  }

  .splitter-panel-header {
    padding: 6px 8px;
  }

  .splitter-panel-type {
    margin: 0;
    font-size: 0.98rem;
    line-height: 1.15;
  }

  .splitter-panel-header .btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }

  .splitter-panel-ports .port-card {
    padding: 10px;
    min-height: 48px;
  }

  .splitter-panel-ports .ports-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    padding-inline: 8px;
  }

  .splitter-panel-ports .port-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    row-gap: 2px;
    padding: 4px 3px;
    min-height: 62px;
    border-width: 1px;
    border-radius: 5px;
  }

  .splitter-panel-ports .port-card .port-num-square {
    width: 18px;
    height: 18px;
    margin: 0 0 1px 0;
    font-size: 0.62rem;
    border-radius: 2px;
  }

  .splitter-panel-ports .port-card .port-line {
    margin: 0;
    width: 100%;
    font-size: 0.56rem;
    line-height: 1.05;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .splitter-panel-ports .port-card.active .port-line,
  .splitter-panel-ports .port-card.inactive .port-line {
    margin-left: 0;
  }

  .splitter-panel-edit-actions .btn {
    min-height: 40px;
  }

  .building-list li {
    padding: 12px 14px;
    min-height: 48px;
  }

  .building-list .btn-delete-building {
    min-width: 44px;
    min-height: 44px;
    padding: 10px;
  }

  .building-search-input {
    padding: 10px 12px;
    font-size: 16px; /* отключает зум при фокусе в iOS */
  }

  .modal {
    padding: 12px;
    align-items: flex-start;
    overflow-y: auto;
  }

  .modal-content {
    margin: auto 0;
  }

  .scheme-titles-row {
    gap: 16px;
    padding-bottom: 8px;
    position: relative;
    top: auto;
  }

  .scheme-title-cell {
    min-width: 100px;
    font-size: 0.85rem;
  }

  .scheme-entrance {
    min-width: 100px;
  }

  .scheme-entrances-row {
    gap: 16px;
  }

  .slot-cell {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .splitter-node {
    width: 42px;
    height: 42px;
    font-size: 0.7rem;
  }

  .hint,
  #parentPortChoice,
  #distPortChoice {
    display: block;
    width: 100%;
    margin-top: 4px;
  }

  .port-choice-btn,
  .dist-port-choice-btn {
    min-height: 40px;
    min-width: 40px;
  }
}

@media (max-width: 480px) {
  .header-search-input {
    width: 64px;
  }

  #searchSplitterById {
    width: 104px;
    min-width: 104px;
    flex-basis: 104px;
  }

  .scheme-title-cell {
    min-width: 80px;
    font-size: 0.8rem;
  }

  .scheme-entrance {
    min-width: 80px;
  }

  .slot-cell {
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
  }

  .splitter-node {
    width: 38px;
    height: 38px;
    font-size: 0.65rem;
  }

  .ports-grid.modal-8 {
    grid-template-columns: repeat(4, 1fr);
  }

  .splitter-panel-ports {
    padding: 5px 12px 8px;
  }

  .splitter-panel-ports .ports-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    padding-inline: 8px;
  }

  .splitter-panel-ports .port-card {
    padding: 3px 2px;
    min-height: 56px;
    row-gap: 1px;
  }

  .splitter-panel-ports .port-card .port-num-square {
    width: 16px;
    height: 16px;
    font-size: 0.56rem;
  }

  .splitter-panel-ports .port-card .port-line {
    font-size: 0.52rem;
    line-height: 1.02;
  }

  .btn-low-dbm {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 0.84rem;
    line-height: 1.1;
  }

  .splitter-panel-header {
    padding: 5px 7px;
  }

  .splitter-panel-type {
    font-size: 0.92rem;
    line-height: 1.12;
  }

  .architecture-modal-body {
    flex-direction: column;
  }

  .architecture-toc {
    width: auto;
    min-width: 0;
    max-height: 28vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .architecture-content-wrap {
    max-height: 42vh;
  }

  .architecture-content {
    max-height: 100%;
  }
}
