:root {
  --bg: #111214;
  --panel: #1b1c1f;
  --panel-2: #232428;
  --border: #2e3035;
  --text: #e8e9eb;
  --muted: #949ba4;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --good: #23a55a;
  --warn: #f0b232;
  --bad: #da373c;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
p { margin: 0 0 .8em; }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 4px; }
a { color: #8ea1ff; }
.muted { color: var(--muted); }
.center-text { text-align: center; margin-top: 4em; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.narrow { max-width: 440px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.logo { color: var(--accent); }
.tabs { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 8px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
.tabs button:hover { color: var(--text); background: var(--panel-2); }
.tabs button.active { color: var(--text); background: var(--panel-2); font-weight: 600; }
.me { display: flex; align-items: center; gap: 8px; margin-left: auto; }

main { max-width: 1150px; margin: 0 auto; padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.card + .card, .grid + .card, .card + .grid { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.stat .num { font-size: 28px; font-weight: 700; }
.stat .label { color: var(--muted); }

label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 10px 0 4px; font-weight: 600; }
input, select, textarea { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.row { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.row > .shrink { flex: 0 0 auto; }

.btn { display: inline-block; text-decoration: none; background: var(--accent); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #a12828; }
.btn.good { background: var(--good); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user img, .avatar-ph { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 32px; background: var(--panel-2); }
.user .names { min-width: 0; }
.user .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user .sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); color: var(--muted); }
.badge.good { background: rgba(35,165,90,.15); color: #57d08a; }
.badge.warn { background: rgba(240,178,50,.15); color: var(--warn); }
.badge.bad { background: rgba(218,55,60,.15); color: #f07175; }

.results { margin-top: 6px; border: 1px solid var(--border); border-radius: 6px; max-height: 260px; overflow-y: auto; }
.results:empty { display: none; }
.results button { display: block; width: 100%; background: none; border: 0; border-bottom: 1px solid var(--border); color: inherit; padding: 6px 10px; text-align: left; cursor: pointer; font: inherit; }
.results button:last-child { border-bottom: 0; }
.results button:hover { background: var(--panel-2); }

.selected { margin-top: 12px; padding: 12px; border-radius: 8px; background: var(--panel-2); }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; gap: 8px; }

.gw { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--panel-2); }
.gw + .gw { margin-top: 10px; }
.gw-head { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.gw-title { font-weight: 700; font-size: 15px; }
.gw-meta { color: var(--muted); font-size: 13px; margin: 4px 0 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.bonus-row { display: flex; gap: 8px; margin-top: 6px; }
.bonus-row select { flex: 1; } .bonus-row input { width: 90px; flex: 0 0 90px; }

.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 14px; border-radius: 6px; cursor: pointer; font: inherit; }
.seg button.active { background: var(--accent); color: #fff; font-weight: 600; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--panel-2); border: 1px solid var(--border); border-left: 4px solid var(--good); padding: 10px 14px; border-radius: 8px; max-width: 380px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast.error { border-left-color: var(--bad); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; width: min(640px, 94vw); max-height: 85vh; }
dialog::backdrop { background: rgba(0,0,0,.6); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.empty { color: var(--muted); padding: 12px 0; }
