:root {
  --bg: #0d1117;
  --bg-2: #10151c;
  --panel: #161c24;
  --panel-2: #1c242e;
  --line: #262f3b;
  --line-2: #313c4a;
  --text: #e8edf3;
  --muted: #8b98a8;
  --muted-2: #5f6b7a;
  --accent: #2f81f7;
  --accent-2: #1f6feb;
  --green: #2ea043;
  --green-l: #3fb950;
  --amber: #d29922;
  --red: #e5484d;
  --shadow: 0 8px 30px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 70% -10%, #16202c 0%, var(--bg) 55%);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font: inherit; color: inherit; }
input { font: inherit; }

.logo-mark {
  width: 18px; height: 18px; border-radius: 5px; display: inline-block;
  background: linear-gradient(135deg, var(--accent), #7ee787);
  box-shadow: 0 0 0 3px rgba(47,129,247,.15);
}

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; gap: 18px; align-content: center; }
.login-card {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  padding: 34px; border-radius: 16px; width: 340px;
  display: flex; flex-direction: column; gap: 14px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.login-card .logo { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.login-card .sub { margin: -6px 0 6px; color: var(--muted); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.login-card input {
  padding: 11px 12px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--bg); color: var(--text); outline: none; transition: border-color .15s;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button {
  margin-top: 6px; padding: 12px; border-radius: 9px; border: 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 600;
  transition: filter .15s;
}
.login-card button:hover { filter: brightness(1.08); }
.error { color: #ff8a8d; margin: 2px 0 0; font-size: 13px; }
.foot-note { color: var(--muted-2); font-size: 12px; }

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 12px 20px;
  background: rgba(16,21,28,.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .2px; }
.conn { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12.5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted-2); transition: background .2s; }
.dot.on { background: var(--green-l); box-shadow: 0 0 0 3px rgba(63,185,80,.18); }
.dot.off { background: var(--red); box-shadow: 0 0 0 3px rgba(229,72,77,.18); }

.search { position: relative; display: flex; align-items: center; }
.search-ico { width: 15px; height: 15px; position: absolute; left: 10px; color: var(--muted-2); }
.search input {
  background: var(--bg); border: 1px solid var(--line-2); color: var(--text);
  padding: 8px 12px 8px 32px; border-radius: 9px; width: 210px; outline: none; transition: border-color .15s, width .2s;
}
.search input:focus { border-color: var(--accent); width: 250px; }

.filters { display: flex; gap: 6px; }
.pill {
  background: transparent; border: 1px solid var(--line-2); color: var(--muted);
  padding: 7px 12px; border-radius: 20px; font-size: 12.5px; transition: .15s; display: flex; gap: 6px; align-items: center;
}
.pill span { background: var(--panel-2); padding: 0 7px; border-radius: 10px; font-size: 11px; color: var(--muted); }
.pill:hover { border-color: var(--line-2); color: var(--text); }
.pill.active { background: rgba(47,129,247,.12); border-color: var(--accent); color: #cfe3ff; }
.pill.active span { background: var(--accent); color: #fff; }
.spacer { flex: 1; }
.ghost {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-2);
  padding: 8px 13px; border-radius: 9px; transition: .15s;
}
.ghost:hover { background: var(--panel-2); border-color: var(--line-2); }
.ghost.sm { padding: 5px 10px; font-size: 13px; }

/* ===== Grid ===== */
.grid {
  display: grid; gap: 18px; padding: 22px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  overflow: hidden; transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { border-color: var(--line-2); }
.card.online:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.card .thumb {
  aspect-ratio: 16 / 9; background: #05070a center/cover no-repeat;
  display: grid; place-items: center; position: relative; overflow: hidden;
}
.card.online .thumb { cursor: pointer; }
.card.offline .thumb { filter: grayscale(1) brightness(.35); }
.thumb-empty { color: var(--muted-2); font-size: 12px; letter-spacing: .3px; }
.card .badge {
  position: absolute; top: 9px; left: 9px; padding: 4px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; background: rgba(5,7,10,.72); backdrop-filter: blur(4px);
  display: flex; align-items: center; gap: 5px;
}
.badge .bdot { width: 7px; height: 7px; border-radius: 50%; }
.badge.on { color: #8ff0a4; } .badge.on .bdot { background: var(--green-l); animation: pulse 1.8s infinite; }
.badge.off { color: #ff9d9d; } .badge.off .bdot { background: var(--red); }
.badge.busy { color: #ffd479; } .badge.busy .bdot { background: var(--amber); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(63,185,80,.5); } 50% { box-shadow: 0 0 0 5px rgba(63,185,80,0); } }

.thumb .play {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(5,7,10,.35); opacity: 0; transition: opacity .15s; color: #fff; font-weight: 600; gap: 8px;
}
.card.online .thumb:hover .play { opacity: 1; }
.play-ico {
  width: 46px; height: 46px; border-radius: 50%; background: rgba(47,129,247,.92);
  display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.play-ico::after { content: ""; border-left: 15px solid #fff; border-top: 9px solid transparent; border-bottom: 9px solid transparent; margin-left: 4px; }

.card .meta { padding: 11px 13px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .seen { color: var(--muted-2); font-size: 11.5px; white-space: nowrap; }
.card .os { color: var(--muted); font-size: 11.5px; }

/* ===== Empty ===== */
.empty { text-align: center; color: var(--muted); margin: 80px auto; max-width: 360px; }
.empty h3 { color: var(--text); margin: 14px 0 6px; }
.empty-ico { width: 56px; height: 56px; margin: 0 auto; border-radius: 14px; border: 2px dashed var(--line-2); }

/* ===== Live ===== */
.live-overlay {
  position: fixed; inset: 0; background: rgba(3,5,8,.9); backdrop-filter: blur(6px);
  display: grid; place-items: center; z-index: 20; padding: 24px; animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.live-box {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px;
  max-width: 96vw; max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow);
}
.live-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.live-rec { width: 9px; height: 9px; border-radius: 50%; background: var(--red); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.live-head #live-title { font-weight: 600; }
.live-state { color: var(--muted); font-size: 12.5px; padding: 2px 8px; border-radius: 12px; background: var(--panel-2); }
.live-state.on { color: #8ff0a4; background: rgba(63,185,80,.12); }
.live-stats { color: var(--muted-2); font-size: 12px; }
.live-actions { margin-left: auto; display: flex; gap: 8px; }
.live-stage { position: relative; background: #000; display: grid; place-items: center; }
#live-video { max-width: 92vw; max-height: 80vh; display: block; }
.live-loader { position: absolute; inset: 0; display: grid; place-items: center; gap: 12px; color: var(--muted); align-content: center; }
.spinner { width: 34px; height: 34px; border: 3px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toasts ===== */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 40; }
.toast {
  background: var(--panel); border: 1px solid var(--line-2); border-left: 3px solid var(--accent);
  padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px;
  display: flex; align-items: center; gap: 9px; animation: slideIn .2s; max-width: 300px;
}
.toast.on { border-left-color: var(--green-l); }
.toast.off { border-left-color: var(--red); }
.toast.err { border-left-color: var(--amber); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }

@media (max-width: 720px) {
  .search input { width: 130px; } .search input:focus { width: 150px; }
  .filters { display: none; }
}
