:root {
  --bg: #090b10;
  --panel: rgba(20, 23, 32, 0.78);
  --panel-solid: #14171f;
  --panel-2: rgba(255, 255, 255, 0.035);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #eceef5;
  --muted: #8a91a5;
  --faint: #5b6275;
  --accent: #6f7cff;
  --accent-2: #a07bff;
  --accent-soft: rgba(111, 124, 255, 0.14);
  --gradient: linear-gradient(135deg, #6f7cff, #a07bff);
  --green: #3fcf8e;
  --amber: #f2b552;
  --red: #f2555a;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 32px rgba(0, 0, 0, 0.32);
  font-family: Inter, 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body::before {
  content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(111, 124, 255, 0.16), transparent 70%),
    radial-gradient(760px 480px at 100% 0%, rgba(160, 123, 255, 0.11), transparent 70%),
    radial-gradient(900px 600px at 60% 120%, rgba(63, 207, 142, 0.05), transparent 70%);
}
a { color: #a9b1ff; text-decoration: none; }
a:hover { color: #c7ccff; }
code, .mono { font-family: 'Cascadia Code', 'JetBrains Mono', Consolas, monospace; font-size: 12px; }
h1 { font-size: 24px; margin: 0; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 14px; margin: 0 0 14px; font-weight: 600; letter-spacing: -0.005em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
::selection { background: rgba(111, 124, 255, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.08); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, 0.16); }

/* Layout */
.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }
.sidebar { background: rgba(12, 14, 20, 0.7); backdrop-filter: blur(18px); border-right: 1px solid var(--border); padding: 20px 14px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand .dot { width: 32px; height: 32px; border-radius: 10px; background: var(--gradient); display: grid; place-items: center; font-size: 15px; font-weight: 800; color: #fff; box-shadow: 0 6px 20px rgba(111, 124, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 9px; color: var(--muted); font-weight: 500; transition: background 0.15s, color 0.15s; }
.nav a:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: #fff; }
.nav a.active::before { content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gradient); }
.nav a.active .ico { color: #b3baff; }
.ico { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav .sep { margin: 16px 10px 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint); font-weight: 600; }
.sidebar .me { margin-top: auto; padding: 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sidebar .me form { margin-left: auto; }
.main { padding: 30px 36px 64px; min-width: 0; max-width: 1480px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500; color: var(--muted); padding: 5px 12px 5px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel-2); }
.status-pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); display: inline-block; }
.status-pill.on i { background: var(--green); box-shadow: 0 0 0 3px rgba(63, 207, 142, 0.18), 0 0 10px rgba(63, 207, 142, 0.6); }

/* Cards */
.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; min-width: 0; box-shadow: var(--shadow); backdrop-filter: blur(10px); }
.card.flush { padding: 0; overflow: hidden; }
.card.flush h2 { padding: 18px 20px 4px; }
.stat { overflow: hidden; }
.stat::after { content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(circle, rgba(111, 124, 255, 0.16), transparent 70%); pointer-events: none; }
.grid > .stat:nth-child(2)::after { background: radial-gradient(circle, rgba(63, 207, 142, 0.14), transparent 70%); }
.grid > .stat:nth-child(3)::after { background: radial-gradient(circle, rgba(160, 123, 255, 0.16), transparent 70%); }
.grid > .stat:nth-child(4)::after { background: radial-gradient(circle, rgba(242, 181, 82, 0.13), transparent 70%); }
.stat .label { color: var(--muted); font-size: 12px; font-weight: 500; display: flex; justify-content: space-between; align-items: center; }
.stat .value { font-size: 32px; font-weight: 700; margin-top: 8px; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.section { margin-top: 18px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 20px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--faint); font-weight: 600; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 36px; text-align: center; color: var(--faint); }

.person { display: flex; align-items: center; gap: 11px; min-width: 180px; color: var(--text); }
.person:hover .n { color: #c7ccff; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #262b3a, #1b1f2a); flex: none; object-fit: cover; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.05); }
.avatar.lg { width: 64px; height: 64px; }
.person .n { font-weight: 600; transition: color 0.12s; }
.person .u { font-size: 11.5px; color: var(--faint); }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; background: rgba(255, 255, 255, 0.05); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.support, .badge.active, .badge.open, .badge.keep, .badge.removed-ok, .badge.met { background: rgba(63, 207, 142, 0.12); color: #6ee0aa; border-color: rgba(63, 207, 142, 0.28); }
.badge.lead_support { background: rgba(56, 189, 248, 0.12); color: #7dd3fc; border-color: rgba(56, 189, 248, 0.28); }
.badge.moderator, .badge.grace, .badge.flagged { background: rgba(242, 181, 82, 0.12); color: #f6c97a; border-color: rgba(242, 181, 82, 0.28); }
.badge.admin, .badge.manager, .badge.former, .badge.left, .badge.deleted, .badge.remove, .badge.failed, .badge.missed, .badge.removed { background: rgba(242, 85, 90, 0.12); color: #ff8f93; border-color: rgba(242, 85, 90, 0.28); }
.badge.developer { background: rgba(160, 123, 255, 0.14); color: #c9b3ff; border-color: rgba(160, 123, 255, 0.3); }
.badge.closed, .badge.none, .badge.higher, .badge.exempt { color: var(--muted); }

/* Progress and chart */
.progress { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar { width: 90px; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, #f2b552, #f7cf7f); border-radius: 99px; }
.bar.done > span { background: linear-gradient(90deg, #2fb57a, #5be3a5); }

.chart { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; height: 100%; justify-content: flex-end; }
.chart .b { width: 100%; max-width: 34px; background: linear-gradient(180deg, #a07bff, #6f7cff 70%, rgba(111, 124, 255, 0.55)); border-radius: 8px 8px 3px 3px; min-height: 3px; box-shadow: 0 8px 22px rgba(111, 124, 255, 0.22); transition: filter 0.15s, transform 0.15s; }
.chart .col:hover .b { filter: brightness(1.2); transform: translateY(-2px); }
.chart .col:last-child .b { background: linear-gradient(180deg, #7ef0bd, #3fcf8e 70%, rgba(63, 207, 142, 0.55)); box-shadow: 0 8px 22px rgba(63, 207, 142, 0.25); }
.chart .v { font-size: 11px; font-weight: 600; color: var(--text); }
.chart .l { font-size: 10px; color: var(--faint); white-space: nowrap; }

/* Forms */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border-strong); background: rgba(255, 255, 255, 0.04); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s, filter 0.15s; }
.btn:hover { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.btn.primary { background: var(--gradient); border-color: transparent; color: #fff; font-weight: 600; box-shadow: 0 6px 18px rgba(111, 124, 255, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: rgba(242, 85, 90, 0.1); border-color: rgba(242, 85, 90, 0.35); color: #ff8f93; }
.btn.danger:hover { background: rgba(242, 85, 90, 0.18); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 8px; }
.btn.icon { padding: 2px 8px; font-size: 12px; color: var(--muted); background: transparent; border-color: transparent; }
.btn.icon:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
input, select, textarea { background: rgba(0, 0, 0, 0.28); color: var(--text); border: 1px solid var(--border-strong); border-radius: 9px; padding: 8px 11px; font: inherit; width: 100%; transition: border-color 0.15s, box-shadow 0.15s; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: rgba(255, 255, 255, 0.2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(111, 124, 255, 0.2); }
select option { background: var(--panel-solid); }
select[multiple] { min-height: 120px; }
input[type='checkbox'] { accent-color: var(--accent); width: 16px; height: 16px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field { margin-bottom: 14px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > input, .inline > select { width: auto; }
.inline-select { width: auto; padding: 4px 8px; font-size: 12px; }
.check { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 14px; }
.check input { width: 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; }
.toolbar input[type='search'] { width: 260px; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: 18px; flex-wrap: wrap; border-radius: 12px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); }
.tabs a { padding: 6px 14px; color: var(--muted); border-radius: 8px; font-weight: 500; transition: background 0.15s, color 0.15s; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: #fff; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(111, 124, 255, 0.3); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 20px; }
.notice { padding: 12px 16px; border-radius: 11px; background: rgba(242, 181, 82, 0.08); border: 1px solid rgba(242, 181, 82, 0.25); color: #f6c97a; margin-bottom: 18px; }
.notice.info { background: rgba(111, 124, 255, 0.08); border-color: rgba(111, 124, 255, 0.25); color: #b3baff; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 9px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; justify-content: space-between; }
.timeline li:last-child { border-bottom: none; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
pre.json { white-space: pre-wrap; word-break: break-word; margin: 0; max-width: 380px; max-height: 120px; overflow: auto; color: var(--muted); }

/* Developer switches (Settings) */
.dev-card h2 { display: flex; align-items: center; gap: 10px; }
.switch-row { display: flex; align-items: center; gap: 14px; padding: 10px 0; margin: 0; color: var(--text); font-size: 14px; cursor: pointer; }
.switch-row + .switch-row { border-top: 1px solid var(--border); }
.switch { position: relative; flex: none; width: 42px; height: 24px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: rgba(255, 255, 255, 0.12); transition: background 0.15s; pointer-events: none; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px rgba(111, 124, 255, 0.35); }

/* Users page */
.role-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: rgba(255, 255, 255, 0.04); color: var(--muted); white-space: nowrap; }
.role-badge.owner { background: linear-gradient(135deg, rgba(111, 124, 255, 0.22), rgba(160, 123, 255, 0.22)); border-color: rgba(160, 123, 255, 0.45); color: #d4c6ff; }
.role-badge.admin { background: rgba(242, 85, 90, 0.12); border-color: rgba(242, 85, 90, 0.3); color: #ff8f93; }
.role-badge.editor { background: rgba(242, 181, 82, 0.12); border-color: rgba(242, 181, 82, 0.3); color: #f6c97a; }
.you { font-size: 11px; color: var(--faint); margin-left: 6px; font-weight: 500; }
.legend { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.legend > div { padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px; background: rgba(255, 255, 255, 0.02); }
.legend p { margin: 8px 0 0; font-size: 12px; color: var(--muted); }

/* Dialog & toasts */
dialog { background: var(--panel-solid); color: var(--text); border: 1px solid var(--border-strong); border-radius: 16px; padding: 0; width: min(440px, 92vw); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); }
dialog[open] { animation: pop 0.16s ease-out; }
dialog::backdrop { background: rgba(4, 5, 9, 0.65); backdrop-filter: blur(4px); }
dialog form { padding: 22px; }
dialog h3 { margin: 0 0 4px; font-size: 16px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel-solid); border: 1px solid var(--border-strong); padding: 11px 16px 11px 14px; border-radius: 11px; box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45); max-width: 380px; display: flex; gap: 10px; align-items: center; animation: slide 0.2s ease-out; }
.toast::before { content: ''; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--green); box-shadow: 0 0 10px var(--green); }
.toast.error::before { background: var(--red); box-shadow: 0 0 10px var(--red); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* Login and error pages */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; position: relative; overflow: hidden; }
.login::before, .login::after { content: ''; position: absolute; border-radius: 50%; filter: blur(70px); pointer-events: none; }
.login::before { width: 520px; height: 520px; left: calc(50% - 420px); top: calc(50% - 380px); background: rgba(111, 124, 255, 0.28); animation: float 14s ease-in-out infinite alternate; }
.login::after { width: 440px; height: 440px; left: calc(50% - 20px); top: calc(50% - 60px); background: rgba(160, 123, 255, 0.2); animation: float 18s ease-in-out infinite alternate-reverse; }
@keyframes float { from { transform: translate(0, 0); } to { transform: translate(40px, 30px); } }
.login .card { width: min(380px, 100%); text-align: center; padding: 38px 32px 32px; background: rgba(18, 21, 29, 0.72); backdrop-filter: blur(20px); border-color: var(--border-strong); z-index: 1; }
.login .brand { flex-direction: column; gap: 14px; padding: 0 0 6px; font-size: 20px; }
.login .brand .dot { width: 54px; height: 54px; border-radius: 16px; font-size: 24px; }
.login h1 { font-size: 20px; }
.login p { margin: 6px 0 0; }
.login .notice { margin: 18px 0 0; text-align: left; }
.btn.discord { background: #5865f2; border-color: transparent; color: #fff; padding: 12px 18px; width: 100%; justify-content: center; gap: 10px; font-weight: 600; margin-top: 24px; border-radius: 11px; box-shadow: 0 8px 24px rgba(88, 101, 242, 0.35); }
.btn.discord:hover { background: #6773f4; }
.btn.discord svg { width: 20px; height: 20px; fill: currentColor; }
.login .actions { display: flex; gap: 8px; justify-content: center; margin-top: 22px; }

/* Responsive */
@media (max-width: 1100px) {
  .grid.cols-4, .legend { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 6px; border-right: none; border-bottom: 1px solid var(--border); }
  .brand { padding: 4px 8px; }
  .brand small { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 2px; width: 100%; order: 3; }
  .nav a { padding: 6px 10px; }
  .nav a .ico { display: none; }
  .nav a.active::before { display: none; }
  .nav .sep { display: none; }
  .sidebar .me { margin: 0 0 0 auto; padding: 4px 4px 4px 8px; }
  .main { padding: 20px 16px 50px; }
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .toolbar input[type='search'] { width: 100%; }
}
@media (max-width: 520px) { .legend { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
