body {
  font-family: Arial, sans-serif;
  font-size: 14px;
  margin: 20px;
}

nav {
  margin-bottom: 20px;
}

nav a {
  margin-right: 15px;
}

table {
  border-collapse: collapse;
  margin-bottom: 20px;
}

td, th {
  border: 1px solid #000;
  padding: 5px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #1f60c4;
  color: #fff;
  font-weight: bold;
}

.blocks {
  display: flex;
  gap: 40px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.error-banner {
  display: inline-flex;
  align-items: stretch;
  margin-bottom: 20px;
  border: 1px solid #000;
  font-size: 13px;
  line-height: 1.4;
}

.error-banner .error-tag {
  background: #ff0000;
  color: #fff;
  font-weight: bold;
  padding: 3px 8px;
  border-right: 1px solid #000;
  white-space: nowrap;
}

.error-banner .error-text {
  background: #fff;
  color: #000;
  padding: 3px 8px;
}

.summary-box {
  background: #fff6cc;
  border: 1px solid #cc9;
  padding: 10px 15px;
  margin-bottom: 20px;
  max-width: 700px;
}

.summary-box .summary-title {
  font-weight: bold;
  margin-bottom: 6px;
}

.summary-box ul {
  margin: 0;
  padding-left: 20px;
}

.info-box {
  background: #ffd6d6;
  border: 1px solid #c00;
  padding: 10px 15px;
  margin-bottom: 20px;
  max-width: 700px;
}

.info-box .info-title {
  font-weight: bold;
  color: #000;
  margin-bottom: 6px;
}

.info-box ol {
  margin: 0;
  padding-left: 22px;
}

.cell-up {
  background: #228B22;
  color: #000;
}

.cell-down {
  background: #ff0000;
  color: #000;
}

.cell-bad {
  background: #ff0000;
  color: #000;
}

.cell-warn {
  background: #ffff00;
  color: #000;
}

.flash {
  color: #b00;
  margin-bottom: 10px;
}

label {
  display: inline-block;
  min-width: 110px;
}

form.poll-form input[type="text"] {
  width: 220px;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: #fff;
  color: #000;
  border: 1px solid #999;
  border-radius: 4px;
  max-width: 640px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.modal-header {
  background: #f2f2f2;
  border-bottom: 1px solid #ccc;
  border-radius: 4px 4px 0 0;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: bold;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.modal-body {
  padding: 12px 15px;
  overflow: auto;
  flex: 1;
}

.modal-body .ping-line {
  margin: 0 0 2px 0;
}

.modal-footer {
  border-top: 1px solid #ccc;
  padding: 8px 12px;
  text-align: right;
}

.modal-ok {
  color: #060;
  margin: 0;
}

.modal-error {
  color: #b00;
  margin: 0;
}

/* ------------------------------------------------------------------ */
/* Компактный вид таблиц: тот же функционал, меньше места на экране.    */
/* ------------------------------------------------------------------ */

table.compact {
  font-size: 12.5px;
  line-height: 1.35;
  margin-bottom: 16px;
}

table.compact td,
table.compact th {
  padding: 3px 8px;
}

table.compact th {
  font-size: 12.5px;
  white-space: nowrap;
}

.ports-table {
  width: auto;
}

.ports-table th {
  vertical-align: bottom;
}

.ports-table td.if-name {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Кнопки действий в строку, компактные */
td.actions {
  white-space: nowrap;
}

td.actions form {
  display: inline-block;
  margin: 0 2px 0 0;
}

td.actions button {
  font-size: 11.5px;
  padding: 2px 7px;
  line-height: 1.35;
  cursor: pointer;
}

/* Колонка блоков: таблица опроса и таблица "Действие" друг под другом */
.block-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.block-col table {
  margin-bottom: 12px;
}

.block-col td button {
  font-size: 12.5px;
  padding: 3px 10px;
  cursor: pointer;
  width: 100%;
}

.block-col form {
  margin: 0;
}

.debug-table {
  border: 2px solid #000;
}

.debug-table td,
.debug-table th {
  border: 2px solid #000;
}

/* ------------------------------------------------------------------ */
/* Модальные окна                                                       */
/* ------------------------------------------------------------------ */

.modal-wide {
  max-width: 900px;
}

.modal-table {
  width: 100%;
  margin-bottom: 0;
}

.modal-details {
  margin: 8px 0 0 0;
  padding-left: 20px;
  font-size: 12px;
  color: #333;
}

.modal-details li {
  margin-bottom: 2px;
}

.modal-meta {
  margin: 2px 0;
  font-size: 12px;
  color: #444;
}

.modal-raw {
  margin-top: 10px;
  font-size: 11px;
}

.modal-raw summary {
  cursor: pointer;
  color: #1f60c4;
}

.modal-raw .ping-line {
  font-family: Consolas, monospace;
  font-size: 11px;
}


/* ------------------------------------------------------------------ */
/* Проверка актуального состояния порта по клику                       */
/* ------------------------------------------------------------------ */

.state-cell {
  cursor: pointer;
  user-select: none;
}

.state-cell:hover {
  text-decoration: underline dotted;
}

.state-cell.state-busy {
  opacity: 0.55;
  cursor: progress;
}

/* Дописанные значения отличаются от исходного, чтобы не путать
   состояние на момент опроса с проверками, сделанными позже. */
.state-history {
  color: #1f60c4;
}

/* ------------------------------------------------------------------ */
/* Фрейм действий                                                       */
/* ------------------------------------------------------------------ */

/* По умолчанию фрейм скрыт; скрипт показывает его через display:flex.
   Выравнивание по верху — длинные списки (интерфейсы, разведка MIB)
   иначе уезжают за края экрана. */
.modal-overlay {
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 0;
  overflow-y: auto;
}

.modal-wait {
  color: #444;
  font-style: italic;
  margin: 4px 0;
}

.modal-footer button {
  font-size: 12.5px;
  padding: 3px 12px;
  margin-right: 6px;
  cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Меню: одинаково на всех страницах                                    */
/* ------------------------------------------------------------------ */

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

nav .nav-brand {
  font-weight: bold;
}

nav .nav-menu {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
}

nav .nav-menu a.nav-active {
  text-decoration: underline;
  font-weight: bold;
}

nav .nav-user {
  opacity: 0.8;
}

/* ------------------------------------------------------------------ */
/* Главная страница                                                     */
/* ------------------------------------------------------------------ */

.home-page {
  max-width: 760px;
  line-height: 1.5;
}

.home-section {
  margin: 18px 0;
  padding-left: 12px;
  border-left: 3px solid #ccc;
}

.home-section-title {
  font-weight: bold;
  margin-bottom: 4px;
}

.home-hint,
.page-hint {
  color: #555;
  font-size: 12.5px;
}

/* ------------------------------------------------------------------ */
/* Таблица узлов                                                        */
/* ------------------------------------------------------------------ */

.nodes-table td {
  vertical-align: top;
}

.nodes-table td.actions button {
  margin-right: 4px;
}

.nodes-empty {
  color: #666;
  font-style: italic;
}

/* Поля во фрейме добавления и изменения узла */
.modal-field {
  margin: 6px 0;
}

.modal-field label {
  display: inline-block;
  width: 110px;
  font-size: 12.5px;
}

.modal-field input {
  width: 240px;
}

/* ------------------------------------------------------------------ */
/* Панель поиска и навигация по страницам узлов                        */
/* ------------------------------------------------------------------ */

.nodes-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

.nodes-toolbar input {
  width: 260px;
}

.nodes-count {
  margin-left: auto;
  color: #555;
  font-size: 12.5px;
}

.pager {
  display: flex;
  gap: 4px;
  align-items: center;
  margin: 10px 0 20px 0;
}

.pager button {
  min-width: 28px;
  padding: 2px 7px;
  font-size: 12.5px;
  cursor: pointer;
}

.pager button:disabled {
  opacity: 0.4;
  cursor: default;
}

.pager button.pager-active {
  font-weight: bold;
  border: 2px solid #333;
}

/* ------------------------------------------------------------------ */
/* Отключённый пункт меню                                              */
/* ------------------------------------------------------------------ */

nav .nav-disabled {
  color: #9a9a9a;
  cursor: not-allowed;
  user-select: none;
}

.home-off {
  color: #9a9a9a;
  font-weight: normal;
}

/* Галочка debug в таблице пользователей */
.debug-cell {
  text-align: center;
}

.debug-form {
  margin: 0;
  display: inline;
}

/* Уровень оптического сигнала между порогами */
.cell-signal-mid {
  background: #ffff00;
  color: #000;
}

/* Фрейм «Свойства» */
.props-text {
  width: 100%;
  min-height: 220px;
  box-sizing: border-box;
  font-family: Arial, sans-serif;
  font-size: 13px;
  resize: vertical;
}

.props-view {
  white-space: pre-wrap;
  margin: 0;
  min-height: 40px;
}

.optic-line {
  margin: 0 0 4px 0;
}

.optic-line .signal {
  padding: 1px 6px;
}

.inline-action { display: inline; }
.server-report table { margin-bottom: 14px; }
.server-report td { overflow-wrap: anywhere; max-width: 32em; }
.server-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr)); gap: 0 18px; }
.server-fields .modal-field input { width: 100%; box-sizing: border-box; }
.server-fields .modal-field label { display: block; width: auto; }
.device-fields h4 { margin: 12px 0 4px; }
.server-fields .modal-field input[type="checkbox"] { width: auto; }

.port-results { margin: 12px 0; }
.server-report .port-command { text-align: center; }
.server-report .status-value {
  color: inherit;
  font: inherit;
  background: transparent;
  border: 0;
  padding: 0;
  text-decoration: underline dotted;
  cursor: pointer;
}
.port-results .error-tag { color: #000; }

.server-report { display: grid; grid-template-columns: minmax(12rem, min(32%, 20rem)) minmax(0, 1fr); gap: clamp(12px, 3vw, 40px); }
.server-report .port-results { gap: 12px clamp(12px, 3vw, 40px); }
@media (max-width: 560px) {
  .server-report { grid-template-columns: minmax(0, 1fr); }
}
.server-report .report-stack { width: min(20rem, 100%); }
.server-report .report-stack table { width: 100%; table-layout: fixed; }
.server-info button, .server-report .port-command button { width: 100%; box-sizing: border-box; }
.server-report > section { min-width: 0; max-width: 100%; }
.uplink-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.port-macs summary { cursor: pointer; text-decoration: underline dotted; }
.port-macs ul { list-style: none; padding: 0; margin: 4px 0 0; }
.provider-option { display: block; font-size: 12.5px; }
.switch-fields { margin: 12px 0 0; padding: 6px 0; border: 0; min-width: 0; }
.switch-fields legend { padding: 0; font-weight: bold; }

.assignee-list label { display: block; width: auto; }

.totp-qr { max-width: 100%; height: auto; image-rendering: pixelated; }
.recovery-codes { line-height: 1.6; }
