/* ============================================================
   Proxy Panel — design system
   Light/Dark theme · icon sidebar · cards · tables · forms
   ============================================================ */

:root {
  --bg-main: #f4f6fb;
  --bg-panel: #ffffff;
  --bg-soft: #f7f9fd;
  --bg-hover: #eef2f9;
  --bg-inset: #f1f4fa;

  --border: #e2e8f2;
  --border-strong: #cdd7e8;

  --text: #0f1b2d;
  --text-soft: #475569;
  --text-muted: #7b8aa3;

  --accent: #2f6bff;
  --accent-hover: #2057e6;
  --accent-soft: #e8f0ff;
  --accent-rgb: 47, 107, 255;

  --green: #16a34a;
  --green-soft: rgba(22, 163, 74, 0.12);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.14);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.12);
  --slate-soft: rgba(100, 116, 139, 0.14);
  --slate: #64748b;

  --sidebar-bg: #0e1f3a;
  --sidebar-w: 84px;

  --radius-sm: 7px;
  --radius: 11px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 27, 45, 0.06);
  --shadow: 0 6px 20px rgba(15, 27, 45, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 27, 45, 0.14);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Fira Code", Menlo, monospace;

  --t-fast: 140ms ease;
}

[data-theme="dark"] {
  --bg-main: #0c1424;
  --bg-panel: #111c31;
  --bg-soft: #14223b;
  --bg-hover: #1a2a47;
  --bg-inset: #0f1c33;

  --border: #25395d;
  --border-strong: #2f456c;

  --text: #e6edf8;
  --text-soft: #aab8d0;
  --text-muted: #7d8eac;

  --accent: #5b8bff;
  --accent-hover: #74a0ff;
  --accent-soft: #1a2c50;
  --accent-rgb: 91, 139, 255;

  --green-soft: rgba(34, 197, 94, 0.16);
  --amber-soft: rgba(245, 158, 11, 0.16);
  --red-soft: rgba(248, 113, 113, 0.16);
  --slate-soft: rgba(148, 163, 184, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 26px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 18px 46px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-main);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--accent-hover); }

code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 6px;
  color: var(--text-soft);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); background-clip: padding-box; }

/* ---------------- Layout ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 130;
  transition: transform 0.22s ease;
}

.sidebar-head {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}
.sidebar-logo {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #6f9bff);
  color: #fff;
  box-shadow: 0 6px 18px rgba(var(--accent-rgb), 0.45);
  transition: transform var(--t-fast);
}
.sidebar-logo:hover { transform: scale(1.06); }

.sidebar-nav {
  flex: 1;
  min-height: 0;
  padding: 4px 0 8px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  /* Firefox: тонкий скролл, проявляется при наведении на сайдбар */
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  transition: scrollbar-color 0.2s ease;
}
.sidebar:hover .sidebar-nav { scrollbar-color: rgba(148, 166, 197, 0.35) transparent; }
/* WebKit: узкий «плавающий» ползунок в цветах сайдбара */
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; margin: 6px 0; }
.sidebar-nav::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 999px;
  border: 0;
}
.sidebar:hover .sidebar-nav::-webkit-scrollbar-thumb { background: rgba(148, 166, 197, 0.28); }
.sidebar-nav::-webkit-scrollbar-thumb:hover,
.sidebar-nav::-webkit-scrollbar-thumb:active { background: rgba(var(--accent-rgb), 0.75) !important; }
/* Мягкие затухания сверху/снизу, когда есть что прокрутить (классы ставит app.js) */
.sidebar-nav.fade-top { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px); mask-image: linear-gradient(to bottom, transparent 0, #000 28px); }
.sidebar-nav.fade-bottom { -webkit-mask-image: linear-gradient(to top, transparent 0, #000 28px); mask-image: linear-gradient(to top, transparent 0, #000 28px); }
.sidebar-nav.fade-top.fade-bottom {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%);
}

.nav-section + .nav-section { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.nav-section-title {
  padding: 3px 4px 2px;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 166, 197, 0.55);
  user-select: none;
}

.nav-link {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 1px 8px;
  padding: 6px 4px 5px;
  border-radius: 11px;
  color: #94a6c5;
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-link svg { width: 20px; height: 20px; flex-shrink: 0; transition: transform var(--t-fast); }
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-link:hover svg { transform: translateY(-1px); }
.nav-link:focus-visible { outline: 2px solid rgba(var(--accent-rgb), 0.8); outline-offset: -2px; }
.nav-link.active { background: rgba(var(--accent-rgb), 0.22); color: #fff; }
.nav-link.active::before {
  content: "";
  position: absolute;
  left: -8px; top: 9px; bottom: 9px;
  width: 3px; border-radius: 0 4px 4px 0;
  background: #6f9bff;
}
.nav-sep { height: 1px; margin: 8px 16px; background: rgba(255, 255, 255, 0.08); }

/* Низкие экраны: ещё компактнее, без подписей разделов */
@media (max-height: 820px) {
  .nav-section-title { display: none; }
  .nav-link { padding: 5px 4px 4px; gap: 1px; }
  .nav-link svg { width: 19px; height: 19px; }
}

.sidebar-foot { padding: 8px; border-top: 1px solid rgba(255, 255, 255, 0.07); flex-shrink: 0; }
.theme-btn {
  width: 100%;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 8px 4px;
  border: none; cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  color: #94a6c5;
  border-radius: 12px;
  font-size: 11px; font-weight: 500;
  transition: background var(--t-fast), color var(--t-fast);
}
.theme-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.theme-btn svg { width: 19px; height: 19px; }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: block; }

/* main column */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky; top: 0; z-index: 90;
  display: flex; align-items: center; gap: 14px;
  height: 64px;
  padding: 0 26px;
  background: color-mix(in srgb, var(--bg-panel) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-spacer { flex: 1; }
.btn.menu-btn { display: none; }  /* .btn ниже в файле задаёт inline-flex — нужна большая специфичность */

.content { padding: 26px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* ---------------- Page header ---------------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }
.page-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--bg-soft);
  color: var(--text);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3); }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }

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

.btn-danger { background: transparent; border-color: var(--border-strong); color: var(--red); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }

.btn-success { background: transparent; border-color: var(--border-strong); color: var(--green); }
.btn-success:hover { background: var(--green-soft); border-color: var(--green); color: var(--green); }

.btn-solid-danger { background: var(--red); color: #fff; }
.btn-solid-danger:hover { background: #b91c1c; color: #fff; }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-icon { padding: 7px; }
.btn-icon.btn-sm { width: 30px; padding: 0; justify-content: center; }
.btn-sm svg { width: 15px; height: 15px; }
.btn-icon svg { width: 15px; height: 15px; }

/* Подсказки data-tip — одно плавающее окошко (app.js), а не ::after у кнопки:
   псевдоэлемент у крайних строк/колонок вылезал за таблицу и давал прокрутку. */
.tip-float {
  position: fixed; z-index: 500;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg-panel);
  font-size: 11px; font-weight: 500; line-height: 1.2; letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transition: opacity .12s ease;
}
.tip-float.is-on { opacity: 1; }

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

/* ---------------- Cards ---------------- */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }
.card-pad { padding: 20px; }

/* stat grid */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  display: flex; align-items: center; gap: 15px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
}
a.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--border-strong); color: var(--text); }
.stat-icon {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 13px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.stat-icon svg { width: 23px; height: 23px; }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-icon.red { background: var(--red-soft); color: var(--red); }
.stat-meta { min-width: 0; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.stat-label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* ---------------- Tables ---------------- */
.table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.table-wrap .table-scroll { overflow-x: auto; overflow-y: hidden; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.data thead th {
  text-align: left;
  padding: 11px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data tbody td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: none; }
/* Без transition: на тысячах строк анимация hover заметно тормозит прокрутку. */
table.data tbody tr:hover > td { background: var(--bg-soft); }
table.data tbody tr.is-selected > td { background: var(--accent-soft); }
table.data .col-num { width: 1%; white-space: nowrap; color: var(--text-muted); font-variant-numeric: tabular-nums; }
table.data .col-nowrap { white-space: nowrap; }
table.data td.text-mono, table.data .text-mono { font-size: 12.5px; }
table.data td.actions, table.data th.actions { text-align: right; white-space: nowrap; width: 1%; }
/* Keep actions in one line inside the cell — never flex the <td> itself (breaks row height). */
table.data td.actions .actions-inner {
  gap: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  min-height: 30px;
  vertical-align: middle;
}
table.data td.actions > .inline-form,
table.data td.actions > .btn { margin-left: 4px; vertical-align: middle; }
table.data td.actions .btn { margin-left: 0; }
table.data td.actions .btn-slot {
  display: inline-block;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
}
.cell-strong { font-weight: 600; color: var(--text); }

.domain-cell {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
  vertical-align: middle;
}
.domain-cell .domain-name {
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.domain-cell .badge.plain {
  flex-shrink: 0;
  font-size: 11px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.domain-quick {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  opacity: 0.4;
}
tr:hover .domain-quick,
.domain-quick:focus-within { opacity: 1; }

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
  font-size: 14px;
  line-height: 1;
  font-weight: 600;
}
.btn-ghost:hover {
  background: var(--bg-inset);
  border-color: transparent;
  color: var(--text);
}
.cell-sub { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.text-muted { color: var(--text-muted); }
.text-mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------------- Badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  background: var(--slate-soft); color: var(--slate);
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-error { background: var(--red-soft); color: var(--red); }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.badge-info { background: var(--accent-soft); color: var(--accent); }
.badge-muted { background: var(--slate-soft); color: var(--slate); }

/* ---------------- Forms ---------------- */
.form-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  max-width: 820px;
}
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.field { grid-column: span 12; }
.field.col-6 { grid-column: span 6; }
.field.col-4 { grid-column: span 4; }
.field.col-3 { grid-column: span 3; }
.field.col-8 { grid-column: span 8; }
@media (max-width: 680px) { .field.col-6, .field.col-4, .field.col-3, .field.col-8 { grid-column: span 12; } }

.label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit; font-size: 13.5px;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-panel);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}
.textarea { resize: vertical; min-height: 64px; }
.select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237b8aa3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
  padding-right: 34px;
}
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--text-soft); user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ---------------- Flash ---------------- */
.flash-stack { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--slate);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  animation: flash-in 0.25s ease;
}
@keyframes flash-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.flash-success { border-left-color: var(--green); }
.flash-error, .flash-danger { border-left-color: var(--red); }
.flash-warning { border-left-color: var(--amber); }
.flash-info { border-left-color: var(--accent); }
.flash-msg { flex: 1; }
.flash-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 18px; line-height: 1; padding: 0 2px; }
.flash-close:hover { color: var(--text); }

/* ---------------- Empty state ---------------- */
.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty svg { width: 52px; height: 52px; opacity: 0.5; margin-bottom: 12px; }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }
.empty p { margin: 0 0 16px; font-size: 13.5px; }

/* ---------------- Breadcrumb ---------------- */
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-size: 13.5px; margin-bottom: 16px; }
.crumbs a { color: var(--text-soft); padding: 3px 8px; border-radius: 6px; }
.crumbs a:hover { background: var(--bg-hover); color: var(--accent); }
.crumbs .sep { color: var(--text-muted); }
.crumbs .current { color: var(--text); font-weight: 600; padding: 3px 8px; }

/* ---------------- Monitor ---------------- */
.monitor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.meter-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-soft); margin-bottom: 4px; }
.meter { height: 8px; border-radius: 999px; background: var(--bg-inset); overflow: hidden; margin-bottom: 12px; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: var(--green); transition: width 0.4s ease; }
.meter > span.warn { background: var(--amber); }
.meter > span.crit { background: var(--red); }
.svc-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Per-core CPU grid (htop-style) */
.core-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px 10px;
  margin: 2px 0 12px;
}
.core-cell .core-top {
  display: flex; justify-content: space-between;
  font-size: 10.5px; color: var(--text-muted);
  font-variant-numeric: tabular-nums; margin-bottom: 2px;
}
.core-cell .meter { height: 5px; margin-bottom: 0; }

/* Top processes table (htop-style) */
.proc-list { margin: 4px 0 10px; font-size: 12px; }
.proc-row {
  display: grid; grid-template-columns: 1fr 48px 48px;
  gap: 6px; padding: 2px 0; font-variant-numeric: tabular-nums;
}
.proc-row span:not(.proc-name) { text-align: right; color: var(--text-soft); }
.proc-head { color: var(--text-muted); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--border); margin-bottom: 2px; padding-bottom: 3px; }
.proc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); }

/* ---------------- File manager ---------------- */
.fm-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.fm-toolbar .grow { flex: 1; }

.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-soft);
  transition: border-color var(--t-fast), background var(--t-fast);
  margin-bottom: 18px;
}
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone strong { color: var(--text); }
.dropzone .dz-status { margin-top: 8px; font-size: 12.5px; }

.fm-name { display: inline-flex; align-items: center; gap: 9px; min-width: 0; }
.fm-ico { width: 18px; height: 18px; flex-shrink: 0; }
.fm-ico.dir { color: var(--amber); }
.fm-ico.file { color: var(--text-muted); }
.fm-ico.arc { color: var(--accent); }
.fm-name a { color: var(--text); font-weight: 500; }
.fm-name a:hover { color: var(--accent); }
.fm-up a { color: var(--text-soft); font-weight: 500; }

/* Bulk select column + action bar */
.fm-check { width: 34px; text-align: center; }
.fm-check input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }
table.data th.fm-sort { padding: 0; }
table.data th.fm-sort a {
  display: block;
  padding: 13px 16px;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}
table.data th.fm-sort a:hover { color: var(--accent); }
.sort-arrow { color: var(--accent); font-size: 10px; }
.bulkbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--accent-soft); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.bulkbar .bulk-count { font-size: 13px; color: var(--text-soft); }
.bulkbar .bulk-count strong { color: var(--text); }
.bulkbar .bulk-origin-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-soft);
  min-width: 0;
}
.bulkbar .bulk-origin-label .select,
.bulkbar .select-sm {
  min-width: 220px;
  max-width: min(360px, 42vw);
  height: 34px;
  padding: 4px 10px;
  font-size: 13px;
}
@media (max-width: 720px) {
  .bulkbar { flex-wrap: wrap; }
  .bulkbar .bulk-origin-label { width: 100%; }
  .bulkbar .bulk-origin-label .select { max-width: none; flex: 1; }
}

/* Modal (file editor) */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(8, 15, 30, 0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px; max-height: 88vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-lg { max-width: 860px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 16px; font-weight: 700; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close {
  background: none; border: none; font-size: 26px; line-height: 1;
  color: var(--text-muted); cursor: pointer; padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 20px; overflow: auto; flex: 1; }
.modal-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}

/* Confirm modal — plain + rich bodies */
.modal-confirm { max-width: 460px; }
.modal-confirm.modal-confirm-lg { max-width: 520px; }
.confirm-plain {
  margin: 0;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-soft);
}
.confirm-rich { margin: 0; }
.confirm-rich-inner { display: flex; flex-direction: column; gap: 14px; }
.confirm-lead {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--text);
}
.confirm-lead strong { font-weight: 700; }
.confirm-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: stretch;
}
.confirm-flow-node {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-soft);
  min-width: 0;
}
.confirm-flow-node.is-source {
  border-color: color-mix(in srgb, var(--green) 35%, var(--border));
  background: var(--green-soft);
}
.confirm-flow-node.is-target {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--accent-soft);
}
.confirm-flow-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.confirm-flow-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.confirm-flow-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
}
.confirm-flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.confirm-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.confirm-points li {
  position: relative;
  padding: 8px 10px 8px 32px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-soft);
  background: var(--bg-soft);
}
.confirm-points li::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 10px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--slate-soft);
}
.confirm-points li.is-ok::before { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.confirm-points li.is-warn::before { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.confirm-points li.is-muted::before { background: var(--slate); box-shadow: 0 0 0 3px var(--slate-soft); }
.confirm-points li strong { color: var(--text); font-weight: 650; }

@media (max-width: 560px) {
  .confirm-flow { grid-template-columns: 1fr; }
  .confirm-flow-arrow { transform: rotate(90deg); padding: 2px 0; }
}
.editor-area {
  width: 100%; min-height: 48vh; resize: vertical;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  background: #0b1220; color: #d6e2f5;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; white-space: pre; tab-size: 4;
}

.fm-sr-results {
  max-height: 42vh; overflow: auto;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-soft);
}
.fm-sr-list { padding: 6px 0; }
.fm-sr-hit {
  padding: 7px 14px; border-bottom: 1px solid var(--border);
  font-size: 12.5px; line-height: 1.5;
}
.fm-sr-hit:last-child { border-bottom: none; }
.fm-sr-path { color: var(--accent); font-family: var(--mono); font-weight: 500; }
.fm-sr-path:hover { text-decoration: underline; }
.fm-sr-line { color: var(--text-muted); font-family: var(--mono); margin-right: 6px; }
.fm-sr-text {
  display: block; margin-top: 3px;
  font-family: var(--mono); font-size: 12px;
  color: var(--text-soft); white-space: pre-wrap; word-break: break-all;
}

/* ---------------- Offers ---------------- */
.offers-toolbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.search-box { position: relative; flex: 1; min-width: 220px; max-width: 460px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); pointer-events: none; }
.search-box .input { width: 100%; padding-left: 36px; }
.offer-filter { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-soft); white-space: nowrap; cursor: pointer; }
.offer-filter input { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.offer-link {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-soft);
  font-family: var(--mono);
}
#offers-table { table-layout: fixed; }
#offers-table th:nth-child(1),
#offers-table td:nth-child(1) { width: 36px; }
#offers-table th:nth-child(2),
#offers-table td:nth-child(2) { width: 28%; }
#offers-table th:nth-child(3),
#offers-table td:nth-child(3) { width: 12%; }
#offers-table th:nth-child(5),
#offers-table td:nth-child(5) { width: 88px; }
#offers-table tbody td { height: 48px; }
#offers-table .offer-url-cell { max-width: 0; } /* force ellipsis inside fixed table */
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }

/* Paste-friendly badge filter: chips + an inline text input in one box */
.badge-filter {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  flex: 1; min-width: 240px; max-width: 620px;
  padding: 6px 10px 6px 34px; position: relative;
  background: var(--bg-panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius); transition: border-color var(--t-fast);
}
.badge-filter:focus-within { border-color: var(--accent); }
.badge-filter > svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.bf-chips { display: contents; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 4px 2px 9px; font-size: 12px; font-weight: 500;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 999px; white-space: nowrap;
}
.filter-chip button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border: none; border-radius: 999px;
  background: transparent; color: inherit; font-size: 15px; line-height: 1;
  cursor: pointer; opacity: 0.7;
}
.filter-chip button:hover { opacity: 1; background: rgba(var(--accent-rgb), 0.18); }
.bf-input {
  flex: 1; min-width: 120px; border: none; outline: none; background: transparent;
  color: var(--text); font: inherit; font-size: 13.5px; padding: 3px 2px;
}
.bf-input::placeholder { color: var(--text-muted); }
.dom-offer-slot:empty { display: none; }
.dom-count { font-size: 12.5px; white-space: nowrap; margin-left: auto; }

/* ---------------- Job log ---------------- */
.log-pre {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  background: #0b1220;
  color: #d6e2f5;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 560px;
  overflow: auto;
}
.def-list { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 13.5px; }
.def-list dt { color: var(--text-muted); font-weight: 600; }
.def-list dd { margin: 0; }

/* ---------------- Sidebar mobile ---------------- */
.backdrop { position: fixed; inset: 0; background: rgba(8, 15, 30, 0.55); z-index: 120; }
.backdrop.hidden { display: none; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .btn.menu-btn { display: inline-flex; }
  .content { padding: 18px; }
}

.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.gap-actions { display: inline-flex; gap: 4px; align-items: center; }

/* ---------------- Spinner ---------------- */
.spinner {
  display: inline-block;
  width: 15px; height: 15px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 7px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.mon-loading { display: flex; align-items: center; padding: 14px 0; }

/* ---------------- Topbar job tray ---------------- */
.job-tray { position: relative; margin-left: 8px; }
.job-tray-btn { position: relative; }
.job-tray-btn.active { color: var(--accent); border-color: var(--accent); }
.job-tray-count {
  position: absolute; top: -6px; right: -6px;
  min-width: 17px; height: 17px; padding: 0 4px;
  font-size: 10.5px; font-weight: 700; line-height: 17px;
  text-align: center; color: #fff; background: var(--accent);
  border-radius: 999px;
}
.job-tray-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px; max-height: 60vh; overflow: auto;
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 8px; z-index: 130; display: none;
}
.job-tray-panel.open { display: block; }
.job-tray-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 8px 8px;
}
.job-tray-head a { font-size: 11.5px; color: var(--accent); text-transform: none; }
.job-tray-empty { padding: 18px 8px; text-align: center; color: var(--text-muted); font-size: 13px; }
.job-tray-item {
  display: block; padding: 9px 8px; border-radius: var(--radius-sm);
  text-decoration: none; color: var(--text);
}
.job-tray-item:hover { background: var(--bg-hover); }
.job-tray-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.job-tray-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-tray-pct { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.job-tray-step { font-size: 11.5px; color: var(--text-muted); margin: 2px 0 5px; }
.job-tray-item .meter { margin-bottom: 0; }

/* ---------------- Upload / job progress bar ---------------- */
.progress {
  height: 9px; border-radius: 999px; background: var(--bg-inset);
  overflow: hidden; margin: 8px 0;
}
.progress > span {
  display: block; height: 100%; width: 0;
  border-radius: 999px; background: var(--accent);
  transition: width 0.25s ease;
}
.progress.done > span { background: var(--green); }
.progress.failed > span { background: var(--red); }
.upload-item { margin: 10px 0; }
.upload-item .up-name { font-size: 12.5px; color: var(--text-soft); display: flex; justify-content: space-between; }

/* ── Analytics integration page ──────────────────────────────────────────── */
.an-sub { margin: 0 0 16px; color: var(--text-muted); font-size: 13px; }
.an-endpoints { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.an-endpoints .k { display: inline-block; min-width: 120px; color: var(--text-muted); font-weight: 600; }
.an-endpoints code { font-family: var(--mono); font-size: 12px; word-break: break-all; }
.an-note {
  margin-top: 16px; padding: 12px 14px; border-radius: 10px; font-size: 13px;
  background: rgba(var(--accent-rgb), 0.08); color: var(--text-soft);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
}
.an-bullet { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
.an-bullet li { font-size: 13.5px; color: var(--text-soft); line-height: 1.5; }
.an-empty { color: var(--text-muted); font-size: 13.5px; padding: 8px 0; }
.an-status { min-width: 11rem; }
.an-status .badge { margin: 0.15rem 0.25rem 0.15rem 0; }
.an-status .an-st-detail { display: block; margin-top: 0.2rem; font-size: 0.75rem; color: var(--slate); }

/* ── Web SSH terminal ────────────────────────────────────────────────────── */
.shell-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-right: 8px;
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shell-page {
  display: flex;
  flex-direction: column;
  gap: 10px;
  /* Fill the main content area under the topbar. */
  min-height: calc(100vh - 88px);
}
.shell-status {
  font-size: 12.5px;
  font-family: var(--mono);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  align-self: flex-start;
}
.shell-status.is-ok { color: var(--green); background: var(--green-soft); border-color: transparent; }
.shell-status.is-err { color: var(--red); background: var(--red-soft); border-color: transparent; }
.shell-status.is-connecting { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.shell-term-wrap {
  flex: 1;
  min-height: 420px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid #1e293b;
  background: #0b1220;
  box-shadow: var(--shadow);
}
.shell-term {
  height: 100%;
  min-height: 420px;
  padding: 8px 10px 12px;
}
.shell-term .xterm { height: 100%; }
.shell-term .xterm-viewport { overflow-y: auto !important; }

/* Terminal needs the full content width, not the 1320px form/table cap. */
body:has(.shell-page) .content {
  max-width: none;
  padding: 12px 16px 16px;
}
body:has(.shell-page) .shell-page {
  min-height: calc(100vh - 72px);
}

/* ── SSH server picker ───────────────────────────────────────────────────── */
.shell-pick { display: flex; flex-direction: column; gap: 22px; }
.shell-group {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.shell-group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--bg-soft), var(--bg-panel));
}
.shell-group-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.shell-group-head p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.shell-group-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.shell-group-icon svg { width: 18px; height: 18px; }
.shell-group-icon.is-origin {
  color: var(--accent);
  background: var(--accent-soft);
}
.shell-group-icon.is-proxy {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.12);
}
.shell-group-icon.is-provision {
  color: var(--green);
  background: var(--green-soft);
}
.shell-group-count {
  margin-left: auto;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-soft);
  background: var(--bg-inset);
}
.shell-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 14px;
}
.shell-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 14px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(var(--accent-rgb), 0.08), transparent 55%),
    var(--bg-panel);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}
.shell-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.shell-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.shell-card-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.shell-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}
.shell-card-ip {
  font-size: 13px;
  color: var(--text-soft);
}
.shell-card-ssh code {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  padding: 4px 7px;
  border-radius: 6px;
  background: var(--bg-inset);
  color: var(--text-soft);
}
.shell-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.shell-card-cta {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
}
.shell-card:hover .shell-card-cta { color: var(--accent-hover); }

/* ---------------- Маршрутизация (жалобы / эвакуация) ---------------- */
.rt-hosters { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 16px; }
@media (max-width: 640px) { .rt-hosters { grid-template-columns: 1fr; } .rt-proxy { flex-wrap: wrap; } }
.rt-proxy-list { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.rt-proxy { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-soft); }
.rt-proxy.is-off { opacity: .6; }
.rt-proxy-main { flex: 1; min-width: 0; }
.rt-proxy-main .cell-strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rt-proxy-stats { display: flex; gap: 12px; font-size: 12px; color: var(--text-soft); white-space: nowrap; }
.rt-proxy-stats b { color: var(--text); }
.rt-bad, .rt-bad b { color: var(--red) !important; }
.rt-alert { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 14px; border-radius: var(--radius); background: var(--red-soft); border: 1px solid rgba(220, 38, 38, .35); }
.rt-alert-info { background: var(--accent-soft); border-color: rgba(var(--accent-rgb), .35); }
.rt-sources { display: flex; flex-wrap: wrap; gap: 8px; }
.rt-source { display: flex; flex-direction: column; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); background: var(--bg-soft); min-width: 170px; transition: border-color var(--t-fast), background var(--t-fast); }
.rt-source:hover { border-color: var(--accent); color: var(--text); }
.rt-source.active { border-color: var(--accent); background: var(--accent-soft); }
.rt-source.is-down { border-color: var(--red); }
.rt-source-hoster { border-style: dashed; }
.rt-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.rt-chip { padding: 5px 10px; border-radius: 999px; background: var(--bg-panel); border: 1px solid var(--border); font-size: 12.5px; }
.rt-bulk { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.rt-row-stuck td { background: var(--red-soft); }
.rt-choice { min-width: 230px; }
.select-sm { height: 32px; font-size: 12.5px; padding-top: 0; padding-bottom: 0; }
.rt-lookup { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: opacity var(--t-fast); }
.rt-lookup.is-loading { opacity: .55; }
.rt-lookup-row { display: grid; grid-template-columns: minmax(160px, 1.1fr) 1.4fr 1.4fr 1.2fr; gap: 12px; align-items: center; padding: 9px 12px; font-size: 13px; }
.rt-lookup-row + .rt-lookup-row { border-top: 1px solid var(--border); }
.rt-lookup-domain { font-weight: 600; word-break: break-all; }
.rt-hoster-tag { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 600; }
@media (max-width: 900px) { .rt-lookup-row { grid-template-columns: 1fr; gap: 4px; } }

/* ---------------- Иконки и меню действий строки ---------------- */
svg.i { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.row-more-btn.is-open { background: var(--bg-hover); color: var(--text); }
.row-menu-float {
  position: fixed; z-index: 400;
  min-width: 220px; max-width: 320px;
  padding: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: rm-in .12s ease;
}
@keyframes rm-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.row-menu-float .rm-form { display: block; margin: 0; }
.row-menu-float .rm-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit; font-size: 13px; text-align: left;
  cursor: pointer;
  text-decoration: none;
}
.row-menu-float .rm-item:hover { background: var(--bg-hover); color: var(--text); }
.row-menu-float .rm-item svg.i { color: var(--text-muted); }
.row-menu-float .rm-item.is-danger, .row-menu-float .rm-item.is-danger svg.i { color: var(--red); }
.row-menu-float .rm-item.is-danger:hover { background: var(--red-soft); }
.row-menu-float .rm-item.is-accent, .row-menu-float .rm-item.is-accent svg.i { color: var(--accent); }
.row-menu-float .rm-sep { height: 1px; margin: 5px 4px; background: var(--border); }
.row-menu-float .rm-title { padding: 6px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }

/* Постепенная отрисовка больших таблиц */
.table-more { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--border); }
.table-more .text-muted { font-size: 12.5px; align-self: center; margin-right: 10px; }

[hidden] { display: none !important; }

/* ---------------- Дашборд ---------------- */
.tone-ok { color: var(--green); } .tone-warn { color: var(--amber); } .tone-bad { color: var(--red); } .tone-muted { color: var(--text-muted); }
.db-alerts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.db-alert { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--bg-panel); color: var(--text); font-size: 13.5px; }
a.db-alert:hover { border-color: var(--border-strong); color: var(--text); }
.db-alert-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--slate); }
.db-alert-text { flex: 1; min-width: 0; }
.db-alert-go { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
.db-alert.is-red { background: var(--red-soft); border-color: rgba(220, 38, 38, .3); } .db-alert.is-red .db-alert-dot { background: var(--red); }
.db-alert.is-amber { background: var(--amber-soft); border-color: rgba(217, 119, 6, .3); } .db-alert.is-amber .db-alert-dot { background: var(--amber); }
.db-alert.is-ok { background: var(--green-soft); border-color: rgba(22, 163, 74, .3); } .db-alert.is-ok .db-alert-dot { background: var(--green); }

.db-kpis { display: grid; grid-template-columns: 1.6fr repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 1280px) { .db-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .db-kpis { grid-template-columns: 1fr 1fr; } }
.db-kpi { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); color: var(--text); min-width: 0; }
a.db-kpi:hover { border-color: var(--border-strong); color: var(--text); }
.db-kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.db-kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.db-kpi-of { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-left: 6px; letter-spacing: 0; }
.db-kpi-sub { font-size: 12px; color: var(--text-muted); }
.db-bar { display: flex; height: 6px; border-radius: 999px; overflow: hidden; background: var(--bg-inset); margin: 4px 0 2px; }
.db-bar .up { background: var(--green); } .db-bar .stub { background: var(--amber); } .db-bar .down { background: var(--red); }

.db-card { margin-bottom: 16px; }
.db-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.db-grid > .db-card { margin-bottom: 16px; }
@media (max-width: 1100px) { .db-grid { grid-template-columns: 1fr; } }

.db-hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 4px; height: 90px; align-items: end; }
.db-hour { height: 100%; display: flex; align-items: flex-end; border-radius: 4px; background: var(--bg-inset); }
.db-hour-bar { display: block; width: 100%; border-radius: 4px; min-height: 3px; }
.tone-bg-ok { background: var(--green); } .tone-bg-warn { background: var(--amber); } .tone-bg-bad { background: var(--red); } .tone-bg-muted { background: var(--border-strong); }
.db-hours-axis { display: grid; grid-template-columns: repeat(24, 1fr); gap: 4px; margin-top: 6px; font-size: 10.5px; color: var(--text-muted); }

.db-servers { display: flex; flex-direction: column; }
.db-server { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.db-server:last-child { border-bottom: 0; }
.db-server.is-down { background: var(--red-soft); }
.db-server.is-off { opacity: .6; }
.db-server-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.db-server-head .cell-strong { color: var(--text); }
.db-ip { margin-left: auto; font-size: 12px; }
.db-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--slate); flex-shrink: 0; }
.db-dot.ok { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.db-dot.warn { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.db-dot.bad { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.db-server-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 8px; }
.db-server-stats div { display: flex; flex-direction: column; }
.db-server-stats b { font-size: 15px; font-weight: 700; }
.db-server-stats span { font-size: 11.5px; color: var(--text-muted); }
.db-ping { margin-bottom: 8px; }
.db-ping-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.db-ping-up { margin-left: auto; color: var(--text-muted); }
.db-ping-strip { display: flex; gap: 2px; margin-top: 6px; height: 14px; }
.db-ping-strip i { flex: 1; border-radius: 2px; background: var(--green); opacity: .8; max-width: 10px; }
.db-ping-strip i.bad { background: var(--red); opacity: 1; }
.db-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.db-metric { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; align-items: center; font-size: 11.5px; color: var(--text-muted); }
.db-metric .meter { grid-column: 2; }
.db-metric em { grid-column: 1 / -1; font-style: normal; font-size: 11.5px; color: var(--text-soft); }
.db-metric-error { grid-column: 1 / -1; font-size: 12px; color: var(--red); }

.db-list { display: flex; flex-direction: column; }
.db-list-row { display: grid; grid-template-columns: 10px minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.db-list-row:last-child { border-bottom: 0; }
.db-list-main { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.db-list-sub { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-list-meta { color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.monitor-dot-lite { width: 8px; height: 8px; border-radius: 50%; background: var(--slate); }
.monitor-dot-lite.ok { background: var(--green); } .monitor-dot-lite.bad { background: var(--red); }
.monitor-dot-lite.warn { background: var(--amber); } .monitor-dot-lite.info { background: var(--accent); }
.db-metric .meter { margin: 0; height: 6px; }

/* Раскрывающиеся предупреждения дашборда */
details.db-alert { display: block; padding: 0; }
details.db-alert > summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; list-style: none; }
details.db-alert > summary::-webkit-details-marker { display: none; }
details.db-alert > summary:hover .db-alert-toggle { color: var(--text); }
.db-alert-toggle { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.db-alert-toggle::after { content: " ▾"; }
details[open] .db-alert-toggle { font-size: 0; }
details[open] .db-alert-toggle::before { content: "скрыть"; font-size: 12px; }
details[open] .db-alert-toggle::after { content: " ▴"; font-size: 12px; }
a.db-alert-go:hover { color: var(--accent); }
.db-alert-list { border-top: 1px solid var(--border); background: var(--bg-panel); border-radius: 0 0 var(--radius) var(--radius); max-height: 360px; overflow: auto; }
.db-alert-item { display: grid; grid-template-columns: minmax(160px, 260px) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 7px 14px 7px 32px; font-size: 13px; border-bottom: 1px solid var(--border); }
.db-alert-item:last-child { border-bottom: 0; }
.db-alert-item:hover { background: var(--bg-soft); }
.db-alert-item-main { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-alert-item-main:hover { color: var(--accent); }
.db-alert-item-sub { color: var(--text-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.db-alert-more { display: block; padding: 8px 14px 8px 32px; font-size: 12.5px; }
@media (max-width: 700px) { .db-alert-item { grid-template-columns: 1fr auto; } .db-alert-item-sub { grid-column: 1 / -1; } }

/* ---------------- Вход ---------------- */
.auth-body { min-height: 100vh; display: flex; background:
  radial-gradient(1200px 600px at 10% -10%, rgba(var(--accent-rgb), .18), transparent 60%),
  radial-gradient(900px 500px at 110% 110%, rgba(var(--accent-rgb), .12), transparent 60%), var(--bg-main); }
.auth-wrap { margin: auto; width: 100%; max-width: 420px; padding: 24px 16px; }
.auth-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 28px 26px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-logo { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent), #6f9bff); box-shadow: 0 6px 18px rgba(var(--accent-rgb), .45); }
.auth-title { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.auth-sub { font-size: 12.5px; color: var(--text-muted); }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form .label { margin-top: 8px; }
.auth-submit { margin-top: 16px; width: 100%; justify-content: center; height: 42px; font-size: 14px; }
.auth-code { font-family: var(--mono); font-size: 22px; letter-spacing: .35em; text-align: center; height: 50px; }
.auth-note { font-size: 12.5px; color: var(--text-muted); margin: 14px 0 0; line-height: 1.5; }
.auth-msg { padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; border: 1px solid var(--border); }
.auth-msg-error, .auth-msg-danger { background: var(--red-soft); border-color: rgba(220, 38, 38, .3); color: var(--text); }
.auth-msg-warning { background: var(--amber-soft); border-color: rgba(217, 119, 6, .3); }
.auth-msg-success { background: var(--green-soft); border-color: rgba(22, 163, 74, .3); }
.auth-qr { display: flex; justify-content: center; margin: 14px 0 8px; }
.auth-qr svg { width: 200px; height: 200px; background: #fff; border-radius: 12px; padding: 6px; }
.auth-secret { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; margin-bottom: 8px; }
.auth-secret code { font-size: 13px; letter-spacing: .08em; word-break: break-all; text-align: center; }
.auth-foot { text-align: center; font-size: 11.5px; color: var(--text-muted); margin-top: 14px; }
.sidebar-user { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.theme-btn.is-active { background: rgba(var(--accent-rgb), 0.22); color: #fff; }
a.theme-btn { text-decoration: none; }
