/* ==========================================================================
   Arcade admin — dark back office
   ========================================================================== */

.viz-root {
  color-scheme: dark;
  --surface-1: #12121f;          /* chart surface (validated against palette) */
  --series-1: #9085e9;           /* single-series bars */
  --cat-2: #199e70;
  --cat-3: #c98500;
  --cat-4: #d55181;
  --text-primary: #ececfa;
  --text-secondary: #9494b8;
  --text-muted: #6b6b8f;
}

:root {
  --bg: #0a0a12;
  --panel: #12121f;
  --panel-2: #191929;
  --line: #26263f;
  --text: #ececfa;
  --muted: #9494b8;
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; }

/* The hidden attribute must win over the layout rules below. Author styles
   beat the browser's own `[hidden] { display: none }`, so `.gate { display:
   grid }` would otherwise keep the login card on screen after signing in,
   pushing the dashboard below the fold. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { letter-spacing: -.3px; }

/* --- Login gate ------------------------------------------------------------ */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px;
        background: radial-gradient(700px 400px at 50% 0%, rgba(236,72,153,.16), transparent 60%); }
.gate-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px;
  text-align: center;
}
.gate-logo {
  width: 54px; height: 54px; margin: 0 auto 14px;
  border-radius: 16px; display: grid; place-items: center; font-size: 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.gate-card h1 { margin: 0 0 6px; font-size: 23px; }
.gate-card p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.gate-card .field { text-align: left; }
.back { display: block; margin-top: 16px; color: var(--muted); font-size: 13px; }
.back:hover { color: var(--text); }

/* --- Shell ---------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }

.side {
  background: #0d0d18;
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 700; padding: 4px 8px 16px; }
.side-brand .mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-size: 17px;
}
.side-brand b { background: linear-gradient(135deg, var(--accent), var(--accent-2));
                -webkit-background-clip: text; background-clip: text; color: transparent; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 10px 12px;
  border: 0; background: transparent; color: var(--muted);
  border-radius: 10px; font: 600 14px inherit; cursor: pointer; text-align: left;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.on { background: var(--panel-2); color: #fff; box-shadow: inset 0 0 0 1px var(--line); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.who { display: flex; align-items: center; gap: 9px; padding: 10px 12px; background: var(--panel);
       border: 1px solid var(--line); border-radius: 10px; font-size: 13.5px; font-weight: 600; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
          background: var(--accent-2); font-size: 12px; font-weight: 800; }
.ghost-btn {
  display: block; text-align: center; padding: 9px; border-radius: 9px;
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  font: 600 13px inherit; cursor: pointer;
}
.ghost-btn:hover { background: var(--panel); color: var(--text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 24px;
  background: rgba(10,10,18,.86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.bar h1 { margin: 0; font-size: 20px; }
.spacer { flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600;
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--bad); animation: blip 1.4s infinite; }
@keyframes blip { 50% { opacity: .25 } }
.body { padding: 24px; }

/* --- Buttons / forms ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 15px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
  font: 600 13.5px inherit; cursor: pointer;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: #4a2130; }
.btn.danger:hover { background: #2a1119; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn.wide { width: 100%; justify-content: center; height: 44px; font-size: 15px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.field .hint { color: var(--text-muted); font-weight: 400; }
.field input, .field textarea, .field select {
  width: 100%; border-radius: 10px; padding: 10px 12px;
  background: #0e0e1a; border: 1px solid var(--line); color: var(--text);
  font: inherit; font-size: 14px; outline: none; resize: vertical;
}
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,92,246,.16);
}
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-bottom: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

.checks { display: flex; flex-wrap: wrap; gap: 7px; }
.checks label {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: #0e0e1a;
  font-size: 13px; cursor: pointer; color: var(--muted);
}
.checks label:has(input:checked) { border-color: var(--accent); color: var(--text); background: rgba(139,92,246,.14); }
.checks input { accent-color: var(--accent); }

.toggles { display: flex; gap: 20px; margin: 6px 0 14px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.switch input { display: none; }
.switch span {
  width: 40px; height: 22px; border-radius: 999px; background: #2a2a44;
  position: relative; transition: background .16s;
}
.switch span::after {
  content: ''; position: absolute; left: 3px; top: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .16s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

/* --- Cards / tables --------------------------------------------------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.card > h2 { margin: 0 0 4px; font-size: 16px; }
.card > .sub { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.tile .k { font-size: 11.5px; letter-spacing: 1.1px; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; }
.tile .v { font-size: 30px; font-weight: 800; letter-spacing: -1px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile .d { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.tile.good .v { color: var(--good); }
.tile.live .v { color: var(--bad); }
.tile.accent .v { color: var(--series-1); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: var(--text-secondary); font-weight: 700; }
tbody tr:hover { background: #15152a; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.rowacts { display: flex; gap: 6px; justify-content: flex-end; }

.chip {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; border: 1px solid var(--line); color: var(--muted);
}
.chip.on { background: rgba(52,211,153,.14); color: var(--good); border-color: rgba(52,211,153,.3); }
.chip.off { background: rgba(148,148,184,.1); }
.chip.multi { background: rgba(239,68,68,.14); color: #fca5a5; border-color: rgba(239,68,68,.3); }
.chip.ban { background: rgba(248,113,113,.14); color: var(--bad); border-color: rgba(248,113,113,.3); }
.chip.admin { background: rgba(236,72,153,.16); color: #f9a8d4; border-color: rgba(236,72,153,.3); }

.thumb-mini { width: 42px; height: 42px; border-radius: 9px; overflow: hidden; flex: 0 0 auto; }
.thumb-mini svg { width: 100%; height: 100%; display: block; }
.gname { display: flex; align-items: center; gap: 11px; }
.gname b { display: block; font-size: 14px; }
.gname span { font-size: 12px; color: var(--muted); }

/* --- Chart ------------------------------------------------------------------ */
.chart { width: 100%; height: 190px; display: block; overflow: visible; }
.chart .grid-line { stroke: #23233c; stroke-width: 1; }
.chart .axis-text { fill: var(--text-secondary); font-size: 10.5px; }
.chart .bar { fill: var(--series-1); transition: fill .12s; }
.chart .bar-hit:hover + .bar, .chart .bar:hover { fill: #b3a9ff; }
.chart .val-label { fill: var(--text-primary); font-size: 10.5px; font-weight: 700; }
.tip {
  position: fixed; z-index: 90; pointer-events: none;
  background: #1c1c30; border: 1px solid #33334f; border-radius: 9px;
  padding: 7px 11px; font-size: 12.5px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
  opacity: 0; transition: opacity .1s;
}
.tip.show { opacity: 1; }
.tip b { display: block; font-size: 14px; }

.barlist { display: flex; flex-direction: column; gap: 10px; }
.barlist .row { display: grid; grid-template-columns: 1fr 46px; align-items: center; gap: 10px; font-size: 13.5px; }
.barlist .track { height: 8px; background: #1e1e33; border-radius: 999px; overflow: hidden; margin-top: 5px; }
.barlist .fill { height: 100%; border-radius: 999px; background: var(--series-1); }
.barlist .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

.feed { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; }
.feed .ev { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 13px; }
.feed .ev .t { color: var(--text-muted); font-size: 11.5px; margin-left: auto; white-space: nowrap; }
.dotk { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dotk.play { background: var(--series-1); }
.dotk.score { background: var(--cat-2); }
.dotk.login, .dotk.register { background: var(--cat-3); }
.dotk.admin { background: var(--cat-4); }
.dotk.chat { background: #6b7280; }
.dotk.connect { background: var(--good); }
.dotk.disconnect { background: #6b7280; }

.empty { color: var(--muted); font-size: 13.5px; padding: 18px 6px; text-align: center; }

/* --- Modal ------------------------------------------------------------------ */
/* --- Ads + traffic ---------------------------------------------------------- */
.code-area {
  width: 100%;
  min-height: 110px;
  border-radius: 10px;
  padding: 11px 12px;
  background: #08080f;
  border: 1px solid var(--line);
  color: #b9f6ca;
  font: 12.5px/1.55 ui-monospace, "Cascadia Code", Consolas, monospace;
  outline: none;
  resize: vertical;
  white-space: pre;
  overflow-x: auto;
}
.code-area:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139, 92, 246, .16); }
.code-area::placeholder { color: #40405c; }

.slot-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; }
.slot-head b { font-size: 14px; }
.slot-head span { font-size: 12.5px; color: var(--text-secondary); }
.slot-head .len { margin-left: auto; font-size: 11.5px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.slot { margin-bottom: 20px; }

.hint-box {
  background: rgba(139, 92, 246, .10);
  border: 1px solid rgba(139, 92, 246, .28);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 13px;
  line-height: 1.65;
  color: #c9c9e6;
  margin-bottom: 18px;
}
.hint-box b { color: #fff; }
.hint-box code {
  background: #0c0c16; border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 6px; font-size: 12px; color: #b9f6ca;
}

.score-bar {
  display: inline-block; width: 54px; height: 7px; border-radius: 99px;
  background: #23233c; overflow: hidden; vertical-align: middle; margin-right: 8px;
}
.score-bar i { display: block; height: 100%; border-radius: 99px; }

.ip-mono { font: 12.5px ui-monospace, Consolas, monospace; }
.ua-cell {
  max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-muted); font-size: 12px;
}
.seg { display: flex; gap: 6px; }
.seg button {
  border: 1px solid var(--line); background: var(--panel); color: var(--muted);
  border-radius: 8px; padding: 6px 12px; font: 600 12.5px inherit; cursor: pointer;
}
.seg button.on { background: var(--accent); border-color: transparent; color: #fff; }

.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4,4,10,.74); backdrop-filter: blur(5px);
  display: grid; place-items: center; padding: 20px; overflow-y: auto;
}
.modal[hidden] { display: none; }
.sheet {
  width: min(420px, 100%);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 24px;
  max-height: 92vh; overflow-y: auto;
}
.wide-sheet { width: min(640px, 100%); }
.sheet h2 { margin: 0 0 16px; font-size: 19px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 11px 20px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-brand { padding: 0 8px 0 0; }
  .side nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
  .nav-item { width: auto; }
  .nav-item span { display: none; }
  .side-foot { flex-direction: row; margin: 0; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .body { padding: 16px; }
}
