/* ── Design Tokens ───────────────────────────────────────── */
:root {
  --primary: #5865F2;
  --primary-hover: #4752C4;
  --primary-light: #E3E5F8;
  --bg: #f2f3f5;
  --surface: #ffffff;
  --surface-hover: #f8f9fa;
  --text: #1e1f22;
  --text-secondary: #4f5660;
  --text-muted: #96989d;
  --border: #e3e5e8;
  --border-strong: #d3d6da;
  --danger: #ed4245;
  --danger-hover: #c03537;
  --danger-bg: #fdeaea;
  --success: #3ba55d;
  --success-bg: #e6f5eb;
  --warning: #f9a62b;
  --warning-bg: #fef3e2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.12);
  --header-height: 56px;
  --sidebar-width: 240px;
  --sidebar-surface: #fcfcfd;
  --sidebar-border: #e3e5e8;
  --overlay: rgba(15, 17, 24, 0.42);
}

[data-theme="dark"] {
  --bg: #1a1b1e;
  --surface: #232428;
  --surface-hover: #2b2d31;
  --text: #f2f3f5;
  --text-secondary: #b5bac1;
  --text-muted: #6d6f78;
  --border: #3f4147;
  --border-strong: #505259;
  --primary-light: #31323a;
  --danger-bg: #3a1c1d;
  --success-bg: #1e3a27;
  --warning-bg: #3a2e1a;
  --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.2);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.4);
  --sidebar-surface: #1f2126;
  --sidebar-border: #343740;
  --overlay: rgba(5, 7, 11, 0.6);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: "Pretendard", "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

/* ── Header ──────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100000;
  height: var(--header-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.site-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
}
.site-header .brand svg { width: 28px; height: 28px; }
.site-header .brand:hover { text-decoration: none; }

.sidebar-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.sidebar-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.header-actions .user-name {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.user-widget {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--primary-light);
}
.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.user-display-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.user-handle {
  font-size: 11px;
  color: var(--text-muted);
}

.header-actions .btn-sm {
  font-size: 13px;
  padding: 6px 14px;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { background: var(--surface-hover); color: var(--text); }
.theme-toggle .theme-icon { display: none; }
.theme-toggle.active .theme-icon.dark,
.theme-toggle:not(.active) .theme-icon.light { display: flex; }

/* ── Layout ──────────────────────────────────────────────── */
.app-shell {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding: 24px;
}

.admin-sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  position: relative;
  z-index: 10000;
}

.sidebar-panel {
  position: sticky;
  top: calc(var(--header-height) + 24px);
  background: var(--sidebar-surface);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 18px 14px;
  max-height: calc(100vh - var(--header-height) - 48px);
  overflow: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px 18px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
}

.sidebar-brand:hover {
  color: var(--text);
  text-decoration: none;
}

.sidebar-brand svg {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
}

.sidebar-brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.sidebar-brand-copy strong {
  font-size: 15px;
  font-weight: 700;
}

.sidebar-brand-copy span {
	font-size: 12px;
	color: var(--text-muted);
}

.sidebar-server-icon {
	width: 32px;
	height: 32px;
	border-radius: var(--radius-sm);
	background: var(--primary-light);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	font-weight: 700;
	flex-shrink: 0;
	overflow: hidden;
	border: 2px solid var(--surface);
	box-shadow: 0 0 0 1px var(--border);
}

.sidebar-server-icon img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border-left: 3px solid transparent;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: var(--surface-hover);
  color: var(--text);
  text-decoration: none;
  transform: translateX(2px);
}

.sidebar-link.active {
  background: var(--primary-light);
  border-left-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.content-shell {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.sidebar-backdrop {
  display: none;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}
.container-narrow {
  max-width: 780px;
}

/* ── Typography ──────────────────────────────────────────── */
h1 { font-size: 26px; font-weight: 700; margin: 0 0 12px; }
h2 { font-size: 20px; font-weight: 700; margin: 36px 0 14px; color: var(--text); }
h3 { font-size: 16px; font-weight: 600; margin: 24px 0 10px; }
p { font-size: 15px; color: var(--text-secondary); margin: 0 0 12px; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-body { padding: 28px; }
.card-header {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { margin: 0; font-size: 16px; }
.card-header .muted { font-size: 13px; color: var(--text-muted); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.18s ease, background 0.18s ease;
  text-decoration: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,0.12); }
.btn:active { transform: translateY(1px); box-shadow: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; color: #fff; box-shadow: 0 4px 14px rgba(88, 101, 242, 0.35); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); text-decoration: none; color: #fff; box-shadow: 0 4px 14px rgba(237, 66, 69, 0.35); }

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}
.btn-outline:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }

.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-group input,
.form-group select,
.form-group textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group select[multiple] {
  padding: 6px;
  min-height: 130px;
}
[data-theme="dark"] .form-group select option {
  background: var(--surface);
  color: var(--text);
}
.form-actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
}

/* ── Tables ──────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
.data-table thead th {
  background: #f4f5f7;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.data-table tbody tr:hover td { background: var(--surface-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Stats / Metrics ─────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.25s ease;
}
.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); border-color: var(--border-strong); }
.stat-card .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.stat-card .value.primary { color: var(--primary); }
.stat-card .value.success { color: var(--success); }
.stat-card .value.warning { color: var(--warning); }

/* ── Server List (index) ─────────────────────────────────── */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}
.server-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.25s ease;
}
.server-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
  border-color: var(--primary);
  text-decoration: none;
  color: var(--text);
}
.server-card.bot-present {
  border: 2px solid #22c55e !important;
}
.server-card.bot-absent {
  border: 2px solid #ef4444 !important;
}
.server-card .server-banner {
  width: calc(100% + 40px);
  aspect-ratio: 16 / 9;
  margin: -20px -20px 14px -20px;
  overflow: hidden;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--bg);
  flex-shrink: 0;
}
.server-card .server-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.server-card .server-card-body {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}
.server-card .icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  overflow: hidden;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.server-card .icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.server-card .name {
  font-weight: 600;
  font-size: 15px;
}
.server-card .id {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.3px;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: #8f6c1e; }

/* ── Empty State ─────────────────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 14px;
}
.empty svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.5; }

.invite-page,
.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-height) - 160px);
}

.empty-state {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.state-card {
  position: relative;
  overflow: hidden;
}

.state-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), transparent);
}

.empty-state .card-body {
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.empty-state h1 {
  margin: 0;
}

.empty-state p {
  margin: 0;
  max-width: 560px;
}

.state-icon {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.state-icon svg {
  width: 34px;
  height: 34px;
}

.state-icon-primary {
  background: var(--primary-light);
  color: var(--primary);
}

.state-icon-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.state-icon-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.state-subtext {
  font-size: 13px;
  color: var(--text-muted);
}

.state-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.big-btn {
  min-height: 48px;
  padding: 12px 22px;
  font-size: 15px;
  box-shadow: var(--shadow);
}

.big-btn:hover {
  box-shadow: var(--shadow-hover);
}

/* ── Footer ──────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 20px 28px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: auto;
}
.site-footer a { color: var(--text-muted); margin: 0 8px; }
.site-footer a:hover { color: var(--primary); }

/* ── TOC (terms/privacy) ─────────────────────────────────── */
.toc {
  background: #f4f5f7;
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 28px;
}
.toc h3 { margin: 0 0 10px 0; font-size: 14px; color: var(--text-muted); }
.toc ol { margin: 0; padding-left: 20px; }
.toc li { margin-bottom: 4px; font-size: 14px; }
.toc a { color: var(--primary); }

/* ── Legal content (terms/privacy) ───────────────────────── */
.legal-content h2 {
  font-size: 18px;
  color: var(--primary);
  margin-top: 32px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}
.legal-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 14px;
}
.legal-content th, .legal-content td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}
.legal-content th { background: #f4f5f7; font-weight: 600; }
.legal-content code {
  background: #f0f2f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}
.legal-content .contact-box {
  background: #f4f5f7;
  border-radius: 10px;
  padding: 18px 22px;
  margin-top: 10px;
}
.legal-content .contact-box p { margin: 4px 0; font-size: 14px; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  .site-header { padding: 0 16px; }
  .container { padding: 20px 16px 40px; }
  .card-body { padding: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .server-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .data-table thead { display: none; }
  .data-table tbody td {
    display: block;
    padding: 8px 16px;
    border-bottom: none;
  }
  .data-table tbody tr {
    display: block;
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
  }
  .data-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    display: block;
    margin-bottom: 2px;
  }
  h1 { font-size: 22px; }
  h2 { font-size: 18px; }

  .invite-page,
  .error-page {
    min-height: auto;
  }

  .empty-state .card-body {
    padding: 28px 20px;
  }

  .state-actions {
    width: 100%;
    flex-direction: column;
  }

  .state-actions .btn,
  .big-btn {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .sidebar-toggle {
    display: inline-flex;
  }

  .app-shell {
    display: block;
    padding: 0;
  }

  .admin-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: min(82vw, 280px);
    padding: 16px 16px 16px 0;
    transform: translateX(-110%);
    transition: transform 0.2s ease;
    z-index: 10000;
    pointer-events: none;
  }

  body.sidebar-open .admin-sidebar {
    transform: translateX(0);
    pointer-events: auto;
  }

  .sidebar-panel {
    position: relative;
    top: 0;
    height: 100%;
    max-height: none;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    padding-top: 20px;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: var(--header-height) 0 0 0;
    display: block;
    border: 0;
    padding: 0;
    background: var(--overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 120;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ── Charts ──────────────────────────────────────────────── */
.chart-container {
	position: relative;
	width: 100%;
	height: 280px;
	min-height: 200px;
}

/* ── Searchable Select ───────────────────────────────────── */
.ss-wrapper { position: relative; }

.ss-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  min-height: 42px;
  user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ss-trigger:hover { border-color: var(--primary); }
.ss-trigger:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.ss-trigger.open {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.ss-trigger-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ss-trigger-text.placeholder { color: var(--text-muted); }

.ss-arrow {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ss-arrow svg { width: 16px; height: 16px; }
.ss-trigger.open .ss-arrow { transform: rotate(180deg); }

.ss-dropdown {
  position: absolute;
  z-index: 9000;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.14);
  overflow: hidden;
  animation: ss-in 0.12s ease;
}
@keyframes ss-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ss-search {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}
.ss-search-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: calc(var(--radius-sm) - 2px);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ss-search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.ss-list {
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.ss-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.1s;
  user-select: none;
}
.ss-option:hover { background: var(--surface-hover); }
.ss-option.hidden { display: none; }
.ss-label { flex: 1; }
.ss-option.selected .ss-label { color: var(--primary); font-weight: 600; }

.ss-check {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--primary);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.1s;
}
.ss-option.selected .ss-check { opacity: 1; }

.ss-empty {
  list-style: none;
  padding: 12px 10px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

.ss-checkbox {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-strong);
  border-radius: 4px;
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}
.ss-option.selected .ss-checkbox {
  background: var(--primary);
  border-color: var(--primary);
}
.ss-option.selected .ss-checkbox::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 28px rgba(0,0,0,0.16);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-width: 220px;
  max-width: 340px;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transition: opacity 0.28s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}
.toast.toast-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--success);
}
.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
  line-height: 1;
  font-size: 18px;
  transition: color 0.15s;
}
.toast-close:hover { color: var(--text); }

@media (max-width: 640px) {
  .toast {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
  }
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.content-shell { animation: fadeIn 0.25s ease both; }

.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Stagger for grid children */
.stats-grid .stat-card.reveal:nth-child(2) { transition-delay: 0.07s; }
.stats-grid .stat-card.reveal:nth-child(3) { transition-delay: 0.14s; }
.stats-grid .stat-card.reveal:nth-child(4) { transition-delay: 0.21s; }
.server-grid .server-card.reveal:nth-child(2) { transition-delay: 0.07s; }
.server-grid .server-card.reveal:nth-child(3) { transition-delay: 0.14s; }
.server-grid .server-card.reveal:nth-child(4) { transition-delay: 0.21s; }
.server-grid .server-card.reveal:nth-child(5) { transition-delay: 0.28s; }
.server-grid .server-card.reveal:nth-child(6) { transition-delay: 0.35s; }

/* Smooth focus ring everywhere */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Table row slide-in feel */
.data-table tbody tr {
  transition: background 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
  .content-shell { animation: none; }
  .reveal, .reveal.visible {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .btn:hover { transform: none; }
  .sidebar-link:hover { transform: none; }
}

/* ── Dark mode overrides ─────────────────────────────────── */
[data-theme="dark"] .sidebar-link.active {
	color: #9da6ff;
}
[data-theme="dark"] .data-table thead th { background: #2b2d31; }
[data-theme="dark"] .toc { background: #2b2d31; }
[data-theme="dark"] .legal-content th { background: #2b2d31; }
[data-theme="dark"] .legal-content code { background: #2b2d31; color: var(--text); }
[data-theme="dark"] .legal-content .contact-box { background: #2b2d31; }

/* ── Page Loader ─────────────────────────────────────────── */
#page-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
#page-loader.visible {
  opacity: 1;
  pointer-events: all;
}
.page-loader-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.page-loader-text {
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .page-loader-spinner { animation: none; border-top-color: var(--primary); }
}

/* ── Guild Dashboard ─────────────────────────────────────── */
.guild-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.guild-banner-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}
.guild-banner-icon img { width: 100%; height: 100%; object-fit: cover; }
.guild-banner-letter { font-size: 28px; font-weight: 700; color: var(--primary); }
.guild-banner-info { flex: 1; min-width: 0; }
.guild-banner-name { font-size: 20px; font-weight: 700; margin: 0 0 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.guild-banner-meta { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--text-muted); }
.guild-banner-meta .meta-item { display: flex; align-items: center; gap: 4px; }
.guild-banner-meta .meta-item svg { width: 12px; height: 12px; flex-shrink: 0; }

.section-heading { font-size: 13px; font-weight: 700; color: var(--text); margin: 0 0 12px; letter-spacing: 0.3px; text-transform: uppercase; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.feature-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 17px;
  border-bottom: 1px solid var(--border);
}
.feature-card-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.feature-card-title svg { width: 14px; height: 14px; color: var(--primary); flex-shrink: 0; }
.manage-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 9px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.manage-link:hover { background: var(--primary); color: #fff; text-decoration: none; }
.feature-card-body { padding: 12px 17px; display: flex; flex-direction: column; gap: 8px; }
.feature-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-secondary); line-height: 1.3; }
.fi-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.fi-icon.ok { background: var(--success-bg); color: var(--success); }
.fi-icon.err { background: var(--danger-bg); color: var(--danger); }
.fi-icon svg { width: 9px; height: 9px; }

.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.recent-list { display: flex; flex-direction: column; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.recent-item:first-child { padding-top: 0; }
.recent-item:last-child { border-bottom: none; padding-bottom: 0; }
.recent-avatar { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; object-fit: cover; }
.recent-info { flex: 1; min-width: 0; }
.recent-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.recent-badge { flex-shrink: 0; }

.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--overlay);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal-overlay.active {
  display: flex;
  opacity: 1;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-hover);
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
}
.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}
.modal-body { padding: 22px; }
.modal .form-actions { margin-top: 8px; }

@media (max-width: 900px) {
  .dashboard-bottom { grid-template-columns: 1fr; }
  .feature-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .guild-banner { flex-wrap: wrap; }
  .feature-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; }
}
