:root {
  --bg: #0e1116;
  --panel: #171b22;
  --panel-2: #1e242d;
  --border: #2a313c;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2f81f7;
  --accent-hover: #4d95f9;
  --online: #3fb950;
  --offline: #6e7681;
  --danger: #f85149;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  transition: background 0.12s, border-color 0.12s;
}
button:hover { background: #262d38; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); }
button.danger { border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: rgba(248, 81, 73, 0.12); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input[type="password"], input[type="text"] {
  font: inherit;
  width: 100%;
  padding: 11px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
}
input:focus { outline: 2px solid var(--accent); border-color: var(--accent); }

/* ---- login ---- */
.center-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  width: 100%; max-width: 380px;
}
.card h1 { margin: 0 0 4px; font-size: 20px; }
.card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.field { margin-bottom: 14px; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }

/* ---- dashboard ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.topbar h1 { font-size: 17px; margin: 0; }
.container { max-width: 900px; margin: 0 auto; padding: 26px 20px; }
.device-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.device {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; cursor: pointer;
  transition: border-color 0.12s, transform 0.06s;
}
.device:hover { border-color: var(--accent); }
.device:active { transform: translateY(1px); }
.device.offline { cursor: default; opacity: 0.75; }
.device.offline:hover { border-color: var(--border); }
.device .name { font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.device .meta { color: var(--muted); font-size: 13px; margin-top: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.dot.online { background: var(--online); box-shadow: 0 0 0 3px rgba(63,185,80,0.18); }
.dot.offline { background: var(--offline); }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }

/* ---- viewer ---- */
.viewer-root { display: flex; flex-direction: column; height: 100vh; }
.viewer-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.viewer-bar .spacer { flex: 1; }
.viewer-bar .status { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.bar-select {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 7px 9px; cursor: pointer;
}
.viewer-bar button { padding: 7px 11px; font-size: 13px; }
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--border); color: var(--text);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; z-index: 20;
  opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.stage { flex: 1; background: #000; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
/* Show the local system cursor over the video. Because each mouse move is sent
   to the host as an absolute position, the local cursor sits exactly where the
   remote cursor is — an always-visible, lag-free pointer. */
#remote { max-width: 100%; max-height: 100%; outline: none; cursor: default; }
.stage.disconnected #remote { display: none; }
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 15px; text-align: center; padding: 20px; pointer-events: none;
}
.pill { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); }
.hud {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px; line-height: 1.5; color: #d6f5df;
  background: rgba(0,0,0,0.62); border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; padding: 8px 11px; pointer-events: none; white-space: pre;
}
