:root {
  --bg: #170a40;
  --ground: #24125e;
  --card: #2c1870;
  --line: #3e2a8c;
  --text: #ffffff;
  --muted: #b9aee6;
  --sun: #ffd23f;
  --pink: #ff4f8b;
  --sky: #29c5f6;
  --mint: #19b37d;
  --red: #ff6b6b;
  --amber: #ffb347;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1em; }
code, .mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12px; }

.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--ground); border: 1px solid var(--line); border-radius: 16px; padding: 16px; margin-bottom: 16px; min-width: 0; }
.card h2 { margin: 0 0 12px; font-size: 15px; color: var(--sun); letter-spacing: .3px; }
.login { width: min(380px, 100%); text-align: center; }
.login h1 { margin-top: 0; }

.btn { border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; cursor: pointer; color: var(--text); background: var(--card); }
.btn.primary { background: var(--sun); color: #1a0e40; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn:hover { filter: brightness(1.1); }

header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--ground); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 800; font-size: 18px; }
.brand span { color: var(--sun); }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav button { background: transparent; color: var(--muted); border: 0; padding: 8px 12px; border-radius: 10px; font-weight: 700; cursor: pointer; }
nav button.active { background: var(--card); color: var(--text); }
.user { display: flex; gap: 10px; align-items: center; color: var(--muted); }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.grid2 .card { margin-bottom: 0; }
.grid2 + .card, .grid2 + .grid2 { margin-top: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--ground); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.kpi .v { font-size: 26px; font-weight: 800; }
.kpi .l { color: var(--muted); font-size: 12px; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.empty { color: var(--muted); padding: 8px 0; }
.link { color: var(--sky); cursor: pointer; text-decoration: underline dotted; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--card); }
.pill.ranked { background: var(--sky); color: #1a0e40; }
.pill.room { background: var(--pink); color: #1a0e40; }
.pill.bot { background: var(--amber); color: #1a0e40; }
.pill.win { background: var(--mint); color: #1a0e40; }
.pill.loss { background: var(--red); color: #1a0e40; }
.pill.on { background: var(--mint); color: #1a0e40; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
input, select { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.filters input { flex: 1 1 200px; }
.toggle { display: flex; gap: 6px; align-items: center; color: var(--muted); }

.log { display: grid; grid-template-columns: 150px 52px 1fr; gap: 10px; padding: 6px 4px; border-bottom: 1px solid var(--line); font-size: 12px; }
.log .t { color: var(--muted); font-family: ui-monospace, Consolas, monospace; }
.log .lv { font-weight: 800; text-transform: uppercase; font-size: 11px; }
.log.warn { background: rgba(255, 179, 71, .07); } .log.warn .lv { color: var(--amber); }
.log.error { background: rgba(255, 107, 107, .1); } .log.error .lv { color: var(--red); }
.log.info .lv { color: var(--sky); } .log.debug .lv { color: var(--muted); }
.log .m { font-weight: 700; }
.log .d { color: var(--muted); word-break: break-word; font-family: ui-monospace, Consolas, monospace; }
.log.new { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(255, 210, 63, .25); } }

.bar { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.bar .fill { height: 10px; background: var(--sky); border-radius: 6px; }
.bar .name { width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--ground); border-left: 1px solid var(--line); z-index: 20; overflow-y: auto; padding: 16px 20px; box-shadow: -20px 0 40px rgba(0, 0, 0, .4); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 12px 0 20px; }
.kv div:nth-child(odd) { color: var(--muted); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 30; }

@media (max-width: 640px) {
  main { padding: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .log { grid-template-columns: 1fr; gap: 2px; }
}
