:root {
  --bg: #0d0f17;
  --bg-grad: radial-gradient(1200px 600px at 80% -10%, #1c1f3a 0%, transparent 60%),
             radial-gradient(900px 500px at -10% 10%, #1a2236 0%, transparent 55%), #0d0f17;
  --surface: #161925;
  --surface-2: #1c2030;
  --surface-3: #232838;
  --line: #2a2f42;
  --line-soft: #21263550;
  --text: #e9ebf5;
  --muted: #8a90a6;
  --primary: #6c5ce7;
  --primary-2: #8b5cf6;
  --grad: linear-gradient(135deg, #6c5ce7 0%, #8b5cf6 60%, #a855f7 100%);
  --success: #34d399;
  --danger: #f87171;
  --warn: #fbbf24;
  --info: #38bdf8;
  --gold: #fbbf24;
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 8px 24px -8px rgba(108, 92, 231, 0.5);
  --radius: 16px;
  --radius-sm: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Sarabun', 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-2); text-decoration: none; transition: 0.15s; }
a:hover { color: #b89dff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid var(--bg); }
::selection { background: rgba(139, 92, 246, 0.35); }

.layout { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: 256px;
  background: rgba(20, 23, 35, 0.7);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px; font-size: 18px; font-weight: 800;
  border-bottom: 1px solid var(--line-soft);
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; background: var(--grad);
  display: grid; place-items: center; font-size: 20px; box-shadow: var(--shadow-glow);
}
.brand .logo svg { width: 20px; height: 20px; color: #fff; }
.brand .logo-img { width: 40px; height: 40px; border-radius: 11px; object-fit: cover; box-shadow: var(--shadow-glow); }
.logo-big-img { width: 84px; height: 84px; border-radius: 22px; object-fit: cover; margin: 0 auto 22px; display: block; box-shadow: var(--shadow-glow); }
.nav-label { padding: 18px 22px 8px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.sidebar nav { display: flex; flex-direction: column; padding: 8px 12px; gap: 3px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); padding: 11px 14px; border-radius: 11px;
  font-weight: 600; font-size: 14.5px; transition: 0.16s; position: relative;
}
.sidebar nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar nav a:hover { background: var(--surface-2); color: var(--text); }
.sidebar nav a.active { background: var(--grad); color: #fff; box-shadow: var(--shadow-glow); }
.sidebar-foot {
  padding: 14px; border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 11px;
}
.sidebar-foot .avatar { width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--line); }
.uname { font-weight: 700; font-size: 14px; line-height: 1.2; }
.logout { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.logout:hover { color: var(--danger); }

/* ===== Content ===== */
.content { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 26px 34px 20px;
}
.topbar h1 { font-size: 25px; font-weight: 800; letter-spacing: -0.02em; }
.topbar .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.menu-btn { display: none; background: var(--surface-2); border: 1px solid var(--line); color: var(--text); width: 42px; height: 42px; border-radius: 11px; cursor: pointer; font-size: 20px; }
.page { padding: 4px 34px 40px; max-width: 1180px; animation: fade 0.35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Cards ===== */
.grid { display: grid; gap: 16px; }
.stats { grid-template-columns: repeat(auto-fit, minmax(195px, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin-bottom: 16px; font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }

/* stat card */
.stat { display: flex; align-items: center; gap: 16px; transition: 0.2s; }
.stat:hover { transform: translateY(-3px); border-color: #3a4060; }
.stat .ico { width: 50px; height: 50px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; }
.stat .ico svg { width: 24px; height: 24px; }
.stat .ico.indigo { background: rgba(108,92,231,.16); color: #a594ff; }
.stat .ico.green { background: rgba(52,211,153,.14); color: var(--success); }
.stat .ico.gold { background: rgba(251,191,36,.14); color: var(--gold); }
.stat .ico.blue { background: rgba(56,189,248,.14); color: var(--info); }
.stat .ico.pink { background: rgba(236,72,153,.14); color: #f472b6; }
.stat .ico.red { background: rgba(248,113,113,.14); color: var(--danger); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat .value { font-size: 25px; font-weight: 800; letter-spacing: -0.02em; margin-top: 1px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== Table ===== */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; }
th { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--line); }
td { border-bottom: 1px solid var(--line-soft); }
tbody tr { transition: 0.12s; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
.user-cell { display: flex; align-items: center; gap: 11px; }
.user-cell img { width: 34px; height: 34px; border-radius: 10px; }
.mono { font-family: ui-monospace, 'SF Mono', monospace; font-size: 12px; color: var(--muted); }

/* ===== Forms / buttons ===== */
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 10px 13px; border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; width: 100%;
  transition: 0.15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,92,231,.18); }
textarea { resize: vertical; min-height: 84px; }
label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; margin-top: 14px; }
.row { display: flex; gap: 11px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; }
.btn {
  background: var(--grad); color: #fff; border: none; padding: 10px 18px; border-radius: var(--radius-sm);
  font-weight: 700; cursor: pointer; font-size: 14px; width: auto; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 7px; transition: 0.16s; box-shadow: var(--shadow-glow);
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn.sm { padding: 7px 12px; font-size: 13px; box-shadow: none; }
.btn.danger { background: linear-gradient(135deg, #ef4444, #f87171); box-shadow: none; }
.btn.ghost { background: var(--surface-3); color: var(--text); box-shadow: none; }
.btn.ghost:hover { background: #2c3346; }
.btn.success { background: linear-gradient(135deg, #10b981, #34d399); box-shadow: none; }
form.inline { display: inline; }

/* ===== Misc ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.common { background: #94a3b822; color: #cbd5e1; }
.badge.rare { background: #3b82f622; color: #93c5fd; }
.badge.epic { background: #a855f722; color: #d8b4fe; }
.badge.legendary { background: #fbbf2422; color: var(--gold); }
.badge.on { background: #34d39922; color: var(--success); }
.badge.off { background: #f8717122; color: var(--danger); }
.muted { color: var(--muted); }
.pill { background: var(--surface-3); padding: 4px 11px; border-radius: 8px; font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; font-weight: 600; }
.section-title { margin: 24px 0 12px; font-size: 14px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.pagination { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.notice { background: linear-gradient(135deg, #10b98122, #34d39911); border: 1px solid #34d39955; color: var(--success); padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-weight: 600; }
.empty { color: var(--muted); padding: 36px; text-align: center; }
details > summary { cursor: pointer; color: var(--primary-2); font-weight: 700; padding: 6px 0; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details > summary::before { content: '＋'; font-weight: 700; }
details[open] > summary::before { content: '－'; }
.gap { margin-top: 14px; }

/* ===== Login / Error ===== */
.center-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: 44px 40px; max-width: 420px; width: 100%; text-align: center; box-shadow: var(--shadow);
  animation: fade 0.4s ease;
}
.auth-card .logo-big {
  width: 76px; height: 76px; border-radius: 22px; background: var(--grad);
  display: grid; place-items: center; margin: 0 auto 22px; box-shadow: var(--shadow-glow); font-size: 38px;
}
.auth-card h1 { font-size: 24px; font-weight: 800; margin-bottom: 8px; }
.auth-card p { color: var(--muted); margin-bottom: 26px; font-size: 14.5px; }
.btn-discord {
  background: var(--grad); color: #fff; padding: 14px 26px; border-radius: 13px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 10px; font-size: 15.5px; box-shadow: var(--shadow-glow); transition: 0.16s;
}
.btn-discord:hover { filter: brightness(1.08); transform: translateY(-2px); color: #fff; }
.btn-discord svg { width: 22px; height: 22px; }
.big-emoji { font-size: 52px; margin-bottom: 6px; }

/* ===== Mobile ===== */
.backdrop { display: none; }
@media (max-width: 860px) {
  .cols, .stats { grid-template-columns: 1fr; }
  .menu-btn { display: block; }
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: 0.25s; box-shadow: 0 0 50px rgba(0,0,0,.6);
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 15; }
  .page, .topbar { padding-left: 18px; padding-right: 18px; }
}
