:root {
  --bg: #111214; --side: #18191c; --panel: #1e1f22; --panel2: #2b2d31; --line: #2a2b30; --text: #dbdee1; --muted: #949ba4; --faint: #6d6f78;
  --accent: #5865f2; --accent2: #4752c4; --ok: #23a55a; --good: #57f287; --bad: #da373c; --warn: #f0b232; --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
a { color: #00a8fc; }
h1, h2, h3 { color: #fff; margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border-radius: 14px; padding: 36px 32px; max-width: 380px; width: 100%; text-align: center; box-shadow: 0 8px 30px #0006; }
.login-logo { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 34px; }
.login-card { border: 1px solid var(--line); }
.login-error { background: #da373c22; border: 1px solid var(--bad); color: #ffb3b3; border-radius: 8px; padding: 10px; }

/* layout: fixed sidebar + content */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--side); border-right: 1px solid var(--line); padding: 16px 10px 12px;
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; padding: 0 6px; }
.brand img { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); }
.sidebar .brand { margin-bottom: 18px; }
#nav { flex: 1; overflow-y: auto; }
.nav-group { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin: 14px 0 6px 10px; }
.nav-group:first-child { margin-top: 0; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; margin-bottom: 2px; }
#nav a .ti { font-size: 18px; }
#nav a:hover { background: var(--panel); color: var(--text); }
#nav a.active { background: #5865f22e; color: #c9cdfb; }
.nav-badge { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.me { display: flex; align-items: center; gap: 8px; padding: 10px 6px 0; border-top: 1px solid var(--line); margin-top: 8px; }
.me img { width: 30px; height: 30px; border-radius: 50%; background: var(--panel2); }
.me span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; font-size: 13px; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 4px; border-radius: 6px; }
.icon-btn:hover { color: #fff; background: var(--panel2); }
.mobilebar { display: none; }
.menu-btn { background: none; border: 0; color: var(--text); font-size: 22px; cursor: pointer; }
.content { flex: 1; padding: 24px 28px; max-width: 1180px; min-width: 0; }

/* overview: banner, tiles, module cards */
.banner { background: var(--accent); border-radius: 14px; padding: 18px; display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.banner-icon { width: 56px; height: 56px; border-radius: 16px; background: #ffffff33; display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.banner-icon img { width: 100%; height: 100%; object-fit: cover; }
.banner-icon .ti { font-size: 28px; color: #fff; }
.banner-text { flex: 1; min-width: 0; }
.banner-title { color: #fff; font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.banner-sub { color: #e0e3ff; font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dot-online { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px #57f28733; }
.banner-btn { background: #ffffff26; color: #fff; border-radius: 8px; padding: 8px 14px; text-decoration: none; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.banner-btn:hover { background: #ffffff40; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.tile-label { color: var(--muted); font-size: 12px; }
.tile-value { color: #fff; font-size: 26px; font-weight: 700; line-height: 1.2; margin: 2px 0; }
.tile-sub { color: var(--muted); font-size: 12px; }
.tile-sub.good { color: var(--good); } .tile-sub.warn { color: #fee75c; }
.section-title { color: #fff; font-weight: 700; font-size: 15px; margin: 4px 0 10px; }
.modules { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.module { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; cursor: pointer; transition: border-color .15s, transform .15s; }
.module:hover { border-color: #3f4147; transform: translateY(-1px); }
.module-top { display: flex; justify-content: space-between; align-items: center; }
.module-icon { width: 36px; height: 36px; border-radius: 10px; background: #5865f22e; color: #a5acf7; display: grid; place-items: center; font-size: 20px; }
.module.off .module-icon { background: var(--panel2); color: var(--faint); }
.module-name { color: #fff; font-weight: 600; margin-top: 10px; }
.module-sub { color: var(--muted); font-size: 12px; }
.switch { width: 36px; height: 20px; border-radius: 999px; background: #3f4147; border: 0; position: relative; cursor: pointer; padding: 0; transition: background .15s; }
.switch span { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--ok); }
.switch.on span { left: 19px; }
.callout { display: flex; gap: 12px; align-items: flex-start; border-color: #5865f266; }
.callout > .ti { font-size: 22px; color: #a5acf7; }
.skeleton div { height: 90px; border-radius: 12px; margin-bottom: 14px; background: linear-gradient(90deg, var(--panel) 0%, var(--panel2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton div:first-child { height: 92px; background-color: var(--accent); opacity: .35; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.page { animation: fadein .15s ease-out; }
@keyframes fadein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.audit-row { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.audit-row:first-child { border-top: 0; }
.audit-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--panel2); flex-shrink: 0; }
.audit-main { flex: 1; min-width: 0; }
.audit-main b { color: #fff; }
.audit-action { color: var(--text); word-wrap: break-word; }
.audit-details { color: var(--muted); font-size: 12px; white-space: pre-wrap; word-wrap: break-word; background: var(--bg); border-radius: 6px; padding: 6px 8px; margin-top: 4px; }
.audit-time { text-align: right; color: var(--muted); font-size: 12px; white-space: nowrap; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

/* cards, grid */
.card { background: var(--panel); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; border: 1px solid var(--line); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat b { display: block; font-size: 26px; color: #fff; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }

/* forms */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin-bottom: 5px; }
input[type=text], input[type=number], input:not([type]), select, textarea {
  width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
select[multiple] { min-height: 130px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--accent2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ok { background: var(--ok); } .btn-ok:hover { background: #1a8f4c; }
.btn-bad { background: var(--bad); } .btn-bad:hover { background: #b52c30; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); } .btn-ghost:hover { background: var(--panel2); }
.btn-small { padding: 4px 10px; font-size: 12px; }
.btn-discord { background: #5865f2; padding: 12px 22px; font-size: 15px; margin-top: 8px; }

/* tables / lists */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; font-weight: 600; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--panel2); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--panel2); color: var(--text); }
.badge.ok { background: #23a55a33; color: #6be09a; } .badge.bad { background: #da373c33; color: #ff9a9d; } .badge.warn { background: #f0b23233; color: #ffd27a; } .badge.blue { background: #5865f244; color: #c9cdfb; }
.empty { color: var(--muted); padding: 16px 0; }
.item { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; background: var(--panel2); }
.qa { margin-bottom: 14px; }
.qa b { display: block; color: #fff; margin-bottom: 3px; }
.qa div { white-space: pre-wrap; word-wrap: break-word; background: var(--bg); padding: 8px 10px; border-radius: 6px; }
.item-row { display: grid; grid-template-columns: 1.4fr 1fr .7fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }

/* click-to-pick chips */
.picker { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.picker-search { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow-y: auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel2); color: var(--text); font: inherit; font-size: 13px; cursor: pointer; user-select: none; }
.chip:hover { border-color: var(--muted); }
.chip i { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on::after { content: "✓"; font-weight: 700; }
.picker-foot { font-size: 12px; color: var(--muted); margin-top: 6px; }
button.link { background: none; border: 0; padding: 0; color: #00a8fc; font: inherit; cursor: pointer; }

/* permissions */
.perm { border-top: 1px solid var(--line); padding: 12px 0; }
.perm:first-of-type { border-top: 0; }
.perm-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.perm-roles { margin-top: 10px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { background: var(--bg); color: var(--text); border: 0; border-left: 1px solid var(--line); padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.seg-btn:first-child { border-left: 0; }
.seg-btn.on { background: var(--accent); color: #fff; }
.seg-btn.on .muted { color: #e0e3ff; }
.bulk { background: var(--panel2); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.savebar { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; box-shadow: 0 -6px 20px #0006; }
.warn-text { color: var(--warn) !important; font-weight: 600; }

/* modal & toast */
.modal-backdrop { position: fixed; inset: 0; background: #000a; display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 720px; max-height: 90vh; overflow-y: auto; padding: 22px; border: 1px solid var(--line); }
.toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--panel2); border-left: 4px solid var(--ok); padding: 10px 14px; border-radius: 6px; box-shadow: 0 4px 16px #0008; max-width: 360px; white-space: pre-wrap; }
.toast.bad { border-color: var(--bad); }

@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
  .mobilebar { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; padding: 10px 16px; background: var(--side); border-bottom: 1px solid var(--line); }
  .mobilebar .brand { padding: 0; }
  .mobilebar .brand img { width: 28px; height: 28px; }
  .layout { min-height: calc(100vh - 53px); }
  .sidebar { position: fixed; top: 53px; height: calc(100vh - 53px); left: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar .brand { display: none; }
  .sidebar.open { transform: none; box-shadow: 8px 0 30px #000a; }
  .content { padding: 16px; }
  .banner { flex-wrap: wrap; }
  .banner-btn { width: 100%; justify-content: center; }
  .item-row { grid-template-columns: 1fr 1fr; }
}
