:root {
  --surface-1:      #fcfcfb;
  --page-plane:     #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --border:         rgba(11,11,11,0.10);

  /* Всплывающие окна: фон чуть темнее страницы + средне-серый контур,
     чтобы окно читалось на любом фоне (не «белое на белом»). */
  --modal-surface:  #eef0f3;
  --modal-ring:     rgba(60,60,60,0.45);

  --slot-blue:    #2a78d6;
  --slot-aqua:    #1baf7a;
  --slot-yellow:  #eda100;
  --slot-green:   #008300;
  --slot-violet:  #4a3aa7;
  --slot-red:     #e34948;

  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;

  --accent: #2a78d6;
  --accent-glow: rgba(42,120,214,0.35);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-1:      #1a1a19;
    --page-plane:     #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --border:         rgba(255,255,255,0.10);

    /* Тёмная схема: окно светлее страницы (#0d0d0d) + светлый контур. */
    --modal-surface:  #26261f;
    --modal-ring:     rgba(180,180,180,0.45);

    --slot-blue:    #3987e5;
    --slot-aqua:    #199e70;
    --slot-yellow:  #c98500;
    --slot-green:   #008300;
    --slot-violet:  #9085e9;
    --slot-red:     #e66767;

    --status-good:     #0ca30c;
    --status-warning:  #fab219;
    --status-serious:  #ec835a;
    --status-critical: #d03b3b;

    --accent: #3987e5;
    --accent-glow: rgba(57,135,229,0.40);
  }
}
/* ручной выбор тёмной темы (кнопка в шапке) — те же значения */
:root[data-theme="dark"] {
  --surface-1:      #1a1a19;
  --page-plane:     #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --border:         rgba(255,255,255,0.10);

  /* Тёмная схема: окно светлее страницы (#0d0d0d) + светлый контур. */
  --modal-surface:  #26261f;
  --modal-ring:     rgba(180,180,180,0.45);

  --slot-blue:    #3987e5;
  --slot-aqua:    #199e70;
  --slot-yellow:  #c98500;
  --slot-green:   #008300;
  --slot-violet:  #9085e9;
  --slot-red:     #e66767;

  --status-good:     #0ca30c;
  --status-warning:  #fab219;
  --status-serious:  #ec835a;
  --status-critical: #d03b3b;

  --accent: #3987e5;
  --accent-glow: rgba(57,135,229,0.40);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* top navigation bar */
.topbar {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
  height: 56px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  text-decoration: none;
}
/* Значок КИТ (стиль Кит: логотип-«кит» слева от названия приложения) */
.brand-logo { display: block; flex: none; object-fit: contain; }
/* Название — двумя цветами: смысловые части разными акцентами. Подберите
   пару под проект (эталон Make1s: акцент + slot-yellow). */
.brand-name .b-1 { color: var(--accent); }
.brand-name .b-2 { color: var(--slot-yellow); }
.brand .accent { color: var(--accent); }
/* значок идущей загрузки с releases.1c.ru — в шапке после версии,
   ссылка на страницу прогресса */
.brand .dl-indicator {
  display: inline-flex;
  margin-left: 8px;
  vertical-align: 1px;
}
.brand .app-version {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  vertical-align: 2px;
}
.nav-links {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 8px;
  transition: background 0.12s, color 0.12s;
}
.nav-links a:hover {
  background: var(--page-plane);
  color: var(--text-primary);
}
.nav-links a.active {
  background: var(--accent);
  color: #fff;
}
.topbar-user {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.topbar-user .user-name {
  color: var(--text-secondary);
  font-weight: 500;
}
.topbar-user .logout-link {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.topbar-user .logout-link:hover {
  color: var(--text-primary);
  background: var(--page-plane);
}

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
header.page-header { margin-bottom: 28px; }
header.page-header h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
}
header.page-header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13px;
}

section {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}
section h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 2px;
}
section .subtitle {
  color: var(--text-secondary);
  font-size: 12.5px;
  margin: 0 0 16px;
}
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.section-head .subtitle { margin-bottom: 16px; }
.section-head form { flex: none; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--gridline);
}
tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--gridline);
  vertical-align: top;
}
tbody tr:last-child td { border-bottom: none; }
td.mono, .mono { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12.5px; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--page-plane); }
tr.row-link td a { color: var(--accent); text-decoration: none; font-weight: 500; }
/* ссылка-кнопка внутри строки-ссылки — текст кнопки, а не ссылки */
tr.row-link td a.btn { color: #fff; }
tr.row-link td a.btn.secondary { color: var(--text-primary); }

/* Список серверов: слева компактные метаданные сервера в столбик,
   справа — широкая колонка «Установленные 1С». */
.servers-table { table-layout: fixed; }
.servers-table .col-server { width: 300px; }
.server-cell { width: 300px; }
.server-name { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.server-meta { margin: 0; }
.server-meta > div { display: flex; gap: 8px; font-size: 12px; line-height: 1.5; }
.server-meta dt { flex: 0 0 78px; color: var(--text-secondary); }
.server-meta dd { margin: 0; min-width: 0; word-break: break-word; }
.server-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.server-actions .scan-form { margin: 0; }

.installed-cell .onec-ver { margin-bottom: 10px; }
.installed-cell .onec-ver:last-of-type { margin-bottom: 4px; }
.onec-head { font-weight: 500; }
.onec-svc { padding-left: 16px; font-size: 12.5px; color: var(--text-secondary); }
/* Разделение кластеров (каждый экземпляр службы = кластер на своём порту)
   горизонтальной линией. */
.onec-svc + .onec-svc { border-top: 1px solid var(--border); margin-top: 5px; padding-top: 5px; }
.onec-run { color: #2e7d32; font-weight: 500; }
.onec-stopped { color: #b26a00; font-weight: 500; }
.onec-none { color: var(--text-muted); }
/* потребители лицензий (rmngr/rphost у сервера лицензирования) */
.onec-consumers { color: #2e7d32; font-size: 12px; padding-left: 14px; }
/* мини-кнопки пуск/стоп экземпляра прямо в списке серверов */
.power-form { display: inline; margin-left: 6px; }
.btn-mini {
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 10px;
  line-height: 1.4;
  padding: 2px 7px;
  vertical-align: 1px;
}
.btn-mini.icon-start { background: #2e7d32; }
.btn-mini.icon-stop { background: #c62828; }
.btn-mini.icon-delete { background: #8e2424; font-weight: 700; }
.btn-mini.icon-add { background: #2e7d32; font-weight: 700; margin-left: 6px; }
/* деинсталляция компонентов версии — открывает консоль с планом */
.onec-uninst { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 4px; }
.onec-uninst form { margin: 0; }
.btn-mini.uninst {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--status-critical);
  font-size: 10.5px;
}
.btn-mini.uninst:hover { border-color: var(--status-critical); }
/* подключение сервера лицензирования — открывает предварительный план */
.btn-mini.lic-connect {
  background: transparent;
  border: 1px solid var(--border);
  color: #2e7d32;
  font-size: 10.5px;
  margin-left: 6px;
}
.btn-mini.lic-connect:hover { border-color: #2e7d32; }

.empty-state {
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px 4px;
  text-align: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}
.btn.secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
/* ячейка со своим действием — по ней строка-ссылка не переходит */
.cell-nolink { white-space: nowrap; }

/* формы */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.field input[type="text"],
.field input[type="password"] {
  width: 100%;
  max-width: 560px;
  background: var(--page-plane);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-primary);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
.field input[type="text"]:focus,
.field input[type="password"]:focus {
  outline: none;
  border-color: var(--accent);
}
.field .select {
  width: 100%;
  max-width: 560px;
  background: var(--page-plane);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  color: var(--text-primary);
}
.field .select:focus { outline: none; border-color: var(--accent); }
.form-actions { margin-top: 4px; }
.form-actions .btn + .btn { margin-left: 8px; }
.field.checkboxes { display: flex; gap: 20px; }
.field.checkboxes label { display: flex; align-items: center; gap: 6px; font-weight: 400; color: var(--text-primary); }

/* строки «сеть → путь» в настройках дистрибутивов */
.path-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}
.path-row input[type="text"]:first-child { max-width: 260px; }
.path-row input[type="text"]:last-child { max-width: 480px; }

/* блоки команд (предпросмотр установки) */
pre.code {
  background: var(--page-plane);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 0 0 8px;
  overflow-x: auto;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre;
}
.step-note {
  color: var(--text-secondary);
  font-size: 12.5px;
  margin: 0;
}
.survey-error { color: var(--status-critical); }
.survey-time { color: var(--text-muted); font-size: 11px; }
/* версия агента sInformer (дотягивается фоном в списке и карточке) */
.agent-ver-err { color: var(--text-muted); }

/* итог действия со службой — сообщением прямо в строке сервера */
.row-msg {
  border-radius: 8px;
  padding: 6px 10px;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 500;
}
.row-msg.ok {
  background: rgba(12,163,12,0.10);
  border: 1px solid var(--status-good);
  color: var(--status-good);
}
.row-msg.err {
  background: rgba(208,59,59,0.10);
  border: 1px solid var(--status-critical);
  color: var(--status-critical);
}

/* общее количество лицензий сервера (сумма «Количество пользователей») */
.lic-total { margin-top: 8px; font-weight: 600; font-size: 12px; }

/* текст файла программной лицензии (Linux /var/1C/licenses,
   Windows C:\ProgramData\1C\licenses) — как есть */
.lic-text {
  background: var(--page-plane);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  margin: 8px 0 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* установленные службы 1С в карточке сервера */
.svc-table td { vertical-align: top; }
.svc-sub { color: var(--text-secondary); font-size: 11.5px; margin-top: 2px; }
.svc-ok { color: #2e7d32; font-weight: 600; }
.svc-lic { color: #2e7d32; }
.svc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.svc-actions form { margin: 0; }
/* кнопки-иконки старт/стоп службы (подсказка — в title) */
.btn-icon { gap: 5px; }
.btn-icon .icon-label { font-weight: 500; }
.btn-icon.icon-start { background: #2e7d32; }
.btn-icon.icon-stop { background: #c62828; }
.btn-icon.icon-delete { background: #8e2424; }
/* статус фоновой загрузки блока служб в карточке */
.svc-wait { display: flex; align-items: center; gap: 10px; }
.spinner {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.svc-recreate { display: flex; gap: 6px; align-items: center; }

/* консоль установки/удаления (потоковый вывод, как командная строка) */
.console {
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 4px;
  height: 460px;
  overflow-y: auto;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #d7d7d2;
}
.console .cline { white-space: pre-wrap; word-break: break-word; }
.console .c-head   { color: #6f9bd6; font-weight: 600; }
.console .c-step   { color: #f0f0ea; font-weight: 600; }
.console .c-where  { color: #898781; }
.console .c-cmd    { color: #c3c2b7; }
.console .c-note   { color: #7c8a6a; }
.console .c-prompt { color: #6fd67a; }
.console .c-out    { color: #d7d7d2; }
.console .c-ok     { color: #4fd06a; font-weight: 600; }
.console .c-err    { color: #e66767; font-weight: 600; }

/* модальное окно «Сканирование» — действия и результаты опроса сервера */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--modal-surface);
  border: 1px solid var(--modal-ring);
  border-radius: 10px;
  width: 640px;
  max-width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--modal-ring);
}
/* Высококонтрастные схемы Windows: цвета переопределяются системой —
   гарантируем видимую рамку окна системным цветом. */
@media (forced-colors: active) {
  .modal { border: 2px solid CanvasText; }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
}
.modal-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
/* Имя сервера в заголовке окна — всегда крупнее и в акцентном цвете. */
.modal-head .srv-name { font-size: 1.25em; font-weight: 700; color: var(--accent); }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 7px;
  border-radius: 6px;
}
.modal-close:hover { color: var(--text-primary); background: var(--page-plane); }
.modal .console {
  margin: 0 16px 16px;
  height: auto;
  min-height: 140px;
  max-height: 55vh;
}
.modal .scan-wait { display: flex; align-items: center; gap: 10px; }
/* окно-форма («Создать агента») */
.modal-body { padding: 0 16px 16px; overflow-y: auto; }
.modal-body .field input[type="text"],
.modal-body .field input[type="password"] { max-width: none; }
/* Поля ввода в окнах запроса: рамка подсвечена всегда (даже без фокуса),
   при выборе — ярче, со свечением. */
.modal-body .field input[type="text"],
.modal-body .field input[type="password"],
.modal-body .field .select {
  border-color: var(--accent);
}
.modal-body .field input[type="text"]:focus,
.modal-body .field input[type="password"]:focus,
.modal-body .field .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
/* окно подтверждения (вместо системного confirm) */
.modal-confirm { width: 480px; }
.confirm-text {
  padding: 2px 16px 0;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-line;
}
.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px;
}
.btn.danger { background: #c62828; }

/* служебные сообщения */
.notice {
  background: rgba(12,163,12,0.10);
  border: 1px solid var(--status-good);
  color: var(--status-good);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 20px;
}
.notice.error {
  background: rgba(208,59,59,0.10);
  border-color: var(--status-critical);
  color: var(--status-critical);
}

footer {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 24px 0;
}
