:root {
  --bg-0: #1e1f22;
  --bg-1: #2b2d31;
  --bg-2: #313338;
  --bg-3: #383a40;
  --bg-hover: #404249;
  --border: #3f4147;
  --text: #dbdee1;
  --text-strong: #f2f3f5;
  --muted: #949ba4;
  --blurple: #5865f2;
  --blurple-hover: #4752c4;
  --green: #23a559;
  --yellow: #f0b232;
  --red: #da373c;
  --red-hover: #a12828;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg-2); -webkit-font-smoothing: antialiased; }
a { color: #00a8fc; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.hidden { display: none !important; }
.boot { display: grid; place-items: center; height: 100%; color: var(--muted); }

/* Shell */
.app { height: 100%; }
.layout { display: grid; grid-template-columns: 232px 1fr; height: 100%; }
.sidebar { background: var(--bg-1); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 12px 8px; gap: 2px; overflow-y: auto; }
.brand { padding: 8px 12px 14px; font-weight: 800; letter-spacing: -0.02em; color: var(--text-strong); font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand small { font-weight: 500; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.nav-section { padding: 14px 12px 4px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 4px; color: var(--muted); font-weight: 500; cursor: pointer; }
.nav-item:hover { background: var(--bg-3); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--bg-hover); color: var(--text-strong); }
.nav-item .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blurple); display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }
.who { min-width: 0; flex: 1; }
.who .name { font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .sub { color: var(--muted); font-size: 12px; }
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 24px; height: 52px; border-bottom: 1px solid var(--border); background: var(--bg-2); }
.topbar h1 { font-size: 16px; margin: 0; font-weight: 700; color: var(--text-strong); }
.topbar .spacer { flex: 1; }
.content { padding: 20px 24px 40px; overflow-y: auto; flex: 1; }
.banner { padding: 10px 24px; font-weight: 500; }
.banner.info { background: rgba(88,101,242,.25); }
.banner.warning { background: rgba(240,178,50,.25); }
.banner.danger { background: rgba(218,55,60,.3); }

/* Login */
.login-wrap { min-height: 100%; display: grid; place-items: center; background: radial-gradient(900px 500px at 50% -10%, rgba(88,101,242,.25), transparent 70%), var(--bg-2); }
.login { width: 400px; background: var(--bg-1); border-radius: var(--radius); padding: 28px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.login h1 { margin: 0 0 4px; font-size: 22px; color: var(--text-strong); }
.login p.sub { margin: 0 0 20px; color: var(--muted); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .02em; }
.input, select.input, textarea.input { background: var(--bg-0); border: 1px solid transparent; border-radius: 4px; padding: 9px 10px; color: var(--text-strong); outline: none; width: 100%; }
.input:focus { border-color: var(--blurple); }
textarea.input { min-height: 84px; resize: vertical; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .field { flex: 1; margin-bottom: 0; min-width: 140px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px 16px; }
.err { color: #fa777c; font-size: 12px; min-height: 16px; }
.help { color: var(--muted); font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.check input { width: 16px; height: 16px; accent-color: var(--blurple); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 4px; padding: 8px 14px; font-weight: 600; cursor: pointer; background: var(--bg-3); color: var(--text-strong); white-space: nowrap; }
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--blurple); color: #fff; }
.btn.primary:hover { background: var(--blurple-hover); }
.btn.danger { background: var(--red); color: #fff; }
.btn.danger:hover { background: var(--red-hover); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--bg-3); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; justify-content: center; }

/* Cards, stats */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.card { background: var(--bg-1); border-radius: var(--radius); padding: 14px 16px; }
.card .label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.card .value { font-size: 26px; font-weight: 800; color: var(--text-strong); margin-top: 6px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.panel { background: var(--bg-1); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; }
.panel h3 { margin: 16px 0 8px; font-size: 13px; color: var(--text-strong); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar .input { width: 320px; }
.toolbar .spacer { flex: 1; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--bg-3); color: var(--text); }
.pill.green { background: rgba(35,165,89,.25); color: #57f287; }
.pill.red { background: rgba(218,55,60,.25); color: #fa777c; }
.pill.yellow { background: rgba(240,178,50,.25); color: #ffd166; }
.pill.blurple { background: rgba(88,101,242,.3); color: #c9cdfb; }
.badge { background: var(--red); color: #fff; border-radius: 8px; padding: 0 6px; font-size: 11px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--bg-3); border-radius: 4px; padding: 3px 8px; font-size: 12.5px; }
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0; }
.chip button:hover { color: #fa777c; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tr.clickable { cursor: pointer; }
td .avatar { display: inline-grid; vertical-align: middle; margin-right: 8px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.empty { padding: 24px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; color: var(--muted); }

/* Detail layout */
.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.detail-head .avatar { width: 56px; height: 56px; font-size: 22px; }
.detail-head h2 { margin: 0; font-size: 20px; color: var(--text-strong); }
.detail-head .sub { color: var(--muted); }
.detail-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { padding: 8px 12px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font-weight: 600; }
.tab.active { color: var(--text-strong); border-bottom-color: var(--blurple); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text-strong); word-break: break-all; }
pre.json { background: var(--bg-0); border-radius: 4px; padding: 10px; overflow: auto; max-height: 320px; margin: 0; font-family: var(--mono); font-size: 12px; line-height: 1.45; }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1000px) { .two, .diff, .grid3 { grid-template-columns: 1fr; } .grid2 { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .layout { grid-template-columns: 1fr; } .sidebar { display: none; } }

/* Modal, toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; z-index: 50; }
.modal { width: 480px; max-width: 94vw; background: var(--bg-2); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.5); }
.modal .mh { padding: 16px 16px 0; font-size: 18px; font-weight: 700; color: var(--text-strong); }
.modal .mb { padding: 12px 16px; }
.modal .mf { padding: 12px 16px; background: var(--bg-1); border-radius: 0 0 var(--radius) var(--radius); display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--bg-0); border-left: 3px solid var(--blurple); padding: 10px 14px; border-radius: 4px; box-shadow: 0 6px 16px rgba(0,0,0,.4); max-width: 380px; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.secret { font-family: var(--mono); background: var(--bg-0); padding: 10px; border-radius: 4px; word-break: break-all; user-select: all; }
