/* Панель сервера. Шрифт Geist (SIL OFL 1.1), лежит рядом в /fonts. */

@font-face {
  font-family: 'Geist';
  src: url('/fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('/fonts/GeistMono-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

/* ---------- Токены ---------- */

:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f4;
  --surface-3: #e9e9e9;
  --border: #e6e6e6;
  --border-strong: #d4d4d4;
  --text: #171717;
  --text-2: #4f4f4f;
  --muted: #7a7a7a;
  --primary: #171717;
  --primary-hover: #333333;
  --on-primary: #ffffff;
  --danger: #d0302f;
  --danger-hover: #b52423;
  --danger-text: #c42a2a;
  --danger-soft: #fdf2f2;
  --danger-border: #f2caca;
  --warn-text: #8a5a00;
  --warn-soft: #fff8e8;
  --warn-border: #f1d99b;
  --info-text: #2458c6;
  --info-soft: #f1f5fe;
  --info-border: #cbdaf8;
  /* Статусы: фиксированные ступени, всегда вместе с подписью. */
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --idle: #a8a8a8;
  --running: #2f6fdb;
  --focus: #2f6fdb;
  --meter: #171717;
  --log-bg: #fafafa;
  --backdrop: rgba(10, 10, 10, 0.32);
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.04), 0 10px 28px -6px rgba(0, 0, 0, 0.14);
  --shadow-dialog: 0 1px 3px rgba(0, 0, 0, 0.06), 0 28px 56px -16px rgba(0, 0, 0, 0.28);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #0a0a0a;
    --surface: #111111;
    --surface-2: #1a1a1a;
    --surface-3: #262626;
    --border: #232323;
    --border-strong: #333333;
    --text: #ededed;
    --text-2: #b3b3b3;
    --muted: #808080;
    --primary: #ededed;
    --primary-hover: #cfcfcf;
    --on-primary: #0a0a0a;
    --danger: #e5484d;
    --danger-hover: #f05a5f;
    --danger-text: #ff6b70;
    --danger-soft: #241011;
    --danger-border: #4a1c1f;
    --warn-text: #f3b93f;
    --warn-soft: #221a07;
    --warn-border: #473612;
    --info-text: #7ea6f2;
    --info-soft: #0f1829;
    --info-border: #203a66;
    --idle: #666666;
    --running: #5b8def;
    --focus: #5b8def;
    --meter: #ededed;
    --log-bg: #0a0a0a;
    --backdrop: rgba(0, 0, 0, 0.6);
    --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px -6px rgba(0, 0, 0, 0.6);
    --shadow-dialog: 0 1px 3px rgba(0, 0, 0, 0.5), 0 28px 56px -16px rgba(0, 0, 0, 0.8);
  }
}

:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #1a1a1a;
  --surface-3: #262626;
  --border: #232323;
  --border-strong: #333333;
  --text: #ededed;
  --text-2: #b3b3b3;
  --muted: #808080;
  --primary: #ededed;
  --primary-hover: #cfcfcf;
  --on-primary: #0a0a0a;
  --danger: #e5484d;
  --danger-hover: #f05a5f;
  --danger-text: #ff6b70;
  --danger-soft: #241011;
  --danger-border: #4a1c1f;
  --warn-text: #f3b93f;
  --warn-soft: #221a07;
  --warn-border: #473612;
  --info-text: #7ea6f2;
  --info-soft: #0f1829;
  --info-border: #203a66;
  --idle: #666666;
  --running: #5b8def;
  --focus: #5b8def;
  --meter: #ededed;
  --log-bg: #0a0a0a;
  --backdrop: rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px -6px rgba(0, 0, 0, 0.6);
  --shadow-dialog: 0 1px 3px rgba(0, 0, 0, 0.5), 0 28px 56px -16px rgba(0, 0, 0, 0.8);
}

/* ---------- База ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'ss01' on;
}

h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.i { width: 16px; height: 16px; flex: none; }
.i.spin { animation: spin 0.9s linear infinite; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.985); } }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes pulse { 50% { opacity: 0.35; } }

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

/* ---------- Каркас ---------- */

.shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  min-width: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--on-primary);
  flex: none;
}
.brand-mark .i { width: 17px; height: 17px; }
.brand-name { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; line-height: 1.25; }
.brand-sub { font-size: 12px; color: var(--muted); line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current='page'] { background: var(--surface-3); color: var(--text); }
.nav-item .i { color: var(--muted); }
.nav-item[aria-current='page'] .i { color: var(--text); }
.nav-count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 4px;
}
.host-facts {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
}
.host-facts strong { color: var(--text); font-weight: 500; }
.sidebar-actions { display: flex; gap: 4px; }
.sidebar-actions .btn { flex: 1; justify-content: flex-start; }

.main { min-width: 0; }
.page { max-width: 1180px; margin: 0 auto; padding: 32px 40px 72px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; }
.page-sub { margin-top: 4px; color: var(--muted); font-size: 13.5px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 40px;
  font-size: 13px;
  border-bottom: 1px solid var(--info-border);
  background: var(--info-soft);
  color: var(--info-text);
}
.banner.offline { background: var(--warn-soft); color: var(--warn-text); border-color: var(--warn-border); }

@media (max-width: 880px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  /* На телефоне: сверху строка с сервером и кнопками, под ней вкладки. */
  .sidebar {
    position: sticky;
    z-index: 20;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 10px 16px 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0; flex: 1 1 auto; }
  .brand-mark { width: 28px; height: 28px; border-radius: 7px; }
  .host-facts { display: none; }
  .sidebar-foot { order: 2; margin: 0; flex-direction: row; padding: 0; }
  .sidebar-actions .btn span { display: none; }
  .sidebar-actions .btn { width: 32px; height: 32px; padding: 0; justify-content: center; }
  .nav {
    order: 3;
    flex: 1 0 100%;
    flex-direction: row;
    gap: 4px;
    margin: 0 -16px;
    padding: 0 12px;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav-item { height: 40px; padding: 0 8px; border-radius: 0; white-space: nowrap; border-bottom: 2px solid transparent; }
  .nav-item:hover { background: none; }
  .nav-item[aria-current='page'] { background: none; border-bottom-color: var(--text); }
  .nav-count { margin-left: 2px; }
  .page { padding: 20px 16px 56px; }
  .banner { padding: 8px 16px; }
}

/* ---------- Кнопки и поля ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 500 13px/1 var(--font);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s, opacity 0.12s;
  user-select: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { background: var(--surface-3); }
.btn .i { width: 15px; height: 15px; }
.btn[disabled], .btn[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; }
.btn[disabled]:hover { background: var(--surface); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.btn-sm .i { width: 14px; height: 14px; }
.btn-icon { width: 32px; padding: 0; }
.btn-sm.btn-icon { width: 28px; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-primary[disabled]:hover { background: var(--primary); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger[disabled]:hover { background: var(--danger); }

.btn-danger-outline { color: var(--danger-text); border-color: var(--danger-border); }
.btn-danger-outline:hover { background: var(--danger-soft); }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: 400 14px var(--font);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder { color: var(--muted); }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.input.mono { font-family: var(--mono); font-size: 13.5px; }

.search { position: relative; width: 260px; max-width: 100%; }
.search .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search .input { height: 32px; padding-left: 32px; font-size: 13px; }
.search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font: 500 11px var(--mono); color: var(--muted);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; background: var(--surface-2);
}

.segmented {
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.segmented button {
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: 500 12.5px var(--font);
  cursor: pointer;
  white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed='true'] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border); }
.segmented .count { margin-left: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}
.check input {
  appearance: none;
  flex: none;
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.check input:checked { background: var(--primary); border-color: var(--primary); }
.check input:checked::after {
  content: '';
  width: 9px;
  height: 5px;
  border: 2px solid var(--on-primary);
  border-top: 0;
  border-right: 0;
  transform: translateY(-1px) rotate(-45deg);
}
.check-title { display: block; font-weight: 500; font-size: 13.5px; }
.check-sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 1px; }

/* ---------- Статус ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--idle); flex: none; }
.dot.good { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 16%, transparent); }
.dot.warn { background: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 20%, transparent); }
.dot.bad { background: var(--critical); box-shadow: 0 0 0 3px color-mix(in srgb, var(--critical) 18%, transparent); }
.dot.run { background: var(--running); box-shadow: 0 0 0 3px color-mix(in srgb, var(--running) 18%, transparent); }
.dot.pulse { animation: pulse 1.2s ease-in-out infinite; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 7px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--border-strong); color: var(--text); }

.callout {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-2);
}
.callout .i { margin-top: 2px; }
.callout strong { color: var(--text); font-weight: 600; }
.callout.warn { background: var(--warn-soft); border-color: var(--warn-border); color: var(--warn-text); }
.callout.warn strong { color: inherit; }
.callout.danger { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }
.callout.danger strong { color: inherit; }
.callout.info { background: var(--info-soft); border-color: var(--info-border); color: var(--info-text); }

/* ---------- Сводка сервера ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  margin-bottom: 32px;
}
.stat { padding: 16px 20px 18px; min-width: 0; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-value {
  margin-top: 6px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-unit { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.stat-foot { display: flex; align-items: center; gap: 5px; margin-top: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-foot.warn { color: var(--warn-text); }
.stat-foot.bad { color: var(--danger-text); }
.stat-foot .i { width: 13px; height: 13px; }

.meter { height: 4px; margin-top: 12px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; width: 0; border-radius: 2px; background: var(--meter); transition: width 0.4s ease; }
.meter.warn > span { background: var(--warning); }
.meter.bad > span { background: var(--critical); }

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--border); }
}
@media (max-width: 420px) {
  .stat { padding: 14px 14px 16px; }
  .stat-value { font-size: 20px; }
}

/* ---------- Проекты ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.section-head p { font-size: 13px; color: var(--muted); }
.section-note { margin: -4px 0 12px; font-size: 13px; color: var(--muted); max-width: 720px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 16px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.card:hover { border-color: var(--border-strong); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px -4px rgba(0, 0, 0, 0.06); }
.card.is-busy { opacity: 0.6; pointer-events: none; }
.card-main { padding: 18px 20px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.card-title::after { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.card-top .badge { margin-left: auto; }
.card-top .btn-icon { position: relative; z-index: 1; margin-right: -6px; }
.card-domain {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  align-self: flex-start;
  max-width: 100%;
  color: var(--text-2);
  font: 400 13px var(--mono);
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-domain:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.card-domain .i { width: 13px; height: 13px; color: var(--muted); }
.card-desc {
  color: var(--muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 6px 0 0;
}
.facts div { min-width: 0; }
.facts dt { font-size: 12px; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-size: 13.5px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facts dd.bad { color: var(--danger-text); }

.card-foot {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  cursor: default;
}
.card-foot .spacer { flex: 1; }
.card-note { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); }
.card-note .i { width: 14px; height: 14px; }

.orphans { margin-top: 40px; }
.list {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-width: 0;
}
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-main { min-width: 0; flex: 1; }
.list-title { font-weight: 500; font-size: 13.5px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.list-title .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-actions { display: flex; gap: 6px; flex: none; }

@media (max-width: 560px) {
  .list-row { flex-wrap: wrap; }
  .list-actions { width: 100%; }
}

/* ---------- Таблица ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  position: sticky;
  top: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}
th:first-child, td:first-child { padding-left: 16px; }
th:last-child, td:last-child { padding-right: 16px; }
th.num, td.num { text-align: right; }
th button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
th button:hover { color: var(--text); }
th[aria-sort] button { color: var(--text); }
th .i { width: 13px; height: 13px; }
th[aria-sort='ascending'] .i { transform: rotate(180deg); }
td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.p-name { font-weight: 500; white-space: nowrap; }
.p-args {
  max-width: 100%;
  margin-top: 1px;
  color: var(--muted);
  font: 12px var(--mono);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.p-unit { display: block; font: 12px var(--mono); color: var(--muted); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proc-table { min-width: 860px; }
/* max-width: 0 даёт ячейке сжиматься по ширине колонки, а длинной команде —
   обрезаться многоточием, вместо того чтобы распирать таблицу. */
.proc-table td.p-main { width: 32%; max-width: 0; }
.proc-table td.p-owner { width: 17%; max-width: 0; }
.p-mem { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar { width: 44px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--meter); border-radius: 2px; }
.lock {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--muted);
  border-radius: var(--radius-sm);
  cursor: help;
}
.lock .i { width: 14px; height: 14px; }
td.actions { text-align: right; white-space: nowrap; width: 1%; }

/* На узком экране строки таблицы процессов становятся карточками:
   кнопка «Завершить» всегда видна без прокрутки вбок. */
@media (max-width: 700px) {
  .proc-table, .proc-table tbody { display: block; min-width: 0; width: 100%; }
  .proc-table thead { display: none; }
  .proc-table tr {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }
  .proc-table tbody tr:last-child { border-bottom: 0; }
  .proc-table td {
    display: block;
    width: auto !important;
    max-width: none !important;
    padding: 0 !important;
    border: 0;
    text-align: left !important;
    font-size: 12.5px;
    background: none !important;
  }
  .proc-table td.p-main { flex: 1 0 100%; min-width: 0; padding-right: 104px !important; font-size: 13px; }
  .proc-table td.p-owner { flex: 1 0 100%; min-width: 0; margin: 4px 0 2px; }
  .proc-table td.p-owner .chip { max-width: 100%; }
  .proc-table td[data-label]::before { content: attr(data-label) ' '; color: var(--muted); }
  .proc-table td.actions { position: absolute; top: 12px; right: 16px; }
  .proc-table .bar { display: none; }
}

/* ---------- Пустые состояния ---------- */

.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 56px 24px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  text-align: center;
}
.empty .i { width: 22px; height: 22px; color: var(--muted); margin-bottom: 6px; }
.empty h3 { font-size: 14px; font-weight: 600; }
.empty p { font-size: 13px; color: var(--muted); max-width: 420px; }

.skeleton {
  height: 188px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Боковая панель проекта ---------- */

.backdrop { position: fixed; inset: 0; background: var(--backdrop); animation: fade-in 0.15s ease-out; }
.drawer-backdrop { z-index: 40; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  display: flex;
  flex-direction: column;
  width: min(620px, 100vw);
  border-left: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
  animation: slide-in 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.drawer-head { padding: 20px 24px 18px; border-bottom: 1px solid var(--border); }
.drawer-title { display: flex; align-items: center; gap: 10px; }
.drawer-title h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-title .btn-icon { margin-left: auto; margin-right: -8px; }
.drawer-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 6px; font-size: 13px; color: var(--muted); }
.drawer-meta a { display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 12.5px; color: var(--text-2); text-decoration: none; }
.drawer-meta a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.drawer-meta a .i { width: 12px; height: 12px; }
.drawer-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.drawer-body { flex: 1; overflow-y: auto; padding: 0 24px 40px; overscroll-behavior: contain; }
.drawer-body > .callout { margin-top: 20px; }

.d-section { padding: 22px 0 4px; }
.d-section + .d-section { border-top: 1px solid var(--border); margin-top: 18px; }
.d-section h3 { font-size: 13.5px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.d-section h3 .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.d-section h3 .btn { margin-left: auto; }

.unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.unit + .unit { margin-top: 8px; }
.unit-name { display: flex; align-items: center; gap: 8px; min-width: 0; font: 500 13px var(--mono); letter-spacing: -0.01em; }
.unit-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-desc { grid-column: 1; font-size: 12.5px; color: var(--muted); margin-left: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unit-meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 6px 0 0 15px; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.unit-meta .bad { color: var(--danger-text); }
.unit-actions { grid-column: 2; grid-row: 1 / span 2; display: flex; gap: 6px; }
@media (max-width: 520px) {
  .unit { grid-template-columns: minmax(0, 1fr); }
  .unit-actions { grid-column: 1; grid-row: auto; order: 1; margin: 10px 0 0 15px; flex-wrap: wrap; }
}

.kv { display: grid; grid-template-columns: 148px minmax(0, 1fr); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }
.kv dt, .kv dd { margin: 0; padding: 10px 14px; border-top: 1px solid var(--border); }
.kv dt:first-of-type, .kv dt:first-of-type + dd { border-top: 0; }
.kv dt { display: flex; align-items: flex-start; gap: 8px; color: var(--muted); }
.kv dt .i { width: 14px; height: 14px; margin-top: 2px; }
.kv dd { min-width: 0; }
.kv .row { display: flex; justify-content: space-between; gap: 12px; min-width: 0; }
.kv .row + .row { margin-top: 4px; }
.kv .row .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv .gone { color: var(--muted); text-decoration: line-through; }
@media (max-width: 520px) {
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dd { border-top: 0; padding-top: 0; }
}

.log-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.select {
  height: 28px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 14px;
  color: var(--text);
  font: 12.5px var(--mono);
  appearance: none;
  min-width: 0;
  max-width: 100%;
}
.log {
  max-height: 360px;
  overflow: auto;
  padding: 10px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--log-bg);
  font: 12px/1.65 var(--mono);
  letter-spacing: -0.01em;
}
.log-line { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 12px; padding: 0 12px; }
.log-line:hover { background: var(--surface-2); }
.log-time { color: var(--muted); white-space: nowrap; }
.log-msg { white-space: pre-wrap; word-break: break-word; }
.log-line.err .log-msg { color: var(--danger-text); }
.log-line.warn .log-msg { color: var(--warn-text); }
.log-empty { padding: 16px 12px; color: var(--muted); font-family: var(--font); font-size: 13px; }
@media (max-width: 520px) { .log-line { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 3px 12px; } }

.danger-zone {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--danger-border);
  border-radius: var(--radius);
}
.danger-zone p { font-size: 13px; color: var(--muted); margin-top: 2px; }
.danger-zone strong { font-weight: 600; font-size: 13.5px; }
.danger-zone .btn { margin-left: auto; flex: none; }
@media (max-width: 520px) { .danger-zone { flex-direction: column; align-items: stretch; } .danger-zone .btn { margin-left: 0; } }

/* ---------- Меню ---------- */

.menu {
  position: fixed;
  z-index: 50;
  min-width: 208px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: pop-in 0.12s ease-out;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.menu-item .i { width: 15px; height: 15px; color: var(--muted); }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); outline: none; }
.menu-item.danger, .menu-item.danger .i { color: var(--danger-text); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; margin: 4px 0; background: var(--border); }

/* ---------- Диалог ---------- */

.dialog-wrap {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
}
.dialog-wrap .backdrop { z-index: -1; }
.dialog {
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
  overflow: hidden;
  animation: pop-in 0.16s ease-out;
}
.dialog.wide { width: min(600px, 100%); }
.dialog-body { padding: 24px; overflow-y: auto; }
.dialog-title { font-size: 17px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.35; }
.dialog-text { margin-top: 8px; color: var(--text-2); font-size: 13.5px; }
.dialog-text + .dialog-text { margin-top: 8px; }
.dialog-body > .callout, .dialog-body > .field, .dialog-body > .check, .dialog-body > .kv, .dialog-body > .code { margin-top: 16px; }
.dialog-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.dialog-foot .left { margin-right: auto; }
@media (max-width: 480px) {
  .dialog-body { padding: 20px 16px; }
  .dialog-foot { padding: 12px 16px; flex-wrap: wrap; }
  .dialog-foot .left { width: 100%; margin: 0 0 4px; }
}

.field label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-2); }
.field label .mono { color: var(--text); font-weight: 500; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; }
.field-error { margin-top: 8px; font-size: 13px; color: var(--danger-text); }

.del-list { margin-top: 18px; }
.del-list .kv { grid-template-columns: 148px minmax(0, 1fr); }
.kv .size { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.del-list-title { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }

.code {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--log-bg);
  font: 12.5px var(--mono);
  letter-spacing: -0.01em;
}
.code code { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; }

.steps { list-style: none; margin: 18px 0 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 10px; padding: 7px 0; }
.step-icon { display: grid; place-items: center; width: 20px; height: 20px; }
.step-icon .i { width: 16px; height: 16px; }
.step-icon .ring { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--border-strong); }
.step-icon.done { color: var(--good); }
.step-icon.failed { color: var(--critical); }
.step-icon.warning { color: var(--warning); }
.step-icon.skipped, .step-icon.running { color: var(--muted); }
.step-label { font-size: 13.5px; line-height: 20px; }
.steps li.pending .step-label, .steps li.skipped .step-label { color: var(--muted); }
.step-detail { font: 12px/1.5 var(--mono); color: var(--muted); letter-spacing: -0.01em; word-break: break-word; margin-top: 1px; }
.steps li.failed .step-detail { color: var(--danger-text); }

.result { display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; padding: 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; }
.result .i { width: 18px; height: 18px; margin-top: 1px; }
.result.ok .i { color: var(--good); }
.result.fail { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger-text); }

/* ---------- Уведомления ---------- */

#toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(400px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: 13px;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}
.toast .i { margin-top: 1px; }
.toast.ok .i { color: var(--good); }
.toast.err .i { color: var(--critical); }
.toast-title { font-weight: 500; }
.toast-text { color: var(--muted); margin-top: 1px; word-break: break-word; }
.toast.leaving { opacity: 0; transform: translateY(4px); transition: opacity 0.2s, transform 0.2s; }

/* ---------- Вход ---------- */

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}
.login-card { width: min(360px, 100%); }
.login-card .brand-mark { width: 40px; height: 40px; border-radius: 10px; margin-bottom: 20px; }
.login-card .brand-mark .i { width: 20px; height: 20px; }
.login-card h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.025em; }
.login-card .page-sub { margin-bottom: 24px; }
.login-card form { display: grid; gap: 12px; }
.login-card .btn { height: 36px; font-size: 14px; }
.login-foot { margin-top: 32px; font-size: 12.5px; color: var(--muted); }

/* ---------- Журнал ---------- */

.audit-action { font-weight: 500; }
.audit-target { font: 12.5px var(--mono); color: var(--text-2); letter-spacing: -0.01em; }
.audit-detail { font-size: 12.5px; color: var(--muted); max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Мелочи ---------- */

.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.break-all { word-break: break-all; }
.text-danger { color: var(--danger-text); }
