:root {
  --bg: #0f0f13;
  --bg-secondary: #1a1a24;
  --bg-card: #1e1e2e;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --text: #e0e0e0;
  --text-muted: #888;
  --border: #2a2a3a;
  --success: #57f287;
  --error: #ed4245;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}

/* Sidebar layout */
body.has-sidebar { display: flex; flex-direction: column; }

.layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - 64px);
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
}

.sidebar-guild {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.sidebar-guild-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-guild-placeholder {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-guild-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 0 0.5rem;
}

.sidebar-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0.75rem 0.75rem 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.sidebar-link.active { background: rgba(88,101,242,0.15); color: var(--accent); }
.sidebar-link svg { flex-shrink: 0; opacity: 0.8; }

.page-main {
  flex: 1;
  padding: 2rem;
  min-width: 0;
}

.page-heading {
  margin-bottom: 2rem;
}

.page-heading h1 { font-size: 1.75rem; font-weight: 700; }
.page-subtitle { color: var(--text-muted); margin-top: 0.25rem; font-size: 0.95rem; }

/* Overview stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
}

/* Placeholder pages */
.placeholder-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  gap: 1rem;
}

.placeholder-icon { font-size: 3rem; }
.placeholder-page h2 { font-size: 1.4rem; }
.placeholder-page p { color: var(--text-muted); max-width: 400px; line-height: 1.6; }

.navbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand a {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
}

.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
  display: inline-block;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-card); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-outline:hover { color: var(--text); border-color: var(--text-muted); }
.btn-large { padding: 0.9rem 2rem; font-size: 1rem; }

.hero {
  text-align: center;
  padding: 6rem 0 4rem;
}

.hero h1 {
  font-size: 3.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #eb459e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.hero-subtitle {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 4rem;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.feature-card h3 {
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.feature-card p {
  color: var(--text-muted);
}

h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.subtitle { color: var(--text-muted); margin-bottom: 2rem; }

.guild-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.guild-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  transition: border-color 0.2s, transform 0.2s;
  color: var(--text);
}

.guild-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.guild-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

.guild-icon-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 0.5rem;
}

.guild-icon-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
}

.guild-name {
  font-weight: 600;
  text-align: center;
  font-size: 0.9rem;
}

.empty-state {
  grid-column: 1/-1;
  text-align: center;
  color: var(--text-muted);
  padding: 3rem;
}

.page-header {
  margin-bottom: 2rem;
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: inline-block;
  margin-bottom: 0.75rem;
}

.back-link:hover { color: var(--text); }

.settings-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 800px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.form-group select,
.channel-select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem 1rem;
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s;
  appearance: none;
  cursor: pointer;
}

.form-group select:focus,
.channel-select:focus {
  outline: none;
  border-color: var(--accent);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  display: block;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Kanal tabel */
.channel-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.channel-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.channel-table td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.channel-table tr:last-child td { border-bottom: none; }
.channel-table tr:hover td { background: rgba(255,255,255,0.02); }

.channel-name {
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.ch-hash { color: var(--text-muted); }

.ch-category {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 0.5rem;
  background: var(--bg);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.num-input {
  width: 80px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  color: var(--text);
  font-size: 0.9rem;
}

.num-input:focus { outline: none; border-color: var(--accent); }

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.85rem; }
.btn-success { background: var(--success) !important; color: #000 !important; }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 22px;
  transition: background 0.2s;
  cursor: pointer;
}

.slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle input:checked + .slider { background: var(--accent); }
.toggle input:checked + .slider::before { transform: translateX(18px); }

.loading-state {
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
}

.empty-cell {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem !important;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.7rem 1rem;
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

.save-message {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-weight: 600;
}

.save-message.success { background: rgba(87, 242, 135, 0.1); color: var(--success); }
.save-message.error { background: rgba(237, 66, 69, 0.1); color: var(--error); }

/* AutoMod */
.automod-master {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.toggle-large {
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-large .slider::before {
  width: 20px;
  height: 20px;
  left: 4px;
  top: 4px;
}

.toggle-large input:checked + .slider::before { transform: translateX(24px); }

.automod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.automod-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.automod-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.automod-card-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.automod-card-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.form-row-sm {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.num-input-wide {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.95rem;
}

.num-input-wide:focus { outline: none; border-color: var(--accent); }

.automod-actions-section { margin-top: 1rem; }

.automod-actions-grid {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.checkbox-label input[type=checkbox] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.error-page {
  text-align: center;
  padding: 6rem 0;
}

.error-code {
  font-size: 6rem;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 1rem;
}

.error-message {
  color: var(--text-muted);
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

/* ── XP page ────────────────────────────────────────────── */
.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.search-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  color: var(--text);
  font-size: 0.9rem;
  width: 220px;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.leaderboard-sort-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sort-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}
.sort-btn:hover { border-color: var(--accent); color: var(--text); }
.sort-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.level-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 20px;
}

.xp-bar-wrap {
  background: var(--bg-secondary);
  border-radius: 4px;
  height: 6px;
  width: 120px;
  overflow: hidden;
  margin-bottom: 2px;
}
.xp-bar {
  background: var(--accent);
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.xp-val { font-size: 0.8rem; color: var(--text-muted); }

.user-cell { display: flex; align-items: center; gap: 0.6rem; }
.user-avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.user-avatar-placeholder {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  font-size: 0.8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.modal-box h3 { font-size: 1.1rem; }
.modal-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ── Analytics page ─────────────────────────────────────── */
.analytics-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 1.5rem;
}

.analytics-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.chart-wrap {
  position: relative;
  height: 220px;
  margin-top: 1rem;
}

.top-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1rem;
}
.top-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.top-row:last-child { border-bottom: none; }
.top-rank {
  width: 22px;
  text-align: center;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.top-name { flex: 1; font-size: 0.9rem; }
.top-val { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
.mod-action-badge {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  text-transform: capitalize;
  flex: 1;
}
.empty-state-sm { color: var(--text-muted); font-size: 0.9rem; padding: 0.5rem 0; }

.loading-state {
  color: var(--text-muted);
  padding: 2rem 0;
  text-align: center;
}

/* ── Announcements page ─────────────────────────────────── */
.announce-preview {
  display: flex;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.announce-preview-bar {
  width: 4px;
  flex-shrink: 0;
  background: #5865f2;
}
.announce-preview-body {
  padding: 1rem 1.25rem;
  flex: 1;
}
.announce-preview-title {
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0.4rem;
  display: none;
}
.announce-preview-content {
  font-size: 0.9rem;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Sponsorship page ───────────────────────────────────── */
.sp-app-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.sp-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.sp-username {
  font-weight: 600;
  font-size: 1rem;
  display: block;
}
.sp-app-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.sp-status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sp-status-pending { background: rgba(254,231,92,0.15); color: #fee75c; }
.sp-status-approved { background: rgba(87,242,135,0.15); color: #57f287; }
.sp-status-rejected { background: rgba(237,66,69,0.15); color: #ed4245; }

.sp-qa {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.75rem;
}
.sp-question {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}
.sp-answer {
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}
