/* Шрифты: свои файлы из @fontsource (SIL OFL), без внешних CDN. */
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/onest-cyrillic-600.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: "Onest";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/onest-latin-600.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/golos-text-cyrillic-400.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/golos-text-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/golos-text-cyrillic-500.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: "Golos Text";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/golos-text-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-cyrillic-400.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-latin-400.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-cyrillic-500.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/jetbrains-mono-latin-500.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* Переменные дизайн-системы (docs/design.md). Тема по системе или по выбору (кнопка в шапке). */
:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #e3e6eb;
  --text: #14181f;
  --muted: #5b6572;
  --accent: #5b6cff;
  --accent-strong: #4a59e6; /* тот же индиго, темнее: текст ссылок и кнопка держат контраст 4,5:1 */
  --on-accent: #ffffff;
  --ok: #1e8f5f;
  --bad: #d6373d;
  --warn: #b7791f;
  --off: #7a8594;

  --font-head: "Onest", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-text: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-card: 10px;
  --radius-btn: 8px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --page-max: 1200px;
}

/* Тёмная тема: по системе (если выбор не «Светлая») или по выбору data-theme="dark" */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116;
    --surface: #151a21;
    --surface-2: #1b222b;
    --border: #262e39;
    --text: #e6eaf0;
    --muted: #8a94a3;
    --accent: #8591ff;
    --accent-strong: #8591ff;
    --on-accent: #0e1116;
    --ok: #2fb67c;
    --bad: #f0666b;
    --warn: #e0a526;
    --off: #6b7685;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1116;
  --surface: #151a21;
  --surface-2: #1b222b;
  --border: #262e39;
  --text: #e6eaf0;
  --muted: #8a94a3;
  --accent: #8591ff;
  --accent-strong: #8591ff;
  --on-accent: #0e1116;
  --ok: #2fb67c;
  --bad: #f0666b;
  --warn: #e0a526;
  --off: #6b7685;
}

:root[data-theme="light"] {
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.5;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-head);
  font-weight: 600;
  line-height: 1.25;
}

h1 {
  font-size: 20px;
}

h2 {
  font-size: 16px;
}

p {
  margin: 0;
}

a {
  color: var(--accent-strong);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.mono {
  font-family: var(--font-mono);
}

.muted {
  color: var(--muted);
}

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

/* Шапка */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  display: flex;
  align-items: center;
  gap: var(--s2);
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--s4);
}

.brand {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 20px;
  color: var(--text);
  text-decoration: none;
}

.nav {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav::-webkit-scrollbar {
  display: none;
}

.nav a {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 var(--s3);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 120ms, background-color 120ms;
}

.nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.topbar .btn {
  flex: none;
}

/* Переключатель темы: квадрат 44×44 с иконкой */
.theme-toggle {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: color 120ms, background-color 120ms;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--surface-2);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle svg {
  display: none;
}

.theme-toggle[data-mode="auto"] .i-auto,
.theme-toggle[data-mode="light"] .i-light,
.theme-toggle[data-mode="dark"] .i-dark {
  display: block;
}

.theme-toggle--corner {
  position: absolute;
  top: var(--s3);
  right: var(--s3);
}

.topbar__msg {
  flex: 1 0 100%;
  order: 10;
  padding: var(--s2) 0;
  font-size: 14px;
  color: var(--bad);
}

/* Телефон: бренд и «Выйти» в первой строке, разделы второй строкой на всю ширину */
@media (max-width: 479px) {
  .topbar__inner {
    flex-wrap: wrap;
    padding: 0 var(--s3);
  }

  .brand {
    flex: 1 1 auto;
  }

  .topbar .theme-toggle {
    width: 44px;
    min-height: 44px;
  }

  .topbar .btn {
    min-height: 40px;
    padding: 0 var(--s3);
  }

  .nav {
    order: 5;
    flex: 1 0 100%;
    margin: 0 calc(-1 * var(--s2));
  }

  .nav a {
    flex: 1 1 0;
    justify-content: center;
    padding: 0 var(--s2);
  }
}

/* Страница */
.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.page__title {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

/* Карточка */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--s4);
}

.card > * + * {
  margin-top: var(--s2);
}

/* Кнопки */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  color: var(--text);
  font: 500 14px/1 var(--font-text);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms;
}

.btn:hover {
  background: var(--surface-2);
}

.btn--primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
}

.btn--primary:hover {
  background: var(--accent-strong);
  filter: brightness(1.08);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--block {
  width: 100%;
}

/* Поля */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.field label {
  font-size: 14px;
  font-weight: 500;
}

.input {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--font-text);
}

.input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
  border-color: var(--accent);
}

.input:disabled {
  opacity: 0.7;
}

/* Плашка сообщения */
.alert {
  padding: var(--s2) var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-size: 14px;
}

.alert--error {
  color: var(--bad);
  border-color: var(--bad);
}

/* Значок статуса: точка и слово */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-size: 14px;
  font-weight: 500;
}

.status .dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--off);
}

.status.run .dot {
  background: var(--ok);
  animation: breathe 2.4s ease-in-out infinite;
}

.status.down .dot {
  background: var(--bad);
}

.status.restart .dot {
  background: var(--warn);
}

.status.unknown .dot {
  background: transparent;
  border: 2px dashed var(--off);
}

@keyframes breathe {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* Строка-вердикт главной */
.verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1) var(--s2);
  min-height: 44px;
}

.verdict .status {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 600;
}

.verdict .status.unknown {
  color: var(--muted);
}

/* Пустое состояние */
.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s3);
}

.empty p {
  max-width: 60ch;
}

/* Экран входа */
.auth {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s5);
  padding: var(--s4);
}

.auth__head {
  text-align: center;
}

.auth__head h1 {
  font-size: 28px;
}

.auth__card {
  width: 100%;
  max-width: 360px;
}

.auth__card form {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.auth__card .btn {
  min-height: 48px;
}

.auth__card .card > * + *,
.auth__card form > * + * {
  margin-top: 0;
}

/* Телефон: вход на всю ширину, главное действие под рукой */
@media (max-width: 479px) {
  .auth {
    justify-content: flex-start;
    padding-top: var(--s5);
  }

  .auth__card {
    max-width: none;
  }
}

@media (min-width: 768px) {
  h1 {
    font-size: 28px;
  }

  body {
    font-size: 14px;
  }

  .input {
    font-size: 14px;
  }

  .page {
    padding: var(--s5) var(--s4);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Плашки: успех и внимание (ошибка уже есть выше) */
/* Зелёный и жёлтый на белом не дотягивают до 4,5:1, поэтому цветом идёт рамка, текст обычный. */
.alert--ok {
  border-color: var(--ok);
  border-left-width: 4px;
}

.alert--warn {
  border-color: var(--warn);
  border-left-width: 4px;
}

.alert__list {
  margin: var(--s2) 0 0;
  padding-left: var(--s4);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.alert__list li + li {
  margin-top: var(--s1);
}

/* Блок «Реестр» */
.registry-info {
  color: var(--muted);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.registry-info .path {
  font-size: 12px;
}

.registry-result {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.registry-result:empty {
  display: none;
}

.card > .btn--registry {
  margin-top: var(--s3);
}

.card > .registry-result {
  margin-top: var(--s3);
}

/* Фильтр главной: ссылки-«таблетки», на телефоне прокручиваются внутри полосы */
.filters {
  display: flex;
  gap: var(--s2);
  margin-bottom: var(--s3);
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s4);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 120ms, border-color 120ms;
}

.chip:hover {
  background: var(--surface-2);
}

.chip[aria-current="true"] {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* Сетка карточек проектов: 1 колонка на телефоне, 2 на планшете, 3 на десктопе */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.project > * + * {
  margin-top: var(--s2);
}

.project__name {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.project__tag,
.project__note {
  font-size: 14px;
  overflow-wrap: anywhere;
}

.project__note {
  font-size: 12px;
}

@media (min-width: 600px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Телефон: кнопка реестра на всю ширину */
@media (max-width: 479px) {
  .card > .btn--registry {
    display: flex;
    width: 100%;
  }
}

/* --- Этап 3: главная, карточки, графики, страница проекта --- */

#dashboard,
.live {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.summary {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
}

.verdict__word {
  color: var(--bad);
}

.verdict__rest {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 600;
}

.counts {
  font-size: 12px;
  line-height: 1.6;
}

.counts > span {
  white-space: nowrap;
}

.updated {
  font-size: 12px;
}

.status.stopped .dot {
  background: var(--off);
}

/* Карточка сервера */
.server__body {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s4);
}

.server__meters {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.server__charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s3);
  align-content: start;
}

.server__facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s1) var(--s4);
  font-size: 14px;
  color: var(--muted);
}

.meter__head {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  font-size: 14px;
}

.meter__head .mono {
  font-size: 13px;
}

.meter__bar {
  display: block;
  width: 100%;
  height: 8px;
  margin-top: var(--s1);
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}

.meter__fill {
  fill: var(--muted);
}

.meter--hot .meter__fill {
  fill: var(--warn);
}

.figure {
  margin: 0;
}

.figure figcaption {
  display: flex;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s1);
  font-size: 12px;
  color: var(--muted);
}

.figure figcaption .mono {
  color: var(--text);
}

/* Графики: серверный SVG, цвета через currentColor и переменные */
.chart {
  display: block;
  width: 100%;
  overflow: visible;
  color: var(--muted);
}

.chart--wide {
  height: 56px;
}

.chart--spark {
  height: 36px;
}

.chart__line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.chart__area {
  fill: currentColor;
  fill-opacity: 0.14;
  stroke: none;
}

.chart__dot {
  fill: none;
  stroke: var(--text);
  stroke-width: 6;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.chart-empty {
  font-size: 12px;
  color: var(--muted);
}

/* Карточка проекта: вся карточка ссылка */
.grid__item {
  display: flex;
}

a.project {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  transition: background-color 120ms, border-color 120ms;
}

a.project:hover {
  background: var(--surface-2);
}

.project__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
}

.project__uptime {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.project__metrics {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--s3);
}

.project__nums {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  line-height: 1.5;
}

.project__spark {
  min-width: 0;
}

.project__noload {
  font-size: 12px;
}

.project__reason {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.project__reason--bad {
  font-size: 14px;
  color: var(--bad);
}

.projects > .card {
  margin-top: 0;
}

/* Страница проекта */
.back {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 44px;
  font-size: 14px;
  font-weight: 500;
}

.phead {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.phead__name {
  font-size: 28px;
  overflow-wrap: anywhere;
}

.phead__tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.tag {
  display: inline-block;
  padding: 2px var(--s2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
}

.bigstatus .status {
  gap: var(--s3);
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 600;
}

.bigstatus .status .dot {
  width: 14px;
  height: 14px;
}

.summary-line {
  font-size: 14px;
}

.summary-line .mono {
  font-size: 13px;
}

.tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s4);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}

.tab[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab--off {
  cursor: not-allowed;
}

.overview {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s4);
}

.res {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.card > .facts,
.card > .res,
.card > .servitors {
  margin-top: var(--s3);
}

.facts {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  margin: 0;
}

.facts > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.facts dt {
  font-size: 12px;
  color: var(--muted);
}

.facts dd {
  margin: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.facts dd.mono {
  font-size: 13px;
}

.facts__bad {
  color: var(--bad);
}

/* Блок «Сервиторы» на странице «Система» */
.servitors {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.servitor__line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s1) var(--s2);
  font-size: 14px;
}

.servitor__title {
  font-weight: 500;
}

.servitor__error {
  margin-top: var(--s1);
  font-size: 14px;
  color: var(--bad);
  overflow-wrap: anywhere;
}

@media (min-width: 768px) {
  .server__body {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--s5);
  }

  .overview {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .overview__wide {
    grid-column: 1 / -1;
  }

  .facts > div {
    flex-direction: row;
    gap: var(--s4);
  }

  .facts dt {
    flex: none;
    width: 160px;
    padding-top: 2px;
  }
}

@media (max-width: 479px) {
  a.project {
    padding: var(--s3);
  }

  .phead__name {
    font-size: 20px;
  }

  .bigstatus .status {
    font-size: 20px;
  }
}

/* --- Этап 4: инциденты, история, пороги --- */

.project__critical {
  color: var(--text);
  font-weight: 500;
}

.project__reason--bad + .project__reason {
  margin-top: var(--s1);
}

.incident {
  border-color: var(--bad);
}

/* Кнопка в виде ссылки («Повторить») */
.linkbtn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 var(--s2);
  border: 0;
  background: none;
  color: var(--accent-strong);
  font: 500 14px/1 var(--font-text);
  text-decoration: underline;
  cursor: pointer;
}

.alert .linkbtn {
  min-height: 44px;
}

/* История: таблица на десктопе, карточки на телефоне */
.history {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}

.itable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  overflow: hidden;
  font-size: 14px;
}

.itable th {
  padding: var(--s3) var(--s4);
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-2);
  white-space: nowrap;
}

.itable td {
  padding: var(--s3) var(--s4);
  vertical-align: top;
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
}

.itable .mono {
  font-size: 13px;
}

.itable__open {
  color: var(--bad);
  font-weight: 500;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  font-size: 14px;
}

.pager .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
}

.history__skeleton {
  display: none;
  flex-direction: column;
  gap: var(--s2);
}

.skeleton {
  height: 44px;
  border-radius: var(--radius-btn);
  background: var(--surface-2);
}

.history.htmx-request .history__skeleton {
  display: flex;
}

.history.htmx-request .history__error {
  display: none;
}

@media (max-width: 639px) {
  .itable,
  .itable tbody,
  .itable tr,
  .itable td {
    display: block;
  }

  .itable {
    background: none;
    border: 0;
    border-radius: 0;
    overflow: visible;
  }

  .itable thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .itable tr {
    margin-bottom: var(--s3);
    padding: var(--s3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
  }

  .itable td {
    display: flex;
    justify-content: space-between;
    gap: var(--s3);
    padding: var(--s1) 0;
    border-top: 0;
    text-align: right;
  }

  .itable td::before {
    content: attr(data-label);
    flex: none;
    font-family: var(--font-text);
    font-size: 12px;
    color: var(--muted);
    text-align: left;
  }

  .itable td.itable__reason {
    flex-direction: column;
    gap: var(--s1);
    text-align: left;
  }

  .pager .btn {
    flex: 1 1 0;
  }

  .pager__pos {
    flex: none;
  }
}

/* Пороги и автоперезапуск */
.settings {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  margin-top: var(--s3);
  max-width: 480px;
}

.card > .settings {
  margin-top: var(--s3);
}

.field__hint {
  font-size: 12px;
}

.field__error {
  font-size: 14px;
  color: var(--bad);
}

.input[aria-invalid="true"] {
  border-color: var(--bad);
}

.switch-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: 44px;
}

.switch-row label {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  min-height: 44px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  position: relative;
  width: 44px;
  height: 26px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface-2);
  cursor: pointer;
  transition: background-color 120ms, border-color 120ms;
}

.switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 120ms, background-color 120ms;
}

.switch:checked {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.switch:checked::before {
  transform: translateX(18px);
  background: var(--on-accent);
}

.settings__result:empty {
  display: none;
}

@media (max-width: 479px) {
  .settings {
    max-width: none;
  }

  .btn--save {
    width: 100%;
    min-height: 48px;
  }
}

/* --- Этап 5: управление, логи, действия, журнал --- */

/* Кнопки управления проектом: на телефоне в столбик на всю ширину */
.controls {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.controls__row {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}

.controls__row .btn {
  width: 100%;
  min-height: 48px;
}

.controls__reason {
  font-size: 13px;
}

.action-result:empty {
  display: none;
}

@media (min-width: 640px) {
  .controls__row {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .controls__row .btn {
    width: auto;
    min-height: 44px;
  }
}

/* Окно подтверждения */
.dialog {
  width: calc(100% - 2 * var(--s4));
  max-width: 440px;
  padding: var(--s5);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--text);
}

.dialog::backdrop {
  background: rgba(14, 17, 22, 0.6);
}

.dialog > * + * {
  margin-top: var(--s3);
}

.dialog h2 {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.dialog__actions {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--s2);
  margin-top: var(--s4);
}

.dialog__actions .btn {
  width: 100%;
  min-height: 48px;
}

@media (min-width: 480px) {
  .dialog__actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .dialog__actions .btn {
    width: auto;
    min-height: 44px;
  }
}

/* Логи */
.logs {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.logs__bar {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.logs__btns {
  display: flex;
  gap: var(--s2);
}

.logs__btns .btn {
  flex: 1 1 0;
}

select.input {
  padding-right: var(--s2);
}

.logs__status,
.logs__masked {
  font-size: 14px;
}

.logs__view {
  margin: 0;
  padding: var(--s3);
  max-height: 60vh;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (min-width: 640px) {
  .logs__bar {
    flex-direction: row;
    align-items: flex-end;
  }

  .logs__filter {
    flex: 1 1 auto;
  }

  .logs__lines {
    flex: none;
    width: 120px;
  }

  .logs__btns .btn {
    flex: none;
  }

  .logs__view {
    white-space: pre;
    overflow-wrap: normal;
  }
}

/* Результат: цвет и слово */
.result {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  flex: none;
  padding: 2px var(--s2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.result::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.result--ok {
  border-color: var(--ok);
}

.result--ok::before {
  background: var(--ok);
}

.result--bad {
  border-color: var(--bad);
}

.result--bad::before {
  background: var(--bad);
}

.result--warn {
  border-color: var(--warn);
}

.result--warn::before {
  background: var(--warn);
}

/* Последние действия в «Истории» */
.alog {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}

.alog__list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.alog__item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  font-size: 14px;
}

.alog__item + .alog__item {
  border-top: 1px solid var(--border);
}

.alog__text {
  overflow-wrap: anywhere;
}

/* Журнал /audit */
.afilters {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--s3);
}

.afilters__apply {
  width: 100%;
}

@media (min-width: 768px) {
  .afilters {
    grid-template-columns: repeat(3, 1fr) auto;
    align-items: end;
  }

  .afilters__apply {
    width: auto;
  }
}

.atable__line2 {
  display: none;
}

.atable__detail {
  font-size: 12px;
}

@media (max-width: 639px) {
  .atable tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--s2) var(--s3);
    align-items: start;
  }

  .atable td {
    display: none;
    padding: 0;
    text-align: left;
  }

  .atable td::before {
    content: none;
  }

  .atable td.atable__time {
    display: block;
    grid-column: 1;
    grid-row: 1;
  }

  .atable td.atable__project {
    display: block;
    grid-column: 2;
    grid-row: 1;
    max-width: 45vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: right;
    font-size: 13px;
  }

  .atable td.atable__line2 {
    display: block;
    grid-column: 1;
    grid-row: 2;
    overflow-wrap: anywhere;
  }

  .atable td.atable__result {
    display: block;
    grid-column: 2;
    grid-row: 2;
  }
}
