/* homelab-dashboard — оформление в духе pface.ru: тёмный фон,
   сине-фиолетовые акценты, мягкие свечения и сетка. */

:root {
  --bg: #070a14;
  --bg-2: #0a0f1d;
  --card: #0f172a;
  --card-2: #131f38;
  --border: rgba(148, 163, 184, 0.13);
  --border-strong: rgba(192, 132, 252, 0.38);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --purple: #c084fc;
  --pink: #f472b6;
  --cyan: #22d3ee;
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #f87171;
  --grad: linear-gradient(120deg, #c084fc 0%, #f472b6 100%);
  --glow-purple: rgba(192, 132, 252, 0.35);
  --glow-pink: rgba(244, 114, 182, 0.30);
  --radius: 20px;
  --wrap: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(192, 132, 252, 0.20), transparent 62%),
    radial-gradient(780px 460px at 88% 4%, rgba(244, 114, 182, 0.16), transparent 60%),
    radial-gradient(700px 500px at 50% 108%, rgba(34, 211, 238, 0.10), transparent 65%),
    var(--bg);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 78%);
  mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 78%);
}

a { color: var(--purple); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── шапка ─────────────────────────────────────────────────────────── */

.header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(7, 10, 20, 0.72);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--text);
  font-size: 16px;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--grad);
  box-shadow: 0 6px 22px -8px var(--glow-purple);
  display: grid;
  place-items: center;
  color: #0b1020;
  font-size: 15px;
  font-weight: 900;
}
.brand small {
  display: block;
  color: var(--muted-2);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(192, 132, 252, 0.10);
  color: #e9d5ff;
  font-size: 13px;
  font-weight: 600;
}

.logout-form { margin: 0; }

/* ── кнопки ────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-sm { padding: 8px 15px; font-size: 13px; border-radius: 10px; }

.btn-primary {
  background: var(--grad);
  color: #0b1020;
  box-shadow: 0 10px 30px -14px var(--glow-purple), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.btn-primary:hover { box-shadow: 0 14px 40px -12px var(--glow-pink); }

.btn-ghost {
  background: rgba(192, 132, 252, 0.07);
  border-color: rgba(192, 132, 252, 0.34);
  color: #e9d5ff;
}
.btn-ghost:hover {
  background: rgba(192, 132, 252, 0.14);
  border-color: rgba(192, 132, 252, 0.6);
}

/* ── герой ─────────────────────────────────────────────────────────── */

.hero { padding: 54px 0 26px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 7px 15px 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(192, 132, 252, 0.32);
  background: rgba(192, 132, 252, 0.08);
  color: #e9d5ff;
  font-size: 13px;
  font-weight: 600;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
  animation: pulse 2.4s ease-in-out infinite;
}
.dot.off { background: var(--red); box-shadow: 0 0 10px var(--red); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 10px rgba(74, 222, 128, 0.9); }
  50% { opacity: 0.55; box-shadow: 0 0 18px rgba(74, 222, 128, 0.55); }
}

.hero h1 {
  margin: 18px 0 8px;
  font-size: clamp(30px, 4.6vw, 48px);
  font-weight: 800;
  line-height: 1.1;
  background: linear-gradient(115deg, #f5f3ff 0%, #e9d5ff 30%, #c084fc 58%, #f472b6 82%, #22d3ee 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  max-width: 720px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 14px;
  color: var(--muted-2);
  font-size: 13px;
}

/* ── поиск ─────────────────────────────────────────────────────────── */

.search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 2px;
  max-width: 560px;
  padding: 6px 6px 6px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(150deg, rgba(19, 31, 56, 0.9), rgba(10, 15, 29, 0.9));
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-wrap { position: relative; max-width: none; width: 100%; }
.search-wrap .search { max-width: none; }
.search:focus-within {
  border-color: rgba(192, 132, 252, 0.55);
  box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.14), 0 18px 44px -30px var(--glow-purple);
}

.search-icon {
  flex: 0 0 auto;
  color: var(--muted-2);
  transition: color 0.2s ease;
}
.search:focus-within .search-icon { color: var(--purple); }

.search input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 0;
  border: 0;
  outline: none;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  appearance: none;
  -webkit-appearance: none;
}
.search input::placeholder { color: var(--muted-2); }
.search input::-webkit-search-cancel-button { filter: invert(0.6); cursor: pointer; }

.search button {
  flex: 0 0 auto;
  padding: 9px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--grad);
  color: #0b1020;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.search button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px -12px var(--glow-pink);
}
.search button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.suggest {
  position: absolute;
  top: calc(100% - 2px);
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: 14px;
  border: 1px solid rgba(192, 132, 252, 0.28);
  background: rgba(15, 23, 42, 0.98);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(7, 10, 20, 0.6);
  max-height: 320px;
  overflow-y: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.suggest[hidden] { display: none; }

.suggest li {
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 14.5px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggest li:hover,
.suggest li.active { background: rgba(192, 132, 252, 0.16); }

/* ── карточки статистики ───────────────────────────────────────────── */

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 26px 0 8px;
}

.stat {
  position: relative;
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(160deg, rgba(19, 31, 56, 0.85), rgba(15, 23, 42, 0.9));
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(192, 132, 252, 0.5), transparent);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stat-value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.stat-value small {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0;
}
.stat-sub { margin-top: 4px; color: var(--muted-2); font-size: 12.5px; }

.bar {
  margin-top: 12px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--grad);
  box-shadow: 0 0 12px var(--glow-purple);
  transition: width 0.5s ease;
}
.bar-fill.warm { background: linear-gradient(90deg, #fbbf24, #f97316); box-shadow: 0 0 12px rgba(251, 191, 36, 0.35); }
.bar-fill.hot { background: linear-gradient(90deg, #f87171, #ef4444); box-shadow: 0 0 12px rgba(248, 113, 113, 0.35); }

/* ── секции ────────────────────────────────────────────────────────── */

.section { margin: 40px 0 0; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.section-head .count {
  color: var(--muted-2);
  font-size: 13px;
}
.section-head .hint {
  margin-left: auto;
  color: var(--muted-2);
  font-size: 12.5px;
}

/* ── приложения ────────────────────────────────────────────────────── */

.apps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.app {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(165deg, rgba(19, 31, 56, 0.78), rgba(15, 23, 42, 0.92));
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.app:hover {
  border-color: rgba(192, 132, 252, 0.34);
  transform: translateY(-2px);
  box-shadow: 0 18px 44px -28px var(--glow-purple);
}

.app-top { display: flex; align-items: center; gap: 12px; min-width: 0; }

.app-icon {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 17px;
  color: #0b1020;
  background: linear-gradient(140deg, #c084fc, #f472b6);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}
.app-icon.t2 { background: linear-gradient(140deg, #22d3ee, #818cf8); }
.app-icon.t3 { background: linear-gradient(140deg, #4ade80, #22d3ee); }
.app-icon.t4 { background: linear-gradient(140deg, #fbbf24, #f472b6); }

.app-name {
  min-width: 0;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-sub {
  color: var(--muted-2);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.pill.running { color: #86efac; background: rgba(74, 222, 128, 0.10); border-color: rgba(74, 222, 128, 0.32); }
.pill.stopped { color: #fca5a5; background: rgba(248, 113, 113, 0.10); border-color: rgba(248, 113, 113, 0.32); }
.pill.other { color: #fcd34d; background: rgba(251, 191, 36, 0.10); border-color: rgba(251, 191, 36, 0.32); }

.app-links { display: flex; flex-wrap: wrap; gap: 8px; }
.app-link {
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #c7d2fe;
  background: rgba(129, 140, 248, 0.10);
  border: 1px solid rgba(129, 140, 248, 0.28);
}
.app-link:hover { text-decoration: none; background: rgba(129, 140, 248, 0.18); }
.app-link.local {
  color: var(--muted);
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.24);
}
.app-link.local:hover { background: rgba(148, 163, 184, 0.16); }

/* без входа раздел служб контейнера не показываем вообще */
body.guest #services-section { display: none; }

.app-actions {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.act {
  flex: 1;
  padding: 8px 6px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(148, 163, 184, 0.06);
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
}
.act:hover:not(:disabled) { color: var(--text); border-color: rgba(192, 132, 252, 0.42); background: rgba(192, 132, 252, 0.12); }
.act:disabled { opacity: 0.35; cursor: not-allowed; }
.act.start:hover:not(:disabled) { color: #86efac; border-color: rgba(74, 222, 128, 0.45); background: rgba(74, 222, 128, 0.10); }
.act.stop:hover:not(:disabled) { color: #fca5a5; border-color: rgba(248, 113, 113, 0.45); background: rgba(248, 113, 113, 0.10); }

/* ── пулы ──────────────────────────────────────────────────────────── */

.pools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.pool {
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.72);
}
.pool-head { display: flex; align-items: center; gap: 10px; }
.pool-name { font-weight: 700; font-size: 15px; }
.pool-note { margin-left: auto; color: var(--muted-2); font-size: 12px; }
.pool-meta { margin-top: 6px; color: var(--muted); font-size: 12.5px; }

/* ── таблица служб ─────────────────────────────────────────────────── */

.table-wrap {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.72);
}

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  padding: 11px 16px;
  color: var(--muted-2);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(10, 15, 29, 0.7);
  border-bottom: 1px solid var(--border);
}
td { padding: 11px 16px; border-bottom: 1px solid rgba(148, 163, 184, 0.07); }
tr:last-child td { border-bottom: none; }
td.num { color: var(--muted); font-variant-numeric: tabular-nums; }
td .unit { color: var(--muted-2); font-size: 12px; }

/* ── подвал ────────────────────────────────────────────────────────── */

.footer {
  margin: 46px 0 34px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted-2);
  font-size: 12.5px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

/* ── уведомления ───────────────────────────────────────────────────── */

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: 360px;
  padding: 13px 18px;
  border-radius: 12px;
  border: 1px solid rgba(192, 132, 252, 0.42);
  background: rgba(19, 31, 56, 0.96);
  color: var(--text);
  font-size: 13.5px;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.8);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.err { border-color: rgba(248, 113, 113, 0.55); }

/* ── страница входа ────────────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 34px 32px 30px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: linear-gradient(170deg, rgba(19, 31, 56, 0.92), rgba(10, 15, 29, 0.96));
  box-shadow: 0 40px 100px -50px rgba(192, 132, 252, 0.5);
}
.login-card .brand { margin-bottom: 22px; }
.login-card h1 { margin: 0 0 6px; font-size: 23px; font-weight: 800; }
.login-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid rgba(148, 163, 184, 0.20);
  background: rgba(7, 10, 20, 0.7);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.field input:focus {
  outline: none;
  border-color: rgba(192, 132, 252, 0.62);
  box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.16);
}
.field .hint { margin-top: 6px; color: var(--muted-2); font-size: 12px; }
.field input.code { letter-spacing: 0.32em; font-variant-numeric: tabular-nums; }

.login-card .btn { width: 100%; margin-top: 8px; }

.form-error {
  margin: 0 0 16px;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.42);
  background: rgba(248, 113, 113, 0.10);
  color: #fca5a5;
  font-size: 13px;
}

.login-foot { margin-top: 18px; color: var(--muted-2); font-size: 12px; text-align: center; }

/* ── адаптивность ──────────────────────────────────────────────────── */

@media (max-width: 980px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .apps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .header-inner { height: 60px; }
  .brand small { display: none; }
  .stats { grid-template-columns: 1fr; }
  .apps { grid-template-columns: 1fr; }
  .pools { grid-template-columns: 1fr; }
  .hero { padding-top: 34px; }
  .section { margin-top: 30px; }
  .toast { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}

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