:root {
  --pm-bg: #f5f2ea;
  --pm-surface: rgba(255, 255, 255, 0.72);
  --pm-surface-strong: #fffdf8;
  --pm-ink: #18312c;
  --pm-muted: #5f6f68;
  --pm-line: rgba(24, 49, 44, 0.12);
  --pm-ok: #2f7d4c;
  --pm-warn: #c48b18;
  --pm-fail: #be4a2f;
  --pm-unreachable: #7c3aed;
  --pm-stale: #6b7280;
}

html {
  font-size: 15px;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  color: var(--pm-ink);
  background:
    radial-gradient(circle at top left, rgba(36, 91, 76, 0.14), transparent 32%),
    radial-gradient(circle at top right, rgba(196, 139, 24, 0.12), transparent 28%),
    linear-gradient(180deg, #f6f3ec 0%, #ece6da 100%);
  font-family: Georgia, "Times New Roman", serif;
}

a {
  color: #1f5f51;
  text-decoration: none;
}

a:hover {
  color: #143c33;
}

.dashboard-hero,
.details-hero,
.auth-panel__card,
.empty-state-panel,
.host-card,
.details-panel,
.metric-card,
.notice {
  background: var(--pm-surface);
  border: 1px solid var(--pm-line);
  box-shadow: 0 18px 40px rgba(24, 49, 44, 0.08);
  backdrop-filter: blur(10px);
}

.dashboard-hero,
.details-hero,
.auth-panel__card {
  border-radius: 28px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.dashboard-hero h1,
.details-hero h1,
.auth-panel__card h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  margin: 0.35rem 0 0.75rem;
}

.dashboard-hero p,
.details-hero p,
.auth-panel__lead,
.panel-empty,
.table-subtle,
.host-card__meta,
.metric-label,
.eyebrow,
.facts-list {
  color: var(--pm-muted);
}

.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 700;
}

.host-grid,
.metrics-grid,
.details-grid,
.auth-panel {
  display: grid;
  gap: 1rem;
}

.host-grid {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 1.5rem;
}

.details-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  margin-bottom: 1.5rem;
}

.details-grid--history {
  align-items: start;
}

.auth-panel {
  min-height: calc(100vh - 240px);
  place-items: center;
}

.auth-panel__card {
  width: min(100%, 520px);
}

.auth-form {
  margin-top: 1.25rem;
}

.auth-panel__submit {
  min-width: 220px;
}

.host-card,
.details-panel,
.metric-card,
.empty-state-panel {
  border-radius: 24px;
  padding: 1.25rem;
}

.details-panel--scroll {
  display: flex;
  flex-direction: column;
}

.details-panel__scroll-body {
  /* Внутренняя прокрутка не даёт блоку истории запусков растягивать всю карточку PACS. */
  overflow: auto;
  max-height: 440px;
  margin-top: 0.75rem;
}

.details-panel--wide {
  margin-bottom: 1.5rem;
}

.preserved-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.log-sample {
  max-width: min(920px, 70vw);
  margin: 0.55rem 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.84rem;
  line-height: 1.45;
}

.facts-list--columns {
  columns: 2 260px;
}

.form-panel {
  max-width: 880px;
}

.settings-form {
  max-width: 720px;
}

.host-target-editor {
  margin-top: 2rem;
}

.host-target-editor__header {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.host-target-editor__header h2 {
  margin: 0;
}

.host-target-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.host-target-card .runtime-editor-card__header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.host-card__header,
.details-hero {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.host-card__title-row,
.step-list__header,
.run-summary {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.host-card__title-row h2,
.details-panel h2 {
  margin: 0;
}

.host-card__heartbeat {
  min-width: 170px;
  text-align: right;
}

.pacs-table-wrap {
  overflow-x: auto;
}

.pacs-table {
  width: 100%;
  border-collapse: collapse;
}

.pacs-table th,
.pacs-table td {
  padding: 0.8rem 0.55rem;
  border-bottom: 1px solid var(--pm-line);
  vertical-align: top;
}

.pacs-table th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--pm-muted);
}

.monitoring-agent-row td {
  background: rgba(39, 73, 92, 0.08);
  border-top: 2px solid rgba(39, 73, 92, 0.2);
  font-weight: 600;
}

.monitoring-pacs-row td {
  background: rgba(255, 255, 255, 0.45);
}

.monitoring-pacs-row--collapsed {
  display: none;
}

/* Кнопка раскрытия PACS: символ мелкий, но цель клика остаётся крупной. */
.dashboard-group-toggle {
  align-items: center;
  border: 1px solid var(--pm-line);
  border-radius: 999px;
  color: #1f5f51;
  background: rgba(255, 255, 255, 0.78);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 1rem;
  font-weight: 700;
  justify-content: center;
  line-height: 1;
  margin: 0;
  min-height: 32px;
  min-width: 32px;
  padding: 0;
}

.dashboard-group-toggle:hover {
  background: rgba(255, 255, 255, 0.95);
  color: #143c33;
}

.dashboard-group-toggle:focus-visible {
  outline: 2px solid #1f5f51;
  outline-offset: 2px;
}

/* На touch-разметке цель клика увеличена до рекомендованных 44 px. */
.dashboard-group-toggle--touch {
  min-height: 44px;
  min-width: 44px;
}

/* Кнопка и имя агента держатся в одной строке. */
.dashboard-agent-title {
  align-items: center;
  display: flex;
  gap: 0.5rem;
}

.table-summary {
  color: var(--pm-muted);
  margin-bottom: 0.85rem;
}

.table-row-number {
  color: var(--pm-muted);
  font-weight: 700;
  white-space: nowrap;
}

.monitoring-pacs-object {
  position: relative;
  padding-left: 1.4rem;
}

.monitoring-pacs-object::before {
  content: "↳";
  position: absolute;
  left: 0.15rem;
  color: var(--pm-muted);
}

.pacs-link {
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.metric-status,
.status-pill--ok {
  color: var(--pm-ok);
}

.status-pill--warn {
  color: var(--pm-warn);
}

.status-pill--fail {
  color: var(--pm-fail);
}

.alert-row--highlighted {
  animation: alert-row-highlight-fade 3s ease-out 1;
}

@keyframes alert-row-highlight-fade {
  from {
    background-color: rgba(190, 74, 47, 0.25);
  }
  to {
    background-color: transparent;
  }
}

.status-pill--unreachable {
  color: var(--pm-unreachable);
}

.status-pill--stale {
  color: var(--pm-stale);
}

.status-pill--ok,
.status-pill--warn,
.status-pill--fail,
.status-pill--unreachable,
.status-pill--stale {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid currentColor;
}

.step-list {
  margin: 1rem 0 0;
  padding-left: 1.25rem;
}

.step-list__item + .step-list__item {
  margin-top: 0.85rem;
}

.facts-list {
  margin: 0;
  padding-left: 1rem;
}

.run-check-button {
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.25rem;
  color: #f7f3e9;
  background: linear-gradient(135deg, #234c42, #2f7d4c);
  font-weight: 700;
  box-shadow: 0 14px 30px rgba(35, 76, 66, 0.24);
}

/* Вторичное действие карточки: та же геометрия, что и у основной кнопки,
   но контурное оформление — иначе ссылка теряется рядом с основной кнопкой. */
.secondary-button {
  align-items: center;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--pm-line);
  border-radius: 999px;
  color: #1f5f51;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  padding: 0.9rem 1.25rem;
  text-decoration: none;
  white-space: nowrap;
}

.secondary-button:hover {
  background: #ffffff;
  color: #143c33;
}

.secondary-button:focus-visible {
  outline: 2px solid #1f5f51;
  outline-offset: 2px;
}

.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  color: var(--pm-muted);
}

.hero-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.list-toolbar {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(260px, 1.8fr) minmax(180px, 1fr) auto;
  align-items: end;
  margin-bottom: 1.25rem;
}

/* Освободившееся место после удаления колонки «Карточка» отдаётся объекту,
   чтобы тип и summary читались с меньшим числом переносов. */
.alerts-entity-column {
  min-width: 260px;
  width: 26%;
}

.alerts-entity-cell {
  min-width: 260px;
}

.alerts-entity-link {
  color: #1f5f51;
  font-weight: 700;
  text-decoration: none;
}

.alerts-entity-link:hover {
  color: #143c33;
  text-decoration: underline;
}

.alerts-entity-link:focus-visible {
  outline: 2px solid #1f5f51;
  outline-offset: 2px;
}

/* Три диагностических времени в одну строку вместо трёх: снижает высоту строки списка агентов. */
.heartbeat-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
  white-space: nowrap;
}

/* Пояснение под полем поиска: объясняет находки по скрытым идентификаторам. */
.form-hint {
  color: var(--pm-muted);
  display: block;
  font-size: 0.82rem;
  margin-top: 0.3rem;
}

.filter-chips {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--pm-line);
  color: #1f5f51;
  background: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-weight: 600;
}

.filter-chip--active {
  color: #f7f3e9;
  background: linear-gradient(135deg, #234c42, #2f7d4c);
  border-color: transparent;
}

.runtime-editor__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.runtime-editor__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.runtime-editor__header h3 {
  margin: 0;
}

.runtime-editor-list {
  display: grid;
  gap: 1rem;
}

.runtime-editor-card {
  border: 1px solid var(--pm-line);
  border-radius: 16px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.7);
}

.facts-banner {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  color: var(--pm-muted);
}

.managed-group + .managed-group {
  margin-top: 1.5rem;
}

.managed-group__header {
  margin-bottom: 0.85rem;
}

.managed-group__header h2 {
  margin: 0;
}

.table-actions {
  min-width: 180px;
}

.table-bulk-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

.inline-form {
  display: inline;
}

.table-action-link {
  color: #1f5f51;
  font-weight: 600;
  text-decoration: none;
}

.table-action-link:hover {
  color: #143c33;
}

.notice {
  border-radius: 18px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
}

.notice--success {
  border-color: rgba(47, 125, 76, 0.25);
  color: #225b38;
}

.notice--error {
  border-color: rgba(190, 74, 47, 0.25);
  color: #8c3420;
}

.notice--warn {
  border-color: rgba(196, 139, 24, 0.3);
  color: #8a5f0f;
}

.mobile-card-list {
  display: none;
}

@media (max-width: 767px) {
  body {
    overflow-x: hidden;
  }

  .app-shell {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .dashboard-hero,
  .details-hero,
  .auth-panel__card {
    border-radius: 18px;
    padding: 1.15rem;
    margin-bottom: 1rem;
  }

  .dashboard-hero h1,
  .details-hero h1,
  .auth-panel__card h1 {
    font-size: 1.85rem;
    line-height: 1.08;
  }

  .host-card,
  .details-panel,
  .metric-card,
  .empty-state-panel {
    border-radius: 16px;
    padding: 1rem;
  }

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

  .list-toolbar {
    grid-template-columns: 1fr;
  }

  .filter-chips,
  .hero-actions,
  .table-bulk-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-chip,
  .run-check-button,
  .secondary-button {
    align-items: center;
    display: inline-flex;
    justify-content: center;
    min-height: 44px;
    text-align: center;
    width: 100%;
  }

  .secondary-button {
    border: 1px solid var(--pm-line);
    border-radius: 999px;
    color: #1f5f51;
    background: rgba(255, 255, 255, 0.78);
    font-weight: 700;
    padding: 0.68rem 1rem;
    text-decoration: none;
  }

  .runtime-editor__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .host-card__header,
  .details-hero {
    flex-direction: column;
  }

  .host-card__heartbeat {
    min-width: auto;
    text-align: left;
  }

  .alerts-table-desktop {
    display: none;
  }

  .dashboard-table-desktop {
    display: none;
  }

  .details-table-desktop {
    display: none;
  }

  .responsive-table-desktop {
    display: none;
  }

  .dashboard-mobile-list {
    display: grid;
    gap: 0.85rem;
  }

  .dashboard-agent-card {
    border-color: rgba(39, 73, 92, 0.2);
    background: rgba(39, 73, 92, 0.08);
  }

  .dashboard-pacs-card {
    margin-left: 0.75rem;
    position: relative;
  }

  .dashboard-pacs-card::before {
    content: "";
    position: absolute;
    left: -0.55rem;
    top: 1rem;
    bottom: 1rem;
    border-left: 2px solid var(--pm-line);
  }

  .dashboard-pacs-card--collapsed {
    display: none;
  }

  .alerts-mobile-list {
    display: grid;
    gap: 0.85rem;
  }

  .details-mobile-list {
    display: grid;
    gap: 0.85rem;
    margin-top: 0.85rem;
  }

  .list-mobile-list {
    display: grid;
    gap: 0.85rem;
  }

  .mobile-data-card {
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--pm-line);
    border-radius: 16px;
    padding: 1rem;
  }

  .mobile-data-card__header {
    align-items: flex-start;
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
  }

  .mobile-data-card__summary {
    margin-top: 0.75rem;
  }

  .mobile-data-card__meta {
    display: grid;
    gap: 0.55rem;
    grid-template-columns: minmax(0, 1fr);
    margin: 0.85rem 0 0;
  }

  .mobile-data-card__meta div {
    border-top: 1px solid var(--pm-line);
    padding-top: 0.55rem;
  }

  .mobile-data-card__meta dt {
    color: var(--pm-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  .mobile-data-card__meta dd {
    margin: 0.15rem 0 0;
    overflow-wrap: anywhere;
  }

  .mobile-data-card__actions {
    align-items: stretch;
    display: grid;
    gap: 0.55rem;
    margin-top: 1rem;
  }

  .mobile-data-card__actions .table-action-link,
  .mobile-data-card__actions .btn-link {
    min-height: 44px;
    padding: 0.65rem 0;
    text-align: center;
    width: 100%;
  }

  .mobile-data-card__select {
    align-items: center;
    color: var(--pm-muted);
    display: flex;
    gap: 0.5rem;
    min-height: 44px;
  }
}
