:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --border: #e3e5ec;
  --text: #1f2330;
  --muted: #6b7183;
  --accent: #5865f2;
  --accent-soft: #e6e8fd;
  --green: #23a55a;
  --red: #da373c;
  --amber: #c98a00;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171c;
    --surface: #1e2027;
    --border: #2c2f38;
    --text: #e8e9ee;
    --muted: #9599a8;
    --accent: #7983f5;
    --accent-soft: #2a2e4d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { margin: 0 0 4px; font-size: 1.6rem; }
h2 { margin: 0 0 14px; font-size: 1.05rem; }
h2 + * { margin-top: 0; }
section h2:not(:first-child) { margin-top: 26px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px max(16px, calc((100% - 1120px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
nav { display: flex; align-items: center; gap: 18px; }
nav a { color: var(--muted); }
nav a:hover { color: var(--text); text-decoration: none; }

.container { max-width: 1120px; margin: 0 auto; padding: 24px 16px 40px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  min-width: 0;
}
.center { text-align: center; padding: 48px 20px; }

.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff !important;
  font-weight: 600;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }

.hero { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.hero .muted { margin-left: 8px; }

.status { font-weight: 600; }
.status.online { color: var(--green); }
.status.offline { color: var(--red); }
.status.unknown { color: var(--amber); }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid.wide-left { grid-template-columns: 2fr 1fr; }

.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--border); }
.list .row { padding: 10px 0; }
.list.compact .row { padding: 7px 0; }
a.row { color: var(--text); }
a.row:hover { text-decoration: none; background: var(--accent-soft); border-radius: 10px; }

.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 1.4rem; padding-right: 6px; }

.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar.sm { width: 26px; height: 26px; }
.avatar.lg { width: 72px; height: 72px; }
.avatar.placeholder {
  display: inline-grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
}
.avatar.lg.placeholder { font-size: 1.4rem; }

.muted { color: var(--muted); }
.small { font-size: .82rem; font-weight: 400; }

.badge {
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  flex: none;
}
.badge.join { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.badge.leave { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.bars li { display: grid; grid-template-columns: minmax(80px, 130px) 1fr auto; align-items: center; gap: 10px; }
.bar-label { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; }
.bar-value { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.bar { display: block; height: 8px; background: var(--accent-soft); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: .8rem; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.rank { font-weight: 700; color: var(--muted); }
.rank.r1 { color: #d4a017; }
.rank.r2 { color: #9aa3ad; }
.rank.r3 { color: #b8733e; }

.footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px 32px;
  color: var(--muted);
  font-size: .85rem;
}

@media (max-width: 820px) {
  .grid, .grid.wide-left { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
  .hero { flex-direction: column; text-align: center; }
  .hero .muted { display: block; margin: 4px 0 0; }
}
