:root {
  --bg: #0b1020;
  --bg2: #101834;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-solid: #151d3a;
  --panel-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.09);
  --text: #eef2fb;
  --muted: #8b94b0;
  --sky: #38bdf8;
  --green: #34d399;
  --red: #fb7185;
  --amber: #fbbf24;
  --violet: #a78bfa;
  --accent: linear-gradient(135deg, #38bdf8, #6366f1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(56, 189, 248, 0.14), transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- icons ---------- */
svg.ic {
  width: 18px; height: 18px;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  fill: none; flex: none;
}
.ic-xl { width: 44px; height: 44px; opacity: .5; }

/* ---------- buttons ---------- */
button { font: inherit; }
.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  border: 1px solid var(--border); border-radius: 11px;
  padding: .55rem .95rem; font-weight: 600; font-size: .9rem;
  cursor: pointer; color: var(--text); background: var(--panel);
  transition: transform .06s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-hover); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); border: none; color: #fff; box-shadow: 0 6px 18px rgba(99, 102, 241, .35); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: rgba(251, 113, 133, .14); border-color: rgba(251, 113, 133, .35); color: var(--red); }
.btn-danger:hover { background: rgba(251, 113, 133, .22); }
.btn-warn { background: rgba(251, 191, 36, .12); border-color: rgba(251, 191, 36, .3); color: var(--amber); }
.btn-warn:hover { background: rgba(251, 191, 36, .2); }
.btn-accent { background: rgba(56, 189, 248, .13); border-color: rgba(56, 189, 248, .35); color: var(--sky); }
.btn-accent:hover { background: rgba(56, 189, 248, .22); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--panel-hover); }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  border-radius: 9px; width: 34px; height: 34px; display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer; flex: none;
}
.icon-btn:hover { color: var(--text); background: var(--panel-hover); }
.icon-btn.danger:hover { color: var(--red); }

.select {
  background: var(--panel-solid); color: var(--text); border: 1px solid var(--border);
  border-radius: 11px; padding: .55rem .8rem; font: inherit; font-size: .9rem;
}

/* ---------- login ---------- */
.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 1rem; position: relative; overflow: hidden;
}
.login-glow {
  position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(99, 102, 241, .35), transparent 65%);
  filter: blur(40px); animation: pulse 6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: .7; transform: scale(1); } 50% { opacity: 1; transform: scale(1.08); } }
.login-card {
  position: relative; width: 380px; max-width: 100%;
  background: rgba(21, 29, 58, .75); backdrop-filter: blur(18px);
  border: 1px solid var(--border); border-radius: 22px; padding: 2rem;
  box-shadow: var(--shadow); animation: rise .4s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.login-logo { display: flex; align-items: center; gap: .8rem; margin-bottom: 1.4rem; }
.login-logo svg { width: 46px; height: 46px; color: var(--sky); }
.login-logo h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; }
.login-logo p { margin: .1rem 0 0; color: var(--muted); font-size: .8rem; }
.login-card form { display: flex; flex-direction: column; gap: .9rem; }
.login-foot { color: var(--muted); font-size: .75rem; text-align: center; margin: 1rem 0 0; }

.fld { display: flex; flex-direction: column; gap: .35rem; }
.fld span { font-size: .8rem; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="password"] {
  background: rgba(11, 16, 32, .7); border: 1px solid var(--border); color: var(--text);
  padding: .7rem .85rem; border-radius: 11px; font: inherit; font-size: .95rem;
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(56, 189, 248, .18); }
.error-text { color: var(--red); font-size: .85rem; text-align: center; min-height: 1.1rem; }

/* ---------- layout ---------- */
#main-view { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: none; display: flex; flex-direction: column; gap: 1.2rem;
  padding: 1.2rem 1rem; position: sticky; top: 0; height: 100vh;
  background: rgba(13, 18, 40, .55); backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; }
.brand svg { width: 30px; height: 30px; color: var(--sky); }
.nav { display: flex; flex-direction: column; gap: .35rem; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .7rem; width: 100%;
  background: transparent; border: 1px solid transparent; color: var(--muted);
  padding: .65rem .8rem; border-radius: 11px; font-weight: 600; font-size: .92rem;
  cursor: pointer; text-align: left; transition: all .15s ease;
}
.nav-item:hover { color: var(--text); background: var(--panel); }
.nav-item.active { color: var(--text); background: var(--accent); border-color: transparent; box-shadow: 0 6px 18px rgba(99, 102, 241, .3); }
.nav-item.active .badge { background: rgba(255,255,255,.2); color: #fff; }
.badge {
  background: var(--red); color: #fff; border-radius: 999px; padding: .08rem .5rem;
  font-size: .72rem; font-weight: 700; margin-left: auto;
}
.sidebar-foot { display: flex; flex-direction: column; gap: .6rem; }
.net { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .8rem; }
.net-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 0 rgba(251,191,36,.6); }
.net.live .net-dot { background: var(--green); box-shadow: 0 0 0 0 rgba(52,211,153,.6); animation: ping 1.8s infinite; }
.net.down .net-dot { background: var(--red); }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.5); } 100% { box-shadow: 0 0 0 9px rgba(52,211,153,0); } }

.mobile-bar { display: none; }

.content { flex: 1; padding: 1.2rem 1.5rem 3rem; min-width: 0; }
main { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 1.1rem; }
.tab-panel { display: none; animation: rise .3s ease; }
.tab-panel.active { display: block; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .9rem; }
.stat {
  display: flex; align-items: center; gap: .8rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; backdrop-filter: blur(8px);
}
.stat-ic {
  width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex: none;
}
.t-sky { background: rgba(56,189,248,.15); color: var(--sky); }
.t-green { background: rgba(52,211,153,.15); color: var(--green); }
.t-red { background: rgba(251,113,133,.15); color: var(--red); }
.t-amber { background: rgba(251,191,36,.15); color: var(--amber); }
.stat b { display: block; font-size: 1.35rem; letter-spacing: -.02em; line-height: 1.1; }
.stat span:last-child { color: var(--muted); font-size: .78rem; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.toolbar .all { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .9rem; cursor: pointer; user-select: none; }
.toolbar input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--sky); }
.spacer { flex: 1; }
.sel-count { color: var(--sky); font-size: .8rem; font-weight: 700; }
.hint { color: var(--muted); font-size: .8rem; }

/* ---------- device grid ---------- */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .85rem; }
.device-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem; display: flex; flex-direction: column; gap: .55rem;
  cursor: pointer; backdrop-filter: blur(8px); position: relative;
  transition: border-color .15s ease, transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.device-card:hover { border-color: rgba(56,189,248,.4); transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.device-card.selected { border-color: var(--sky); background: linear-gradient(160deg, rgba(56,189,248,.12), rgba(99,102,241,.1)); }
.device-card .row { display: flex; align-items: center; gap: .55rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: .85rem;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 8px rgba(52,211,153,.7); }
.dot.off { background: var(--red); }
.device-card .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-card .meta { font-size: .76rem; color: var(--muted); display: flex; flex-direction: column; gap: .15rem; }
.metric-chips { display: flex; gap: .35rem; flex-wrap: wrap; }
.chip {
  font-size: .7rem; font-weight: 700; padding: .15rem .45rem; border-radius: 999px;
  background: var(--panel-hover); border: 1px solid var(--border); color: var(--muted);
}
.chip.cpu { color: var(--amber); }
.chip.ram { color: var(--sky); }
.card-actions { display: none; position: absolute; top: .6rem; right: .6rem; gap: .3rem; }
.device-card:hover .card-actions { display: flex; }
.device-card .thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 10px; background: #000; border: 1px solid var(--border); }

/* monitor grid */
.monitor-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.monitor-grid .device-card { cursor: default; }

/* ---------- empty state ---------- */
.empty {
  text-align: center; color: var(--muted); padding: 3.5rem 1rem;
  background: var(--panel); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty p { margin: .4rem 0; }
.empty p.sub { font-size: .82rem; }

/* ---------- install list ---------- */
.install-list { display: flex; flex-direction: column; gap: .65rem; }
.install-item {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .95rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  backdrop-filter: blur(8px); animation: rise .3s ease;
}
.install-item.pending { border-left: 3px solid var(--amber); }
.install-item.approved { border-left: 3px solid var(--green); opacity: .75; }
.install-item.denied { border-left: 3px solid var(--red); opacity: .75; }
.install-icon {
  width: 40px; height: 40px; border-radius: 11px; flex: none; display: flex;
  align-items: center; justify-content: center; font-size: 1.1rem;
  background: var(--panel-hover);
}
.install-info { flex: 1; min-width: 200px; }
.install-info .app { font-weight: 700; }
.install-info .info { color: var(--muted); font-size: .78rem; margin-top: .15rem; }
.install-status { font-size: .78rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; }
.install-status.pending { background: rgba(251,191,36,.13); color: var(--amber); }
.install-status.approved { background: rgba(52,211,153,.13); color: var(--green); }
.install-status.denied { background: rgba(251,113,133,.13); color: var(--red); }
.install-actions { display: flex; gap: .5rem; }

/* ---------- settings ---------- */
.setting-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.4rem; Max-width: 640px; backdrop-filter: blur(8px);
}
.setting-head h2 { margin: 0 0 .3rem; font-size: 1.1rem; }
.setting-head p { margin: 0 0 1rem; color: var(--muted); font-size: .9rem; line-height: 1.5; }

/* ---------- modal ---------- */
.modal-wrap {
  position: fixed; inset: 0; background: rgba(5, 8, 18, .7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 60; animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(440px, 92vw); background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: 20px; padding: 1.4rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 1rem;
  animation: rise .3s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 1.15rem; }
.modal form { display: flex; flex-direction: column; gap: .85rem; }
.token-box {
  display: flex; flex-direction: column; gap: .6rem; background: rgba(11,16,32,.7);
  border: 1px solid var(--border); border-radius: 12px; padding: .9rem;
}
.token-box code { font-family: "JetBrains Mono", Consolas, monospace; color: var(--sky);
  word-break: break-all; font-size: .85rem; line-height: 1.4; }
.token-row { display: flex; gap: .5rem; align-items: center; }
.success-box { display: flex; align-items: center; gap: .6rem; color: var(--green); font-weight: 700; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 1.4rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel-solid); border: 1px solid var(--border); color: var(--text);
  padding: .8rem 1.3rem; border-radius: 14px; font-size: .9rem; font-weight: 600;
  box-shadow: var(--shadow); z-index: 100; opacity: 0; pointer-events: none;
  transition: all .25s ease; display: flex; align-items: center; gap: .5rem;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(251,113,133,.5); color: var(--red); }
.toast.ok { border-color: rgba(52,211,153,.5); color: var(--green); }

/* ---------- remote control ---------- */
.remote-card {
  width: min(1300px, 96vw); height: min(88vh, 860px); background: var(--panel-solid);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden; animation: rise .3s ease;
}
.remote-head { display: flex; align-items: center; gap: .8rem; padding: .8rem 1.2rem;
  border-bottom: 1px solid var(--border); }
.remote-name { font-weight: 700; font-size: 1rem; }
.remote-quick { display: flex; align-items: center; gap: .45rem; padding: .6rem 1.2rem;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.remote-screen {
  position: relative; flex: 1; display: flex; align-items: center; justify-content: center;
  background: #04060c; overflow: hidden; cursor: crosshair; outline: none;
}
.remote-screen img {
  max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; pointer-events: none;
}
.remote-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .6rem; color: var(--muted); }
.remote-placeholder p { margin: 0; }
.remote-badge {
  position: absolute; top: .5rem; right: .5rem; z-index: 5;
  background: rgba(251,113,133,.2); color: var(--red); border: 1px solid rgba(251,113,133,.45);
  padding: .2rem .5rem; border-radius: 8px; font-size: .65rem; font-weight: 700;
  backdrop-filter: blur(4px);
}
.device-card.remote-active { border-color: rgba(251,113,133,.6); box-shadow: 0 0 0 1px rgba(251,113,133,.4); }
.remote-screen.remote-pan { cursor: grab; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; }
  .mobile-bar {
    display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem;
    position: sticky; top: 0; z-index: 40; background: rgba(11,16,32,.9); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .mobile-bar .brand { margin-right: auto; }
  .mobile-bar .tabs { display: flex; gap: .2rem; }
  .mobile-bar .tab {
    background: transparent; border: none; color: var(--muted); font-weight: 600;
    padding: .45rem .7rem; border-radius: 9px; cursor: pointer;
  }
  .mobile-bar .tab.active { color: var(--text); background: var(--panel); }
  .content { padding: 1rem; }
  .stats { grid-template-columns: 1fr 1fr; }
}