:root {
  --bg: #070b17;
  --bg-soft: #0f1a37;
  --card: rgba(16, 24, 47, 0.82);
  --card-2: rgba(21, 31, 58, 0.9);
  --line: rgba(121, 149, 235, 0.25);
  --text: #e9efff;
  --muted: #9eb1e6;
  --accent: #6ed4ff;
  --accent-2: #8b7cff;
  --accent-3: #3df2b8;
  --hot: #ff7ad9;
  --good: #45d483;
  --warn: #ffd166;
  --bad: #ff6b7a;
  --glow-cyan: 0 0 22px rgba(110, 212, 255, 0.34);
  --glow-green: 0 0 24px rgba(61, 242, 184, 0.26);
  --speed: 180ms;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 18%, rgba(27, 74, 112, 0.85) 0%, transparent 34%),
    radial-gradient(circle at 78% 6%, rgba(76, 45, 120, 0.7) 0%, transparent 28%),
    linear-gradient(135deg, #050811 0%, #08101f 44%, #06120f 100%);
  color: var(--text);
  font: 15px/1.5 "Inter", "Segoe UI", Arial, sans-serif;
  overflow-x: hidden;
}

.bg-overlay {
  position: fixed;
  inset: -25vmax;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(40vmax 40vmax at 15% 25%, rgba(110, 212, 255, 0.2), transparent 60%),
    radial-gradient(45vmax 45vmax at 90% 10%, rgba(255, 122, 217, 0.16), transparent 64%),
    radial-gradient(35vmax 35vmax at 60% 90%, rgba(61, 242, 184, 0.16), transparent 60%);
  filter: blur(14px) saturate(120%);
  animation: pulseGlow 14s ease-in-out infinite alternate;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(130, 150, 220, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(130, 150, 220, 0.08) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at 50% 25%, black 35%, transparent 100%);
  animation: gridDrift 24s linear infinite;
}

.panel-shell {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  letter-spacing: 0;
  color: #f5f9ff;
  text-shadow: 0 0 28px rgba(110, 212, 255, 0.34), 0 0 52px rgba(61, 242, 184, 0.16);
}
.hero p {
  margin: 0;
  color: var(--muted);
  animation: softTextPulse 3.6s ease-in-out infinite;
}

.auth-card {
  min-width: 240px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.auth-card img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  box-shadow: var(--glow-cyan);
}
.auth-card strong,
.auth-card span {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-card span { color: var(--muted); font-size: 0.86rem; }

.login-btn,
button {
  appearance: none;
  border: 1px solid rgba(110, 212, 255, 0.45);
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, rgba(110, 212, 255, 0.14), rgba(61, 242, 184, 0.08));
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 8px 22px rgba(0, 0, 0, 0.22);
  transition: transform var(--speed) ease, border-color var(--speed) ease, box-shadow var(--speed) ease, color var(--speed) ease;
}
button { padding: 7px 10px; }
.login-btn::before,
button::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.16) 45%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 520ms ease;
}
.login-btn:hover,
button:hover {
  transform: translateY(-1px);
  border-color: rgba(61, 242, 184, 0.65);
  box-shadow: var(--glow-cyan), 0 12px 28px rgba(0, 0, 0, 0.32);
}
.login-btn:hover::before,
button:hover::before { transform: translateX(120%); }
.login-btn:active,
button:active { transform: translateY(0) scale(0.99); }
.login-btn:focus-visible,
button:focus-visible,
textarea:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(61, 242, 184, 0.68);
  outline-offset: 2px;
}

.page-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.page-tabs button {
  min-height: 38px;
  border-color: rgba(121, 149, 235, 0.28);
  background: rgba(16, 24, 47, 0.72);
  color: var(--muted);
}
.page-tabs button.active {
  border-color: rgba(110, 212, 255, 0.7);
  background: linear-gradient(135deg, rgba(110, 212, 255, 0.2), rgba(61, 242, 184, 0.12));
  color: var(--text);
  box-shadow: var(--glow-cyan);
  animation: activeTabGlow 2.6s ease-in-out infinite;
}
.page { display: none; }
.page.active {
  display: block;
  animation: pageIn 260ms ease-out;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.metric,
.card {
  position: relative;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(8px);
  transition: transform var(--speed) ease, border-color var(--speed) ease, box-shadow var(--speed) ease;
}
.metric::before,
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(90deg, transparent, rgba(110, 212, 255, 0.2), rgba(61, 242, 184, 0.18), transparent);
  opacity: 0;
  transform: translateX(-35%);
  transition: opacity var(--speed) ease;
}
.metric:hover,
.card:hover {
  transform: translateY(-2px);
  border-color: rgba(110, 212, 255, 0.5);
  box-shadow: var(--glow-cyan), 0 18px 46px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.09);
}
.metric:hover::before,
.card:hover::before {
  opacity: 1;
  animation: borderSweep 1.35s ease-out;
}
.metric {
  min-height: 78px;
  padding: 13px;
}
.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}
.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1.15rem;
  overflow-wrap: anywhere;
  color: #f8fbff;
  text-shadow: 0 0 18px rgba(110, 212, 255, 0.22);
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}
.grid.two { grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr); }
.card { padding: 16px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
h2 { margin: 0; font-size: 1.05rem; }
.pill {
  flex: none;
  border: 1px solid var(--line);
  background: rgba(139, 124, 255, 0.13);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: inset 0 0 14px rgba(110, 212, 255, 0.08);
  animation: pillGlow 3.8s ease-in-out infinite;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(138, 161, 234, 0.18);
  text-align: left;
  vertical-align: top;
}
th { color: var(--accent); font-weight: 600; }
tr td { transition: background var(--speed) ease, color var(--speed) ease; }
tr:hover td {
  background: rgba(110, 212, 255, 0.08);
  color: #f7fbff;
}

.clean-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}
.clean-list li,
.role-row,
.node,
.command {
  position: relative;
  background: var(--card-2);
  border: 1px solid rgba(121, 149, 235, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  transition: transform var(--speed) ease, border-color var(--speed) ease, box-shadow var(--speed) ease, background var(--speed) ease;
}
.clean-list li:hover,
.role-row:hover,
.node:hover,
.command:hover,
.matrix-row:hover,
.id-config label:hover {
  transform: translateY(-1px);
  border-color: rgba(61, 242, 184, 0.42);
  background: rgba(22, 38, 66, 0.95);
  box-shadow: var(--glow-green);
}
.clean-list span,
.role-row span,
.node span,
.command span {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.muted { color: var(--muted); opacity: 0.85; }

.server-list,
.role-list {
  display: grid;
  gap: 10px;
}
.node {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.node b { color: var(--warn); }
.node.online b { color: var(--good); }
.node.offline b,
.node.error b { color: var(--bad); }

.command-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  max-height: 440px;
  overflow: auto;
  padding-right: 4px;
}
.command strong {
  display: block;
  color: var(--accent);
  margin-bottom: 3px;
  text-shadow: 0 0 16px rgba(110, 212, 255, 0.25);
}

.setup-grid {
  display: grid;
  gap: 14px;
}
.setup-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.id-config {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.id-config label {
  display: grid;
  gap: 6px;
  background: var(--card-2);
  border: 1px solid rgba(121, 149, 235, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  transition: transform var(--speed) ease, border-color var(--speed) ease, box-shadow var(--speed) ease, background var(--speed) ease;
}
.id-config span {
  color: var(--accent);
  font-weight: 600;
}
.id-config textarea {
  width: 100%;
  min-height: 68px;
  resize: vertical;
  border: 1px solid rgba(110, 212, 255, 0.35);
  border-radius: 8px;
  background: rgba(7, 13, 29, 0.88);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease, background var(--speed) ease;
}
.id-config textarea:focus {
  border-color: rgba(61, 242, 184, 0.72);
  background: rgba(8, 18, 35, 0.98);
  box-shadow: inset 0 0 18px rgba(110, 212, 255, 0.08), var(--glow-green);
}
.matrix {
  display: grid;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}
.matrix-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 12px;
  align-items: center;
  background: var(--card-2);
  border: 1px solid rgba(121, 149, 235, 0.18);
  border-radius: 8px;
  padding: 10px 12px;
  transition: transform var(--speed) ease, border-color var(--speed) ease, box-shadow var(--speed) ease, background var(--speed) ease;
}
.matrix-row b,
.matrix-row small {
  display: block;
}
.matrix-row b { color: var(--accent); }
.matrix-row small {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.visibility-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.visibility-options label {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(121, 149, 235, 0.18);
  border-radius: 8px;
  padding: 6px 8px;
  background: rgba(16, 24, 47, 0.55);
  cursor: pointer;
  transition: border-color var(--speed) ease, background var(--speed) ease, box-shadow var(--speed) ease;
}
.visibility-options input {
  accent-color: var(--accent-3);
  flex: none;
  width: 16px;
  height: 16px;
}
.visibility-options label:has(input:checked) {
  border-color: rgba(61, 242, 184, 0.54);
  background: rgba(61, 242, 184, 0.13);
  box-shadow: inset 0 0 16px rgba(61, 242, 184, 0.08);
}
.visibility-options span {
  color: var(--text);
  font-size: 0.86rem;
}
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(110, 212, 255, 0.35);
  border-radius: 8px;
  background: rgba(7, 13, 29, 0.92);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  transition: border-color var(--speed) ease, box-shadow var(--speed) ease, background var(--speed) ease;
}
select:focus {
  border-color: rgba(61, 242, 184, 0.72);
  box-shadow: var(--glow-green);
}

@keyframes pulseGlow {
  0% { transform: translate3d(-2%, -1%, 0) scale(1); }
  100% { transform: translate3d(2%, 1%, 0) scale(1.04); }
}

@keyframes gridDrift {
  0% { background-position: 0 0, 0 0; }
  100% { background-position: 32px 64px, 64px 32px; }
}

@keyframes softTextPulse {
  0%, 100% { opacity: 0.78; text-shadow: none; }
  50% { opacity: 1; text-shadow: 0 0 18px rgba(110, 212, 255, 0.3); }
}

@keyframes activeTabGlow {
  0%, 100% { box-shadow: 0 0 18px rgba(110, 212, 255, 0.22); }
  50% { box-shadow: 0 0 30px rgba(61, 242, 184, 0.32); }
}

@keyframes pillGlow {
  0%, 100% { border-color: rgba(121, 149, 235, 0.25); }
  50% { border-color: rgba(110, 212, 255, 0.56); }
}

@keyframes borderSweep {
  0% { transform: translateX(-75%); }
  100% { transform: translateX(75%); }
}

@keyframes pageIn {
  0% { opacity: 0; transform: translateY(8px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 1040px) {
  .summary-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid.two { grid-template-columns: 1fr; }
  .command-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .panel-shell { padding: 16px; }
  .hero { flex-direction: column; }
  .auth-card { width: 100%; justify-content: flex-start; }
  .summary-grid,
  .command-grid { grid-template-columns: 1fr; }
  .node { grid-template-columns: 1fr; }
  .matrix-row { grid-template-columns: 1fr; }
  .id-config,
  .visibility-options { grid-template-columns: 1fr; }
}
