@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #08080a;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-hover: rgba(255, 255, 255, 0.055);
  --surface-solid: #141417;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #f5f5f7;
  --text-secondary: #a3a3ab;
  --text-tertiary: #6b6b73;
  --accent: #ff6a1a;
  --accent-2: #ff8f3f;
  --accent-soft: rgba(255, 106, 26, 0.14);
  --success: #35d871;
  --danger: #ff4d4d;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.01em;
}

/* ---------- Ambient background ---------- */
body::before, body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}
body::before {
  width: 620px; height: 620px;
  top: -220px; right: -160px;
  background: radial-gradient(circle, rgba(255, 106, 26, 0.22), transparent 70%);
  animation: drift1 26s ease-in-out infinite alternate;
}
body::after {
  width: 560px; height: 560px;
  bottom: -240px; left: -180px;
  background: radial-gradient(circle, rgba(80, 110, 255, 0.14), transparent 70%);
  animation: drift2 30s ease-in-out infinite alternate;
}
@keyframes drift1 { from { transform: translate(0,0); } to { transform: translate(-40px, 40px); } }
@keyframes drift2 { from { transform: translate(0,0); } to { transform: translate(30px, -30px); } }

h1, h2, h3 { font-weight: 700; letter-spacing: -0.02em; margin: 0; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  height: 64px;
  background: rgba(8, 8, 10, 0.72);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: flex; align-items: center; gap: 0.65rem; font-weight: 700; font-size: 0.98rem; color: var(--text); }
.topbar .brand .mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, var(--accent), #c94500);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px -4px rgba(255, 106, 26, 0.55), inset 0 1px 0 rgba(255,255,255,0.25);
}
.topbar .brand .mark svg { width: 16px; height: 16px; color: #1a0800; }
.topbar .brand .name { display: flex; flex-direction: column; line-height: 1.1; }
.topbar .brand .name small { font-weight: 500; color: var(--text-tertiary); font-size: 0.7rem; letter-spacing: 0.02em; }

.topbar nav { display: flex; gap: 0.25rem; align-items: center; }
.topbar nav a {
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
}
.topbar nav a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.topbar nav a.active { color: var(--text); background: var(--surface-hover); }
.topbar .right { display: flex; align-items: center; gap: 0.9rem; margin-left: 1rem; padding-left: 1rem; border-left: 1px solid var(--border); }
.topbar .who { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--text-secondary); }
.topbar .avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(145deg, #2a2a30, #1a1a1e);
  border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: var(--text-secondary);
}
.topbar .logout-link { color: var(--text-tertiary); font-size: 0.82rem; }
.topbar .logout-link:hover { color: var(--danger); }

/* ---------- Mobile nav toggle ---------- */
.nav-toggle {
  display: none;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle svg { width: 18px; height: 18px; }
.nav-toggle .icon-close { display: none; }
.topbar.nav-open .nav-toggle .icon-open { display: none; }
.topbar.nav-open .nav-toggle .icon-close { display: block; }

/* ---------- Layout ---------- */
.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 2.6rem 1.75rem 4rem;
  width: 100%;
  position: relative;
  z-index: 1;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2rem;
  animation: fadeInUp 0.5s var(--ease) both;
}
.hero h1 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 2rem;
  background: linear-gradient(180deg, #ffffff, #b8b8c0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .sub { color: var(--text-tertiary); font-size: 0.92rem; margin-top: 0.35rem; font-weight: 500; }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.7rem 1.85rem;
  margin-bottom: 1.25rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 24px 48px -32px rgba(0,0,0,0.6);
  transition: border-color 0.25s var(--ease), transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  animation: fadeInUp 0.5s var(--ease) both;
  position: relative;
  z-index: 1;
}
.card:nth-of-type(2) { animation-delay: 0.05s; }
.card:nth-of-type(3) { animation-delay: 0.1s; }
.card:hover { border-color: var(--border-strong); }
.card h2 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.card h2 .icon { width: 17px; height: 17px; color: var(--accent-2); flex-shrink: 0; }

/* ---------- Status ---------- */
.status-row { display: flex; align-items: center; gap: 0.55rem; }
.dot { width: 8px; height: 8px; border-radius: 50%; position: relative; flex-shrink: 0; }
.dot.on { background: var(--success); }
.dot.on::after {
  content: '';
  position: absolute; inset: -6px;
  border-radius: 50%;
  border: 1px solid var(--success);
  animation: ring 1.8s var(--ease) infinite;
}
.dot.off { background: var(--danger); }
@keyframes ring {
  0% { transform: scale(0.4); opacity: 0.9; }
  100% { transform: scale(1.8); opacity: 0; }
}
.status-row .label { font-size: 0.88rem; font-weight: 600; color: var(--text-secondary); }
.status-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  font-size: 0.83rem; font-weight: 600;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.62rem 1.1rem;
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.86rem;
  cursor: pointer;
  transition: border-color 0.18s var(--ease), background 0.18s var(--ease), transform 0.12s var(--ease), box-shadow 0.18s var(--ease);
}
.btn svg { width: 15px; height: 15px; }
.btn:hover { border-color: var(--border-strong); background: var(--surface-hover); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn.primary {
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
  border-color: transparent;
  color: #200d00;
}
.btn.primary:hover { box-shadow: 0 10px 24px -10px rgba(255, 106, 26, 0.55); transform: translateY(-1px); }
.btn.danger { background: rgba(255, 77, 77, 0.1); border-color: rgba(255, 77, 77, 0.35); color: #ff8080; }
.btn.danger:hover { background: rgba(255, 77, 77, 0.16); border-color: var(--danger); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.btn-row { display: flex; gap: 0.65rem; flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; margin: 0 -0.1rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 480px; }
th, td { text-align: left; padding: 0.7rem 0.5rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-tertiary); font-weight: 600; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; }
tbody tr { transition: background 0.15s var(--ease); }
tbody tr:hover { background: var(--surface); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Forms ---------- */
form.stack { display: flex; flex-direction: column; gap: 1.1rem; max-width: 420px; }
label { font-size: 0.8rem; color: var(--text-secondary); display: block; margin-bottom: 0.4rem; font-weight: 500; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  border-radius: 9px;
  font-size: 0.92rem;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%), linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%); background-position: calc(100% - 18px) center, calc(100% - 13px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }

.checkbox-row { display: flex; align-items: center; gap: 0.55rem; }
.checkbox-row input { width: auto; accent-color: var(--accent); }

.msg {
  padding: 0.8rem 1.1rem;
  border-radius: 12px;
  margin-bottom: 1.3rem;
  font-size: 0.88rem;
  border: 1px solid;
  animation: fadeInUp 0.35s var(--ease) both;
  position: relative; z-index: 1;
}
.msg.error { background: rgba(255, 77, 77, 0.08); color: #ffb0b0; border-color: rgba(255, 77, 77, 0.28); }
.msg.ok { background: rgba(53, 216, 113, 0.08); color: #a8f5c3; border-color: rgba(53, 216, 113, 0.28); }

.login-wrap { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.login-card { width: 100%; max-width: 380px; text-align: left; }
.login-card .logo-row { display: flex; flex-direction: column; align-items: center; gap: 0.9rem; margin-bottom: 1.8rem; text-align: center; }
.login-card .logo-row .mark {
  width: 46px; height: 46px; border-radius: 13px;
  background: linear-gradient(145deg, var(--accent-2), var(--accent));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px -8px rgba(255, 106, 26, 0.5), inset 0 1px 0 rgba(255,255,255,0.25);
}
.login-card .logo-row .mark svg { width: 24px; height: 24px; color: #200d00; }
.login-card .logo-row h1 { font-family: 'Space Grotesk', sans-serif; font-size: 1.3rem; }
.login-card .logo-row .sub { color: var(--text-tertiary); font-size: 0.86rem; }

.pill { font-size: 0.72rem; padding: 0.22rem 0.6rem; border-radius: 999px; background: var(--surface-solid); color: var(--text-secondary); font-weight: 600; border: 1px solid var(--border); }
.pill.admin { background: var(--accent-soft); color: var(--accent-2); border-color: rgba(255, 106, 26, 0.3); }

.group-list { display: flex; flex-direction: column; gap: 0.55rem; }
.group-item { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 11px; transition: border-color 0.18s var(--ease); }
.group-item:hover { border-color: var(--border-strong); }
.group-item .name { font-size: 0.9rem; font-weight: 500; }

.hint { color: var(--text-tertiary); font-size: 0.86rem; line-height: 1.55; }

code {
  background: rgba(0,0,0,0.35);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
  font-family: 'Space Grotesk', monospace;
  color: var(--accent-2);
  letter-spacing: 0.02em;
}

details summary { cursor: pointer; font-weight: 600; padding: 0.5rem 0; color: var(--text-secondary); list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary:hover { color: var(--text); }
details[open] summary { color: var(--text); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat-tile { background: rgba(0,0,0,0.2); border: 1px solid var(--border); border-radius: 13px; padding: 1.1rem 1.2rem; }
.stat-tile .label { font-size: 0.72rem; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.45rem; font-weight: 600; }
.stat-tile .value { font-family: 'Space Grotesk', sans-serif; font-size: 1.7rem; font-weight: 600; color: var(--text); }
.stat-tile .value.accent { color: var(--accent-2); }
.stat-tile .value .of { color: var(--text-tertiary); font-size: 1.05rem; font-weight: 500; }

.verify-code {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(0,0,0,0.3);
  border: 1px dashed var(--border-strong);
  border-radius: 13px;
  padding: 1.1rem 1.4rem;
  margin: 1rem 0 1.2rem;
}
.verify-code code { font-size: 1.35rem; padding: 0; border: none; background: none; }
.verify-code .copy-btn { background: none; border: none; color: var(--text-tertiary); cursor: pointer; padding: 0.3rem; display: flex; }
.verify-code .copy-btn:hover { color: var(--accent-2); }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.steps li { display: flex; gap: 0.9rem; align-items: flex-start; font-size: 0.9rem; color: var(--text-secondary); line-height: 1.5; }
.steps .num {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-solid); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.76rem; font-weight: 700; color: var(--text-secondary);
}

.verified-badge { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--success); font-weight: 600; font-size: 0.92rem; }
.verified-badge svg { width: 18px; height: 18px; }

/* ---------- Server-Viewer Baum ---------- */
.tree { display: flex; flex-direction: column; gap: 0.15rem; }
.tree-channel { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem; border-radius: 7px; }
.tree-channel:hover { background: var(--surface); }
.tree-channel .ch-icon { width: 15px; height: 15px; color: var(--text-tertiary); flex-shrink: 0; }
.tree-channel .ch-name { font-size: 0.88rem; font-weight: 500; color: var(--text-secondary); }
.tree-channel .ch-count { font-size: 0.72rem; color: var(--text-tertiary); background: var(--surface-solid); padding: 0.05rem 0.45rem; border-radius: 999px; }
.tree-client { display: flex; align-items: center; gap: 0.55rem; padding: 0.35rem 0.5rem; border-radius: 7px; }
.tree-client:hover { background: var(--surface); }
.tree-client .cl-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.tree-client .cl-dot.away { background: var(--text-tertiary); }
.tree-client .cl-name { font-size: 0.86rem; color: var(--text); }
.tree-client .cl-icon { width: 13px; height: 13px; color: var(--danger); flex-shrink: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 840px) {
  .topbar { padding: 0 1.1rem; }
  .topbar .brand .name small { display: none; }
  .nav-toggle { display: flex; }
  .topbar nav {
    position: fixed;
    top: 64px; left: 0; right: 0; bottom: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.3rem;
    padding: 1.1rem;
    background: rgba(8, 8, 10, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
    overflow-y: auto;
    z-index: 15;
  }
  .topbar.nav-open nav {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
  .topbar nav a { padding: 0.85rem 1rem; font-size: 0.98rem; border-radius: 10px; }
  .topbar nav a.active { background: var(--accent-soft); color: var(--accent-2); }
  .topbar .right {
    margin: 0.6rem 0 0;
    padding: 1rem 1rem 0;
    border-left: none;
    border-top: 1px solid var(--border);
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }
  .topbar .who { padding: 0.6rem 1rem; }
  .topbar .logout-link { padding: 0.6rem 1rem; }
}

@media (max-width: 640px) {
  .wrap { padding: 1.7rem 1.15rem 3rem; }
  .hero { flex-direction: column; align-items: flex-start; gap: 0.8rem; }
  .hero h1 { font-size: 1.55rem; }
  .card { padding: 1.3rem 1.15rem; border-radius: 14px; }
  .card h2 { font-size: 0.9rem; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.7rem; }
  .stat-tile { padding: 0.85rem 0.9rem; }
  .stat-tile .value { font-size: 1.4rem; }
  .btn-row { flex-direction: column; }
  .btn-row .btn { width: 100%; justify-content: center; }
  form.stack { max-width: 100%; }
  .group-item { flex-wrap: wrap; gap: 0.6rem; }
  .verify-code { flex-direction: column; padding: 1rem; }
  .verify-code code { font-size: 1.1rem; word-break: break-all; text-align: center; }
  .login-card { max-width: 100%; }
  .login-wrap { padding: 1.5rem; }
  table { min-width: 420px; }
}

@media (max-width: 420px) {
  .hero h1 { font-size: 1.35rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
