/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:        #1a1d21;
  --bg2:       #111214;
  --card:      #2b2d31;
  --card2:     #232428;
  --border:    #3a3d43;
  --accent:    #5865f2;
  --accent-h:  #4752c4;
  --text:      #dbdee1;
  --muted:     #80848e;
  --danger:    #f04747;
  --success:   #3ba55c;
  --warning:   #faa81a;
  --sidebar-w: 240px;
  --topbar-h:  56px;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font-family: inherit; }

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, #2a2d5e 0%, var(--bg) 60%);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,.5);
}
.login-icon { margin-bottom: 20px; }
.login-card h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: 8px; }
.login-card .subtitle { color: var(--muted); margin-bottom: 28px; }
.login-card .hint { color: var(--muted); font-size: .8rem; margin-top: 20px; }
.btn-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  padding: 13px 28px;
  border-radius: 8px;
  font-size: 1rem;
  transition: background .15s;
  width: 100%;
}
.btn-discord:hover { background: var(--accent-h); }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .2s;
}
.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.2rem;
  flex-shrink: 0;
}
.sidebar-title { font-weight: 700; font-size: .95rem; }
.sidebar-sub { color: var(--muted); font-size: .75rem; }

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: .9rem;
  transition: background .1s, color .1s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--card); color: #fff; }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.me-info {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
  min-height: 36px;
}
.me-info img { width: 32px; height: 32px; border-radius: 50%; }
.me-info span { font-size: .85rem; font-weight: 500; }
.logout-btn {
  display: block; text-align: center;
  background: var(--card);
  color: var(--muted);
  border-radius: 6px;
  padding: 7px;
  font-size: .8rem;
  transition: background .1s, color .1s;
}
.logout-btn:hover { background: var(--danger); color: #fff; }

/* Main */
.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
}
.page-title { font-size: 1.1rem; font-weight: 700; }
.hamburger {
  display: none;
  background: none; border: none; color: var(--text);
  font-size: 1.3rem; cursor: pointer; padding: 4px 8px;
}
.content { padding: 24px; flex: 1; }

/* Overlay for mobile */
.overlay {
  display: none;
  position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,.6);
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.card-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 16px;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.stat-label { font-size: .75rem; color: var(--muted); text-transform: uppercase;
              letter-spacing: .05em; margin-bottom: 8px; }
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-value.green { color: var(--success); }
.stat-value.blue  { color: var(--accent); }
.stat-value.orange{ color: var(--warning); }
.stat-value.red   { color: var(--danger); }

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th { text-align: left; padding: 10px 14px; color: var(--muted);
     font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
     border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.04);
     vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.03); }

.user-cell { display: flex; align-items: center; gap: 10px; }
.user-cell img { width: 30px; height: 30px; border-radius: 50%; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: .75rem; font-weight: 600;
}
.badge-warn    { background: rgba(250,168,26,.15); color: var(--warning); }
.badge-kick    { background: rgba(240,71,71,.15);  color: var(--danger); }
.badge-ban     { background: rgba(240,71,71,.25);  color: #ff6b6b; }
.badge-mute    { background: rgba(88,101,242,.15); color: var(--accent); }
.badge-unmute  { background: rgba(59,165,92,.15);  color: var(--success); }
.badge-unban   { background: rgba(59,165,92,.15);  color: var(--success); }
.badge-tempban { background: rgba(240,71,71,.15);  color: var(--danger); }
.badge-automod { background: rgba(128,132,142,.15);color: var(--muted); }
.badge-clearwarns,.badge-deletewarn { background: rgba(128,132,142,.15); color: var(--muted); }
.badge-online  { background: rgba(59,165,92,.2);   color: var(--success); }
.badge-offline { background: rgba(128,132,142,.2); color: var(--muted); }
.badge-timeout { background: rgba(240,71,71,.15);  color: var(--danger); }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; font-size: .875rem; font-weight: 600;
  cursor: pointer; border: none; transition: opacity .15s, background .15s;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .85; }
.btn-success { background: var(--success); color: #fff; }
.btn-ghost   { background: var(--card2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--card); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 600;
                    color: var(--muted); margin-bottom: 6px; text-transform: uppercase;
                    letter-spacing: .04em; }
.form-control {
  width: 100%; padding: 9px 12px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: .9rem;
  outline: none; transition: border-color .15s;
}
.form-control:focus { border-color: var(--accent); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-check { display: flex; align-items: center; gap: 10px; }
.form-check input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }

/* ── Filters row ───────────────────────────────────────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.filters .form-control { width: auto; flex: 1; min-width: 140px; }
.filters .btn { white-space: nowrap; }

/* ── Pagination ────────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 8px; margin-top: 16px;
              justify-content: flex-end; flex-wrap: wrap; }
.pagination .btn { min-width: 36px; }
.page-info { color: var(--muted); font-size: .85rem; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: .9rem; margin-bottom: 16px; }
.alert-error   { background: rgba(240,71,71,.15);  color: #ff8080; border: 1px solid rgba(240,71,71,.3); }
.alert-success { background: rgba(59,165,92,.15);  color: #5ddb8c; border: 1px solid rgba(59,165,92,.3); }

/* ── Loader ────────────────────────────────────────────────────────────────── */
.loader { text-align: center; color: var(--muted); padding: 60px 0; }

/* ── Overview grid ─────────────────────────────────────────────────────────── */
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .overview-grid { grid-template-columns: 1fr; } }

/* ── Action log item ───────────────────────────────────────────────────────── */
.log-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0;
            border-bottom: 1px solid rgba(255,255,255,.05); }
.log-item:last-child { border-bottom: none; }
.log-item-avatar { width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
                   background: var(--card2); }
.log-item-body { flex: 1; min-width: 0; }
.log-item-title { font-size: .875rem; font-weight: 500; }
.log-item-meta  { font-size: .78rem; color: var(--muted); margin-top: 2px; }

/* ── User card (profile) ───────────────────────────────────────────────────── */
.user-profile { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.user-profile img { width: 64px; height: 64px; border-radius: 50%; }
.user-profile h2 { font-size: 1.2rem; }
.user-profile .user-id { color: var(--muted); font-size: .8rem; }
.roles-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.role-badge { padding: 2px 10px; border-radius: 12px; font-size: .78rem; font-weight: 600; }

/* ── Leaderboard ───────────────────────────────────────────────────────────── */
.lb-row { display: flex; align-items: center; gap: 14px; padding: 12px 0;
          border-bottom: 1px solid rgba(255,255,255,.05); }
.lb-row:last-child { border-bottom: none; }
.lb-rank { width: 28px; text-align: center; font-weight: 700; color: var(--muted); font-size: .9rem; }
.lb-rank.gold   { color: #ffd700; }
.lb-rank.silver { color: #c0c0c0; }
.lb-rank.bronze { color: #cd7f32; }
.lb-row img { width: 40px; height: 40px; border-radius: 50%; }
.lb-info { flex: 1; min-width: 0; }
.lb-name { font-weight: 600; font-size: .9rem; }
.lb-xp { font-size: .8rem; color: var(--muted); }
.lb-level { text-align: right; }
.lb-level-num { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.lb-level-label { font-size: .7rem; color: var(--muted); }
.xp-bar-wrap { background: var(--bg2); border-radius: 4px; height: 4px; margin-top: 4px; }
.xp-bar { background: var(--accent); border-radius: 4px; height: 4px; transition: width .3s; }

/* ── Settings ──────────────────────────────────────────────────────────────── */
.settings-section { margin-bottom: 28px; }
.settings-section h3 { font-size: .9rem; font-weight: 700; color: var(--muted);
                       text-transform: uppercase; letter-spacing: .05em; margin-bottom: 14px; }
.toggle-row { display: flex; justify-content: space-between; align-items: center;
              padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.toggle-row:last-child { border-bottom: none; }
.toggle-label h4 { font-size: .9rem; font-weight: 500; }
.toggle-label p  { font-size: .8rem; color: var(--muted); }
.toggle { position: relative; display: inline-block; width: 42px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; border-radius: 24px;
  background: var(--border); cursor: pointer; transition: background .2s;
}
.toggle-slider::after {
  content: ''; position: absolute; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: transform .2s;
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider::after { transform: translateX(18px); }

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 100%;
  max-width: 440px;
}
.modal-box h2 { font-size: 1.1rem; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ── Quick actions ─────────────────────────────────────────────────────────── */
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── Chips ─────────────────────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card2); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 20px; font-size: .82rem;
  color: var(--text);
}
.chip-danger {
  background: rgba(240,71,71,.12); border-color: rgba(240,71,71,.3); color: #ff8080;
}
.chip-remove {
  background: none; border: none; color: inherit; cursor: pointer;
  font-size: .8rem; padding: 0; line-height: 1; opacity: .7; transition: opacity .15s;
}
.chip-remove:hover { opacity: 1; }

/* ── Notes ─────────────────────────────────────────────────────────────────── */
.note-item {
  background: var(--card2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; margin-bottom: 8px;
}
.note-text  { font-size: .88rem; margin-bottom: 5px; line-height: 1.5; }
.note-meta  {
  font-size: .75rem; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}

/* ── Icon button (notes delete etc.) ──────────────────────────────────────── */
.btn-icon {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: .75rem; padding: 2px 5px; border-radius: 4px;
  transition: background .1s, color .1s; margin-left: auto;
}
.btn-icon:hover { background: var(--danger); color: #fff; }

/* ── Permission matrix table ───────────────────────────────────────────────── */
#perm-table td, #perm-table th { padding: 10px 8px; }
#perm-table th { font-size: .68rem; }
#perm-table .toggle { width: 36px; height: 20px; }
#perm-table .toggle-slider::after { width: 14px; height: 14px; }
#perm-table .toggle input:checked + .toggle-slider::after { transform: translateX(16px); }

/* ── Charts container ──────────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 180px; }

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .overlay.open { display: block; }
  .main-wrap { margin-left: 0; }
  .hamburger { display: block; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 32px 20px; }
}
