:root {
  --bg: #0f1117;
  --panel: #171a23;
  --panel2: #1e2230;
  --line: #2a2f42;
  --text: #e6e8ef;
  --muted: #8b91a7;
  --accent: #5865f2;
  --good: #3ecf8e;
  --warn: #f5a524;
  --bad: #ef5b5b;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; }
.hidden { display: none !important; }
a { color: var(--accent); }

.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 40px; width: min(420px, 92vw); text-align: center; }
.login-card h1 { margin: 0 0 8px; }
.login-card p { color: var(--muted); }

.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 16px 12px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 17px; padding: 4px 10px 16px; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
nav button { all: unset; cursor: pointer; padding: 9px 12px; border-radius: 8px; color: var(--muted); }
nav button:hover { background: var(--panel2); color: var(--text); }
nav button.active { background: var(--accent); color: #fff; }
.me { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.me img { width: 34px; height: 34px; border-radius: 50%; }
.me .name { font-weight: 600; }
.me .roles { color: var(--muted); font-size: 12px; }
.me button { margin-left: auto; }

main { padding: 20px 28px; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.topbar h2 { margin: 0; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.stat .num { font-size: 28px; font-weight: 700; }
.muted { color: var(--muted); }
.error { color: var(--bad); }

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-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; }

.btn { all: unset; cursor: pointer; background: var(--panel2); border: 1px solid var(--line); padding: 7px 12px; border-radius: 8px; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #1b1300; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.big { padding: 12px 22px; display: inline-block; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%; }
textarea { min-height: 80px; resize: vertical; }
label { display: block; margin: 10px 0 4px; color: var(--muted); font-size: 12px; }
.search { max-width: 460px; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel2); border: 1px solid var(--line); }
.pill.good { color: var(--good); border-color: var(--good); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.bad { color: var(--bad); border-color: var(--bad); }
.pill.accent { color: var(--accent); border-color: var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { all: unset; cursor: pointer; padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }

.trust-head { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.trust-score { font-size: 38px; font-weight: 800; }
.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; flex: 1; border: 1px solid var(--line); }
.bar > div { height: 100%; }
.delta.pos { color: var(--good); }
.delta.neg { color: var(--bad); }

.entry { border-bottom: 1px solid var(--line); padding: 10px 0; }
.entry:last-child { border-bottom: 0; }
.entry .meta { color: var(--muted); font-size: 12px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; z-index: 10; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(460px, 100%); }
.modal.wide { width: min(980px, 100%); max-height: 92vh; overflow-y: auto; }
.modal h3 { margin: 0 0 6px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid var(--good); padding: 12px 16px; border-radius: 8px; z-index: 20; max-width: 360px; }
.toast.err { border-left-color: var(--bad); }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  nav { flex-direction: row; flex-wrap: wrap; }
}
