:root {
  --bg: #0a0a0f;
  --bg-soft: #101019;
  --panel: #14141f;
  --panel-2: #191926;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #ece9f5;
  --muted: #8b8aa3;
  --muted-2: #6b6a84;
  --accent: #8b5cf6;
  --accent-2: #a78bfa;
  --accent-soft: rgba(139, 92, 246, 0.14);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 24px 60px -30px rgba(0, 0, 0, 0.85);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Sora", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(139, 92, 246, 0.12), transparent 60%),
    radial-gradient(700px 400px at 0% 0%, rgba(99, 102, 241, 0.08), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--accent-soft); }

img { display: block; max-width: 100%; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 22px;
  background: rgba(10, 10, 15, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: 10px; color: #fff;
  background: linear-gradient(135deg, var(--accent), #6d28d9);
  box-shadow: 0 8px 24px -8px var(--accent);
}
.brand-name { font-size: 1.05rem; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-link { color: var(--muted); font-size: 0.9rem; }
.topbar-link:hover { color: var(--text); }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 12px 5px 6px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 0.88rem; background: var(--panel);
}
.user-chip img { border-radius: 999px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: 10px; color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }

/* ---------- Flash ---------- */
.flash {
  margin: 16px auto 0; max-width: 1180px; padding: 12px 16px;
  border-radius: var(--radius-sm); font-size: 0.9rem;
  border: 1px solid var(--line-strong);
}
.flash-success { background: rgba(52, 211, 153, 0.1); border-color: rgba(52, 211, 153, 0.3); color: #a7f3d0; }
.flash-error { background: rgba(248, 113, 113, 0.1); border-color: rgba(248, 113, 113, 0.3); color: #fecaca; }

/* ---------- Shell / layout ---------- */
.shell { display: flex; max-width: 1320px; margin: 0 auto; }
.content { flex: 1; min-width: 0; padding: 28px 26px 60px; }
body:not(.has-sidebar) .content { max-width: 1180px; margin: 0 auto; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 268px; flex-shrink: 0; padding: 22px 16px;
  border-right: 1px solid var(--line);
  position: sticky; top: 64px; align-self: flex-start;
  height: calc(100vh - 64px); overflow-y: auto;
}
.guild-head { display: flex; align-items: center; gap: 12px; padding: 6px 8px 16px; }
.guild-icon { border-radius: 12px; object-fit: cover; }
.guild-icon-fallback {
  display: grid; place-items: center; width: 44px; height: 44px;
  background: var(--accent-soft); color: var(--accent-2); font-weight: 700;
}
.guild-meta strong { display: block; font-size: 0.95rem; line-height: 1.2; }
.guild-meta a { font-size: 0.78rem; color: var(--muted); }
.guild-meta a:hover { color: var(--accent-2); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px; color: var(--muted);
  font-size: 0.9rem; transition: background .15s, color .15s;
}
.side-link:hover { background: var(--panel); color: var(--text); }
.side-link.active { background: var(--accent-soft); color: var(--text); }
.side-link.active .side-ico { color: var(--accent-2); }
.side-ico { display: grid; place-items: center; }
.side-label { flex: 1; }
.dot { width: 7px; height: 7px; border-radius: 999px; }
.dot-on { background: var(--ok); box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.14); }
.dot-off { background: var(--muted-2); }

/* ---------- Headings ---------- */
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0 0 6px; font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { margin: 0; color: var(--muted); font-size: 0.94rem; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent-2); margin-bottom: 10px;
}
.section-title { font-size: 1.05rem; font-weight: 600; margin: 28px 0 14px; }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--panel), var(--bg-soft));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.card-head .ci {
  display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 11px; color: var(--accent-2);
  background: var(--accent-soft); border: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.card-head p { margin: 2px 0 0; font-size: 0.83rem; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Stat cards ---------- */
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px;
}
.stat .stat-ico { color: var(--accent-2); margin-bottom: 12px; }
.stat .stat-val { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; }
.stat .stat-lbl { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }

/* ---------- Module grid (overview) ---------- */
.mod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.mod-card {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; transition: border-color .15s, transform .15s;
}
.mod-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.mod-card .mc-ico {
  display: grid; place-items: center; width: 42px; height: 42px; flex-shrink: 0;
  border-radius: 11px; color: var(--accent-2); background: var(--accent-soft);
}
.mod-card .mc-body { flex: 1; min-width: 0; }
.mod-card .mc-body h3 { margin: 0 0 3px; font-size: 0.98rem; font-weight: 600; }
.mod-card .mc-body p { margin: 0 0 12px; font-size: 0.82rem; color: var(--muted); }
.mc-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mc-config { font-size: 0.82rem; color: var(--accent-2); display: inline-flex; align-items: center; gap: 4px; }

/* ---------- Toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; cursor: pointer; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line-strong); transition: .2s;
}
.switch .track::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px;
  background: var(--muted); border-radius: 999px; transition: .2s;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::before { transform: translateX(18px); background: #fff; }

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 7px; }
.field .hint { color: var(--muted); font-size: 0.78rem; margin-top: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 11px 13px; color: var(--text);
  background: var(--bg-soft); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); font: inherit; font-size: 0.9rem;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; min-height: 92px; }
.row-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.row-toggle:last-child { border-bottom: none; }
.row-toggle .rt-label strong { display: block; font-size: 0.9rem; }
.row-toggle .rt-label span { font-size: 0.78rem; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 11px 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
  transition: filter .15s, background .15s, border-color .15s; white-space: nowrap;
}
.btn-sm { padding: 8px 13px; font-size: 0.83rem; }
.btn-accent { background: var(--accent); color: #fff; box-shadow: 0 10px 24px -12px var(--accent); }
.btn-accent:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-danger { background: rgba(248, 113, 113, 0.12); color: #fecaca; border-color: rgba(248, 113, 113, 0.3); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.2); }
.btn-block { width: 100%; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.tbl th, table.tbl td { padding: 12px 14px; text-align: left; }
table.tbl thead th {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); background: var(--panel); border-bottom: 1px solid var(--line);
}
table.tbl tbody tr { border-bottom: 1px solid var(--line); }
table.tbl tbody tr:last-child { border-bottom: none; }
table.tbl tbody tr:hover { background: var(--panel); }
.mono { font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  border: 1px solid var(--line-strong); color: var(--muted);
}
.badge-ok { color: #a7f3d0; border-color: rgba(52, 211, 153, 0.3); background: rgba(52, 211, 153, 0.1); }
.badge-warn { color: #fde68a; border-color: rgba(251, 191, 36, 0.3); background: rgba(251, 191, 36, 0.1); }
.badge-danger { color: #fecaca; border-color: rgba(248, 113, 113, 0.3); background: rgba(248, 113, 113, 0.1); }
.badge-accent { color: var(--accent-2); border-color: rgba(139, 92, 246, 0.35); background: var(--accent-soft); }

.empty {
  text-align: center; color: var(--muted); padding: 48px 20px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
}

/* ---------- Login / servers ---------- */
.center-wrap { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 30px; }
.login-card { max-width: 420px; width: 100%; text-align: center; }
.login-card .brand-mark { width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 16px; }
.login-card h1 { font-size: 1.6rem; margin: 0 0 8px; }
.login-card p { color: var(--muted); margin: 0 0 24px; }
.dc-btn { background: #5865F2; color: #fff; }
.dc-btn:hover { filter: brightness(1.08); }

.servers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.server-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 12px;
}
.server-card.is-out { opacity: 0.7; }
.server-top { display: flex; align-items: center; gap: 12px; }
.server-top .guild-icon, .server-top .guild-icon-fallback { width: 48px; height: 48px; border-radius: 13px; }
.server-top strong { font-size: 0.95rem; }

.footer {
  border-top: 1px solid var(--line); margin-top: 40px;
  padding: 22px 26px; color: var(--muted); font-size: 0.82rem;
  display: flex; gap: 10px; justify-content: center; align-items: center;
}
.footer a:hover { color: var(--accent-2); }
.footer-sep { opacity: 0.4; }

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 0.85rem; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .side-nav { flex-direction: row; flex-wrap: wrap; }
  .side-link { flex: 0 0 auto; }
  .side-label { display: none; }
  .side-link { padding: 10px; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .content { padding: 20px 16px 48px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .brand-name { display: none; }
  .user-chip span { display: none; }
}
