:root {
  --bg: #080b10;
  --bg-elev: #0e141d;
  --panel: #111a25;
  --panel-2: #0d151f;
  --line: rgba(146, 173, 205, 0.12);
  --line-strong: rgba(146, 173, 205, 0.22);
  --text: #e9f0f8;
  --muted: #7f95ad;
  --muted-2: #5d738c;
  --primary: #a6ff5c;
  --primary-dim: #7ecb3f;
  --ink: #0a0e13;
  --cyan: #56dcff;
  --danger: #ff6a5e;
  --warn: #ffbf4d;
  --ok: #4ee59b;
  --radius: 16px;
  --radius-sm: 10px;
  --font: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- background decoration ---------- */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(146,173,205,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(146,173,205,0.04) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000 40%, transparent 100%);
}
.bg-glow {
  position: fixed; z-index: 0; pointer-events: none;
  top: -260px; left: 50%; transform: translateX(-50%);
  width: 900px; height: 620px;
  background: radial-gradient(circle at 50% 50%, rgba(166,255,92,0.16), transparent 62%);
  filter: blur(20px);
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font);
  font-weight: 600;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--line-strong); background: #16202d; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: var(--primary); color: var(--ink); border-color: transparent;
  box-shadow: 0 6px 22px -8px rgba(166,255,92,.6);
}
.btn-primary:hover { background: #b6ff77; }
.btn-cyan { background: var(--cyan); color: var(--ink); border-color: transparent; }
.btn-cyan:hover { background: #74e6ff; }
.btn-warn { background: var(--warn); color: var(--ink); border-color: transparent; }
.btn-warn:hover { background: #ffca6b; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-danger:hover { background: #ff8177; }
.btn-ghost { background: transparent; }
.btn-lg { padding: 14px 18px; font-size: 16px; width: 100%; }
.btn-sm { padding: 9px 15px; font-size: 13px; }
.btn-mini { padding: 6px 12px; font-size: 12px; border-radius: 8px; }

/* ---------- connect gate ---------- */
.gate {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 32px 20px;
}
.gate-card {
  width: 100%; max-width: 440px;
  background: linear-gradient(180deg, rgba(19,28,40,.92), rgba(13,21,31,.92));
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 32px 26px;
  backdrop-filter: blur(12px);
  box-shadow: 0 40px 80px -40px rgba(0,0,0,.8);
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center;
  background: var(--primary); color: var(--ink);
  box-shadow: 0 8px 24px -8px rgba(166,255,92,.7);
}
.brand h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.brand h1 span { color: var(--primary); }
.tagline { color: var(--muted); font-size: 13px; letter-spacing: .18em; text-transform: uppercase; margin-top: 2px; }

.conn-form { display: grid; grid-template-columns: 1fr 120px; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field-full, .remember, #connect-btn, .gate-error { grid-column: 1 / -1; }
.field span { font-size: 12px; color: var(--muted); font-weight: 500; letter-spacing: .04em; }
.field input, .cmd-bar input, .composer input {
  font-family: var(--mono);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 13px;
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
  width: 100%;
}
.field input:focus, .cmd-bar input:focus, .composer input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(166,255,92,.14);
}
.remember { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; cursor: pointer; margin-top: 2px; }
.remember input { accent-color: var(--primary); width: 16px; height: 16px; }
.gate-error { color: var(--danger); font-size: 13px; min-height: 4px; font-family: var(--mono); }
.gate-error:not(:empty) { margin-top: -4px; }
.gate-hint { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.gate-hint code { color: var(--cyan); font-family: var(--mono); }
.gate-hint pre {
  font-family: var(--mono); font-size: 12px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 14px; margin-top: 10px; line-height: 1.7;
}

/* ---------- dashboard ---------- */
.dash { position: relative; z-index: 1; max-width: 1240px; margin: 0 auto; padding: 22px 22px 40px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 20px; margin-bottom: 18px;
  background: linear-gradient(180deg, rgba(19,28,40,.85), rgba(13,21,31,.7));
  border: 1px solid var(--line); border-radius: var(--radius);
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.status-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 4px rgba(78,229,155,.16); flex: none;
  animation: pulse 2.2s ease-in-out infinite;
}
.status-dot.stale { background: var(--warn); box-shadow: 0 0 0 4px rgba(255,191,77,.16); }
.status-dot.down { background: var(--danger); box-shadow: 0 0 0 4px rgba(255,106,94,.16); animation: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.server-id { min-width: 0; }
.server-id h2 { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.server-id p { color: var(--muted); font-size: 12.5px; font-family: var(--mono); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-stat { display: flex; align-items: baseline; gap: 6px; }
.ts-num { font-size: 22px; font-weight: 700; color: var(--primary); font-family: var(--mono); }
.ts-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }

.auto-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.auto-toggle input { display: none; }
.auto-toggle .track {
  width: 40px; height: 22px; border-radius: 999px; background: var(--panel-2);
  border: 1px solid var(--line-strong); position: relative; transition: background .2s ease;
}
.auto-toggle .thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted); transition: transform .2s ease, background .2s ease;
}
.auto-toggle input:checked + .track { background: rgba(166,255,92,.2); border-color: var(--primary); }
.auto-toggle input:checked + .track .thumb { transform: translateX(18px); background: var(--primary); }
.auto-label { font-size: 12.5px; color: var(--muted); }

/* stat tiles */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: flex; align-items: center; gap: 15px;
  transition: border-color .2s ease, transform .2s ease;
}
.stat-tile:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; flex: none; background: var(--panel-2); position: relative; }
.stat-icon::after {
  content: ''; position: absolute; inset: 0; background: currentColor;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: center; mask-position: center; -webkit-mask-size: 22px; mask-size: 22px;
}
.stat-icon.players { color: var(--primary); }
.stat-icon.players::after { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M23 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75'/%3E%3C/svg%3E"); }
.stat-icon.signal { color: var(--cyan); }
.stat-icon.signal::after { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='6' y1='20' x2='6' y2='14'/%3E%3Cline x1='12' y1='20' x2='12' y2='10'/%3E%3Cline x1='18' y1='20' x2='18' y2='4'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='6' y1='20' x2='6' y2='14'/%3E%3Cline x1='12' y1='20' x2='12' y2='10'/%3E%3Cline x1='18' y1='20' x2='18' y2='4'/%3E%3C/svg%3E"); }
.stat-icon.tag { color: var(--warn); }
.stat-icon.tag::after { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z'/%3E%3Cline x1='7' y1='7' x2='7.01' y2='7'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z'/%3E%3Cline x1='7' y1='7' x2='7.01' y2='7'/%3E%3C/svg%3E"); }
.stat-icon.clock { color: var(--ok); }
.stat-icon.clock::after { -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E"); mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E"); }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-num { font-size: 26px; font-weight: 700; font-family: var(--mono); line-height: 1.1; }
.stat-num.small { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-cap { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* grid */
.grid { display: grid; grid-template-columns: 380px 1fr; gap: 18px; align-items: start; }
.col-left { display: flex; flex-direction: column; gap: 18px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.panel-head h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.badge {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  background: rgba(166,255,92,.14); color: var(--primary);
  padding: 2px 9px; border-radius: 999px;
}

/* players */
.players-list { max-height: 560px; overflow-y: auto; padding: 8px; }
.player-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px; transition: background .15s ease;
}
.player-item:hover { background: var(--panel-2); }
.player-avatar {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  background: linear-gradient(135deg, rgba(166,255,92,.25), rgba(86,220,255,.25)); color: var(--text);
}
.player-info { min-width: 0; flex: 1; }
.player-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-id { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-actions { display: flex; gap: 6px; opacity: 0; transition: opacity .15s ease; }
.player-item:hover .player-actions { opacity: 1; }
.pa-btn {
  font-family: var(--font); font-size: 11px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--bg-elev); color: var(--muted);
  padding: 5px 9px; border-radius: 7px; transition: all .15s ease;
}
.pa-btn.kick:hover { color: var(--warn); border-color: var(--warn); }
.pa-btn.ban:hover { color: var(--danger); border-color: var(--danger); }
.empty { text-align: center; color: var(--muted); font-size: 13px; padding: 40px 20px; }

/* command reference */
.players-list { max-height: 340px; }
.ref-hint { font-size: 11px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .1em; }
.ref-list { padding: 8px; max-height: 380px; overflow-y: auto; }
.ref-item {
  width: 100%; text-align: left; cursor: pointer; display: block;
  background: transparent; border: 1px solid transparent; border-radius: 11px;
  padding: 10px 12px; transition: background .15s ease, border-color .15s ease;
  font-family: var(--font);
}
.ref-item:hover { background: var(--panel-2); border-color: var(--line-strong); }
.ref-item .ref-sig { font-family: var(--mono); font-size: 13px; color: var(--text); }
.ref-item .ref-sig .arg { color: var(--warn); }
.ref-item:hover .ref-sig .cmd { color: var(--primary); }
.ref-item .ref-desc { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.ref-item.danger:hover { border-color: rgba(255,106,94,.4); }
.ref-item.danger:hover .ref-sig .cmd { color: var(--danger); }

/* console */
.console-panel { display: flex; flex-direction: column; }
.quick-row { display: flex; gap: 9px; padding: 14px 18px 0; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); font-size: 12.5px; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text);
  padding: 7px 13px; border-radius: 999px; transition: all .15s ease;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.composers { display: flex; flex-direction: column; gap: 9px; padding: 14px 18px 0; }
.composer { display: flex; gap: 9px; }
.composer .secs { width: 74px; flex: none; text-align: center; }
.composer input { flex: 1; }
.composer .btn { flex: none; }

.log {
  margin: 16px 18px; padding: 14px 16px; flex: 1;
  background: #060a0f; border: 1px solid var(--line); border-radius: 12px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6;
  height: 320px; overflow-y: auto;
}
.log-entry { margin-bottom: 12px; }
.log-entry:last-child { margin-bottom: 0; }
.log-cmd { color: var(--primary); }
.log-cmd .arrow { color: var(--muted); margin-right: 6px; }
.log-ts { color: var(--muted-2); font-size: 11px; float: right; }
.log-out { color: #c6d4e3; white-space: pre-wrap; word-break: break-word; margin-top: 4px; }
.log-out.err { color: var(--danger); }
.log-out.sys { color: var(--cyan); }
.log-placeholder { color: var(--muted); }

.cmd-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-top: 1px solid var(--line);
}
.cmd-bar .prompt { color: var(--primary); font-family: var(--mono); font-size: 18px; font-weight: 700; }
.cmd-bar input { flex: 1; }

/* toasts */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 50; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--bg-elev); border: 1px solid var(--line-strong); border-left-width: 3px;
  border-radius: 10px; padding: 12px 16px; font-size: 13.5px; min-width: 240px; max-width: 360px;
  box-shadow: 0 20px 40px -20px rgba(0,0,0,.8);
  animation: slidein .25s ease; color: var(--text);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--cyan); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* modal */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(4,7,11,.7); backdrop-filter: blur(4px); }
.modal-card { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 18px; padding: 26px; max-width: 400px; width: calc(100% - 40px); }
.modal-card h4 { font-size: 18px; margin-bottom: 10px; }
.modal-card p { color: var(--muted); font-size: 14px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: padding-box; }

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .conn-form { grid-template-columns: 1fr; }
  .topbar-right { width: 100%; justify-content: space-between; }
}
